function tabs() { $tpl = new templates(); $page = CurrentPageName(); $q = new mysql_squid_builder(); $familysite = $q->GetFamilySites($_GET["sitename"]); $_GET["xtime"] = strtotime("{$_GET["day"]} 00:00:00"); if (is_numeric($_GET["xtime"])) { $dateT = " " . date("{l} {F} d", $_GET["xtime"]); if ($tpl->language == "fr") { $dateT = date("{l} d {F} ", $_GET["xtime"]); } } $tablesource = "dansguardian_events_" . date("Ymd", $_GET["xtime"]); $array["popup"] = "{status} {$dateT}"; if ($q->TABLE_EXISTS($tablesource)) { $array["uris"] = "{urls}"; } while (list($num, $ligne) = each($array)) { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes&field={$_GET["field"]}&value=" . urlencode($_GET["value"]) . "&familysite={$_GET["familysite"]}&day={$_GET["day"]}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); } echo "\n\t<div id=main_config_zoomwebsiteAndUser>\n\t\t<ul>" . implode("\n", $html) . "</ul>\n\t</div>\n\t\t<script>\n\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\$('#main_config_zoomwebsiteAndUser').tabs();\n\t\t\n\t\t\n\t\t\t});\n\t\t</script>"; }
function popup() { $tpl = new templates(); $tpl = new templates(); $q = new mysql_squid_builder(); $t = time(); $sql = "SELECT category FROM personal_categories ORDER BY category"; $results = $q->QUERY_SQL($sql); $CountDecat = mysql_num_rows($results); $array[null] = "{select}"; while ($ligne = mysql_fetch_assoc($results)) { $array[$ligne["category"]] = $ligne["category"]; } $familysite = $q->GetFamilySites($_GET["www-popup"]); $html = "<div style='font-size:26px;margin-bottom:15px'>{$_GET["www-popup"]}</div>\n\t\n\t<div style='width:98%' class=form>\n\t<table style='width:99%'>\n\t\t<tr>\n\t\t\t<td><strong style='font-size:16px'>{unblock}: {$_GET["www-popup"]}</strong></td>\n\t\t\t<td> </td>\n\t\t\t<td width=1% nowrap>" . button("Go", "Save{$t}('{$_GET["www-popup"]}')", 16) . "</td>\n\t\t</tR>\n\t"; if ($familysite != $_GET["www-popup"]) { $html = $html . "<tr><td colspan=2> </td></tr>\n\t\t<tr>\n\t\t\t<td><strong style='font-size:16px'>{or} {unblock}: {$familysite}</strong></td>\n\t\t\t<td> </td>\n\t\t\t<td width=1% nowrap>" . button("Go", "Save{$t}('{$familysite}')", 16) . "</td>\n\t\t</tR>"; } if ($CountDecat > 0) { $html = $html . "\n\t\t\t<tr>\n\t\t\t<td><strong style='font-size:16px'>{or} {move_to_category}:</strong></td>\n\t\t\t<td>" . Field_array_Hash($array, "categories-{$t}", null, "style:font-size:16px") . "</td>\n\t\t\t<td width=1% nowrap>" . button("Go", "Move{$t}('{$familysite}')", 16) . "</td>\n\t\t\t</tR>\n"; } $html = $html . "\t\n</table>\t\t\n</div>\n<script>\nfunction xSave{$t}(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);}\n\tYahooWinBrowseHide();\n\tLoadjs('squid.compile.whiteblack.progress.php?ask=yes');\n\t\n}\t\t\t\n\t\t\t\nfunction Save{$t}(www){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('whitelist-single',www);\n\tXHR.sendAndLoad('squid.urlrewriteaccessdeny.php', 'POST',xSave{$t});\t\n}\nfunction xMove{$t}(obj){\n\tvar tempvalue=obj.responseText;\n\tif(tempvalue.length>3){alert(tempvalue);}\n\tvar category=document.getElementById('categories-{$t}').value;\n\tYahooWinBrowseHide();\n\tLoadjs('ufdbguard.compile.category.php?category='+category);\n\t\n}\t\n\nfunction Move{$t}(www){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('textToParseCats',www);\n\tXHR.appendData('category',document.getElementById('categories-{$t}').value);\n\tXHR.appendData('ForceCat',1);\n\tXHR.appendData('ForceExt',1);\n\tXHR.sendAndLoad('squid.visited.php', 'POST',xMove{$t});\t\n}\n\n\n\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function visited_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $family = $q->GetFamilySites($_GET["www"]); $search = '%'; $table = "visited_sites"; $page = 1; $COUNT_ROWS = $q->COUNT_ROWS($table); $FORCE_FILTER = "familysite='{$family}'"; if ($COUNT_ROWS == 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']; } $_POST["query"] = trim($_POST["query"]); 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 {$FORCE_FILTER} {$searchstring}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup")); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE {$FORCE_FILTER}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $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 {$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 (mysql_num_rows($results) == 0) { $data['rows'][] = array('id' => $ligne[time()], 'cell' => array($sql, "", "", "")); } while ($ligne = mysql_fetch_assoc($results)) { $categories = $q->GET_CATEGORIES($ligne['sitename']); $FamilySite = $q->GetFamilySites($ligne['sitename']); $categorize = imgtootltip("add-database-32.png", $ligne['sitename'], "javascript:Loadjs('squid.categorize.php?www={$ligne['sitename']}&day={$_GET["day"]}&week={$_GET["week"]}&month={$_GET["month"]}');"); $thumbs = $q->GET_THUMBNAIL($ligne['sitename'], 48); $ahref = "Loadjs('squid.traffic.statistics.days.php?today-zoom=yes&type=req&familysite={$FamilySite}&day={$_GET["day"]}')"; $data['rows'][] = array('id' => $ligne['sitename'], 'cell' => array($thumbs, "<div style='margin-top:10px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$ahref}\" style='font-size:14px;text-decoration:underline'>{$ligne['sitename']}</a></div>", "<div style='font-size:14px;margin-top:10px'>{$categories}</span>", $categorize)); } echo json_encode($data); }
function parseTemplate_unlock($error = null) { include_once dirname(__FILE__) . "/ressources/class.sockets.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; $sock = new sockets(); $ARRAY = unserialize(base64_decode($_REQUEST["serialize"])); $sock->BuildTemplatesConfig($ARRAY); $SquidGuardIPWeb = null; $url = $_REQUEST["url"]; $IPADDR = $_REQUEST["ipaddr"]; if (isset($_GET["SquidGuardIPWeb"])) { $SquidGuardIPWeb = $_GET["SquidGuardIPWeb"]; } if ($SquidGuardIPWeb == null) { $SquidGuardIPWeb = CurrentPageName(); } if ($GLOBALS["VERBOSE"]) { echo "<H1>SquidGuardIPWeb={$SquidGuardIPWeb}</H1>"; } $UfdbGuardHTTPAllowNoCreds = intval($sock->GET_INFO("UfdbGuardHTTPAllowNoCreds")); $q = new mysql_squid_builder(); $parse_url = parse_url($url); $host = $parse_url["host"]; if (preg_match("#(.+?):[0-9]+#", $host, $re)) { $host = $re[1]; } $FinalHost = $q->GetFamilySites($host); if (!isset($GLOBALS["UfdbGuardHTTP"]["FOOTER"])) { $GLOBALS["UfdbGuardHTTP"]["FOOTER"] = null; } $FOOTER = $GLOBALS["UfdbGuardHTTP"]["FOOTER"]; $MAX = $GLOBALS["UfdbGuardHTTP"]["UnbblockMaxTime"]; $Timez[5] = "5 {minutes}"; $Timez[10] = "10 {minutes}"; $Timez[15] = "15 {minutes}"; $Timez[30] = "30 {minutes}"; $Timez[60] = "1 {hour}"; $Timez[120] = "2 {hours}"; $Timez[240] = "4 {hours}"; $Timez[720] = "12 {hours}"; $Timez[2880] = "2 {days}"; $TEXT_TIME = $Timez[$MAX]; $UnbblockText2 = $GLOBALS["UfdbGuardHTTP"]["UnbblockText2"]; $page = CurrentPageName(); $UnbblockText2 = str_replace("%WEBSITE%", $url, $UnbblockText2); $UnbblockText2 = str_replace("%TIME%", $TEXT_TIME, $UnbblockText2); $fontfamily = "font-family: {$GLOBALS["UfdbGuardHTTP"]["Family"]};"; $fontfamily = str_replace('"', "", $fontfamily); $wifidog_build_uri = wifidog_build_uri(); $uriext = $wifidog_build_uri[0]; $HiddenFields = $wifidog_build_uri[1]; $client_username = $ARRAY["clientname"]; if ($client_username != null) { $_REQUEST["clientname"] = $client_username; } if ($q->COUNT_ROWS("ufdb_page_rules") > 0) { include_once dirname(__FILE__) . "/ressources/class.ufdb.parsetemplate.inc"; $unlock = new parse_template_ufdb(); $noauth = $unlock->parseTemplate_unlock_privs($ARRAY, $pattern = "noauth=1", 0, true); $UfdbGuardHTTPAllowNoCreds = $noauth; } $UFDBGUARD_UNLOCK_LINK = $GLOBALS["UfdbGuardHTTP"]["UFDBGUARD_UNLOCK_LINK"]; $unlock_web_site_text = "{unlock_web_site}"; if ($UFDBGUARD_UNLOCK_LINK != null) { $unlock_web_site_text = $UFDBGUARD_UNLOCK_LINK; } if ($noauth == 1) { $f[] = parseTemplate_headers("{$unlock_web_site_text}", null, $SquidGuardIPWeb); $f[] = $f[] = "<form id='unlockform' action=\"{$SquidGuardIPWeb}\" method=\"post\">\n\t\t<input type='hidden' id='unlock-www' name='unlock-www' value='yes'>\n\t\t<input type='hidden' id='finalhost' name='finalhost' value='{$FinalHost}'>\n\t\t<input type='hidden' id='ipaddr' name='ipaddr' value='{$IPADDR}'>\n\t\t<input type='hidden' id='SquidGuardIPWeb' name='SquidGuardIPWeb' value='{$SquidGuardIPWeb}'>\n\t\t<input type='hidden' id='serialize' name='serialize' value='{$_REQUEST["serialize"]}'>\n\t\t<input type='hidden' id='url' name='url' value='{$url}'>"; $f[] = "<input type='hidden' id='username' name='username' value='{$_REQUEST["clientname"]}'>"; $f[] = "<input type='hidden' id='nocreds' name='nocreds' value='1'>"; $f[] = "<script>\t"; $f[] = "function CheckTheForm(){\t"; $f[] = "document.forms['unlockform'].submit();"; $f[] = "}\t"; $f[] = "CheckTheForm();"; $f[] = "</script>\t"; $f[] = "</body>"; $f[] = "</html>"; echo @implode("\n", $f); return; } $UFDBGUARD_UNLOCK_LINK = $GLOBALS["UfdbGuardHTTP"]["UFDBGUARD_UNLOCK_LINK"]; $unlock_web_site_text = "{unlock_web_site}"; if ($UFDBGUARD_UNLOCK_LINK != null) { $unlock_web_site_text = $UFDBGUARD_UNLOCK_LINK; } $f[] = parseTemplate_headers($unlock_web_site_text, null, $SquidGuardIPWeb); $f[] = " <h2>{$unlock_web_site_text} {$FinalHost} {for} {$IPADDR} {$_REQUEST["clientname"]}</h2>"; if ($error != null) { $f[] = " <h2>{$error}</h2>"; } $f[] = " <div id=\"info\">"; $f[] = "<p style='margin-bottom:30px'>{$UnbblockText2}</p>"; $f[] = "<form id='unlockform' action=\"{$SquidGuardIPWeb}\" method=\"post\">\n\t<input type='hidden' id='unlock-www' name='unlock-www' value='yes'>\n\t<input type='hidden' id='finalhost' name='finalhost' value='{$FinalHost}'>\n\t<input type='hidden' id='ipaddr' name='ipaddr' value='{$IPADDR}'>\n\t<input type='hidden' id='serialize' name='serialize' value='{$_REQUEST["serialize"]}'>\n\t<input type='hidden' id='url' name='url' value='{$url}'>"; $f[] = "<input type='hidden' id='username' name='username' value='{$_REQUEST["clientname"]}'>"; if ($UfdbGuardHTTPAllowNoCreds == 1) { $f[] = "<input type='hidden' id='username' name='username' value='{$_REQUEST["clientname"]}'>"; $f[] = "<input type='hidden' id='password' name='password' value='{$_REQUEST["password"]}'>"; } $f[] = "<table width='100%;'>"; if ($UfdbGuardHTTPAllowNoCreds == 0) { $f[] = " <tr>\n\t\t\t\t<td class=\"info_title\">{username}:</td>\n\t\t\t\t<td class=\"info_content\">" . Field_text("username", $_REQUEST["username"], "{$fontfamily};width:80%;font-size:35px;padding:5px") . "</td>\n\t\t\t</tr> \n\t\t\t<tr>\n\t\t\t\t<td class=\"info_title\">{password}:</td>\n\t\t\t\t<td class=\"info_content\">" . Field_password("nolock:password", $_REQUEST["password"], "{$fontfamily};width:80%;font-size:35px;padding:5px", null, null, null, false, "CheckTheForm(event)") . "</td>\n\t\t\t</tr>"; } $f[] = " <tr><td colspan=2 align='right'><hr>" . button("{submit}", "document.forms['unlockform'].submit();") . "</td></tr>\n\t</table>\n\t</form>\n\t<script>\n\tfunction CheckTheForm(e){\n\t\tif(!checkEnter(e)){return;}\n\t\tdocument.forms['unlockform'].submit();\n\t\t}\n\t\t\t\n\t</script>\t\t\n\t"; $f[] = " </div> {$FOOTER}"; $f[] = "</div>"; $f[] = "</body>"; $f[] = "</html>"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body(@implode("\n", $f)); }
function WordScanners() { if (isset($GLOBALS["WordScanners_executed"])) { return; } $GLOBALS["WordScanners_executed"] = true; $workdir = "/var/log/artica-postfix/searchwords"; @mkdir($workdir, 0755, true); if ($GLOBALS["VERBOSE"]) { echo "Open {$workdir}\n"; } $handle = opendir($workdir); if (!$handle) { if ($GLOBALS["VERBOSE"]) { echo "Fatal unable to opendir {$workdir}\n"; } events("Fatal unable to opendir {$workdir}", __FUNCTION__, __FILE__, __LINE__); return; } if ($GLOBALS["VERBOSE"]) { events("WordScanners(" . __LINE__ . "):Open {$workdir} done.. instanciate mysql_squid_builder()"); } $q = new mysql_squid_builder(); if ($GLOBALS["VERBOSE"]) { events("WordScanners(" . __LINE__ . "):Start looping()"); } $FF = array(); while (false !== ($filename = readdir($handle))) { if ($filename == ".") { continue; } if ($filename == "..") { continue; } $targetFile = "{$workdir}/{$filename}"; if ($GLOBALS["VERBOSE"]) { echo "Scanning {$targetFile}\n"; } $searchWords = unserialize(@file_get_contents($targetFile)); while (list($key, $val) = each($searchWords)) { $searchWords[$key] = addslashes(str_replace("'", "`", $val)); } $zmd5 = md5(serialize($searchWords)); $ipaddr = $searchWords["ipaddr"]; $date = $searchWords["date"]; $Time = strtotime($date); $uid = $searchWords["uid"]; if (strlen($uid) < 3) { $uid = null; } $mac = trim($searchWords["mac"]); if ($mac == null) { $mac = GetMacFromIP($ipaddr); } $hostname = $searchWords["hostname"]; $words = $searchWords["WORDS"]; if (trim($words) == null) { @unlink($targetFile); continue; } $sitename = $searchWords["SITENAME"]; $sitename = addslashes($sitename); if (!isset($GLOBALS["familysite"][$sitename])) { $GLOBALS["familysite"][$sitename] = $q->GetFamilySites($sitename); } $familysite = $GLOBALS["familysite"][$sitename]; if ($mac != null) { if ($uid == null) { $uid = $q->UID_FROM_MAC($mac); } } if ($ipaddr != null) { if ($uid == null) { $uid = $q->UID_FROM_IP($ipaddr); } } $FF[date("Ymdh", $Time)][] = "('{$zmd5}','{$sitename}','{$date}','{$ipaddr}','{$hostname}','{$uid}','{$mac}','0','{$familysite}','{$words}')"; @unlink($targetFile); } events("WordScanners(" . __LINE__ . "): End looping...\n"); $q = new mysql_squid_builder(); while (list($tablePrefix, $f) = each($FF)) { if (count($f) > 0) { if ($q->check_SearchWords_hour($tablePrefix)) { $tablename = "searchwords_{$tablePrefix}"; $prefix = "INSERT IGNORE INTO {$tablename} (`zmd5`,`sitename`,`zDate`,`ipaddr`,`hostname`,`uid`,`MAC`,`account`,`familysite`,`words`) VALUES " . @implode(",", $f); $q->QUERY_SQL($prefix); if (!$q->ok) { writelogs_squid("{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "stats"); @mkdir("/var/log/artica-postfix/searchwords-sql-errors", 0755, true); @file_put_contents("/var/log/artica-postfix/searchwords-sql-errors/" . md5($prefix), $prefix); } } } } }
function thumbnail($zmd5 = null) { $sitename = $_GET["thumbnail"]; $width = $_GET["width"]; $q = new mysql_squid_builder(); $familySite = $q->GetFamilySites($sitename); $md = md5($sitename); $md_family = md5($familySite); if ($zmd5 != null) { $md = $zmd5; } if (isset($_GET["zmd5"])) { $md = $_GET["zmd5"]; } if (!is_numeric($width)) { $width = 400; } $imagepath = "ressources/logs/thumbnails.{$md}.{$width}.gif"; $imageSourcePath = "ressources/logs/thumbnails.{$md}.400.gif"; if ($GLOBALS["VERBOSE"]) { echo "<H1>VERBOSES {$sitename}/{$familySite} - {$md} -</H1>"; if (is_file($imageSourcePath)) { echo "<li>{$md} {$imageSourcePath} exists on disk</li>"; echo "<li>{$imageSourcePath} file_md5=" . md5_file($imageSourcePath) . "</li>"; } } $badThumbs["ee1e683b39c902e5ee69fadcff54b6b9"] = true; $badThumbs["45ec39db5951e8e11be11f5148bd707a"] = true; if (is_file($imageSourcePath)) { $md5_file = md5_file($imageSourcePath); } if ($badThumbs[$md5_file]) { if ($GLOBALS["VERBOSE"]) { echo "<li style=color:#d32d2d>Deleting {$md}</li>"; } @unlink($imageSourcePath); @unlink($imagepath); $q->QUERY_SQL("DELETE FROM webfilters_thumbnails WHERE zmd5='{$md}'"); $q->QUERY_SQL("DELETE FROM webfilters_thumbnails WHERE LinkTo='{$md}'"); } if (is_file($imagepath)) { if (!$GLOBALS["VERBOSE"]) { header("Content-type: image/gif"); ob_clean(); flush(); readfile($imagepath); } return; } else { if ($GLOBALS["VERBOSE"]) { echo "<li>{$imagepath} no such file</li>"; } } if (!is_file($imageSourcePath)) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT savedate,filemd5,picture,LinkTo FROM webfilters_thumbnails WHERE zmd5='{$md}'")); if ($GLOBALS["VERBOSE"]) { echo "<li>{$md} LinkTo={$ligne["LinkTo"]} - " . strlen($ligne["picture"]) . " bytes</li>"; } if (trim($ligne["LinkTo"]) != null) { thumbnail($ligne["LinkTo"]); return; } if ($ligne["picture"] == null) { if ($md_family != $md) { thumbnail($md_family); return; } } if ($ligne["picture"] != null) { @file_put_contents($imageSourcePath, $ligne["picture"]); } } else { if ($GLOBALS["VERBOSE"]) { echo "<li>{$md} {$imageSourcePath} exists on disk</li>"; } if ($GLOBALS["VERBOSE"]) { echo "<li>{$imageSourcePath} file_md5=" . md5_file($imageSourcePath) . "</li>"; } } if (is_file($imageSourcePath)) { if ($width < 400) { if ($GLOBALS["VERBOSE"]) { echo "<li>{$md} ->SimpleImage({$imageSourcePath})</li>"; } $image = new SimpleImage(); $image->load($imageSourcePath); if ($GLOBALS["VERBOSE"]) { echo "<li>{$md} ->resize({$width},{$width})</li>"; } $image->resize($width, $width); $image->save($imagepath); if (!$GLOBALS["VERBOSE"]) { header("Content-type: image/gif"); ob_clean(); flush(); readfile($imagepath); } return; } if (!$GLOBALS["VERBOSE"]) { header("Content-type: image/gif"); ob_clean(); flush(); readfile($imageSourcePath); } return; } if (!is_file($imageSourcePath)) { if ($width < 400) { if (!is_file("img/bgheader-{$width}-thumbs-400.gif")) { $image = new SimpleImage(); $image->load("img/bgheader--thumbs-400.gif"); $image->resize($width, $width); $image->save("img/bgheader-{$width}-thumbs-400.gif"); } header("Content-type: image/gif"); ob_clean(); flush(); readfile("img/bgheader-{$width}-thumbs-400.gif"); return; } header("Content-type: image/gif"); ob_clean(); flush(); readfile("img/bgheader--thumbs-400.gif"); return; } }
$c++; $pattern = trim(fgets($handle, 4096)); if ($pattern == null) { continue; } if (strpos($pattern, "NONE/400") > 0) { continue; } if (!preg_match("#^([0-9\\.]+)\\s+([0-9]+)\\s+([0-9\\.]+)\\s+([A-Z\\/0-9_]+)\\s+([0-9]+)\\s+([A-Z]+)\\s+(.*?)\\s+(.*?)\\s+([A-Z]+)#", $pattern, $re)) { echo "*** `{$pattern}` ****\n"; continue; } $time = $re[1]; $xdate = date("Y-m-d H:i:s", $time); $times = $re[2]; $ipaddr = $re[3]; $Code = $re[4]; $Size = $re[5]; $PROTO = $re[6]; $URI = $re[7]; $user = trim(strtolower($re[8])); if ($user_req != $user) { continue; } $arrayURI = parse_url($URI); $hostname = $arrayURI["host"]; $familysite = $q->GetFamilySites($hostname); @fwrite($d, "\"{$xdate}\";\"{$URI}\",\"{$familysite}\",\"{$Size}\",\"{$user}\"\n"); } @fclose($d); @fclose($handle);
function ParseSubDir($dir) { $unix = new unix(); $q = new mysql_squid_builder(); $countDefile = $unix->COUNT_FILES($dir); events("{$dir} -> {$countDefile} files on Line: ", __LINE__); if ($countDefile == 0) { events("ParseSubDir():: {$dir}: no files... remove... ", __LINE__); @rmdir($dir); return; } $FINAL = array(); if (!($handle = opendir($dir))) { events("ParseSubDir():: Fatal: {$dir} no such directory", __LINE__); return; } $DUSTBIN["mx.yahoo.com"] = true; $DUSTBIN["row.bc.yahoo.com"] = true; $DUSTBIN["us.bc.yahoo.com"] = true; $DUSTBIN["xiti.com"] = true; $c = 0; while (false !== ($filename = readdir($handle))) { if ($filename == ".") { continue; } if ($filename == "..") { continue; } $targetFile = "{$dir}/{$filename}"; $arrayFile = unserialize(@file_get_contents($targetFile)); if (!is_array($arrayFile)) { @unlink($targetFile); continue; } if ($GLOBALS["VERBOSE"]) { echo "{$targetFile}\n"; } while (list($index, $array) = each($arrayFile)) { $words = mysql_escape_string2(trim($array["WORDS"])); if ($words == null) { continue; } $sitename = $array["SITENAME"]; $familysite = $q->GetFamilySites($sitename); if (isset($DUSTBIN[$sitename])) { continue; } if (isset($DUSTBIN[$familysite])) { continue; } $ipaddr = $array["ipaddr"]; $zDate = $array["date"]; $uid = mysql_escape_string2($array["uid"]); $MAC = mysql_escape_string2($array["mac"]); $hostname = mysql_escape_string2($array["hostname"]); $time = strtotime($zDate); $prefix = date("YmdH", $time); $zmd5 = md5(serialize($array)); $account = 0; $line = "('{$zmd5}','{$sitename}','{$zDate}','{$ipaddr}','{$hostname}','{$uid}','{$MAC}','{$account}','{$familysite}','{$words}')"; if ($GLOBALS["VERBOSE"]) { echo "{$prefix} -> {$line}\n"; } $f[$prefix][] = $line; } @unlink($targetFile); } if (count($f) > 0) { inject_array($f); } }
function today_zoom_popup_history_list(){ $Mypage=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $t=time(); $fontsize=13; $type=$_GET["type"]; $field_query="size"; $field_query2="SUM(size)"; $table_field="{size}"; $category=$tpl->_ENGINE_parse_body("{category}"); if($_GET["day"]==date('Y-m-d')){$_GET["day"]=$q->HIER();} $hour_table=date('Ymd',strtotime($_GET["day"]))."_hour"; $member=$tpl->_ENGINE_parse_body("{member}"); $sitename=$tpl->_ENGINE_parse_body("{website}"); if (isset($_POST['rp'])) {$rp = $_POST['rp'];} if(isset($_POST["sortname"])){if($_POST["sortname"]<>null){$ORDER="ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";}} if (isset($_POST['page'])) {$page = $_POST['page'];} $pageStart = ($page-1)*$rp; $limitSql = "LIMIT $pageStart, $rp"; if($type=="req"){ $field_query="hits"; $field_query2="SUM(hits)"; $table_field="{hits}"; } $table="(SELECT $field_query2 as thits, uid,client,MAC,sitename,category,familysite FROM $hour_table GROUP BY uid,client,sitename,MAC,category,familysite HAVING familysite='{$_GET["familysite"]}' ) as t"; $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"]; }else{ $sql="SELECT COUNT(*) as TCOUNT FROM $table WHERE 1"; $ligne=mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]+1; } $sql="SELECT * FROM $table WHERE 1 $searchstring $ORDER $limitSql"; $results=$q->QUERY_SQL($sql); $data = array(); $data['page'] = 0; $data['total'] = $total; $data['rows'] = array(); if(!$q->ok){json_error_show($q->mysql_error);}; if(mysql_num_rows($results)==0){json_error_show("No data");} $data['total'] = mysql_num_rows($results); $style="style='font-size:{$fontsize}px'"; while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ if($type<>"req"){$ligne["thits"]=FormatBytes($ligne["thits"]/1024);} $categorize="Loadjs('squid.categorize.php?www={$ligne["sitename"]}')"; if(trim($ligne["category"])==null){$ligne["category"]="<span style='color:#D70707'>{categorize_this_website}</span>";} $id=md5(@implode("", $ligne)); if(trim($ligne["uid"])=="-"){$ligne["uid"]=null;} if(trim($ligne["uid"])==null){$ligne["uid"]=$q->UID_FROM_MAC($ligne["MAC"]);} $categorize="<a href=\"javascript:blur()\" OnClick=\"javascript:$categorize\" style='font-size:{$fontsize}px;text-decoration:underline'>"; $familysite=$q->GetFamilySites($ligne["sitename"]); $TrafficHour="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?familysite={$ligne["sitename"]}&day={$_GET["day"]}')\" style='font-size:{$fontsize}px;text-decoration:underline'>"; $data['rows'][] = array( 'id' => $id, 'cell' => array( "<span $style>{$ligne["uid"]}</span>", "<span $style>{$ligne["MAC"]}</span>", "<span $style>{$ligne["client"]}</span>", "<span $style>$TrafficHour{$ligne["sitename"]}</a></span>", "<span $style>{$ligne["thits"]}</span>", "<span $style>$categorize{$ligne["category"]}</a></span>" ) ); } echo json_encode($data); }
function proxypac() { include_once 'ressources/class.proxypac.inc'; include_once 'ressources/class.templates.inc'; include_once 'ressources/class.ldap.inc'; include_once 'ressources/class.user.inc'; include_once 'ressources/class.langages.inc'; include_once 'ressources/class.sockets.inc'; include_once 'ressources/class.mysql.inc'; include_once 'ressources/class.privileges.inc'; include_once 'ressources/class.squid.inc'; $hostname = $_SERVER["REMOTE_ADDR"]; $md5 = $_GET["proxypac"]; $sql = "SELECT userid,email,ProxyPacCompiled,ProxyPacDatas FROM usersisp WHERE zmd5='{$md5}' AND enabled=0"; error_log("[{$_SESSION["uid"]}]::{$hostname}: {$ligne["email"]}" . __FUNCTION__ . " file " . basename(__FILE__) . " line " . __LINE__); $q = new mysql_squid_builder(); $ligne = @mysql_fetch_array($q->QUERY_SQL($sql)); $sock = new sockets(); $Array = unserialize(base64_decode($ligne["ProxyPacDatas"])); if ($ligne["ProxyPacCompiled"] == null) { $defaultDomain = $q->GetFamilySites($_SERVER["SERVER_NAME"]); $Array["localHostOrDomainIs"][] = "dnsDomainIs:{$defaultDomain}"; if (!is_array($Array["PROXYS"])) { $Array["PROXYS"] = array(); } $squid = new squidbee(); $SquidISPProxyServerAddress = $sock->GET_INFO("SquidISPProxyServerAddress"); if ($SquidISPProxyServerAddress == null) { $SquidISPProxyServerAddress = $sock->GET_INFO("SquidBinIpaddr"); } $SquidISPProxyServerAddress = $SquidISPProxyServerAddress . ":" . $squid->listen_port; array_unshift($Array["PROXYS"], $SquidISPProxyServerAddress); $ppac = new proxypacrules($Array); $ppacFinal = $ppac->ProxyPacFinal; $sql = "UPDATE usersisp SET ProxyPacCompiled='" . addslashes($ppacFinal) . "' WHERE zmd5='{$md5}'"; $q = new mysql_squid_builder(); $q->QUERY_SQL($sql); } else { $ppacFinal = $ligne["ProxyPacCompiled"]; } header("Content-type: application/x-ns-proxy-autoconfig"); header('Content-Disposition: attachment; filename="proxy.pac"'); header("Date: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time())); header("Last-Modified: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time())); header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 60 * 30)); echo $ppacFinal; }
function graphs() { include_once 'ressources/class.artica.graphs.inc'; $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); $t = $_GET["t"]; $ff = time(); $graph1 = null; $graph2 = null; $day = $_GET["day"]; $ttime = strtotime("{$day} 00:00:00"); $table = date("Ymd", $ttime) . "_hour"; $familysite = $_GET["familysite"]; if ($familysite != null) { $familysite2 = $q->GetFamilySites($familysite); } $F = array(); if ($_GET["filterby"] != null) { $OP = "="; $field_site0 = "`{$_GET["filterby"]}`,"; if ($_GET["filterby"] == "ipaddr") { $_GET["filterby"] = "client"; $field_site0 = "`client`,"; } $titleadd = " »{$_GET["filterby"]} »{$_GET["filterdata"]} »"; if (strpos(" {$_GET["filterdata"]}", "*") > 0) { $OP = " LIKE "; $_GET["filterdata"] = str_replace("*", "%", $_GET["filterdata"]); } $display = null; $F[] = "AND {$_GET["filterby"]}{$OP}'{$_GET["filterdata"]}'"; } if ($familysite != null) { if ($familysite2 == $familysite) { $field_site = "familysite,"; $F[] = "AND familysite ='{$familysite}'"; } else { $field_site = "sitename,"; $F[] = "AND sitename ='{$familysite}'"; } } if (count($F) > 0) { $HAVING = "HAVING thits>0 " . @implode(" ", $F); } $sql = "SELECT SUM(hits) as thits, {$field_site}{$field_site0} `hour` FROM `{$table}` GROUP BY {$field_site}{$field_site0},`hour` {$HAVING} ORDER BY `hour`"; $sql = str_replace(", ,", ",", $sql); $sql = str_replace(",,", ",", $sql); $unknown = $tpl->_ENGINE_parse_body("{unknown}"); $c = 0; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } if (mysql_num_rows($results) > 1) { while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ydata[] = $ligne["thits"]; $xdata[] = $ligne["hour"]; $c++; } $t = time(); $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".{$sql}.1{$tablename}") . ".png"; $gp = new artica_graphs(); $gp->width = 900; $gp->height = 350; $gp->filename = "{$targetedfile}"; $gp->xdata = $xdata; $gp->ydata = $ydata; $gp->y_title = null; $gp->x_title = $tpl->_ENGINE_parse_body("{hits}/{hours}"); $gp->title = null; $gp->margin0 = true; $gp->Fillcolor = "blue@0.9"; $gp->color = "146497"; $gp->line_green(); if (is_file("{$targetedfile}")) { $graph1 = "\n\t\t\t\t<center style='font-size:18px;margin:10px'>{$gp->x_title}</center>\n\t\t\t\t<img src='{$targetedfile}'>"; } else { $graph1 = "{$targetedfile} no such file<hr>{$sql}<hr>"; } } else { $graph1 = $tpl->_ENGINE_parse_body("{only_one_value_no_graph}<hr><span style='font-size:11px'>{$sql}</span>"); } $xdata = array(); $ydata = array(); $sql = "SELECT SUM(size) as thits, {$field_site}{$field_site0} `hour` FROM `{$table}` GROUP BY {$field_site}{$field_site0},`hour` {$HAVING} ORDER BY `hour`"; $sql = str_replace(", ,", ",", $sql); $sql = str_replace(",,", ",", $sql); $unknown = $tpl->_ENGINE_parse_body("{unknown}"); $c = 0; $results = $q->QUERY_SQL($sql); if (!$q->ok) { echo "<H2>{$q->mysql_error}</H2><center style='font-size:11px'><code>{$sql}</code></center>"; } if (mysql_num_rows($results) > 1) { while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ydata[] = $ligne["thits"]; $xdata[] = $ligne["hour"]; $c++; } $t = time(); $targetedfile = "ressources/logs/" . md5(basename(__FILE__) . "." . __FUNCTION__ . ".{$sql}.2{$tablename}") . ".png"; $gp = new artica_graphs(); $gp->width = 900; $gp->height = 350; $gp->filename = "{$targetedfile}"; $gp->xdata = $xdata; $gp->ydata = $ydata; $gp->y_title = null; $gp->x_title = $tpl->_ENGINE_parse_body("{size}/{hours}"); $gp->title = null; $gp->margin0 = true; $gp->Fillcolor = "blue@0.9"; $gp->color = "146497"; $gp->line_green(); if (is_file("{$targetedfile}")) { $graph2 = "\n\t\t<center style='font-size:18px;margin:10px'>{$gp->x_title}</center>\n\t\t<img src='{$targetedfile}'>"; } } else { $graph2 = $tpl->_ENGINE_parse_body("{only_one_value_no_graph}<hr><span style='font-size:11px'>{$sql}</span>"); } $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td width=50% style='font-size:16px'>{$graph1}</td>\n\t</tr>\n\t<tr>\n\t\t<td width=50% style='font-size:16px'>{$graph2}</td>\n\t</tr>\n\t</table>"; echo $html; }
function parseTemplate_ticket($error = null) { include_once dirname(__FILE__) . "/ressources/class.sockets.inc"; include_once dirname(__FILE__) . "/ressources/class.mysql.squid.builder.php"; include_once dirname(__FILE__) . "/ressources/class.tcpip.inc"; $sock = new sockets(); $ARRAY = unserialize(base64_decode($_REQUEST["serialize"])); $sock->BuildTemplatesConfig($ARRAY); $SquidGuardIPWeb = null; $url = $_REQUEST["url"]; $IPADDR = $_REQUEST["ipaddr"]; if (isset($_GET["SquidGuardIPWeb"])) { $SquidGuardIPWeb = $_GET["SquidGuardIPWeb"]; } if ($SquidGuardIPWeb == null) { $SquidGuardIPWeb = CurrentPageName(); } if ($GLOBALS["VERBOSE"]) { echo "<H1>SquidGuardIPWeb={$SquidGuardIPWeb}</H1>"; } $UfdbGuardHTTPAllowNoCreds = intval($sock->GET_INFO("UfdbGuardHTTPAllowNoCreds")); $q = new mysql_squid_builder(); $parse_url = parse_url($url); $host = $parse_url["host"]; if (preg_match("#(.+?):[0-9]+#", $host, $re)) { $host = $re[1]; } $FinalHost = $q->GetFamilySites($host); if (!isset($GLOBALS["UfdbGuardHTTP"]["FOOTER"])) { $GLOBALS["UfdbGuardHTTP"]["FOOTER"] = null; } $FOOTER = $GLOBALS["UfdbGuardHTTP"]["FOOTER"]; $ticket_web_site_text = "{submit_a_ticket}"; $UFDBGUARD_TICKET_LINK = $GLOBALS["UfdbGuardHTTP"]["UFDBGUARD_UNLOCK_LINK"]; if ($UFDBGUARD_TICKET_LINK != null) { $ticket_web_site_text = $UFDBGUARD_TICKET_LINK; } $f[] = parseTemplate_headers("{$UFDBGUARD_TICKET_LINK}", null, $SquidGuardIPWeb); $f[] = $f[] = "<form id='unlockform' action=\"{$SquidGuardIPWeb}\" method=\"post\">\n\t<input type='hidden' id='unlock-ticket' name='unlock-ticket' value='yes'>\n\t<input type='hidden' id='finalhost' name='finalhost' value='{$FinalHost}'>\n\t<input type='hidden' id='ipaddr' name='ipaddr' value='{$IPADDR}'>\n\t<input type='hidden' id='SquidGuardIPWeb' name='SquidGuardIPWeb' value='{$SquidGuardIPWeb}'>\n\t<input type='hidden' id='serialize' name='serialize' value='{$_REQUEST["serialize"]}'>\n\t<input type='hidden' id='url' name='url' value='{$url}'>"; $f[] = "<input type='hidden' id='username' name='username' value='{$_REQUEST["clientname"]}'>"; $f[] = "<script>\t"; $f[] = "function CheckTheForm(){\t"; $f[] = "document.forms['unlockform'].submit();"; $f[] = "}\t"; $f[] = "CheckTheForm();"; $f[] = "</script>\t"; $f[] = "</body>"; $f[] = "</html>"; echo @implode("\n", $f); }
function _repair_from_sources_tables($sourcetable, $daytable) { percentage("Repair {$daytable} FROM {$sourcetable}", 2); //zMD5 | sitename | familysite | client | hostname | account | hour | remote_ip | MAC | country | size | hits | uid | category | cached $f = array(); $sql = "SELECT HOUR(zDate) as `hour`,SUM(QuerySize) as size, SUM(hits) as hits, \n\tsitename,uid,CLIENT,hostname,MAC,account,cached FROM {$sourcetable} \n\tGROUP BY `hour`,sitename,uid,CLIENT,hostname,MAC,account,cached"; $prefix = "INSERT IGNORE INTO {$daytable} \n\t(`zMD5`,`sitename`,`familysite`,`client`,`hostname`,`uid`,`account`,`hour`,`MAC`,`size`,`hits`) VALUES"; $q = new mysql_squid_builder(); $results = $q->QUERY_SQL($sql); while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $zMD5 = md5(serialize($ligne)); $familysite = $q->GetFamilySites($ligne["sitename"]); while (list($key, $val) = each($ligne)) { $ligne[$key] = mysql_escape_string2($val); } $f[] = "('{$zMD5}','{$ligne["sitename"]}','{$familysite}','{$ligne["CLIENT"]}','{$ligne["hostname"]}','{$ligne["uid"]}','{$ligne["account"]}','{$ligne["hour"]}','{$ligne["MAC"]}','{$ligne["size"]}','{$ligne["hits"]}')"; if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); } } if (count($f) > 0) { $q->QUERY_SQL($prefix . @implode(",", $f)); $f = array(); } $sql = "SELECT COUNT(`sitename`) as tcount FROM {$daytable} WHERE LENGTH(`category`)=0"; if ($GLOBALS["VERBOSE"]) { echo $sql . "\n"; } $ligne2 = mysql_fetch_array($q->QUERY_SQL($sql)); $max = $ligne2["tcount"]; $sql = "UPDATE tables_day SET `not_categorized`={$max} WHERE tablename='{$sourcetable}'"; $q->QUERY_SQL($sql); }
function elephantlist_Redirected($data) { $CACHE = unserialize(@file_get_contents("/root/p**n-cache.db")); $q = new mysql_squid_builder(); if (preg_match_all("#elephantlist\\.com\\/tp\\/out\\.php\\?to=(.+?)&#is", $data, $re)) { while (list($num, $ligne) = each($re[1])) { $sitename = $ligne; $familysite = $q->GetFamilySites($ligne); if (!isset($CACHE[$sitename])) { $q->categorize($sitename, "p**n"); $CACHE[$sitename] = true; } if (!isset($CACHE[$familysite])) { $q->categorize($familysite, "p**n"); $CACHE[$familysite] = true; } $f[] = "http://{$sitename}"; } } else { echo "elephantlist_Redirected - nothing found\n"; return array(); } @file_put_contents("/root/p**n-cache.db", serialize($CACHE)); return $f; }
function today_zoom_popup_history_list(){ $Mypage=CurrentPageName(); $tpl=new templates(); $q=new mysql_squid_builder(); $t=time(); $fontsize=13; $type=$_GET["type"]; $field_query="size"; $field_query2="SUM(size)"; $table_field="{size}"; $category=$tpl->_ENGINE_parse_body("{category}"); $hour_table=date('Ymd',strtotime($_GET["day"]))."_hour"; $member=$tpl->_ENGINE_parse_body("{member}"); $sitename=$tpl->_ENGINE_parse_body("{website}"); if($type=="req"){ $field_query="hits"; $field_query2="SUM(hits)"; $table_field="{hits}"; } $sql="SELECT $field_query2 as thits, uid,client,MAC,sitename,category,familysite FROM $hour_table GROUP BY uid,client,sitename,MAC,category,familysite HAVING familysite='{$_GET["familysite"]}' ORDER BY thits DESC LIMIT 0,100"; $results=$q->QUERY_SQL($sql); $data = array(); $data['page'] = 0; $data['total'] = $total; $data['rows'] = array(); if(!$q->ok){$data['rows'][] = array('id' => $ligne[time()],'cell' => array($sql,"$q->mysql_error", "",""));echo json_encode($data);return;} if(mysql_num_rows($results)==0){array('id' => $ligne[time()],'cell' => array(null,"", "",""));echo json_encode($data);return;} $data['total'] = mysql_num_rows($results); $style="style='font-size:{$fontsize}px'"; while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ if($type<>"req"){$ligne["thits"]=FormatBytes($ligne["thits"]/1024);} $categorize="Loadjs('squid.categorize.php?www={$ligne["sitename"]}')"; if(trim($ligne["category"])==null){$ligne["category"]="<span style='color:#D70707'>{categorize_this_website}</span>";} $id=md5(@implode("", $ligne)); if(trim($ligne["uid"])=="-"){$ligne["uid"]=null;} if(trim($ligne["uid"])==null){$ligne["uid"]=$q->UID_FROM_MAC($ligne["MAC"]);} $categorize="<a href=\"javascript:blur()\" OnClick=\"javascript:$categorize\" style='font-size:{$fontsize}px;text-decoration:underline'>"; $familysite=$q->GetFamilySites($ligne["sitename"]); $TrafficHour="<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?familysite={$ligne["sitename"]}&day={$_GET["day"]}')\" style='font-size:{$fontsize}px;text-decoration:underline'>"; $data['rows'][] = array( 'id' => $id, 'cell' => array( "<span $style>{$ligne["uid"]}</span>", "<span $style>{$ligne["MAC"]}</span>", "<span $style>{$ligne["client"]}</span>", "<span $style>$TrafficHour{$ligne["sitename"]}</a></span>", "<span $style>{$ligne["thits"]}</span>", "<span $style>$categorize{$ligne["category"]}</a></span>" ) ); } echo json_encode($data); }
function family_list() { $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $table = "visited_sites"; $country_select = null; $search = '%'; $page = 1; $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"] = "*" . trim($_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 sitename,familysite FROM {$table} WHERE familysite='{$_GET["familysite"]}' {$searchstring}"; $results = $q->QUERY_SQL($sql); $total = mysql_num_rows($results); writelogs("{$sql} = `{$total}`", __FUNCTION__, __FILE__, __LINE__); } else { $sql = "SELECT familysite FROM {$table} WHERE familysite='{$_GET["familysite"]}'"; $results = $q->QUERY_SQL($sql); $total = mysql_num_rows($results); writelogs("{$sql} = `{$total}`", __FUNCTION__, __FILE__, __LINE__); } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; $sql = "SELECT sitename,familysite,category,HitsNumber FROM {$table} WHERE familysite='{$_GET["familysite"]}' {$searchstring} {$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) { $q->mysql_error = wordwrap($q->mysql_error, 80, "<br>"); $sql = wordwrap($sql, 80, "<br>"); $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) { $sql = wordwrap($sql, 80, "<br>"); $data['rows'][] = array('id' => time(), 'cell' => array($sql, "", "", "")); } writelogs("{$sql}", __FUNCTION__, __FILE__, __LINE__); $button = null; while ($ligne = mysql_fetch_assoc($results)) { $error = null; $color = "black"; $myFamily = $q->GetFamilySites($ligne['sitename']); if ($myFamily != $_GET["familysite"]) { $error = $tpl->_ENGINE_parse_body("<br><i style='font-weight:normal'>false should be {$myFamily} instead of {$_GET["familysite"]}</i>"); $color = "#BD0000"; } $jscat = "javascript:Loadjs('{$MyPage}?family-js={$ligne['familysite']}')"; if ($ligne["category"] == null) { $ligne["category"] = "«<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.categorize.php?www={$ligne['sitename']}&day=&week=&month=');\"> categorize »</A>"; } $data['rows'][] = array('id' => md5($ligne['sitename']), 'cell' => array("<spanstyle='font-size:12px;color:{$color};font-weight:bold;text-decoration:underline'>{$ligne['sitename']}{$error}</span>", "<span style='font-size:12px;font-weight:bold'>{$ligne["category"]}</span>", "<span style='font-size:12px;font-weight:bold'>{$ligne["HitsNumber"]}</span>", $button)); } echo json_encode($data); }
function items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $ID = $_GET["ID"]; $tablename = "WebTrackMem{$ID}"; $search = '%'; $table = "(SELECT SUM(hits) as hits, SUM(size) as size,sitename,category,zDate FROM {$tablename} GROUP BY sitename,category,zDate HAVING category='{$_GET["category"]}') as t "; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablename, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablename, $database) == 0) { json_error_show("No rules"); } 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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } $rp = new squid_report($ID); while ($ligne = mysql_fetch_assoc($results)) { $zmd5 = md5(serialize($ligne)); $color = "black"; //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?filterby={$rp->userfield}&filterdata=" . urlencode($rp->userdata) . "&day={$ligne["zDate"]}&familysite={$ligne["sitename"]}');\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $family = $q->GetFamilySites($ligne["sitename"]); $urljsFAM = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?filterby={$rp->userfield}&filterdata=" . urlencode($rp->userdata) . "&day={$ligne["zDate"]}&familysite={$family}');\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:14px;color:{$color}'>{$urljsSIT}{$ligne["zDate"]}</a></span>", "<span style='font-size:14px;color:{$color}'>{$urljsSIT}{$ligne["sitename"]}</a> ({$urljsFAM}{$family}</a>)</span>", "<span style='font-size:14px;color:{$color}'>{$urljs}{$ligne["size"]}</span>", "<span style='font-size:14px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
function haproxy_events() { $qs = new mysql_squid_builder(); $q = new mysql_haproxy_builder(); if (!($handle = opendir("{$GLOBALS["ARTICALOGDIR"]}/haproxy-rtm"))) { @mkdir("{$GLOBALS["ARTICALOGDIR"]}/haproxy-rtm", 0755, true); return; } $hash = array(); $prefixMid = " (sitename,uri,td,http_code,client,hostname,familysite,service,backend,zDate,size,MAC,zMD5,statuslb)"; while (false !== ($filename = readdir($handle))) { if ($filename == ".") { continue; } if ($filename == "..") { continue; } $targetFile = "{$GLOBALS["ARTICALOGDIR"]}/haproxy-rtm/{$filename}"; $countDeFiles++; $ARRAY = unserialize(@file_get_contents($targetFile)); while (list($key, $value) = each($ARRAY)) { $ARRAY[$key] = trim(addslashes($value)); } $ARRAY["MAC"] = GetMacFromIP($ARRAY["SOURCE"]); $hostname = GetComputerName($ARRAY["SOURCE"]); $dayhour = date("YmdH", $ARRAY["TIME"]); $time = date("H:i:s", $ARRAY["TIME"]); $fulldate = date('Y-m-d H:i:s', $ARRAY["TIME"]); $table = "hour_{$dayhour}"; if (preg_match("#(.+?)\\s+(.*?)#", $ARRAY["SERVICE"], $ri)) { $ARRAY["SERVICE"] = $ri[1]; } if (preg_match("#(.+?)\\s+(.*?)#", $ARRAY["BACKEND"], $ri)) { $ARRAY["BACKEND"] = $ri[1]; } $uri = $ARRAY["URI"]; $md5 = md5(serialize($ARRAY)); if (preg_match("#^(?:[^/]+://)?([^/:]+)#", $uri, $re)) { $sitename = $re[1]; if (preg_match("#^www\\.(.+)#", $sitename, $ri)) { $sitename = $ri[1]; } $familysite = $qs->GetFamilySites($sitename); } $linsql = "('{$sitename}','{$uri}','{$ARRAY["TD"]}','{$ARRAY["HTTP_CODE"]}','{$ARRAY["SOURCE"]}','{$hostname}','{$familysite}','{$ARRAY["SERVICE"]}','{$ARRAY["BACKEND"]}','{$fulldate}','{$ARRAY["BYTES"]}','{$ARRAY["MAC"]}','{$md5}','{$ARRAY["STATUSLB"]}')"; $hash[$table][] = $linsql; if ($GLOBALS["VERBOSE"]) { echo "Remove: {$targetFile}\n"; } @unlink($targetFile); if (system_is_overloaded()) { break; } } while (list($table, $tr) = each($hash)) { if (trim($table) == null) { continue; } if (!$q->create_TableHour($table)) { @mkdir("{$GLOBALS["ARTICALOGDIR"]}/haproxy-errors", 0755, true); @file_put_contents("{$GLOBALS["ARTICALOGDIR"]}/haproxy-errors/" . md5(serialize($hash)), serialize($hash)); return; } $sql = "INSERT IGNORE INTO {$table} {$prefixMid} VALUES " . @implode(",", $tr); $q->QUERY_SQL($sql); if (!$q->ok) { WriteMyLogs($q->mysql_error, __FUNCTION__, __FILE__, __LINE__); @mkdir("{$GLOBALS["ARTICALOGDIR"]}/haproxy-errors", 0755, true); @file_put_contents("{$GLOBALS["ARTICALOGDIR"]}/haproxy-errors/" . md5(serialize($hash)), serialize($hash)); return; } } haproxy_errors(); }
function now_search_list() { $page = CurrentPageName(); $tpl = new templates(); $sock = new sockets(); $search = $_GET["search"]; $q = new mysql_squid_builder(); $search = '%'; $table = "squidhour_" . date("YmdH"); $page = 1; $ORDER = "ORDER BY ID DESC"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } if ($_POST["query"] != null) { $_POST["query"] = str_replace("*", "%", $_POST["query"]); $search = $_POST["query"]; $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE (`uri` LIKE '{$search}')"; $QUERY = "WHERE (`uri` LIKE '{$search}')"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $total = $q->COUNT_ROWS($table); } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$pageStart}, {$rp}"; if ($q->COUNT_ROWS($table) == 0) { return; } $sql = "SELECT *,DATE_FORMAT(zDate,'%H:%i:%s') as ttime FROM `{$table}` {$QUERY} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); // | {$ligne["CLIENT"]} | {$ligne["uid"]} $data = array(); $data['page'] = $page; $data['total'] = $total; $data['rows'] = array(); $results = $q->QUERY_SQL($sql); writelogs($sql, __FUNCTION__, __FILE__, __LINE__); while ($ligne = mysql_fetch_assoc($results)) { if ($ligne["QuerySize"] > 1024) { $ligne["QuerySize"] = FormatBytes($ligne["QuerySize"] / 1024); } else { $ligne["QuerySize"] = "{$ligne["QuerySize"]} Bytes"; } $c++; $today = date("Y-m-d"); $familysite = $q->GetFamilySites($ligne["sitename"]); $js = "squid.traffic.statistics.days.php?today-zoom=yes&type=req&familysite={$familysite}&day={$today}"; if ($ligne["uid"] != null) { $uid = " | {$ligne["uid"]}"; } if ($ligne["CLIENT"] != null) { $ip = "{$ligne["CLIENT"]}"; $textname = $ligne["CLIENT"]; $fieldfilter = "CLIENT"; } if ($ligne["hostname"] != null) { $ip = "{$ligne["hostname"]}"; $textname = $ligne["hostname"]; $fieldfilter = "hostname"; } if ($ligne["MAC"] != null) { $ip = "{$ligne["MAC"]}"; $fieldfilter = "MAC"; } $ip = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('squid.traffic.now.php?field={$fieldfilter}&value={$ip}&NameTitle=" . base64_encode($textname) . "');\" style='text-decoration:underline'>{$textname}</a>"; $data['rows'][] = array('id' => "{$ligne["ID"]}", 'cell' => array($ligne["ttime"], $ligne["country"], "<a href=\"#\" style='text-decoration:underline' OnClick=\"javascript:Loadjs('{$js}');\">{$ligne["sitename"]}</a>", "{$ip}{$uid}", $ligne["uri"], $ligne["QuerySize"], "add")); } echo json_encode($data); }
function search() { $Mypage = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $t = time(); $fontsize = 13; $type = $_GET["type"]; $field_query = "size"; $field_query2 = "SUM(size)"; $table_field = "{size}"; $category = $tpl->_ENGINE_parse_body("{category}"); $table = "WEEK_RTTH"; $member = $tpl->_ENGINE_parse_body("{member}"); $sitename = $tpl->_ENGINE_parse_body("{website}"); $search = '%'; $page = 1; $ORDER = "ORDER BY ID DESC"; $ip = new IP(); $Select = "MAC"; $FORCE_FILTER = " AND `MAC`='{$_GET["MAC"]}'"; if ($ip->isIPAddress($_GET["ipaddr"])) { $Select = "ipaddr"; $FORCE_FILTER = "ipaddr='{$_GET["ipaddr"]}'"; } if ($ip->IsvalidMAC($_GET["MAC"])) { $Select = "MAC"; $FORCE_FILTER = "MAC='{$_GET["MAC"]}'"; } $table = "(SELECT `day`,SUM(size) as size,{$Select} FROM WEEK_RTTH GROUP BY `day`,{$Select} HAVING {$FORCE_FILTER}) as t"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } if (isset($_POST['page'])) { $page = $_POST['page']; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $search = string_to_flexquery(); if ($search != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $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 {$search} {$ORDER} {$limitSql}"; $results = $q->QUERY_SQL($sql); $data = array(); $data['page'] = 0; $data['total'] = $total; $data['rows'] = array(); if (!$q->ok) { json_error_show($q->mysql_error); } if (mysql_num_rows($results) == 0) { json_error_show("no data"); } $data['total'] = mysql_num_rows($results); $style = "style='font-size:22px'"; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ligne["size"] = FormatBytes($ligne["size"] / 1024); $categorize = "Loadjs('squid.categorize.php?www={$ligne["sitename"]}')"; if (trim($ligne["category"]) == null) { $ligne["category"] = "<span style='color:#D70707'>{categorize_this_website}</span>"; } $id = md5(@implode("", $ligne)); if (trim($ligne["uid"]) == "-") { $ligne["uid"] = null; } if (trim($ligne["uid"]) == null) { $ligne["uid"] = $q->UID_FROM_MAC($ligne["MAC"]); } if (trim($ligne["uid"]) == null) { $ligne["uid"] = $q->UID_FROM_IP($ligne["CLIENT"]); } $categorize = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:{$categorize}\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>"; $familysite = $q->GetFamilySites($ligne["sitename"]); $TrafficHour = "<a href=\"javascript:blur()\" \n\t\tOnClick=\"javascript:Loadjs('squid.traffic.statistics.hours.php?familysite={$ligne["sitename"]}&day={$_GET["day"]}')\" \n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'>"; $dd = date("Y-m"); $D = $q->time_to_date(strtotime("{$dd}-{$ligne["day"]} 00:00:00")); $data['rows'][] = array('id' => $id, 'cell' => array("<span {$style}>{$D}</span>", "<span {$style}>{$ligne["size"]}</a></span>")); } echo json_encode($data); }
function items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $search = '%'; $table = $_GET["table"]; $page = 1; $FORCE_FILTER = null; if ($_GET["field"] != null) { $FORCE_FILTER = " AND `{$_GET["field"]}`='{$_GET["value"]}'"; } if ($_GET["sitename"] != null) { $FORCE_FILTER = $FORCE_FILTER . " AND `sitename`='{$_GET["sitename"]}'"; } if (!$q->TABLE_EXISTS($table, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($table, $database) == 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("{$sql}<hr>No row", 1); } $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(serialize($ligne)); $color = "black"; $date = strtotime($ligne["zDate"]); $Hour = date("H:i"); //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('squid.website-zoom.php?js=yes&sitename={$ligne["sitename"]}&xtime={$_GET["xtime"]}');\"\n\tstyle='font-size:14px;text-decoration:underline;color:{$color}'>"; $urijs = "s_PopUpFull('{$ligne["uri"]}','1024','900');"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $ligne["familysite"] = $q->GetFamilySites($ligne["sitename"]); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:12px;color:{$color}'>{$Hour}</a></span>", "<span style='font-size:12px;color:{$color}'><a href=\"javascript:blur();\" OnClick=\"javascript:{$urijs}\" style='text-decoration:underline'>{$ligne["uri"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$ligne["size"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
function cachednshosts_records($g) { $unix = new unix(); if (!is_array($g)) { $g = array(); } $build_hosts_array = unserialize(@file_get_contents("/etc/dnsmasq.hash.domains")); $sock = new sockets(); $IpClass = new IP(); $EnableDNSMASQOCSDB = $sock->GET_INFO("EnableDNSMASQOCSDB"); $EnableDHCPServer = intval($sock->GET_INFO("EnableDHCPServer")); $EnableDNSMASQLDAPDB = $sock->GET_INFO("EnableDNSMASQLDAPDB"); if (!is_numeric($EnableDNSMASQOCSDB)) { $EnableDNSMASQOCSDB = 1; } if (!is_numeric($EnableDNSMASQLDAPDB)) { $EnableDNSMASQLDAPDB = 0; } $EnableArticaHotSpot = intval($sock->GET_INFO("EnableArticaHotSpot")); $C = 0; if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Use OCS database {$EnableDNSMASQOCSDB}\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Use LDAP database {$EnableDNSMASQLDAPDB}\n"; } $q = new mysql_squid_builder(); $qSquid = new mysql_squid_builder(); $sql = "SELECT * FROM dnsmasq_records"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { $GLOBALS["MYSQL_ERROR_DNSMASQ"] = true; if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} MySQL error, aborting\n"; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$q->mysql_error}\n"; } return false; } $CNAMES = array(); $MAIN_MEM = array(); @unlink("/etc/dnsmasq.hosts.cmdline"); while ($ligne = mysql_fetch_assoc($results)) { $ipaddr = trim($ligne["ipaddr"]); $hostname = hostname_valid($ligne["hostname"]); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} host: {$hostname}/{$ipaddr}\n"; } if ($hostname == null) { continue; } if (strpos($hostname, ".") > 0) { $build_hosts_array[$q->GetFamilySites($hostname)] = true; } if (strpos($hostname, ".") > 0) { $hostname_EXPLODED = explode(".", $hostname); $MAIN_MEM[$ipaddr][] = $hostname_EXPLODED[0]; } push_ptr($hostname, $ipaddr); $results2 = $q->QUERY_SQL("SELECT hostname FROM dnsmasq_cname WHERE recordid={$ligne["ID"]}"); $aliases = array(); while ($ligne2 = mysql_fetch_assoc($results2)) { if (trim(hostname_valid($ligne2["hostname"])) == null) { continue; } $aliases[] = $ligne2["hostname"]; $C++; $GLOBALS["CNAMES"][$ligne2["hostname"]] = "--cname={$ligne2["hostname"]},{$ipaddr}"; if ($GLOBALS["VERBOSE"]) { echo "{$hostname} -> {$ligne2["hostname"]}\n"; } } } if ($EnableDHCPServer == 1) { $q = new mysql(); $results = $q->QUERY_SQL("SELECT * FROM dhcpd_fixed", "artica_backup"); if (!$q->ok) { return; } $c = 0; while ($ligne = mysql_fetch_assoc($results)) { $ligne["hostname"] = hostname_valid($ligne["hostname"]); if ($ligne["hostname"] == null) { continue; } $arecord = $ligne["ipaddr"]; $hostname = $ligne["hostname"]; if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.#", $hostname)) { continue; } if ($GLOBALS["VERBOSE"]) { echo "[" . __LINE__ . "] dhcpd_fixed::{$hostname}/{$arecord}\n"; } if (strpos($hostname, ".") > 0) { $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true; } push_ptr($hostname, $arecord); if ($GLOBALS["VERBOSE"]) { echo "dhcpd_fixed:: {$hostname} -> {$ipaddr}\n"; } } } if ($EnableArticaHotSpot == 1) { $HospotHTTPServerName = trim($sock->GET_INFO("HospotHTTPServerName")); if ($HospotHTTPServerName != null) { $ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface"); $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES(); $IPADDR = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"]; if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, adding {$HospotHTTPServerName}/{$IPADDR}\n"; } if (strpos($HospotHTTPServerName, ".") > 0) { $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true; } push_ptr($HospotHTTPServerName, $IPADDR); $C++; } } if ($EnableDNSMASQOCSDB == 1) { $sql = "SELECT networks.IPADDRESS,hardware.name FROM networks,hardware WHERE \tnetworks.HARDWARE_ID=hardware.ID\n\t\t\tAND networks.IPADDRESS!='0.0.0.0' AND networks.IPADDRESS REGEXP '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$'"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "ocsweb"); if ($GLOBALS["VERBOSE"]) { if (!$q->ok) { echo $q->mysql_error . "\n"; } } if ($GLOBALS["VERBOSE"]) { echo "[" . __LINE__ . "] ocs_addresses:: MYSQL -> " . mysql_num_rows($results) . " entries\n"; } while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $arecord = $ligne["IPADDRESS"]; $hostname = hostname_valid($ligne["name"]); if ($hostname == null) { continue; } if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.#", $hostname)) { continue; } if ($GLOBALS["VERBOSE"]) { echo "[" . __LINE__ . "] ocs_addresses:: {$hostname}/{$arecord} OCS MYSQL\n"; } if (strpos($hostname, ".") > 0) { $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true; } $C++; push_ptr($hostname, $arecord); if ($GLOBALS["VERBOSE"]) { echo "OCS:: {$hostname} -> {$ipaddr}\n"; } } } if ($EnableDNSMASQLDAPDB == 1) { $ldap = new clladp(); $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn=*)(ComputerIP=*)(uid=*))(gecos=computer))"; $ldap = new clladp(); $attrs = array("uid", "ComputerIP"); $dn = "{$ldap->suffix}"; $hash = $ldap->Ldap_search($dn, $filter_search, $attrs); for ($i = 0; $i < $hash["count"]; $i++) { $arecord = $hash[$i][strtolower("ComputerIP")][0]; $hostname = trim(strtolower($hash[$i]["uid"][0])); $hostname = hostname_valid($hostname); if ($hostname == null) { continue; } if ($arecord == "127.0.0.1") { continue; } if ($arecord == "0.0.0.0") { continue; } if ($arecord == null) { continue; } if (isset($GLOBALS["ARRAY_ADRESSES_DONE"][$hostname])) { continue; } if (!$IpClass->isValid($arecord)) { continue; } if (strpos($hostname, ".") > 0) { $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true; } $reversed = reversed_name($arecord); $C++; push_ptr($hostname, $arecord); if ($GLOBALS["VERBOSE"]) { echo "LDAP:: {$hostname} -> {$arecord}\n"; } } } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, " . count($GLOBALS["PTR_RECORDS"]) . " Records...\n"; } while (list($arecord, $hostnames) = each($GLOBALS["PTR_RECORDS"])) { if ($arecord == "0.0.0.0") { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Invalid `{$arecord}/{$hostnames}`\n"; } continue; } $netbiosname = hostname_valid($hostnames[0]); $FullyHostname = hostname_valid($hostnames[1]); if ($netbiosname == null) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Invalid hostname_valid():`{$arecord}/{$hostnames[0]}`\n"; } continue; } $hostname_text = @implode("/", $hostnames); $hostname = $hostnames[0]; $hostname = str_replace(" ", "", $hostname); $reversed = reversed_name($arecord); $g[] = "--address=/{$hostname_text}/{$arecord}"; $g[] = "--ptr-record={$reversed}.in-addr.arpa.,{$hostname}"; } while (list($arecord, $cmdline) = each($GLOBALS["CNAMES"])) { $g[] = $cmdline; } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$C} host(s)\n"; } @file_put_contents("/etc/dnsmasq.hash.domains", serialize($build_hosts_array)); $g = GetGoogleWebsitesList($g); if (count($g) > 0) { @file_put_contents("/etc/dnsmasq.hosts.cmdline", @implode(" ", $g)); } if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, return " . count($g) . " host item(s)\n"; } return $g; }
function webstats_middle_table_items() { $t = $_GET["t"]; $tpl = new templates(); $MyPage = CurrentPageName(); $q = new mysql_squid_builder(); $users = new usersMenus(); $sock = new sockets(); $search = '%'; $tablemain = "youtubeday_" . date("Ymd", $_GET["xtime"]); $table = "(SELECT SUM( hits ) AS hits, ipaddr, hostname, uid, MAC, youtubeid, title\nFROM (\n\tSELECT {$tablemain}.hits AS hits, {$tablemain}.ipaddr, {$tablemain}.hostname,\n\t{$tablemain}.uid, {$tablemain}.MAC, {$tablemain}.youtubeid, youtube_objects.title\n\tFROM `{$tablemain}` , `youtube_objects`\n\tWHERE youtube_objects.youtubeid = {$tablemain}.youtubeid\n\t) AS t1\nGROUP BY ipaddr, hostname, uid, MAC, youtubeid, title) as t"; $page = 1; $FORCE_FILTER = null; if (!$q->TABLE_EXISTS($tablemain, $database)) { json_error_show("{$table} doesn't exists..."); } if ($q->COUNT_ROWS($tablemain, $database) == 0) { json_error_show("No rules"); } 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}"; writelogs($sql, __FUNCTION__, __FILE__, __LINE__); $results = $q->QUERY_SQL($sql, $database); $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(serialize($ligne)); $color = "black"; //familysite size hits $urljsSIT = "<a href=\"javascript:blur();\" \n\tOnClick=\"javascript:Loadjs('miniadm.webstats.youtubeid.php?youtubeid={$ligne["youtubeid"]}&xtime={$_GET["xtime"]}');\"\n\tstyle='font-size:12px;text-decoration:underline;color:{$color}'>"; $ligne["hits"] = numberFormat($ligne["hits"], 0, "", " "); $ligne["size"] = FormatBytes($ligne["size"] / 1024); $ligne["familysite"] = $q->GetFamilySites($ligne["sitename"]); $data['rows'][] = array('id' => "{$zmd5}", 'cell' => array("<span style='font-size:12px;color:{$color}'>{$urljsSIT}{$ligne["title"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$urljsFAM}{$ligne["uid"]}</a></span>", "<span style='font-size:12px;color:{$color}'>{$urljs}{$ligne["ipaddr"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hostname"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["MAC"]}</span>", "<span style='font-size:12px;color:{$color}'>{$ligne["hits"]}</span>")); } echo json_encode($data); }
function automation_popup() { $page = CurrentPageName(); $tpl = new templates(); $users = new usersMenus(); $sock = new sockets(); $importsquid = null; $html = ""; $apply = $tpl->_ENGINE_parse_body("{apply}"); if ($users->SQUID_INSTALLED) { $importsquid = button("{import_squid_conf}", "Loadjs('import.squid.zip.php')", 22) . " "; } $nic = new system_nic("eth0"); $IPADDR = $nic->IPADDR; $NETMASK = $nic->NETMASK; $GATEWAY = $nic->GATEWAY; $BROADCAST = $nic->BROADCAST; $metric = $nic->metric; if (!is_numeric($metric)) { $metric = 1; } $hostname = base64_decode($sock->getFrameWork("network.php?fqdn=yes")); $q = new mysql_squid_builder(); $domainname = $q->GetFamilySites($hostname); $CMP = explode(".", $domainname); $CompanyName = strtoupper($CMP[0]); $arrayNameServers = GetNamesServers(); $tt = explode(".", $hostname); $tt1 = $tt[0]; unset($tt[0]); $tt2 = @implode(".", $tt); $f[] = "########################################"; $f[] = "#"; $f[] = "# Automation script sample #"; $f[] = "#"; $f[] = "########################################"; $f[] = "# Copy this content and paste modified data"; $f[] = "# After apply, the server will change all parameters"; $f[] = "# You will have access to the interface using"; $f[] = "# Manager as account and secret as password"; $f[] = ""; $f[] = "########################################"; $f[] = "###### Network ######"; $f[] = "########################################"; $f[] = ""; $f[] = "# First main Network interface"; $f[] = "# \"KEEPNET\" should modify current network [0] or keep the current network settings [1]"; $f[] = "KEEPNET=0"; $f[] = "VPS_COMPATIBLE=0"; $f[] = "NIC=eth0"; $f[] = "IPADDR={$IPADDR}"; $f[] = "NETMASK={$NETMASK}"; $f[] = "GATEWAY={$GATEWAY}"; $f[] = "BROADCAST={$BROADCAST}"; $f[] = "metric={$metric}"; $f[] = "DNS1=" . $arrayNameServers[0]; $f[] = "DNS2=" . $arrayNameServers[1]; $f[] = ""; $f[] = "########################################"; $f[] = "###### SNMP Service ######"; $f[] = "########################################"; $f[] = ""; $f[] = "# Activate the SNMP service 0/1"; $f[] = "EnableSNMPD=0"; $f[] = "# Public community"; $f[] = "SNMPDCommunity=public"; $f[] = "# Allowed network"; $f[] = "SNMPDNetwork=default"; $ArticaMetaHost = $sock->GET_INFO("ArticaMetaHost"); $ArticaMetaPort = intval($sock->GET_INFO("ArticaMetaPort")); if ($ArticaMetaPort == 0) { $ArticaMetaPort = 9000; } $f[] = "########################################"; $f[] = "###### Meta Server ######"; $f[] = "########################################"; $f[] = ""; $f[] = "# Use an Meta Server Global Management console 0/1"; $f[] = "EnableArticaMetaClient=0"; $f[] = "# Meta Server server user name"; $f[] = "#ArticaMetaUsername=Manager"; $f[] = "# Meta Server server password"; $f[] = "#ArticaMetaPassword=secret"; $f[] = "# Meta Server server address"; $f[] = "#ArticaMetaHost=1.2.3.4"; $f[] = "# Meta Server server port"; $f[] = "#ArticaMetaPort=9000"; $f[] = ""; $f[] = "########################################"; $f[] = "###### System parameters ###### "; $f[] = "########################################"; $f[] = "# Hostname of the server 15 characters MAX"; $f[] = "netbiosname={$tt1}"; $f[] = ""; $f[] = "# Domain of the server ( use the same of your Active directory server if you plan to use AD)"; $f[] = "domain={$tt2}"; $f[] = ""; $f[] = "# Time zone: Europe/Moscow, Europe/Paris, Europe/Rome, US/Central ..."; $f[] = "# see http://en.wikipedia.org/wiki/List_of_tz_database_time_zones for the complete list"; $f[] = "timezones=US/Central"; $f[] = "# OpenLDAP server threads"; $f[] = "SlapdThreads=2"; $f[] = "# Kernel Swapiness define after which percentage of physical memory use the kernel will use the swap file"; $f[] = "swappiness=90"; $f[] = "# Change the system root password ( used for SSH or console mode )"; $f[] = "#RootPassword=artica"; $f[] = ""; $f[] = ""; $f[] = "########################################"; $f[] = "###### Registration parameters ######"; $f[] = "########################################"; $f[] = ""; $f[] = ""; $f[] = "# company name will be the title of your web interface"; $f[] = "# you should not set corrupted data such as toto mdlcsmck or something else"; $f[] = "# You will not be able to change it after"; $f[] = "company_name={$CompanyName}"; $f[] = "city=Paris"; $f[] = "# LDAP Organization ( if not connected to the Active Directory)"; $f[] = "organization={$CompanyName}"; $f[] = "country=France"; $f[] = "smtp_domainname={$domainname}"; $f[] = "mail=support@{$domainname}"; $f[] = "telephone=00.00.00.00.00"; $f[] = "employees=55"; $f[] = "#The Gold key License number provided by our sales team;"; $f[] = "#GoldKey="; $f[] = ""; $f[] = "########################################"; $f[] = "###### Services/Proxy section ######"; $f[] = "########################################"; $f[] = ""; $f[] = "# Standard Proxy Listen port ( non transparent)"; $f[] = "proxy_listen_port=3128"; $f[] = ""; $f[] = "# Enable/Disable the transparent mode 0 = no, 1 = yes"; $f[] = "# Standard Proxy Transparent Listen port"; $f[] = "EnableTransparent=0"; $f[] = "# Transparent port"; $f[] = "TransparentPort=0"; $f[] = ""; $f[] = "# Activate FreeRadius"; $f[] = "EnableFreeRadius=0"; $f[] = ""; $f[] = "# Activate DHCP service."; $f[] = "EnableDHCPServer=0"; $f[] = ""; $f[] = "# Activate Web Filtering."; $f[] = "EnableWebFiltering=1"; $f[] = ""; $f[] = "# Activate NTLM Proxy"; $f[] = "EnableCNTLM=0"; $f[] = ""; $f[] = "# Artica Features level"; $f[] = "# SquidPerformance=0 Enable all features including Categories services,statistics and relatime monitor"; $f[] = "# SquidPerformance=1 Disable Categories services, enable Artica statistics and Artica realtime monitor"; $f[] = "# SquidPerformance=2 Disable Categories services, Disable Artica statistics and Artica realtime monitor"; $f[] = "SquidPerformance=1"; $f[] = ""; $f[] = "# NTLM Proxy Listen port"; $f[] = "CnTLMPORT=3155"; $f[] = "# Proxy shared physical memory (MB)"; $f[] = "cache_mem=256"; $f[] = "# Proxy FQDN DNS cache size (items)"; $f[] = "fqdncache_size=51200"; $f[] = "# Proxy IP DNS cache size (items)"; $f[] = "ipcache_size=51200"; $f[] = "# Proxy DNS cache low (%)"; $f[] = "ipcache_low=90"; $f[] = "# Proxy DNS cache High (%)"; $f[] = "ipcache_low=95"; $f[] = ""; $f[] = ""; $f[] = "# Watchdog"; $f[] = ""; $MonitConfig = unserialize(base64_decode($sock->GET_INFO("SquidWatchdogMonitConfig"))); if (!isset($MonitConfig["ENABLE_PING_GATEWAY"])) { $MonitConfig["ENABLE_PING_GATEWAY"] = 0; } if (!isset($MonitConfig["MAX_PING_GATEWAY"])) { $MonitConfig["MAX_PING_GATEWAY"] = 10; } if (!isset($MonitConfig["PING_FAILED_RELOAD_NET"])) { $MonitConfig["PING_FAILED_RELOAD_NET"] = 0; } if (!isset($MonitConfig["PING_FAILED_REPORT"])) { $MonitConfig["PING_FAILED_REPORT"] = 1; } if (!isset($MonitConfig["PING_FAILED_REBOOT"])) { $MonitConfig["PING_FAILED_REBOOT"] = 0; } if (!isset($MonitConfig["PING_FAILED_FAILOVER"])) { $MonitConfig["PING_FAILED_FAILOVER"] = 0; } $f[] = "# Ping the gateway in order to see if network is available ?"; $f[] = "ENABLE_PING_GATEWAY={$MonitConfig["ENABLE_PING_GATEWAY"]}"; $f[] = "# Ip address of the gateway, if not set, then automatically found it"; $f[] = "PING_GATEWAY={$MonitConfig["PING_GATEWAY"]}"; $f[] = "# Max rotation, after x failed, stop to evaluate the ping process"; $f[] = "MAX_PING_GATEWAY={$MonitConfig["MAX_PING_GATEWAY"]}"; $f[] = "# If ping failed, reconfigure the network ?"; $f[] = "PING_FAILED_RELOAD_NET={$MonitConfig["PING_FAILED_RELOAD_NET"]}"; $f[] = "# If ping failed, reboot the server ?"; $f[] = "PING_FAILED_REBOOT={$MonitConfig["PING_FAILED_REBOOT"]}"; $f[] = "# If ping failed, report network status ?"; $f[] = "PING_FAILED_REPORT={$MonitConfig["PING_FAILED_REPORT"]}"; $f[] = "# If ping failed, switch to failover backup server ?"; $f[] = "PING_FAILED_FAILOVER={$MonitConfig["PING_FAILED_FAILOVER"]}"; $f[] = ""; $f[] = ""; $f[] = "# Specifics DNS servers for the proxy. Separate them with a comma"; $f[] = "ProxyDNS=" . @implode(",", $arrayNameServers); $f[] = ""; $f[] = "# Blacklist categories in default rule."; $f[] = "# Separate them with a comma"; $f[] = "# possible values are:"; $f[] = "#p**n,sex/lingerie,mixed_adult,sexual_education,abortion,dating,tattooing,agressive,violence,terrorism,"; $f[] = "#automobile/bikes,automobile/boats,automobile/cars,automobile/planes,automobile/carpool,bicycle,publicite,"; $f[] = "#cleaning,dangerous_material,downloads,chat,passwords,drugs,dynamic,financial,stockexchange,"; $f[] = "#finance/banking,finance/insurance,finance/moneylending,finance/realestate,finance/other,"; $f[] = "#forums,socialnet,jobsearch,jobtraining,learning,humanitarian,associations,gamble,hacking,warez,"; $f[] = "#hobby/cooking,hobby/fishing,hobby/arts,hobby/other,isp,webmail,liste_bu,mobile-phone,marketingware,"; $f[] = "#webradio,audio-video,webtv,music,movies,blog,news,press,society,books,manga,dictionaries,phishing,"; $f[] = "#redirector,proxy,paytosurf,reaffected,tricheur,webphone,weapons,"; $f[] = "#games,hobby/pets,animals,horses,filehosting,photo,pictureslib,imagehosting,religion,sect,"; $f[] = "#genealogy,recreation/wellness,recreation/travel,recreation/nightout,governments,"; $f[] = "#recreation/schools,housing/doityourself,housing/builders,housing/accessories,houseads,smallads,"; $f[] = "#electricalapps,justice,police,converters,meetings,getmarried,tobacco,recreation/sports,recreation/humor,"; $f[] = "#children,teens,shopping,gifts,luxury,cosmetics,clothing,electronichouse,models,celebrity,womanbrand,"; $f[] = "#politic,industry,science/chemistry,sciences,astrology,science/astronomy,science/weather,nature,green,"; $f[] = "#browsersplugins,webplugins,maps,webapps,science/computing,remote-control,hospitals,medical,health,"; $f[] = "#handicap,sslsites,updatesites,internal,searchengines,translators,spyware,malware,tracker,"; $f[] = "#transport,culture,wine,alcohol,literature,mailing,suspicious"; $f[] = ""; $f[] = "Blacklists=p**n,mixed_adult,dating,violence,spyware,malware,tracker,publicite,mailing,suspicious"; $f[] = ""; $f[] = ""; $f[] = "# Caches center."; $f[] = "# Allows you to auto-create caches"; $f[] = "# Caches will be prepared but will not created until the license is not accepted by Artica"; $f[] = "# If you have a gold key, it is fully supported"; $f[] = "# caches type should be tmpfs,rock,aufs,diskd"; $f[] = "# define: cache_name,cpu,directory,type,cache_size (MB),cache_dir_level1,cache_dir_level2"; $f[] = "# Cache Memory Example: "; $f[] = "# caches=Mem1,1,/home/mem,tmpfs,500,128,256 Will create a cache memory with 500MB"; $f[] = "# Cache disk Example: "; $f[] = "# caches=disk1,2,/home/squid/cache,tmpfs,5000,128,256 Wil create a cache disk for CPU2 with 5GB"; $f[] = ""; $f[] = "# Activate ARP Daemon"; $f[] = "EnableArpDaemon=0"; $f[] = "#"; $f[] = "# Activate FreeWebs Web servers management"; $f[] = "EnableFreeWeb=0"; $f[] = "# If 1 then Artica Proxy Statistics are disabled, if 0 Artica Proxy Statistics are enabled"; $f[] = "DisableArticaProxyStatistics=0"; $f[] = "# Activate SARG statistics generation"; $f[] = "EnableSargGenerator=0"; $f[] = "# Activate Hostnames logging in Proxy statistics"; $f[] = "EnableProxyLogHostnames=1"; $TuningParameters = unserialize(base64_decode($sock->GET_INFO("MySQLSyslogParams"))); $username = $TuningParameters["username"]; $password = $TuningParameters["password"]; $mysqlserver = $TuningParameters["mysqlserver"]; $RemotePort = $TuningParameters["RemotePort"]; if ($username == null) { $username = "******"; } $BackupSquidLogsNASIpaddr = $sock->GET_INFO("BackupSquidLogsNASIpaddr"); $BackupSquidLogsNASFolder = $sock->GET_INFO("BackupSquidLogsNASFolder"); $BackupSquidLogsNASUser = $sock->GET_INFO("BackupSquidLogsNASUser"); $BackupSquidLogsNASPassword = $sock->GET_INFO("BackupSquidLogsNASPassword"); $WizardStatsApplianceDisconnected = intval($sock->GET_INFO("WizardStatsApplianceDisconnected")); $f[] = ""; $f[] = "########################################"; $f[] = "###### Statistics appliance ###### "; $f[] = "########################################"; $f[] = "# Use Statistics appliance in disconnected mode (0/1) - suggest to 1"; $f[] = "#WizardStatsApplianceDisconnected=0"; $f[] = "# Artica stats appliance remote address"; $f[] = "#WizardStatsAppliance_server="; $f[] = "# Artica stats appliance remote SSL port"; $f[] = "#WizardStatsAppliance_port=9000"; $f[] = "# SuperAdmin credentials to communicate"; $f[] = "#WizardStatsAppliance_username=Manager"; $f[] = "#WizardStatsAppliance_password=secret"; $f[] = ""; $f[] = "########################################"; $f[] = "###### Squid.conf acls importation ###### "; $f[] = "########################################"; $f[] = ""; $f[] = "# copy/paste your old Squid.conf inside <SQUIDCONF></SQUIDCONF> paragraph"; $f[] = "<SQUIDCONF>"; $f[] = "#something here..."; $f[] = "</SQUIDCONF>"; $f[] = ""; $f[] = "########################################"; $f[] = "###### LOGS ROTATION ######"; $f[] = "########################################"; $f[] = "# Activate System events rotation storage"; $f[] = "#Run/install a MySQL dedicated service on this computer 1 = Enabled, 0= disabled"; $f[] = "EnableSyslogDB=0"; $f[] = "#Where to put rotate files ?"; $f[] = "# 1 = MySQL Local service"; $f[] = "# 2 = Remote MySQL service"; $f[] = "# 3 = Remote NAS Storage"; $f[] = "# 4 = On the local disk"; $f[] = "MySQLSyslogType=4"; $f[] = "#"; $f[] = "# Where to put Syslog database path ( if EnableSyslogDB=1 )"; $f[] = "MySQLSyslogWorkDir=/home/syslogsdb"; $f[] = "MySQLSyslogUsername={$username}"; $f[] = "MySQLSyslogPassword={$password}"; $f[] = "MySQLSyslogServer={$mysqlserver}"; $f[] = "MySQLSyslogServerPort={$RemotePort}"; $f[] = "# NAS Storage system parameters( if MySQLSyslogType=4 )"; $f[] = "# NAS IP address"; $f[] = "#BackupSquidLogsNASIpaddr={$BackupSquidLogsNASIpaddr}"; $f[] = "# NAS Shared Folder"; $f[] = "#BackupSquidLogsNASFolder={$BackupSquidLogsNASFolder}"; $f[] = "# NAS username and password ( empty if no credential)"; $f[] = "#BackupSquidLogsNASUser={$BackupSquidLogsNASUser}"; $f[] = "#BackupSquidLogsNASPassword={$BackupSquidLogsNASPassword}"; $f[] = ""; $f[] = "########################################"; $f[] = "###### Web Interface ######"; $f[] = "########################################"; $f[] = "# Manager name and password:"******"# This is the Account of the global Manager interface ( default: Username Manager, password=secret)"; $f[] = "#ManagerAccount=Manager"; $f[] = "#ManagerPassword=secret"; $f[] = "# Disable insert special characters in passwords (0/1)"; $f[] = "#DisableSpecialCharacters=1"; $f[] = ""; $f[] = "# EndUser Web Access Web servername"; $f[] = "adminwebserver=admin.company.tld"; $f[] = ""; $f[] = "# EndUser Web Access Web servername 2"; $f[] = "second_webadmin={$IPADDR}"; $f[] = "# Full Administrator"; $f[] = "administrator=admin"; $f[] = "administratorpass=password"; $f[] = "# Statistics Administrator"; $f[] = "statsadministrator=admin"; $f[] = "statsadministratorpass=password"; $f[] = ""; $f[] = "########################################"; $f[] = "###### Active Directory settings ###### "; $f[] = "########################################"; $f[] = ""; $f[] = ""; $f[] = "# Enable/Disable Active Directory connection."; $f[] = "EnableKerbAuth=0"; $f[] = "# Enable Active Directory connection."; $f[] = "# Active Directory DNS suffix."; $f[] = "WINDOWS_DNS_SUFFIX={$domainname}"; $f[] = ""; $f[] = "# Active Directory server netbios name"; $f[] = "WINDOWS_SERVER_NETBIOSNAME=dc"; $f[] = "# Active Directory workgroup name"; $f[] = "ADNETBIOSDOMAIN={$CompanyName}"; $f[] = "# Ip address of the Active Directory server"; $f[] = "ADNETIPADDR=192.168.1.10"; $f[] = "# If ip address is set, you can force system to use the AD as first DNS"; $f[] = "UseADAsNameServer=1"; $f[] = "# Use the Active Directory as Time server ? 0/1"; $f[] = "NtpdateAD=0"; $f[] = "# Use this Internal Interface to communicate with the Active Directory"; $f[] = "#SambaBindInterface=10.10.10.1"; $f[] = "# Active Directory server version ( WIN_2003 or WIN_2008AES for both 2008/2012)"; $f[] = "WINDOWS_SERVER_TYPE=WIN_2003"; $f[] = ""; $f[] = "COMPUTER_BRANCH=CN=Computers"; $f[] = "WINDOWS_SERVER_ADMIN=administrator"; $f[] = "WINDOWS_SERVER_PASS=adminpassword\n"; $f[] = ""; $t = time(); $text = @implode("\n", $f); $button = button($apply, "Save{$t}()", 22); $html = "\n<div style='font-size:22px;margin:15px' class=explain>{automation_script_explain}</div>\n<center id='{$t}' style='margin:10px'></center>\n<center>\n<div style='text-align:center;width:100%;background-color:white;margin-bottom:10px;padding:5px;'>{$importsquid}{$button}<br></div>\n<textarea\nstyle='width:95%;height:400px;overflow:auto;border:5px solid #CCCCCC;font-size:14px;font-weight:bold;padding:3px'\nid='content-{$t}'>{$text}</textarea>\n<div style='text-align:center;width:100%;background-color:white;margin-top:10px'>{$button}</div>\n</center>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar res=obj.responseText;\n\tdocument.getElementById('{$t}').innerHTML='';\n\tif(res.length>3){alert(res);return;}\n\tLoadjs('wizard.automationscript.progress.php');\n\t//alert('The Automation Script was correctly executed on your server...\\nWe suggest to reboot your server after 2/3 minutes');\n\t//document.location.href='logon.php';\n\n}\n\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('AutomationScript', encodeURIComponent(document.getElementById('content-{$t}').value));\n\tdocument.getElementById('{$t}').innerHTML=\"<img src='img/wait_verybig_old.gif' style='margin:30px'>\";\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>"; echo $tpl->_ENGINE_parse_body($html); }
function site_infos() { $page = CurrentPageName(); $tpl = new templates(); $q = new mysql_squid_builder(); $Familysite = $q->GetFamilySites($_GET["site-infos"]); $sql = "SELECT whois FROM `visited_sites` WHERE familysite='{$Familysite}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); writelogs("WHOIS::{$Familysite}:: " . strlen($ligne["whois"]) . " bytes", __FUNCTION__, __FILE__, __LINE__); $whois = unserialize($ligne["whois"]); $jssecond = "<script>LoadAjax('search-stats-categories','{$page}?search-stats-categories={$_GET["site-infos"]}&idcallback={$_GET["idcallback"]}&disposition={$_GET["disposition"]}&disposition={$_GET["disposition"]}&gen-thumbnail={$_GET["gen-thumbnail"]}');</script>"; if (isset($_GET["idcallback"])) { $t = time(); $jsThird = "\n\t\t<div id='tasks-{$t}'></div>\n\t\t<script>\n\t\t\tfunction TasksCallBacks{$t}(){\n\t\t\t\tLoadAjax('tasks-{$t}','squid.miniwebsite.tasks.php?sitename={$_GET["site-infos"]}&idcallback={$_GET["idcallback"]}&TasksCallBacks=TasksCallBacks{$t}&disposition={$_GET["disposition"]}&gen-thumbnail={$_GET["gen-thumbnail"]}');\n\t\t\t}\n\t\t\tTasksCallBacks{$t}();\t\t\n\t\t</script>"; } if (!isset($whois["regrinfo"])) { if (preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+#", $_GET["site-infos"])) { echo $tpl->_ENGINE_parse_body("{$jssecond}{$jsThird}"); return; } $html = "\n\t\t<table style='width:99%' class=form>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/question-48.png'></td>\n\t\t\t<td width=99%>\n\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:Loadjs('{$page}?whoissave-js={$_GET["site-infos"]}&idcallback={$_GET["idcallback"]}&disposition={$_GET["disposition"]}&gen-thumbnail={$_GET["gen-thumbnail"]}');\" \n\t\t\t\tstyle='text-decoration:underline;font-size:14px'>{website_nowhois_error}</a></td>\n\t\t</tr>\n\t\t</tbody>\n\t\t</table>{$jssecond}{$jsThird}"; echo $tpl->_ENGINE_parse_body($html); return; } $lengthMail = strlen($whois["regrinfo"]["owner"]["email"]); if ($lengthMail > 30) { $tt = explode("@", $whois["regrinfo"]["owner"]["email"]); $whois["regrinfo"]["owner"]["email"] = "...@{$tt[1]}"; } $created = $whois["regrinfo"]["domain"]["created"]; $sponsor = $whois["regrinfo"]["domain"]["sponsor"]; $whois["regrinfo"]["owner"]["email"] = str_replace(";", "<br>", $whois["regrinfo"]["owner"]["email"]); $owner = "\n\t<table style='width:100%'>\n\t<tbody>\n\t<tr>\n\t\t<td style='font-size:11px' class=legend valign='top'>mail:</td>\n\t\t<td style='font-size:11px'>{$whois["regrinfo"]["owner"]["email"]}</td>\n\t</tr>\n\t<tr>\n\t\t<td style='font-size:11px' class=legend valign='top'>{name}:</td>\n\t\t<td style='font-size:11px'>{$whois["regrinfo"]["owner"]["name"]}</td>\n\t</tr>\t\n\t<tr>\n\t\t<td style='font-size:11px' class=legend valign='top'>Tel.:</td>\n\t\t<td style='font-size:11px'>{$whois["regrinfo"]["owner"]["phone"]}</td>\n\t</tr>\n\t<tr>\n\t\t<td style='font-size:11px' class=legend valign='top'>{address}:</td>\n\t\t<td style='font-size:11px'>" . @implode(" ", $whois["regrinfo"]["owner"]["address"]) . "</td>\n\t</tr>\t\n\t</tbody>\n\t</table>\t\t\n\t"; $html = "{$jsThird}\n\t\t<table style='width:99%' class=form>\n\t\t<tbody>\n\t\t<tr>\n\t\t\t\n\t\t\t<td style='font-size:16px;height:40px;border-bottom:1px solid #CCCCCC' colspan=2>{$Familysite}<div style='font-size:11px;text-align:right'>sponsor:{$sponsor}</div></td>\n\t\t</tr>\t\t\n\t\t<tr>\n\t\t\t<td width=1% nowrap class=legend>{created_on}:</td>\n\t\t\t<td style='font-size:14px'>{$created}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td width=1% nowrap class=legend valign='top'>{owner}:</td>\n\t\t\t<td style='font-size:14px'>{$owner}</td>\n\t\t</tr>\t\t\n\t\t</tbody>\n\t\t</table>{$jssecond}"; echo $tpl->_ENGINE_parse_body($html); }
function cache_params_popup() { $q = new mysql_squid_builder(); $page = CurrentPageName(); $tpl = new templates(); if (!$q->TABLE_EXISTS("websites_caches_params")) { $q->CheckTables(); } $enabled = 0; $_GET["sitename"] = $q->GetFamilySites($_GET["sitename"]); $sql = "SELECT * FROM websites_caches_params WHERE sitename='{$_GET["sitename"]}'"; $ligne = mysql_fetch_array($q->QUERY_SQL($sql)); if ($ligne["sitename"] != null) { $enabled = 1; } $t = $_GET["t"]; if (!is_numeric($t)) { $t = time(); } $MIN_AGES[60] = "1 {hour}"; $MIN_AGES[120] = "2 {hours}"; $MIN_AGES[360] = "6 {hours}"; $MIN_AGES[720] = "12 {hours}"; $MIN_AGES[1440] = "1 {day}"; $MIN_AGES[2880] = "2 {days}"; $MIN_AGES[10080] = "1 {week}"; $MIN_AGES[20160] = "2 {weeks}"; $MIN_AGES[43200] = "1 {month}"; $MIN_AGES[525600] = "1 {year}"; if (!is_numeric($ligne["MIN_AGE"])) { $ligne["MIN_AGE"] = 1440; } if (!is_numeric($ligne["PERCENT"])) { $ligne["PERCENT"] = 70; } if (!is_numeric($ligne["options"])) { $ligne["options"] = 1; } if (!is_numeric($ligne["MAX_AGE"])) { $ligne["MAX_AGE"] = 10080; } $PERCENTS[9999] = "{no_refresh}"; $PERCENTS[95] = "{very_low}"; $PERCENTS[70] = "{low}"; $PERCENTS[50] = "{medium}"; $PERCENTS[20] = "{high}"; $PERCENTS[10] = "{very_high}"; $PERCENTS[0] = "{all_times}"; $options[0] = "{webserver_override_cache}"; $options[1] = "{cache_override_webserver_medium}"; $options[2] = "{cache_override_webserver_strong}"; if ($_GET["TasksCallBacks"] != null) { $TasksCallBacks = "{$_GET["TasksCallBacks"]}();"; } // 1 -> ignore-no-cache ignore-no-store ignore-private refresh-ims // 2 -> override-expire ignore-no-cache ignore-no-store ignore-private override-lastmod ignore-auth ignore-reload if ($_GET["with-enable"] == "yes") { $enabled = 1; } // see http://archive09.linux.com/feature/153221.html $html = "\n\t<div id='animate-{$t}'></div>\n\t<div style='font-size:18px;font-weight:bold'>{$_GET["sitename"]} {cache_parameters}</div>\n\t<div style='width:98%' class=form>\n\t<table >\n\t\n\t\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{enable}:</td>\n\t\t<td>" . Field_checkbox("enabled-{$t}", 1, $enabled, "CheckCacheEnable{$t}()") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{refresh_website_each}:</td>\n\t\t<td>" . Field_array_Hash($MIN_AGES, "MIN_AGE-{$t}", $ligne["MIN_AGE"], "style:font-size:14px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{refresh_rate}:</td>\n\t\t<td>" . Field_array_Hash($PERCENTS, "PERCENT-{$t}", $ligne["PERCENT"], "style:font-size:14px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{reload_website_each}:</td>\n\t\t<td>" . Field_array_Hash($MIN_AGES, "MAX_AGE-{$t}", $ligne["MAX_AGE"], "style:font-size:14px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:14px'>{cache_priorities}:</td>\n\t\t<td>" . Field_array_Hash($options, "options-{$t}", $ligne["options"], "style:font-size:14px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td colspan=2 align='right'>" . button("{apply}", "SaveCacheWebParams{$t}()", 16) . "</td>\n\t</tr>\n\t</table>\n</div>\n\t<script>\n\t\tvar X_SaveCacheWebParams{$t}= function (obj) {\n\t\t\tvar tableT='{$_GET["table-t"]}';\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>3){alert(results);}\t\n\t\t\tif(document.getElementById('animate-{$t}')){document.getElementById('animate-{$t}').innerHTML='';}\n\t\t\tExecuteByClassName('SearchFunction');\t\n\t\t\tif(tableT.length>0){\n\t\t\t\tif(IsFunctionExists('RechargeTableauDesSitesCaches')){RechargeTableauDesSitesCaches();}\n\t\t\t}\n\t\t\tYahooWin5Hide();\n\t\t\t{$TasksCallBacks}\n\t\t\t\n\t\t\t}\n\t\n\t\n\t\tfunction SaveCacheWebParams{$t}(){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('sitename','{$_GET["sitename"]}');\n\t\t\tXHR.appendData('MIN_AGE',document.getElementById('MIN_AGE-{$t}').value);\n\t\t\tXHR.appendData('MAX_AGE',document.getElementById('MAX_AGE-{$t}').value);\n\t\t\tXHR.appendData('PERCENT',document.getElementById('PERCENT-{$t}').value);\n\t\t\tXHR.appendData('options',document.getElementById('options-{$t}').value);\n\t\t\tif(!document.getElementById('enabled-{$t}').checked){\n\t\t\t\tXHR.appendData('DELETE','{$_GET["sitename"]}');\n\t\t\t}\n\t\t\tAnimateDiv('animate-{$t}');\n\t\t\tXHR.sendAndLoad('{$page}', 'POST',X_SaveCacheWebParams{$t});\n\t\t\t\n\t\t}\n\t\t\n\t\tfunction CheckCacheEnable{$t}(){\n\t\t\tdocument.getElementById('MIN_AGE-{$t}').disabled=true;\n\t\t\tdocument.getElementById('MAX_AGE-{$t}').disabled=true;\n\t\t\tdocument.getElementById('PERCENT-{$t}').disabled=true;\n\t\t\tdocument.getElementById('options-{$t}').disabled=true;\n\t\t\tif(document.getElementById('enabled-{$t}').checked){\n\t\t\t\tdocument.getElementById('MIN_AGE-{$t}').disabled=false;\n\t\t\t\tdocument.getElementById('MAX_AGE-{$t}').disabled=false;\n\t\t\t\tdocument.getElementById('PERCENT-{$t}').disabled=false;\n\t\t\t\tdocument.getElementById('options-{$t}').disabled=false;\t\t\t\n\t\t\t}\n\t\t}\n\t\n\tCheckCacheEnable{$t}();\n\t</script>"; echo $tpl->_ENGINE_parse_body($html); }
function inject_stored_array() { $file = "/var/cache/purge.calculated.db"; $handle = @fopen($file, "r"); if (!$handle) { echo "Failed to open file\n"; return; } $q = new mysql_squid_builder(); $c = 0; while (!feof($handle)) { $c++; $line = trim(fgets($handle, 4096)); if (!preg_match("#^.+?\\s+[0-9]+\\s+([0-9]+)\\s+(.+)#", $line, $re)) { if ($GLOBALS["VERBOSE"]) { echo "{$line} no match\n"; } continue; } $size = intval($re[1]); $uri = $re[2]; $p = parse_url($uri); $sitename = $p["host"]; if (preg_match("#^www\\.(.+)#", $sitename, $rz)) { $sitename = $rz[1]; } if ($GLOBALS["VERBOSE"]) { echo "Found: {$sitename} {$size} {$BIGARRAY[$sitename]["ITEMS"]}+1\n"; } if (!isset($BIGARRAY[$sitename])) { $BIGARRAY[$sitename]["SIZE"] = $size; $BIGARRAY[$sitename]["ITEMS"] = 1; $BIGARRAY[$sitename]["FAMILY"] = $q->GetFamilySites($sitename); continue; } $BIGARRAY[$sitename]["SIZE"] = $BIGARRAY[$sitename]["SIZE"] + $size; $BIGARRAY[$sitename]["ITEMS"]++; $BIGARRAY[$sitename]["FAMILY"] = $q->GetFamilySites($sitename); } return $BIGARRAY; }
function tab() { $tpl = new templates(); $page = CurrentPageName(); $q = new mysql_squid_builder(); $familysite = $q->GetFamilySites($_GET["sitename"]); if (is_numeric($_GET["xtime"])) { $prefix = date("YmdH", $_GET["xtime"]); $tableHour = "squidhour_{$prefix}"; if ($q->TABLE_EXISTS($tableHour)) { $array["thishour"] = "{this_hour}"; } } $array["ident"] = "{$_GET["sitename"]}"; if (!is_numeric($_GET["xtime"])) { if ($_GET["day"] != null) { $_GET["xtime"] = strtotime("{$_GET["day"]} 00:00:00"); } } if (is_numeric($_GET["xtime"])) { $dateT = " " . date("{l} {F} d", $_GET["xtime"]); if ($tpl->language == "fr") { $dateT = date("{l} d {F} ", $_GET["xtime"]); } $array["day"] = "{websites}"; $array["members"] = "{members}"; } if (is_numeric($_GET["week"])) { $dateT = "{week} {$_GET["week"]}"; $array["week"] = $familysite . ":{websites}"; $array["members-week"] = "{members}"; } //$array["popup"]="{status} $dateT"; while (list($num, $ligne) = each($array)) { if ($num == "ident") { $day = date("Y-m-d", $_GET["xtime"]); $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.www-ident.php?popup=yes&www={$_GET["sitename"]}&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "thishour") { $day = date("Y-m-d", $_GET["xtime"]); $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.traffic.statistics.hour.php?day={$day}&sitename={$_GET["sitename"]}&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "day") { $day = date("Y-m-d", $_GET["xtime"]); $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.traffic.statistics.days.php?today-zoom-popup-history=yes&day={$day}&type=size&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "members") { $day = date("Y-m-d", $_GET["xtime"]); $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.traffic.statistics.days.php?today-zoom-popup-members=yes&day={$day}&type=size&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "week") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.week.familysite.php?week={$_GET["week"]}&year={$_GET["year"]}&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } if ($num == "members-week") { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"squid.week.familysite.php?members-week=yes&week={$_GET["week"]}&year={$_GET["year"]}&familysite={$familysite}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); continue; } $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?{$num}=yes&sitename={$_GET["sitename"]}&xtime={$_GET["xtime"]}&week={$_GET["week"]}&year={$_GET["year"]}\"><span style='font-size:14px'>{$ligne}</span></a></li>\n"); } echo build_artica_tabs($html, "main_config_zoomwebsite"); }
function UFDGUARD_UNLOCKED($url) { if (trim($url) == null) { return false; } $q = new mysql_squid_builder(); if ($q->COUNT_ROWS("ufdbunlock") == 0) { return false; } $values = explode(" ", $url); $LOGIN = $values[0]; $IPADDR = $values[1]; $MAC = $values[2]; $XFORWARD = $values[3]; $WWW = $values[4]; $LOGIN = str_replace("%25", "-", $LOGIN); $IPADDR = str_replace("%25", "-", $IPADDR); $MAC = str_replace("%25", "-", $MAC); $XFORWARD = str_replace("%25", "-", $XFORWARD); if ($XFORWARD == "-") { $XFORWARD = null; } if ($MAC == "00:00:00:00:00:00") { $MAC = null; } if ($MAC == "-") { $MAC = null; } if ($LOGIN == "-") { $LOGIN = null; } $IPCalls = new IP(); if ($IPCalls->isIPAddress($XFORWARD)) { $IPADDR = $XFORWARD; } if (preg_match("#(.+?):[0-9]+#", $WWW, $re)) { $WWW = $re[1]; } if (preg_match("#^www\\.(.+)#", $WWW, $re)) { $WWW = $re[1]; } $WWW = $q->GetFamilySites($WWW); if (!isset($GLOBALS["ufdbunlock_c"])) { $GLOBALS["ufdbunlock_c"] = 0; } $GLOBALS["ufdbunlock_c"]++; if ($GLOBALS["ufdbunlock_c"] > 90) { $q->QUERY_SQL("DELETE FROM ufdbunlock WHERE `finaltime` <" . time()); if (!$q->ok) { WLOG("{$q->mysql_error}"); } $GLOBALS["ufdbunlock_c"] = 0; } if ($LOGIN != null) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT md5,finaltime FROM ufdbunlock WHERE `www`='{$WWW}' AND uid='{$LOGIN}'")); if (!$q->ok) { WLOG("{$q->mysql_error}"); } if ($ligne["md5"] != null) { if ($ligne["finaltime"] < time()) { return false; } if ($MAC != null) { $q->QUERY_SQL("UPDATE ufdbunlock SET MAC='{$MAC}' WHERE uid='{$LOGIN}'"); } return true; } } if ($MAC != null) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT md5,finaltime FROM ufdbunlock WHERE `www`='{$WWW}' AND MAC='{$MAC}'")); if (!$q->ok) { WLOG("{$q->mysql_error}"); } if ($ligne["md5"] != null) { if ($ligne["finaltime"] < time()) { return false; } if ($IPADDR != null) { $q->QUERY_SQL("UPDATE ufdbunlock SET ipaddr='{$IPADDR}' WHERE MAC='{$MAC}'"); } return true; } } if ($IPADDR != null) { $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT md5,finaltime FROM ufdbunlock WHERE `www`='{$WWW}' AND ipaddr='{$IPADDR}'")); if (!$q->ok) { WLOG("{$q->mysql_error}"); } $time = time(); if ($ligne["md5"] != null) { if ($ligne["finaltime"] < time()) { WLOG("{$ligne["finaltime"]} < {$time} -> FALSE"); return false; } if ($MAC != null) { $q->QUERY_SQL("UPDATE ufdbunlock SET MAC='{$MAC}' WHERE ipaddr='{$IPADDR}'"); } return true; } } }
function tabs() { $page = CurrentPageName(); $tpl = new templates(); $t = time(); $q = new mysql_squid_builder(); $boot = new boostrap_form(); $date = time_to_date($_GET["xtime"]); $dateT = $tpl->javascript_parse_text("{$date} {$_GET["hour"]}H"); $sitename = $_GET["sitename"]; $familysite = $q->GetFamilySites($sitename); $sitenameenc = urlencode($sitename); $title = $tpl->_ENGINE_parse_body("{member}:{$_GET["uid"]}, {$dateT} «{$sitename}»"); $_GET["uid"] = urlencode($_GET["uid"]); $array["{requests}"] = "{$page}?www-requests=yes&sitename={$sitenameenc}&hour={$_GET["hour"]}&uid={$_GET["uid"]}&xtime={$_GET["xtime"]}"; $array[$familysite] = "miniadm.webstats.website.infos.php?familysite={$familysite}"; echo "<H3>" . $title . "</H3>" . $boot->build_tab($array); }