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


PHP mysql_squid_builder::CreateCategoryTable方法代码示例

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


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

示例1: migrate_categories_single

function migrate_categories_single($category)
{
    $categoryTB = str_replace('/', "_", $category);
    $categoryTB = str_replace('-', "_", $categoryTB);
    $qA = new mysql_squid_builder();
    $q = new mysql();
    $qA->CreateCategoryTable($categoryTB);
    if (!$qA->TABLE_EXISTS("category_{$categoryTB}")) {
        events_tail("Unable to create category_{$categoryTB} table");
        return false;
    }
    $sql = "SELECT * FROM dansguardian_community_categories WHERE category='{$category}'";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    $mysql_num_rows = mysql_num_rows($results);
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . " => {$mysql_num_rows}\n";
    }
    $prefix = "INSERT IGNORE INTO category_{$categoryTB}(`zmd5`,`zDate`,`category`,`pattern`,`enabled`,`uuid`) VALUES ";
    $c = 0;
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $c++;
        $f[] = "('{$ligne["zmd5"]}','{$ligne["zDate"]}','{$ligne["category"]}','{$ligne["pattern"]}','{$ligne["enabled"]}','{$ligne["uuid"]}')";
        if (count($f) > 500) {
            events_tail("Injecting {$c} rows");
            $qA->QUERY_SQL("{$prefix}" . @implode(",", $f));
            $f = array();
            if (!$q->ok) {
                writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
                return;
            }
        }
    }
    if (count($f) > 0) {
        $c = $c + count($f);
        events_tail("Injecting {$c} rows");
        $qA->QUERY_SQL("{$prefix}" . @implode(",", $f));
        if (!$q->ok) {
            writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    events_tail("removing category {$category} in original table");
    $sql = "DELETE FROM dansguardian_community_categories WHERE category='{$category}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        writelogs("Fatal Error: {$q->mysql_error}", __CLASS__ . '/' . __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    return true;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:54,代码来源:exec.squid.logs.migrate.php

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

示例3: add_category_save

function add_category_save()
{
    $_POST["personal_database"] = url_decode_special_tool($_POST["personal_database"]);
    $_POST["category_text"] = url_decode_special_tool($_POST["category_text"]);
    $org = $_POST["personal_database"];
    include_once dirname(__FILE__) . "/ressources/class.html.tools.inc";
    $html = new htmltools_inc();
    $dans = new dansguardian_rules();
    $_POST["personal_database"] = strtolower($html->StripSpecialsChars($_POST["personal_database"]));
    if ($_POST["personal_database"] == null) {
        echo "No category set or wrong category name \"{$org}\"\n";
        return;
    }
    if ($_POST["personal_database"] == "security") {
        $_POST["personal_database"] = "security2";
    }
    if ($_POST["CatzByGroupA"] != null) {
        $_POST["CatzByGroupL"] = $_POST["CatzByGroupA"];
    }
    $_POST["CatzByGroupL"] = mysql_escape_string2($_POST["CatzByGroupL"]);
    $_POST["category_text"] = url_decode_special_tool($_POST["category_text"]);
    $_POST["category_text"] = mysql_escape_string2($_POST["category_text"]);
    $q = new mysql_squid_builder();
    $sql = "SELECT category FROM personal_categories WHERE category='{$_POST["personal_database"]}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if ($ligne["category"] != null) {
        $sql = "UPDATE personal_categories\n\t\tSET category_description='{$_POST["category_text"]}',\n\t\t`PublicMode`='{$_POST["PublicMode"]}',\n\t\tmaster_category='{$_POST["CatzByGroupL"]}'\n\t\tWHERE category='{$_POST["personal_database"]}'\n\t\t";
    } else {
        if (isset($dans->array_blacksites[$_POST["personal_database"]])) {
            $tpl = new templates();
            echo $tpl->javascript_parse_text("{$_POST["personal_database"]}:{category_already_exists}");
            return;
        }
        $sql = "INSERT IGNORE INTO personal_categories (category,category_description,master_category,PublicMode)\n\t\tVALUES ('{$_POST["personal_database"]}','{$_POST["category_text"]}','{$_POST["CatzByGroupL"]}','{$_POST["PublicMode"]}');";
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $q->CreateCategoryTable($_POST["personal_database"]);
    $sql = "TRUNCATE TABLE webfilters_categories_caches";
    $dans->CategoriesTableCache();
    $dans->CleanCategoryCaches();
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:45,代码来源:dansguardian2.databases.perso.php

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

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

示例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:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

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

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

示例9: Export

function Export($asPid = false)
{
    return;
    $unix = new unix();
    $restartProcess = false;
    $nohup = $unix->find_program("nohup");
    $php5 = $unix->LOCATE_PHP5_BIN();
    $cachetime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "CacheTime: {$cachetime}\n";
    }
    $restart_cmd = trim("{$nohup} {$php5} " . __FILE__ . " --export >/dev/null 2>&1 &");
    $sock = new sockets();
    shell_exec(trim("{$nohup} {$php5} " . __FILE__ . " --export-not-categorized >/dev/null 2>&1 &"));
    if ($asPid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $unix = new unix();
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            WriteMyLogs("Already executed PID:{$pid}, die()", __FUNCTION__, __FILE__, __LINE__);
            die;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $uuid = $unix->GetUniqueID();
    if ($uuid == null) {
        if ($GLOBALS["VERBOSE"]) {
            echo "No system ID !\n";
        }
        return;
    }
    $q = new mysql_squid_builder();
    $tables = $q->LIST_TABLES_CATEGORIES();
    $c = 0;
    while (list($table, $www) = each($tables)) {
        $limit = null;
        $limitupate = null;
        if (!preg_match("#category_(.+?)\$#", $table)) {
            continue;
        }
        if (!$q->TABLE_EXISTS($table)) {
            continue;
        }
        $sql = "SELECT COUNT(zmd5) as tcount FROM {$table} WHERE sended=0 and enabled=1";
        $q->CreateCategoryTable(null, $table);
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            writelogs("{$table} {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
        $prefix = "INSERT IGNORE INTO categorize (zmd5 ,pattern,zDate,uuid,category) VALUES";
        if ($ligne["tcount"] > 0) {
            writelogs("{$table} {$ligne["tcount"]} items to export", __FUNCTION__, __FILE__, __LINE__);
            if ($ligne["tcount"] > 5000) {
                $limit = "LIMIT 0,5000";
                $limitupate = "LIMIT 5000";
            }
            $results = $q->QUERY_SQL("SELECT * FROM {$table} WHERE sended=0 AND enabled=1 {$limit}");
            while ($ligne2 = mysql_fetch_array($results, MYSQL_ASSOC)) {
                $md5 = md5("{$ligne2["category"]}{$ligne2["pattern"]}");
                $f[] = "('{$md5}','{$ligne2["pattern"]}','{$ligne2["zDate"]}','{$uuid}','{$ligne2["category"]}')";
                $c++;
                if (count($f) > 1000) {
                    $q->QUERY_SQL($prefix . @implode(",", $f));
                    if (!$q->ok) {
                        echo $q->mysql_error . "\n";
                        return;
                    }
                    $f = array();
                }
            }
            $q->QUERY_SQL("UPDATE {$table} SET sended=1 WHERE sended=0 {$limitupate}");
        }
    }
    if (count($f) > 0) {
        $q->QUERY_SQL($prefix . @implode(",", $f));
        $f = array();
    }
    $ALLCOUNT = $q->COUNT_ROWS("categorize");
    if ($GLOBALS["VERBOSE"]) {
        echo "Total row in categorize table: {$ALLCOUNT}\n";
    }
    if ($ALLCOUNT > 2000) {
        $restartProcess = true;
    }
    $sql = "SELECT * FROM categorize ORDER BY zDate DESC LIMIT 0,2000";
    if ($GLOBALS["VERBOSE"]) {
        echo "Execute query\n";
    }
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error . "\n{$sql}\n";
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["category"] == null) {
            continue;
        }
        if ($ligne["pattern"] == null) {
            continue;
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.web-community-filter.php

示例10: defragment_category_table

function defragment_category_table($tablename)
{
    if (preg_match("#(.+?)bak\$#", $tablename, $re)) {
        $oldtable = $tablename;
        $tablename = $re[1];
    } else {
        $oldtable = "{$tablename}bak";
    }
    $q = new mysql_squid_builder();
    if (!$q->TABLE_EXISTS($oldtable)) {
        $sql = "RENAME TABLE `squidlogs`.`{$tablename}` TO `squidlogs`.`{$oldtable}`;";
        $q->QUERY_SQL($sql);
    }
    if (!$q->ok) {
        writelogs_squid("Fatal: {$q->mysql_error}} on `{$tablename}`", __FUNCTION__, __FILE__, __LINE__, "defrag");
        return;
    }
    $tablename = strtolower($tablename);
    $q->CreateCategoryTable(null, $tablename);
    $f = array();
    $countTotal = $q->COUNT_ROWS($oldtable);
    $sql = "INSERT IGNORE INTO {$tablename} (`zmd5`,`zDate`,`category`,`pattern`,`enabled`,`uuid`,`sended`) \n\tSELECT zmd5,zDate,category,pattern,enabled,uuid,sended FROM {$oldtable}";
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
        return false;
    }
    $q->QUERY_SQL("DROP TABLE {$oldtable}");
    return true;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:30,代码来源:exec.squid.stats.php

示例11: category_save

function category_save()
{
    include_once dirname(__FILE__) . "/ressources/class.ldap.inc";
    $ldap = new clladp();
    $dans = new dansguardian_rules();
    $_POST["category-to-add"] = url_decode_special_tool($_POST["category-to-add"]);
    $_POST["category_text"] = url_decode_special_tool($_POST["category_text"]);
    if ($_POST["category-to-add"] == "security") {
        $_POST["category-to-add"] = "security2";
    }
    if ($_POST["CatzByGroupA"] != null) {
        $_POST["group"] = $_POST["CatzByGroupA"];
    }
    $_POST["CatzByGroupL"] = mysql_escape_string2($_POST["CatzByGroupL"]);
    $_POST["category_text"] = mysql_escape_string2($_POST["category_text"]);
    $q = new mysql_squid_builder();
    $sql = "SELECT category FROM personal_categories WHERE category='" . mysql_escape_string2($_POST["category-to-add"]) . "'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
    if ($ligne["category"] != null) {
        $sql = "UPDATE personal_categories\n\t\t\tSET category_description='{$_POST["category_text"]}',\n\t\t\tmaster_category='{$_POST["group"]}'\n\t\t\tWHERE category='{$_POST["category-to-add"]}'";
    } else {
        $_POST["category-to-add"] = strtolower($ldap->StripSpecialsChars($_POST["category-to-add"]));
        if (isset($dans->array_blacksites[$_POST["category-to-add"]])) {
            $tpl = new templates();
            echo $tpl->javascript_parse_text("{$_POST["category-to-add"]}:: {category_already_exists}");
            return;
        }
        $sql = "INSERT IGNORE INTO personal_categories (category,category_description,master_category)\n\t\tVALUES ('{$_POST["category-to-add"]}','{$_POST["category_text"]}','{$_POST["group"]}');";
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    $q->CreateCategoryTable($_POST["category-to-add"]);
    $sql = "TRUNCATE TABLE webfilters_categories_caches";
    $dans->CategoriesTableCache();
    $dans->CleanCategoryCaches();
    $sock = new sockets();
    $sock->getFrameWork("squid.php?clean-catz-cache=yes");
    $sock->getFrameWork("squid.php?export-web-categories=yes");
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:42,代码来源:miniadmin.webfiltering.categories.php


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