PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/1.1.0/www/src/prepend.inc.php

http://scalr.googlecode.com/
PHP | 80 lines | 59 code | 14 blank | 7 comment | 21 complexity | 7554a54de05a8e4e9c4971be74b31f88 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0, GPL-3.0
  1. <?
  2. $ADM = true;
  3. session_start();
  4. require_once (dirname(__FILE__)."/../../src/prepend.inc.php");
  5. // Define current context
  6. if (!$context)
  7. CONTEXTS::$APPCONTEXT = !stristr($_SERVER['PHP_SELF'], "event_handler.php") ? APPCONTEXT::CONTROL_PANEL : APPCONTEXT::EVENT_HANDLER;
  8. else
  9. CONTEXTS::$APPCONTEXT = $context;
  10. if (!defined("NO_AUTH"))
  11. {
  12. Core::load("Data/JSON/JSON.php");
  13. Core::load("XMLNavigation", dirname(__FILE__));
  14. define("NOW", str_replace("..","", substr(basename($_SERVER['PHP_SELF']),0, -4)));
  15. // Auth
  16. if ($_SESSION["uid"] == 0)
  17. $newhash = $Crypto->Hash(CONFIG::$ADMIN_LOGIN.":".CONFIG::$ADMIN_PASSWORD.":".$_SESSION["sault"]);
  18. else
  19. {
  20. $user = $db->GetRow("SELECT * FROM clients WHERE id=?", $_SESSION['uid']);
  21. $newhash = $Crypto->Hash("{$user['email']}:{$user['password']}:".$_SESSION["sault"]);
  22. }
  23. $valid = ($newhash == $_SESSION["hash"] && !empty($_SESSION["hash"]));
  24. if (!$valid && !stristr($_SERVER['PHP_SELF'], "login.php"))
  25. {
  26. if (CONTEXTS::$APPCONTEXT != APPCONTEXT::AJAX_REQUEST)
  27. {
  28. $_SESSION["REQUEST_URI"] = $_SERVER['REQUEST_URI'];
  29. $mess = "Please login";
  30. UI::Redirect("/login.php");
  31. }
  32. else
  33. {
  34. throw new Exception(_("Session expired. Please <a href='/login.php'>login</a> again."));
  35. exit();
  36. }
  37. }
  38. //
  39. // Load menu
  40. //
  41. require_once (dirname(__FILE__)."/navigation.inc.php");
  42. if ($get_search)
  43. $display["grid_query_string"] = "&query={$get_search}";
  44. // title
  45. $display["title"] = "Scalr CP";
  46. if ($_SESSION['uid'] != 0)
  47. {
  48. if (!$_SESSION["aws_accesskey"] ||
  49. !$_SESSION["aws_private_key"] ||
  50. !$_SESSION["aws_certificate"]
  51. ) {
  52. if (!stristr($_SERVER['PHP_SELF'], 'aws_settings.php') &&
  53. !stristr($_SERVER['PHP_SELF'], 'login.php') &&
  54. !stristr($_SERVER['PHP_SELF'], 'profile.php')
  55. )
  56. UI::Redirect("aws_settings.php");
  57. $errmsg = "Welcome to Scalr - in order to get started, we need some additional information. Please enter the reqested information below.";
  58. }
  59. }
  60. }
  61. if ($req_region)
  62. $_SESSION['aws_region'] = $req_region;
  63. //TODO: Move default region to config
  64. if (!$_SESSION['aws_region'])
  65. $_SESSION['aws_region'] = 'us-east-1';
  66. ?>