From: Maxious Date: Tue, 21 Aug 2012 01:20:03 +0000 Subject: Add Google Analytics X-Git-Url: http://maxious.lambdacomplex.org/git/?p=contractdashboard.git&a=commitdiff&h=56097201cec4f490fcd2038aaf80c98d58a5cdd1 --- Add Google Analytics --- --- 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 @@ exec("update datasets set \"lastUpdated\" = NOW() where title = 'Contract Notices'"); // cn echo "link amend
"; include ("linkAmendments.php"); @@ -194,5 +197,6 @@ //include ("setAgencyStatus.php"); //include ("setAgencyURLABN.php"); } +} ?> --- 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,6 +105,10 @@ $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 +143,14 @@ @import "media/css/demo_table.css"; - + + '; + } + + include ("graphs.inc.php"); + + + + --- /dev/null +++ b/lib/openid-php/Auth/OpenID/Consumer.php @@ -1,1 +1,2235 @@ - + + * @copyright 2005-2008 Janrain, Inc. + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache + */ + +/** + * Require utility classes and functions for the consumer. + */ +require_once "Auth/OpenID.php"; +require_once "Auth/OpenID/Message.php"; +require_once "Auth/OpenID/HMAC.php"; +require_once "Auth/OpenID/Association.php"; +require_once "Auth/OpenID/CryptUtil.php"; +require_once "Auth/OpenID/DiffieHellman.php"; +require_once "Auth/OpenID/KVForm.php"; +require_once "Auth/OpenID/Nonce.php"; +require_once "Auth/OpenID/Discover.php"; +require_once "Auth/OpenID/URINorm.php"; +require_once "Auth/Yadis/Manager.php"; +require_once "Auth/Yadis/XRI.php"; + +/** + * This is the status code returned when the complete method returns + * successfully. + */ +define('Auth_OpenID_SUCCESS', 'success'); + +/** + * Status to indicate cancellation of OpenID authentication. + */ +define('Auth_OpenID_CANCEL', 'cancel'); + +/** + * This is the status code completeAuth returns when the value it + * received indicated an invalid login. + */ +define('Auth_OpenID_FAILURE', 'failure'); + +/** + * This is the status code completeAuth returns when the + * {@link Auth_OpenID_Consumer} instance is in immediate mode, and the + * identity server sends back a URL to send the user to to complete his + * or her login. + */ +define('Auth_OpenID_SETUP_NEEDED', 'setup needed'); + +/** + * This is the status code beginAuth returns when the page fetched + * from the entered OpenID URL doesn't contain the necessary link tags + * to function as an identity page. + */ +define('Auth_OpenID_PARSE_ERROR', 'parse error'); + +/** + * An OpenID consumer implementation that performs discovery and does + * session management. See the Consumer.php file documentation for + * more information. + * + * @package OpenID + */ +class Auth_OpenID_Consumer { + + /** + * @access private + */ + var $discoverMethod = 'Auth_OpenID_discover'; + + /** + * @access private + */ + var $session_key_prefix = "_openid_consumer_"; + + /** + * @access private + */ + var $_token_suffix = "last_token"; + + /** + * Initialize a Consumer instance. + * + * You should create a new instance of the Consumer object with + * every HTTP request that handles OpenID transactions. + * + * @param Auth_OpenID_OpenIDStore $store This must be an object + * that implements the interface in {@link + * Auth_OpenID_OpenIDStore}. Several concrete implementations are + * provided, to cover most common use cases. For stores backed by + * MySQL, PostgreSQL, or SQLite, see the {@link + * Auth_OpenID_SQLStore} class and its sublcasses. For a + * filesystem-backed store, see the {@link Auth_OpenID_FileStore} + * module. As a last resort, if it isn't possible for the server + * to store state at all, an instance of {@link + * Auth_OpenID_DumbStore} can be used. + * + * @param mixed $session An object which implements the interface + * of the {@link Auth_Yadis_PHPSession} class. Particularly, this + * object is expected to have these methods: get($key), set($key), + * $value), and del($key). This defaults to a session object + * which wraps PHP's native session machinery. You should only + * need to pass something here if you have your own sessioning + * implementation. + * + * @param str $consumer_cls The name of the class to instantiate + * when creating the internal consumer object. This is used for + * testing. + */ + function Auth_OpenID_Consumer($store, $session = null, + $consumer_cls = null) + { + if ($session === null) { + $session = new Auth_Yadis_PHPSession(); + } + + $this->session = $session; + + if ($consumer_cls !== null) { + $this->consumer = new $consumer_cls($store); + } else { + $this->consumer = new Auth_OpenID_GenericConsumer($store); + } + + $this->_token_key = $this->session_key_prefix . $this->_token_suffix; + } + + /** + * Used in testing to define the discovery mechanism. + * + * @access private + */ + function getDiscoveryObject($session, $openid_url, + $session_key_prefix) + { + return new Auth_Yadis_Discovery($session, $openid_url, + $session_key_prefix); + } + + /** + * Start the OpenID authentication process. See steps 1-2 in the + * overview at the top of this file. + * + * @param string $user_url Identity URL given by the user. This + * method performs a textual transformation of the URL to try and + * make sure it is normalized. For example, a user_url of + * example.com will be normalized to http://example.com/ + * normalizing and resolving any redirects the server might issue. + * + * @param bool $anonymous True if the OpenID request is to be sent + * to the server without any identifier information. Use this + * when you want to transport data but don't want to do OpenID + * authentication with identifiers. + * + * @return Auth_OpenID_AuthRequest $auth_request An object + * containing the discovered information will be returned, with a + * method for building a redirect URL to the server, as described + * in step 3 of the overview. This object may also be used to add + * extension arguments to the request, using its 'addExtensionArg' + * method. + */ + function begin($user_url, $anonymous=false) + { + $openid_url = $user_url; + + $disco = $this->getDiscoveryObject($this->session, + $openid_url, + $this->session_key_prefix); + + // Set the 'stale' attribute of the manager. If discovery + // fails in a fatal way, the stale flag will cause the manager + // to be cleaned up next time discovery is attempted. + + $m = $disco->getManager(); + $loader = new Auth_Yadis_ManagerLoader(); + + if ($m) { + if ($m->stale) { + $disco->destroyManager(); + } else { + $m->stale = true; + $disco->session->set($disco->session_key, + serialize($loader->toSession($m))); + } + } + + $endpoint = $disco->getNextService($this->discoverMethod, + $this->consumer->fetcher); + + // Reset the 'stale' attribute of the manager. + $m = $disco->getManager(); + if ($m) { + $m->stale = false; + $disco->session->set($disco->session_key, + serialize($loader->toSession($m))); + } + + if ($endpoint === null) { + return null; + } else { + return $this->beginWithoutDiscovery($endpoint, + $anonymous); + } + } + + /** + * Start OpenID verification without doing OpenID server + * discovery. This method is used internally by Consumer.begin + * after discovery is performed, and exists to provide an + * interface for library users needing to perform their own + * discovery. + * + * @param Auth_OpenID_ServiceEndpoint $endpoint an OpenID service + * endpoint descriptor. + * + * @param bool anonymous Set to true if you want to perform OpenID + * without identifiers. + * + * @return Auth_OpenID_AuthRequest $auth_request An OpenID + * authentication request object. + */ + function beginWithoutDiscovery($endpoint, $anonymous=false) + { + $loader = new Auth_OpenID_ServiceEndpointLoader(); + $auth_req = $this->consumer->begin($endpoint); + $this->session->set($this->_token_key, + $loader->toSession($auth_req->endpoint)); + if (!$auth_req->setAnonymous($anonymous)) { + return new Auth_OpenID_FailureResponse(null, + "OpenID 1 requests MUST include the identifier " . + "in the request."); + } + return $auth_req; + } + + /** + * Called to interpret the server's response to an OpenID + * request. It is called in step 4 of the flow described in the + * consumer overview. + * + * @param string $current_url The URL used to invoke the application. + * Extract the URL from your application's web + * request framework and specify it here to have it checked + * against the openid.current_url value in the response. If + * the current_url URL check fails, the status of the + * completion will be FAILURE. + * + * @param array $query An array of the query parameters (key => + * value pairs) for this HTTP request. Defaults to null. If + * null, the GET or POST data are automatically gotten from the + * PHP environment. It is only useful to override $query for + * testing. + * + * @return Auth_OpenID_ConsumerResponse $response A instance of an + * Auth_OpenID_ConsumerResponse subclass. The type of response is + * indicated by the status attribute, which will be one of + * SUCCESS, CANCEL, FAILURE, or SETUP_NEEDED. + */ + function complete($current_url, $query=null) + { + if ($current_url && !is_string($current_url)) { + // This is ugly, but we need to complain loudly when + // someone uses the API incorrectly. + trigger_error("current_url must be a string; see NEWS file " . + "for upgrading notes.", + E_USER_ERROR); + } + + if ($query === null) { + $query = Auth_OpenID::getQuery(); + } + + $loader = new Auth_OpenID_ServiceEndpointLoader(); + $endpoint_data = $this->session->get($this->_token_key); + $endpoint = + $loader->fromSession($endpoint_data); + + $message = Auth_OpenID_Message::fromPostArgs($query); + $response = $this->consumer->complete($message, $endpoint, + $current_url); + $this->session->del($this->_token_key); + + if (in_array($response->status, array(Auth_OpenID_SUCCESS, + Auth_OpenID_CANCEL))) { + if ($response->identity_url !== null) { + $disco = $this->getDiscoveryObject($this->session, + $response->identity_url, + $this->session_key_prefix); + $disco->cleanup(true); + } + } + + return $response; + } +} + +/** + * A class implementing HMAC/DH-SHA1 consumer sessions. + * + * @package OpenID + */ +class Auth_OpenID_DiffieHellmanSHA1ConsumerSession { + var $session_type = 'DH-SHA1'; + var $hash_func = 'Auth_OpenID_SHA1'; + var $secret_size = 20; + var $allowed_assoc_types = array('HMAC-SHA1'); + + function Auth_OpenID_DiffieHellmanSHA1ConsumerSession($dh = null) + { + if ($dh === null) { + $dh = new Auth_OpenID_DiffieHellman(); + } + + $this->dh = $dh; + } + + function getRequest() + { + $math = Auth_OpenID_getMathLib(); + + $cpub = $math->longToBase64($this->dh->public); + + $args = array('dh_consumer_public' => $cpub); + + if (!$this->dh->usingDefaultValues()) { + $args = array_merge($args, array( + 'dh_modulus' => + $math->longToBase64($this->dh->mod), + 'dh_gen' => + $math->longToBase64($this->dh->gen))); + } + + return $args; + } + + function extractSecret($response) + { + if (!$response->hasKey(Auth_OpenID_OPENID_NS, + 'dh_server_public')) { + return null; + } + + if (!$response->hasKey(Auth_OpenID_OPENID_NS, + 'enc_mac_key')) { + return null; + } + + $math = Auth_OpenID_getMathLib(); + + $spub = $math->base64ToLong($response->getArg(Auth_OpenID_OPENID_NS, + 'dh_server_public')); + $enc_mac_key = base64_decode($response->getArg(Auth_OpenID_OPENID_NS, + 'enc_mac_key')); + + return $this->dh->xorSecret($spub, $enc_mac_key, $this->hash_func); + } +} + +/** + * A class implementing HMAC/DH-SHA256 consumer sessions. + * + * @package OpenID + */ +class Auth_OpenID_DiffieHellmanSHA256ConsumerSession extends + Auth_OpenID_DiffieHellmanSHA1ConsumerSession { + var $session_type = 'DH-SHA256'; + var $hash_func = 'Auth_OpenID_SHA256'; + var $secret_size = 32; + var $allowed_assoc_types = array('HMAC-SHA256'); +} + +/** + * A class implementing plaintext consumer sessions. + * + * @package OpenID + */ +class Auth_OpenID_PlainTextConsumerSession { + var $session_type = 'no-encryption'; + var $allowed_assoc_types = array('HMAC-SHA1', 'HMAC-SHA256'); + + function getRequest() + { + return array(); + } + + function extractSecret($response) + { + if (!$response->hasKey(Auth_OpenID_OPENID_NS, 'mac_key')) { + return null; + } + + return base64_decode($response->getArg(Auth_OpenID_OPENID_NS, + 'mac_key')); + } +} + +/** + * Returns available session types. + */ +function Auth_OpenID_getAvailableSessionTypes() +{ + $types = array( + 'no-encryption' => 'Auth_OpenID_PlainTextConsumerSession', + 'DH-SHA1' => 'Auth_OpenID_DiffieHellmanSHA1ConsumerSession', + 'DH-SHA256' => 'Auth_OpenID_DiffieHellmanSHA256ConsumerSession'); + + return $types; +} + +/** + * This class is the interface to the OpenID consumer logic. + * Instances of it maintain no per-request state, so they can be + * reused (or even used by multiple threads concurrently) as needed. + * + * @package OpenID + */ +class Auth_OpenID_GenericConsumer { + /** + * @access private + */ + var $discoverMethod = 'Auth_OpenID_discover'; + + /** + * This consumer's store object. + */ + var $store; + + /** + * @access private + */ + var $_use_assocs; + + /** + * @access private + */ + var $openid1_nonce_query_arg_name = 'janrain_nonce'; + + /** + * Another query parameter that gets added to the return_to for + * OpenID 1; if the user's session state is lost, use this claimed + * identifier to do discovery when verifying the response. + */ + var $openid1_return_to_identifier_name = 'openid1_claimed_id'; + + /** + * This method initializes a new {@link Auth_OpenID_Consumer} + * instance to access the library. + * + * @param Auth_OpenID_OpenIDStore $store This must be an object + * that implements the interface in {@link Auth_OpenID_OpenIDStore}. + * Several concrete implementations are provided, to cover most common use + * cases. For stores backed by MySQL, PostgreSQL, or SQLite, see + * the {@link Auth_OpenID_SQLStore} class and its sublcasses. For a + * filesystem-backed store, see the {@link Auth_OpenID_FileStore} module. + * As a last resort, if it isn't possible for the server to store + * state at all, an instance of {@link Auth_OpenID_DumbStore} can be used. + * + * @param bool $immediate This is an optional boolean value. It + * controls whether the library uses immediate mode, as explained + * in the module description. The default value is False, which + * disables immediate mode. + */ + function Auth_OpenID_GenericConsumer($store) + { + $this->store = $store; + $this->negotiator = Auth_OpenID_getDefaultNegotiator(); + $this->_use_assocs = (is_null($this->store) ? false : true); + + $this->fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); + + $this->session_types = Auth_OpenID_getAvailableSessionTypes(); + } + + /** + * Called to begin OpenID authentication using the specified + * {@link Auth_OpenID_ServiceEndpoint}. + * + * @access private + */ + function begin($service_endpoint) + { + $assoc = $this->_getAssociation($service_endpoint); + $r = new Auth_OpenID_AuthRequest($service_endpoint, $assoc); + $r->return_to_args[$this->openid1_nonce_query_arg_name] = + Auth_OpenID_mkNonce(); + + if ($r->message->isOpenID1()) { + $r->return_to_args[$this->openid1_return_to_identifier_name] = + $r->endpoint->claimed_id; + } + + return $r; + } + + /** + * Given an {@link Auth_OpenID_Message}, {@link + * Auth_OpenID_ServiceEndpoint} and optional return_to URL, + * complete OpenID authentication. + * + * @access private + */ + function complete($message, $endpoint, $return_to) + { + $mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode', + ''); + + $mode_methods = array( + 'cancel' => '_complete_cancel', + 'error' => '_complete_error', + 'setup_needed' => '_complete_setup_needed', + 'id_res' => '_complete_id_res', + ); + + $method = Auth_OpenID::arrayGet($mode_methods, $mode, + '_completeInvalid'); + + return call_user_func_array(array($this, $method), + array($message, &$endpoint, $return_to)); + } + + /** + * @access private + */ + function _completeInvalid($message, $endpoint, $unused) + { + $mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode', +