PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/1.0RC1/www/src/prepend.inc.php

http://scalr.googlecode.com/
PHP | 64 lines | 46 code | 12 blank | 6 comment | 16 complexity | d9d0967c527207e5b35b04aed7cd4be5 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. CONTEXTS::$APPCONTEXT = !stristr($_SERVER['PHP_SELF'], "event_handler.php") ? APPCONTEXT::CONTROL_PANEL : APPCONTEXT::EVENT_HANDLER;
  7. if (!defined("NO_AUTH"))
  8. {
  9. Core::load("Data/JSON/JSON.php");
  10. Core::load("XMLNavigation", dirname(__FILE__));
  11. define("NOW", str_replace("..","", substr(basename($_SERVER['PHP_SELF']),0, -4)));
  12. // Auth
  13. if ($_SESSION["uid"] == 0)
  14. $newhash = $Crypto->Hash(CONFIG::$ADMIN_LOGIN.":".CONFIG::$ADMIN_PASSWORD.":".$_SESSION["sault"]);
  15. else
  16. {
  17. $user = $db->GetRow("SELECT * FROM clients WHERE id=?", $_SESSION['uid']);
  18. $newhash = $Crypto->Hash("{$user['email']}:{$user['password']}:".$_SESSION["sault"]);
  19. }
  20. $valid = ($newhash == $_SESSION["hash"] && !empty($_SESSION["hash"]));
  21. if (!$valid && !stristr($_SERVER['PHP_SELF'], "login.php"))
  22. {
  23. $_SESSION["REQUEST_URI"] = $_SERVER['REQUEST_URI'];
  24. $mess = "Please login";
  25. UI::Redirect("/login.php");
  26. }
  27. //
  28. // Load menu
  29. //
  30. require_once (dirname(__FILE__)."/navigation.inc.php");
  31. if ($get_search)
  32. {
  33. $_POST["filter_q"] = $post_filter_q = $get_search;
  34. $_POST["Submit"] = $post_Submit = "Filter";
  35. $_POST["act"] = $post_act = "filter1";
  36. unset($_SESSION['filter']);
  37. }
  38. // title
  39. $display["title"] = "Control Panel";
  40. if ($_SESSION['uid'] != 0)
  41. {
  42. if (!$_SESSION["aws_accesskey"] ||
  43. !$_SESSION["aws_private_key"] ||
  44. !$_SESSION["aws_certificate"]
  45. ) {
  46. if (!stristr($_SERVER['PHP_SELF'], 'aws_settings.php') && !stristr($_SERVER['PHP_SELF'], 'login.php'))
  47. UI::Redirect("aws_settings.php");
  48. $errmsg = "Welcome to Scalr - in order to get started, we need some additional information. Please enter the reqested information below.";
  49. }
  50. }
  51. }
  52. ?>