コード例 #1
0
ファイル: check.php プロジェクト: lionker/cpp_learn
function ScanRules($dao)
{
    $getRulesIn = new Dao_GetRulesIn();
    $getRulesOut = new Dao_GetRulesOut();
    $dao->GetRules($getRulesIn, $getRulesOut);
    foreach ($getRulesOut->rules as &$item) {
        $url = $item["s_url"];
        $pattern = $item["s_pattern"];
        $patternType = $item["s_pattern_type"];
        $lastResult = $item["s_last_result"];
        GetLogger()->info("scanning url[{$url}] pattern[{$pattern}] type[{$patternType}]");
        $currentResult = "";
        // load html
        $options = new NetUtilsHttpLoadOptions();
        $options->url = $url;
        $options->method = "GET";
        $options->timeoutSeconds = 20;
        // 20s timeout
        $loadData = "";
        $errorMessage = NetUtilsHttpLoad($options, $loadData);
        if ($errorMessage != "") {
            GetLogger()->error("Load remote page error, {$errorMessage}");
            continue;
        }
        $currentResult = array();
        if ($patternType == "preg") {
            // filter
            $output = array();
            preg_match_all($pattern, $loadData, $output);
            $currentResult = $output[0];
        }
        if (count($currentResult) == 0) {
            GetLogger()->error("scan url[{$url}] pattern[{$pattern}] failed, currentResult empty");
            continue;
        }
        $currentResult = json_encode($currentResult);
        GetLogger()->info("remote page scan complete url[{$url}] pattern[{$pattern}]");
        // compare with history result
        if ($currentResult != $lastResult) {
            GetLogger()->error("update detected url[{$url}] pattern[{$pattern}]");
            // store result in db
            $updateLastResultIn = new Dao_UpdateRuleLastResultIn();
            $updateLastResultIn->id = $item["i_rule_id"];
            $updateLastResultIn->lastResult = $currentResult;
            $updateLastResultOout = new Dao_UpdateRuleLastResultOut();
            $dao->UpdateRuleLastResult($updateLastResultIn, $updateLastResultOout);
        }
    }
}
コード例 #2
0
ファイル: doc_load.php プロジェクト: lionker/cpp_learn
<?php

require_once dirname(__FILE__) . "/" . '../../libs/rlib/NetUtils.php';
require_once dirname(__FILE__) . "/" . '../common/GetLogger.php';
$url = "";
if (isset($_GET["url"])) {
    $url = $_GET["url"];
}
if ($url == "") {
    exit(0);
}
$options = new NetUtilsHttpLoadOptions();
$options->url = $url;
$options->method = "GET";
$options->timeoutSeconds = 20;
// 20s timeout
$options->headers[] = $_SERVER['HTTP_USER_AGENT'];
$loadData = "";
$errorMessage = NetUtilsHttpLoad($options, $loadData);
// $metaTag = "<meta name=\"Referer\" content=\"$url\">";
//$baseTag = "";
echo $errorMessage;
//echo str_replace("<head>","<head>$baseTag",$loadData);
echo $loadData;
コード例 #3
0
<?php

require_once '../../libs/rlib/NetUtils.php';
$options = new NetUtilsHttpLoadOptions();
$options->url = "www.qq.com";
$loadData = "";
NetUtilsHttpLoad($options, $loadData);
echo $loadData;