当前位置: 首页>>代码示例>>PHP>>正文


PHP mysql_squid_builder::GET_CATEGORIES方法代码示例

本文整理汇总了PHP中mysql_squid_builder::GET_CATEGORIES方法的典型用法代码示例。如果您正苦于以下问题:PHP mysql_squid_builder::GET_CATEGORIES方法的具体用法?PHP mysql_squid_builder::GET_CATEGORIES怎么用?PHP mysql_squid_builder::GET_CATEGORIES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysql_squid_builder的用法示例。


在下文中一共展示了mysql_squid_builder::GET_CATEGORIES方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WEBTESTS

function WEBTESTS(){
	
$www=$_REQUEST["WEBTESTS"];
$q=new mysql_squid_builder();
$www=$q->WebsiteStrip($www);

if($www==null){echo "corrupted\n";return;}
$catz=str_replace(",", "\n- ", $q->GET_CATEGORIES($www,true));
echo "\nFinal:\n\"".$q->GET_CATEGORIES($www,true)."\"\n";
	
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:11,代码来源:squid.test.categories.php

示例2: CategorizeAWebSite

function CategorizeAWebSite($www, $category)
{
    $md5 = md5($www . $category);
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $uuid = $GLOBALS["UUID"];
    $category_table = $q->category_transform_name($category);
    $sql_add = "INSERT IGNORE INTO categorize (zmd5,zDate,category,pattern,uuid) VALUES('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')";
    $sql_add2 = "INSERT IGNORE INTO category_{$category_table} (zmd5,zDate,category,pattern,uuid) VALUES('{$md5}',NOW(),'{$category}','{$www}','{$uuid}')";
    $q->QUERY_SQL($sql_add);
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql_add}\n";
        return false;
    }
    $q->QUERY_SQL($sql_add2);
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql_add2}\n";
        return false;
    }
    $categories = $q->GET_CATEGORIES($www, true);
    if ($categories != null) {
        $sql = "UPDATE visited_sites SET category='{$categories}' WHERE sitename='{$www}'";
        $q->QUERY_SQL($sql);
        if (!$q->ok) {
            echo $q->mysql_error . "\n{$sql}\n";
            return false;
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.scrapper.php

示例3: visited_sites

function visited_sites()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/squid.visited_sites_rescan.pid";
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    $t = time();
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid} since {$time}mn\n";
        }
        die;
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    stats_admin_events(2, "Starting table visited_sites", "", __FILE__, __LINE__);
    progress("Starting table visited_sites", 5);
    $q = new mysql_squid_builder();
    $sql = "SELECT sitename FROM visited_sites WHERE LENGTH(category)=0";
    $results = $q->QUERY_SQL($sql);
    $num_rows = mysql_num_rows($results);
    $took = $unix->distanceOfTimeInWords($t, time());
    stats_admin_events(2, "Query done {$num_rows} websites to scan", "took:{$took}", __FILE__, __LINE__);
    if ($num_rows == 0) {
        progress(null, 100);
        return;
    }
    progress("Query done {$num_rows} websites to scan", 10);
    $c = 0;
    $t = 0;
    $d = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $sitenameOrg = $ligne["sitename"];
        $sitename = strtolower(trim($sitenameOrg));
        if (badCharacters($sitename)) {
            $q->categorize_reaffected($sitename);
            $sitenameOrg = mysql_escape_string2($sitenameOrg);
            $q->QUERY_SQL("UPDATE visited_sites SET category='reaffected' WHERE `sitename`='{$sitenameOrg}'");
            if (!$q->ok) {
                progress("Fatal", 100);
                die;
            }
            $d++;
            $c++;
            continue;
        }
        if (strpos($sitename, ".") == 0) {
            $q->categorize_reaffected($sitename);
            $sitenameOrg = mysql_escape_string2($sitenameOrg);
            $q->QUERY_SQL("UPDATE visited_sites SET category='reaffected' WHERE `sitename`='{$sitenameOrg}'");
            if (!$q->ok) {
                progress("Fatal", 100);
                die;
            }
            $d++;
            $c++;
            continue;
        }
        if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $sitename)) {
            $sitename = gethostbyaddr($sitename);
            if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $sitename)) {
                $c++;
                continue;
            }
        }
        $ipaddr = gethostbyname($sitename);
        if (!preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ipaddr)) {
            $q->categorize_reaffected($sitenameOrg);
            $q->QUERY_SQL("UPDATE visited_sites SET category='reaffected' WHERE `sitename`='{$sitenameOrg}'");
            if (!$q->ok) {
                progress("Fatal", 100);
                die;
            }
            $d++;
            $c++;
            continue;
        }
        $cat = $q->GET_CATEGORIES($sitename);
        if ($cat != null) {
            $d++;
            $q->QUERY_SQL("UPDATE visited_sites SET category='{$cat}' WHERE `sitename`='{$sitenameOrg}'");
            if (!$q->ok) {
                progress("Fatal", 100);
                die;
            }
        }
        $c++;
        if ($c > 50) {
            $t = $t + $c;
            $purc = $t / $num_rows;
            $purc = round($purc, 2) * 100;
            $c = 0;
            if ($purc > 10) {
                progress("{$sitename} {$t}/{$num_rows}", $purc);
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.visited.sites.php

示例4: GetDomains

function GetDomains($i)
{
    $unix = new unix();
    $tmpfile = $unix->FILE_TEMP();
    $curl = new ccurl("http://0675.com.cn/newwebsite_20120101_list._page0.html");
    $curl->NoHTTP_POST = true;
    echo "Get page {$i}\n";
    if (!$curl->GetFile($tmpfile)) {
        echo "http://0675.com.cn/newwebsite_20120101_list._page{$i}.html -> error: \n" . $curl->error . "\n";
        return;
    }
    $datas = @file($tmpfile);
    $size = strlen(@implode("", $datas)) / 1024;
    echo "Page[{$i}]:: {$tmpfile} Size: {$size} Ko\n";
    while (list($num, $ligne) = each($datas)) {
        if (preg_match("#<div class=.*?newdomain.*?>(.*)#", $ligne)) {
            echo "Sure line {$num}";
            $newdata = str_replace("</li>", "", $ligne);
            $newdata = str_replace("</div>", "", $newdata);
            $f = explode("<li>", $newdata);
        }
    }
    $q = new mysql_squid_builder();
    while (list($num, $www) = each($f)) {
        if (preg_match("#^\\.(.+)#", $www, $re)) {
            $www = $re[1];
        }
        if (strpos($www, ",") > 0) {
            continue;
        }
        if (strpos($www, " ") > 0) {
            continue;
        }
        if (strpos($www, ":") > 0) {
            continue;
        }
        if (strpos($www, "%") > 0) {
            continue;
        }
        if (strpos($www, ">") > 0) {
            continue;
        }
        if (strpos($www, "<") > 0) {
            continue;
        }
        if (preg_match("#^www\\.(.+)#", $www, $re)) {
            $www = $re[1];
        }
        $articacats = trim($q->GET_CATEGORIES($www, true, false));
        if ($articacats != null) {
            echo "\"{$www}\" SUCCESS - {$articacats} -\n";
            continue;
        }
        echo "\"{$www}\" FAILED\n";
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:56,代码来源:exec.scan.0675-com.php

示例5: site_infos_categories

function site_infos_categories()
{
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $page = CurrentPageName();
    include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
    $delete = $tpl->javascript_parse_text("{delete}");
    $from = $tpl->javascript_parse_text("{from}");
    $do_you_want_to_recompile_database = $tpl->javascript_parse_text("{do_you_want_to_recompile_database}");
    $success = $tpl->javascript_parse_text("{sucess}");
    $t = time();
    $catz = $q->GET_CATEGORIES($_GET["search-stats-categories"]);
    if ($catz != null) {
        if (strpos($catz, ",") > 0) {
            $cats = explode(",", $catz);
        } else {
            $cats[] = $catz;
        }
    }
    $catNum = count($cats);
    if ($catNum == 0) {
        $html = "\n\t\t\n\t\t<table style='width:99%'>\n\t\t\t<tbody><tr><td width=1%>\n\t\t\t\t<img src='img/warning-panneau-32.png'></td>\n\t\t\t\t<td width=99% style='font-size:13px;font-weight:bold'>{this_website_hasnocat}</td>\n\t\t\t\t</tr></tbody></table>";
        echo $tpl->_ENGINE_parse_body("{$html}");
        return;
    }
    $dd = new dansguardian_rules();
    $catstext = $tpl->_ENGINE_parse_body("{this_website_is_categorized_inXX}");
    $catstext = str_replace("XX", count($cats), $catstext);
    https:
    //192.168.1.106:9000/squid.categories.php?query=yes&category=porn&search=megavideo.&strictSearch=0
    $html = "<table style='width:99%'>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td colspan=2 style='font-size:13px'>{$catstext}</td>\n\t\t</tr>\n\t";
    while (list($a, $b) = each($cats)) {
        if ($b == null) {
            continue;
        }
        $img = $dd->array_pics[$b];
        if ($img == null) {
            $img = "20-categories-personnal.png";
        }
        $id = md5($b);
        $html = $html . "<tr id='tt{$id}'>\n\t\t\t<td width=1%><img src='img/{$img}'></td>\n\t\t\t<td style='font-size:13px;font-weight:bold'>\n\t\t\t<a href=\"javascript:blur();\" \n\t\t\tOnClick=\"javascript:Loadjs('squid.categorize.php?www={$_GET["search-stats-categories"]}&day=&week=&month=');\" \n\t\t\tstyle='font-size:13px;text-decoration:underline;;font-weight:bold'>{$b}</td>\n\t\t\t</tr>";
    }
    $html = $html . "</tbody></table>\n\t\n\t<script>\n\tvar MEMCAT{$t}='';\n\tvar MEMID{$t}='';\n\t\n\t\tvar x_DeleteCategoryFromSite{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>0){alert(results);return;}\n\t\t\t\$('#tt'+ MEMID{$t}).remove();\n\t\t\tif(confirm('{$do_you_want_to_recompile_database} ?')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tXHR.appendData('action_compile_category','yes');\n\t\t\t\tXHR.appendData('category',MEMCAT{$t});\n\t\t\t\tXHR.sendAndLoad('{$page}', 'POST');\t\t\t\n\t\t\t\talert('{$success}');\n\t\t\t}\n\t\t\t\n\t\t}\t\t\n\t\n\t\n\t\tfunction DeleteCategoryFromSite{$t}(category,www,id){\n\t\t\tMEMID{$t}=id;\n\t\t\tif(confirm('{$delete} '+category+' {$from} '+www+' ?')){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tMEMCAT{$t}=category;\n\t\t\t\tXHR.appendData('action_delete_from_category','yes');\n\t\t\t\tXHR.appendData('sitename',www);\n\t\t\t\tXHR.appendData('category',category);\n\t\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_DeleteCategoryFromSite{$t});\n\t\t\t}\n\t\t\n\t\t}\n\t</script>\n\t";
    echo $tpl->_ENGINE_parse_body("{$html}");
    return;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:46,代码来源:squid.search.statistics.php

示例6: array

    echo "No changes\n";
    die;
}
$table_hours = $q->LIST_TABLES_HOURS();
$table_days = $q->LIST_TABLES_DAYS();
$table_week = $q->LIST_TABLES_WEEKS();
$ALREADY = array();
$MAX = mysql_num_rows($results);
$D = 0;
while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
    if (isset($ALREADY[$ligne["sitename"]])) {
        $q->QUERY_SQL("DELETE FROM categorize_changes WHERE `zmd5`='{$ligne["zmd5"]}'");
        continue;
    }
    $website = $ligne["sitename"];
    $categories = $q->GET_CATEGORIES($website, true);
    $ALREADY[$ligne["sitename"]] = true;
    reset($table_hours);
    reset($table_days);
    reset($table_week);
    $categories = addslashes($categories);
    $D++;
    $t = time();
    $a = 0;
    $b = 0;
    $c = 0;
    while (list($num, $table) = each($table_hours)) {
        $a++;
        if ($GLOBALS["VERBOSE"]) {
            echo "Update {$table}\n";
        }
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.re-categorize.php

示例7: GetCategory

function GetCategory($www)
{
    $q = new mysql_squid_builder();
    return $q->GET_CATEGORIES($www);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:5,代码来源:exec.web-community-filter.php

示例8: categorize

function categorize($day = null)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".{$day}." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid}\n";
        }
        return;
    }
    if ($day == null) {
        return;
    }
    if (system_is_overloaded()) {
        echo "Overloaded system, aborting task\n";
        writelogs_squid("Overloaded system, aborting task", __FUNCTION__, __FILE__, __LINE__, "categorize");
        return;
    }
    $daySource = $day;
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $q = new mysql_squid_builder();
    $time = strtotime("{$day} 00:00:00");
    $day = str_replace("-", "", $day);
    $table = "{$day}_hour";
    $table_blocked = "{$day}_blocked";
    $table_month = date("Ym", $time) . "_day";
    $table_week = date("YW", $time) . "_week";
    $table_week_blocked = date("YW", $time) . "_blocked_week";
    $ipClass = new IP();
    echo "{$daySource} time: {$time} Table day={$table}, table_blocked={$table_blocked}, table_month={$table_month}, table_week={$table_week}\n";
    events("{$daySource} time: {$time} Table day={$table}, table_blocked={$table_blocked}, table_month={$table_month}, table_week={$table_week}");
    $t = time();
    $f = 0;
    if (!$q->TABLE_EXISTS($table)) {
        echo $table . " no such table\n";
        return;
    }
    $sql = "SELECT sitename,category FROM {$table} GROUP BY sitename,category HAVING LENGTH(category)=0";
    events("{$sql}");
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        writelogs_squid("Re-categorized table {$table} Query failed: `{$sql}` ({$q->mysql_error})", __FUNCTION__, __FILE__, __LINE__, "categorize");
    }
    if (!$q->TABLE_EXISTS($table_month)) {
        if (!$q->CreateMonthTable($table_month)) {
            writelogs_squid("failed Create {$table_month} table {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "categorize");
        }
    }
    if (!$q->TABLE_EXISTS($table_week)) {
        if (!$q->CreateWeekTable($table_week)) {
            writelogs_squid("failed Create {$table_week} table {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "categorize");
        }
    }
    $L = 0;
    $q->QUERY_SQL("DELETE FROM `catztemp` WHERE `category`=''");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $website = trim($ligne["sitename"]);
        if (preg_match("#^www\\.(.+)#", $website, $re)) {
            $q->QUERY_SQL("UPDATE {$table} SET sitename='{$re[1]}' WHERE sitename='{$website}'");
            $q->QUERY_SQL("UPDATE {$table_month} SET sitename='{$re[1]}' WHERE sitename='{$website}'");
            $q->QUERY_SQL("UPDATE {$table_week} SET sitename='{$re[1]}' WHERE sitename='{$website}'");
            $q->QUERY_SQL("UPDATE {$table_blocked} SET website='{$re[1]}' WHERE sitename='{$website}'");
            $q->QUERY_SQL("UPDATE {$table_week_blocked} SET website='{$re[1]}' WHERE sitename='{$website}'");
            $website = $re[1];
        }
        if ($website == null) {
            continue;
        }
        if ($ipClass->isValid($website)) {
            $website = gethostbyaddr($website);
        }
        if (isset($GLOBALS[__FUNCTION__][$website])) {
            $category = $GLOBALS[__FUNCTION__][$website];
        }
        $category = $q->GET_CATEGORIES($website);
        if ($category == null) {
            if ($ipClass->isValid($website)) {
                $category = "ipaddr";
            }
        }
        events("{$day}] {$website} = {$category}");
        $GLOBALS[__FUNCTION__][$website] = $category;
        if ($L > 500) {
            if (system_is_overloaded()) {
                ufdbguard_admin_events("Fatal: Overloaded system, die();", __FUNCTION__, __FILE__, __LINE__, "stats");
                return;
            }
            $L = 0;
        }
        if ($category == null) {
            continue;
        }
        $f++;
        events("Update {$table} {$website} = {$category}");
        $q->QUERY_SQL("UPDATE {$table} SET category='{$category}' WHERE sitename='{$website}'");
        if (!$q->ok) {
            writelogs_squid("Re-categorized table {$table} failed {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "categorize");
        }
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.stats.recategorize.missed.php

示例9: import_translated

function import_translated()
{
    $q = new mysql_squid_builder();
    $MAINZ = unserialize(@file_get_contents("/root/translated"));
    $translated_done = unserialize(@file_get_contents("/root/translated_done"));
    $max = count($MAINZ);
    $gg = new generic_categorize();
    $i = 1;
    while (list($www, $category) = each($MAINZ)) {
        echo "{$i}/{$max} {$www} ";
        $i++;
        if (isset($translated_done[$www])) {
            echo "\n";
            continue;
        }
        $category_artica = $gg->GetCategories($www);
        if ($category_artica != null) {
            echo "-> ARTICA {$category_artica}\n";
            $q->categorize($www, $category_artica);
            $translated_done[$www] = true;
            @file_put_contents("/root/translated_done", serialize($translated_done));
            continue;
        }
        $category_artica = $q->GET_CATEGORIES($www, true, true, true, true);
        if ($category_artica != null) {
            echo "-> ARTICA {$category}<>{$category_artica}\n";
            $translated_done[$www] = true;
            @file_put_contents("/root/translated_done", serialize($translated_done));
            continue;
        }
        echo "{$category}\n";
        $q->categorize($www, $category);
        $translated_done[$www] = true;
        @file_put_contents("/root/translated_done", serialize($translated_done));
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:36,代码来源:exec.categorize-file.php

示例10: visited_list

function visited_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_squid_builder();
    $family = $q->GetFamilySites($_GET["www"]);
    $search = '%';
    $table = "visited_sites";
    $page = 1;
    $COUNT_ROWS = $q->COUNT_ROWS($table);
    $FORCE_FILTER = "familysite='{$family}'";
    if ($COUNT_ROWS == 0) {
        json_error_show("No data...");
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $_POST["query"] = trim($_POST["query"]);
    if ($_POST["query"] != null) {
        $_POST["query"] = "*{$_POST["query"]}*";
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE_FILTER} {$searchstring}";
        writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE_FILTER}";
        writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", ""));
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $categories = $q->GET_CATEGORIES($ligne['sitename']);
        $FamilySite = $q->GetFamilySites($ligne['sitename']);
        $categorize = imgtootltip("add-database-32.png", $ligne['sitename'], "javascript:Loadjs('squid.categorize.php?www={$ligne['sitename']}&day={$_GET["day"]}&week={$_GET["week"]}&month={$_GET["month"]}');");
        $thumbs = $q->GET_THUMBNAIL($ligne['sitename'], 48);
        $ahref = "Loadjs('squid.traffic.statistics.days.php?today-zoom=yes&type=req&familysite={$FamilySite}&day={$_GET["day"]}')";
        $data['rows'][] = array('id' => $ligne['sitename'], 'cell' => array($thumbs, "<div style='margin-top:10px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$ahref}\" style='font-size:14px;text-decoration:underline'>{$ligne['sitename']}</a></div>", "<div style='font-size:14px;margin-top:10px'>{$categories}</span>", $categorize));
    }
    echo json_encode($data);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:65,代码来源:squid.websites.infos.php

示例11: build_report

function build_report($ID, $nopid = false)
{
    if (!is_numeric($ID)) {
        ufdbguard_admin_events("Not a numeric ID", __FUNCTION__, __FILE__, __LINE__, "reports");
        return;
    }
    $t = time();
    $unix = new unix();
    $tablename = "WebTrackMem{$ID}";
    $tableBlock = "WebTrackMeB{$ID}";
    if (!$nopid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$ID}.pid";
        $pid = @file_get_contents($pidfile);
        if ($pid < 100) {
            $pid = null;
        }
        if ($unix->process_exists($pid, basename(__FILE__))) {
            ufdbguard_admin_events("Already executed pid {$pid}", __FUNCTION__, __FILE__, __LINE__, "reports");
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid}\n";
            }
            return;
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Building report {$ID}\n";
    }
    $q = new mysql_squid_builder();
    if ($q->TABLE_EXISTS($tablename)) {
        $q->DELETE_TABLE($tablename);
    }
    if ($q->TABLE_EXISTS($tableBlock)) {
        $q->DELETE_TABLE($tableBlock);
    }
    if (!$q->CreateMemberReportTable($tablename)) {
        ufdbguard_admin_events("could not create table {$tablename}", __FUNCTION__, __FILE__, __LINE__, "reports");
        return;
    }
    if (!$q->CreateMemberReportBlockTable($tableBlock)) {
        ufdbguard_admin_events("could not create table {$tablename}", __FUNCTION__, __FILE__, __LINE__, "reports");
        return;
    }
    $rp = new squid_report($ID);
    $LIST_TABLES_dansguardian_events = $q->LIST_TABLES_dansguardian_events();
    progress(10, $ID);
    $counttables = count($LIST_TABLES_dansguardian_events);
    $prefix = "INSERT IGNORE INTO {$tablename} (`zMD5`,`sitename`,`familysite`,`{$rp->userfield}`,`zDate`,`size`,`hits`,`category`) VALUES ";
    while (list($sourcetable, $ligne) = each($LIST_TABLES_dansguardian_events)) {
        $c++;
        $sql = $rp->BuildQuery($sourcetable);
        $results = $q->QUERY_SQL($sql);
        if (!$q->ok) {
            ufdbguard_admin_events("{$q->mysql_error}\n{$sql}", __FUNCTION__, __FILE__, __LINE__, "reports");
            return;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "Parsing {$sourcetable} \n{$sql}\n-> `" . mysql_num_rows($results) . "` rows\n";
        }
        if (mysql_num_rows($results) == 0) {
            continue;
        }
        $purc = round($c / $counttables, 2) * 100;
        progress($purc, $ID);
        $f = array();
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            $md5 = md5(serialize($ligne));
            $sitename = $ligne["sitename"];
            $familysite = $q->GetFamilySites($sitename);
            if (!isset($GLOBALS["CATEGORY"][$sitename])) {
                $GLOBALS["CATEGORY"][$sitename] = $q->GET_CATEGORIES($sitename);
            }
            $category = $GLOBALS["CATEGORY"][$sitename];
            $source = addslashes($ligne["source"]);
            $zDate = $ligne["zDate"];
            $size = $ligne["size"];
            $hits = $ligne["hits"];
            $category = addslashes($category);
            $f[] = "('{$md5}','{$sitename}','{$familysite}','{$source}','{$zDate}','{$size}','{$hits}','{$category}')";
        }
        if (count($f) == 0) {
            continue;
        }
        $q->QUERY_SQL($prefix . @implode(",", $f));
        if (!$q->ok) {
            ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "reports");
            return;
        }
        if (system_is_overloaded(__FILE__)) {
            sleep(5);
        }
    }
    if ($rp->csv == 1) {
        SaveCSV($ID);
    }
    $LIST_TABLES_BLOCKED = $q->LIST_TABLES_BLOCKED();
    $prefix = "INSERT IGNORE INTO {$tableBlock} (`zMD5`,`zDate`,`hits`,`website`,`category`,`rulename`,`event`,`why`,`explain`,`blocktype`,`{$rp->userfield}`) VALUES ";
    while (list($sourcetable, $ligne) = each($LIST_TABLES_BLOCKED)) {
        $c++;
        if ($GLOBALS["VERBOSE"]) {
            echo "Parsing {$sourcetable}\n";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.reports.php

示例12: CheckWebsites

function CheckWebsites($data, $category)
{
    $founds = array();
    if (!preg_match_all("#Domain:(.*?)<#s", $data, $founds)) {
        echo "NO MATCH scan 1.....\n";
    }
    $count = count($founds[1]);
    if ($count == 0) {
        if (!preg_match_all("#Name:(.*?)<#s", $data, $founds)) {
            echo "NO MATCH scan 2.....\n";
        }
    }
    $count = count($founds[1]);
    if ($count == 0) {
        return;
    }
    echo strlen($curl->data) . " bytes lenth...found: {$count} items\n";
    $q = new mysql_squid_builder();
    if ($count > 0) {
        while (list($id, $www) = each($founds[1])) {
            $www = trim($www);
            $www = str_replace("\t", "", $www);
            $www = str_replace(chr(194), "", $www);
            $www = str_replace(chr(32), "", $www);
            $www = str_replace(chr(160), "", $www);
            if (!preg_match("#([a-z0-9\\-_\\.]+)\\.([a-z]+)\$#i", $www, $re)) {
                echo "{$www} skiped L." . __LINE__ . "\n";
                continue;
            }
            if (strpos($www, ",") > 0) {
                echo "{$www} skiped L." . __LINE__ . "\n";
                continue;
            }
            if (strpos($www, " ") > 0) {
                echo "{$www} skiped L." . __LINE__ . "\n";
                continue;
            }
            if (strpos($www, ":") > 0) {
                echo "{$www} skiped L." . __LINE__ . "\n";
                continue;
            }
            if (strpos($www, "%") > 0) {
                echo "{$www} skiped L." . __LINE__ . "\n";
                continue;
            }
            if (preg_match("#^www\\.(.+)#", $www, $re)) {
                $www = $re[1];
            }
            $articacats = trim($q->GET_CATEGORIES($www, true, true));
            if ($articacats != null) {
                echo "\"{$www}\" already in {$articacats}\n";
            }
            $newsWeb[] = $www;
        }
    }
    while (list($id, $www) = each($newsWeb)) {
        echo "Adding \"{$www}\" -> {$category}\n";
        $q->ADD_CATEGORYZED_WEBSITE($www, $category);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:60,代码来源:exec.cacaweb.com.php

示例13: websites_uid_not_categorised

function websites_uid_not_categorised($uid = null, $tablename = null, $aspid = false)
{
    if (isset($GLOBALS["websites_uid_not_categorised_{$uid}"])) {
        return;
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".{$uid}.pid";
    if ($aspid) {
        $pid = @file_get_contents($pidfile);
        $myfile = basename(__FILE__);
        if ($unix->process_exists($pid, $myfile)) {
            ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "stats");
            return;
        }
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $q = new mysql_squid_builder();
    if ($uid != null) {
        $uidtable = $q->uid_to_tablename($uid);
        $tablename = "www_{$uidtable}";
    }
    if (!$q->FIELD_EXISTS($tablename, "category")) {
        $q->QUERY_SQL("ALTER TABLE `{$tablename}` ADD `category` varchar(255), ADD INDEX (`category`)");
    }
    $sql = "SELECT familysite,`category` FROM `{$tablename}` GROUP BY familysite,`category` HAVING `category` IS NULL ";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            echo "############# ERROR #########\n{$q->mysql_error}\\Line:" . __LINE__ . "\n#############\n";
        }
        return false;
    }
    $c = 0;
    $mysql_num_rows = mysql_num_rows($results);
    if ($mysql_num_rows == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "{$sql} (No rows)\n";
        }
        return true;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $sitename = $ligne["familysite"];
        $IpClass = new IP();
        if ($IpClass->isValid($sitename)) {
            if (isset($GLOBALS["IPCACHE"][$sitename])) {
                $t = time();
                $sitename = gethostbyaddr($sitename);
                events("{$tablename}: {$ligne["familysite"]} -> {$sitename} " . $unix->distanceOfTimeInWords($t, time()) . " gethostbyaddr() LINE:" . __LINE__);
                $GLOBALS["IPCACHE"][$sitename] = $sitename;
            }
        }
        $category = $q->GET_CATEGORIES($sitename);
        if ($IpClass->isValid($sitename)) {
            if ($category == null) {
                $category = "ipaddr";
            }
            $q->categorize($sitename, $category);
        }
        events("{$tablename}: {$ligne["familysite"]} -> {$sitename} [{$category}] LINE:" . __LINE__);
        if (strlen($category) > 0) {
            $category = mysql_escape_string2($category);
            $ligne["familysite"] = mysql_escape_string2($ligne["familysite"]);
            $sql = "UPDATE `{$tablename}` SET `category`='{$category}' WHERE familysite='{$ligne["familysite"]}'";
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                ufdbguard_admin_events("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats");
                return;
            }
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:72,代码来源:exec.squid.retranslations.updates.php

示例14: _not_categorized_months

function _not_categorized_months($table)
{
    $t = time();
    $unix = new unix();
    $sql = "SELECT familysite FROM {$table} WHERE category='' GROUP BY familysite";
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL($sql);
    if (mysql_num_rows($results) == 0) {
        return true;
    }
    $c = 0;
    while ($ligne = mysql_fetch_assoc($results)) {
        $category = $q->GET_CATEGORIES($ligne["familysite"]);
        echo "{$table} {$ligne["familysite"]} -> `{$category}`\n";
        if ($category == null) {
            continue;
        }
        $q->QUERY_SQL("UPDATE {$table} SET category='{$category}' WHERE familysite='{$ligne["familysite"]}'");
        $c++;
    }
    if ($c > 0) {
        stats_admin_events(2, "{$table} {$c} websites categorized took:" . $unix->distanceOfTimeInWords($t, time()), null, __FILE__, __LINE__);
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:24,代码来源:exec.squid.stats.not-categorized.php

示例15: popup_categories_sql

function popup_categories_sql()
{
    //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
    $tpl = new templates();
    $MyPage = CurrentPageName();
    if ($GLOBALS["VERBOSE"]) {
        echo __FUNCTION__ . "::" . __LINE__ . ":: mysql_squid_builder()\n<br>";
    }
    $q = new mysql_squid_builder();
    $OnlyEnabled = false;
    if (isset($_GET["OnlyEnabled"])) {
        $OnlyEnabled = true;
    }
    $search = '%';
    $table = "webfilters_categories_caches";
    $page = 1;
    $ORDER = "ORDER BY categorykey ASC";
    if (!$q->TABLE_EXISTS($table)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "<H2>Create create_webfilters_categories_caches()</H2>\n";
        }
        $q->create_webfilters_categories_caches();
    }
    $FORCE_FILTER = null;
    if (trim($_GET["group"]) != null) {
        $FORCE_FILTER = " AND master_category='{$_GET["group"]}'";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "<h2>" . __FUNCTION__ . "::" . __LINE__ . ":: q->COUNT_ROWS({$table})</h2>\n<br>";
    }
    if ($q->COUNT_ROWS($table) == 0) {
        $ss = new dansguardian_rules();
        $ss->CategoriesTableCache();
    }
    $www = trim(strtolower($_GET["www"]));
    $ArticaDBZ = new mysql_catz();
    $CategoriesFound = $ArticaDBZ->GET_CATEGORIES($www);
    $catArDB = explode(",", $CategoriesFound);
    writelogs("ArticaDB({$www}) = " . @implode(",", $catArDB), __FUNCTION__, __FILE__, __LINE__);
    if (is_array($catArDB)) {
        while (list($num, $ligne) = each($catArDB)) {
            $ligne = trim($ligne);
            if ($ligne == null) {
                continue;
            }
            $hash_ARTICA[$ligne] = true;
        }
    }
    if (preg_match("#www\\.(.+?)\$#i", $www, $re)) {
        $www = $re[1];
    }
    $q = new mysql_squid_builder();
    $CategoriesFound = $q->GET_CATEGORIES($www, true, true, true, true);
    $cats = explode(",", $CategoriesFound);
    $www_encoded = base64_encode($_GET["www"]);
    $COUNT_ROWS = $q->COUNT_ROWS($table);
    $hash_community = array();
    if (is_array($cats)) {
        while (list($num, $ligne) = each($cats)) {
            $ligne = trim($ligne);
            if ($ligne == null) {
                continue;
            }
            $hash_community[$ligne] = true;
        }
    }
    if ($COUNT_ROWS == 0) {
        $data['page'] = $page;
        $data['total'] = $total;
        $data['rows'] = array();
        echo json_encode($data);
        return;
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $_POST["query"] = trim($_POST["query"]);
    if ($_POST["query"] != null) {
        $_POST["query"] = "*{$_POST["query"]}*";
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("**", "*", $_POST["query"]);
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $COUNT_ROWS;
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:squid.categorize.php


注:本文中的mysql_squid_builder::GET_CATEGORIES方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。