<?php |
<?php |
date_default_timezone_set("Australia/ACT"); |
date_default_timezone_set("Australia/ACT"); |
|
|
error_reporting(E_ALL ^ E_NOTICE); |
error_reporting(E_ALL ^ E_NOTICE); |
|
|
|
|
$conn = new PDO("pgsql:dbname=contractDashboard;user=postgres;password=snmc;host=localhost"); |
$conn = new PDO("pgsql:dbname=contractdashboard;user=postgres;password=snmc;host=localhost"); |
|
|
if (!$conn) { |
if (!$conn) { |
die("A database error occurred.\n"); |
die("A database error occurred.\n"); |
} |
} |
|
|
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME)); |
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME)); |
if (strstr($_SERVER['PHP_SELF'], "labs/")) { |
if (strstr($_SERVER['PHP_SELF'], "labs/") || strstr($_SERVER['PHP_SELF'], "admin/") || strstr($_SERVER['PHP_SELF'], "heuristics/")) { |
$basePath = "../"; |
$basePath = "../"; |
} |
} |
|
/*require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; |
require ROOT . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'openid.php'; |
require(ROOT.'/solarium/vendor/autoload.php'); |
$openid = new LightOpenID($_SERVER['HTTP_HOST']); |
require(ROOT.'/solarium/library/Solarium/Autoloader.php'); |
|
Solarium\Autoloader::register(); |
function login() { |
// check solarium version available |
global $openid; |
//echo 'Solarium library version: ' . Solarium\Client::VERSION . ' - '; |
if (!$openid->mode) { |
$config = array( |
$openid->required = array('contact/email'); |
'endpoint' => array( |
$openid->identity = 'https://www.google.com/accounts/o8/id'; |
'localhost' => array( |
header('Location: ' . $openid->authUrl()); |
'host' => '127.0.0.1', |
} |
'port' => 8983, |
} |
'path' => '/solr/contracts/', |
|
) |
function auth() { |
) |
global $openid; |
); |
if ($_SESSION['authed'] == true) { |
// create a client instance |
return true; |
$solr_client = new Solarium\Client($config); |
} |
|
|
|
if ($openid->mode) { |
$openid = new LightOpenID($_SERVER['HTTP_HOST']); |
$attr = $openid->getAttributes(); |
// you have to open the session to be able to modify or remove it |
if ($attr['contact/email'] != 'maxious@gmail.com') { |
session_start(); |
die('Access Denied'); |
function login() { |
} else { |
global $openid; |
$_SESSION['authed'] = true; |
if (!$openid->mode) { |
} |
$openid->required = array('contact/email'); |
} else { |
$openid->identity = 'https://www.google.com/accounts/o8/id'; |
login(); |
header('Location: ' . $openid->authUrl()); |
} |
} |
} |
} |
|
|
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
function auth() { |
function databaseError($errMsg) { |
global $openid; |
if ($errMsg[2] != "") { |
if ($_SESSION['authed'] == true) { |
echo '<div class="alert-message error">'; |
return true; |
die(print_r($errMsg, true)); |
} |
echo "</div>"; |
|
} |
if ($openid->mode) { |
} |
$attr = $openid->getAttributes(); |
|
if ($attr['contact/email'] != 'maxious@gmail.com') { |
function ucsmart($str) { |
die('Access Denied'); |
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
} else { |
, "Of", "On", "Or", "The", "To", "With"); |
$_SESSION['authed'] = true; |
$strArray = explode(" ", preg_replace("/(?<=(?<!:|’s)\W) |
} |
(A|An|And|At|For|In|Of|On|Or|The|To|With) |
} else { |
(?=\W)/e", 'strtolower("$1")', ucwords(strtolower($str)))); |
login(); |
foreach ($strArray as &$word) { |
} |
if (strlen($word) <= 4 && !in_array($word, $shortWords)) |
}*/ |
$word = strtoupper($word); |
|
} |
// $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
return implode(" ", $strArray); |
function databaseError($errMsg) { |
} |
if ($errMsg[2] != "") { |
|
echo '<div class="alert-message error">'; |
function percent($num_amount, $num_total) { |
die(print_r($errMsg, true)); |
$count1 = $num_amount / $num_total; |
echo "</div>"; |
$count2 = $count1 * 100; |
} |
$count = number_format($count2, 2); |
} |
return $count; |
|
} |
function ucsmart($str) { |
|
$shortWords = Array("The", "Pty", "Ltd", "Inc", "Red", "Oil", "A", "An", "And", "At", "For", "In" |
function array_sum_all($a) { |
, "Of", "On", "Or", "The", "To", "With"); |
if (!is_array($a)) |
$strArray = explode(" ", preg_replace_callback("/(?<=(?<!:|’s)\W) |
return $a; |
(A|An|And|At|For|In|Of|On|Or|The|To|With) |
foreach ($a as $key => $value) |
(?=\W)/", |
$totale += array_sum_all($value); |
function($matches) { return strtolower($matches[1]); } , ucwords(strtolower($str)))); |
return $totale; |
foreach ($strArray as &$word) { |
} |
if (strlen($word) <= 4 && !in_array($word, $shortWords)) |
|
$word = strtoupper($word); |
// magic query modifiers |
} |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
return implode(" ", $strArray); |
if ($agency != "") |
} |
$agencyQ = "agencyName = '" . $agency . "' AND "; |
|
|
function percent($num_amount, $num_total) { |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
$count1 = $num_amount / $num_total; |
if ($supplier != "") { |
$count2 = $count1 * 100; |
$supplierParts = explode("-", $supplier); |
$count = number_format($count2, 2); |
$supplierName = "%" . $supplierParts[1] . "%"; |
return $count; |
$supplierABN = $supplierParts[0]; |
} |
if ($supplierParts[0] > 0) |
|
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
function array_sum_all($a) { |
else |
if (!is_array($a)) |
$supplierQ = ' "supplierName" LIKE :supplierName AND '; |
return $a; |
} |
$totale = 0; |
|
foreach ($a as $key => $value) |
$startYear = 2007; |
$totale += array_sum_all($value); |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
return $totale; |
if ($year != "") { |
} |
$yearQ = "YEAR(publishDate) = " . $year . " AND "; |
|
} |
// magic query modifiers |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
$agency = filter_var($_REQUEST['agency'], FILTER_SANITIZE_STRING); |
$start = 0.0; |
if ($agency != "") |
|
$agencyQ = "agencyName = '" . $agency . "' AND "; |
function local_url() { |
|
return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; |
$supplier = filter_var($_REQUEST['supplier'], FILTER_SANITIZE_STRING); |
} |
if ($supplier != "") { |
|
$supplierParts = explode("-", $supplier); |
function include_header($title) { |
$supplierName = "%" . $supplierParts[1] . "%"; |
global $start; |
$supplierABN = $supplierParts[0]; |
?> |
if ($supplierParts[0] > 0) |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
$supplierQ = ' "supplierABN" = :supplierABN AND '; |
"http://www.w3.org/TR/html4/strict.dtd"> |
else |
<html> |
$supplierQ = ' "supplierName" ILIKE :supplierName AND '; |
<head> |
} |
<title><?php echo $title; ?> - Contract Dashboard</title> |
|
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
$startYear = 2007; |
<link rel="stylesheet" type="text/css" href="bootstrap-responsive.css"> |
$year = filter_var($_REQUEST['year'], FILTER_SANITIZE_NUMBER_INT); |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
if ($year != "") { |
<!--[if lt IE 9]> |
$yearQ = 'extract(year from "contractStart") = ' . $year . " AND "; |
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
} |
<![endif]--> |
$standardQ = ' "childCN" is null '; // AND YEAR(contractStart) >= 2007 AND YEAR(contractStart) <= 2010'; |
<script type="text/javascript" src="lib/bsn.AutoSuggest_2.1.3_comp.js" charset="utf-8"></script> |
$start = 0.0; |
<link rel="stylesheet" href="autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> |
|
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
function local_url() { |
<script type="text/javascript"> |
return "http://" . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/"; |
$(document).ready(function() |
} |
{ |
|
//hide the all of the element with class msg_body |
function include_header($title) { |
$(".msg_body").hide(); |
global $start; |
//toggle the componenet with class msg_body |
?> |
$(".msg_head").click(function() |
<!DOCTYPE html> |
{ |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" version="XHTML+RDFa 1.1" |
$(this).next(".msg_body").slideToggle(600); |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
}); |
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" |
}); |
xmlns:gr="http://purl.org/goodrelations/v1#" |
</script> |
xmlns:dc="http://purl.org/dc/terms/" |
|
xmlns:pc="http://purl.org/procurement#" |
<style type="text/css" title="currentStyle"> |
xmlns:unspsc="http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml#" |
@import "media/css/demo_table.css"; |
xmlns:xsd="http://www.w3.org/2001/XMLSchema#" |
</style> |
xmlns:pcdt="http://purl.org/procurement/public-contracts-datatypes#" |
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script> |
prefix="rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# |
<script type="text/javascript" language="javascript" src="lib/bootstrap-dropdown.js"></script> |
rdfs: http://www.w3.org/2000/01/rdf-schema# |
<script type="text/javascript" charset="utf-8"> |
gr: http://purl.org/goodrelations/v1# |
jQuery.fn.dataTableExt.aTypes.unshift( |
dcterms: http://purl.org/dc/terms/ |
function ( sData ) |
pc: http://purl.org/procurement/public-contracts# |
{ |
cpv: http://purl.org/weso/pscs/cpv/2008/resource/ |
var sValidChars = "0123456789.-,"; |
unspsc: http://www.ksl.stanford.edu/projects/DAML/UNSPSC.daml# |
var Char; |
v: http://www.w3.org/2006/vcard/ns# |
|
payment: http://reference.data.gov.uk/def/payment# |
/* Check the numeric part */ |
br: http://purl.org/business-register# |
for ( i=1 ; i<sData.length ; i++ ) |
xsd: http://www.w3.org/2001/XMLSchema# |
{ |
pcdt: http://purl.org/procurement/public-contracts-datatypes#"> |
Char = sData.charAt(i); |
<head> |
if (sValidChars.indexOf(Char) == -1) |
<title><?php echo $title; ?> - Contract Dashboard</title> |
{ |
<link rel="stylesheet" type="text/css" href="bootstrap.min.css"> |
return null; |
<link rel="stylesheet" type="text/css" href="bootstrap-responsive.css"> |
} |
<!-- Le HTML5 shim, for IE6-8 support of HTML elements --> |
} |
<!--[if lt IE 9]> |
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> |
/* Check prefixed by currency */ |
<![endif]--> |
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
<script type="text/javascript" src="lib/bsn.AutoSuggest_2.1.3_comp.js" charset="utf-8"></script> |
{ |
<link rel="stylesheet" href="autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> |
return 'currency'; |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> |
} |
<script type="text/javascript"> |
return null; |
$(document).ready(function() |
} |
{ |
); |
//hide the all of the element with class msg_body |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
$(".msg_body").hide(); |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
//toggle the componenet with class msg_body |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
$(".msg_head").click(function() |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
{ |
|
$(this).next(".msg_body").slideToggle(600); |
/* Remove the currency sign */ |
}); |
x = x.substring( 1 ); |
}); |
y = y.substring( 1 ); |
</script> |
|
|
/* Parse and return */ |
<style type="text/css" title="currentStyle"> |
x = parseFloat( x ); |
@import "media/css/demo_table.css"; |
y = parseFloat( y ); |
</style> |
return x - y; |
<script type="text/javascript" language="javascript" src="media/js/jquery.dataTables.js"></script> |
}; |
<script type="text/javascript" language="javascript" src="lib/bootstrap-dropdown.js"></script> |
|
<script type="text/javascript" charset="utf-8"> |
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
jQuery.fn.dataTableExt.aTypes.unshift( |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
function ( sData ) |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
{ |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
var sValidChars = "0123456789.-,"; |
|
var Char; |
/* Remove the currency sign */ |
|
x = x.substring( 1 ); |
/* Check the numeric part */ |
y = y.substring( 1 ); |
for ( i=1 ; i<sData.length ; i++ ) |
|
{ |
/* Parse and return */ |
Char = sData.charAt(i); |
x = parseFloat( x ); |
if (sValidChars.indexOf(Char) == -1) |
y = parseFloat( y ); |
{ |
return y - x; |
return null; |
}; |
} |
$(document).ready(function() { |
} |
$('table').dataTable(); |
|
} ); |
/* Check prefixed by currency */ |
</script> |
if ( sData.charAt(0) == '$' || sData.charAt(0) == '£' ) |
<link type="text/css" rel="stylesheet" href="style.css"> |
{ |
</head> |
return 'currency'; |
<body> |
} |
<div class="navbar"> |
return null; |
<div class="navbar-inner"> |
} |
<div class="container-fluid"> |
); |
<a class="brand" href="#">contract dashboard</a> |
jQuery.fn.dataTableExt.oSort['currency-asc'] = function(a,b) { |
<ul class="nav"> |
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
<li><a href="displayAgency.php">agencies</a></li> |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
<li><a href="displaySupplier.php">suppliers</a></li> |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
<li><a href="displayCategory.php">categories</a></li> |
|
<li><a href="displayCalendar.php">time periods</a></li> |
/* Remove the currency sign */ |
<!-- <li class="dropdown"> |
x = x.substring( 1 ); |
<a href="#" class="dropdown-toggle">metrics</a> |
y = y.substring( 1 ); |
<ul class="dropdown-menu">--> |
|
<li><a href="displayProcurementMethod.php">tenderm</a></li> |
/* Parse and return */ |
<li><a href="displayConfidentialities.php">confidentiality</a></li> |
x = parseFloat( x ); |
<li><a href="displayConsultancies.php">consultancies</a></li> |
y = parseFloat( y ); |
<li><a href="displayAmendments.php">amendments</a></li> |
return x - y; |
<li><a href="displayMap.php">geo</a></li> |
}; |
</ul> |
|
|
jQuery.fn.dataTableExt.oSort['currency-desc'] = function(a,b) { |
|
/* Remove any commas (assumes that if present all strings will have a fixed number of d.p) */ |
<form method="post" action="search.php" class="pull-right"> |
var x = a == "-" ? 0 : a.replace( /,/g, "" ); |
<input type="text" id="searchKeyword" name="searchKeyword" value="" placeholder="Search" /> |
var y = b == "-" ? 0 : b.replace( /,/g, "" ); |
<input type="hidden" id="searchID" name="searchID" value=""/> |
|
</form> |
/* Remove the currency sign */ |
|
x = x.substring( 1 ); |
</div> |
y = y.substring( 1 ); |
</div><!-- /topbar-inner --> |
|
</div><!-- /topbar --> |
/* Parse and return */ |
</div><!-- /topbar-wrapper --> |
x = parseFloat( x ); |
<script type="text/javascript"> |
y = parseFloat( y ); |
|
return y - x; |
var options_xml = { |
}; |
script: function (input) { return "search_autosuggest.php?input="+input; }, |
$(document).ready(function() { |
varname:"input", |
$('table').dataTable(); |
callback: function (obj) { document.getElementById('searchID').value = obj.id; } |
} ); |
}; |
</script> |
var as_xml = new bsn.AutoSuggest('searchKeyword', options_xml); |
<link type="text/css" rel="stylesheet" href="style.css"> |
</script> |
</head> |
<div class="container-fluid"> |
<body> |
<div class="row-fluid"> |
<div class="navbar"> |
<div class="span3"> |
<div class="navbar-inner"> |
<div class="well sidebar-nav"> |
<div class="container-fluid"> |
<li class="nav-header">Filter by:</li> |
<a class="brand" href="#">contract dashboard</a> |
<li>2008</li> |
<ul class="nav"> |
</div> |
<li><a href="displayAgency.php">agencies</a></li> |
</div> |
<li><a href="displaySupplier.php">suppliers</a></li> |
<div class="span9"> |
<li><a href="displaySON.php">standing offers</a></li> |
<?php |
<li><a href="displayCategory.php">categories</a></li> |
$start = (float) array_sum(explode(' ', microtime())); |
<li><a href="displayCalendar.php">dates</a></li> |
} |
<li><a href="displayProcurementMethod.php">tenderm</a></li> |
|
<li><a href="displayConfidentialities.php">confidentiality</a></li> |
function include_footer() { |
<li><a href="displayConsultancies.php">consultancies</a></li> |
global $start; |
<li><a href="displayAmendments.php">amendments</a></li> |
$end = (float) array_sum(explode(' ', microtime())); |
<li><a href="displayMap.php">geo</a></li> |
|
</ul> |
echo '</div> <footer>' . "Processing time: " . sprintf("%.4f", ($end - $start)) . " seconds" . ' <footer>'; |
|
|
|
if (strpos($_SERVER['SERVER_NAME'], ".gs")) { |
<form method="get" action="search.php" class="pull-right"> |
?> |
<input type="text" id="searchKeyword" name="searchKeyword" value="" placeholder="Search" /> |
<script type="text/javascript"> |
<input type="hidden" id="searchID" name="searchID" value=""/> |
|
</form> |
var _gaq = _gaq || []; |
|
_gaq.push(['_setAccount', 'UA-12341040-3']); |
</div> |
_gaq.push(['_trackPageview']); |
</div><!-- /topbar-inner --> |
|
</div><!-- /topbar --> |
(function() { |
</div><!-- /topbar-wrapper --> |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
<script type="text/javascript"> |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
|
var s = document.getElementsByTagName('script')[ |