示例#1
0
<?php

require_once 'Class_HandleSiteConfig.php';
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 * UrlPattern:<input type=\"text\" name=\"UrlPattern\" /><br><input type=\"submit\" value=\"Delete\" /><br></form><br>";
 */
$tag = $_GET['tag'];
$site = $_GET['site'];
$property = $_GET['property'];
$value = $_GET['value'];
$urlpattern = $_GET['UrlPattern'];
var_dump($urlpattern);
if (strcmp("", $urlpattern) == 0) {
    echo "!!!!!!!!!";
}
echo "Delete Site:" . $site . "   Tag:" . $tag . " " . $property . "=" . $value . "   with UrlPattern:" . $urlpattern . "<br>";
$findresult = new siteConfig("D:\\Sina\\wamp\\wamp\\www\\SiteConfig\\siteConfig.cfg");
$findresult->DeleteSiteconfig($site, $tag, $property, $value, $urlpattern);
 public function FindNewTemplate()
 {
     echo "<strong>Begin to find new template...........</strong><br>";
     echo "******************************************<br>";
     echo "******************************************<br>";
     $line_number = 0;
     //use $line_number to record the number of Url;
     $error_number = 0;
     //use $error_number to record the number of Errof;
     $position = 0;
     $bumpcontent = false;
     $result = array();
     if ($this->flog != NULL) {
         while (!feof($this->flog)) {
             if ($bumpcontent) {
                 fseek($this->flog, $position, SEEK_SET);
                 $bumpcontent = false;
             }
             $line = fgets($this->flog);
             if (preg_match("/\\[[ 0-9\\-\\:]*\\] \\[INFO\\] \\[[0-9]*\\] getArticleContent()/", $line)) {
                 $ftemp = $this->flog;
                 $bumpcontent = true;
                 $position = ftell($this->flog);
                 $line_number++;
                 preg_match("/\\[([0-9]*)\\]/", $line, $matches);
                 $threadNumber = $matches[1];
                 preg_match("/Url=([\\d\\D]*) pageLoadTimtout/", $line, $matchUrl);
                 $urlKey = $matchUrl[1];
                 $flag = true;
                 //To see whether the thread has not finished.
                 $bestflag = false;
                 //To see whether the Thread hold a best block.
                 while ($flag) {
                     $reline = fgets($ftemp);
                     if (feof($ftemp)) {
                         fseek($this->flog, $position, SEEK_SET);
                         $bumpcontent = false;
                         break;
                     }
                     preg_match("/\\[([0-9]*)\\]/", $reline, $matchagain);
                     if (count($matchagain) > 1) {
                         if ($matchagain[1] == $threadNumber) {
                             //Element tag:div, Property=class, Value="main"
                             if (preg_match("/\\[[ 0-9\\-\\:]*\\] \\[INFO\\] \\[[0-9]*\\] Found the best block. Element tag:([\\d\\D]*), Property=([\\d\\D]*), Value=\"([\\d\\D]*)\"/", $reline, $bestblock)) {
                                 if (count($bestblock) > 3) {
                                     $tag = $bestblock[1];
                                     $property = $bestblock[2];
                                     $idclass = $bestblock[3];
                                     $bestflag = true;
                                 }
                             }
                             if (preg_match("/\\[[ 0-9\\-\\:]*\\] \\[INFO\\] \\[[0-9]*\\] getArticleContent()/", $reline) || preg_match("/\\[[ 0-9\\-\\:]*\\] \\[INFO\\] \\[[0-9]*\\] Cost/", $reline)) {
                                 $flag = false;
                                 $nextline = fgets($ftemp);
                                 if (preg_match("/\\[[ 0-9\\-\\:]*\\] \\[SEVERE\\] \\[[0-9]*\\] Failed to get static content/", $nextline)) {
                                     $error_number++;
                                     //echo "<strong>[ERROR]</strong> Template need to be update,please update the template in " . $urlKey . " <strong>[ERROR]!</strong><br>";
                                     if ($bestflag) {
                                         $siteName = "D:\\Sina\\wamp\\wamp\\www\\SiteConfig\\siteConfig.cfg";
                                         $site = new siteConfig($siteName);
                                         $checkresult = $site->CheckLogFile($urlKey, $tag, $property, $idclass);
                                         array_push($result, $checkresult);
                                     } else {
                                         echo "<strong>[SEVERE]</strong>There is no BestBlock Found in this url!" . $urlKey;
                                     }
                                     $flag = false;
                                     $bestflag = false;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         fclose($this->flog);
     }
     echo "<table><tr><th>Total</th><th>Error</th></tr><tr><td>" . $line_number . "</td><td>" . $error_number . "</td></tr></table><br>";
     //var_dump($result);
     return $result;
 }
<?php

ini_set('date.timezone', 'Asia/Shanghai');
require_once 'Class_HandleSiteConfig.php';
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$siteconfig = new siteConfig("D:\\Sina\\wamp\\wamp\\www\\SiteConfig\\siteConfig.cfg");
$url = $_POST['CheckUrl'];
$tag = $_POST['tag'];
$site = $_POST['site'];
$property = $_POST['property'];
$idclass = $_POST['value'];
$matches = $_POST['TemplateMatchTime'];
$PregMatchTime = $_POST['PregMatchTime'];
$logName = $_POST['Logname'];
$file = date('YmdHis');
echo "TestUrl:" . $url . "tag:" . $tag . "  site:" . $site . "  property:" . $property . "  idclass:" . $idclass . "  TagMatchTime:" . $matches . "  PregMatchTime" . $PregMatchTime . "<br>";
$flag = $siteconfig->EvaluateSituation($tag, $PregMatchTime, $matches);
if ($flag) {
    $siteconfig->WriteSiteconfig($url, $site, $tag, $property, $idclass);
    $writelog = fopen("D:\\Sina\\wamp\\wamp\\www\\ModifySiteConfig.log", "a");
    fputs($writelog, "Time:   " . $file . "\n");
    fputs($writelog, "Url:   " . $url . "\n");
    fputs($writelog, "Site:  " . $site . "\n");
    fputs($writelog, $tag . " " . $property . "=" . $idclass . "\n");
    fputs($writelog, "******************" . "\n");
    fclose($writelog);
} else {
示例#4
0
<?php

require_once 'Class_HandleSiteConfig.php';
echo "<strong>Attenrion</strong>请输入完整的正确site!<br>";
$site = $_GET['site'];
$tag = $_GET['tag'];
$property = $_GET['property'];
$value = $_GET['value'];
$templatematch = $_GET['TemplateMatchTime'];
$pregmatch = $_GET['PregMatchTime'];
echo "Looking for site:" . $site . "<br>";
$findresult = new siteConfig("D:\\Sina\\wamp\\wamp\\www\\SiteConfig\\siteConfig.cfg");
$findresult->FindSiteconfig($site, $tag, $property, $value, $templatematch, $pregmatch);
 public function testCompareXmlToIni()
 {
     $xml = new siteConfig(__DIR__ . '/files/siteConfig.xml');
     $ini = new siteConfig(__DIR__ . '/files/siteConfig.ini');
     $this->assertEquals($xml->get_fullConfig(), $ini->get_fullConfig());
 }