From: Maxious Date: Sat, 11 Aug 2012 10:40:08 +0000 Subject: Add openid security X-Git-Url: https://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=ee3b8843ace8c9395ea09f3c936c4f9365a7cb79 --- Add openid security --- --- 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/displayContract.php +++ b/displayContract.php @@ -34,7 +34,7 @@ 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']); --- 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(); -?> - --- 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); @@ -104,14 +139,14 @@ @import "media/css/demo_table.css"; - +