function rows_table() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_blackbox(); $nodeid = $_GET["nodeid"]; $search = '%'; $table = "cachelogs{$nodeid}"; $page = 1; $ORDER = "ORDER BY zDate DESC"; if (!$q->TABLE_EXISTS($table)) { writelogs("`{$table}` no such table", __FUNCTION__, __FILE__, __LINE__); } writelogs("`{$table}` " . $q->COUNT_ROWS($table) . " items", __FUNCTION__, __FILE__, __LINE__); $total = 0; if ($q->COUNT_ROWS($table) == 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"] = "*" . $_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 {$searchstring}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table); } 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) { writelogs("`{$table}` {$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__); } $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { $data['rows'][] = array('id' => $ligne[time() + 1], 'cell' => array($q->mysql_error, "", "", "")); $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", "")); echo json_encode($data); return; } //if(mysql_num_rows($results)==0){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"", "",""));} writelogs("`{$sql}` " . mysql_num_rows($results), __FUNCTION__, __FILE__, __LINE__); while ($ligne = mysql_fetch_assoc($results)) { $color = "black"; if (preg_match("#(crashing|failed|No such|FATAL|abnormally|WARNING|refused)#", $ligne["line"])) { $color = "red"; } $data['rows'][] = array('id' => $ligne['mac'], 'cell' => array("<span style='font-size:14px;color:{$color}'>{$ligne["zDate"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["line"]}</span>")); } echo json_encode($data); }
function inject_stored_items($nopid = false) { $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; if (system_is_overloaded(basename(__FILE__))) { $php = $unix->LOCATE_PHP5_BIN(); ufdbguard_admin_events("Overloaded system... ask to run this task later...", __FUNCTION__, __FILE__, __LINE__, "proxy"); $unix->THREAD_COMMAND_SET("{$php} " . __FILE__ . " --inject"); } if (!$nopid) { $pid = @file_get_contents($pidfile); $myfile = basename(__FILE__); if ($unix->process_exists($pid, $myfile)) { ufdbguard_admin_events("Task already running PID: {$pid}, aborting current task", __FUNCTION__, __FILE__, __LINE__, "proxy"); return; } } $mypid = getmypid(); @file_put_contents($pidfile, $mypid); $t1 = time(); $file = "/var/cache/purge.calculated.db"; if (!is_file($file)) { echo "{$file} no such file\n"; return; } $q = new mysql_blackbox(); if (!$q->TABLE_EXISTS("cacheitems_localhost")) { $q->build_cached_items_table("localhost"); } $BIGARRAY = inject_stored_array(); $prefix = "INSERT IGNORE INTO cacheitems_localhost(sitename,familysite,size,items) VALUES "; $q->QUERY_SQL("TRUNCATE TABLE cacheitems_localhost"); $f = array(); $c = 0; while (list($sitename, $array) = each($BIGARRAY)) { $c++; $f[] = "('{$sitename}','{$array["FAMILY"]}','{$array["SIZE"]}','{$array["ITEMS"]}')"; if (count($f) > 500) { $q->QUERY_SQL($prefix . @implode(",", $f)); if (!$q->ok) { squid_admin_mysql(0, "MySQL error!", $q->mysql_error, __FILE__, __LINE__); return; } } } if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); if (!$q->ok) { squid_admin_mysql(0, "MySQL error!", $q->mysql_error, __FILE__, __LINE__); return; } } $took = $unix->distanceOfTimeInWords($t1, time()); if ($c > 0) { squid_admin_mysql(2, "Sucess adding {$c} cached websites took:{$took}", null, __FILE__, __LINE__); } @unlink($file); }
function main_tabs() { $tpl = new templates(); $page = CurrentPageName(); $squid = new squidbee(); $sock = new sockets(); $DisableAnyCache = $sock->GET_INFO("DisableAnyCache"); if (!is_numeric($DisableAnyCache)) { $DisableAnyCache = 0; } $SquidCacheLevel = $sock->GET_INFO("SquidCacheLevel"); if (!is_numeric($SquidCacheLevel)) { $SquidCacheLevel = 4; } if ($SquidCacheLevel == 0) { $DisableAnyCache = 1; } $UseSimplifiedCachePattern = $sock->GET_INFO("UseSimplifiedCachePattern"); if (!is_numeric($UseSimplifiedCachePattern)) { $UseSimplifiedCachePattern = 1; } $realsquidversion = @file_get_contents("/etc/artica-postfix/settings/Daemons/SquidVersion"); $ID = $_GET["ID"]; $t = $_GET["t"]; $array["caches-level"] = '{cache_level}'; $array["caches-status"] = '{caches_status}'; if ($DisableAnyCache == 0) { if (preg_match("#^3\\.(4|5|6|7|8)\\.#", $realsquidversion)) { $array["rock"] = '{rock_store}'; } } $array["caches-center"] = '{caches_center}'; $array["artica-cache"] = "{enforce_rules}"; if ($UseSimplifiedCachePattern == 0) { if ($SquidCacheLevel > 2) { //$array["dyn-section"]="{dynamic_enforce_rules}"; } } if ($SquidCacheLevel > 1) { //$array["main-section"]="{cache_rules}"; } $array["parameters"] = "{global_parameters}"; if ($DisableAnyCache == 0) { $q = new mysql_blackbox(); if ($q->TABLE_EXISTS("cacheitems_localhost")) { $ct = $q->COUNT_ROWS("cacheitems_localhost"); if ($ct > 0) { $array["cached_items"] = "{$ct} {cached_items}"; } } } if (count($array) >= 4) { $fontsize = 18; } if (count($array) >= 8) { $fontsize = 14; } while (list($num, $ligne) = each($array)) { if ($num == "artica-cache") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.artica-rules.php\">\n\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "rock") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.rock.php\">\n\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "caches-level") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.level.php\">\n\t\t\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "caches-status") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.status.php\">\n\t\t\t\t\t <span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "caches") { $html[] = $tpl->_ENGINE_parse_body("<li>\n\t\t\t\t\t<a href=\"squid.caches32.php?uuid={$squid->uuid}\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "caches-params") { $html[] = $tpl->_ENGINE_parse_body("<li>\n\t\t\t\t\t<a href=\"squid.caches.php?parameters=yes\">\n\t\t\t\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "caches-center") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.center.php\" ><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "cached_items") { $html[] = $tpl->_ENGINE_parse_body("<li ><a href=\"squid.cached.itemps.php?hostid=localhost\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "dyn-section") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.cache.dynamic.rules.php\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } $html[] = $tpl->_ENGINE_parse_body("<li>\n\t\t\t\t\t<a href=\"{$page}?{$num}=yes&t={$t}&ID={$ID}&tt={$_GET["tt"]}&SourceT={$_GET["SourceT"]}\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); } echo build_artica_tabs($html, "main_cache_rules_main_tabs") . "<script>LeftDesign('caches-center-white-256-opac20.png');</script>"; }
function section_status() { $page = CurrentPageName(); $sock = new sockets(); $users = new usersMenus(); $q = new mysql_blackbox(); $tpl = new templates(); $language = $tpl->language; $array["status"] = "{services_status}"; $array["events-squidaccess"] = '{realtime_requests}'; if ($q->TABLE_EXISTS("cacheitems_localhost")) { $ct = $q->COUNT_ROWS("cacheitems_localhost"); if ($ct > 0) { $array["cached_items"] = "{$ct} {cached_items}"; } } $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance"); if (!is_numeric($EnableRemoteStatisticsAppliance)) { $EnableRemoteStatisticsAppliance = 0; } $array["remote-web-appliances"] = "{appliances}"; $fontsize = 14; if ($language == "fr") { $fontsize = "12.5"; } while (list($num, $ligne) = each($array)) { if ($num == "software-update") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.softwares.php\">\n\t\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "events-squidaccess") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.accesslogs.php?table-size=898&url-row=433\">\n\t\t\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "remote-web-appliances") { $html[] = $tpl->_ENGINE_parse_body("<li ><a href=\"squid.statsappliance.clients.php\">\n\t\t\t\t\t<span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n", null, "310", null, 1); continue; } if ($num == "cached_items") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.cached.itemps.php?hostid=localhost\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "graphs") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.graphs.php\" style='font-size:{$fontsize}px'><span>{$ligne}</span></a></li>\n"); continue; } if ($num == "events-squidcache") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.cachelogs.php\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); continue; } $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes\"><span style='font-size:{$fontsize}px'>{$ligne}</span></a></li>\n"); //$html=$html . "<li><a href=\"javascript:LoadAjax('squid_main_config','$page?main=$num&hostname={$_GET["hostname"]}')\" $class>$ligne</a></li>\n"; } echo build_artica_tabs($html, "squid_main_svc", 950) . "\n\t\t<script>QuickLinkShow('quicklinks-services_status');</script>"; }
function ORDER_DELETE() { $hostid = $_POST["hostid"]; $blk = new blackboxes($hostid); echo "DELETING ORDER {$_POST["orderid"]}\n"; writelogs("DEL ORDER \"{$_POST["orderid"]}\"", __CLASS__ . "/" . __FUNCTION__, __FILE__, __LINE__); $q = new mysql_blackbox(); if (!$q->TABLE_EXISTS("poolorders")) { $q->CheckTables(); } $sql = "DELETE FROM poolorders WHERE orderid='{$_POST["orderid"]}'"; echo "{$sql}\n"; $q->QUERY_SQL($sql); _udfbguard_admin_events("orderid {$_POST["roder_text"]} ({$_POST["orderid"]}) as been executed by remote host {$blk->hostname}", __FUNCTION__, __FILE__, __LINE__, "communicate"); if (!$q->ok) { echo $q->mysql_error . "\n"; writelogs($q->mysql_error, __CLASS__ . "/" . __FUNCTION__, __FILE__, __LINE__); } }
<?php include_once dirname(__FILE__) . '/ressources/class.templates.inc'; include_once dirname(__FILE__) . '/ressources/class.ldap.inc'; include_once dirname(__FILE__) . '/ressources/class.users.menus.inc'; include_once dirname(__FILE__) . '/ressources/class.mysql.inc'; include_once dirname(__FILE__) . '/ressources/class.os.system.inc'; include_once dirname(__FILE__) . '/ressources/class.mysql.blackboxes.inc'; include_once dirname(__FILE__) . '/framework/frame.class.inc'; include_once dirname(__FILE__) . '/framework/class.unix.inc'; if (posix_getuid() != 0) { die("Cannot be used in web server mode\n\n"); } $GLOBALS["AS_ROOT"] = true; $GLOBALS["VERBOSE"] = true; ini_set('display_errors', 1); ini_set('error_reporting', E_ALL); ini_set('error_prepend_string', null); ini_set('error_append_string', null); echo "Starting initalization....\n"; $q = new mysql_blackbox(); $q->CheckTables(); if ($q->TABLE_EXISTS("nodes")) { echo "Starting nodes......: OK\n"; } if ($q->TABLE_EXISTS("squidconf")) { echo "Starting squidconf..: OK\n"; }
function main_tabs(){ $tpl=new templates(); $page=CurrentPageName(); $squid=new squidbee(); $sock=new sockets(); $DisableAnyCache=$sock->GET_INFO("DisableAnyCache"); if(!is_numeric($DisableAnyCache)){$DisableAnyCache=0;} $CacheManagement2=$sock->GET_INFO("CacheManagement2"); if(!is_numeric($CacheManagement2)){$CacheManagement2=0;} $SquidCacheLevel=$sock->GET_INFO("SquidCacheLevel"); if(!is_numeric($SquidCacheLevel)){$SquidCacheLevel=4;} if($SquidCacheLevel==0){$DisableAnyCache=1;} $UseSimplifiedCachePattern=$sock->GET_INFO("UseSimplifiedCachePattern"); if(!is_numeric($UseSimplifiedCachePattern)){$UseSimplifiedCachePattern=1;} $ID=$_GET["ID"]; $t=$_GET["t"]; $array["caches-level"]='{cache_level}'; $array["caches-status"]='{caches_status}'; if($CacheManagement2==1){ $array["caches-center"]='{caches_center}'; } $array["artica-cache"]="{enforce_rules}"; if($UseSimplifiedCachePattern==0){ if($SquidCacheLevel>2){ $array["dyn-section"]="{dynamic_enforce_rules}"; } } if($SquidCacheLevel>1){ $array["main-section"]="{cache_rules}"; } $array["parameters"]='{global_parameters}'; if($CacheManagement2==0){ $array["caches"]='{caches}'; $array["caches-params"]='{caches_parameters}'; } if($DisableAnyCache==0){ $q=new mysql_blackbox(); if($q->TABLE_EXISTS("cacheitems_localhost")){ $ct=$q->COUNT_ROWS("cacheitems_localhost"); if($ct>0){ if($CacheManagement2==1){$array["cached_items"]="$ct {cached_items}";} } } } if(count($array)>=4){ $fontsize=18; } if(count($array)>=7){ $fontsize=14; } while (list ($num, $ligne) = each ($array) ){ if($num=="artica-cache"){ $html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.artica-rules.php\"> <span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="caches-level"){ $html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.level.php\"> <span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="caches-status"){ $html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.status.php\"> <span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="caches"){ $html[]= $tpl->_ENGINE_parse_body("<li> <a href=\"squid.caches32.php?uuid=$squid->uuid\"><span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="caches-params"){ $html[]= $tpl->_ENGINE_parse_body("<li> <a href=\"squid.caches.php?parameters=yes\"> <span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="caches-center"){ $html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.caches.center.php\" ><span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="cached_items"){ $html[]= $tpl->_ENGINE_parse_body("<li ><a href=\"squid.cached.itemps.php?hostid=localhost\"><span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } if($num=="dyn-section"){ $html[]= $tpl->_ENGINE_parse_body("<li><a href=\"squid.cache.dynamic.rules.php\"><span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); continue; } $html[]= $tpl->_ENGINE_parse_body("<li> <a href=\"$page?$num=yes&t=$t&ID=$ID&tt={$_GET["tt"]}&SourceT={$_GET["SourceT"]}\"><span style='font-size:{$fontsize}px'>$ligne</span></a></li>\n"); } echo build_artica_tabs($html, "main_cache_rules_main_tabs")."<script>LeftDesign('caches-center-white-256-opac20.png');</script>"; }