Example #1
0
function status_computer()
{
    if (!$GLOBALS["AS_ROOT"]) {
        if (!$GLOBALS["VERBOSE"]) {
            if (is_file("/usr/share/artica-postfix/ressources/logs/web/admin.index.memory.html")) {
                $data = @file_get_contents("/usr/share/artica-postfix/ressources/logs/web/admin.index.memory.html");
                if (strlen($data) > 45) {
                    $tpl = new templates();
                    echo $tpl->_ENGINE_parse_body($data);
                    return;
                }
            }
        }
    }
    $page = CurrentPageName();
    $sock = new sockets();
    $newfrontend = false;
    if (isset($_GET["newfrontend"])) {
        $newfrontend = true;
    }
    if (!$GLOBALS["VERBOSE"]) {
        if (!$GLOBALS["AS_ROOT"]) {
            if (GET_CACHED(__FILE__, __FUNCTION__, "time", false, 3)) {
                return;
            }
            if (internal_load() > 1.2) {
                if (GET_CACHED(__FILE__, __FUNCTION__)) {
                    return;
                }
            }
        }
    }
    if ($newfrontend) {
        $ajaxadd = "&newfrontend=yes";
    }
    include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc";
    $html = "<div id='admin-index-status-mysql'></div>\n\t<script>LoadAjaxTiny('admin-index-status-mysql','{$page}?admin-index-status-mysql=yes');</script>";
    $os = new os_system();
    if ($GLOBALS["VERBOSE"]) {
        echo "os->html_Memory_usage()<br>\n";
    }
    $html = $html . RoundedLightGrey($os->html_Memory_usage()) . "<br>\n\t<script>\n\tif(document.getElementById('left_status')){\n\t\tvar content=document.getElementById('left_status').innerHTML;\n\t\tif(content.length<5){\n\t\t\tLoadAjax('left_status','{$page}?status=left{$ajaxadd}',true);\n\t\t}\n\t}\n\t</script>\n\t\n\t\n\t";
    if ($GLOBALS["AS_ROOT"]) {
        include_once dirname(__FILE__) . '/framework/class.unix.inc';
        include_once dirname(__FILE__) . '/framework/frame.class.inc';
        @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/admin.index.memory.html", $html);
        return;
    }
    SET_CACHED(__FILE__, __FUNCTION__, $html);
    SET_CACHED(__FILE__, __FUNCTION__, "time", $html);
    echo $html;
}
function left_menus_actions()
{
    $cachePage = dirname(__FILE__) . "/ressources/logs/web/" . basename(__FILE__) . "." . __FUNCTION__;
    if (!$GLOBALS["AS_ROOT"]) {
        if (is_file($cachePage)) {
            $users = new usersMenus();
            if ($users->AsSystemAdministrator) {
                $data = @file_get_contents($cachePage);
                if (strlen($data) > 45) {
                    $tpl = new templates();
                    echo $tpl->_ENGINE_parse_body($data) . wizards();
                    return;
                }
            }
        }
    }
    $users = new usersMenus();
    if (!$GLOBALS["AS_ROOT"]) {
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " Saving {$cachePage}\n";
        }
        if (GET_CACHED(__FILE__, __FUNCTION__, null, false, 1)) {
            return;
        }
        if (internal_load() > 1.2) {
            if (GET_CACHED(__FILE__, __FUNCTION__)) {
                return;
            }
        }
    } else {
        $users->AsPostfixAdministrator = true;
        $users->AsAnAdministratorGeneric = true;
        $users->AsWebStatisticsAdministrator = true;
        $users->AsPostfixAdministrator = true;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Saving {$cachePage}\n";
    }
    $sock = new sockets();
    $tpl = new templates();
    $f = array();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    if (!is_numeric($EnableRemoteStatisticsAppliance)) {
        $EnableRemoteStatisticsAppliance = 0;
    }
    $EnableWebProxyStatsAppliance = $sock->GET_INFO("EnableWebProxyStatsAppliance");
    if ($EnableWebProxyStatsAppliance == 1) {
        $users->SQUID_INSTALLED = true;
    }
    $OnlySMTP = false;
    if ($users->SMTP_APPLIANCE) {
        $OnlySMTP = true;
    }
    if ($users->KASPERSKY_SMTP_APPLIANCE) {
        $OnlySMTP = true;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Saving {$cachePage}\n";
    }
    if (!$users->PROXYTINY_APPLIANCE) {
        if ($users->SQUID_INSTALLED) {
            if ($users->AsWebStatisticsAdministrator) {
                $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
                if (!is_numeric($SQUIDEnable)) {
                    $SQUIDEnable = 1;
                }
                if ($EnableRemoteStatisticsAppliance == 0) {
                    if ($SQUIDEnable == 1) {
                        if (!$users->SQUID_REVERSE_APPLIANCE) {
                            $f[] = left_menus_format("CATEGORIZE_A_WEBSITE", "32-categories-add.png", "Loadjs('squid.visited.php?add-www=yes')", "ADDWEBSITE_PROXY_EXPLAIN");
                            $f[] = left_menus_format("whitelist_website", "domain-whitelist-w32.png", "Loadjs('squid.urlrewriteaccessdeny.php?add-www-js=yes')", "whitelist_website_explain");
                            $f[] = left_menus_format("test_categories", "loupe-32.png", "Loadjs('squid.category.tests.php')", "squid_test_categories_explain");
                        }
                    }
                }
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Saving {$cachePage}\n";
    }
    if ($users->POSTFIX_INSTALLED) {
        $EnablePostfixMultiInstance = $sock->GET_INFO("EnablePostfixMultiInstance");
        if (!is_numeric($EnablePostfixMultiInstance)) {
            $EnablePostfixMultiInstance = 0;
        }
        if ($EnablePostfixMultiInstance == 1) {
            if ($users->AsPostfixAdministrator) {
                $f[] = left_menus_format("NEW_SMTP_INSTANCE", "32-network-server-add.png", "Loadjs('postfix.multiple.instances.wizard.php')");
            }
        }
        $EnableAmavisDaemon = trim($sock->GET_INFO("EnableAmavisDaemon", true));
        if (!is_numeric($EnableAmavisDaemon)) {
            $EnableAmavisDaemon = 0;
        }
        if ($users->AsAnAdministratorGeneric) {
            $f[] = left_menus_format("check_recipients", "check-32.png", "only:Loadjs('postfix.debug.mx.php')");
            if ($users->AMAVIS_INSTALLED) {
                if ($users->spamassassin_installed) {
                    if ($EnableAmavisDaemon == 1) {
                        $f[] = left_menus_format("SPAMASSASSIN_RULES", "script-32.png", "only:Loadjs('spamassassin.rules.php?byid=admin-start_page')");
                    }
                }
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Saving {$cachePage} users->POWER_DNS_INSTALLED = {$users->POWER_DNS_INSTALLED} users->AsAnAdministratorGeneric={$users->AsAnAdministratorGeneric}\n";
    }
    if ($users->AsAnAdministratorGeneric) {
        if (!$OnlySMTP) {
            $f[] = left_menus_format("explorer", "explorer-32.png", "only:Loadjs('tree.php');", 'SHARE_FOLDER_TEXT');
        }
        if (!$OnlySMTP) {
            $f[] = left_menus_format("ADD_COMPUTER", "computer-32-add.png", "only:YahooUser(1051,'domains.edit.user.php?userid=newcomputer\$&ajaxmode=yes','New computer');", "ADD_COMPUTER_TEXT");
        }
        if ($users->POWER_DNS_INSTALLED) {
            $DisablePowerDnsManagement = $sock->GET_INFO("DisablePowerDnsManagement");
            $EnablePDNS = $sock->GET_INFO("EnablePDNS");
            $PowerDNSMySQLEngine = $sock->GET_INFO("PowerDNSMySQLEngine");
            if (!is_numeric($EnablePDNS)) {
                $EnablePDNS = 0;
            }
            if (!is_numeric($PowerDNSMySQLEngine)) {
                $PowerDNSMySQLEngine = 1;
            }
            if (!is_numeric($DisablePowerDnsManagement)) {
                $DisablePowerDnsManagement = 0;
            }
            if ($DisablePowerDnsManagement == 0) {
                if ($EnablePDNS == 1) {
                    $f[] = left_menus_format("new_dns_entry", "filter-add-32.png", "only:YahooWin5('550','pdns.mysql.php?item-id=0&t={$t}','PowerDNS');", "new_dns_entry");
                }
            }
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Saving {$cachePage} -> " . count($f) . "\n";
    }
    if (count($f) > 0) {
        $html = "\n\t\t<hr>\n\t\t<div style='font-size:16px;color:white;margin-top:8px;text-transform:capitalize;'>{actions}:</div>\n\t\t<table style='width:99%' class=form><tbody>\n\t\t" . @implode("\n", $f) . "\n\t\t</tbody>\n\t\t</table;\n\t\t";
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " AS ROOT={$GLOBALS["AS_ROOT"]}\n";
        }
        if ($GLOBALS["AS_ROOT"]) {
            if ($GLOBALS["VERBOSE"]) {
                echo __LINE__ . " Saving {$cachePage}\n";
            }
            @mkdir(dirname($cachePage), 0777, true);
            @file_put_contents($cachePage, $html);
            @chmod($cachePage, 0777);
            return;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " Saving {$cachePage} ->" . count($f) . "\n";
        }
        $html = $tpl->_ENGINE_parse_body($html);
        SET_CACHED(__FILE__, __FUNCTION__, null, $html);
        echo $html;
    }
}