コード例 #1
0
 function parseForDomen($domen)
 {
     $url = str_replace("{DOMEN}", $domen, $this->templateUrl);
     $main = 0;
     $rest = 0;
     $without = 0;
     $res = $this->parseFromUrl($url);
     if (PEAR::isError($res)) {
         return $res;
     }
     foreach ($this->items as $link) {
         $u = parse_url($link["url"]);
         if ((!isset($u["path"]) || $u["path"] == "/") && !isset($u["query"])) {
             $main++;
         } else {
             $rest++;
         }
         if ($this->withoutOur) {
             $host = isset($u["host"]) ? $u["host"] : "";
             if (strpos($host, "." . removeWWW($domen)) === false || strcmp($host, $domen) != 0) {
                 $without++;
             }
         }
     }
     return array("main" => $main, "rest" => $rest, "withoutOur" => $without);
 }
コード例 #2
0
function koodimonni_mail_from($email)
{
    if (endsWith($email, '@localhost') || empty($email)) {
        $parsed = parse_url(get_site_url());
        $hostname = removeWWW($parsed['host']);
        return "no-reply@{$hostname}";
    }
}
コード例 #3
0
function HandleCheckTIC()
{
    header("Content-type: text/html; charset=windows-1251");
    require_once "YandexTICGrabber.php";
    $json = new Services_JSON();
    $result = array("rowNum" => (int) $_REQUEST["rowNum"], "url" => $_REQUEST["url"]);
    $proxyService = new ProxiesService("yandex", SERVER_IP);
    $res = $proxyService->getProxyData();
    if (PEAR::isError($res)) {
        $result["error"] = $res->getMessage();
        print $json->encode($result);
        exit;
    }
    if (isset($_REQUEST["delay"]) && $_REQUEST["delay"] == "true") {
        if (isset($_REQUEST["delayValue"])) {
            sleep((int) $_REQUEST["delayValue"]);
        } else {
            sleep(DELAY_BEFORE_REQUEST);
        }
    }
    $_REQUEST["url"] = trim($_REQUEST["url"]);
    $parser =& new YandexTICGrabber();
    $parser->showInfo = false;
    $cy = $parser->parseForDomen(removeWWW($_REQUEST["url"]));
    $proxyService->increase();
    $cyNoWww = $parser->parseForDomen("www." . removeWWW($_REQUEST["url"]));
    $proxyService->increase();
    $cy = max($cy["num"], $cyNoWWW["num"]);
    if ($cy < 0) {
        $result["error"] = "Wrong CY";
        print $json->encode($result);
        exit;
    }
    $result["num"] = $cy;
    print $json->encode($result);
}
コード例 #4
0
function HandleCheckPriceLink()
{
    header("Content-type: text/html; charset=windows-1251");
    require_once "YandexTICGrabber.php";
    require_once "CheckPageRankGrabber.php";
    $json = new Services_JSON();
    $result = array("url" => $_REQUEST["url"], "rowNum" => (int) $_REQUEST["rowNum"]);
    $proxyService = new ProxiesService("yandex", SERVER_IP);
    $res = $proxyService->getProxyData();
    if (PEAR::isError($res)) {
        $result["error"] = $res->getMessage();
        print $json->encode($result);
        exit;
    }
    if (isset($_REQUEST["delay"]) && $_REQUEST["delay"] == "true") {
        if (isset($_REQUEST["delayValue"])) {
            sleep((int) $_REQUEST["delayValue"]);
        } else {
            sleep(DELAY_BEFORE_REQUEST);
        }
    }
    $_REQUEST["url"] = trim($_REQUEST["url"]);
    $parserTic =& new YandexTICGrabber();
    $parserTic->showInfo = false;
    $resultTic = $parserTic->parseForDomen(removeWWW($_REQUEST["url"]));
    $proxyService->increase();
    $resultTicNoWww = $parserTic->parseForDomen("www." . removeWWW($_REQUEST["url"]));
    $resultTic = max($resultTic["num"], $resultTicNoWww["num"]);
    if ($resultTic < 0) {
        $result["error"] = "Wrong CY";
        print $json->encode($result);
        exit;
    }
    $proxyService->increase();
    $parserRank =& new CheckPageRankGrabber();
    $parserRank->showInfo = false;
    $resultRank = $parserRank->parseForDomen($_REQUEST["url"]);
    $pageRank = max($resultRank["www"], $resultRank["nowww"]);
    if ($pageRank < 0) {
        $result["error"] = "Wrong Page Rank";
        print $json->encode($result);
        exit;
    }
    if (strpos($_REQUEST["url"], "http://") === false || strpos($_REQUEST["url"], "http://") > 0) {
        $_REQUEST["url"] = "http://" . $_REQUEST["url"];
    }
    $res = getLinksForUrlDOM($_REQUEST["url"]);
    if (PEAR::isError($res)) {
        $result["error"] = $res->getMessage();
        print $json->encode($result);
        exit;
    }
    list($linksCount, $linksCountNoIndex, $linksCountIn, $linksCountOut, $linkCountOur) = $res;
    $lCount = $linksCountOut + $linkCountOur;
    switch ((int) $_REQUEST["linktype"]) {
        case 1:
            $result["num1"] = get_face_value($pageRank, $resultTic, -1);
            $result["num"] = get_face_value($pageRank, $resultTic, $linksCountOut + $linkCountOur);
            break;
        case 2:
            $result["num1"] = get_inner_value($pageRank, $resultTic, -1);
            $result["num"] = get_inner_value($pageRank, $resultTic, $linksCountOut + $linkCountOur);
            break;
    }
    $result["linksCountOut"] = $lCount;
    $result["pr"] = $pageRank;
    $result["cy"] = $resultTic;
    print $json->encode($result);
}
コード例 #5
0
function getLinksForUrl($url, $useProxy = true)
{
    $linksCount = 0;
    $linksCountNoIndex = 0;
    $linkCountIn = 0;
    $linkCountOut = 0;
    $linkCountOur = 0;
    $params = array();
    if ($useProxy) {
        $proxyService = new ProxiesService();
        $res = $proxyService->getRandomProxyData();
        if (PEAR::isError($res)) {
            return $res;
        }
        $params["proxyData"] = $res;
    }
    $pageContent = UrlUtils::loadPage($url, $params);
    if (strlen($pageContent) == 0) {
        return new PEAR_Error("Empty content");
    }
    $pattern = "{<a[^>]+?(href=\".+?\"|href='.+?'|href=.+?\\s)[^>]*>}si";
    if (!preg_match_all($pattern, $pageContent, $matches, PREG_SET_ORDER)) {
        return array($linksCount, $linksCountNoIndex, $linkCountIn, $linkCountOut, $linkCountOur);
    }
    $linksCount = sizeof($matches);
    $currUrl = parse_url($url);
    foreach ($matches as $m) {
        $m[1] = strtolower($m[1]);
        $url = removeQuotes(str_replace("href=", "", $m[1]));
        $u = parse_url($url);
        if (!isset($u["host"])) {
            $linkCountIn++;
        } else {
            if (strcmp(removeWWW($u["host"]), removeWWW($currUrl["host"])) == 0) {
                $linkCountIn++;
            } else {
                if (strpos(removeWWW($u["host"]), "." . removeWWW($currUrl["host"])) !== false) {
                    $linkCountOur++;
                } else {
                    $linkCountOut++;
                }
            }
        }
    }
    $pageContent = preg_replace("{<noindex>.+?</noindex>}si", "", $pageContent);
    preg_match_all($pattern, $pageContent, $matches, PREG_SET_ORDER);
    $linksCountNoIndex = sizeof($matches);
    return array($linksCount, $linksCountNoIndex, $linkCountIn, $linkCountOut, $linkCountOur);
}