function engine_params()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $LogRotatePath = $sock->GET_INFO("LogRotatePath");
    $SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
    $BackupMaxDays = $sock->GET_INFO("BackupMaxDays");
    $BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
    $LogsRotateDeleteSize = $sock->GET_INFO("LogsRotateDeleteSize");
    $LogsRotateDefaultSizeRotation = $sock->GET_INFO("LogsRotateDefaultSizeRotation");
    if (!is_numeric($LogsRotateDefaultSizeRotation)) {
        $LogsRotateDefaultSizeRotation = 100;
    }
    $MySQLSyslogType = $sock->GET_INFO("MySQLSyslogType");
    if (!is_numeric($MySQLSyslogType)) {
        $MySQLSyslogType = 1;
    }
    if ($SystemLogsPath == null) {
        $SystemLogsPath = "/var/log";
    }
    if (!is_numeric($BackupMaxDays)) {
        $BackupMaxDays = 30;
    }
    $BackupSquidLogsUseNas = $sock->GET_INFO("BackupSquidLogsUseNas");
    $BackupSquidLogsNASIpaddr = $sock->GET_INFO("BackupSquidLogsNASIpaddr");
    $BackupSquidLogsNASFolder = $sock->GET_INFO("BackupSquidLogsNASFolder");
    $BackupSquidLogsNASUser = $sock->GET_INFO("BackupSquidLogsNASUser");
    $BackupSquidLogsNASPassword = $sock->GET_INFO("BackupSquidLogsNASPassword");
    if (!is_numeric($BackupSquidLogsUseNas)) {
        $BackupSquidLogsUseNas = 0;
    }
    $BackupSquidLogsNASRetry = $sock->GET_INFO("BackupSquidLogsNASRetry");
    if (!is_numeric($BackupSquidLogsNASRetry)) {
        $BackupSquidLogsNASRetry = 0;
    }
    if ($LogRotatePath == null) {
        $LogRotatePath = "/home/logrotate";
    }
    if ($BackupMaxDaysDir == null) {
        $BackupMaxDaysDir = "/home/logrotate_backup";
    }
    if (!is_numeric($LogsRotateDeleteSize)) {
        $LogsRotateDeleteSize = 5000;
    }
    $boot = new boostrap_form();
    $boot->set_field("LogsRotateDeleteSize", "{delete_if_file_exceed} (MB)", $LogsRotateDeleteSize);
    $boot->set_field("LogsRotateDefaultSizeRotation", "{default_size_for_rotation} (MB)", $LogsRotateDefaultSizeRotation);
    $boot->set_field("SystemLogsPath", "{system_logs_path}", $SystemLogsPath, array("BROWSE" => true));
    $boot->set_spacertitle("{storage}");
    if ($MySQLSyslogType == 1) {
        $boot->set_field("storage_files_path", "{storage_files_path}", $LogRotatePath, array("BROWSE" => true, "TOOLTIP" => "{LogRotatePath_explain}"));
        $boot->set_field("BackupMaxDays", "{max_day_in_database}", $BackupMaxDays);
        $boot->set_field("BackupMaxDaysDir", "{backup_folder}", $BackupMaxDaysDir, array("BROWSE" => true, "TOOLTIP" => "{BackupMaxDaysDir_explain}"));
        $boot->set_spacertitle("{NAS_storage}");
        $boot->set_checkbox("BackupSquidLogsUseNas", "{use_remote_nas}", $BackupSquidLogsUseNas, array("TOOLTIP" => "{BackupSquidLogsUseNas_explain}", "LINK" => "BackupSquidLogsNASIpaddr,BackupSquidLogsNASFolder,BackupSquidLogsNASUser,BackupSquidLogsNASPassword"));
        $boot->set_checkbox("BackupSquidLogsNASRetry", "{retry}", $BackupSquidLogsNASRetry, array("TOOLTIP" => "{BackupSquidLogsNASRetry_explain}"));
        $boot->set_field("BackupSquidLogsNASIpaddr", "{hostname}", $BackupSquidLogsNASIpaddr);
        $boot->set_field("BackupSquidLogsNASFolder", "{shared_folder}", $BackupSquidLogsNASFolder, array("ENCODE" => true));
        $boot->set_field("BackupSquidLogsNASUser", "{username}", $BackupSquidLogsNASUser, array("ENCODE" => true));
        $boot->set_fieldpassword("BackupSquidLogsNASPassword", "{password}", $BackupSquidLogsNASPassword, array("ENCODE" => true));
    } else {
        $boot->set_spacerexplain("{syslogs_store_use_remote}");
    }
    $boot->set_Newbutton("{test_connection}", "Loadjs('miniadm.system.syslogstore.php?test-nas-js=yes')");
    echo $boot->Compile() . "<hr style='margin-bottom:10px'>";
}
function ldap_auth_parameters()
{
    $boot = new boostrap_form();
    $squid = new squidbee();
    $users = new usersMenus();
    $sock = new sockets();
    $SquidLdapAuthEnableGroups = $sock->GET_INFO("SquidLdapAuthEnableGroups");
    $EnableKerbAuth = $sock->GET_INFO("EnableKerbAuth");
    $SquidLdapAuthBanner = $sock->GET_INFO("SquidLdapAuthBanner");
    if ($SquidLdapAuthBanner == null) {
        $SquidLdapAuthBanner = "Basic credentials, Please logon...";
    }
    if ($EnableKerbAuth == 1) {
        $error = "<p class=text-error>{ldap_with_ad_explain}</p>";
    }
    $boot->set_spacertitle("{local_ldap}");
    $boot->set_spacerexplain("{authenticate_users_explain}");
    $boot->set_checkbox("ldap_auth", "{local_ldap}", $squid->LDAP_AUTH);
    //$boot->set_checkbox("SquidLdapAuthEnableGroups", "{enable_group_checking}",$SquidLdapAuthEnableGroups);
    $boot->set_field("SquidLdapAuthBanner", "{auth_banner}", $SquidLdapAuthBanner, array("ENCODE" => true));
    $boot->set_spacertitle("{remote_database}");
    $boot->set_spacerexplain("{SQUID_LDAP_AUTH_EXT}");
    $ldap_server = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_server"];
    $ldap_port = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_port"];
    $userdn = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_user"];
    $ldap_password = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_password"];
    $ldap_suffix = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_suffix"];
    $ldap_filter_users = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_filter_users"];
    $ldap_filter_group = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_filter_group"];
    $ldap_server = $squid->EXTERNAL_LDAP_AUTH_PARAMS["ldap_server"];
    $auth_banner = $squid->EXTERNAL_LDAP_AUTH_PARAMS["auth_banner"];
    $EnableSquidExternalLDAP = $squid->LDAP_EXTERNAL_AUTH;
    if ($auth_banner == null) {
        $auth_banner = $SquidLdapAuthBanner;
    }
    if ($ldap_filter_users == null) {
        $ldap_filter_users = "sAMAccountName=%s";
    }
    if ($ldap_filter_group == null) {
        $ldap_filter_group = "(&(objectclass=person)(sAMAccountName=%u)(memberof=*))";
    }
    if ($ldap_port == null) {
        $ldap_port = 389;
    }
    $boot->set_checkbox("EnableSquidExternalLDAP", "{activate}", $EnableSquidExternalLDAP);
    $boot->set_field("ldap_server", "{hostname}", $ldap_server);
    $boot->set_field("ldap_port", "{listen_port}", $ldap_port);
    $boot->set_field("auth_banner", "{auth_banner}", $auth_banner);
    $boot->set_field("ldap_user", "{userdn}", $userdn);
    $boot->set_fieldpassword("ldap_password", "{ldap_password}", $ldap_password, array("ENCODE" => true));
    $boot->set_field("ldap_suffix", "{ldap_suffix}", $ldap_suffix);
    $boot->set_field("ldap_filter_users", "{ldap_filter_users}", $ldap_filter_users);
    $boot->set_field("ldap_filter_group", "{ldap_filter_group}", $ldap_filter_group);
    $boot->set_button("{apply}");
    if (!$users->AsSquidAdministrator) {
        $boot->set_form_locked();
    }
    $boot->set_Newbutton("{restart_onlysquid}", "Loadjs('squid.restart.php?onlySquid=yes&ask=yes');");
    echo $error . $boot->Compile();
}
Exemplo n.º 3
0
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 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 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;
}