--- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -1,317 +1,336 @@ - '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 "
"; - } -} - -function ucsmart($str) { - $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" - , "Of", "On", "Or", "The", "To", "With"); - $strArray = explode(" ", preg_replace("/(?<=(? $value) - $totale += array_sum_all($value); - return $totale; -} - -// magic query modifiers -$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); -if ($agency != "") - $agencyQ = "agencyName = '" . $agency . "' AND "; - -$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); -if ($supplier != "") { - $supplierParts = explode("-", $supplier); - $supplierName = "%" . $supplierParts[1] . "%"; - $supplierABN = $supplierParts[0]; - if ($supplierParts[0] > 0) - $supplierQ = ' "supplierABN" = :supplierABN AND '; - else - $supplierQ = ' "supplierName" LIKE :supplierName AND '; -} - -$startYear = 2007; -$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); -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; - ?> - - - - <?php echo $title; ?> - Contract Dashboard - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
-
' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . '
'; - - if (strpos($_SERVER['SERVER_NAME'], ".gs")) { - ?> - -
'; - } - - include ("graphs.inc.php"); - - - - - + array( + 'localhost' => array( + 'host' => '127.0.0.1', + 'port' => 8983, + 'path' => '/solr/contracts/', + ) + ) +); +// create a client instance +$solr_client = new Solarium\Client($config); + + +$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 '
'; + die(print_r($errMsg, true)); + echo "
"; + } +} + +function ucsmart($str) { + $shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" + , "Of", "On", "Or", "The", "To", "With"); + $strArray = explode(" ", preg_replace_callback("/(?<=(? $value) + $totale += array_sum_all($value); + return $totale; +} + +// magic query modifiers +$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); +if ($agency != "") + $agencyQ = "agencyName = '" . $agency . "' AND "; + +$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); +if ($supplier != "") { + $supplierParts = explode("-", $supplier); + $supplierName = "%" . $supplierParts[1] . "%"; + $supplierABN = $supplierParts[0]; + if ($supplierParts[0] > 0) + $supplierQ = ' "supplierABN" = :supplierABN AND '; + else + $supplierQ = ' "supplierName" ILIKE :supplierName AND '; +} + +$startYear = 2007; +$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); +if ($year != "") { + $yearQ = 'extract(year from "contractStart") = ' . $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; + ?> + + + + <?php echo $title; ?> - Contract Dashboard + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
'; + } + + include ("graphs.inc.php"); +