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


PHP mysql_squid_builder::category_transform_name方法代码示例

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


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

示例1: 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

示例2: export_category

function export_category($category)
{
    $q = new mysql_squid_builder();
    echo "Exporting {$category}\n";
    if (!preg_match("#^category_.+?#", $category)) {
        $table = "category_" . $q->category_transform_name($category);
    } else {
        $table = $category;
    }
    $t = time();
    $dirtmp = "/tmp/categories_{$t}";
    $Finaldir = "/root/categories";
    @mkdir($dirtmp);
    @mkdir($Finaldir);
    shell_exec("/bin/chmod 777 -R {$dirtmp}");
    $sql = "SELECT zmd5,zDate,category,pattern,uuid FROM {$table} WHERE enabled=1 ORDER BY pattern\n\tINTO OUTFILE '{$dirtmp}/{$table}.csv'\n\tFIELDS TERMINATED BY ','\n\tENCLOSED BY '\"'\n\tLINES TERMINATED BY '\\n'";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
    }
    if (!is_file("{$dirtmp}/{$table}.csv")) {
        echo "{$dirtmp}/{$table}.csv no such file\n";
        return;
    }
    echo "{$dirtmp}/{$table}.csv success\n";
    compress("{$dirtmp}/{$table}.csv", "{$dirtmp}/{$table}.csv.gz");
    if (!is_file("{$dirtmp}/{$table}.csv.gz")) {
        echo "Failed {$dirtmp}/{$table}.csv.gz no such file\n";
        return;
    }
    @unlink("{$dirtmp}/{$table}.csv");
    echo "Success {$dirtmp}/{$table}.csv.gz\n";
    copy("{$dirtmp}/{$table}.csv.gz", "{$Finaldir}/{$table}.csv.gz");
    @unlink("{$dirtmp}/{$table}.csv.gz");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:35,代码来源:exec.squid.exportcatz.php

示例3: download

function download()
{
    $category = $_GET["category"];
    header("Content-Type: text/csv");
    header("Content-Disposition: attachment; filename={$category}.csv");
    header("Cache-Control: no-cache, no-store, must-revalidate");
    // HTTP 1.1
    header("Pragma: no-cache");
    // HTTP 1.0
    header("Expires: 0");
    // Proxies
    $q = new mysql_squid_builder();
    $table = "category_" . $q->category_transform_name($category);
    $sql = "SELECT * FROM {$table} ORDER BY `pattern`";
    $results = $q->QUERY_SQL($sql);
    $f[] = array("Date", "Website");
    while ($ligne = mysql_fetch_assoc($results)) {
        $f[] = array($ligne['zDate'], $ligne["pattern"]);
    }
    outputCSV($f);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:21,代码来源:squid.categories.export.php

示例4: buildconfig


//.........这里部分代码省略.........
    $array["category_warez"] = "warez";
    $array["category_hacking"] = "hacking";
    $array["category_proxy"] = "proxy";
    $array["category_porn"] = "porn";
    $array["category_dating"] = "dating";
    $array["category_mixed_adult"] = "mixed_adult";
    $array["category_sex_lingerie"] = "sex/lingerie";
    $array["category_sexual_education"] = "sexual_education";
    $array["category_marketingware"] = "marketingware";
    $array["category_publicite"] = "publicite";
    $array["category_tracker"] = "tracker";
    $array["category_mailing"] = "mailing";
    $array["category_redirector"] = "redirector";
    $array["category_violence"] = "violence";
    $array["category_spyware"] = "spyware";
    $array["category_malware"] = "malware";
    $array["category_phishing"] = "phishing";
    $array["category_dangerous_material"] = "dangerous_material";
    $array["category_weapons"] = "weapons";
    $array["category_internal"] = "internal";
    $array["category_dynamic"] = "dynamic";
    $array["category_isp"] = "isp";
    $array["category_sslsites"] = "sslsites";
    $array["category_reaffected"] = "reaffected";
    $array["category_arjel"] = "arjel";
    $array["category_bitcoin"] = "bitcoin";
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM personal_categories";
    $results = $q->QUERY_SQL($sql);
    $main_path = "/var/lib/squidguard";
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $category = $ligne["category"];
        $category_table = $q->cat_totablename($category);
        $table = "category_" . $q->category_transform_name($category);
        $categorynamePerso = TransFormCategoryName($category);
        $categorynamePersoBAse = "{$main_path}/{$categorynamePerso}";
        $categorynamePersoPathBase = "{$categorynamePersoBAse}/domains.ufdb";
        $categorynamePersoPathUrls = "{$categorynamePersoBAse}/urls";
        $TARGET_DIR = "/home/ufdbcat/PERSO_{$categorynamePerso}";
        $TARGET_DB = "/home/ufdbcat/PERSO_{$categorynamePerso}/domains.ufdb";
        if (is_file($categorynamePersoPathBase)) {
            @mkdir($TARGET_DIR, 0755, true);
            $size = @filesize($categorynamePersoPathBase);
            $md51 = md5_file($categorynamePersoPathBase);
            $md52 = md5_file($TARGET_DB);
            if ($md51 != $md52) {
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Duplicate personal database {$category}\n";
                }
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$categorynamePersoPathBase}: {$md51}\n";
                }
                if ($GLOBALS["OUTPUT"]) {
                    echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$TARGET_DB}: {$md52}\n";
                }
                @unlink($TARGET_DB);
                if (!@copy($categorynamePersoPathBase, $TARGET_DB)) {
                    if ($GLOBALS["OUTPUT"]) {
                        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Duplicate personal database {$category} [!FAILED]\n";
                    }
                }
                @touch("{$TARGET_DIR}/urls");
                @touch("{$TARGET_DIR}/expressions");
                $md52 = md5_file($TARGET_DB);
                $size2 = @filesize($TARGET_DB);
                if ($md51 != $md52) {
开发者ID:articatech,项目名称:artica,代码行数:67,代码来源:exec.ufdbcat.php

示例5: query

function query(){
	
	$category=null;
	$tpl=new templates();
	$also=$tpl->_ENGINE_parse_body("{also}");
	$MyPage=CurrentPageName();
	$q=new mysql_squid_builder();
	$nowebsites=$tpl->_ENGINE_parse_body("{no_saved_web_site_catz}");
	
	writelogs("Category:$category",__FUNCTION__,__FILE__,__LINE__);
	if($category==null){if($_GET["category"]<>null){$category=$_GET["category"];}}
	if($category==null){if($_POST["qtype"]<>null){$category=$_POST["qtype"];}}	
	
	
	if($_POST["query"]<>null){if($_GET["website"]<>null){$_POST["query"]=$_GET["website"];}}
	if($category==null){json_error_show("Please select a category first");}
	if($_POST["sortname"]=="sitename"){$_POST["sortname"]="zDate";$_POST["sortorder"]="desc";}
	
	writelogs("Category:$category",__FUNCTION__,__FILE__,__LINE__);
	$table="categoryuris_".$q->category_transform_name($category);
	$CategoriesCheckRightsWrite=CategoriesCheckRightsWrite();
	$q->CreateCategoryUrisTable(null,$table);
	$search='%';
	$page=1;
	$COUNT_ROWS=$q->COUNT_ROWS($table);
	
	if($COUNT_ROWS==0){json_error_show("no data",1);}
	
	if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}}	
	if (isset($_POST['page'])) {$page = $_POST['page'];}
	
	$searchstring=string_to_flexquery();
	
	
	if($searchstring<>null){
		$sql="SELECT COUNT(zmd5) as TCOUNT FROM `$table` WHERE 1 $searchstring";
		$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
		$total = $ligne["TCOUNT"];
		
	}else{
		$total = $q->COUNT_ROWS($table);
	}
	
	if (isset($_POST['rp'])) {$rp = $_POST['rp'];}	
	

	
	$pageStart = ($page-1)*$rp;
	$limitSql = "LIMIT $pageStart, $rp";
	
	$sql="SELECT zDate,zmd5,pattern,enabled  FROM `$table` WHERE 1 $searchstring $ORDER $limitSql";	
	$results = $q->QUERY_SQL($sql);
	if(!$q->ok){json_error_show($q->mysql_error,1);}
	if(mysql_num_rows($results)==0){json_error_show("$nowebsites",1);}
	$disabled_text=$tpl->_ENGINE_parse_body("{disabled}");
	
	$data = array();
	$data['page'] = $page;
	$data['total'] = $total;
	$data['rows'] = array();
	
	
	
	while ($ligne = mysql_fetch_assoc($results)) {
		$delete=imgtootltip("delete-24.png","{delete}","DeleteCategorizedURI('{$ligne["zmd5"]}','$table')");

		$enabled=$ligne["enabled"];
		$color="color:black";
		if($enabled==0){
			$color="color:#B6ACAC";
			$added=$added."<div><i style='font-size:11px'>$disabled_text</i></div>";
			$moveAll="&nbsp;";
			$move="&nbsp;";
			
		}
		
$jscat="<a href=\"javascript:blur();\" 
		OnClick=\"javascript:Loadjs('squid.categorize.php?www={$ligne["pattern"]}');\"
		style='font-size:14px;text-decoration:underline;$color'>";	

if(!$CategoriesCheckRightsWrite){
	$jscat=null;
	$delete=null;
}
		
	$data['rows'][] = array(
		'id' => $ligne['zmd5'],
		'cell' => array("
		<span style='font-size:14px;$color'>{$ligne['zDate']}</span>",
		"<span style='font-size:14px;$color'>$jscat{$ligne['pattern']}</a></span>$added",$delete)
		);
	}
	
	
echo json_encode($data);	

	
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:98,代码来源:squid.categories.urls.php

示例6: inject

function inject($category, $table = null, $file = null)
{
    include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
    $unix = new unix();
    $q = new mysql_squid_builder();
    if (is_file($category)) {
        $file = $category;
        $category_name = basename($file);
        echo "{$file} -> {$category_name}\n";
        if (preg_match("#(.+?)\\.gz\$#", $category_name)) {
            echo "{$category_name} -> gunzip\n";
            $new_category_name = str_replace(".gz", "", $category_name);
            $gunzip = $unix->find_program("gunzip");
            $target_file = dirname($file) . "/{$new_category_name}";
            $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1";
            echo "{$cmd}\n";
            shell_exec($cmd);
            if (!is_file($target_file)) {
                echo "Uncompress failed\n";
                return;
            }
            $file = $target_file;
            $table = $new_category_name;
            $category = $q->tablename_tocat($table);
            echo "{$new_category_name} -> {$table}\n";
        } else {
            $table = $category_name;
            echo "{$new_category_name} -> {$table}\n";
            $category = $q->tablename_tocat($table);
        }
        echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n";
    }
    if (!is_file($file)) {
        if (!is_file($table)) {
            echo "`{$table}` No such file\n";
        }
        if (is_file($table)) {
            $file = $table;
            $table = null;
        }
    }
    if ($table == null) {
        $table = "category_" . $q->category_transform_name($category);
        echo "Table will be {$table}\n";
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "{$table} does not exists, check if it is an official one\n";
        $dans = new dansguardian_rules();
        if (isset($dans->array_blacksites[$category])) {
            $q->CreateCategoryTable($category);
        }
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "`{$category}` -> no such table \"{$table}\"\n";
        return;
    }
    $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        if (preg_match("#is marked as crashed and last#", $q->mysql_error)) {
            echo "`{$table}` -> crashed, remove \"{$table}\"\n";
            $q->QUERY_SQL("DROP TABLE {$table}");
            $q->QUERY_SQL("flush tables");
            $q = new mysql_squid_builder();
            echo "`{$table}` -> Create category \"{$category}\"\n";
            $q->CreateCategoryTable($category);
            $q->CreateCategoryTable($category);
            $q = new mysql_squid_builder();
        }
        if (!$q->TABLE_EXISTS($table)) {
            echo "`{$category}` -> no such table \"{$table}\"\n";
            return;
        }
    }
    if ($file == null) {
        $dir = "/var/lib/squidguard";
        if ($GLOBALS["SHALLA"]) {
            $dir = "/root/shalla/BL";
        }
        if (!is_file("{$dir}/{$category}/domains")) {
            echo "{$dir}/{$category}/domains no such file";
            return;
        }
        $file = "{$dir}/{$category}/domains";
    }
    if (!is_file($file)) {
        echo "{$file} no such file";
        return;
    }
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        echo "No uuid\n";
        return;
    }
    echo "open {$file}\n";
    $handle = @fopen($file, "r");
    if (!$handle) {
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

示例7: Execute

function Execute()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $myFile = basename(__FILE__);
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, $myFile)) {
        WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
        die;
    }
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $q = new mysql_squid_builder();
    if ($q->COUNT_ROWS("framework_orders") == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Table framework_orders as no row\n";
        }
        die;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nice = EXEC_NICE();
    $q = new mysql_squid_builder();
    $results = $q->QUERY_SQL("SELECT * FROM framework_orders");
    if (!$q->ok) {
        if (strpos($q->mysql_error, "doesn't exist") > 0) {
            $q->CheckTables();
            $results = $q->QUERY_SQL("SELECT * FROM framework_orders");
        }
    }
    if (!$q->ok) {
        ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "framework");
        die;
    }
    $reconfigure_plugins = false;
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($GLOBALS["VERBOSE"]) {
            echo "ORDER: {$ligne["ORDER"]} -> {$ligne["zmd5"]}\n";
        }
        if (preg_match("#COMPILEDB:(.+)#", $ligne["ORDER"], $re)) {
            if (preg_match("#english-(.+)#", $re[1])) {
                $q->QUERY_SQL("DELETE FROM framework_orders WHERE zmd5='{$ligne["zmd5"]}'");
                continue;
            }
            ufdbguard_admin_events("LAUNCH: category {$re[1]} compilation", __FUNCTION__, __FILE__, __LINE__, "framework");
            $re[1] = trim($re[1]);
            $table = "category_" . $q->category_transform_name($re[1]);
            if ($GLOBALS["VERBOSE"]) {
                echo "order to compile database {$re[1]} (table {$table})\n";
            }
            if (!$q->TABLE_EXISTS($table)) {
                ufdbguard_admin_events("Fatal: {$table} no suche table, create it", __FUNCTION__, __FILE__, __LINE__, "framework");
                $q->CreateCategoryTable(null, $table);
            }
            $cmd = "{$nice} {$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category \"{$re[1]}\"";
            if ($GLOBALS["VERBOSE"]) {
                echo "{$cmd}\n";
            }
            $q->QUERY_SQL("DELETE FROM framework_orders WHERE zmd5='{$ligne["zmd5"]}'");
            if (!$q->ok) {
                ufdbguard_admin_events("Fatal: {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "framework");
                die;
            }
            shell_exec($cmd);
            $reconfigure_plugins = true;
        }
    }
    if ($reconfigure_plugins) {
        ufdbguard_admin_events("LAUNCH: filters reconfiguration", __FUNCTION__, __FILE__, __LINE__, "framework");
        shell_exec("{$nice} {$php5} /usr/share/artica-postfix/exec.squidguard.php --build");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:70,代码来源:exec.squid.framework.php

示例8: www_delete

function www_delete()
{
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    ini_set('error_prepend_string', "<p class=text-error>");
    ini_set('error_append_string', "</p>\n");
    $q = new mysql_squid_builder();
    $category_table = "category_" . $q->category_transform_name($_POST["category"]);
    $q->QUERY_SQL("DELETE FROM {$category_table} WHERE pattern='{$_POST["www-delete"]}'");
    $q->categorize_logs($_POST["category"], "{delete}", $_POST["www-delete"]);
    if (!$q->ok) {
        echo $q->mysql_error;
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:14,代码来源:miniadmin.proxy.dynamic.categories.php

示例9: WriteCategory

function WriteCategory($category)
{
    $squidguard = new squidguard();
    $q = new mysql_squid_builder();
    echo "Starting......: " . date("H:i:s") . " Artica database writing category {$category}\n";
    echo "Starting......: " . date("H:i:s") . " Artica database /etc/dansguardian/lists/blacklist-artica/{$category}/domains\n";
    echo "Starting......: " . date("H:i:s") . " Artica database /var/lib/squidguard/blacklist-artica/{$category}\n";
    @mkdir("/etc/dansguardian/lists/blacklist-artica/{$category}", 0755, true);
    @mkdir("/var/lib/squidguard/blacklist-artica/{$category}", 0755, true);
    if (!is_dir("/var/lib/squidguard/{$category}")) {
        @mkdir("/var/lib/squidguard/{$category}", 0755, true);
    }
    if (!is_dir("/etc/dansguardian/lists/blacklist/{$category}/urls")) {
        @mkdir("/etc/dansguardian/lists/blacklist/{$category}/urls", 755, true);
    }
    if (!is_file("/etc/dansguardian/lists/blacklist/{$category}/urls")) {
        @file_put_contents("/etc/dansguardian/lists/blacklist/{$category}/urls", "\n");
    }
    if (!is_file("/var/lib/squidguard/{$category}/urls")) {
        @file_put_contents("/var/lib/squidguard/{$category}/urls", "\n");
    }
    $tablesource = "category_" . $q->category_transform_name($category);
    $sql = "SELECT pattern FROM {$tablesource} WHERE enabled=1";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "Starting......: " . date("H:i:s") . " Artica database {$q->mysql_error}\n";
        return;
    }
    $num = mysql_num_rows($results);
    echo "Starting......: " . date("H:i:s") . " Artica database {$num} domains\n";
    $domain_path_1 = "/etc/dansguardian/lists/blacklist/{$category}/domains";
    $domain_path_2 = "/var/lib/squidguard/{$category}/domains";
    $fh1 = fopen($domain_path_1, 'w+');
    $fh2 = fopen($domain_path_2, 'w+');
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["pattern"] == null) {
            continue;
        }
        if (!$squidguard->VerifyDomainCompiledPattern($ligne["pattern"])) {
            continue;
        }
        fwrite($fh1, $ligne["pattern"] . "\n");
        fwrite($fh2, $ligne["pattern"] . "\n");
    }
    fclose($fh1);
    fclose($fh2);
    echo "Starting......: " . date("H:i:s") . " finish\n\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:48,代码来源:exec.web-community-filter.php

示例10: rangetables

function rangetables()
{
    $q = new mysql_squid_builder();
    $tables = $q->LIST_TABLES_CATEGORIES();
    while (list($table, $none) = each($tables)) {
        $sql = "SELECT category FROM {$table} GROUP BY category";
        $results = $q->QUERY_SQL($sql);
        if (mysql_numrows($results) == 1) {
            continue;
        }
        while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
            if (trim($ligne["category"]) == null) {
                continue;
            }
            $sourceCategory = $ligne["category"];
            if ($ligne["category"] == "category_publicite") {
                $ligne["category"] = "publicite";
            }
            if ($ligne["category"] == "category_automobile_") {
                $ligne["category"] = "automobile/cars";
            }
            if ($ligne["category"] == "category_finance_oth") {
                $ligne["category"] = "finance/other";
            }
            if ($ligne["category"] == "category_recreation_") {
                $ligne["category"] = "recreation/travel";
            }
            echo "Found category `{$ligne["category"]}`\n";
            $destTable = "category_" . $q->category_transform_name($ligne["category"]);
            $destTable = str_replace("category_category_", "category_", $destTable);
            if (trim($destTable) == trim($table)) {
                continue;
            }
            echo "Move from {$table}: Category {$ligne["category"]} to table {$destTable}\n";
            $sql = "INSERT IGNORE INTO {$destTable} (`zmd5`,`zDate`,`category`,`pattern`,`enabled`,`uuid`,`sended`) \n\t\t\tSELECT zmd5,zDate,category,pattern,enabled,uuid,sended FROM {$table} WHERE category='{$sourceCategory}'";
            $q->QUERY_SQL($sql);
            if (!$q->ok) {
                echo $q->mysql_error . "\n";
                continue;
            }
            $q->QUERY_SQL("DELETE FROM {$table} WHERE category='{$sourceCategory}'");
        }
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:44,代码来源:exec.squid.stats.php

示例11: category_urls_delete

function category_urls_delete()
{
    $category = $_POST["category"];
    $item = mysql_escape_string2($_POST["category-items-delete"]);
    $q = new mysql_squid_builder();
    $table = "categoryuris_" . $q->category_transform_name($category);
    $q->QUERY_SQL("DELETE FROM {$table} WHERE `pattern`='{$item}'");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $sock = new sockets();
    $sock->getFrameWork("squid.php?ufdbguard-compile-database={$category}");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:14,代码来源:miniadmin.webfiltering.categories.php

示例12: inject

function inject($category, $table = null, $file = null)
{
    include_once dirname(__FILE__) . "/ressources/class.dansguardian.inc";
    $unix = new unix();
    $q = new mysql_squid_builder();
    if (is_file($category)) {
        $file = $category;
        $category_name = basename($file);
        echo "{$file} -> {$category_name}\n";
        if (preg_match("#(.+?)\\.gz\$#", $category_name)) {
            echo "{$category_name} -> gunzip\n";
            $new_category_name = str_replace(".gz", "", $category_name);
            $gunzip = $unix->find_program("gunzip");
            $target_file = dirname($file) . "/{$new_category_name}";
            $cmd = "/bin/gunzip -d -c \"{$file}\" >{$target_file} 2>&1";
            echo "{$cmd}\n";
            shell_exec($cmd);
            if (!is_file($target_file)) {
                echo "Uncompress failed\n";
                return;
            }
            $file = $target_file;
            $table = $new_category_name;
            $category = $q->tablename_tocat($table);
            echo "{$new_category_name} -> {$table}\n";
        } else {
            $table = $category_name;
            echo "{$new_category_name} -> {$table}\n";
            $category = $q->tablename_tocat($table);
        }
        echo "Table: {$table}\nSource File:{$file}\nCategory: {$category}\n";
    }
    if (!is_file($file)) {
        if (!is_file($table)) {
            echo "`{$table}` No such file\n";
        }
        if (is_file($table)) {
            $file = $table;
            $table = null;
        }
    }
    if ($table == null) {
        $table = "category_" . $q->category_transform_name($category);
        echo "Table will be {$table}\n";
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "{$table} does not exists, check if it is an official one\n";
        $dans = new dansguardian_rules();
        if (isset($dans->array_blacksites[$category])) {
            $q->CreateCategoryTable($category);
        }
    }
    if (!$q->TABLE_EXISTS($table)) {
        echo "`{$category}` -> no such table \"{$table}\"\n";
        return;
    }
    $sql = "SELECT COUNT(*) AS TCOUNT FROM {$table}";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        if (preg_match("#is marked as crashed and last#", $q->mysql_error)) {
            echo "`{$table}` -> crashed, remove \"{$table}\"\n";
            $q->QUERY_SQL("DROP TABLE {$table}");
            $q->QUERY_SQL("flush tables");
            $q = new mysql_squid_builder();
            echo "`{$table}` -> Create category \"{$category}\"\n";
            $q->CreateCategoryTable($category);
            $q->CreateCategoryTable($category);
            $q = new mysql_squid_builder();
        }
        if (!$q->TABLE_EXISTS($table)) {
            echo "`{$category}` -> no such table \"{$table}\"\n";
            return;
        }
    }
    if ($file == null) {
        $dir = "/var/lib/squidguard";
        if ($GLOBALS["SHALLA"]) {
            $dir = "/root/shalla/BL";
        }
        if (!is_file("{$dir}/{$category}/domains")) {
            echo "{$dir}/{$category}/domains no such file";
            return;
        }
        $file = "{$dir}/{$category}/domains";
    }
    if (!is_file($file)) {
        echo "{$file} no such file";
        return;
    }
    $sock = new sockets();
    $unix = new unix();
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        echo "No uuid\n";
        return;
    }
    echo "open {$file}\n";
    $handle = @fopen($file, "r");
    if (!$handle) {
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

示例13: MoveCategorizedWebsite

function MoveCategorizedWebsite($md5=null,$nextCategory=null,$table=null){
	$q=new mysql_squid_builder();
	$sock=new sockets();
	if($md5==null){$md5=$_POST["MoveCategorizedWebsite"];}
	if($nextCategory==null){$nextCategory=trim($_POST["NextCategory"]);}
	if($table==null){$table=trim($_POST["TABLE"]);}
	
	
	if($nextCategory==null){echo "Next category = Null\n";return;}
	if($table==null){echo "Table = Null\n";return;}
	if($md5==null){echo "md5 = Null\n";return;}
	
	
	if(!isset($GLOBALS["uuid"])){$GLOBALS["uuid"]=base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes"));}
	$uuid=$GLOBALS["uuid"];
	
	$sql="SELECT * FROM $table WHERE zmd5='$md5'";
	$ligne=mysql_fetch_array($q->QUERY_SQL($sql));
	if(!$q->ok){echo $q->mysql_error;return;}
	$www=$ligne["pattern"];
	$sql="INSERT IGNORE INTO categorize_delete (sitename,category,zmd5) VALUES ('{$ligne["pattern"]}','{$ligne["category"]}','{$ligne["zmd5"]}')";
	$q->QUERY_SQL($sql);
	if(!$q->ok){echo $q->mysql_error;return;}
	$q->QUERY_SQL("UPDATE $table SET enabled=0 WHERE zmd5='$md5'");
	if(!$q->ok){echo $q->mysql_error;return;}
	$sock->getFrameWork("squid.php?export-deleted-categories=yes");
	
	
	$newmd5=md5($nextCategory.$www);
	$q->QUERY_SQL("INSERT IGNORE INTO categorize_changes (zmd5,sitename,category) VALUES('$newmd5','$www','$nextCategory')");
	if(!$q->ok){echo $q->mysql_error;return;}	
	$q->CreateCategoryTable($nextCategory);
	$category_table=$q->category_transform_name($nextCategory);	
	$q->QUERY_SQL("INSERT IGNORE INTO categorize (zmd5,zDate,category,pattern,uuid) VALUES('$newmd5',NOW(),'$nextCategory','$www','$uuid')");
	if(!$q->ok){echo $q->mysql_error;return;}
	$q->QUERY_SQL("INSERT IGNORE INTO category_$category_table (zmd5,zDate,category,pattern,uuid,enabled) VALUES('$md5',NOW(),'$nextCategory','$www','$uuid',1)");
	if(!$q->ok){echo $q->mysql_error;return;}	
	
	$cats=addslashes($q->GET_CATEGORIES($www,true));
	
	$q->QUERY_SQL("UPDATE visited_sites SET category='$cats' WHERE sitename='$www'");
	if(!$q->ok){echo $q->mysql_error."\n";echo $sql."\n";}	
	
	$sock=new sockets();
	$sock->getFrameWork("cmd.php?export-community-categories=yes");
	$sock->getFrameWork("squid.php?re-categorize=yes");	

}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:48,代码来源:squid.categories.php

示例14: CategorizeAll_perform

function CategorizeAll_perform(){
	if($_GET["pattern"]==null){return;}
	$sock=new sockets();
	$uuid=base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes"));
	if($uuid==null){echo "UUID=NULL; Aborting";return;}	
	$pattern=" AND sitename LIKE '%{$_GET["pattern"]}%' ";
	$pattern=str_replace("*","%",$pattern);
	$sql="SELECT sitename FROM `visited_sites` WHERE  LENGTH( `category` )=0 $pattern";
	$category=$_GET["CategorizeAll_category"];
	if($category==null){return;}
	if($category=="teans"){$category="teens";}
	$q=new mysql_squid_builder();
	$results=$q->QUERY_SQL($sql,"artica_events");
	
	if(!$q->ok){
		echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__;
		return;
	}
	if($_GET["week"]<>null){$_GET["day"]=$_GET["week"];}
	
	$category_table="category_".$q->category_transform_name($category);
	
	if(!$q->TABLE_EXISTS($category_table)){$q->CreateCategoryTable($category);}
	
	while($ligne=mysql_fetch_array($results,MYSQL_ASSOC)){
		$website=$ligne["sitename"];
		if($website==null){return;}
		$www=trim(strtolower($website));
		if(preg_match("#^www\.(.+?)$#i",trim($www),$re)){$www=$re[1];}
		$md5=md5($category.$www);
		$enabled=1;
		if($www==null){echo "Alert: website is null...\n";return;}
		
		$sql_add="INSERT INTO $category_table (zmd5,zDate,category,pattern,uuid,enabled) VALUES('$md5',NOW(),'$category','$www','$uuid',1)";
		$ligne=mysql_fetch_array($q->QUERY_SQL("SELECT category,pattern FROM `$category_table` WHERE zmd5='$md5'"));
		if($ligne["category"]==null){$sql_add="UPDATE $category_table SET `category`='$category',pattern='$www' WHERE zmd5='$md5'";}
		if($ligne["pattern"]==null){$sql_add="UPDATE $category_table SET `category`='$category',pattern='$www' WHERE zmd5='$md5'";}
		$q->QUERY_SQL($sql_add);
		if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;return;}
		
		$sql="INSERT IGNORE INTO categorize (zmd5,zDate,category,pattern,uuid) VALUES('$md5',NOW(),'$category','$www','$uuid')";
		$q->QUERY_SQL($sql);
		if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;return;}	
		
		
	$sql="UPDATE `visited_sites` SET `category`='$category' WHERE LENGTH( `category` )=0 $pattern";
	$q->QUERY_SQL($sql);
	if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;return;}			
			
		if($_GET["day"]<>null){
			if($pattern<>null){
				$time=strtotime($_GET["day"]." 00:00:00");
				$tableSrc=date('Ymd',$time)."_hour";
				$categories=$q->GET_CATEGORIES($www,true);
				if($categories==null){$categories=$category;}
				
				$sql="UPDATE $tableSrc SET category='$categories' WHERE LENGTH( `category` )=0 $pattern";
				$q->QUERY_SQL($sql);
				writelogs($sql,__FUNCTION__,__FILE__,__LINE__);                                                                                                                                                                                                                                                                                                                                        
				if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;}
				
				
				$tableWeek=date("YW",$time)."_week";
				$sql="UPDATE $tableWeek SET category='$categories' WHERE LENGTH( `category` )=0 $pattern";
				$q->QUERY_SQL($sql);
				writelogs($sql,__FUNCTION__,__FILE__,__LINE__);  
				if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;}
				
				
				$tableSrcDay=date('Ym',$time)."_day";
				if($q->TABLE_EXISTS($tableSrcDay)){
					$sql="UPDATE $tableSrcDay SET category='$categories' WHERE LENGTH( `category` )=0 $pattern";
					writelogs($sql,__FUNCTION__,__FILE__,__LINE__);  
					$q->QUERY_SQL($sql);
					if(!$q->ok){echo $q->mysql_error."\n".basename(__FILE__)."\nLine".__LINE__."\n";echo $sql;}
				}
				
				
			}else{
				echo "Pattern is null!!\n";
			}
		}		
		
	}
	

	$sock=new sockets();
	$sock->getFrameWork("cmd.php?export-community-categories=yes");	
	
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:90,代码来源:squid.visited.php

示例15: categorize_delete

function categorize_delete()
{
    $unix = new unix();
    $URIBASE = $unix->MAIN_URI();
    $tmpdir = $unix->TEMP_DIR();
    if (!is_file("{$tmpdir}/categorize_delete.sql")) {
        $curl = new ccurl("{$URIBASE}/blacklist/categorize_delete.gz");
        if (!$curl->GetFile("{$tmpdir}/categorize_delete.gz")) {
            // ufdbguard_admin_events("Fatal: unable to download categorize_delete.gz file $curl->error",__FUNCTION__,__FILE__,__LINE__,"ufbd-artica");
            return;
        }
        if (!extractGZ("{$tmpdir}/categorize_delete.gz", "{$tmpdir}/categorize_delete.sql")) {
            // ufdbguard_admin_events("Fatal: unable to extract $tmpdir/categorize_delete.gz",__FUNCTION__,__FILE__,__LINE__,"ufbd-artica");
            return;
        }
    }
    $q = new mysql_squid_builder();
    $datas = explode("\n", @file_get_contents("{$tmpdir}/categorize_delete.sql"));
    while (list($index, $row) = each($datas)) {
        if (trim($row) == null) {
            continue;
        }
        $ligne = unserialize($row);
        $category = $ligne["category"];
        $pattern = $ligne["sitename"];
        $tablename = "category_" . $q->category_transform_name($category);
        if (!$q->TABLE_EXISTS($tablename)) {
            $q->CreateCategoryTable($category);
        }
        $q->QUERY_SQL("UPDATE {$tablename} SET enabled=0 WHERE `pattern`='{$pattern}'");
        if (!$q->ok) {
            echo $q->mysql_error . "\n";
        }
    }
    // ufdbguard_admin_events("Success updating deleted ". count($datas)." websites from categories",__FUNCTION__,__FILE__,__LINE__,"ufbd-artica");
    @unlink("{$tmpdir}/categorize_delete.sql");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:37,代码来源:exec.squid.blacklists.php


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