From: Maxious Date: Sun, 12 Aug 2012 02:32:36 +0000 Subject: Merge branch 'master' of ssh://apples.lambdacomplex.org/git/contractdashboard X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=3bf6c34b764792d50d03d4456eb2484e9b1eafc5 --- Merge branch 'master' of ssh://apples.lambdacomplex.org/git/contractdashboard Conflicts: displayAgency.php --- --- a/admin/agency2portfolio.php +++ /dev/null @@ -1,42 +1,1 @@ - '', - 'advorgunitfield' => $agency, - 'advrolefield' => '', - 'advsection' => 'All', - 'advsurnamefield' => '', - 'search' => 'Submit Query' - )); - $results = curl_exec($c); - - if (preg_match('##smi', $results, $m)) { - $nextURL = $m[1]; - } else { - $cache[$agency] = false; return false; - } - - curl_setopt($c, CURLOPT_URL, 'http://www.directory.gov.au' . $nextURL); - curl_setopt($c, CURLOPT_HTTPGET, true); - curl_setopt($c, CURLOPT_REFERER, 'http://www.directory.gov.au/searchres.php'); - $results = curl_exec($c); - if (preg_match('#portfolios:\s+([^<]+)#ims', $results, $m)) { - $cache[$agency] = $m[1]; return $m[1]; - } else { - $cache[$agency] = false; return false; - } -} - -?> - --- a/admin/fixoldamend.php +++ b/admin/fixoldamend.php @@ -1,7 +1,8 @@ prepare($query); $result->execute(); @@ -37,4 +38,5 @@ echo "parent CN unexpected - $oldCN doesn't look like child of {$record['parentCN']}, rather the ID suggests child of $parentCN
\n"; } } +} --- a/admin/import.php +++ b/admin/import.php @@ -1,7 +1,8 @@ --- a/admin/importUNSPSC.php +++ b/admin/importUNSPSC.php @@ -1,5 +1,8 @@ $success records successfully created"; flush(); fclose($handle); +} ?> --- a/admin/linkAmendments.php +++ b/admin/linkAmendments.php @@ -1,5 +1,8 @@ prepare($query); $query->execute(); @@ -58,5 +61,6 @@ else print_r($errors); } } +} ?> --- a/admin/partialdata/import.php +++ b/admin/partialdata/import.php @@ -1,5 +1,6 @@ --- a/admin/partialdata/importamendments.php +++ b/admin/partialdata/importamendments.php @@ -1,5 +1,6 @@ --- a/admin/partialdata/scraper.txt +++ b/admin/partialdata/scraper.txt @@ -1,4 +1,5 @@ --- a/admin/setAgencyStatus.php +++ /dev/null @@ -1,26 +1,1 @@ -\n"; - else echo "error".mysql_error(); -} -foreach ($suspended as $agency) { - $agencyParts = explode("|",$agency); - $agency = $agencyParts[1]; - $agencyInsert = "INSERT INTO agency (agencyName) VALUES ('$agency')"; - $result = mysql_query($agencyInsert); - $result = mysql_query("UPDATE agency SET status = 'suspended' where agencyName = '".mysql_real_escape_string($agency)."';") ; - if ($result) echo $agency. " set to suspended in ". mysql_affected_rows() . " divisions/branches
\n"; - else echo "error".mysql_error(); -} -?> --- a/admin/setAgencyURLABN.php +++ /dev/null @@ -1,38 +1,1 @@ -"; - $result = $json->responseData->results[0]; - print_r($result); - echo ""; - echo " Agency: $agency"; - echo " URL: http://" . $result->visibleUrl; - preg_match('/\d{2} \d{3} \d{3} \d{3}/i', $result->content, $abn); - $abn[0] = str_replace(" ","",$abn[0]); - echo " ABN: {$abn[0]}"; - if ($abn[0] > 1000) { - $result = mysql_query("UPDATE agency SET website = 'http://" . $result->visibleUrl . "', abn = '{$abn[0]}' WHERE agencyName = '$agency';"); - if ($result) echo $agency . " set in " . mysql_affected_rows() . "
\n"; - } else { - - echo "invalid ABN"; - $result = mysql_query("UPDATE agency SET website = 'http://" . $result->visibleUrl . "' WHERE agencyName = '$agency';"); - if ($result) echo $agency . " set in " . mysql_affected_rows() . "
\n"; - } - // fi - -} -curl_close($ch); -?> + --- a/displayAgency.php +++ b/displayAgency.php @@ -3,11 +3,12 @@ include_once ("./lib/common.inc.php"); if ($_REQUEST['agency']) { - include_header("Agency"); $agency = htmlentities(strip_tags($_REQUEST['agency'])); - MethodCountGraph($agency); - CnCGraph($agency); - MethodValueGraph($agency); + include_header($agency); +echo '

'.$agency.'

'; +// MethodCountGraph($agency); + // CnCGraph($agency); + // MethodValueGraph($agency); /* biggest contracts spending by year spending by industry/category @@ -29,7 +30,7 @@ "contractStart", "supplierName" FROM contractnotice WHERE "agencyName" = :agency - ORDER BY "value" DESC'; + ORDER BY "value" DESC limit 100'; $query = $conn->prepare($query); $query->bindParam(":agency", $agency); $query->execute(); --- a/displayContract.php +++ b/displayContract.php @@ -1,7 +1,6 @@ prepare($query); $query->bindParam(":CNID", $_REQUEST['CNID']); $query->execute(); +$contractResult = $query->fetch(PDO::FETCH_ASSOC); +if (!$contractResult) { + header("Status: 404 Not Found"); + header("HTTP/1.0 404 Not Found"); +include_header("Contract Not Found"); + echo "

No Contract Notice with that ID found

"; databaseError($conn->errorInfo()); -foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { +} else { +$description = ucsmart($contractResult["description"]); +include_header($description); + echo '

'.$description.'

'; +databaseError($conn->errorInfo()); setlocale(LC_MONETARY, 'en_US'); - foreach (array_filter($row) as $key => $value) { + foreach (array_filter($contractResult) as $key => $value) { echo "$key "; switch ($key) { case "supplierName": case "supplierABN": - echo '' . $value . ""; + echo '' . $value . ""; break; case "agencyName": echo '' . $value . ""; @@ -26,15 +35,14 @@ echo "$" . number_format(doubleval($value), 2); break; default: - echo str_replace(" ", "
", $value); + echo str_replace(" ", "
", ucsmart($value)); } echo "
"; } -} echo '
View original record @ tenders.gov.au
'; -$query = 'SELECT * FROM `heuristic_results` where "CNID" = :CNID'; +$query = 'SELECT * FROM heuristic_results where "CNID" = :CNID'; $query = $conn->prepare($query); $agencyName = $input . '%'; $query->bindParam(":CNID", $_REQUEST['CNID']); @@ -43,7 +51,7 @@ foreach ($query->fetchAll() as $r) { echo "{$r['heuristic_name']}: {$r['heuristic_value']} (raw value: {$r['raw_value']}, mean: {$r['mean']}, stddev: {$r['stddev']})
"; } - +} include_footer(); ?> --- a/displaySupplier.php +++ b/displaySupplier.php @@ -3,8 +3,10 @@ include_once ("./lib/common.inc.php"); if ($_REQUEST['supplier']) { - include_header("Supplier"); $supplierS = htmlentities(strip_tags($_REQUEST['supplier'])); + include_header(str_replace("%","",$supplierName)); +echo '

'.str_replace("%","",$supplierName).'

'; + // MethodCountGraph($supplierS); // CnCGraph($supplierS); // MethodValueGraph($supplierS); --- a/futureindex.php +++ /dev/null @@ -1,12 +1,1 @@ - -

Hello, world!

-

Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

-

Learn more »

- '; -include_footer(); -?> - --- /dev/null +++ b/google676a414ad086cefb.html @@ -1,1 +1,2 @@ +google-site-verification: google676a414ad086cefb.html --- a/heuristics/metadataHeuristics.php +++ b/heuristics/metadataHeuristics.php @@ -1,7 +1,7 @@ 1 order by count */ /*- duplicated description @@ -48,7 +48,7 @@ { $query = "select avg(count),STDDEV(count) from ( SELECT description, count(*) as count -FROM `contractnotice` +FROM contractnotice group by description having count > 1 ) as a;"; $result = $conn->query($query); --- a/heuristics/runHeuristics.php +++ b/heuristics/runHeuristics.php @@ -1,4 +1,8 @@ --- a/heuristics/viewHeuristicsDistribution.php +++ b/heuristics/viewHeuristicsDistribution.php @@ -2,7 +2,7 @@ /*// most interesting SELECT sum(heuristic_value) as sum, CNID -FROM `heuristic_results` group by CNID order by sum DESC limit 30 +FROM heuristic_results group by CNID order by sum DESC limit 30 // spread of values select floor(sum) as val,count(*) from (SELECT sum(heuristic_value) --- /dev/null +++ b/index.php @@ -1,1 +1,12 @@ + +

Hello, world!

+

Vestibulum id ligula porta felis euismod semper. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.

+

Learn more »

+ '; +include_footer(); +?> + --- a/lib/common.inc.php +++ b/lib/common.inc.php @@ -8,6 +8,41 @@ if (!$conn) { die("A database error occurred.\n"); +} + +define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME)); +if (strstr($_SERVER['PHP_SELF'], "labs/")) { + $basePath = "../"; +} + +require ROOT . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'openid.php'; +$openid = new LightOpenID($_SERVER['HTTP_HOST']); + +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); @@ -70,7 +105,9 @@ $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; ?> @@ -104,14 +141,14 @@ @import "media/css/demo_table.css"; - +