function xstart() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid"; $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { return; } $TimeExec = $unix->file_time_min($pidtime); if ($TimeExec < 360) { return; } @unlink($pidtime); @file_put_contents($pidtime, time()); @file_put_contents($pidfile, getmypid()); $php5 = $unix->LOCATE_PHP5_BIN(); $q = new mysql_squid_builder(); $q->CreateCategoryUrisTable("malware"); $COUNT1 = $q->COUNT_ROWS("categoryuris_malware"); vxvault(); malwareurls_joxeankoret(); clean_mx_de(); $COUNT2 = $q->COUNT_ROWS("categoryuris_malware"); $URLS_ADDED = $COUNT2 - $COUNT1; if ($URLS_ADDED > 0) { system("{$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category malware"); squid_admin_mysql(2, "{$URLS_ADDED} malware URLs added", null, __FILE__, __LINE__); } }
function page() { //dashboard_user_day $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $html = "<div style='width:1490'>\n\t<div style='float:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjaxRound('squid-top-stats','squid.statistics.top.php');") . "</div>\n\t<div style='font-size:30px'>{top_web}: " . DATE_START() . "</div>\n\t"; if ($q->COUNT_ROWS("dashboard_countwebsite_day") > 1) { $tr[] = "\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-site-size'></div>\n\t\t\t</td>\t\t\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-site-hits'></div>\n\t\t\t</td>\t\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-web-site-size=yes');"; $js[] = "Loadjs('{$page}?top-web-site-hits=yes');"; } if ($q->COUNT_ROWS("dashboard_user_day") > 1) { $tr[] = "\n\t\t<tr>\n\t\t\t<td colspan=2><hr></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-user-size'></div>\n\t\t\t</td>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-user-hits'></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-web-user-size=yes');"; $js[] = "Loadjs('{$page}?top-web-user-hits=yes');"; } if ($q->COUNT_ROWS("dashboard_blocked_day") > 1) { $tr[] = "\n\t\t<tr>\n\t\t\t<td colspan=2><hr></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-blocked-site'></div>\n\t\t\t</td>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-web-blocked-category'></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-web-blocked-site=yes');"; $js[] = "Loadjs('{$page}?top-web-blocked-category=yes');"; } $html = $html . "<table style='width:100%'>" . @implode("\n", $tr) . "</table></div>\n\t<script>\t\t\n\t\t\t\n\t" . @implode("\n", $js) . "</script>"; echo $tpl->_ENGINE_parse_body($html); }
function page() { $sock = new sockets(); $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); $MalwarePatrolDatabasesCount = $sock->getFrameWork("cmd.php?MalwarePatrolDatabasesCount=yes"); if (GET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__)) { return; } $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $users = new usersMenus(); $websitesnums = $q->COUNT_ROWS("visited_sites"); $websitesnums = numberFormat($websitesnums, 0, "", " "); $sql = "DELETE FROM categorize WHERE LENGTH(pattern)=0"; $q->QUERY_SQL($sql); $export = $q->COUNT_ROWS("categorize"); $export = numberFormat($export, 0, "", " "); $categories = $q->COUNT_CATEGORIES(); $categories = numberFormat($categories, 0, "", " "); $tablescat = $q->LIST_TABLES_CATEGORIES(); $tablescatNUM = numberFormat(count($tablescat), 0, "", " "); $q = new mysql_squid_builder(); $requests = $q->EVENTS_SUM(); $requests = numberFormat($requests, 0, "", " "); $PhishingURIS = $q->COUNT_ROWS("uris_phishing"); $PhishingURIS = numberFormat($PhishingURIS, 0, "", " "); $MalwaresURIS = $q->COUNT_ROWS("uris_malwares"); $MalwaresURIS = numberFormat($MalwaresURIS, 0, "", " "); $Computers = $q->COUNT_ROWS("webfilters_nodes"); $Computers = numberFormat($Computers, 0, "", " "); $DAYSNumbers = $q->COUNT_ROWS("tables_day"); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(totalsize) as tsize FROM tables_day")); $totalsize = FormatBytes($ligne["tsize"] / 1024); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT AVG(cache_perfs) as pourc FROM tables_day")); $pref = round($ligne["pourc"]); $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(sitename) as tcount FROM visited_sites WHERE LENGTH(category)=0")); $websitesnumsNot = numberFormat($ligne["tcount"], 0, "", " "); $CachePermformance = $q->CachePerfHour(); if ($CachePermformance > -1) { $color = "#E01313"; if ($CachePermformance > 20) { $color = "#6DBB6A"; } $cachePerfText = "\n\t\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b style='color:{$color}'>{$CachePermformance}%</b> {cache_performance} ({now})</td>\n\t\t</tr>\n\t\t"; } $mouse = "OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\""; $submenu = "\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$totalsize}</b> {downloaded_flow}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$pref}%</b> {cache_performance}</td>\n\t</tr>\n\t"; $main_table = "\n\t<table style='width:98%' class=form>\n\t<tr><td style='font-size:16px'>{statistics}::{status}</td></tr>\n\t{$cachePerfText}\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;><b>{$DAYSNumbers}</b> {daysOfStatistics}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$requests}</b> {requests}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px'><b>{$Computers}</b> {computers}</td>\n\t</tr>\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$websitesnums}</b> {visited_websites}</td>\n\t</tr>\t\n\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$categories}</b> {websites_categorized}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$PhishingURIS}</b> {phishing_uris}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$MalwaresURIS}</b> {viruses_uris}</td>\n\t</tr>\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$MalwarePatrolDatabasesCount}</b> Malware Patrol</td>\n\t</tr>\t\t\t\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$websitesnumsNot}</b> {not_categorized}</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td valign='top' style='font-size:14px;'><b>{$tablescatNUM}</b> {categories}</td>\n\t</tr>\n\t</table>\t\n"; $main_table = $tpl->_ENGINE_parse_body($main_table); SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $main_table); echo $main_table; }
function status(){ $q=new mysql_squid_builder(); $page=CurrentPageName(); $tpl=new templates(); $total=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3); $sql="SELECT count(*) as tcount FROM `dansguardian_sitesinfos` WHERE `dbpath` = ''"; $ligne=@mysql_fetch_array($q->QUERY_SQL($sql,'artica_backup')); $websites_not_categorized=$tpl->_ENGINE_parse_body("{websites_not_categorized}"); $pp=$tpl->_ENGINE_parse_body(Paragraphe("64-categories.png",$ligne["tcount"]." $websites_not_categorized", "{websites_not_categorized_text}","javascript:Loadjs('squid.visited.php')",null,300,76)); $html=" <table style='width:100%'> <tr> <td valign='top'><img src='img/webfilter-community-128.png'></td> <td valign='top' width=99%'> <div class=text-info>{APP_WEBFILTER_COMMUNITY_EXPLAIN}</div> <div style='font-size:14px;font-weight:bold'>$total {websites} ({community})</div> $pp </td> </tr> </table> "; echo $tpl->_ENGINE_parse_body($html); }
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 title_not_categorized() { $tpl = new templates(); $q = new mysql_squid_builder(); $number = FormatNumber($q->COUNT_ROWS("notcategorized")); echo $tpl->_ENGINE_parse_body("{$number} {not_categorized}"); }
function page(){ $q=new mysql_squid_builder(); $timekey=date('Ymd'); $timekeyMonth=date("Ym"); $time=time(); $page=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $table="squidmemory_$timekey"; $TableMonth="squidmemoryM_$timekeyMonth"; if($q->TABLE_EXISTS($table)){ if($q->COUNT_ROWS($table)>1){ $f1[]="<div style='width:1150px;height:340px' id='$time-squid-02'></div>"; $f2[]=" function XSquid02$time(){ AnimateDiv('$time-squid-02'); Loadjs('$page?graph-hour=yes&container=$time-squid-02&time=$time',true); } setTimeout(\"XSquid02$time()\",500);"; $f1[]="<div style='width:1150px;height:340px' id='$time-squid-03'></div>"; $f2[]=" function XSquid03$time(){ AnimateDiv('$time-squid-03'); Loadjs('$page?graph-hour-day=yes&container=$time-squid-03&time=$time',true); } setTimeout(\"XSquid03$time()\",500);"; } } if($q->TABLE_EXISTS($TableMonth)){ if($q->COUNT_ROWS($table)>1){ $f1[]="<div style='width:1150px;height:340px' id='$time-squid-04'></div>"; $f2[]=" function XSquid04$time(){ AnimateDiv('$time-squid-04'); Loadjs('$page?graph-hour-month=yes&container=$time-squid-04&time=$time',true); } setTimeout(\"XSquid04$time()\",500);"; } } $tpl=new templates(); echo "<div style='font-size:26px'>".$tpl->_ENGINE_parse_body("{proxy_memory_service_status}")."</div><p> </p>".@implode($f1, "\n")."<script>\n".@implode($f2, "\n")."</script>"; }
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() { //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 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 js() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $export = $q->COUNT_ROWS("categorize"); $title = $tpl->_ENGINE_parse_body("{$export} {websites_to_export}"); $html = "YahooWin('650','{$page}?popup=yes','{$title}')"; echo $html; }
function community_status(){ $page=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $all_count=FormatNumber($q->COUNT_ROWS("dansguardian_community_categories","artica_backup"),0,'.',' ',3); $artica_community=Paragraphe('webfilter-community-64.png','{community}','{webfilter_community_text}',"javascript:Loadjs('webfilter.community.php')"); if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";} $html=" <table style='width:100%'> <tr> <td width=99% valign='top'> <table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'> <thead class='thead'> <tr> <th colspan=2></th> <th> </th> </tr> </thead> <tbody class='tbody'> <tr class=$classtr> <td style='font-size:14px' colspan=2><i>{websites_number}:</i> <strong>$all_count</i></td> </tr> "; $array=unserialize(@file_get_contents("ressources/logs/web.community.db.status.txt")); while (list ($num, $ligne) = each ($array) ){ if($classtr=="oddRow"){$classtr=null;}else{$classtr="oddRow";} $f=FormatNumber($ligne,0,'.',' ',3); $html=$html."<tr class=$classtr> <td style='font-size:14px;text-align:right' width=1% nowrap><strong>$num:</td> <td style='font-size:14px' width=99%><strong>$f</strong></td> </tr>"; } $html=$html."</table> </td> <td valign='top' width=1%>$artica_community</td> </tr> </table> "; echo $tpl->_ENGINE_parse_body($html); }
function popup() { $fontsize = 18; $tpl = new templates(); $page = CurrentPageName(); $users = new usersMenus(); $q = new mysql_squid_builder(); $webfilters_usersasks = $q->COUNT_ROWS("webfilters_usersasks"); $array["table"] = "{$webfilters_usersasks} {unblocks}"; $array["queue"] = "{queue}"; while (list($num, $ligne) = each($array)) { if ($num == "queue") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squidguardweb.unblock.queue.php\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n"); continue; } $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}={$time}\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n"); } echo build_artica_tabs($html, "main_squid_unlock_tabs") . "<script>LeftDesign('logs-white-256-opac20.png');</script>"; }
function search() { $search = $_GET["search"]; $search = "*{$search}*"; $search = str_replace("**", "*", $search); $search = str_replace("**", "*", $search); $search = str_replace("*", "%", $search); if (CACHE_SESSION_GET(__FILE__ . __FUNCTION__ . $search, __FILE__, 2)) { return; } $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $table = "visited_sites"; if ($q->COUNT_ROWS($table) == 0) { echo "<H2>" . $tpl->_ENGINE_parse_body("TABLE:{$table}<br>{error_no_datas}") . "</H2>"; return; } $sql = "SELECT familysite,SUM(HitsNumber) as HitsNumber FROM `{$table}` \n\tGROUP BY familysite HAVING (`familysite` LIKE '{$search}')\n\tORDER BY HitsNumber DESC LIMIT 0,100"; $html = "<center>\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t\n\t\t<th width=50% nowrap colspan=2>{websites}</th>\n\t\t<th width=50% nowrap>{hits}</th>\n\t\t<th width=1% nowrap> </th>\n\t</tr>\n</thead>\n<tbody class='tbody'>"; $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 = "BrowseWWWSelect('{$ligne["familysite"]}');"; $siteTool = imgtootltip("website-add-32.png", "{select}:{$ligne["familysite"]}", $js); $sitname = texttooltip($ligne["familysite"], "{select}", $js, null, 0, "font-size:14px;text-decoration:underline"); $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t<td width=1% style='font-size:14px'>{$siteTool}</td>\n\t\t<td style='font-size:14px' width=99%>{$sitname}</td>\n\t\t<td style='font-size:14px' width=1%>{$ligne["HitsNumber"]}</td>\n\t\t</tr>\t\n\t\t\n\t\t"; } $html = $html . "</tbody></table>\n"; CACHE_SESSION_SET(__FILE__ . __FUNCTION__ . $search, __FILE__, $tpl->_ENGINE_parse_body($html)); }
function week_uris_blocked_verify() { $q = new mysql_squid_builder(); $sql = "SELECT tablename,DATE_FORMAT( zDate, '%Y%m%d' ) AS tablesource, DAYOFWEEK(zDate) \n\t\t\tas DayNumber,WEEK( zDate ) AS tweek, YEAR( zDate ) \n\t\t\tAS tyear FROM tables_day WHERE zDate < DATE_SUB( NOW( ) , INTERVAL 1 DAY ) ORDER BY zDate"; $results = $GLOBALS["Q"]->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $tablename = $ligne["tablename"]; $week_table = "{$ligne["tyear"]}{$ligne["tweek"]}_blocked_week"; if ($GLOBALS["VERBOSE"]) { echo "\n*********** WEEK {$week_table} -> {$ligne["tweek"]} of year {$ligne["tyear"]} ***********\n"; } if (!$q->TABLE_EXISTS($week_table)) { if ($GLOBALS["VERBOSE"]) { echo "Restart {$tablename}\n"; } $q->QUERY_SQL("UPDATE tables_day SET weekbdone=0 WHERE `tablename`='{$tablename}'"); } $Rows = $q->COUNT_ROWS($week_table); if ($GLOBALS["VERBOSE"]) { echo "{$week_table} = {$Rows} rows\n"; } } }
function page() { //dashboard_user_day $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $html = "<div style='width:1490'>\n\t<div style='float:right'>" . imgtootltip("refresh-32.png", "{refresh}", "LoadAjaxRound('squid-top-stats','squid.statistics.top.php');") . "</div>\n\t<div style='font-size:30px'>{top_members} {last_15_minutes}</div>\n\t"; if ($q->COUNT_ROWS("dashboard_currentusers") == 0) { echo FATAL_ERROR_SHOW_128("No data"); return; } $tr[] = "\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-userid-size'></div>\n\t\t\t</td>\t\t\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-userid-hits'></div>\n\t\t\t</td>\t\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-userid-size=yes&token=USER&id=top-userid-size');"; $js[] = "Loadjs('{$page}?top-userid-hits=yes&token=USER&id=top-userid-hits');"; $tr[] = "\n\t\t<tr>\n\t\t\t<td colspan=2><hr></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-MAC-size'></div>\n\t\t\t</td>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-MAC-hits'></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-userid-size=yes&token=MAC&id=top-MAC-size');"; $js[] = "Loadjs('{$page}?top-userid-hits=yes&token=MAC&id=top-MAC-hits');"; $tr[] = "\n\t\t<tr>\n\t\t\t<td colspan=2><hr></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-ipaddr-size'></div>\n\t\t\t</td>\n\t\t\t<td style='width:100%'>\n\t\t\t\t<div style='width:745;height:700px' id='top-ipaddr-hits'></div>\n\t\t\t</td>\n\t\t</tr>\n\t\t"; $js[] = "Loadjs('{$page}?top-userid-size=yes&token=IPADDR&id=top-ipaddr-size');"; $js[] = "Loadjs('{$page}?top-userid-hits=yes&token=IPADDR&id=top-ipaddr-hits');"; $html = $html . "<table style='width:100%'>" . @implode("\n", $tr) . "</table></div>\n\t<script>\t\t\n\t\t\t\n\t" . @implode("\n", $js) . "</script>"; echo $tpl->_ENGINE_parse_body($html); }
function Compile() { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = @file_get_contents($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { if ($GLOBALS["VERBOSE"]) { echo "Already executed pid {$pid}\n"; } return; } $t = time(); $q = new mysql_squid_builder(); echo "**** LIST_TABLES_CATEGORIES_PERSO *****\n"; $tablescat = $q->LIST_TABLES_CATEGORIES_PERSO(); $source_dir = "/home/artica/categories_perso"; if (count($tablescat) == 0) { echo "tablescat = 0\n"; return; } $i = 0; while (list($tablename, $ligne) = each($tablescat)) { if (preg_match("#^categoryuris#", $tablename)) { continue; } $COUNT_ROWS = $q->COUNT_ROWS($tablename); if ($COUNT_ROWS == 0) { continue; } echo " **** {$tablename} {$COUNT_ROWS} ITEMS *****\n"; $Dir = "{$source_dir}/{$tablename}"; @mkdir("{$Dir}", 0777, true); echo "{$tablename}: Building {$Dir}/domains"; @unlink("{$Dir}/domains"); @chmod("{$Dir}/domains", 0777); $sql = "SELECT pattern FROM {$tablename} WHERE enabled=1 ORDER BY pattern INTO OUTFILE '{$Dir}/domains' LINES TERMINATED BY '\n';"; $q->QUERY_SQL($sql); if (!$q->ok) { echo "{$tablename}: {$q->mysql_error}\n"; continue; } $handle = @fopen("{$Dir}/domains", "r"); if (!$handle) { echo "Failed to open file {$Dir}/domains\n"; continue; } $DestDB = "{$Dir}/domains.db"; @unlink($DestDB); $db_desttmp = dba_open($DestDB, "n", "db4"); if (!$db_desttmp) { echo "Unable to Create {$DestDB}\n"; continue; } dba_close($db_desttmp); $db_dest = dba_open($DestDB, "w", "db4"); @chmod($DestDB, 0777); if (!$db_dest) { echo "Unable to open for `writing` \"{$DestDB}\"\n"; continue; } while (!feof($handle)) { $www = trim(fgets($handle, 4096)); $www = trim(str_replace('"', "", $www)); if ($www == null) { continue; } $www = strtolower($www); if (!dba_insert("{$www}", "yes", $db_dest)) { echo "dba_insert({$www},yes... false\n"; continue; } } $i++; dba_close($db_dest); @fclose($handle); @unlink("{$Dir}/domains"); } stats_admin_events(2, "1%) {$i} Personal tables compiled took:" . $unix->distanceOfTimeInWords($t, time()), null, __FILE__, __LINE__); }
function hosts() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $t = $_GET["t"]; $search = '%'; $table = "dnsmasq_records"; $page = 1; $FORCE_FILTER = null; $total = 0; 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 { $total = $q->COUNT_ROWS("dnsmasq_records"); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; if (is_numeric($rp)) { $limitSql = "LIMIT {$pageStart}, {$rp}"; } $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $no_rule = $tpl->_ENGINE_parse_body("{no data}"); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { if (strpos($q->mysql_error, "doesn't exist") > 0) { $q->CheckTables(); $results = $q->QUERY_SQL($sql); } } if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $fontsize = "16"; while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?delete-host-js=yes&ID={$ligne["ID"]}&t={$t}&tt={$_GET["tt"]}')"); $editjs = "<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:Loadjs('{$MyPage}?host-js=yes&ID={$ligne["ID"]}&t={$t}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM dnsmasq_cname WHERE recordid='{$ligne["ID"]}'")); $hostname = $ligne["hostname"]; $ipaddr = $ligne["ipaddr"]; $Items = $ligne2["tcount"]; $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$hostname}</a><br><i style='font-size:12px'> {$grouptype}</i></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ipaddr}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$Items}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>")); } echo json_encode($data); }
function panel_categories(){ $tpl=new templates(); $page=CurrentPageName(); $hour=$_GET["hour"]; if(strlen($hour)==1){$hour="0$hour";} $table=$_GET["table"]; $q=new mysql_squid_builder(); if($q->COUNT_ROWS($table)==0){ echo $tpl->_ENGINE_parse_body("$title<center style='margin:50px'><H2>{error_no_data}</H2>$sql</center>"); return; } $separator="<center><hr style='border:1px dotted #CCCCCC;width:80%'></center>"; if(!$q->TABLE_EXISTS($table)){echo "<H3>".$tpl->_ENGINE_parse_body("{ERROR_NO_DATA}$field")."</h3>";} $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE `hour`={$_GET["hour"]}")); $downloadedINT=$ligne["tsize"]; $downloaded=FormatBytes($downloadedINT/1024); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE `hour`={$_GET["hour"]} AND cached=1")); $cachedINT=$ligne["tsize"]; $cached=FormatBytes($cachedINT/1024); $pourc=$cachedINT/$downloadedINT; $pourc=$pourc*100; $pourc=round($pourc,2); $line=$tpl->_ENGINE_parse_body("$field{your_users_has_downloadedXD-XS-XP}$separator"); $line=str_replace("XD", "<strong>$downloaded</strong>", $line); $line=str_replace("XS", "<strong>$cached</strong>", $line); $line=str_replace("XP", "<strong style='color:#CF1717'>$pourc%</strong>", $line); $html[]="<div style='font-size:12px;text-align:justify;margin-bottom:5px'>$line</div>"; $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize,familysite,`hour` FROM $table GROUP BY familysite,`hour` HAVING `hour`={$_GET["hour"]} ORDER BY tsize DESC LIMIT 0,1")); $XXWWWS=$ligne["familysite"]; $XWSZE=FormatBytes($ligne["tsize"]/1024); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(hits) as tsize,familysite,`hour` FROM $table GROUP BY familysite,`hour` HAVING `hour`={$_GET["hour"]} ORDER BY tsize DESC LIMIT 0,1")); $XXWWWR=$ligne["familysite"]; $XWSZR=$ligne["tsize"]; $XWSCAT=familysite_MergeCategories(array($XXWWWS,$XXWWWR)); $linkWebsite1="<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table=$table&field=familysite&www=$XXWWWS');\" style='font-weight:bold;text-decoration:underline' >"; $linkWebsite2="<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.traffic.statistics.week.website.php?table=$table&field=familysite&www=$XXWWWR');\" style='font-weight:bold;text-decoration:underline' >"; $line=$tpl->_ENGINE_parse_body("{phrase_the_most_websites}"); $line=str_replace("XXWWWS", "$linkWebsite1$XXWWWS</a>", $line); $line=str_replace("XWSZE", "<strong>$XWSZE</strong>", $line); $line=str_replace("XXWWWR", "$linkWebsite2$XXWWWR</a>", $line); $line=str_replace("XWSZR", "<strong>$XWSZR</strong>", $line); $line=str_replace("XWSCAT", "<strong>$XWSCAT</strong>", $line); $html[]="<div style='font-size:12px;text-align:justify'>$line</div>"; $line=$tpl->_ENGINE_parse_body("{phrase_the_most_website_represent}"); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE familysite='$XXWWWS' AND `hour`={$_GET["hour"]}")); $XXWWWSPRC_bin=$ligne["tsize"]; $XXWWWSPRC_size=FormatBytes($XXWWWSPRC_bin/1024); $XXWWWSPRC=$XXWWWSPRC_bin/$downloadedINT; $XXWWWSPRC=$XXWWWSPRC*100; $XXWWWSPRC=round($XXWWWSPRC,2); $ligne=mysql_fetch_array($q->QUERY_SQL("SELECT SUM(size) as tsize FROM $table WHERE familysite='$XXWWWS' AND `hour`={$_GET["hour"]} AND cached=1")); $XXWWWSCHE_bin=$ligne["tsize"]; $XXWWWSCHE_size=FormatBytes($XXWWWSCHE_bin/1024); $line=str_replace("XXWWWSPRC", "<strong>$XXWWWSPRC% ($XXWWWSPRC_size)</strong>", $line); $line=str_replace("XXWWWSCHE", "<strong>$XXWWWSCHE_size</strong>", $line); $line=str_replace("XXWWWS", "$linkWebsite1$XXWWWS</a>", $line); $html[]="<div style='font-size:12px;text-align:justify;margin-top:10px'> <div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>$XXWWWS:</div> $line</div>"; // ****************************************************************************************************** $tabledetails="dansguardian_events_".date("Ymd"); $sql="SELECT mins,COUNT(ID) as thits,SUM(QuerySize) as tsize FROM (SELECT MINUTE(zDate) as mins,ID,QuerySize FROM $tabledetails WHERE HOUR(zDate)={$_GET["hour"]}) as t GROUP BY `mins` ORDER BY `mins` LIMIT 0,1"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); if(!$q->ok){echo $q->mysql_error;} $MostActiveMinNum=$ligne["mins"]; if(!is_numeric($MostActiveMinNum)){$MostActiveMinNum=0;} $MostActiveMinNumText=$MostActiveMinNum; if(strlen($MostActiveMinNumText)==1){$MostActiveMinNumText="0$MostActiveMinNumText";} $MostActiveDaySize=FormatBytes($ligne["tsize"]/1024); $title="{$hour}h$MostActiveMinNumText {phrase_most_time_activehour}"; $prc=round($ligne["tsize"]/$downloadedINT,2)*100; $html[]="<div style='color:#CF1717;font-weight:bold;margin-top:5px;font-size:13.5px'>$title</div> <div style='font-size:12px;text-align:justify;'>{with} <strong>{$ligne["thits"]} {hits}</strong> {or} <strong>$MostActiveDaySize</strong> {it_represents} <strong>$prc%</strong> {of_bandwith}</div> <div style='font-size:12px;text-align:justify;margin-top:10px;margin-bottom:15px'>{phrase_thisisthegraph2}:</div>"; $sql="SELECT mins,COUNT(ID) as thits FROM (SELECT MINUTE(zDate) as mins,ID FROM $tabledetails WHERE HOUR(zDate)={$_GET["hour"]}) as t GROUP BY `mins` ORDER BY `mins`"; $results=$q->QUERY_SQL($sql); while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ $xdata[]=$ligne["mins"]; $ydata[]=$ligne["thits"]; } $time=time(); $targetedfile="ressources/logs/".basename(__FILE__).".".__FUNCTION__.".$table.$time.png"; $gp=new artica_graphs(); $gp->width=270; $gp->height=150; $gp->filename="$targetedfile"; $gp->xdata=$xdata; $gp->ydata=$ydata; $gp->y_title=null; $gp->x_title=$tpl->_ENGINE_parse_body("{minutes}"); $gp->title=null; $gp->margin0=true; $gp->Fillcolor="blue@0.9"; $gp->color="146497"; $gp->line_green(); if(!is_file($targetedfile)){$targetedfile="img/nograph-000.png";} $html[]="<center style='margin-top:5px'><img src='$targetedfile'></center>"; $id=md5($_GET["table"].$_GET["hour"]); $html[]=" <script> if(!document.getElementById('panel-middle-$id')){alert('panel-middle-$id, no such id');} LoadAjax('panel-middle-$id','$page?panel-topwebistes=yes&time={$_GET["time"]}&hour={$_GET["hour"]}&table={$_GET["table"]}'); </script>"; echo $tpl->_ENGINE_parse_body(@implode("\n", $html)); }
function items() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $RULEID = $_GET["RULEID"]; $search = '%'; $table = "UserAgents"; $page = 1; 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 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; if (!$q->ok) { json_error_show("{$q->mysql_error}"); } } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}`"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; if (!$q->ok) { json_error_show("{$q->mysql_error}"); } } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM `{$table}` WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show("{$q->mysql_error}"); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", "")); json_encode($data); return; } while ($ligne = mysql_fetch_assoc($results)) { $pattern_enc = urlencode($ligne["pattern"]); $data['rows'][] = array('id' => md5($ligne["pattern"]), 'cell' => array("<span style='font-size:14px;'>{$ligne["pattern"]}</span>", imgtootltip("plus-24.png", null, "Loadjs('squid.browsers-rules.php?ruleid-js=0&pattern={$pattern_enc}');") . "</span>")); } echo json_encode($data); }
function listext() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $t = $_GET["t"]; $search = '%'; $table = "webfilter_bannedextsdoms"; $page = 1; $ORDER = "ORDER BY ext ASC"; $FORCE_FILTER = " AND ruleid={$_GET["RULEID"]}"; $total = 0; if (!$q->TABLE_EXISTS($table)) { $q->CheckTables(); } if ($q->COUNT_ROWS($table, "artica_backup") == 0) { $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); echo json_encode($data); return; } 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"] = 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, "artica_backup")); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); $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__); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $results = $q->QUERY_SQL($sql, "artica_backup"); $divstart = "<span style='font-size:14px;font-weight:bold'>"; $divstop = "</div>"; $noneTXT = $tpl->_ENGINE_parse_body("{none}"); while ($ligne = mysql_fetch_assoc($results)) { $img = "img/ext/def_small.gif"; if (file_exists("img/ext/{$ligne['ext']}_small.gif")) { $img = "img/ext/{$ligne['ext']}_small.gif"; } $disable = Field_checkbox("disable_{$ligne["zmd5"]}", 1, $ligne["enabled"], "bannedextensionlist_enable{$t}('{$ligne["zmd5"]}')"); $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ext']}", "bannedextensionlist_delete{$t}('{$ligne["zmd5"]}')"); $data['rows'][] = array('id' => $ligne['zmd5'], 'cell' => array("<strong style='font-family:Courier New;font-size:14px'>http://*domain.<span style='color:#A40000'>{$ligne['ext']}</span>/...</strong>", "<span style='font-size:13px'>{$ligne['description']}</span>", "<div style='margin-top:5px'>{$disable}</div>", $delete)); } // http://*domain.<span style='color:#A40000'> 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(); $ID = $_GET["ID"]; $FORCE_FILTER = null; $search = '%'; $table = "webfilters_sqitems"; $page = 1; if ($q->COUNT_ROWS($table) == 0) { json_error_show("no item"); } 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 gpid={$ID} {$FORCE_FILTER} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE gpid={$ID} {$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 gpid={$ID} {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql); if (!$q->ok) { json_error_show($q->mysql_error); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (mysql_num_rows($results) == 0) { json_error_show("no item"); } while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $disable = Field_checkbox("itemid_{$ligne['ID']}", 1, $ligne["enabled"], "EnableDisableItem('{$ligne['ID']}')"); $macname = $q->MAC_TO_NAME($ligne['pattern']); $ligne['pattern'] = utf8_encode($ligne['pattern']); $delete = imgtootltip("delete-24.png", "{delete} {$ligne['pattern']}", "DeleteGroupItem('{$ligne['ID']}')"); $additional_text = null; if ($macname) { $additional_text = "<div style='font-size:10px'>{$macname}</div>"; } $data['rows'][] = array('id' => "item{$ligne['ID']}", 'cell' => array("<span style='font-size:14px;font-weight:bold'>{$ligne['pattern']}</span>{$additional_text}", "<div style='padding-top:5px'>{$disable}</div>", $delete)); } echo json_encode($data); }
function quota_destination_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(); $ID = $_GET["ID"]; $acl = new squid_acls(); $t0 = $_GET["t"]; $search = '%'; $table = "(SELECT webfilters_quotas_grp.gpid,webfilters_quotas_grp.zmd5, webfilters_quotas_grp.ID as LINKID, webfilters_sqgroups.* FROM webfilters_quotas_grp, webfilters_sqgroups WHERE webfilters_quotas_grp.gpid=webfilters_sqgroups.ID AND webfilters_quotas_grp.ruleid={$ID}) as t"; $page = 1; if (!$q->TABLE_EXISTS("webfilters_quotas_grp")) { $q->CheckTables(null, true); } if ($q->COUNT_ROWS("webfilters_quotas_grp") == 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} {$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("No item"); } $rules = $tpl->_ENGINE_parse_body("{rules}"); $acl = new squid_acls_groups(); while ($ligne = mysql_fetch_assoc($results)) { $val = 0; $ID = $ligne["ID"]; $md5 = $ligne["zmd5"]; $arrayF = $acl->FlexArray($ligne['gpid']); $delete = imgsimple("delete-24.png", null, "DeleteObjectLinks{$t0}('{$md5}')"); $data['rows'][] = array('id' => "{$md5}", 'cell' => array($arrayF["ROW"], "<span style='font-size:14px;font-weight:bold'>{$arrayF["ITEMS"]}</span>", $delete)); } echo json_encode($data); }
function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $t = $_GET["t"]; $total = 0; if ($q->COUNT_ROWS("dashboard_user_day", "artica_backup") == 0) { json_error_show("no data [" . __LINE__ . "]", 0); } if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } $table = "(SELECT SUM(RQS) as RQS, SUM(SIZE) as SIZE,USER FROM dashboard_user_day GROUP BY USER ) as t"; $searchstring = string_to_flexquery(); if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if (!is_numeric($rp)) { $rp = 100; } $pageStart = ($page - 1) * $rp; if ($pageStart < 0) { $pageStart = 0; } $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT * FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, "artica_events"); $total = mysql_num_rows($results); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}", 0); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CurrentPage = CurrentPageName(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $q1 = new mysql(); $t = time(); $fontsize = 22; $span = "<span style='font-size:{$fontsize}px'>"; $IPTCP = new IP(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $zmd5 = $ligne["zmd5"]; $member_value = trim($ligne["USER"]); $hits = FormatNumber($ligne["RQS"]); $size = FormatBytes($ligne["SIZE"] / 1024); $ahref = null; $member_assoc = null; $graph = imgtootltip("graph2-48.png", "{statistics}", "Loadjs('{$MyPage}?graph-js=yes&uid=" . urlencode($member_value) . "')"); $graph2 = imgtootltip("graphs-48.png", "{statistics}", "Loadjs('{$MyPage}?graph2-js=yes&uid=" . urlencode($member_value) . "')"); if ($IPTCP->IsvalidMAC($member_value)) { $mac_encoded = urlencode($member_value); $uid = $q->MacToUid($member_value); if ($uid != null) { $member_assoc = " ({$uid})"; } $ahref = "<a href=\"javascript:blur();\"\n\t\t\t\t\tOnClick=\"javascript:Loadjs('squid.nodes.php?node-infos-js=yes&MAC={$mac_encoded}');\"\n\t\t\t\t\tstyle='font-size:{$fontsize};text-decoration:underline'>"; } $data['rows'][] = array('id' => $member_value, 'cell' => array("{$span}{$ahref}{$member_value}</a>{$member_assoc}</span>", "{$span}{$hits}</a></span>", "{$span}{$size}</a></span>", "<center>{$graph}</center>", "<center>{$graph2}</center>")); } echo json_encode($data); }
function js() { header("content-type: application/x-javascript"); $page = CurrentPageName(); $tpl = new templates(); if (!$_SESSION["CORP"]) { $onlycorpavailable = $tpl->javascript_parse_text("{onlycorpavailable}"); echo "alert('{$onlycorpavailable}');"; return; } $q = new mysql_squid_builder(); $youtube_objects = $q->COUNT_ROWS("youtube_objects"); $youtube_objects = numberFormat($youtube_objects, 0, "", " "); $title = $tpl->_ENGINE_parse_body("{$youtube_objects} Youtube {objects}"); echo "YahooWin3('926','{$page}?master-content=yes','{$title}')"; }
function defaults_ports() { $defaults = "22,23,21,24,25,70,81,82,83,3128,88,109,110,113,119,123,143,144,150,194,201,202,203,204,205,206,207,208,209,210,220,389,3306,563,631,873,993,995,1080,1194,1863,3389,5060,5222,5223,5269,5280,5432,5900,5984,6667,6666,6697,7000,8008,8098,9009,25565,49300,8080,9000,9090,3140,3147"; $q = new mysql_squid_builder(); $table = "hotspot_blckports"; if ($q->COUNT_ROWS($table) == 0) { $sql = "CREATE TABLE IF NOT EXISTS `squidlogs`.`hotspot_blckports` ( `port` BIGINT UNSIGNED , `enabled` smallint(1) NOT NULL, PRIMARY KEY ( `port` ) , INDEX ( `enabled`) ) ENGINE = MYISAM;"; $q->QUERY_SQL($sql); $defaultsZ = explode(",", $defaults); while (list($none, $ports) = each($defaultsZ)) { $sqlZ[] = "({$ports},1)"; } $sql = "INSERT IGNORE INTO hotspot_blckports (`port`,`enabled`) VALUES " . @implode(',', $sqlZ); $q->QUERY_SQL($sql); } $sql = "SELECT port FROM `hotspot_blckports` WHERE enabled=1"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$q->mysql_error}\n"; } return; } $Total = mysql_num_rows($results); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["SERVICE_NAME"]} {$Total} restricted ports\n"; } while ($ligne = mysql_fetch_assoc($results)) { $GLOBALS["RESTRICTED_PORTS"][$ligne["port"]] = $ligne["port"]; } }
function clean_squid_stats_dbs() { $sock = new sockets(); $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics"); $CleanArticaSquidDatabases = $sock->GET_INFO("CleanArticaSquidDatabases"); if (!is_numeric($DisableArticaProxyStatistics)) { $DisableArticaProxyStatistics = 0; } if (!is_numeric($CleanArticaSquidDatabases)) { $CleanArticaSquidDatabases = 0; } if (!$GLOBALS["FORCE"]) { if ($CleanArticaSquidDatabases == 0) { echo "Option is not activated...\n"; return; } } $q = new mysql_squid_builder(); $tables = $q->LIST_TABLES_DAYS(); $rows = 0; $count_tables = 0; while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_DAYS_BLOCKED(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_MEMBERS(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_MONTH(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $tables = $q->LIST_TABLES_WEEKS(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $q = new mysql_catz(); $tables = $q->LIST_TABLES_CATEGORIES(); while (list($num, $table) = each($tables)) { $rows = $rows + $q->COUNT_ROWS($table); if ($GLOBALS["VERBOSE"]) { echo " Delete table {$table} {$rows} rows \n"; } $count_tables++; $q->DELETE_TABLE($table); } $q = new mysql(); if ($q->DATABASE_EXISTS("catz")) { $q->DELETE_DATABASE("catz"); } if ($count_tables > 0) { mysql_admin_mysql(1, "Restarting MySQL service...", null, __FILE__, __LINE__); shell_exec("/etc/init.d/mysql restart"); } $sock->TOP_NOTIFY("{$count_tables} statistics tables as been deleted with {$rows} rows", "info"); //print_r($tables); }
function list_items() { $STATUS = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/nginx.status.acl")); $tpl = new templates(); $MyPage = CurrentPageName(); $all_text = $tpl->_ENGINE_parse_body("{all}"); $GLOBALS["CLASS_TPL"] = $tpl; $q = new mysql_squid_builder(); $OrgPage = "miniadmin.proxy.reverse.php"; $sock = new sockets(); $EnableFreeWeb = intval($sock->GET_INFO("EnableFreeWeb")); if (!$q->FIELD_EXISTS("reverse_www", "zOrder")) { $q->QUERY_SQL("ALTER TABLE `reverse_www` ADD `zOrder` smallint(100) NOT NULL default '0'"); if (!$q->ok) { echo $q->mysql_error_html(); } } $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=0&t={$_GET["t"]}')"); $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&ID={$ligne["ID"]}&dir=1&t={$_GET["t"]}')"); $FORCE = "cache_peer_id={$_GET["ID"]}"; $search = '%'; $table = "reverse_www"; $page = 1; $freeweb_compile_background = $tpl->javascript_parse_text("{freeweb_compile_background}"); $reset_admin_password = $tpl->javascript_parse_text("{reset_admin_password}"); $delete_freeweb_text = $tpl->javascript_parse_text("{delete_freeweb_text}"); $delete_freeweb_nginx_text = $tpl->javascript_parse_text("{delete_freeweb_nginx_text}"); $delete_freeweb_dnstext = $tpl->javascript_parse_text("{delete_freeweb_dnstext}"); $total = 0; if ($q->COUNT_ROWS($table, "artica_backup") == 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(*) as TCOUNT FROM `{$table}` WHERE {$FORCE} {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { if (strlen($FORCE) > 2) { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table, "artica_events"); } } 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 {$FORCE} {$searchstring} {$ORDER} {$limitSql}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}", 1); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $CurrentPage = CurrentPageName(); if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $searchstring = string_to_flexquery(); if (!AdminPrivs()) { $sql = "SELECT reverse_www.* FROM reverse_www,reverse_privs\n\t\tWHERE reverse_privs.servername=reverse_www.servername\n\t\tAND reverse_privs.uid='{$_SESSION["uid"]}' {$searchstring} ORDER BY servername LIMIT 0,250"; } $results = $q->QUERY_SQL($sql, 'artica_backup'); if (!$q->ok) { json_error_show($q->mysql_error . "<br>{$sql}"); } $q1 = new mysql(); $t = time(); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $servername = $ligne["servername"]; $explain_text = NGINX_EXPLAIN_REVERSE($ligne["servername"]); $icon = "clound-in-64.png"; $freewebicon = "64-firewall-search.png"; $color = "black"; $status = array(); $portText = null; $md = md5(serialize($ligne)); $RedirectQueries = $ligne["RedirectQueries"]; $default_server = $ligne["default_server"]; $SiteEnabled = $ligne["enabled"]; $servername_enc = urlencode($servername); $Compile = imgsimple("apply-48.png", null, "Loadjs('nginx.single.progress.php?servername={$servername_enc}')"); $limit_rate = $ligne["limit_rate"]; $limit_rate_after = $ligne["limit_rate_after"]; $DeleteFreeWeb = "Loadjs('{$MyPage}?unlink-websites-js=yes&servername={$servername_enc}&md={$md}')"; $icon2 = imgsimple("reconfigure-48.png", null, "Loadjs('miniadmin.proxy.reverse.reconfigure.php?servername={$servername_enc}')"); $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&servername={$servername_enc}&dir=0&t={$_GET["t"]}')"); $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?move-item-js=yes&servername={$servername_enc}&dir=1&t={$_GET["t"]}')"); if ($ligne["DenyConf"] == 1) { $icon = "hearth-blocked-64.png"; } if ($SiteEnabled == 0) { $icon = "domain-main-64-grey.png"; $color = "#8a8a8a"; $icon2 = " "; } $delete = imgsimple("delete-48.png", null, $DeleteFreeWeb); $jsedit = imgsimple($icon, null, "Loadjs('nginx.site.php?servername={$servername_enc}')"); $jsEditWW = $jsedit; $jseditA = $jsedit; $jseditC = imgsimple("script-48.png", null, "Loadjs('nginx.script.php?website-script-js=yes&servername={$servername_enc}')"); if ($limit_rate > 0) { $limit_rate_after_caption = $tpl->_ENGINE_parse_body("{limit_rate_after_caption}"); $limit_rate_after_caption = str_replace("%s", "{$limit_rate}MB/s", $limit_rate_after_caption); $limit_rate_after_caption = str_replace("%f", "{$limit_rate_after}MB", $limit_rate_after_caption); $status[] = "<br><span style='font-size:12px;font-weight:bold;color:#EEB853'>{$limit_rate_after_caption}</span>"; } if (count($status) > 0) { $status_text = $tpl->_ENGINE_parse_body("<div style='font-size:12px'>" . @implode("", $status) . "</div>"); } $FreeWebText = null; if ($EnableFreeWeb == 0) { if ($ligne["ipaddr"] == "127.0.0.1") { $ligne["ipaddr"] = "{error}"; } if ($ligne["cache_peer_id"] == 0) { $ligne["cache_peer_id"] = -1; } } if ($ligne["owa"] == 1) { $freewebicon = "exchange-2010-64.png"; } if ($ligne["poolid"] > 0) { $freewebicon = "64-cluster.png"; $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT poolname FROM nginx_pools WHERE ID='{$ligne["poolid"]}'")); $ligne["ipaddr"] = $ligne2["poolname"]; } $stats = null; $FinalDestination = "{$ligne["ipaddr"]}{$FreeWebText}"; if ($default_server == 1) { $servername = "{$servername} ({$all_text} * )"; $icon = "free-web-64.png"; if ($SiteEnabled == 0) { $icon = "free-web-64-grey.png"; } } $data['rows'][] = array('id' => $ligne['categorykey'], 'cell' => array("{$jseditC}", "<a href=\"javascript:blur();\"\n\t\t\t\t\t\t\tstyle='font-size:18px;font-weight:bold;text-decoration:underline'\n\t\t\t\t\t\t\tOnClick=\"javascript:Loadjs('nginx.site.php?servername={$servername_enc}')\">{$servername}{$portText}</a>\n\t\t\t\t\t\t\t<br>{$status_text}\n\t\t\t\t\t\t\t{$explain_text}", $Compile, $delete)); } echo json_encode($data); }
function accounts_save() { $q = new mysql_squid_builder(); $users = new usersMenus(); while (list($num, $ligne) = each($_POST)) { $_POST[$num] = url_decode_special_tool($ligne); } if (!$q->FIELD_EXISTS("rdpproxy_items", "domain")) { $q->QUERY_SQL("ALTER TABLE `rdpproxy_items` ADD `domain` VARCHAR(128)"); } $ID = $_POST["ID"]; if ($ID > 0) { $sql = "UPDATE rdpproxy_items SET \n\t\t\t`service` ='{$_POST["service"]}',\n\t\t\t`rhost` ='{$_POST["rhost"]}',\n\t\t\t`username` ='{$_POST["username"]}',\n\t\t\t`domain` ='{$_POST["domain"]}',\n\t\t\t`password` ='{$_POST["password"]}',\n\t\t\t`servicetype` ='{$_POST["servicetype"]}',\n\t\t\t`serviceport` ='{$_POST["serviceport"]}',\n\t\t\t`alive` ='{$_POST["alive"]}',\n\t\t\t`is_rec` ='{$_POST["is_rec"]}' WHERE ID={$_POST["ID"]}"; } else { if (!$users->CORP_LICENSE) { if ($q->COUNT_ROWS("rdpproxy_items") > 50) { echo base64_decode("TGljZW5zZSBlcnJvciBNQVg6NTAK"); return; } } $sql = "INSERT INTO rdpproxy_items (`userid`,\t`service`,`rhost`,`username`,`password`,`servicetype`,\n\t\t\t`serviceport`,`alive`,`is_rec`,`domain`)\n\t\tVALUES ('{$_POST["userid"]}','{$_POST["service"]}','{$_POST["rhost"]}',\n\t\t\t'{$_POST["username"]}',\n\t\t\t'{$_POST["password"]}',\n\t\t\t'{$_POST["servicetype"]}',\n\t\t\t'{$_POST["serviceport"]}',\n\t\t\t'{$_POST["alive"]}',\n\t\t\t'{$_POST["is_rec"]}','{$_POST["domain"]}')"; } $q->QUERY_SQL($sql); if (!$q->ok) { echo $q->mysql_error . "\n{$sql}"; } $sock = new sockets(); $sock->getFrameWork("rdpproxy.php?restart-auth=yes"); }
function rules_proxies_search(){ //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(); $acl=new squid_acls(); $ID=$_GET["ID"]; $t0=$_GET["t"]; $t=$_GET["tt"]; $FORCE="aclid=$ID"; $search='%'; $table="wpad_destination"; $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 $FORCE $searchstring"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; }else{ $sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE $FORCE"; $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 $FORCE $searchstring $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; $mkey=$ligne["zmd5"]; $delete=imgsimple("delete-32.png",null,"DeleteObjectLinks$t('$mkey')"); $up=imgsimple("arrow-up-32.png",null,"MoveObjectLinks$t('$mkey','up')"); $down=imgsimple("arrow-down-32.png",null,"MoveObjectLinks$t('$mkey','down')"); $data['rows'][] = array( 'id' => "$mkey", 'cell' => array( "<span style='font-size:16px;font-weight:bold'><a href=\"javascript:blur();\" OnClick=\"javascript:MoveObjectLinksAsk$t('$mkey','{$ligne["zorder"]}')\" style='font-size:16px;font-weight:bold;text-decoration:underline' >[{$ligne["zorder"]}]</a></span>", "<span style='font-size:16px;font-weight:bold'>{$ligne["proxyserver"]}</span>", "<span style='font-size:16px;font-weight:bold'>{$ligne["proxyport"]}</span>", "<span style='font-size:16px;font-weight:bold'>$up</span>", "<span style='font-size:16px;font-weight:bold'>$down</span>", $delete) ); } echo json_encode($data); }