} $images = array(); for ($start = 0; $start < 200; $start += 20) { // echo $start . "\n"; $html = getContents($searchURL, $start)->getBody(); // $html = file_get_contents('images.html'); $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate('/html/body//div[@id="ImgCont"]//td//a'); for ($i = 0; $i < $hrefs->length; $i++) { $url = $hrefs->item($i)->getAttribute('href'); list(, $querystring) = explode('?', $url); $neturl = new Net_URL2("http://example.com/?{$querystring}"); $vars = $neturl->getQueryVariables(); if (isset($vars['imgurl'])) { $images[] = $vars['imgurl']; } } } foreach ($images as $count => $image) { preg_match_all('/([.][^.]+)$/', $image, $foo); if (!isset($foo[0][0])) { continue; } $ext = strtolower($foo[0][0]); $filename = "images/kittens/{$count}{$ext}"; echo $filename . "\n"; try { $contents = getContents($image, 0, $userAgent)->getBody();
/** * Validates the nonce embedded in the openid.return_to paramater and deletes * it from storage.. (For use with OpenID 1.1 only) * * @return void * @throws OpenID_Assertion_Exception on invalid or non-existing nonce */ protected function validateReturnToNonce() { $returnTo = $this->message->get('openid.return_to'); if ($returnTo === null) { // Must be a checkid_immediate negative assertion. $rtURL2 = new Net_URL2($this->message->get('openid.user_setup_url')); $rtqs = $rtURL2->getQueryVariables(); $returnTo = $rtqs['openid.return_to']; $identity = $rtqs['openid.identity']; } $netURL = new Net_URL2($returnTo); $qs = $netURL->getQueryVariables(); if (!array_key_exists(OpenID_Nonce::RETURN_TO_NONCE, $qs)) { throw new OpenID_Assertion_Exception('Missing OpenID 1.1 return_to nonce'); } if (!isset($identity)) { $identity = $this->message->get('openid.identity'); } $nonce = $qs[OpenID_Nonce::RETURN_TO_NONCE]; $discover = $this->getDiscover($identity); $endPoint = $discover->services[0]; $URIs = $endPoint->getURIs(); $opURL = array_shift($URIs); $fromStore = self::getStore()->getNonce(urldecode($nonce), $opURL); // Observing $logMessage = "returnTo: {$returnTo}\n"; $logMessage .= 'OP URIs: ' . print_r($endPoint->getURIs(), true) . "\n"; $logMessage .= 'Nonce in storage?: ' . var_export($fromStore, true) . "\n"; OpenID::setLastEvent(__METHOD__, $logMessage); if (!$fromStore) { throw new OpenID_Assertion_Exception('Invalid OpenID 1.1 return_to nonce in response'); } self::getStore()->deleteNonce($nonce, $opURL); }
/** * Returns the query portion of the url in array form. * * @return array */ public function getQueryVariables() { return $this->_url->getQueryVariables(); }
/** * This is a regression test to test that Net_URL2::getQueryVariables() does * not have a problem with nested array values in form of stacked brackets and * was reported as Bug #17036 on 2010-01-26 15:48 UTC that there would be * a problem with parsed query string. * * @link https://pear.php.net/bugs/bug.php?id=17036 * @covers Net_URL2::getQueryVariables * @return void */ public function test17036() { $queryString = 'start=10&test[0][first][1.1][20]=coucou'; $url = new Net_URL2('?' . $queryString); $vars = $url->getQueryVariables(); $expected = array(); $expected['start'] = '10'; $expected['test'][0]['first']['1.1'][20] = 'coucou'; $this->assertEquals($expected, $vars); // give nice diff in case of failuer $this->assertSame($expected, $vars); // strictly assert the premise }