Example #1
0
function status_squid_left()
{
    if (CACHE_SESSION_GET(__FUNCTION__, __FILE__, 30)) {
        return;
    }
    $tpl = new templates();
    $page = CurrentPageName();
    include_once dirname(__FILE__) . "/ressources/class.status.inc";
    $status = new status();
    $squid_status = $status->Squid_status();
    $q = new mysql();
    $ini = new Bs_IniHandler();
    $sock = new sockets();
    $ini->loadString(base64_decode($sock->getFrameWork("cmd.php?squid-ini-status=yes")));
    $master_version = $ini->_params["SQUID"]["master_version"];
    $master_pid = $ini->_params["SQUID"]["master_pid"];
    $users = new usersMenus();
    $squid = new squidbee();
    if ($ini->_params["SQUID"]["running"] == 0) {
        $img = "status_postfix_bg_failed.png";
        $status = "{stopped}";
        $start = "<hr><div style='text-align:right'>" . button("{start}", "Loadjs('StartStopServices.php?APP=APP_SQUID&cmd=squid-cache&action=start')") . "</div>";
    } else {
        if (preg_match("#2\\.3.*#", $master_version)) {
            $img = 'status_postfix_bg_ok23.png';
        }
        if (preg_match("#2\\.5.*#", $master_version)) {
            $img = 'status_postfix_bg_ok25.png';
        }
        if (preg_match("#2\\.7.*#", $master_version)) {
            $img = 'status_postfix_bg_ok27.png';
        }
        if (preg_match("#2\\.6.*#", $master_version)) {
            $img = 'status_postfix_bg_ok26.png';
        }
        if (preg_match("#2\\.8.*#", $master_version)) {
            $img = 'status_postfix_bg_ok28.png';
        }
        if (preg_match("#2\\.9.*#", $master_version)) {
            $img = 'status_postfix_bg_ok29.png';
        }
        if (preg_match("#3\\.0.*#", $master_version)) {
            $img = 'status_postfix_bg_ok30.png';
        }
        if (preg_match("#3\\.1.*#", $master_version)) {
            $img = 'status_postfix_bg_ok31.png';
        }
        if (preg_match("#3\\.2.*#", $master_version)) {
            $img = 'status_postfix_bg_ok32.png';
        }
        if (preg_match("#3\\.3.*#", $master_version)) {
            $img = 'status_postfix_bg_ok33.png';
        }
        $text = "{service_running}<br>{using_version} {$master_version} {pid} {$master_pid}";
    }
    if ($ini->_params["SQUID"]["icap_enabled"] != '1') {
        $icap = "<table style='width:100%;margin:0px;' " . CellRollOver($js_service) . ">\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/danger16.png'></td>\n\t\t\t<td align='left' nowrap><strong style='color:#D01A1A;font-size:11px'>{no_icap_support}</td>\n\t\t\t<td width=1% align='right'>&nbsp;</td>\n\t\t</tr>\n\t</table>";
    }
    $EnableKavICAPRemote = $sock->GET_INFO("EnableKavICAPRemote");
    $KavICAPRemoteAddr = $sock->GET_INFO("KavICAPRemoteAddr");
    $KavICAPRemotePort = $sock->GET_INFO("KavICAPRemotePort");
    if (!is_numeric($EnableKavICAPRemote)) {
        $EnableKavICAPRemote = 0;
    }
    if ($EnableKavICAPRemote == 1) {
        $fp = @fsockopen($KavICAPRemoteAddr, $KavICAPRemotePort, $errno, $errstr, 1);
        if (!$fp) {
            $text_kavicap_error = "<div>{kavicap_unavailable_text}<br><strong>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.kavicap.php');\" style='font-size:12px;color:#D70707;text-decoration:underline'>{$KavICAPRemoteAddr}:{$KavICAPRemotePort}</a><br>{$errstr}</div>";
        }
        @fclose($fp);
    }
    $q = new mysql_squid_builder();
    if (!$q->TestingConnection()) {
        $img = "status_postfix_bg_failed.png";
        $title = "{MYSQL_ERROR}";
        $text_error_sql = "<div><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('squid.mysql.php');\" \n\t\tstyle='font-size:12px;color:#D70707;text-decoration:underline'>{$title}:{$q->mysql_error}</a></div>";
    }
    $q = new mysql_squid_builder();
    $requests = $q->EVENTS_SUM();
    $requests = numberFormat($requests, 0, "", " ");
    $tableblock = date('Ymd') . "_blocked";
    $ligneW = $q->COUNT_ROWS($tableblock);
    $blocked_today = numberFormat($ligneW["tcount"], 0, "", " ") . " {blocked_websites} {this_day}";
    $q = new mysql_squid_builder();
    $websitesnums = $q->COUNT_ROWS("dansguardian_sitesinfos", "artica_backup");
    $websitesnums = numberFormat($websitesnums, 0, "", " ");
    $q = new mysql_squid_builder();
    $categories = $q->COUNT_ROWS("dansguardian_community_categories");
    $categories = numberFormat($categories, 0, "", " ");
    $sock = new sockets();
    $sock->SET_INFO("squidStatsCategoriesNum", $categories);
    $sock->SET_INFO("squidStatsWebSitesNum", $websitesnums);
    $sock->SET_INFO("squidStatsBlockedToday", $blocked_today);
    $sock->SET_INFO("squidStatsRequestNumber", $requests);
    $migration_pid = unserialize(base64_decode($sock->getFrameWork("squid.php?migration-stats=yes")));
    if (is_array($migration_pid)) {
        $text_script = "<span style='color:#B80000;font-size:13px'>{migration_script_run_text} PID:{$migration_pid[0]} {since}:{$migration_pid[1]}Mn</span>";
    }
    if ($users->KAV4PROXY_INSTALLED) {
        $img = "info-18.png";
        $text = "{enabled}";
        if ($squid->enable_kavproxy != 1) {
            $text = "{disabled}";
            $img = "status_warning.gif";
        }
        $services_enabled = $services_enabled . "\n\t\t\t<tr " . CellRollOver("Loadjs('squid.popups.php?script=plugins')") . ">\n\t\t\t\t<td width=1%><img src='img/{$img}'></td>\n\t\t\t\t<td class=legend style='font-size:13px;' align='left' width=1% nowrap>{APP_KAV4PROXY}:</td>\n\t\t\t\t<td class=legend style='font-size:14px' align='left' width=100%>{$text}</td>\n\t\t\t</tr>\n\t\t\t";
    }
    if ($users->APP_UFDBGUARD_INSTALLED) {
        $img = "info-18.png";
        $text = "{enabled}";
        $EnableUfdbGuard = $sock->GET_INFO("EnableUfdbGuard");
        if ($EnableUfdbGuard != 1) {
            $text = "{disabled}";
            $img = "status_warning.gif";
        }
        $services_enabled = $services_enabled . "\n\t\t\t<tr " . CellRollOver("Loadjs('squid.popups.php?script=plugins')") . ">\n\t\t\t\t<td width=1%><img src='img/{$img}'></td>\n\t\t\t\t<td class=legend style='font-size:13px;' nowrap width=1% align='left'>{APP_UFDBGUARD}:</td>\n\t\t\t\t<td class=legend style='font-size:14px' width=100% align='left'>{$text}</td>\n\t\t\t</tr>\n\t\t\t";
    }
    $design = "\n\t{$text_error_sql}\n\t{$text_script}\n\t{$text_kavicap_error}\n\t<table style='width:250px;margin-top:10px;' class=form>\n\t<tbody>\n\t\t<tr>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td class=legend nowrap>{version}:</td>\n\t\t\t<td style='font-size:14px'>{$master_version}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td class=legend>PID:</td>\n\t\t\t<td style='font-size:14px'>{$master_pid}</td>\n\t\t</tr>\n\t\t\t{$services_enabled}\n\t\t</tbody>\n\t</table>\t\n\t</table>\n\t<div style='width:100%;text-align:right'>" . imgtootltip("refresh-24.png", "{refresh}", "LoadAjax('squid-status','squid.main.quicklinks.php?status=yes');") . "</div>\n\t\n\t";
    $html = "\n\t{$design}\n\t<center>\n\t\n\t\t<div id='squid-status-stats' class=form style='width:90%'></div>\n\t</center>\n\t\n\t\n\t<script>\n\t\tLoadAjax('squid-status-stats','squid.traffic.statistics.php?squid-status-stats=yes');\t\n\t\tLoadAjax('squid-services','{$page}?squid-services=yes');\n\t</script>\n\t";
    $html = $tpl->_ENGINE_parse_body($html);
    CACHE_SESSION_SET(__FUNCTION__, __FILE__, $html);
}
Example #2
0
function checkdatabase()
{
    $f["webfilter_aclsdynamic"] = true;
    $f["webfilter_aclsdynlogs"] = true;
    $f["webfilter_assoc_groups"] = true;
    $f["webfilter_avwhitedoms"] = true;
    $f["webfilter_bannedexts"] = true;
    $f["webfilter_bannedextsdoms"] = true;
    $f["webfilter_blkcnt"] = true;
    $f["webfilter_blkgp"] = true;
    $f["webfilter_blklnk"] = true;
    $f["webfilter_blks"] = true;
    $f["webfilter_certs"] = true;
    $f["webfilter_dnsbl"] = true;
    $f["webfilter_group"] = true;
    $f["webfilter_members"] = true;
    $f["webfilter_rules"] = true;
    $f["webfilter_terms"] = true;
    $f["webfilter_termsassoc"] = true;
    $f["webfilter_termsg"] = true;
    $f["webfilter_ufdbexpr"] = true;
    $f["webfilter_ufdbexprassoc"] = true;
    $f["webfilter_updateev"] = true;
    $f["webfilters_backupeddbs"] = true;
    $f["webfilters_bigcatzlogs"] = true;
    $f["webfilters_blkwhlts"] = true;
    $f["webfilters_categories_caches"] = true;
    $f["webfilters_databases_disk"] = true;
    $f["webfilters_dbstats"] = true;
    $f["webfilters_dtimes_blks"] = true;
    $f["webfilters_dtimes_rules"] = true;
    $f["webfilters_ipaddr"] = true;
    $f["webfilters_nodes"] = true;
    $f["webfilters_quotas"] = true;
    $f["webfilters_rewriteitems"] = true;
    $f["webfilters_rewriterules"] = true;
    $f["webfilters_schedules"] = true;
    $f["webfilters_sqaclaccess"] = true;
    $f["webfilters_sqacllinks"] = true;
    $f["webfilters_sqacls"] = true;
    $f["webfilters_sqaclsports"] = true;
    $f["webfilters_sqgroups"] = true;
    $f["webfilters_sqitems"] = true;
    $f["webfilters_sqtimes_assoc"] = true;
    $f["webfilters_sqtimes_rules"] = true;
    $f["webfilters_thumbnails"] = true;
    $f["webfilters_updates"] = true;
    $f["webfilters_usersasks"] = true;
    $f["websites_caches_params"] = true;
    $q = new mysql_squid_builder();
    if (!$q->TestingConnection()) {
        echo "Starting......: " . date("H:i:s") . " [MYSQL]: Connection failed...\n";
        return;
    }
    $build = false;
    while (list($tablename, $DGRULE) = each($f)) {
        if (!$q->TABLE_EXISTS($tablename)) {
            echo "Starting......: " . date("H:i:s") . " [MYSQL]: Missing table `{$tablename}`\n";
            $build = true;
        }
    }
    if ($build) {
        echo "Starting......: " . date("H:i:s") . " [MYSQL]: Construct database\n";
        $q->CheckTables(null, true);
        $q->CheckTablesICAP();
    }
}
Example #3
0
function squid_mysql_status()
{
    $q = new mysql_squid_builder();
    $img = "ok64.png";
    $title = "{MYSQL_CONNECTION}";
    $text = date('H:i:s') . "<br>" . $q->mysql_server . ":" . $q->mysql_port;
    if (!$q->TestingConnection()) {
        $img = "danger64.png";
        $title = "{MYSQL_ERROR}";
        $text = $text . "<br>" . $q->mysql_error;
    }
    $tpl = new templates();
    echo Paragraphe($img, $title, $text, null, $text) . "<div style='text-align:right'>" . imgtootltip("refresh-24.png", "{refresh}", "RefreshMysqlConnection()");
}
Example #4
0
include_once dirname(__FILE__) . '/ressources/class.mysql.squid.builder.php';
$file = $argv[1];
$_GET["DEBUG"] = false;
if (trim(strtolower($argv[2])) == "--debug") {
    $_GET["DEBUG"] = true;
}
if ($argv[1] == '--rebuild-sites') {
    rebuildsites();
    die('finish');
}
die("depreciated");
if (!file_exists($file)) {
    write_syslog(" Unable to stat {$file}", __FILE__);
}
$q = new mysql_squid_builder();
if (!$q->TestingConnection()) {
    write_syslog("Unable to logon to mysql", __FILE__);
}
$datas_file = file_get_contents($file);
$datas = explode("\n", $datas_file);
write_syslog("{$file}: " . Count($datas) . " line(s) with " . strlen($datas_file) . " bytes length", __FILE__);
while (list($num, $val) = each($datas)) {
    if (trim($val == null)) {
        continue;
    }
    if ($_GET["DEBUG"]) {
        echo "Parsing line number {$num}/" . Count($datas) . "\n";
    }
    if (!parseDansLine($val)) {
        return;
    }