function mysql_rebuild() { $q = new mysql(); if (!$q->CheckTable_dansguardian()) { echo $q->mysql_error; } }
function free_catgorized_save(){ $sock=new sockets(); $uuid=base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes")); if(!preg_match_all("#http.*?:\/\/(.+?)[\/\s]+#",$_POST["textToParseCats"]."\n",$re)){echo "No webistes\n";} while (list ($num, $www) = each ($re[1]) ){ $www=strtolower($www); $www=replace_accents($www); if(preg_match("#^www\.(.+?)$#i",$www,$ri)){$www=$ri[1];} $sites[$www]=$www; } $q=new mysql(); $q->CheckTable_dansguardian(); if(count($sites)==0){echo "NO websites\n";return;} $category=$_POST["category"]; echo "analyze ".count($sites)." websites into $category\n"; while (list ($num, $www) = each ($sites) ){ $md5=md5($www.$category); $sql="SELECT zmd5 FROM dansguardian_community_categories WHERE pattern='$www' AND category='$category'"; $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup")); $sql_add="INSERT INTO dansguardian_community_categories (zmd5,zDate,category,pattern,uuid) VALUES('$md5',NOW(),'$category','$www','$uuid')"; if($ligne["zmd5"]<>null){continue;} echo "Added $www\n"; $q->QUERY_SQL($sql_add,"artica_backup"); if(!$q->ok){echo $q->mysql_error;return;} $cats=GetCategory($www); $sql="UPDATE dansguardian_sitesinfos SET category='$cats', dbpath='$cats' WHERE website='$www'"; writelogs("$sql",__FUNCTION__,__FILE__,__LINE__); $q->QUERY_SQL($sql,"artica_backup"); if(!$q->ok){echo $q->mysql_error."\n";echo $sql;} $sql="UPDATE squid_events_sites SET category='$cats' WHERE website='$www'"; writelogs("$sql",__FUNCTION__,__FILE__,__LINE__); $q->QUERY_SQL($sql,"artica_events"); if(!$q->ok){echo $q->mysql_error."\n";echo $sql;} } $sock=new sockets(); $sock->getFrameWork("cmd.php?export-community-categories=yes"); }
function ComputersList(){ $q=new mysql(); $sock=new sockets(); $sql="SELECT ID,pattern,uid FROM dansguardian_files WHERE filename='bannediplist' AND RuleID=1 ORDER BY ID DESC"; $results=$q->QUERY_SQL($sql,"artica_backup"); if(!$q->ok){ $mysql_error="::$q->mysql_error"; if(preg_match("#doesn't exist#",$q->mysql_error)){ $q->CheckTable_dansguardian(); if(!$q->ok){$mysql_error=$mysql_error."::$q->mysql_error";}else{$mysql_error=null;} } } $style=CellRollOver(); $html="<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'> <thead class='thead'> <tr> <th colspan=4>{black_ip_group}$mysql_error</th> </tr> </thead> <tbody class='tbody'>"; while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";} $MAC=null;$uid=null; if($ligne["uid"]<>null){ $cmp=new computers($ligne["uid"]); $MAC=$cmp->ComputerMacAddress; $uid="<br><i style='font-size:9px'>$cmp->ComputerRealName</i>"; } if(!IsPhysicalAddress($MAC)){ $MAC=$sock->getFrameWork("cmd.php?ip-to-mac={$ligne["pattern"]}"); } if(!IsPhysicalAddress($MAC)){$MAC=null;} $html=$html." <tr class=$classtr> <td width=1% ><img src='img/computer-32.png'></td> <td nowrap><strong style='font-size:14px'>{$ligne["pattern"]}$uid</strong></td> <td nowrap><strong style='font-size:14px'> $MAC</strong></td> <td ><strong>". imgtootltip("delete-24.png","{delete}","DelDansGuardianExceptionipList('{$ligne["ID"]}');")."</strong></td> </tr> "; } $html=$html . " </tbody> </table>"; $html="<center><div style='height:450px;overflow:auto'>$html</div></center>"; $tpl=new templates(); return $tpl->_ENGINE_parse_body($html); }
die; } if ($argv[1] == "--clean-db") { CleanDB(); echo "\n"; die; } //exec.dansguardian.compile.php --patterns echo "\n"; echo "Starting......: Dansguardian reconfigure settings\n"; $q = new mysql(); if (!$q->test_mysql_connection()) { echo "Starting......: Dansguardian Mysql error\n"; die; } $q->CheckTable_dansguardian(); LoadGlobal_exceptionsitelist(); $dans = new dansguardian(); $dans->SaveSettings(); $cmd = LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.web-community-filter.php --patterns{$GLOBALS["cmdlineadd"]}"; events("MAIN:: {$cmd}"); system($cmd); HtmlTemplate(); BuildPersonalCategories(); bannedsitelist_userdefined(); weightedphraselist_userdefined(); BuildRules(); BuildWhiteIpList(); BuildBannedIPList(); FixMissingGroupsFiles(); FixMissingFiles();
function SQUID_TEMPLATES() { if (system_is_overloaded(__FILE__)) { return null; } $unix = new unix(); $EXEC_PID_FILE = "/etc/artica-postfix/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; if ($unix->process_exists(@file_get_contents($EXEC_PID_FILE))) { print "Starting......: Checking squid Already executed pid " . @file_get_contents($EXEC_PID_FILE) . "...\n"; die; } $childpid = posix_getpid(); @file_put_contents($EXEC_PID_FILE, $childpid); if ($GLOBALS["VERBOSE"]) { echo "Search DataDir from compiled environments\n"; } $document_root = $unix->SQUID_GET_DATADIR(); echo "Starting......: squid DataDir: {$document_root}\n"; if (!is_dir("{$document_root}/errors/English")) { echo "Starting......: squid DataDir: {$document_root}/errors/English no such directory\n"; return; } $q = new mysql(); $q->CheckTable_dansguardian(); foreach (glob("{$document_root}/errors/English/*") as $filename) { $file = basename($filename); $sql = "SELECT TEMPLATE_DATA,TEMPLATE_DATA_SOURCE FROM squid_templates WHERE TEMPLATE_NAME='{$file}'"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup')); if ($ligne["TEMPLATE_DATA_SOURCE"] == null) { echo "Starting......: squid importing template {$file}\n"; $datas = addslashes(@file_get_contents($filename)); $sql = "INSERT INTO squid_templates (`TEMPLATE_DATA`,`TEMPLATE_DATA_SOURCE`,`TEMPLATE_NAME`) \n\t\t\tVALUES ('{$datas}','{$datas}','{$file}')"; $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo "Starting......: squid failed {$q->mysql_error}\n"; } $TEMPLATES[$file]["MODIFIED"] = $datas; $TEMPLATES[$file]["SRC"] = $datas; } else { $TEMPLATES[$file]["MODIFIED"] = $ligne["TEMPLATE_DATA"]; $TEMPLATES[$file]["SRC"] = $ligne["TEMPLATE_DATA_SOURCE"]; } } if (!is_array($TEMPLATES)) { echo "Starting......: squid no templates found...\n"; return; } $langsDirs = array('Armenian', 'Azerbaijani', 'Bulgarian', 'Catalan', 'Danish', 'Dutch', 'English', 'Estonian', 'Finnish', 'French', 'German', 'Greek', 'Hebrew', 'Hungarian', 'Italian', 'Japanese', 'Korean', 'Lithuanian', 'Portuguese', 'Romanian', 'Russian-1251', 'Russian-koi8-r', 'Serbian', 'Simplify_Chinese', 'Slovak', 'Spanish', 'Swedish', 'Traditional_Chinese', 'Turkish', 'Ukrainian-1251', 'Ukrainian-koi8-u', 'Ukrainian-utf8', 'af', 'ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma', 'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye', 'az', 'az-az', 'bg', 'bg-bg', 'ca', 'cs', 'cs-cz', 'da', 'da-dk', 'de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu', 'el', 'el-gr', 'en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-in', 'en-jm', 'en-nz', 'en-ph', 'en-sg', 'en-tt', 'en-uk', 'en-us', 'en-za', 'en-zw', 'es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn', 'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve', 'et', 'et-ee', 'fa', 'fa-fa', 'fa-ir', 'fi', 'fi-fi', 'fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu', 'fr-mc', 'he', 'he-il', 'hu', 'hu-hu', 'hy', 'hy-am', 'id', 'id-id', 'it', 'it-ch', 'it-it', 'ja', 'ja-jp', 'ko', 'ko-kp', 'ko-kr', 'lt', 'lt-lt', 'lv', 'lv-lv', 'ms', 'ms-my', 'nl', 'nl-nl', 'pl', 'pl-pl', 'pt', 'pt-br', 'pt-pt', 'ro', 'ro-md', 'ro-ro', 'ru', 'ru-ru', 'sk', 'sk-sk', 'sr', 'sr-latn', 'sr-latn-cs', 'sr-sp', 'sv', 'sv-fi', 'sv-se', 'templates', 'th', 'th-th', 'tr', 'tr-tr', 'uk', 'uk-ua', 'uz', 'zh-cn', 'zh-hk', 'zh-mo', 'zh-sg', 'zh-tw'); $css = SQUID_TEMPLATES_COMPILING_CSS(); while (list($template_name, $content) = each($TEMPLATES)) { if (preg_match("#<title>(.+?)</title>#is", $content["SRC"], $re)) { $title = $re[1]; } if (preg_match("#<body>(.+?)</body>#is", $content["MODIFIED"], $re)) { $body = $re[1]; } else { $body = $content["MODIFIED"]; } $html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\t\t<html>\n\t\t<head>\n\t\t<title>{$title}</title>\n\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n\t\t<style type=\"text/css\">\n\t\t<!--\n\t\t{$css}\n\t\t-->\n\t\t</style>\n\t\t</head>\n\t\t<body>\n\t\t\t{$body}\n\t\t</body>\n\t\t</html>\n\t\t"; $TEMPLATES_NEW[$template_name] = $html; } reset($langsDirs); echo "Starting......: squid building templates...\n"; while (list($index, $subdir) = each($langsDirs)) { reset($TEMPLATES_NEW); @mkdir("{$document_root}/errors/{$subdir}", 0755, true); while (list($template_name, $template_data) = each($TEMPLATES_NEW)) { if ($template_name == "error-details.txt") { continue; } if (!@file_put_contents("{$document_root}/errors/{$subdir}/{$template_name}", $template_data)) { echo "Starting......: squid {$document_root}/errors/{$subdir}/{$template_name} permission denied\n"; } } } errors_details_txt(); echo "Starting......: squid replace " . count($TEMPLATES) . " templates in " . count($langsDirs) . " languages done..\n"; }
function save_category(){ $www=trim(strtolower(base64_decode($_GET["website"]))); if(preg_match("#^www\.(.+?)$#i",$www,$re)){$www=$re[1];} $category=$_GET["category"]; $md5=md5($www.$category); $sock=new sockets(); $uuid=base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes")); $enabled=$_GET["enabled"]; $sql="SELECT zmd5 FROM dansguardian_community_categories WHERE pattern='$www' AND category='$category'"; $q=new mysql(); $q->CheckTable_dansguardian(); $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup")); $sql_add="INSERT INTO dansguardian_community_categories (zmd5,zDate,category,pattern,uuid) VALUES('$md5',NOW(),'$category','$www','$uuid')"; $sql_edit="UPDATE dansguardian_community_categories SET enabled='$enabled' WHERE category='$category' AND pattern='$www'"; writelogs("$www/$category = {$ligne["zmd5"]}",__FUNCTION__,__FILE__,__LINE__); if($ligne["zmd5"]==null){$q->QUERY_SQL($sql_add,"artica_backup");} else{ writelogs("$sql_edit",__FUNCTION__,__FILE__,__LINE__); $q->QUERY_SQL($sql_edit,"artica_backup"); } if(!$q->ok){ echo $q->mysql_error; return; } $cats=GetCategory($www); $sql="UPDATE dansguardian_sitesinfos SET category='$cats', dbpath='$cats' WHERE website='$www'"; writelogs("$sql",__FUNCTION__,__FILE__,__LINE__); $q->QUERY_SQL($sql,"artica_backup"); if(!$q->ok){ echo $q->mysql_error."\n"; echo $sql; } $sql="UPDATE squid_events_sites SET category='$cats' WHERE website='$www'"; writelogs("$sql",__FUNCTION__,__FILE__,__LINE__); $q->QUERY_SQL($sql,"artica_events"); if(!$q->ok){ echo $q->mysql_error."\n"; echo $sql; } $sock=new sockets(); $sock->getFrameWork("cmd.php?export-community-categories=yes"); }