--- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -8,12 +8,57 @@ if (!$conn) { die("A database error occurred.\n"); +} + +define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME)); +if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) { + $basePath = "../"; +} + if (php_sapi_name() != "cli") { + +require $basePath."lib/amon-php/amon.php"; +Amon::config(array('address'=> 'http://127.0.0.1:2464', + 'protocol' => 'http', + 'secret_key' => "JBcSUdFOi5lK0vCjLjbHDpQamcBnRA4iV7QLaTADeDQ")); +Amon::setup_exception_handler(); + } + +require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; +$openid = new LightOpenID($_SERVER['HTTP_HOST']); +// you have to open the session to be able to modify or remove it +session_start(); +function login() { + global $openid; + if (!$openid->mode) { + $openid->required = array('contact/email'); + $openid->identity = 'https://www.google.com/accounts/o8/id'; + header('Location: ' . $openid->authUrl()); + } +} + +function auth() { + global $openid; + if ($_SESSION['authed'] == true) { + return true; + } + + if ($openid->mode) { + $attr = $openid->getAttributes(); + if ($attr['contact/email'] != 'maxious@gmail.com') { + die('Access Denied'); + } else { + $_SESSION['authed'] = true; + } + } else { + login(); + } } // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); function databaseError($errMsg) { if ($errMsg[2] != "") { echo '
'; + Amon::log(print_r($errMsg, true).print_r($_REQUEST, true).print_r($_SERVER, true), array('error')); die(print_r($errMsg, true)); echo "
"; } @@ -65,21 +110,45 @@ $startYear = 2007; $year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); -if ($year != "") +if ($year != "") { $yearQ = "YEAR(publishDate) = " . $year . " AND "; - +} $standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; $start = 0.0; + +function local_url() { + return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; +} function include_header($title) { global $start; ?> - - + + - Contract Dashboard - <?php echo $title; ?> + <?php echo $title; ?> - Contract Dashboard + -
  • tenderm
  • -
  • confidentiality
  • -
  • consultancies
  • -
  • amendments
  • -
  • geo
  • - + +
  • tenderm
  • +
  • confidentiality
  • +
  • consultancies
  • +
  • amendments
  • +
  • geo
  • - - -
    - - -
    - + + +
    + + +
    +
    - -
    - ' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '
    '; - } - - include ("graphs.inc.php"); - ?> +
    +
    + +
    +
    +
    '; + } + + include ("graphs.inc.php"); + + + +