function parameters()
{
    $users = new usersMenus();
    $sock = new sockets();
    if (!$users->HAARP_INSTALLED) {
        senderror("{not_installed}");
    }
    $boot = new boostrap_form();
    $EnableHaarp = $sock->GET_INFO("EnableHaarp");
    if (!is_numeric($EnableHaarp)) {
        $EnableHaarp = 0;
    }
    $page = CurrentPageName();
    $HaarpDebug = $sock->GET_INFO("HaarpDebug");
    $HaarpPort = $sock->GET_INFO("HaarpPort");
    if (!is_numeric($HaarpPort)) {
        $HaarpPort = 0;
    }
    if (!is_numeric($HaarpDebug)) {
        $HaarpDebug = 0;
    }
    if ($HaarpPort == 0) {
        $HaarpPort = rand(35000, 64000);
        $sock->SET_INFO("HaarpPort", $HaarpPort);
    }
    $HaarpConf = unserialize(base64_decode($sock->GET_INFO("HaarpConf")));
    $SERVERNUMBER = $HaarpConf["SERVERNUMBER"];
    $MAXSERVERS = $HaarpConf["MAXSERVERS"];
    if (!is_numeric($SERVERNUMBER)) {
        $SERVERNUMBER = "15";
    }
    if (!is_numeric($MAXSERVERS)) {
        $MAXSERVERS = "500";
    }
    $boot->set_checkbox("EnableHaarp", "{enable}", $EnableHaarp, array("DISABLEALL" => true));
    $boot->set_checkbox("HaarpDebug", "{debug}", $HaarpDebug);
    $boot->set_field("HaarpPort", "{internal_port}", $HaarpPort);
    $boot->set_field("SERVERNUMBER", "{daemons_number}", $SERVERNUMBER);
    $boot->set_field("MAXSERVERS", "{max_daemons}", $MAXSERVERS);
    $boot->set_formdescription("{APP_HAARP_EXPLAIN}");
    $f[] = "SERVERNUMBER 250";
    $f[] = "MAXSERVERS 1000";
    $boot->set_button("{apply}");
    $form = $boot->Compile();
    $html = "\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top' style='vertical-align:top'><div id='haarp-status'></div>\n\t\t\n\t\t<div style='width:100%;text-align:right'>" . imgtootltip("refresh-32.png", null, "LoadAjax('haarp-status','{$page}?srv-status=yes');") . "</div>\n\t\t</td>\n\t\t<td valign='top' style='vertical-align:top;padding-left:15px'>{$form}</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjax('haarp-status','{$page}?srv-status=yes');\t\t\n\t\t\t\n\t</script>";
    echo $html;
}
function sources_group_auth_url($groupid, $params)
{
    $boot = new boostrap_form();
    $sock = new sockets();
    $users = new usersMenus();
    $ldap = new clladp();
    $ID = $_GET["groupid"];
    $title_button = "{apply}";
    $boot->set_formdescription("{redirect_uri_explain}");
    $boot->set_hidden("PARAMS_SAVE", "yes");
    $boot->set_hidden("groupid", $groupid);
    $boot->set_field("URI", "{url}", $params["URI"], array("ENCODE" => true));
    $boot->set_button($title_button);
    $AdminPrivs = AdminPrivs();
    if (!$AdminPrivs) {
        $boot->set_form_locked();
    }
    $boot->set_RefreshSearchs();
    return $boot->Compile();
}
function proxy_behavior()
{
    $boot = new boostrap_form();
    $boot->set_formtitle("{proxy_behavior}");
    $boot->set_formdescription("{proxy_behavior_explain}");
    $sock = new sockets();
    $exclusive_internet_proxy = 1;
    $exclusive_reverse_proxy = 0;
    $mixed_mode = 0;
    $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse");
    $SquidActHasReverseOnly = $sock->GET_INFO("SquidActHasReverseOnly");
    if (!is_numeric($SquidActHasReverse)) {
        $SquidActHasReverse = 0;
    }
    if (!is_numeric($SquidActHasReverseOnly)) {
        $SquidActHasReverseOnly = 0;
    }
    if ($SquidActHasReverseOnly == 1) {
        $exclusive_internet_proxy = 0;
        $exclusive_reverse_proxy = 1;
        $mixed_mode = 0;
    }
    if ($SquidActHasReverseOnly == 0) {
        if ($SquidActHasReverse == 1) {
            $exclusive_internet_proxy = 0;
            $exclusive_reverse_proxy = 0;
            $mixed_mode = 1;
        }
    }
    $boot->set_checkbox("exclusive_reverse_proxy", "{exclusive_reverse_proxy}", $exclusive_reverse_proxy);
    $boot->set_checkbox("exclusive_internet_proxy", "{exclusive_internet_proxy}", $exclusive_internet_proxy);
    $boot->set_checkbox("mixed_mode", "{mixed_mode}", $mixed_mode);
    $boot->set_button("{apply}");
    echo $boot->Compile();
}
function settings()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $q = new mysql_catz();
    $users = new usersMenus();
    $sock = new sockets();
    $SquidDBTuningParameters = unserialize(base64_decode($sock->GET_INFO("MySQLCatzParams")));
    $query_cache_size = $SquidDBTuningParameters["query_cache_size"];
    $max_allowed_packet = $SquidDBTuningParameters["max_allowed_packet"];
    $max_connections = $SquidDBTuningParameters["max_connections"];
    $connect_timeout = $SquidDBTuningParameters["connect_timeout"];
    $interactive_timeout = $SquidDBTuningParameters["interactive_timeout"];
    $key_buffer_size = $SquidDBTuningParameters["key_buffer_size"];
    $table_open_cache = $SquidDBTuningParameters["table_open_cache"];
    $myisam_sort_buffer_size = $SquidDBTuningParameters["myisam_sort_buffer_size"];
    $ListenPort = $SquidDBTuningParameters["ListenPort"];
    $tmpdir = $SquidDBTuningParameters["tmpdir"];
    if (!isset($SquidDBTuningParameters["net_read_timeout"])) {
        $SquidDBTuningParameters["net_read_timeout"] = 120;
    }
    $serverMem = round(($users->MEM_TOTAL_INSTALLEE - 300) / 1024);
    $VARIABLES = $q->SHOW_VARIABLES();
    if (is_array($SquidDBTuningParameters)) {
        while (list($key, $value) = each($SquidDBTuningParameters)) {
            if (isset($SquidDBTuningParameters[$key])) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "VARIABLES[{$key}]={$VARIABLES[$key]} MySQLCatzParams[{$key}]={$SquidDBTuningParameters[$key]}<br>\n";
                }
                if ($VARIABLES[$key] == null) {
                    $VARIABLES[$key] = $SquidDBTuningParameters[$key];
                }
            }
        }
    }
    $read_buffer_size = round($VARIABLES["read_buffer_size"] / 1024 / 1000, 2);
    $read_rnd_buffer_size = round($VARIABLES["read_rnd_buffer_size"] / 1024 / 1000, 2);
    $sort_buffer_size = round($VARIABLES["sort_buffer_size"] / 1024 / 1000, 2);
    $thread_stack = round($VARIABLES["thread_stack"] / 1024 / 1000, 2);
    $join_buffer_size = round($VARIABLES["join_buffer_size"] / 1024 / 1000, 2);
    $max_tmp_table_size = round($VARIABLES["max_tmp_table_size"] / 1024 / 1000, 2);
    $innodb_log_buffer_size = round($VARIABLES["innodb_log_buffer_size"] / 1024 / 1000, 2);
    $innodb_additional_mem_pool_size = round($VARIABLES["innodb_additional_mem_pool_size"] / 1024 / 1000, 2);
    $innodb_log_buffer_size = round($VARIABLES["innodb_log_buffer_size"] / 1024 / 1000, 2);
    $innodb_buffer_pool_size = round($VARIABLES["innodb_buffer_pool_size"] / 1024 / 1000, 2);
    $max_connections = $VARIABLES["max_connections"];
    $per_thread_buffers = $sort_buffer_size + $read_rnd_buffer_size + $sort_buffer_size + $thread_stack + $join_buffer_size;
    $total_per_thread_buffers = $per_thread_buffers * $max_connections;
    if ($total_per_thread_buffers > $serverMem) {
        $color = "#EB0000";
    }
    $query_cache_size = round($VARIABLES["query_cache_size"] / 1024 / 1000, 2);
    $key_buffer_size = round($VARIABLES["key_buffer_size"] / 1024 / 1000, 2);
    if ($tmpdir == null) {
        $tmpdir = "/tmp";
    }
    $server_buffers = $key_buffer_size + $max_tmp_table_size + $innodb_buffer_pool_size + $innodb_additional_mem_pool_size + $innodb_log_buffer_size + $query_cache_size;
    if ($server_buffers > $serverMem) {
        $color = "#EB0000";
    }
    $max_used_memory = $server_buffers + $total_per_thread_buffers;
    if ($max_used_memory > $serverMem) {
        $color = "#EB0000";
    }
    $UNIT = "M";
    if ($max_used_memory > 1000) {
        $max_used_memory = round($max_used_memory / 1000, 2);
        $UNIT = "G";
    }
    if (!is_numeric($ListenPort)) {
        $ListenPort = 0;
    }
    $boot = new boostrap_form();
    $boot->set_hidden("innodb_buffer_pool_size", $innodb_buffer_pool_size);
    $boot->set_hidden("innodb_additional_mem_pool_size", $innodb_additional_mem_pool_size);
    $boot->set_hidden("innodb_log_buffer_size", $innodb_log_buffer_size);
    $boot->set_spacertitle("{threads}:");
    $boot->set_field("read_buffer_size", "{read_buffer_size} (MB)", $read_buffer_size, array("TOOLTIP" => "{read_buffer_size_text}"));
    $boot->set_field("read_rnd_buffer_size", "{read_rnd_buffer_size} (MB)", $read_rnd_buffer_size, array("TOOLTIP" => "{read_rnd_buffer_size_text}"));
    $boot->set_field("sort_buffer_size", "{sort_buffer_size} (MB)", $sort_buffer_size, array("TOOLTIP" => "{sort_buffer_size_text}"));
    $boot->set_field("thread_stack", "Thread Stack", $thread_stack, array("TOOLTIP" => "{thread_stack_text}"));
    $boot->set_spacertitle("{server}:");
    $boot->set_field("ListenPort", "{listen_port}", $ListenPort);
    $boot->set_field("tmpdir", "{working_directory}", $tmpdir, array("BUTTON" => array("LABEL" => "{browse}", "JS" => "Loadjs('SambaBrowse.php?no-shares=yes&field=%f&no-hidden=yes')")));
    $boot->set_field("net_read_timeout", "{net_read_timeout} ({seconds})", $SquidDBTuningParameters["net_read_timeout"]);
    $boot->set_field("max_connections", "{max_connections}", $max_connections);
    $boot->set_field("key_buffer_size", "{key_buffer_size} (MB)", $key_buffer_size);
    $boot->set_field("max_tmp_table_size", "MAX TMP Table size (MB)", $max_tmp_table_size);
    $boot->set_field("query_cache_size", "{query_cache_size} (MB)", $query_cache_size, array("TOOLTIP" => "{thread_stack_text}"));
    $boot->set_button("{apply}");
    $boot->set_formdescription("{$server_buffers}M + {$total_per_thread_buffers}M = {$max_used_memory}{$UNIT}");
    $html = $boot->Compile();
    echo $tpl->_ENGINE_parse_body($html);
}
function wbl_popup()
{
    $page = CurrentPageName();
    $q = new amavisdb();
    $tpl = new templates();
    $t = time();
    $type = $_GET["type"];
    $boot = new boostrap_form();
    $email = $q->email_from_emailid($_GET["rid"]);
    $sender = $q->email_from_mailid($_GET["sid"]);
    $user = new user($_SESSION["uid"]);
    $mails = $user->HASH_ALL_MAILS;
    while (list($b, $email) = each($mails)) {
        $mailZ[$email] = $email;
    }
    if ($_GET["sid"] == 0) {
        $bt = "{add}";
    } else {
        $bt = "{apply}";
    }
    $policy_id = $q->policyid_from_mail($email);
    $boot->set_hidden("wbl-type", $type);
    $boot->set_list("rcpt", "{email}", $mailZ, $email);
    $boot->set_field("sender", "{sender}", $sender, array("MANDATORY" => true));
    $boot->set_button($bt);
    $boot->set_CallBack("YahooWin2Hide");
    $boot->set_RefreshSearchs();
    $boot->set_formdescription("{amavis_wblsql_explain}");
    echo $boot->Compile();
}
function section_blocked_form()
{
    $boot = new boostrap_form();
    $q = new mysql_squid_builder();
    $ARRAYTABLES = $q->LIST_TABLES_BLOCKED();
    while (list($tablename, $none) = each($ARRAYTABLES)) {
        $time = $q->TIME_FROM_DAY_TABLE($tablename);
        $days[$time] = time_to_date($time);
    }
    $BLOCKED_CATEGORY_LIMITS[50] = 50;
    $BLOCKED_CATEGORY_LIMITS[250] = 250;
    $BLOCKED_CATEGORY_LIMITS[500] = 250;
    $BLOCKED_CATEGORY_LIMITS[1000] = 1000;
    $BLOCKED_CATEGORY_LIMITS[2000] = 2000;
    krsort($days);
    $boot->set_list("QUERY_BLOCKED_DATE", "{date}", $days, $_SESSION["QUERY_BLOCKED_DATE"]);
    $boot->set_field("QUERY_BLOCKED_UID", "{member}", $_SESSION["QUERY_BLOCKED_UID"]);
    $boot->set_field("QUERY_BLOCKED_CATEGORY", "{category}", $_SESSION["QUERY_BLOCKED_CATEGORY"]);
    $boot->set_list("BLOCKED_CATEGORY_LIMIT", "{rows}", $BLOCKED_CATEGORY_LIMITS, $_SESSION["BLOCKED_CATEGORY_LIMIT"]);
    $boot->set_button("{search}");
    $boot->set_CloseYahoo("YahooWin2");
    $boot->set_formdescription("{advanced_search_explain}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function wizard_certificate_1()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $hostname = $sock->GET_INFO("myhostname");
    if ($hostname == null) {
        $hostname = $sock->getFrameWork("system.php?hostname-g=yes");
        $sock->SET_INFO($hostname, "myhostname");
    }
    $title = $tpl->_ENGINE_parse_body("{new_certificate}");
    $html = "\n\t<div class=text-info style='font-size:18px'>{wizard_certificate_1}<br><i>{CSR_MULTIPLE_EXPLAIN}</i></div>";
    $ENC[1024] = 1024;
    $ENC[2048] = 2048;
    $ENC[4096] = 4096;
    $boot = new boostrap_form();
    $boot->set_field("wizard-certificate-commonname", "{CommonName}", $hostname);
    $boot->set_list("wizard-certificate-levelenc", "{level_encryption}", $ENC, 1024);
    $boot->set_fieldpassword("wizard-certificate-password", "{password}", "secret");
    $boot->set_formdescription("{wizard_certificate_1}");
    $boot->set_button("{add}");
    $boot->set_RefreshSearchs();
    $boot->set_RefreshFlex("flexRT{$_GET["t"]}");
    $boot->set_CloseYahoo("YahooWin6");
    echo $boot->Compile();
}
function firewall_popup()
{
    $ID = $_GET["ID"];
    $q = new mysql_squid_builder();
    $bt = "{apply}";
    $servername = $_GET["servername"];
    if (!$q->TABLE_EXISTS("nginx_exploits_fw")) {
        $sql = "CREATE TABLE IF NOT EXISTS `nginx_exploits_fw` (\n\t\t`servername` CHAR(255) NOT NULL  PRIMARY KEY,\n\t\t`maxaccess` smallint(1)  NOT NULL DEFAULT 0,\n\t\t`sendlogs` smallint(1)  NOT NULL DEFAULT 0,\n\t\tKEY `maxaccess` (`maxaccess`),\n\t\tKEY `sendlogs` (`sendlogs`)\n\t\t)  ENGINE = MYISAM;";
        if (!$q->QUERY_SQL($sql)) {
            echo $q->mysql_error_html();
        }
    }
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nginx_exploits_fw WHERE servername='{$servername}'"));
    if (!is_numeric($ligne["maxaccess"])) {
        $ligne["maxaccess"] = 0;
    }
    $boot = new boostrap_form();
    $sock = new sockets();
    $boot->set_hidden("servername", $_GET["servername"]);
    $boot->set_hidden("firewall", $_GET["servername"]);
    $boot->set_formtitle("{firewall}");
    $boot->set_formdescription("{NGINX_FW_EXPLAIN}");
    $boot->set_field("maxaccess", "{MAX_EVENTS}", $ligne["maxaccess"], array("TOOLTIP" => "{NGINX_MAXACCESS_FW_EXPLAIN}"));
    $boot->set_checkbox("sendlogs", "{write_logs}", $ligne["sendlogs"]);
    $boot->set_button($bt);
    if ($ID == 0) {
        $boot->set_CloseYahoo("YahooWin4");
    }
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function settings_retention()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $users = new usersMenus();
    if ($users->CORP_LICENSE) {
        $LICENSE = 1;
    } else {
        $LICENSE = 0;
    }
    $ArticaProxyStatisticsBackupFolder = $sock->GET_INFO("ArticaProxyStatisticsBackupFolder");
    $ArticaProxyStatisticsBackupDays = $sock->GET_INFO("ArticaProxyStatisticsBackupDays");
    $ArticaProxyStatisticsBackHourTables = $sock->GET_INFO("ArticaProxyStatisticsBackHourTables");
    if (!is_numeric($ArticaProxyStatisticsBackHourTables)) {
        $ArticaProxyStatisticsBackHourTables = 1;
    }
    if ($ArticaProxyStatisticsBackupFolder == null) {
        $ArticaProxyStatisticsBackupFolder = "/home/artica/squid/backup-statistics";
    }
    $q = new mysql_squid_builder();
    if (!is_numeric($ArticaProxyStatisticsBackupDays)) {
        $ArticaProxyStatisticsBackupDays = 90;
    }
    if (!$users->CORP_LICENSE) {
        $error = "<p class=text-error>{this_feature_is_disabled_corp_license}</p>";
        $ArticaProxyStatisticsBackupDays = 5;
    }
    $t = time();
    $new_schedule = $tpl->javascript_parse_text("{new_schedule}");
    $EnableSquidRemoteMySQL = $sock->GET_INFO("EnableSquidRemoteMySQL");
    if (!is_numeric($EnableSquidRemoteMySQL)) {
        $EnableSquidRemoteMySQL = 0;
    }
    if ($EnableSquidRemoteMySQL == 1) {
        $EnableSquidRemoteMySQL_text = "{EnableSquidRemoteMySQL_text}";
    }
    $lock = false;
    $boot = new boostrap_form();
    $boot->set_formdescription($EnableSquidRemoteMySQL_text . "<br>{purge_statistics_database_explain2}");
    $boot->set_checkbox("ArticaProxyStatisticsBackHourTables", "{backup_hourly_tables}", $ArticaProxyStatisticsBackHourTables, array("TOOLTIP" => "{backup_hourly_tables_explain}"));
    $boot->set_field("ArticaProxyStatisticsBackupFolder", "{backup_folder}", $ArticaProxyStatisticsBackupFolder, array("BROWSE" => true));
    $boot->set_field("ArticaProxyStatisticsBackupDays", "{max_days}", $ArticaProxyStatisticsBackupDays);
    $BackupSquidStatsUseNas = $sock->GET_INFO("BackupSquidStatsUseNas");
    $BackupSquidStatsNASIpaddr = $sock->GET_INFO("BackupSquidStatsNASIpaddr");
    $BackupSquidStatsNASFolder = $sock->GET_INFO("BackupSquidStatsNASFolder");
    $BackupSquidStatsNASUser = $sock->GET_INFO("BackupSquidStatsNASUser");
    $BackupSquidStatsNASPassword = $sock->GET_INFO("BackupSquidStatsNASPassword");
    $BackupSquidStatsNASRetry = $sock->GET_INFO("BackupSquidStatsNASRetry");
    if (!is_numeric($BackupSquidStatsUseNas)) {
        $BackupSquidStatsUseNas = 0;
    }
    if (!is_numeric($BackupSquidStatsNASRetry)) {
        $BackupSquidStatsNASRetry = 0;
    }
    $boot->set_spacertitle("{NAS_storage}");
    $boot->set_checkbox("BackupSquidStatsUseNas", "{use_remote_nas}", $BackupSquidStatsUseNas, array("TOOLTIP" => "{BackupSquidStatsUseNas_explain}", "LINK" => "BackupSquidStatsNASIpaddr,BackupSquidStatsNASFolder,BackupSquidStatsNASUser,BackupSquidStatsNASPassword"));
    $boot->set_field("BackupSquidStatsNASIpaddr", "{hostname}", $BackupSquidStatsNASIpaddr);
    $boot->set_field("BackupSquidStatsNASFolder", "{shared_folder}", $BackupSquidStatsNASFolder, array("ENCODE" => true));
    $boot->set_field("BackupSquidStatsNASUser", "{username}", $BackupSquidStatsNASUser, array("ENCODE" => true));
    $boot->set_fieldpassword("BackupSquidStatsNASPassword", "{password}", $BackupSquidStatsNASPassword, array("ENCODE" => true));
    $boot->set_checkbox("BackupSquidStatsNASRetry", "{retry}", $BackupSquidStatsNASRetry, array("TOOLTIP" => "{BackupSquidLogsNASRetry_explain}"));
    $boot->set_button("{apply}");
    $boot->set_formtitle("{purge_statistics_database}");
    if (!$users->CORP_LICENSE) {
        $boot->set_form_locked();
        $lock = true;
    }
    if ($EnableSquidRemoteMySQL == 1) {
        $boot->set_form_locked();
        $lock = true;
    }
    $new_schedule = $tpl->javascript_parse_text("{new_schedule}");
    if (!$lock) {
        $boot->set_Newbutton("{new_schedule}", "YahooWin3('650','squid.databases.schedules.php?AddNewSchedule-popup=yes&ID=0&t={$t}&ForceType=47&YahooWin=3&jsback=ReloadSchedules{$t}','{$new_schedule}')");
        $ReloadSchedules = "ReloadSchedules{$t}()";
    }
    $boot->set_Newbutton("{test_connection}", "Loadjs('{$page}?test-nas-js=yes')");
    $form = $boot->Compile();
    $html = "\n\n\t\t<div id='title-{$t}'></div>\n\t\t{$error}\n\t\t{$form}\n\t\t<div id='schedules-{$t}'></div>\n\n\t\t<script>\n\t\tfunction ReloadSchedules{$t}(){\n\t\tLoadAjax('schedules-{$t}','squid.artica.statistics.purge.php?schedules=yes');\n}\n\nfunction RefreshTableTitle{$t}(){\nLoadAjaxTiny('title-{$t}','squid.artica.statistics.purge.php?title=yes&t={$t}');\n}\nRefreshTableTitle{$t}();\n{$ReloadSchedules};\n</script>\n\n";
    echo $tpl->_ENGINE_parse_body($html);
}
function tasks_popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $tasks = new system_tasks();
    $PatternToHuman = null;
    $boot = new boostrap_form();
    $q = new mysql();
    $no_schedule_set = $tpl->javascript_parse_text("{no_schedule_set}");
    $buttontext = "{add}";
    $ID = $_GET["ID"];
    $t = $_GET["t"];
    $title = "{new_schedule}";
    $task_type = $tasks->tasks_array;
    if ($ID > 0) {
        $buttontext = "{apply}";
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM system_schedules WHERE ID={$ID}", "artica_backup"));
        $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
        $title = $task_type[$ligne["TaskType"]];
        $PatternToHuman = "<br>" . $tasks->PatternToHuman($ligne["TimeText"], true);
    }
    if (!is_numeric($ligne["TaskType"])) {
        $ligne["TaskType"] = 0;
    }
    if (!is_numeric($ID)) {
        $ID = 0;
    }
    if (!$users->KAV4PROXY_INSTALLED) {
        unset($task_type[5]);
        unset($task_type[12]);
    }
    if (!$users->UPDATE_UTILITYV2_INSTALLED) {
        unset($task_type[13]);
    }
    $task_type = $tasks->tasks_array;
    while (list($TaskType, $content) = each($task_type)) {
        $taskz[$TaskType] = "[{$TaskType}] " . $tpl->_ENGINE_parse_body($content);
    }
    $YahooWinHide = "YahooWin{$_GET["YahooWin"]}";
    $boot->set_formtitle($title);
    $boot->set_hidden("ID", $ID);
    if ($ID == 0) {
        if ($_GET["task-section"] > 0) {
            $boot->set_hidden("TaskType", $_GET["task-section"]);
            $boot->set_formdescription($tasks->tasks_explain_array[$_GET["task-section"]] . $PatternToHuman);
            $ligne["TimeDescription"] = $tpl->javascript_parse_text($tasks->tasks_array[$_GET["task-section"]]);
        } else {
            $boot->set_list("TaskType", "{type}", $taskz, null);
        }
        $ligne["enabled"] = 1;
    } else {
        $boot->set_hidden("TaskType", $ligne["TaskType"]);
        $boot->set_formdescription($tasks->tasks_explain_array[$ligne["TaskType"]]);
    }
    $boot->set_checkbox("enabled", "{enabled}", $ligne["enabled"]);
    $boot->set_textarea("TimeDescription", "{description}", $ligne["TimeDescription"], array("ENCODE" => true));
    $boot->set_field("TimeText", "{schedule}", $ligne["TimeText"], array("SCHEDULE" => true, "MANDATORY" => true, "DISABLED" => true));
    if ($ID == 0) {
        $boot->set_CloseYahoo($YahooWinHide);
    }
    //
    $boot->set_button($buttontext);
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function settings()
{
    $page = CurrentPageName();
    $sock = new sockets();
    $MirrorEnableDebian = $sock->GET_INFO("MirrorEnableDebian");
    $MirrorDebianDirSizeText = null;
    $MirrorDebianBW = $sock->GET_INFO("MirrorDebianBW");
    if (!is_numeric($MirrorEnableDebian)) {
        $MirrorEnableDebian = 0;
    }
    if (!is_numeric($MirrorDebianBW)) {
        $MirrorDebianBW = 500;
    }
    $MirrorDebianDir = $sock->GET_INFO("MirrorDebianDir");
    if ($MirrorDebianDir == null) {
        $MirrorDebianDir = "/home/mirrors/Debian";
    }
    $MirrorDebianDirSize = $sock->GET_INFO("MirrorDebianDirSize");
    if (!is_numeric($MirrorDebianDirSize)) {
        $MirrorDebianDirSize = 0;
    }
    $MirrorDebianMaxExecTime = $sock->GET_INFO("MirrorDebianMaxExecTime");
    $MirrorDebianEachMn = $sock->GET_INFO("MirrorDebianEachMn");
    if (!is_numeric($MirrorDebianEachMn)) {
        $MirrorDebianEachMn = 2880;
    }
    $MirrorDebianExclude = unserialize(base64_decode($sock->GET_INFO("MirrorDebianExclude")));
    $MirrorDebianExcludeOS = unserialize(base64_decode($sock->GET_INFO("MirrorDebianExcludeOS")));
    if (!is_numeric($MirrorDebianMaxExecTime)) {
        $MirrorDebianMaxExecTime = 0;
    }
    $MirrorEnableDebianSchedule = $sock->GET_INFO("MirrorEnableDebianSchedule");
    if (!is_numeric($MirrorEnableDebianSchedule)) {
        $MirrorEnableDebianSchedule = 0;
    }
    $boot = new boostrap_form();
    $timeZ[60] = "1 {hour}";
    $timeZ[120] = "2 {hours}";
    $timeZ[300] = "5 {hours}";
    $timeZ[720] = "12 {hours}";
    $timeZ[1440] = "1 {day}";
    $timeZ[2880] = "2 {days}";
    $timeZ[10080] = "1 {week}";
    if ($MirrorDebianDirSize > 0) {
        $MirrorDebianDirSizeText = " (" . FormatBytes($MirrorDebianDirSize / 1024) . " )";
    }
    $boot->set_formdescription("{debian_mirror_howto}<br>{rsync_out_port_explain}");
    $boot->set_spacertitle("Debian{$MirrorDebianDirSizeText}");
    $boot->set_checkbox("MirrorEnableDebian", "{enable_debian_systems}", $MirrorEnableDebian);
    $boot->set_field("MirrorDebianDir", "{directory}{$MirrorDebianDirSizeText}", $MirrorDebianDir, array("ENCODE" => true));
    $boot->set_field("MirrorDebianBW", "{max_bandwidth} KB/s", $MirrorDebianBW);
    $boot->set_list("MirrorDebianEachMn", "{execute_each}", $timeZ, $MirrorDebianEachMn);
    $boot->set_checkbox("MirrorEnableDebianSchedule", "{use_schedule}", $MirrorEnableDebianSchedule, array("TOOLTIP" => "{MirrorEnableDebianSchedule_explain}"));
    $boot->set_field("MirrorDebianMaxExecTime", "{max_execution_time} ({minutes})", $MirrorDebianMaxExecTime, array("TOOLTIP" => "{MirrorDebianMaxExecTime_explain}"));
    //$boot->set_subtitle("{linux_distribution}");
    if (!is_array($MirrorDebianExcludeOS)) {
        $MirrorDebianExcludeOS["sid"] = true;
        $MirrorDebianExcludeOS["jessie"] = true;
        $MirrorDebianExcludeOS["wheezy"] = true;
        $MirrorDebianExcludeOS["oldstable"] = true;
        $MirrorDebianExcludeOS["stable"] = true;
        $MirrorDebianExcludeOS["oldstable"] = true;
        $MirrorDebianExcludeOS["unstable"] = true;
    }
    $DEBVERS[] = "sid";
    $DEBVERS[] = "testing";
    $DEBVERS[] = "jessie";
    $DEBVERS[] = "squeeze";
    $DEBVERS[] = "wheezy";
    $DEBVERS[] = "oldstable";
    $DEBVERS[] = "stable";
    $DEBVERS[] = "unstable";
    /*	while (list ($none, $pattern) = each ($DEBVERS) ){
    		$enabled=0;
    		if($MirrorDebianExclude["$pattern"]==1){$enabled=1;}
    		$boot->set_checkbox("debian-exclude-$pattern","{exclude}:&nbsp;&laquo;$pattern&raquo;",$enabled);
    	}	
    	
    */
    $boot->set_subtitle("{architecture}");
    $f = array();
    $f[] = "source";
    $f[] = "alpha";
    $f[] = "amd64";
    $f[] = "arm";
    $f[] = "armel";
    $f[] = "armhf";
    $f[] = "hppa";
    $f[] = "hurd-i386";
    $f[] = "i386";
    $f[] = "ia64";
    $f[] = "mips";
    $f[] = "mipsel";
    $f[] = "powerpc";
    $f[] = "s390";
    $f[] = "s390x";
    $f[] = "sparc";
    $f[] = "kfreebsd-i386";
    $f[] = "kfreebsd-amd64";
    if (!is_array($MirrorDebianExclude)) {
        while (list($none, $pattern) = each($f)) {
            if ($pattern == "i386") {
                continue;
            }
            if ($pattern == "amd64") {
                continue;
            }
            $MirrorDebianExclude[$pattern] = 1;
        }
        reset($f);
    }
    while (list($none, $pattern) = each($f)) {
        $enabled = 0;
        if ($MirrorDebianExclude["{$pattern}"] == 1) {
            $enabled = 1;
        }
        $boot->set_checkbox("debian-exclude-{$pattern}", "{exclude}:&nbsp;&laquo;{$pattern}&raquo;", $enabled);
    }
    $t = time();
    $boot->set_button("{apply}");
    $boot->set_Newbutton("{execute}", "Loadjs('{$page}?execute-debian-js=yes&t={$t}')");
    $form = $boot->Compile();
    $html = "<table style='width:100%'>\n\t<tr>\n\t\t<td style='vertical-align:top;width:350px'>\n\t\t\n\t\t<div id='{$t}'>\n\t\t\n\t\t</div>\n\t\t<div style='text-align:right'>" . imgtootltip("refresh-32.png", null, "LoadAjax('{$t}','{$page}?rsync-debian-status=yes')") . "</div>\n\t</td>\n\t<td style='vertical-align:top;padding-left:20px'>\t\t\n\t\t{$form}\n\t</td>\n\t</tr>\n\t</table>\n\t<script>\n\t\tLoadAjax('{$t}','{$page}?rsync-debian-status=yes');\n\t</script>\t\n\t";
    echo $html;
}
function license()
{
    $boot = new boostrap_form();
    $sock = new sockets();
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $uuid = base64_decode($sock->getFrameWork("cmd.php?system-unique-id=yes"));
    $LicenseInfos = unserialize(base64_decode($sock->GET_INFO("LicenseInfos")));
    $WizardSavedSettings = unserialize(base64_decode($sock->GET_INFO("WizardSavedSettings")));
    if ($LicenseInfos["COMPANY"] == null) {
        $LicenseInfos["COMPANY"] = $WizardSavedSettings["company_name"];
    }
    if ($LicenseInfos["EMAIL"] == null) {
        $LicenseInfos["EMAIL"] = $WizardSavedSettings["mail"];
    }
    if (!is_numeric($LicenseInfos["EMPLOYEES"])) {
        $LicenseInfos["EMPLOYEES"] = $WizardSavedSettings["employees"];
    }
    $t = time();
    $ASWEB = false;
    if ($users->SQUID_INSTALLED) {
        $ASWEB = true;
    }
    if ($users->WEBSTATS_APPLIANCE) {
        $ASWEB = true;
    }
    $lastupdate = "<p><strong>{license_status}:</strong> {$LicenseInfos["license_status"]}</p>\n\t<p><strong>{uuid}:</strong> {$uuid}</p>\n\t<p><strong>{license_number}:</strong> {$LicenseInfos["license_number"]}</p>\n\t\n\t";
    if (!$users->CORP_LICENSE) {
        $exp1 = "{CORP_LICENSE_EXPLAIN}\n\t\t<div style='font-size:16px;font-weight:bold'>{price_quote}:</div>\n\t\t\t<div>\n\t\t\t<a href=\"javascript:blur();\"\n\t\t\t\tOnClick=\"javascript:s_PopUpFull('http://www.proxy-appliance.org/index.php?cID=292','1024','900');\"\n\t\t\t\tstyle=\"font-size:14px;font-weight;bold;text-decoration:underline\">{click_here_price_quote}</a>\n\t\t\t</div>";
    }
    $boot->set_formtitle("{artica_license} - {$LicenseInfos["license_status"]}");
    if ($LicenseInfos["license_status"] == null) {
        $exp2 = "<br>{explain_license_free}{$lastupdate}";
        $boot->set_formtitle("{artica_license} ({waiting_registration})");
        $button_text = "{request_a_quote}/{refresh}";
    } else {
        $button_text = "{update_the_request}";
        $exp2 = "<br>{explain_license_order}{$lastupdate}";
    }
    if ($users->CORP_LICENSE) {
        $exp2 = "{$lastupdate}";
    }
    $boot->set_formdescription("{$exp1}{$exp2}");
    if ($users->CORP_LICENSE) {
        $boot->set_form_locked();
    }
    $boot->set_hidden("REGISTER", 1);
    $boot->set_field("COMPANY", "{company}", $LicenseInfos["COMPANY"]);
    $boot->set_field("EMAIL", "{your_email_address}", $LicenseInfos["EMAIL"]);
    $boot->set_field("EMPLOYEES", "{nb_employees}", $LicenseInfos["EMPLOYEES"]);
    $boot->set_field("license_number", "{license_number}", $LicenseInfos["license_number"], array("DISABLED" => true));
    if ($LicenseInfos["license_status"] == "{license_active}") {
        $users->CORP_LICENSE = true;
        $boot->set_hidden("UNLOCKLIC", $LicenseInfos["UNLOCKLIC"]);
    } else {
        $boot->set_field("UNLOCKLIC", "{unlock_license}", $LicenseInfos["UNLOCKLIC"]);
    }
    $boot->set_button($button_text);
    echo $boot->Compile();
}
function parent_import_popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $boot = new boostrap_form();
    $array_type["parent"] = "parent";
    $array_type["sibling"] = "sibling";
    $array_type["multicast"] = "multicast";
    $btname = "{import}";
    $boot->set_formtitle("{import}");
    $boot->set_formdescription("{parents_squid_import_explain}");
    $boot->set_hidden("import-perform", "yes");
    $boot->set_textarea("import-text", "{parents}", null);
    $boot->set_list("server_type", "{server_type}", $array_type, "parent", array("TOOLTIP" => "{squid_parent_sibling_how_to}"));
    $boot->set_field("options", "{options}", "proxy-only,no-query,round-robin,connect-timeout=7,connect-fail-limit=3,weight=%i");
    $boot->set_checkbox("delete_all", "{delete_all}", 0);
    $boot->set_button($btname);
    $boot->set_RefreshSearchs();
    $boot->set_CloseYahoo("YahooWin5");
    echo $boot->Compile();
}
function settings()
{
    $schedules = new system_tasks();
    $q = new mysql_squid_builder();
    $tpl = new templates();
    $buttontext = "{apply}";
    $ID = $_GET["ID"];
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilters_schedules WHERE ID={$ID}"));
    $ligne["TimeDescription"] = utf8_encode($ligne["TimeDescription"]);
    $TimeText = $tpl->_ENGINE_parse_body($schedules->PatternToHuman($ligne["TimeText"]));
    $TimeText = str_replace("<br>", "", $TimeText);
    $explain = $tpl->_ENGINE_parse_body($q->tasks_explain_array[$ligne["TaskType"]]);
    $boot = new boostrap_form();
    $boot->set_hidden("ID", $ID);
    $boot->set_checkbox("enabled", "{enabled}", $ligne["enabled"]);
    $boot->set_field("TimeDescription", "{description}", $ligne["TimeDescription"], array("ENCODE" => TRUE));
    $boot->set_button("{apply}");
    $boot->set_formtitle("{task} {$ligne["ID"]}");
    $runtask = $tpl->_ENGINE_parse_body("<div style='text-align:right'><i class='icon-play'></i> <a href=\"javascript:Blurz();\" OnClick=\"javascript:Loadjs('miniadm.ajax.squid.schedules.php?schedule-run-js=yes&ID={$ID}');\">{run} {task}</div>");
    $boot->set_formdescription("{$explain}<br>{$TimeText}{$runtask}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function wizard_popup()
{
    $boot = new boostrap_form();
    $tpl = new templates();
    $ID = $_GET["ID"];
    $sock = new sockets();
    $ApacheDisableModDavFS = $sock->GET_INFO("ApacheDisableModDavFS");
    if (!is_numeric($ApacheDisableModDavFS)) {
        $ApacheDisableModDavFS = 0;
    }
    $users = new usersMenus();
    $q = new mysql();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT maxsize FROM storage_containers WHERE `groupid`='" . mysql_escape_string2($_GET["gpid"]) . "'", "artica_backup"));
    $maxsize = $ligne["maxsize"];
    if ($maxsize == 0) {
        $maxsizeText = $tpl->_ENGINE_parse_body("{unlimited} ");
    } else {
        $maxsizeText = $maxsize;
    }
    if ($maxsize > 0) {
        if ($ID == 0) {
            $uidenc = mysql_escape_string2($_SESSION["uid"]);
            $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(container_size) as tSize FROM users_containers WHERE `uid`='{$uidenc}'", "artica_backup"));
            $tSize = $ligne["tSize"];
            if ($tSize >= $maxsize) {
                senderror("{error_quota_exceed}");
            }
        }
    }
    $ligne = array();
    if ($ID > 0) {
        $q = new mysql();
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM users_containers WHERE `container_id`='{$ID}'", "artica_backup"));
        $boot->set_formtitle("{$ligne["container_name"]} ({$ligne["container_size"]}MB)");
    }
    if ($ligne["container_name"] == null) {
        $ligne["container_name"] = $tpl->_ENGINE_parse_body("{new_container}");
    }
    if ($maxsize > 0) {
        if (!is_numeric($ligne["container_size"])) {
            $ligne["container_size"] = $maxsize;
        }
    }
    $new_container_user_explain = $tpl->_ENGINE_parse_body("{new_container_user_explain}");
    $new_container_user_explain = str_replace("%S", $maxsize, $new_container_user_explain);
    if ($ID == 0) {
        $boot->set_formdescription($new_container_user_explain);
    }
    $boot->set_hidden("gpid", $_GET["gpid"]);
    $boot->set_hidden("ID", $_GET["ID"]);
    $boot->set_field("container_name", "{container_name}", $ligne["container_name"], array("ENCODE" => true));
    if ($ID == 0) {
        $boot->set_field("container_size", "{container_size}", $ligne["container_size"], array("TOOLTIP" => "{container_size_explain}"));
    } else {
        $boot->set_hidden("container_size", $ligne["container_size"]);
    }
    $webdav_creds = unserialize(base64_decode($ligne["webdav_creds"]));
    if ($webdav_creds["username"] == null) {
        $webdav_creds["username"] = $_SESSION["uid"];
    }
    if ($ApacheDisableModDavFS == 0) {
        $boot->set_checkbox("webdav", "{http_sharing}", $ligne["webdav"], array("TOOLTIP" => "{container_http_sharing_explain}"));
    }
    if ($users->ISCSI_INSTALLED) {
        if (!is_numeric($ligne["iscsid"])) {
            $ligne["iscsid"] = 0;
        }
        $boot->set_checkbox("iscsid", "{network_disk}", $ligne["iscsid"], array("TOOLTIP" => "{container_iscsid_sharing_explain}"));
    }
    $lengthpass = strlen($webdav_creds["password"]);
    $boot->set_field("webdav_username", "{username}", $webdav_creds["username"], array("ENCODED" => true));
    $boot->set_fieldpassword("webdav_password", "{password} ({$lengthpass} chars)", $webdav_creds["password"], array("ENCODED" => true));
    if ($ID == 0) {
        $boot->set_button("{create}");
    } else {
        $boot->set_button("{apply}");
    }
    $boot->set_RefreshSearchs();
    $boot->set_RefreshSearchsForced();
    echo $boot->Compile();
}
function NewMacLink_popup()
{
    $tpl = new templates();
    $_GET["MAC"] = trim($_GET["MAC"]);
    if ($_GET["MAC"] != null) {
        if (!IsPhysicalAddress($_GET["MAC"])) {
            unset($_GET["MAC"]);
        }
    } else {
        unset($_GET["MAC"]);
    }
    $q = new mysql_squid_builder();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilters_nodes WHERE MAC='{$_GET["MAC"]}'"));
    $boot = new boostrap_form();
    if ($_GET["MAC"] == null) {
        $boot->set_field("MAC", "{MAC}", null, array("MANDATORY" => true, "BUTTON" => array("JS" => "Loadjs('miniadm.squid.macbrowser.php?field=%f')", "LABEL" => $tpl->_ENGINE_parse_body("{browse}"))));
    } else {
        $boot->set_formtitle("{MAC}:{$_GET["MAC"]}");
        $boot->set_hidden("MAC", $_GET["MAC"]);
        $ips = array();
        $results2 = $q->QUERY_SQL("SELECT ipaddr FROM members_macip WHERE MAC='{$_GET["MAC"]}' ORDER BY ipaddr");
        while ($ligne2 = mysql_fetch_assoc($results2)) {
            $ips[] = $ligne2["ipaddr"];
        }
        if (count($ips) > 0) {
            $boot->set_formdescription(@implode(", ", $ips));
        }
        $linkstats = "<div style='width:100%'>\n\t\t\t\t<a href=\"javascript:blur();\" \n\t\t\t\tOnClick=\"javascript:miniadm.squid.macbrowser.php?visits-day-js={$_GET["MAC"]}');>{statistics}</a></div>";
    }
    $boot->set_hidden("save-mac", 'yes');
    $boot->set_field("hostname", "{hostname}", $ligne["hostname"]);
    $boot->set_field("uid", "{member}", $ligne["uid"], array("MANDATORY" => true));
    $boot->set_button("{add}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function rules_sources_group_items_popup()
{
    $boot = new boostrap_form();
    $sock = new sockets();
    $users = new usersMenus();
    $ldap = new clladp();
    $groupid = $_GET["groupid"];
    $title_button = "{add}";
    $title = "{new_item}";
    $q = new mysql_squid_builder();
    $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT * FROM authenticator_groups WHERE ID='{$groupid}'"));
    $explain[1] = "{authenticator_explain_network_text}";
    $explain[3] = "{authenticator_explain_cookie_text}";
    $title = $title . "::" . $ligne["groupname"];
    $boot->set_formtitle($title);
    $boot->set_spacerexplain("<i>{group2} ID:{$groupid} {group2} {type}:{$ligne["group_type"]} ({$GLOBALS["SOURCE_TYPE"][$ligne["group_type"]]})</i>");
    $boot->set_formdescription($explain[$ligne["group_type"]]);
    $boot->set_hidden("rules-sources-group-items-add", "yes");
    $boot->set_hidden("groupid", $groupid);
    $boot->set_textarea("items", "{items}", null, array("ENCODE" => true));
    $boot->set_button($title_button);
    $AdminPrivs = AdminPrivs();
    if (!$AdminPrivs) {
        $boot->set_form_locked();
    }
    if ($ligne["group_type"] == 0) {
        $boot->set_form_locked();
    }
    $boot->set_CloseYahoo("YahooWin3");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function subrules_popup()
{
    $ruleid = $_GET["rule-id"];
    $ID = $_GET["subrule"];
    $users = new usersMenus();
    $page = CurrentPageName();
    $tpl = new templates();
    $t = time();
    $buttonname = "{add}";
    $boot = new boostrap_form();
    if ($ID > 0) {
        $q = new mysql();
        $sql = "SELECT *  FROM iproute_rules WHERE ID={$ID}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $title = $tpl->_ENGINE_parse_body("{$ID}::{$ligne["src"]} - {$ligne["destination"]}");
        $buttonname = "{apply}";
    } else {
        $boot->set_CloseYahoo("YahooWin3");
    }
    if (!is_numeric($ligne["enable"])) {
        $ligne["enable"] = 1;
    }
    $boot->set_formtitle($title);
    $boot->set_formdescription("{iprules_explain}");
    $boot->set_hidden("subruleid", $ID);
    $boot->set_hidden("ruleid", $ruleid);
    $boot->set_field("src", "{source}", $ligne["source"]);
    $boot->set_field("destination", "{destination}", $ligne["destination"]);
    $boot->set_field("priority", "{priority}", $ligne["priority"]);
    $boot->set_checkbox("enable", "{enabled}", $ligne["enable"]);
    $users = new usersMenus();
    if (!$users->AsSystemAdministrator) {
        $boot->set_form_locked();
    }
    $boot->set_button($buttonname);
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function failover()
{
    //this_feature_is_disabled_corp_license
    $users = new usersMenus();
    $boot = new boostrap_form();
    $tpl = new templates();
    $t = time();
    $page = CurrentPageName();
    $sock = new sockets();
    $eth = $_GET["nic"];
    $nic = new system_nic($eth);
    for ($i = 1; $i < 256; $i++) {
        $ucarp_vids[$i] = $i;
    }
    $boot->set_hidden("save_nic", $eth);
    $array = unserialize(base64_decode($sock->getFrameWork("system.php?ucarp-status={$eth}")));
    if (!isset($array["PID"])) {
        $boot->set_formdescription("{status}:{stopped}");
        $boot->set_Newbutton("{start}", "Start{$t}()");
    } else {
        $boot->set_Newbutton("{stop}", "Stop{$t}()");
        $boot->set_formdescription("{status}:{running} PID:{$array["PID"]} {since} {$array["TIME"]}Mn");
    }
    $XHR = array();
    $XHR["start-vip"] = "yes";
    $boot->set_AddScript("Start{$t}", array("XHR" => $XHR));
    $XHR = array();
    $XHR["stop-vip"] = "yes";
    $boot->set_AddScript("Stop{$t}", array("XHR" => $XHR));
    $boot->set_checkbox("ucarp_enabled", "{enabled}", $nic->ucarp_enabled, array("DISABLEALL" => true));
    $boot->set_checkbox("ucarp_master", "{isamaster}", $nic->ucarp_master, array("TOOLTIP" => "{ucarp_master_explain}"));
    $boot->set_list("ucarp_vid", "{ucarp-vid}", $ucarp_vids, $nic->ucarp_vid);
    $boot->set_field("ucarp_vip", "{ucarp-vip}", $nic->ucarp_vip, array("MANDATORY" => true, "IPV4" => true, "TOOLTIP" => "{ucarp_vip_explain}"));
    $boot->set_list("ucarp_advskew", "{ucarp-advskew}", $ucarp_vids, $nic->ucarp_advskew);
    $boot->set_field("ucarp_advbase", "{interval} ({seconds})", $nic->ucarp_advbase, array("MANDATORY" => true));
    $boot->set_button("{apply}");
    $boot->set_RefreshSearchs();
    if (!$users->AsSystemAdministrator) {
        $boot->set_form_locked();
    }
    if (!$users->CORP_LICENSE) {
        $error = "<p class=text-error>{this_feature_is_disabled_corp_license}</p>";
        $boot->set_form_locked();
    }
    $form = $boot->Compile();
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($error . $form);
}
function search_database_popup()
{
    $boot = new boostrap_form();
    $q = new mysql_storelogs();
    if (!isset($_SESSION["QUERY_SYSLOG_HOST_DAY_FIELDY"])) {
        $sql = "SELECT DATE_FORMAT(filetime,'%Y-%m-%d') as filetime FROM files_info GROUP BY filetime ORDER BY filetime DESC";
        $results = $q->QUERY_SQL($sql);
        $dayz[null] = "{select}";
        while ($ligne = mysql_fetch_assoc($results)) {
            $time = time_to_date(strtotime($ligne["filetime"] . " 00:00:00"));
            $dayz[$ligne["filetime"]] = $time;
        }
        $_SESSION["QUERY_SYSLOG_HOST_DAY_FIELDY"] = serialize($dayz);
    }
    if (!isset($_SESSION["QUERY_SYSLOG_HOST_FIELDZ"])) {
        $sql = "SELECT hostname FROM files_info GROUP BY hostname ORDER BY hostname ASC";
        $results = $q->QUERY_SQL($sql);
        $hostz[null] = "{select}";
        while ($ligne = mysql_fetch_assoc($results)) {
            $hostz[$ligne["hostname"]] = $ligne["hostname"];
        }
        $_SESSION["QUERY_SYSLOG_HOST_FIELDZ"] = serialize($hostz);
    }
    $LIMITS[50] = 50;
    $LIMITS[250] = 250;
    $LIMITS[500] = 250;
    $LIMITS[1000] = 1000;
    $LIMITS[2000] = 2000;
    if (!isset($_SESSION["QUERY_SYSLOG_LIMIT"])) {
        $_SESSION["QUERY_SYSLOG_LIMIT"] = 250;
    }
    if (!is_numeric($_GET["xtime"])) {
        $boot->set_list("QUERY_SYSLOG_DATE", "{date}", unserialize($_SESSION["QUERY_SYSLOG_HOST_DAY_FIELDY"]), $_SESSION["QUERY_SYSLOG_DATE"]);
    }
    $boot->set_list("QUERY_SYSLOG_HOST", "{hostname}", unserialize($_SESSION["QUERY_SYSLOG_HOST_FIELDZ"]), $_SESSION["QUERY_SYSLOG_HOST"]);
    $boot->set_field("QUERY_SYSLOG_FILE", "{filename}", $_SESSION["QUERY_SYSLOG_FILE"]);
    $boot->set_list("QUERY_SYSLOG_LIMIT", "{rows}", $LIMITS, $_SESSION["QUERY_SYSLOG_LIMIT"]);
    $boot->set_button("{search}");
    $boot->set_CloseYahoo("YahooWin2");
    $boot->set_formdescription("{advanced_search_explain}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function add_www_import()
{
    $boot = new boostrap_form();
    $boot->set_formdescription("{free_catgorized_explain}");
    $boot->set_hidden("category", $_GET["category"]);
    $boot->set_checkbox("ForceCat", "{force}", 0, array("TOOLTIP" => "{free_cat_force_explain}"));
    $boot->set_textarea("categorize", "{items}", null, array("HEIGHT" => 250));
    $boot->set_button("{add}");
    $boot->set_RefreshSearchs();
    $boot->set_RefreshSearchsForced();
    echo $boot->Compile();
}
function settings()
{
    $page = CurrentPageName();
    $sock = new sockets();
    $boot = new boostrap_form();
    $sock = new sockets();
    $tpl = new templates();
    $EnableITChart = $sock->GET_INFO("EnableITChart");
    $ItChartFreeWeb = $sock->GET_INFO("ItChartFreeWeb");
    if (!is_numeric($EnableITChart)) {
        $EnableITChart = 0;
    }
    $q = new mysql_squid_builder();
    $q->CheckTables();
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(*) as tcount FROM itcharters"));
    if ($ligne["tcount"] == 0) {
        echo "<p class=text-error>" . $tpl->_ENGINE_parse_body("{ERROR_NO_ITCHART_CREATED}") . "</p>";
    }
    $boot->set_formtitle("{IT_charter}");
    $boot->set_formdescription("{IT_charter_explain}<br>{IT_charter_explain2}");
    $boot->set_checkbox("EnableITChart", "{enable_it_charter}", $EnableITChart);
    $sql = "SELECT servername,UseSSL FROM freeweb WHERE groupware='ERRSQUID'";
    $me = $_SERVER["SERVER_ADDR"] . ":" . $_SERVER["SERVER_PORT"];
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo "<p class=text-error>{$q->mysql_error}</p>";
    }
    $hash[$me] = $me;
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        $servername = $ligne["servername"];
        if ($ligne["UseSSL"] == 1) {
            $servername = $servername . ":443";
        }
        $hash[$servername] = $servername;
    }
    if ($ItChartFreeWeb == null) {
        $sock->SET_INFO("ItChartFreeWeb", $me);
    }
    $boot->set_list("ItChartFreeWeb", "{webserver}", $hash, $ItChartFreeWeb);
    $users = new usersMenus();
    if (!$users->AsDansGuardianAdministrator) {
        $boot->set_form_locked();
    }
    echo $boot->Compile();
}
function host_edit_options()
{
    $t = time();
    $page = CurrentPageName();
    $tpl = new templates();
    $mac = $_GET["mac"];
    $tt = $_GET["t"];
    $bootstrap = new boostrap_form();
    $q = new mysql();
    if (!$q->FIELD_EXISTS('dhcpd_fixed', 'routers', 'artica_backup')) {
        $sql = "ALTER TABLE `dhcpd_fixed` ADD `routers` VARCHAR( 128 ),\n\t\t\t\t\t`time-servers` VARCHAR( 128 ),\n\t\t\t\t\t`domain-name-servers` VARCHAR( 255 ),\n\t\t\t\t\t`ntp-servers`  VARCHAR( 255 ),\n\t\t\t\t\t`local-pac-server` VARCHAR( 255 )";
        $q->QUERY_SQL($sql, "artica_backup");
        if (!$q->ok) {
            echo $q->mysql_error . "\n{$sql}\n";
        }
    }
    $sql = "SELECT * FROM dhcpd_fixed WHERE `mac`='{$_GET["mac"]}'";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $bootstrap->set_formdescription("{dhcp_host_explain_options}");
    $bootstrap->set_button("{apply}");
    $bootstrap->set_hidden("edit-mac-adv", $mac);
    $bootstrap->set_field("routers", "{gateway}", $ligne["routers"]);
    $bootstrap->set_field("time-servers", "{time-servers}", $ligne["time-servers"]);
    $bootstrap->set_field("domain-name-servers", "{domain-name-servers}", $ligne["domain-name-servers"]);
    $bootstrap->set_field("ntp-servers", "{ntp-servers}", $ligne["ntp-servers"]);
    $bootstrap->set_field("local-pac-server", "{local-pac-server}", $ligne["local-pac-server"]);
    $bootstrap->set_RefreshSearchs();
    echo $tpl->_ENGINE_parse_body($bootstrap->Compile());
}
function websites_popup_webserver_replace_popup()
{
    $tpl = new templates();
    $page = CurrentPageName();
    $servername = $_GET["servername"];
    $q = new mysql_squid_builder();
    $title = "{new_rule}";
    $bt = "{add}";
    $ID = $_GET["replaceid"];
    $boot = new boostrap_form();
    $sock = new sockets();
    $servername = $_GET["servername"];
    if ($ID > 0) {
        $q = new mysql_squid_builder();
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM nginx_replace_www WHERE ID='{$ID}'"));
        $bt = "{apply}";
        $title = "{$ligne["rulename"]}";
        $ligne["stringtosearch"] = stripslashes($ligne["stringtosearch"]);
        $ligne["replaceby"] = stripslashes($ligne["replaceby"]);
        $servername = $ligne["servername"];
    }
    if ($ligne["tokens"] == null) {
        $ligne["tokens"] = "g";
    }
    if ($ligne["rulename"] == null) {
        $ligne["rulename"] = time();
    }
    $boot->set_hidden("replaceid", $ID);
    $boot->set_hidden("servername", $servername);
    $boot->set_formtitle($title);
    $boot->set_field("rulename", "{name}", $ligne["rulename"]);
    $boot->set_field("zorder", "{order}", $ligne["zorder"]);
    $boot->set_spacertitle("{search}");
    $boot->set_textarea("stringtosearch", "{search}", $ligne["stringtosearch"], array("MANDATORY" => true, "ENCODE" => true));
    $boot->set_checkbox("AsRegex", "{regex}", $ligne["AsRegex"], array("TOOLTIP" => "{replace_regex_explain}"));
    $boot->set_spacertitle("{replace}");
    $boot->set_textarea("replaceby", "{replace}", $ligne["replaceby"], array("MANDATORY" => true, "ENCODE" => true));
    $boot->set_field("tokens", "{flags}", $ligne["tokens"], array("MANDATORY" => true));
    $boot->set_button($bt);
    if ($ID == 0) {
        $boot->set_CloseYahoo("YahooWin3");
    }
    $boot->set_RefreshSearchs();
    $boot->set_formdescription("{nginx_subst_explain}");
    echo $boot->Compile();
}
function ruleid_popup()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    $id = $_GET["ruleid"];
    if (!is_numeric($id)) {
        $id = 0;
    }
    $gpid = $_GET["gpid"];
    $buttonname = "{add}";
    if ($id > 0) {
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT * FROM webfilter_aclsdynamic WHERE `ID`='{$id}'"));
        $buttonname = "{apply}";
        $gpid = $ligne["gpid"];
    }
    $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT params FROM webfilters_sqgroups WHERE ID='{$gpid}'"));
    $params = unserialize(base64_decode($ligne2["params"]));
    if ($id == 0) {
        $ligne["duration"] = $params["duration"];
    }
    $t = time();
    if (!is_numeric($gpid)) {
        $gpid = 0;
    }
    $ligne["description"] = stripslashes($ligne["description"]);
    if ($id > 0) {
        $buttonname = "{apply}";
    }
    $durations[0] = "{unlimited}";
    $durations[5] = "05 {minutes}";
    $durations[10] = "10 {minutes}";
    $durations[15] = "15 {minutes}";
    $durations[30] = "30 {minutes}";
    $durations[60] = "1 {hour}";
    $durations[120] = "2 {hours}";
    $durations[240] = "4 {hours}";
    $durations[480] = "8 {hours}";
    $durations[720] = "12 {hours}";
    $durations[960] = "16 {hours}";
    $durations[1440] = "1 {day}";
    $durations[2880] = "2 {days}";
    $durations[5760] = "4 {days}";
    $durations[10080] = "1 {week}";
    $durations[20160] = "2 {weeks}";
    $durations[43200] = "1 {month}";
    $boot = new boostrap_form();
    $boot->set_hidden("SaveRule", "yes");
    $boot->set_hidden("gpid", $gpid);
    $boot->set_hidden("ruleid", $id);
    $boot->set_formdescription("{dynaacl_howto}");
    $boot->set_list("type", "{type}", $q->acl_GroupTypeDynamic, $ligne["type"]);
    $boot->set_field("value", "{value}", $ligne["value"], array("MANDATORY" => true));
    if ($params["allow_duration"] == 1) {
        $boot->set_list("duration", "{time_duration}", $durations, $ligne["duration"]);
    }
    $boot->set_field("description", "{description}", utf8_encode($ligne["description"]));
    $boot->set_button($buttonname);
    $boot->set_RefreshSearchs();
    $html = $boot->Compile();
    echo $tpl->_ENGINE_parse_body($html);
}
function table_all_videos_search_popup()
{
    $boot = new boostrap_form();
    $q = new mysql_squid_builder();
    if (isset($_SESSION["QUERY_YOUTUBE_CATZ"])) {
        $testCatz = unserialize($_SESSION["QUERY_YOUTUBE_CATZ"]);
        if (!is_array($testCatz)) {
            unset($_SESSION["QUERY_YOUTUBE_CATZ"]);
        }
    }
    if (!isset($_SESSION["QUERY_YOUTUBE_CATZ"])) {
        $sql = "SELECT category  FROM youtube_objects GROUP BY category";
        $results = $q->QUERY_SQL($sql);
        $dayz[null] = "{select}";
        while ($ligne = mysql_fetch_assoc($results)) {
            $time = time_to_date(strtotime($ligne["filetime"] . " 00:00:00"));
            $dayz[$ligne["category"]] = $ligne["category"];
        }
        $_SESSION["QUERY_YOUTUBE_CATZ"] = serialize($dayz);
    }
    $LIMITS[50] = 50;
    $LIMITS[250] = 250;
    $LIMITS[500] = 250;
    $LIMITS[1000] = 1000;
    $LIMITS[2000] = 2000;
    if (!isset($_SESSION["QUERY_YOUTUBE_LIMIT"])) {
        $_SESSION["QUERY_YOUTUBE_LIMIT"] = 250;
    }
    $boot->set_list("QUERY_YOUTUBE_CATE", "{category}", unserialize($_SESSION["QUERY_YOUTUBE_CATZ"]), $_SESSION["QUERY_YOUTUBE_CATE"]);
    $boot->set_list("QUERY_YOUTUBE_LIMIT", "{rows}", $LIMITS, $_SESSION["QUERY_YOUTUBE_LIMIT"]);
    $boot->set_button("{search}");
    $boot->set_CloseYahoo("YahooWin2");
    $boot->set_formdescription("{advanced_search_explain}");
    $boot->set_RefreshSearchs();
    echo $boot->Compile();
}
function parameters_backup()
{
    $users = new usersMenus();
    $tpl = new templates();
    if (!$users->SARG_INSTALLED) {
        echo $tpl->_ENGINE_parse_body("<p class=text-error>{SARG_NOT_INSTALLED}</p>");
    }
    $sock = new sockets();
    $tpl = new templates();
    $boot = new boostrap_form();
    $EnableSargGenerator = $sock->GET_INFO("EnableSargGenerator");
    if (!is_numeric($EnableSargGenerator)) {
        $EnableSargGenerator = 0;
    }
    $boot->set_formdescription("{sarg_backup_nfs_explain}");
    $BackupSargUseNas = $sock->GET_INFO("BackupSargUseNas");
    $BackupSargNASIpaddr = $sock->GET_INFO("BackupSargNASIpaddr");
    $BackupSargNASFolder = $sock->GET_INFO("BackupSargNASFolder");
    $BackupSargNASUser = $sock->GET_INFO("BackupSargNASUser");
    $BackupSargNASPassword = $sock->GET_INFO("BackupSargNASPassword");
    if (!is_numeric($BackupSargUseNas)) {
        $BackupSargUseNas = 0;
    }
    $boot->set_spacertitle("{NAS_storage}");
    $boot->set_checkbox("BackupSargUseNas", "{use_remote_nas}", $BackupSargUseNas, array("DISABLEALL" => true));
    $boot->set_field("BackupSargNASIpaddr", "{hostname}", $BackupSargNASIpaddr);
    $boot->set_field("BackupSargNASFolder", "{shared_folder}", $BackupSargNASFolder, array("ENCODE" => true));
    $boot->set_field("BackupSargNASUser", "{username}", $BackupSargNASUser, array("ENCODE" => true));
    $boot->set_fieldpassword("BackupSargNASPassword", "{password}", $BackupSargNASPassword, array("ENCODE" => true));
    $boot->set_button("{apply}");
    if (!$users->AsWebStatisticsAdministrator) {
        $boot->set_form_locked();
    }
    if ($EnableSargGenerator == 0) {
        $boot->set_form_locked();
    }
    echo $boot->Compile();
}