function getSearcherValue($url, $searcher = "google") { $url = urlencode(preg_replace("#^http://#", "", $url)); $searcherUrls = array('google' => 'http://www.google.com/search?hl=en&q=site%3A' . $url, 'googlebl' => 'http://www.google.com/search?hl=en&q=link%3A' . $url); $searcherPats = array('google' => "#</b> of (?:about )?<b>([\\d,]+)</b>#", 'googlebl' => "#</b> of (?:about )?<b>([\\d,]+)</b>#"); if (!array_key_exists($searcher, $searcherUrls)) { $searcher = "google"; } $sourceUrl = $searcherUrls[$searcher]; $httpClient = new HttpClient(); if ($this->extractionWay == 2) { $httpClient->additionalServerUrl = $this->additionalServerUrl; } $buff = $httpClient->getSiteContent($sourceUrl); if ($this->debug) { echo $buff; } if (!preg_match($searcherPats[$searcher], $buff, $m)) { $count = 0; } else { $count = str_replace(",", "", $m[1]); $count = intval($count); } return $count; }
/** * Display login form and login admin */ function logInAction() { if (isset($this->request->login) && isset($this->request->password)) { if ($this->session->loginUser($this->request->login, md5($this->request->password), "login", "administrator")) { $httpClient = new HttpClient(); $this->session->set("scriptLastVersion", $httpClient->getSiteContent("http://script.arfooo.com/version/version.html", false)); $this->redirect($this->moduleLink("index")); } else { $this->set("loginError", 1); } } }
public function verifyCode($code) { $url = "http://www.allopass.com/check/vf.php4?"; $url .= "AUTH=" . urlencode($this->product->allopassId); $url .= "&CODE="; for ($i = 0, $n = count($code); $i < $n; $i++) { $url .= urlencode($code[$i]); if ($i + 1 < $n) { $url .= ","; } } $url .= "&MAXT=" . $this->allopassMaxTime; $httpClient = new HttpClient(); $buff = $httpClient->getSiteContent($url, false); return strncmp("OK", $buff, 2) == 0; }
function checkScriptVersion() { require CODE_ROOT_DIR . "config/version.php"; $lastVersion = $this->session->get("scriptLastVersion"); if (!$lastVersion) { $httpClient = new HttpClient(); $lastVersion = $httpClient->getSiteContent("http://script.arfooo.com/version/version.html", false); if (!$lastVersion) { $lastVersion = "-"; } $this->session->set("scriptLastVersion", $lastVersion); } $newVersionAvailable = version_compare($lastVersion, $currentVersion, ">"); $this->set("currentVersion", $currentVersion); $this->set("lastVersion", $lastVersion); $this->set("newVersionAvailable", $newVersionAvailable); }
function getPageRank($url, $additionalServerUrl = false) { $pageRank = 0; $url = substr(strtolower($url), 0, 7) != "http://" ? "http://" . $url : $url; $queryUrl = "http://" . $this->googleDomains[mt_rand(0, count($this->googleDomains) - 1)]; $queryUrl .= sprintf("/tbr?client=navclient-auto&ch=6%s&features=Rank&q=info:%s", $this->googleCh($this->strord("info:" . $url)), urlencode($url)); $httpClient = new HttpClient(); if ($additionalServerUrl) { $httpClient->additionalServerUrl = $additionalServerUrl; } $content = $httpClient->getSiteContent($queryUrl, false); if ($this->debug) { echo $content; } if (preg_match("#Rank_1:\\d:(\\d{1,2})#", $content, $matches)) { $pageRank = $matches[1]; } return $pageRank; }
public function addAddress($address, $description = '') { $url = self::GEO_URL . '?&output=json&q=' . urlencode($address); if (@ini_get('allow_url_fopen')) { $buff = @file_get_contents($url); } else { $httpClient = new HttpClient(); $buff = $httpClient->getSiteContent($url, false); } $response = json_decode(utf8_encode($buff), true); if (empty($response['Status']['code'])) { throw new Google_Map_ServiceException('Invalid status code'); } if (empty($response['Placemark'][0]['Point']['coordinates'])) { throw new Google_Map_AddressNotFoundException('Point can NOT be found'); } $coords = $response['Placemark'][0]['Point']['coordinates']; $point = array('lat' => $coords[1], 'lng' => $coords[0], 'address' => $address, 'description' => $description); array_push($this->_points, $point); return array('lat' => $coords[1], 'lng' => $coords[0]); }
function downloadAndCacheThumb($forced = false) { $imageFileName = Config::get("SITES_THUMBS_PATH") . $this->siteId . ".jpg"; if (!file_exists($imageFileName) || $forced) { if (!Config::get("thumbsGeneratorUrl")) { throw new Exception("thumbsGeneratorUrl not set"); } $url = $this->getThumbGeneratorSiteUrl(); $httpClient = new HttpClient(); $thumbImage = $httpClient->getSiteContent($url, false, true, true); if ($thumbImage) { // check whether the image is valid if (function_exists('imagecreatefromstring') && @imagecreatefromstring($thumbImage) === false) { throw new Exception("Downloaded thumb is not an image"); } file_put_contents($imageFileName, $thumbImage); } } }
public function handleIpn() { $ipnData = $this->request; $postData = 'cmd=_notify-validate'; foreach ($ipnData as $key => $value) { $postData .= "&" . urlencode($key) . "=" . urlencode($value); } $httpClient = new HttpClient(); $url = $this->getActionUrl(); $buff = $httpClient->getSiteContent($url, false, true, false, "POST", $postData); if (strcmp($buff, "VERIFIED") != 0) { return $this->payLog("Request isn't VERIFIED", "error"); } if ($this->debug) { $this->payLog(var_export($ipnData, true) . "\r\n"); } if ($this->debug) { $this->payLog($postData . "\r\n"); } foreach (array("item_number", "receiver_email", "mc_gross", "mc_currency", "txn_type", "payment_status") as $key) { if (empty($ipnData[$key])) { return $this->payLog("Field {$key} is not set", "error"); } } $this->currentPayment = $this->payment->findByPk($ipnData['item_number']); $errorMessage = $this->validatePayment($ipnData); if ($errorMessage) { return $this->payLog($errorMessage, "error"); } switch ($ipnData['txn_type']) { case "web_accept": switch ($ipnData['payment_status']) { case "Completed": $this->onComplete(); break; case "Pending": $this->onPending(); break; case "Denied": $this->onDenied(); break; } break; default: return $this->payLog("Unhandled txn_type", "error"); } return $this->payLog("Finished"); }