function week_consumption_graph($xtime = 0)
{
    $cache_file = "/usr/share/artica-postfix/ressources/logs/web/" . basename(__FILE__) . "." . md5(serialize($_GET)) . "." . __FUNCTION__ . '.cache';
    $time = file_time_min_Web($cache_file);
    //if($time<360){echo @file_get_contents($cache_file);return;}
    if ($xtime == -1) {
        $d = date("Y-m-d");
        $sqlq = "DATE_FORMAT(days,'%Y-%m-%d')='{$d}'";
    }
    if ($xtime == 0) {
        $d = date("W");
        $sqlq = "WEEK(days)=WEEK(NOW()) AND YEAR(days)=YEAR(NOW())";
    }
    if ($xtime == 1) {
        $d = date("Y-m");
        $sqlq = "MONTH(days)=MONTH(NOW()) AND YEAR(days)=YEAR(NOW())";
    }
    $page = CurrentPageName();
    $gp = new artica_graphs(dirname(__FILE__) . "/ressources/logs/web/squid.{$d}.consumption.png", 0);
    $tpl = new templates();
    //$gp->ImageMap="javascript:Loadjs('squid.stats.category.php?category-js=yes&time=week&category=";
    $html = "<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t<th>{size}</th>\n\t<th>{members}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $sql = "SELECT SUM(size) as tsum,CLIENT FROM squid_events_clients_day WHERE \n\t{$sqlq}  GROUP BY CLIENT ORDER BY tsum DESC LIMIT 0,10";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_events");
    if (mysql_num_rows($results) == 0) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("<H2>{NO_DATA_COME_BACK_LATER}</H2><hr>{$sql}</hr>");
        return;
    }
    if (!$q->ok) {
        echo $q->mysql_error;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (trim($ligne["CLIENT"]) == null) {
            $ligne["CLIENT"] = "unknown";
        }
        $ligne["tsum"] = FormatBytes($ligne["tsum"] / 1024);
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $js = "Loadjs('squid.stats.client.php?client-js=yes&time={$xtime}&client=" . urlencode($ligne["CLIENT"]) . "')";
        $html = $html . "\n\t\t\t<tr class={$classtr}>\n\t\t\t<td style='font-size:15px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\">{$ligne["tsum"]}</a></td>\n\t\t\t<td style='font-size:15px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\">{$ligne["CLIENT"]}</a></td>\n\t\t\t</tr>";
        $gp->xdata[] = $ligne["tsum"];
        $gp->ydata[] = $ligne["CLIENT"];
    }
    $gp->width = 560;
    $gp->height = 580;
    $gp->ViewValues = false;
    $gp->x_title = "{categories}";
    $gp->pie();
    $html = $tpl->_ENGINE_parse_body("<img src='ressources/logs/web/squid.{$d}.consumption.png'  border=0><hr>{$html}</table>");
    @file_put_contents($cache_file, $html);
    echo $html;
}
function BACKUP_EMAIL_BEHAVIOR_DASHBOARD()
{
    $tpl = new templates();
    $ou = $_SESSION["ou"];
    @mkdir("/usr/share/artica-postfix/ressources/web/cache_{$ou}", 0755, true);
    $filebackup = "/usr/share/artica-postfix/ressources/web/cache_{$ou}/BACKUP_EMAIL_BEHAVIOR_DASHBOARD";
    if (file_time_min_Web($filebackup) > 30) {
        $q = new postgres_sql();
        $ldap = new clladp();
        $domains = $ldap->hash_get_domains_ou($ou);
        while (list($domain, $MAIN) = each($domains)) {
            $domain = trim(strtolower($domain));
            if ($domain == null) {
                continue;
            }
            $FDOMS[] = "domainto='{$domain}'";
            $FDOMS2[] = "domainfrom='{$domain}'";
        }
        $imploded1 = @implode(" OR ", $FDOMS);
        $imploded2 = @implode(" OR ", $FDOMS2);
        $sql = "select count(*) as tcount, SUM(size) as size FROM backupmsg WHERE ({$imploded1}) OR ({$imploded2})";
        $ligne = pg_fetch_array($q->QUERY_SQL($sql));
        @unlink($filebackup);
        @file_put_contents($filebackup, serialize($ligne));
    }
    $ligne = unserialize(@file_get_contents($filebackup));
    $tcount = $ligne["tcount"];
    $size = $ligne["size"];
    if ($tcount == 0) {
        echo $tpl->_ENGINE_parse_body("0 {message}");
        return;
    }
    $size = FormatBytes($size / 1024);
    $tcount = FormatNumber($tcount);
    echo $tpl->_ENGINE_parse_body("<a href=\"javascript:blur();\"\n\t\tOnClick=\"javascript:GotoBackupMails()\"\n\t\tstyle='text-decoration:underline'>{$tcount} {messages}</a> ({$size})");
}
Example #3
0
function wifidog_login($error = null)
{
    header('Content-Type: text/html; charset=iso-8859-1');
    $REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
    session_start();
    $ipClass = new IP();
    $USE_TERMS_ACCEPTED = false;
    $gateway_addr = $_REQUEST["gw_address"];
    $gw_port = $_REQUEST["gw_port"];
    $gw_id = $_REQUEST["gw_id"];
    $ARP = $_REQUEST["mac"];
    $url = $_REQUEST["url"];
    $cachefile = "{$GLOBALS["CACHEDIR"]}/{$ARP}." . md5($error . serialize($_REQUEST)) . "." . __FUNCTION__ . ".html";
    if (isset($_POST["wifidog-terms"])) {
        $_SESSION["USE_TERMS_ACCEPTED"] = true;
        $USE_TERMS_ACCEPTED = true;
    }
    if (isset($_SESSION["USE_TERMS_ACCEPTED"])) {
        $USE_TERMS_ACCEPTED = true;
    }
    if (isset($_GET["clear"])) {
        unset($_SESSION["WIFIDOG_RULES"]);
    }
    if (!$ipClass->IsvalidMAC($ARP)) {
        $CacheError1 = "{$GLOBALS["CACHEDIR"]}/hostspot_network_incompatible.html";
        if (!is_file($CacheError1)) {
            $tpl = new templates();
            $text_form = $tpl->_ENGINE_parse_body(FATAL_ERROR_SHOW_128("{hostspot_network_incompatible}"));
            @file_put_contents($CacheError1, $text_form);
        } else {
            $text_form = @file_get_contents($CacheError1);
        }
    }
    if (!isset($_REQUEST["token"])) {
        $_REQUEST["token"] = generateToken($ARP);
    }
    $wifidog_build_uri = wifidog_build_uri();
    $uriext = $wifidog_build_uri[0];
    $HiddenFields = $wifidog_build_uri[1];
    $wifidog_templates = new wifidog_rules();
    $_SESSION["WIFIDOG_RULES"] = $wifidog_templates->ruleid;
    if ($GLOBALS["HOTSPOT_DEBUG"]) {
        wifidog_logs("Rule number {$_SESSION["WIFIDOG_RULES"]}", __FUNCTION__, __LINE__);
    }
    $wifidog_rule = new wifidog_settings($_SESSION["WIFIDOG_RULES"]);
    $ArticaHotSpotNowPassword = intval($wifidog_rule->GET_INFO("ArticaHotSpotNowPassword"));
    $ENABLED_REDIRECT_LOGIN = intval($wifidog_rule->GET_INFO("ENABLED_REDIRECT_LOGIN"));
    $ENABLED_SMTP = intval($wifidog_rule->GET_INFO("ENABLED_SMTP"));
    $ENABLED_AUTO_LOGIN = intval($wifidog_rule->GET_INFO("ENABLED_AUTO_LOGIN"));
    $USE_TERMS = intval($wifidog_rule->GET_INFO("USE_TERMS"));
    $ALLOW_RECOVER_PASS = intval($wifidog_rule->GET_INFO("ALLOW_RECOVER_PASS"));
    $DO_NOT_AUTENTICATE = intval($wifidog_rule->GET_INFO("DO_NOT_AUTENTICATE"));
    $SMS_REGISTER = intval($wifidog_rule->GET_INFO("SMS_REGISTER"));
    $BOUNCE_AUTH = intval($wifidog_rule->GET_INFO("BOUNCE_AUTH"));
    if ($BOUNCE_AUTH == 1) {
        if ($ARP != null) {
            $CacheARP = "{$GLOBALS["CACHEDIR"]}/{$ARP}";
            $ligne["uid"] = null;
            if (is_file($CacheARP)) {
                if (file_time_min_Web($CacheARP) > 15) {
                    @unlink($CacheARP);
                }
            }
            if (!is_file($CacheARP)) {
                $q = new mysql_hotspot();
                $sql = "SELECT * FROM hotspot_members WHERE MAC='{$ARP}'";
                $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
                $uid = $ligne["uid"];
            } else {
                $ligne["uid"] = @file_get_contents($CacheARP);
            }
            if ($ligne["uid"] != null) {
                $array["LOGIN"] = $ligne["uid"];
                $array["IPADDR"] = null;
                $array["MAC"] = $ARP;
                $array["ARP"] = $ARP;
                $array["token"] = $_REQUEST["token"];
                $array["ruleid"] = $_SESSION["WIFIDOG_RULES"];
                if (UnLock($array)) {
                    wifidog_redirect_after_login();
                    return;
                }
            }
        }
    }
    if ($USE_TERMS == 1) {
        if (!$USE_TERMS_ACCEPTED) {
            if ($GLOBALS["HOTSPOT_DEBUG"]) {
                wifidog_logs("->wifidog_terms()", __FUNCTION__, __LINE__);
            }
            return wifidog_terms($ARP);
        }
    }
    $wifidog_templates = new wifidog_templates($_SESSION["WIFIDOG_RULES"]);
    if ($SMS_REGISTER == 1) {
        if ($GLOBALS["HOTSPOT_DEBUG"]) {
            wifidog_logs("->wifidog_register_sms()", __FUNCTION__, __LINE__);
        }
        wifidog_register_sms();
        return;
    }
    if ($ENABLED_SMTP == 1) {
        if ($ENABLED_REDIRECT_LOGIN == 1) {
            wifidog_register();
            return;
        }
    }
    if (is_file($cachefile)) {
        echo @file_get_contents($cachefile);
        return;
    }
    $page = CurrentPageName();
    $tpl = new templates();
    $username = $wifidog_templates->LabelUsername;
    $password = $wifidog_templates->LabelPassword;
    $lost_password_text = $wifidog_templates->LostPasswordLink;
    $please_sign_in = $tpl->_ENGINE_parse_body("{please_sign_in}");
    $page = CurrentPageName();
    $t = time();
    unset($_SESSION["HOTSPOT_AUTO_RECOVER"]);
    $_SESSION["HOTSPOT_REDIRECT_URL"] = $url;
    $url_encoded = urlencode($url);
    if ($DO_NOT_AUTENTICATE == 1) {
        $ArticaHotSpotNowPassword = 1;
    }
    $f[] = "<p>{$wifidog_templates->WelcomeMessage}</p>";
    $f[] = "<div id='content'>";
    $f[] = "";
    $f[] = "<form id='wifidogform' action=\"{$page}\" method=\"post\">";
    $f[] = "<input type=\"hidden\" name=\"ruleid\" id=\"ruleid\" value='{$_SESSION["WIFIDOG_RULES"]}'>";
    $f[] = "{$HiddenFields}";
    if ($wifidog_templates->FORM_HEAD != null) {
        $f[] = "<p>{$wifidog_templates->FORM_HEAD}</p>";
    }
    $f[] = "<table style='width:100%'>";
    $f[] = "<tr>";
    $f[] = "<td class=legend>{$username}:</td>";
    $f[] = "<td>\n\t<input type=\"text\" \n\t\tname=\"username\" \n\t\tid=\"username\"\n\t\tvalue=\"{$_REQUEST["username"]}\" \n\t\tonfocus=\"this.setAttribute('class','active');RemoveLogonCSS();\" \n\t\tonblur=\"this.removeAttribute('class');\" \n\t\tOnKeyPress=\"javascript:SendLogon{$t}(event)\">";
    $f[] = "</td>";
    $f[] = "</tr>";
    if ($ArticaHotSpotNowPassword == 0) {
        $f[] = "<tr>";
        $f[] = "<td class=legend>{$password}:</td>";
        $f[] = "<td><input type=\"password\" name=\"password\" \n\t\t\t\tvalue=\"{$_REQUEST["password"]}\"\n\t\t\t\tid=\"password\" onfocus=\"this.setAttribute('class','active');RemoveLogonCSS();\" \n\t\t\t\tonblur=\"this.removeAttribute('class');\" OnKeyPress=\"javascript:SendLogon{$t}(event)\">";
        $f[] = "</td>";
        $f[] = "</tr>";
    } else {
        $f[] = "<input type=\"hidden\" name=\"password\" id=\"password\" value=''>";
    }
    $f[] = "<tr><td colspan=2>&nbsp;</td></tr>";
    $f[] = "<tr><td colspan=2 align='right' class=ButtonCell>";
    if ($ENABLED_AUTO_LOGIN == 1) {
        $f[] = "<a data-loading-text=\"Chargement...\"\n\t\tstyle=\"text-transform:capitalize\"\n\t\tclass=\"Button2014 Button2014-success Button2014-lg\"\n\t\tid=\"fb92ae5e1f7bbea3b5044cbcdd40f088\"\n\t\thref=\"{$page}?wifidog-register=yes&{$uriext}\">&laquo;&nbsp;{$wifidog_templates->RegisterTitle}&nbsp;&raquo;</a>";
    }
    $f[] = "<a data-loading-text=\"Chargement...\" \n\t\t\tstyle=\"text-transform:capitalize\" \n\t\t\tclass=\"Button2014 Button2014-success Button2014-lg\" \n\t\t\tid=\"fb92ae5e1f7bbea3b5044cbcdd40f088\" \n\t\t\tonclick=\"javascript:document.forms['wifidogform'].submit();\" \n\t\t\thref=\"javascript:Blurz()\">&laquo;&nbsp;" . $wifidog_templates->char($wifidog_templates->ConnectionButton) . "&nbsp;&raquo;</a>";
    $f[] = "</td>\n\t</tr>";
    if ($ENABLED_SMTP == 1) {
        if ($ALLOW_RECOVER_PASS == 1) {
            if ($ArticaHotSpotNowPassword == 0) {
                $f[] = "<tr><td class=legend colspan=2>";
                $f[] = "<a href=\"{$page}?wifidog-recover=yes&email={$_REQUEST["username"]}&{$uriext}\">{$lost_password_text}</a></div>";
                $f[] = "</td></tr>";
            }
        }
    }
    $f[] = "</table>";
    $f[] = "\t\t\t</form>\t";
    $f[] = "</div>\n\t<script>\n\t\tfunction SendLogon{$t}(e){\n\t\t\tif(!checkEnter(e)){return;}\n\t\t\tdocument.forms['wifidogform'].submit();\n\t\t}\n\t</script>\n\t\n";
    $text_form = @implode("\n", $f);
    $page = BuildFullPage($text_form, $error);
    @file_put_contents($cachefile, $page);
    echo $page;
}
Example #4
0
function status_right()
{
    $t = time();
    $page = CurrentPageName();
    if (isset($_GET["newfrontend"])) {
        $newfrontend = true;
    }
    if ($GLOBALS["AS_ROOT"]) {
        $newfrontend = true;
    }
    $tpl = new templates();
    if (!$GLOBALS["AS_ROOT"]) {
        if (is_file("/usr/share/artica-postfix/ressources/logs/web/admin.index.status.html")) {
            $time = file_time_min_Web("/usr/share/artica-postfix/ressources/logs/web/admin.index.status.html");
            if ($time < 5) {
                $data = @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/admin.index.status.html");
                if (strlen($data) > 45) {
                    echo $tpl->_ENGINE_parse_body($data);
                    return;
                }
            }
        }
        $sock = new sockets();
        $sock->getFrameWork('cmd.php?ForceRefreshRight=yes');
        if ($GLOBALS["VERBOSE"]) {
            writelogs("[DEBUG] -> echo next scripts...", __FUNCTION__, __FILE__, __LINE__);
        }
    }
    if (!$newfrontend) {
        $infos = "LoadAjaxTiny('right-status-infos','admin.left.php?part1=yes');";
    } else {
        $ajaxadd = "&newfrontend=yes";
    }
    echo "\n\t<div id='mem_status_computer' style='text-align:center;width:100%;margin:10px;margin-top:0px'></div>\n\t<div id='right-status-infos'></div>\n\t<div id='IMAGE_STATUS_INFO' style='width:100%;min-height:405px' class=form></div>\t\n\t<script>\n\tLoadAjax('mem_status_computer','{$page}?memcomputer=yes{$ajaxadd}',true);\n\t\n\tfunction IMAGE_STATUS_INFO_{$t}(){\n\t\tLoadAjax('IMAGE_STATUS_INFO','admin.index.right-image.php',true);\n\t}\n\t\n\tsetTimeout('IMAGE_STATUS_INFO_{$t}()',1500);\n\t</script>\n\t\n\t";
}