function TEMPLATE_SETTINGS() { $page = CurrentPageName(); $sock = new sockets(); $tpl = new templates(); $error = null; $t = time(); $button = "<hr>" . button("{save}", "Save{$t}()", 40); $TEMPLATE_TITLE = $_GET["TEMPLATE_TITLE"]; $EnableYoutubeLocker = intval($sock->GET_INFO("EnableYoutubeLocker")); $YoutubeLockerSize = intval($sock->GET_INFO("YoutubeLockerSize")); $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(*) AS tcount FROM proxy_ports WHERE UseSSL=1 AND enabled=1")); if ($ligne["tcount"] == 0) { $error = "<p class=text-error style='font-size:18px'>{feature_run_only_ssl}</p>"; } $pp = Paragraphe_switch_img("{youtube_locker}", "{youtube_locker_explain}", "EnableYoutubeLocker-{$t}", $EnableYoutubeLocker, null, 1450); if ($YoutubeLockerSize == 0) { $YoutubeLockerSize = 144; } $RESOLUTIONS[144] = "144p"; $RESOLUTIONS[240] = "240p"; $RESOLUTIONS[360] = "360p"; $RESOLUTIONS[480] = "480p"; $RESOLUTIONS[720] = "720p"; $html = "\n<div style='font-size:40px;margin-bottom:30px'>{youtube_locker}</div>\t\t\n{$error}\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t<td colspan=2>{$pp}</td>\n\t</tr>\n<tr>\n\t<td class=legend style='font-size:24px' width=1% nowrap>{video_quality}:</td>\n\t<td width=99%>" . Field_array_Hash($RESOLUTIONS, "YoutubeLockerSize-{$t}", $YoutubeLockerSize, "style:font-size:24px;width:240px") . "</td>\n</tr>\n\t<tr>\n\t<td colspan=2 align='right'>{$button}</td>\n\t</tr>\n<script>\n\tvar xSave{$t}=function(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue)};\n\tLoadjs('squid.ecap.progress.php');\n}\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('YoutubeLockerSize',document.getElementById('YoutubeLockerSize-{$t}').value);\n\tXHR.appendData('EnableYoutubeLocker',document.getElementById('EnableYoutubeLocker-{$t}').value);\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function popup() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $html = "<div class=explain>{websites_to_export_explain}</div>\n\t<div style='margin:top:10px;width:100%;height:450px;overflow:auto'>\n\t<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n\t<thead class='thead'>\n\t\t\t<tr>\n\t\t\t\t<th width=1%>{date}</th>\n\t\t\t\t<th width=99%>{website}</th>\n\t\t\t\t<th width=99%>{category}</th>\n\t\t\t</tr>\n\t</thead>\n<tbody>"; $sql = "SELECT * FROM categorize ORDER BY zDate DESC LIMIT 0,150"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $js = "Loadjs('{$page}?website-details=yes&familysite={$ligne["familysite"]}&day={$_GET["day"]}&user-field={$_GET["user-field"]}&user={$_GET["user"]}')"; $categorize = "Loadjs('squid.categorize.php?www={$ligne["sitename"]}')"; if (trim($ligne["category"]) == null) { $ligne["category"] = "<span style='color:#D70707'>{categorize_this_website}</span>"; } $html = $html . "\n\t\t\t\t<tr class={$classtr}>\n\t\t\t\t\t<td width=1% style='font-size:14px;'nowrap><strong>{$ligne["zDate"]}</strong></td>\n\t\t\t\t\t<td width=99% style='font-size:14px;' nowrap><strong>{$ligne["pattern"]}</strong></td>\n\t\t\t\t\t<td width=1% style='font-size:14px;' nowrap><strong>{$ligne["category"]}</strong></td>\n\t\t\t\t</tr>\n\t\t\t\t"; } $html = $html . "</tbody></table></div>"; echo $tpl->_ENGINE_parse_body($html); }
function build_rules() { $q = new mysql_squid_builder(); $unix = new unix(); $SQUID_BIN = $unix->LOCATE_SQUID_BIN(); build_progress("{IT_charter}", 25); $sql = "SELECT ID,title FROM itcharters WHERE enabled=1"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { build_progress("{IT_charter} {mysql_error}", 110); echo $q->mysql_error; return; } if (mysql_num_rows($results) == 0) { @unlink("/etc/squid3/itCharts.enabled.db"); squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__); build_progress("{IT_charter} {reload_proxy_service}", 90); system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure"); build_progress("{IT_charter} {done} 0 {item}", 100); return; } while ($ligne = mysql_fetch_assoc($results)) { build_progress("{$ligne["title"]}", 50); echo "{$ligne["ID"]}: {$ligne["title"]}\n"; $MAIN[$ligne["ID"]] = $ligne["title"]; } @file_put_contents("/etc/squid3/itCharts.enabled.db", serialize($MAIN)); squid_admin_mysql(1, "Reloading Proxy service (itCharts)", null, __FILE__, __LINE__); build_progress("{IT_charter} {reload_proxy_service}", 90); system("{$SQUID_BIN} -f /etc/squid3/squid.conf -k reconfigure"); build_progress("{IT_charter} {done} " . count($MAIN) . " {items}", 100); }
function xstart() { $sock = new sockets(); $unix = new unix(); $php = $unix->LOCATE_PHP5_BIN(); $SquidAllow80Port = intval($sock->GET_INFO("SquidAllow80Port")); build_progress("{starting} {allow_80443_port}", 15); if ($SquidAllow80Port == 1) { build_progress("{stopping} {web_service}", 20); system("/etc/init.d/apache2 stop"); build_progress("{stopping} Reverse Proxy", 30); system("/etc/init.d/nginx stop"); } else { build_progress("{remove} 80/443 ports", 20); $q = new mysql_squid_builder(); $q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='80'"); build_progress("{remove} 80/443 ports", 25); $q->QUERY_SQL("DELETE FROM proxy_ports WHERE `port`='443'"); build_progress("{reconfigure_proxy_service}", 30); $php = $unix->LOCATE_PHP5_BIN(); shell_exec("{$php} /usr/share/artica-postfix/exec.squid.php --build --force"); } build_progress("{restarting_artica_status}", 80); system("/etc/init.d/artica-status restart --force"); build_progress("{done}", 100); }
function title() { $tpl = new templates(); $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT servername, ipaddr FROM reverse_sources WHERE ID='{$_GET["cacheid"]}'")); return $tpl->javascript_parse_text("{compile2} {destination} {$ligne["servername"]}/{$ligne["ipaddr"]}"); }
function js() { $page = CurrentPageName(); $tpl = new templates(); if (!is_numeric($_GET["taskid"])) { $_GET["taskid"] = 0; } if ($_GET["table"] == null) { $all_events = $tpl->_ENGINE_parse_body("{all_events}"); $title = $all_events; } else { $title = $tpl->_ENGINE_parse_body("{events}") . "::{$_GET["category"]}"; } if ($_GET["taskid"] > 0) { if ($_GET["table"] == null or preg_match("#TaskSq[0-9]+#", $_GET["table"])) { $q = new mysql_squid_builder(); $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT TaskType,TimeDescription FROM webfilters_schedules WHERE ID={$_GET["taskid"]}", "artica_events")); } else { $q = new mysql(); $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT TaskType,TimeDescription FROM system_schedules WHERE ID={$_GET["taskid"]}", "artica_backup")); } $title = "{$_GET["taskid"]}::Type:{$ligne2["TaskType"]}::{$ligne2["TimeDescription"]}"; } $html = "YahooWin5('690','{$page}?popup=yes&filename={$_GET["filename"]}&taskid={$_GET["taskid"]}&category={$_GET["category"]}&tablesize={$_GET["tablesize"]}&descriptionsize={$_GET["descriptionsize"]}&table={$_GET["table"]}','{$title}')"; echo $html; }
function save() { $sock = new sockets(); if ($_POST["ID"] == 0) { $ligne = unserialize(base64_decode($sock->GET_INFO("DansGuardianDefaultMainRule"))); $ligne["bypass"] = $_POST["bypass"]; $ligne["BypassSecretKey"] = $_POST["BypassSecretKey"]; writelogs("Default rule, saving DansGuardianDefaultMainRule", __FUNCTION__, __FILE__, __LINE__); $sock->SaveConfigFile(base64_encode(serialize($ligne)), "DansGuardianDefaultMainRule"); writelogs("Ask to compile rule...", __FUNCTION__, __FILE__, __LINE__); $sock->getFrameWork("webfilter.php?compile-rules=yes"); return; } $q = new mysql_squid_builder(); $sql = "UPDATE webfilter_rules SET bypass='******',BypassSecretKey='{$_POST["bypass"]}' WHERE ID='{$_POST["ID"]}'"; $q->QUERY_SQL($sql); if (!$q->ok) { if (strpos($q->mysql_error, "Unknown column") > 0) { $q->CheckTables(); $q->QUERY_SQL($sql); } } if (!$q->ok) { echo $q->mysql_error; return; } $sock->getFrameWork("webfilter.php?compile-rules=yes"); }
function delete_link($aclid) { $q = new mysql_squid_builder(); $sql = "SELECT zmd5,gpid FROM webfilters_sqacllinks WHERE aclid='{$aclid}'"; $results = $q->QUERY_SQL($sql); echo "ACL {$aclid} " . mysql_num_rows($results) . " links\n"; while ($ligne = mysql_fetch_assoc($results)) { $gpid = $ligne["gpid"]; $zmd5 = $ligne["zmd5"]; if ($_POST["DeleteGroups"] == 1) { echo "ACL {$aclid} Delete group id {$gpid}\n"; $q->QUERY_SQL("DELETE FROM webfilters_sqgroups WHERE ID={$gpid}"); if (!$q->ok) { echo $q->mysql_error . "\n"; return; } } echo "ACL {$aclid} Delete link id {$zmd5}\n"; $q->QUERY_SQL("DELETE FROM webfilters_sqacllinks WHERE zmd5='{$zmd5}'"); if (!$q->ok) { echo $q->mysql_error . "\n"; return; } } return true; }
function BlockedSites() { $page = CurrentPageName(); $tpl = new templates(); $tableblock = date('Ymd') . "_blocked"; $q = new mysql_squid_builder(); $sql = "SELECT * FROM {$tableblock} ORDER BY ID DESC LIMIT 0,150"; $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2>"; } $html = "<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView'>\n<thead class='thead'>\n\t<tr>\n\t<th width=1%>{date}</th>\n\t<th>{member}</th>\n\t<th>{website}</th>\n\t<th>{category}</th>\n\t<th>{rule}</th>\n\t</tr>\n</thead>\n<tbody>"; $today = date('Y-m-d'); $d + 0; while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { if ($classtr == "oddRow") { $classtr = null; } else { $classtr = "oddRow"; } $ligne["zDate"] = str_replace($today, "{today}", $ligne["zDate"]); if (preg_match("#plus-(.+?)-artica#", $ligne["category"], $re)) { $ligne["category"] = $re[1]; } $html = $html . "\n\t<tr class={$classtr}>\n\t\t<td style='font-size:13px' nowrap width=1%>{$ligne["zDate"]}</td>\n\t\t<td style='font-size:13px' width=1%>{$ligne["client"]}</td>\n\t\t<td style='font-size:13px' width=99%><strong><code>\n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categories.php?category={$ligne["category"]}&website={$ligne["website"]}')\" \n\t\tstyle='font-weight:bold;text-decoration:underline;font-size:13px'>{$ligne["website"]}</a></code></strong></td>\n\t\t<td style='font-size:13px' width=1% align='center'>{$ligne["category"]}</td>\n\t\t<td style='font-size:13px' width=1% align='center'>{$ligne["rulename"]}</td>\n\t</tr>\n\t"; } $html = $html . "</tbody></table>"; echo $tpl->_ENGINE_parse_body($html); }
function reset2() { system("clear"); echo "Remove databases\n"; $q = new mysql(); echo "Remove database settings\n"; $q->DELETE_DATABASE("artica_backup"); echo "Remove database events\n"; $q->DELETE_DATABASE("artica_events"); echo "Remove database Proxy\n"; $q = new mysql_squid_builder(); $q->QUERY_SQL("DROP DATABASE `squidlogs`"); echo "Remove Artica settings Proxy\n"; $unix = new unix(); $files = $unix->DirFiles("/etc/artica-postfix/settings/Daemons"); while (list($filename, $value) = each($files)) { $fulename = "/etc/artica-postfix/settings/Daemons/{$filename}"; echo "Removing {$filename}\n"; @unlink($fulename); } @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/ProxyUseArticaDB", 1); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/StatsPerfsSquidAnswered", 1); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/CacheManagement2", 1); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnablePHPFPM", 0); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToNGninx", 0); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableArticaFrontEndToApache", 1); @file_put_contents("/root/build/etc/artica-postfix/settings/Daemons/EnableNginx", 0); echo "Restarting Web Console...\n"; system('/etc/init.d/artica-webconsole restart'); system("clear"); echo "All data has been erased..\n"; echo "Type Enter key to exit\n"; $answer = trim(strtolower(fgets(STDIN))); die; }
function section_websites_search() { $boot = new boostrap_form(); $tpl = new templates(); $q = new mysql_squid_builder(); $page = CurrentPageName(); $table = "visited_sites_tot"; $searchstring = string_to_flexquery("sites-search"); $ORDER = $boot->TableOrder(array("size" => "ASC")); if ($q->COUNT_ROWS($table) == 0) { senderrors("no data"); } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} ORDER BY {$ORDER} LIMIT 0,250"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { senderrors($q->mysql_error . "<br>{$sql}"); } while ($ligne = mysql_fetch_assoc($results)) { $md = md5(serialize($ligne)); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $sitenameenc = urlencode($ligne["familysite"]); $js = "Loadjs('miniadm.webstats.familysite.all.php?familysite={$sitenameenc}')"; $link = $boot->trswitch($js); $tr[] = "\n\t\t<tr id='{$md}'>\n\t\t\t<td style='font-size:16px' width=10% nowrap {$link}>{$ligne["familysite"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["hits"]}</td>\n\t\t\t<td style='font-size:16px' width=1% nowrap {$link}>{$ligne["size"]}</td>\n\t\t</tr>\n\t\t"; } echo $boot->TableCompile(array("familysite" => "{familysite}", "hits" => "{hits}", "size" => "{size}"), $tr); }
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"); }
function doexport() { $q = new mysql_squid_builder(); $q->BD_CONNECT(); $t = $_GET["t"]; $squidlogs["webfilters_sqacls"] = true; $squidlogs["webfilters_sqaclaccess"] = true; $squidlogs["webfilters_sqgroups"] = true; $squidlogs["webfilters_sqacllinks"] = true; $squidlogs["webfilters_sqitems"] = true; $squidlogs["webfilters_sqtimes_rules"] = true; $squidlogs["webfilters_blkwhlts"] = true; $squidlogs["webfilters_usersasks"] = true; $squidlogs["webfilters_quotas"] = true; $squidlogs["webfilter_avwhitedoms"] = true; $squidlogs["webfilter_aclsdynamic"] = true; $squidlogs["squidtpls"] = true; $dir = dirname(__FILE__) . "/ressources/logs/web/acls.gz"; $databases["squidlogs"] = $squidlogs; if (is_file($dir)) { @unlink($dir); } $dump = new phpMyDumper("squidlogs", $q->mysql_connection, "{$dir}", true, $squidlogs); $dump->doDump(); }
function duplicate() { $ID = $_POST["rule-dup"]; $rulename = url_decode_special_tool($_POST["rulename"]); $sql = "INSERT IGNORE INTO iptables_main (`rulename`,`eth`,`accepttype`,`enabled`)\n\tVALUES ('{$rulename}','{$eth}','ACCEPT','1')"; $q = new mysql(); if (!$q->FIELD_EXISTS("iptables_main", "service", "artica_backup")) { $q->QUERY_SQL("ALTER TABLE `iptables_main` ADD `service` varchar(50) NULL ,ADD INDEX ( service );", "artica_backup"); } $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } $NEW_RULE_ID = $q->last_id; if (!is_numeric($NEW_RULE_ID)) { echo "Failed\n"; return; } if ($NEW_RULE_ID == 0) { echo "Failed\n"; return; } $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM iptables_main WHERE ID='{$ID}'", "artica_backup")); unset($ligne["ID"]); unset($ligne["rulename"]); while (list($key, $value) = each($ligne)) { if (is_numeric($key)) { continue; } $f[] = "`{$key}`='" . mysql_escape_string2($value) . "'"; } $sql = "UPDATE `iptables_main` SET " . @implode(",", $f) . " WHERE ID='{$NEW_RULE_ID}'"; $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } $q = new mysql_squid_builder(); $results = $q->QUERY_SQL("SELECT * FROM firewallfilter_sqacllinks WHERE aclid='{$ID}'"); $prefix = "INSERT IGNORE INTO firewallfilter_sqacllinks (zmd5,aclid,gpid,zOrder,direction,negation) VALUES "; $f = array(); while ($ligne = mysql_fetch_assoc($results)) { $direction = $ligne["direction"]; $gpid = $ligne["gpid"]; $zOrder = $ligne["zOrder"]; $negation = $ligne["negation"]; $aclid = $NEW_RULE_ID; $md5 = md5($aclid . $gpid . $direction); $f[] = "('{$md5}','{$aclid}','{$gpid}',{$zOrder},{$direction},{$negation})"; } if (count($f) > 0) { $q->QUERY_SQL("{$prefix}" . @implode(",", $f)); if (!$q->ok) { echo $q->mysql_error; return; } } }
function start_parse() { if ($GLOBALS["VERBOSE"]) { "echo Loading...\n"; } $unix = new unix(); if ($GLOBALS["VERBOSE"]) { "echo Loading done...\n"; } $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $timefile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time"; $pid = @file_get_contents($pidfile); if (!$GLOBALS["FORCE"]) { if ($pid < 100) { $pid = null; } $unix = new unix(); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } $timeexec = $unix->file_time_min($timefile); if ($timeexec < 10) { return; } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); } @unlink($timefile); @file_put_contents($timefile, time()); $ldap = new clladp(); if (!$ldap->IsKerbAuth()) { return; } $q = new mysql_squid_builder(); $sql = "SELECT ID,GroupName FROM webfilters_sqgroups WHERE `enabled`=1 AND `GroupType`='proxy_auth_statad'"; $results = $q->QUERY_SQL($sql); $REFRESH = false; $Count = mysql_num_rows($results); $UPDATED = array(); while ($ligne = mysql_fetch_assoc($results)) { if (parse_object($ligne["ID"], $ligne["GroupName"])) { $UPDATED[] = $ligne["GroupName"]; $REFRESH = true; } } if ($REFRESH) { squid_admin_mysql(1, "Reloading proxy service after updating " . count($UPDATED) . " Active Directory group(s)", @implode("\n", $UPDATED), __FILE__, __LINE__); $squid = $unix->LOCATE_SQUID_BIN(); system("/etc/init.d/squid reload --force --script=exec.squid.static.ad.groups.php/" . __LINE__); $sock = new sockets(); $EnableTransparent27 = intval($sock->GET_INFO("EnableTransparent27")); if ($EnableTransparent27 == 1) { system("/etc/init.d/squid-nat reload --script=" . basename(__FILE__)); } } }
function showlist() { $page = 1; $q = new mysql_squid_builder(); $tablesrc = "quotatemp_" . date("YmdH"); $table = "(SELECT SUM(size) as size,ipaddr,familysite,uid,MAC FROM `{$tablesrc}` GROUP BY ipaddr,familysite,uid,MAC) as t"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $q = new mysql_squid_builder(); $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if (!is_numeric($rp)) { $rp = 50; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; if (isset($_GET["verbose"])) { echo "<hr><code>{$sql}</code></hr>"; } $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { json_error_show($q->mysql_error, 1); } if (mysql_num_rows($results) == 0) { json_error_show("{$table} no data", 1); } $data = array(); $data['page'] = 1; $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)) { $ipaddr = $ligne["ipaddr"]; $mac = $ligne["MAC"]; $familysite = $ligne["familysite"]; $uid = $ligne["uid"]; $size = FormatBytes($ligne["size"] / 1024); $data['rows'][] = array('id' => md5(serialize($ligne)), 'cell' => array("<span style='font-size:14px'>{$uid}</span>", "<span style='font-size:14px'>{$ipaddr}</span>", "<span style='font-size:14px'>{$mac}</span>", "<span style='font-size:14px'>{$familysite}</span>", "<span style='font-size:14px'>{$size}</span>")); } echo json_encode($data); }
function save() { $q = new mysql_squid_builder(); $q->QUERY_SQL("UPDATE webfilters_sqaclaccess SET httpaccess_data='{$_POST["parentid"]}' WHERE aclid='{$_POST["aclid"]}' AND httpaccess='cache_parent'"); if (!$q->ok) { echo $q->mysql_error; } }
function SquidAsMasterLogChilds() { $q = new mysql_squid_builder(); $q->QUERY_SQL("UPDATE proxy_ports SET\n\tSquidAsMasterLogChilds={$_POST["SquidAsMasterLogChilds"]},\n\tSquidAsMasterCacheChilds={$_POST["SquidAsMasterCacheChilds"]},\n\tSquidAsMasterFollowxForward={$_POST["SquidAsMasterFollowxForward"]}\n\tWHERE ID='{$_POST["ID"]}'"); if (!$q->ok) { echo $q->mysql_error; } }
function compile_destination($cacheid) { $unix = new unix(); $sock = new sockets(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".compile_destination." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); if (!is_numeric($cacheid)) { build_progress("Error Destination ID is not set", 110); return; } if ($cacheid == 0) { build_progress("Error Destination ID is Zero", 110); return; } $q = new mysql_squid_builder(); $sql = "SELECT servername FROM reverse_www WHERE cache_peer_id={$cacheid}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { build_progress("Error MySQL error", 110); echo $q->mysql_error; return; } $count = mysql_num_rows($results); if ($count == 0) { echo "{$sql}\n"; build_progress("Error no destination for ID {$cacheid}", 110); return; } build_progress("{$count} Destination(s)", 5); $c = 0; $php = $unix->LOCATE_PHP5_BIN(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $c++; $prc = $c / $count; $prc = $prc * 100; if ($prc > 90) { $prc = 90; } $servername = $ligne["servername"]; build_progress("{reconfigure} {$servername}", $prc); system("{$php} /usr/share/artica-postfix/exec.nginx.single.php {$servername} --no-reload --output --no-buildmain"); } build_progress("{cleaning_old_configs}...", 91); system("{$php} /usr/share/artica-postfix/exec.nginx.wizard.php --check-http"); build_progress("{building_main_settings}", 95); system("{$php} /usr/share/artica-postfix/exec.nginx.php --main"); build_progress("{$ligne["servername"]}: {reloading_reverse_proxy} ", 96); system("/etc/init.d/nginx reload --force"); build_progress("{$ligne["servername"]}: {reloading_reverse_proxy} {done}", 100); }
function members_search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $search = '%'; $table = "usersisp"; $page = 1; $FORCE_FILTER = null; if ($q->COUNT_ROWS($table) == 0) { json_error_show("Empty table"); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } 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)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$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 (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $id = md5(serialize($ligne)); $delete = "<a href=\"javascript:blur()\" OnClick=\"javascript:DeleteISPMEmber('{$ligne["userid"]}','{$id}','{$ligne["email"]}');\"><img src='img/delete-24.png'></a>"; $enable = Field_checkbox("check-{$id}", 1, $ligne["enabled"], "ISPMemberEnable('{$ligne["userid"]}','check-{$id}')"); $data['rows'][] = array('id' => $id, 'cell' => array("<span style='font-size:14px'>{$ligne["userid"]}</span>", "<span style='font-size:14px'>{$ligne["publicip"]}</span>", "<span style='font-size:14px'>{$ligne["email"]}</span>", $enable, $delete)); } echo json_encode($data); }
function items_list() { //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(); $q = new mysql_squid_builder(); $currentWeek = date("YW"); $table = "{$currentWeek}_not_cached"; $search = '%'; $page = 1; if ($q->COUNT_ROWS("{$table}") == 0) { json_error_show("No datas"); } 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(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error . "\n{$sql}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $familysite = $ligne["familysite"]; $size = FormatBytes($ligne["size"] / 1024); $hits = FormatNumber($ligne["hits"]); $data['rows'][] = array('id' => "{$familysite}", 'cell' => array("<span style='font-size:16px;'>{$familysite}</span>", "<span style='font-size:16px;font-weight:bold'>{$size}</span>", "<span style='font-size:16px;font-weight:bold'>{$hits}</span>")); } echo json_encode($data); }
function items() { //1.4.010916 $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $search = '%'; $table = "webfilter_avwhitedoms"; $database = "artica_backup"; $page = 1; $FORCE_FILTER = ""; if ($q->COUNT_ROWS($table) == 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']; } $searchstring = string_to_flexquery(); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database)); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql, $database); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5($ligne["websitename"]); $delete = imgsimple("delete-32.png", "", "Delete{$t}('{$ligne["websitename"]}','{$zmd5}')"); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:26px;color:{$color}'>{$urljs}{$ligne["websitename"]}</a></span>", "<center style='font-size:16px;color:{$color}'>{$delete}</a></center>")); } echo json_encode($data); }
function Save() { $q = new mysql_squid_builder(); $q->QUERY_SQL("UPDATE proxy_ports SET\n\tWanProxyMemory={$_POST["WanProxyMemory"]},\n\tWanProxyCache={$_POST["WanProxyCache"]}\n\tWHERE ID='{$_POST["ID"]}'"); if (!$q->ok) { echo $q->mysql_error; } $sock = new sockets(); $sock->getFrameWork("wanproxy.php?reconfigure-silent=yes"); }
function Save() { $q = new mysql_squid_builder(); $q->QUERY_SQL("UPDATE proxy_ports SET\n\tFTPProxyMaxClients={$_POST["FTPProxyMaxClients"]},\n\tFTPProxyTimeOuts={$_POST["FTPProxyTimeOuts"]},\n\tFTPProxyDestinationTransferMode={$_POST["FTPProxyDestinationTransferMode"]},\n\tFTPUserAuthMagic={$_POST["FTPUserAuthMagic"]},\n\tFTPUseMagicChar={$_POST["FTPUseMagicChar"]}\n\tWHERE ID='{$_POST["ID"]}'"); if (!$q->ok) { echo $q->mysql_error; } $sock = new sockets(); $sock->getFrameWork("ftp-proxy.php?reconfigure-silent=yes"); }
function general_settings_save() { $q = new mysql_squid_builder(); $servername = $_POST["general-settings"]; $sql = "UPDATE `reverse_www` SET\n\t\t\t`proxy_buffering`='{$_POST["proxy_buffering"]}',\n\t\t\t`proxy_cache_min_uses`='{$_POST["proxy_cache_min_uses"]}',\n\t\t\t`proxy_cache_valid`='{$_POST["proxy_cache_valid"]}',\n\t\t\t`proxy_buffers`='{$_POST["proxy_buffers"]}',\n\t\t\t`proxy_buffer_size`='{$_POST["proxy_buffer_size"]}',\n\t\t\t`proxy_max_temp_file_size`='{$_POST["proxy_max_temp_file_size"]}',\n\t\t\t`proxy_temp_file_write_size`='{$_POST["proxy_temp_file_write_size"]}'\n\t\t\tWHERE `servername`='{$servername}'"; $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error; } }
function page() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $t = time(); $sql = "SELECT zDate,not_categorized FROM tables_day ORDER BY zDate"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $xdata[] = $ligne["tdate"]; $ydata[] = $ligne["not_categorized"]; } $targetedfile = "ressources/logs/" . basename(__FILE__) . "." . __FUNCTION__ . ".png"; $gp = new artica_graphs(); $gp->width = 880; $gp->height = 350; $gp->filename = "{$targetedfile}"; $gp->xdata = $xdata; $gp->ydata = $ydata; $gp->y_title = null; $gp->x_title = $tpl->_ENGINE_parse_body("{days}"); $gp->title = null; $gp->margin0 = true; $gp->Fillcolor = "blue@0.9"; $gp->color = "146497"; $gp->line_green(); if (!is_file($targetedfile)) { writelogs("Fatal \"{$targetedfile}\" no such file!", __FUNCTION__, __FILE__, __LINE__); $targetedfile = "img/kas-graph-no-datas.png"; } $sql = "SELECT zDate,not_categorized FROM tables_day WHERE not_categorized>0 ORDER BY zDate DESC"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } $c = 0; $table = null; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $c++; $table = $table . "<tr>\n\t\t\t<td style='font-size:14px' width=99%><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.visited.php?day={$ligne["zDate"]}&onlyNot=yes');\" style='font-size:14px;text-decoration:underline'>{$ligne["zDate"]}</a></td>\n\t\t\t<td style='font-size:14px' width=1%><strong>{$ligne["not_categorized"]}</strong></td>\n\t\t</tr>\n\t\t"; if ($c > 10) { $c = 0; $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>"; $table = null; } } if ($c > 0) { $tr[] = "<table style='width:20%' class=form><tbody>{$table}</tbody></table>"; } $t = time(); echo $tpl->_ENGINE_parse_body("\n\t<div id='{$t}'>\n\t<div style='font-size:18px'>{not_categorized}/{days}</div>\n\t\n\t<center>\n\t<div style='margin:8px;float-right;width:100%'>" . button("{analyze}", "NoCategorizedAnalyze()") . "</div>\n\t<img src='{$targetedfile}?t=" . time() . "'>\n\t</center>\n\t" . CompileTrGen($tr, 6) . "\n\t</div>\n\t</div>\n\t<script>\n\t\t\n\tvar x_NoCategorizedAnalyze= function (obj) {\n\t\t\tvar tempvalue=obj.responseText;\n\t\t\tif(tempvalue.length>3){alert(tempvalue)};\n\t\t\tif(document.getElementById('squid_stats_consumption')){\n\t \t\tRefreshTab('squid_stats_consumption');\n\t\t\t}\n\t\t\t\n\t\t\tif(document.getElementById('squid_stats_central')){\n\t \t\tRefreshTab('squid_stats_central');\n\t\t\t}\t\t\t\n\t\t}\t\n\n\t\tfunction NoCategorizedAnalyze(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('NoCategorizedAnalyze','yes');\n\t\t\tAnimateDiv('{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',x_NoCategorizedAnalyze);\n\t\t}\n\t</script>\t\t\n\t\n\t"); }
function SaveAccount() { $q = new mysql_squid_builder(); $q->QUERY_SQL("UPDATE usersisp SET user_password='******',email='{$_POST["email"]}' WHERE userid={$_SESSION["uid"]}"); if (!$q->ok) { echo $q->mysql_error; return; } $tpl = new templates(); echo $tpl->javascript_parse_text("{success}"); }
function js() { $ID = $_GET["ID"]; $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT GroupName FROM webfilters_sqgroups WHERE ID='{$ID}'")); $title = $tpl->_ENGINE_parse_body("{proxy_objects}::{$ligne["GroupName"]}::{events}"); $html = "YahooWin3('814','{$page}?popup=yes&ID={$ID}','{$title}')"; echo $html; }
function GetWebsitesList() { $q = new mysql_squid_builder(); $arrayDN = $q->GetFamilySitestt(null, true); while (list($table, $fff) = each($arrayDN)) { if (preg_match("#\\.(gov|gouv|gor|org|net|web|ac)\\.#", "google.{$table}")) { continue; } $array[] = "www.google.{$table}"; } return $array; }
function CICAPEnableSquidGuardSave() { $q = new mysql_squid_builder(); $sock = new sockets(); $q->CheckTablesICAP(); $sock->SET_INFO("CICAPEnableSquidGuard", $_POST["CICAPEnableSquidGuard"]); if ($_POST["CICAPEnableSquidGuard"] == 1) { $q->QUERY_SQL("UPDATE c_icap_services SET enabled=1,zOrder=3 WHERE ID=12"); } else { $q->QUERY_SQL("UPDATE c_icap_services SET enabled=0 WHERE ID=12"); } }