uses('ini_parser,getconf'); $server_config_array = $app->getconf->get_global_config(); ?> var pageFormChanged = false; var tabChangeWarningTxt = ''; var tabChangeDiscardTxt = ''; var tabChangeWarning = false; var tabChangeDiscard = false; var requestsRunning = 0; var indicatorPaddingH = -1; var indicatorPaddingW = -1; var indicatorCompleted = false; var registeredHooks = new Array(); redirect = ''; function reportError(request) { /* Error reporting is disabled by default as some browsers like safari sometimes throw errors when a ajax request is delayed even if the ajax request worked. */ /*alert(request);*/ } function registerHook(name, callback) { if(!registeredHooks[name]) registeredHooks[name] = new Array(); var newindex = registeredHooks[name].length; registeredHooks[name][newindex] = callback; } function callHook(name, params) { if(!registeredHooks[name]) return; for(var i = 0; i < registeredHooks[name].length; i++) { var callback = registeredHooks[name][i]; callback(name, params); } } function resetFormChanged() { pageFormChanged = false; } function showLoadIndicator() { document.body.style.cursor = 'wait'; requestsRunning += 1; if(requestsRunning < 2) { var indicator = jQuery('#ajaxloader'); if(indicator.length < 1) { indicator = jQuery(''); indicator.appendTo('body'); } var parent = jQuery('#content'); if(parent.length < 1) return; indicatorCompleted = false; var atx = parent.offset().left + 150; //((parent.outerWidth(true) - indicator.outerWidth(true)) / 2); var aty = parent.offset().top + 150; indicator.css( {'left': atx, 'top': aty } ).fadeIn('fast', function() { // check if loader should be hidden immediately indicatorCompleted = true; if(requestsRunning < 1) $(this).fadeOut('fast', function() { $(this).hide();}); }); } } function hideLoadIndicator() { document.body.style.cursor = ''; requestsRunning -= 1; if(requestsRunning < 1) { requestsRunning = 0; // just for the case... if(indicatorCompleted == true) jQuery('#ajaxloader').fadeOut('fast', function() { jQuery('#ajaxloader').hide(); } ); } } function onAfterContentLoad(url, data) { if(!data) data = ''; else data = '&' + data; $('#pageContent').find("select:not(.chosen-select)").combobox(); $('.chosen-select').chosen({no_results_text: "", width: '300px'}); callHook('onAfterContentLoad', {'url': url, 'data': data }); } function loadContentRefresh(pagename) { if(document.getElementById('refreshinterval').value > 0) { var pageContentObject2 = jQuery.ajax({ type: "GET", url: pagename, data: "refresh="+document.getElementById('refreshinterval').value, dataType: "html", beforeSend: function() { showLoadIndicator(); }, success: function(data, textStatus, jqXHR) { hideLoadIndicator(); jQuery('#pageContent').html(jqXHR.responseText); onAfterContentLoad(pagename, "refresh="+document.getElementById('refreshinterval').value); pageFormChanged = false; }, error: function() { hideLoadIndicator(); reportError('Ajax Request was not successful.'+pagename); } }); setTimeout( "loadContentRefresh('"+pagename+"&refresh="+document.getElementById('refreshinterval').value+"')", document.getElementById('refreshinterval').value*1000*60 ); } } function capp(module, redirect) { var submitFormObj = jQuery.ajax({ type: "GET", url: "capp.php", data: "mod="+module+((redirect != undefined) ? '&redirect='+redirect : ''), dataType: "html", beforeSend: function() { showLoadIndicator(); }, success: function(data, textStatus, jqXHR) { if(jqXHR.responseText != '') { if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { var parts = jqXHR.responseText.split(':'); loadContent(parts[1]); } else if (jqXHR.responseText.indexOf('URL_REDIRECT:') > -1) { var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length); document.location.href = newUrl; } else { //alert(jqXHR.responseText); } } loadMenus(); hideLoadIndicator(); }, error: function() { hideLoadIndicator(); reportError('Ajax Request was not successful.'+module); } }); } function submitLoginForm(formname) { //* Validate form. TODO: username and password with strip(); var frm = document.getElementById(formname); var userNameObj = frm.username; if(userNameObj.value == ''){ userNameObj.focus(); return; } var passwordObj = frm.passwort; if(passwordObj.value == ''){ passwordObj.focus(); return; } $('#dummy_username').val(userNameObj.value); $('#dummy_passwort').val(passwordObj.value); $('#dummy_login_form').submit(); var submitFormObj = jQuery.ajax({ type: "POST", url: "content.php", data: jQuery('#'+formname).serialize(), dataType: "html", beforeSend: function() { showLoadIndicator(); }, success: function(data, textStatus, jqXHR) { if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { var parts = jqXHR.responseText.split(':'); //alert(parts[1]); loadContent(parts[1]); //redirect = parts[1]; //window.setTimeout('loadContent(redirect)', 1000); } else if (jqXHR.responseText.indexOf('LOGIN_REDIRECT:') > -1) { // Go to the login page document.location.href = 'index.php'; } else { jQuery('#pageContent').html(jqXHR.responseText); onAfterContentLoad('content.php', jQuery('#'+formname).serialize()); pageFormChanged = false; } loadMenus(); hideLoadIndicator(); }, error: function() { hideLoadIndicator(); reportError('Ajax Request was not successful.110'); } }); /* if(redirect != '') { loadContent(redirect); redirect = ''; } document.getElementById('footer').innerHTML = 'Powered by ISPConfig'; */ } function submitForm(formname,target) { var submitFormObj = jQuery.ajax({ type: "POST", url: target, data: jQuery('#'+formname).serialize(), dataType: "html", beforeSend: function() { showLoadIndicator(); }, success: function(data, textStatus, jqXHR) { if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { var parts = jqXHR.responseText.split(':'); //alert(parts[1]); loadContent(parts[1]); //redirect = parts[1]; //window.setTimeout('loadContent(redirect)', 1000); } else { jQuery('#pageContent').html(jqXHR.responseText); onAfterContentLoad(target, jQuery('#'+formname).serialize()); pageFormChanged = false; } hideLoadIndicator(); }, error: function(jqXHR, textStatus, errorThrown) { hideLoadIndicator(); var parts = jqXHR.responseText.split(':'); reportError('Ajax Request was not successful. 111'); } }); /* if(redirect != '') { loadContent(redirect); redirect = ''; } */ } function submitFormConfirm(formname,target,confirmation) { var successMessage = arguments[3]; if(window.confirm(confirmation)) { var submitFormObj = jQuery.ajax({ type: "POST", url: target, data: jQuery('#'+formname).serialize(), dataType: "html", beforeSend: function() { showLoadIndicator(); }, success: function(data, textStatus, jqXHR) { if(successMessage) alert(successMessage); if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { var parts = jqXHR.responseText.split(':'); //alert(parts[1]); loadContent(parts[1]); //redirect = parts[1]; //window.setTimeout('loadContent(redirect)', 1000); } else { jQuery('#pageContent').html(jqXHR.responseText); onAfterContentLoad(target, jQuery('#'+formname).serialize()); pageFormChanged = false; } hideLoadIndicator(); }, error: function(jqXHR, textStatus, errorThrown) { hideLoadIndicator(); var parts = jqXHR.responseText.split(':'); reportError('Ajax Request was not successful. 111'); } }); } } function submitUploadForm(formname,target) { var handleResponse = function(loadedFrame) { var response, responseStr = loadedFrame.contentWindow.document.body.innerHTML; try { response = JSON.parse(responseStr); } catch(e) { response = responseStr; } var msg = ''; var okmsg = jQuery('#OKMsg',response).html(); if(okmsg){ msg = '
'+okmsg+'
'; } var errormsg = jQuery('#errorMsg',response).html(); if(errormsg){ msg = msg+'
'+errormsg+'
'; } return msg; }; var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000); jQuery('body').after('