Пример #1
0
function WriteCategory($category){
	$squidguard=new squidguard();
	echo "Starting......: Artica database writing category $category\n";
	echo "Starting......: Artica database /etc/dansguardian/lists/blacklist-artica/$category/domains\n";
	echo "Starting......: 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_file("/etc/dansguardian/lists/blacklist-artica/$category/urls")){@file_put_contents("/etc/dansguardian/lists/blacklist-artica/$category/urls","#");}
	if(!is_file("/var/lib/squidguard/blacklist-artica/$category/urls")){@file_put_contents("/var/lib/squidguard/blacklist-artica/$category/urls","#");}
		
	$sql="SELECT pattern FROM dansguardian_community_categories WHERE enabled=1 and category='$category'";
	$q=new mysql();
	$results=$q->QUERY_SQL($sql,"artica_backup");
	if(!$q->ok){
		echo "Starting......: Artica database $q->mysql_error\n";
		return;
	}
	$num=mysql_num_rows($results);
	echo "Starting......: Artica database $num domains\n";
	
	$domain_path_1="/etc/dansguardian/lists/blacklist-artica/$category/domains";
	$domain_path_2="/var/lib/squidguard/blacklist-artica/$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......: finish\n\n";
		
}
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";
}