HEX
Server: Apache/2.4.41 (FreeBSD) OpenSSL/1.0.2s mod_fcgid/2.3.9
System: FreeBSD salazo 12.0-RELEASE-p1303-ZFS hostBSD 12.0-RELEASE-p1303-ZFS DMR amd64
User: admin (1000)
PHP: 7.4.3
Disabled: NONE
Upload Files
File: /usr/local/www/apache24/noexec/userdocs/js/domainadmin.js
var nocache = new Date().getTime();
var post_url = '/usertool/domainadmin.pl';
var root_modal = '';
var parent_modal_action = '';

function modal_popup(this_object, args){
	//default modal
	var modal_div = '#modal_window';
	
	if(typeof($(this_object).attr('href')) !== 'undefined'){
		if($(this_object).attr('href') != '#'){
		modal_div = $(this_object).attr('href');
		}
	}
	
	//var this_form = $(modal_div).children('form').attr('id');
	
	//alert(modal_div);
		
	if ($(modal_div).css('display') == 'block') {
		if($(modal_div + " .modal-content").length != 0){	
		$('.tooltip.in').remove();	
		$(modal_div + " .modal-content").empty();
		}
	}
    
	//if($(this_object).hasClass('modal-form-horizontal')){
	//$(this_form).removeClass('form-inline');
	//$(this_form).addClass('form-horizontal');
	//$(this_form + " .modal-dialog").removeClass('modal-lg');
	//}
	//else{	
	//$(this_form).removeClass('form-horizontal');
	//$(this_form).addClass('form-inline');
	//$(this_form + " .modal-dialog").addClass('modal-lg');
	//}
	
	
	if($(this_object).hasClass('modal-form-horizontal')){
	//$(this_form).removeClass('form-inline');
	//$(this_form).addClass('form-horizontal');
	$(modal_div + " .modal-dialog").removeClass('modal-lg');
	}
	else{	
	//$(this_form).removeClass('form-horizontal');
	//$(this_form).addClass('form-inline');
	$(modal_div + " .modal-dialog").addClass('modal-lg');
	}
	
	// store parent modal and reload on reopen
	// eventlistener on class .is_child opens parent after closing child
	if(typeof($(this_object).data('parentaction')) !== 'undefined'){
		if($(this_object).data('parentaction').length){
		//alert('data-modal-parent');
		parent_modal_action = $(this_object).data('parentaction');
		$('#modal_window').modal('hide');
		}
	}
	
	// special solution for multiple country select modal in change_special_spamfilter
	// no reload for reopening parent modal
	var regex_match = [];
	var regex_string = $(this_object).attr("class");
	var myRegexp = /(?:^|\s)modal-target-(.*?)(?:\s|$)/g;
	regex_match = myRegexp.exec(regex_string);

	if(regex_match != null){
		modal_div = '#'+regex_match[1];
		root_modal = modal_div;
	}
	
    $.getJSON( post_url + "?action=" + args + "&cache=" + nocache, function( data ) {
        var json_map = to_json_map(data);
        $(modal_div).find('.modal-content').replaceWith(json_map["ajax_html"]);
		init_js();                    
    });
    
$(modal_div).modal({
  backdrop: 'static',
  keyboard: false
});

	if ($(modal_div).css('display') != 'block') {
		$(modal_div).modal('show');
	}

}

function init_js(){
    
    $('.popover1').popover({'trigger':'hover'});
	$('.tooltip1').tooltip({'placement':'top', 'trigger':'hover', 'container':'body'});
	$('.selectpicker').selectpicker();
	//$('.dropdown-toggle').dropdown();
	
	$('.tooltip.in').remove();
				
    $('table').tablesorter({
        widgets        : ['zebra', 'columns'],
        usNumberFormat : false,
        sortReset      : true,
        sortRestart    : true,
        theme : 'default',
		textExtraction: function(node){ 

		  var numVal = parseFloat($(node).text());
		  if(!numVal){
			return $(node).text();
		  } else {
			if($(node).text().endsWith("kB")){
				numVal *= 1000;
			} else if($(node).text().endsWith("MB")){
				numVal *= 1000 * 1000;
			} else if($(node).text().endsWith("GB")){
				numVal *= 1000 * 1000 * 1000;
			}
			return numVal;
		  }
		  
		}
        //sortList: [[0,0]]
    });
    
}

function to_json_map(data) {
	var json_map = new Object();
			
		$.each(data, function(key, val){
		    
		json_map[key] = val;
			
		});
	return(json_map);
}

function form_modal_post_submit( this_object ){
	
	var this_form = $(this_object).closest('form').attr('id');
	var this_modal_window = $(this_object).closest('.modal').attr('id');
		
	//if a popup has to been opened and form submit from non modal, e.g. delete_sendmail_cw then open modal stored in data-...
	//and show form submit response
	//<a href="#" data-modal-popup="modal_window" onclick="document_submit...
	if(typeof($(this_object).data('modal-popup')) !== 'undefined'){
		if($(this_object).data('modal-popup').length){
			this_modal_window = $(this_object).data('modal-popup');
			if ($("#"+this_modal_window).css('display') != 'block') {
			$("#"+this_modal_window).modal('show');
			}
		}
	}
	    
    $.post( post_url, $('#'+this_form).serializeArray(),
        function( data ) {

		var parsedJson = $.parseJSON(data);
		$("#"+this_modal_window +" .tooltip1").hide();
		
			if(typeof parsedJson.critical_error != 'undefined'){
				$("#"+this_modal_window).find('.modal-footer .form-submit').remove();
				$("#"+this_modal_window).find('.modal-body').html(parsedJson.ajax_html);
				init_js();
            }
			else if(typeof parsedJson.error != 'undefined'){
				$("#"+this_modal_window).find('.modal-content').replaceWith(parsedJson.ajax_html);
				init_js();
            }
			else if(typeof parsedJson.redirect_to != 'undefined'){
				$( "#"+this_modal_window ).modal('hide');
				
				if(parsedJson.redirect_to.charAt(0) === '/'){
						window.location.href = parsedJson.redirect_to;
				} else {
				
					/*
					if(window.location.href.indexOf(parsedJson.redirect_to.charAt(0)) > 0){
						
						window.location.href = window.location.href.substr(0, window.location.href.indexOf(parsedJson.redirect_to.charAt(0))) + parsedJson.redirect_to;
						
					} else {
						
						window.location.href += parsedJson.redirect_to;
						
					}
					*/
					
					window.location.href = window.location.href.replace(/&success_text=[^&]*/g,'').replace(/#+/g,'') + parsedJson.redirect_to;
				
				}
				
			}
			else if(typeof parsedJson.modal_action != 'undefined'){
				$( "#"+this_modal_window ).modal('hide');
				modal_popup(this, parsedJson.modal_action + parsedJson.modal_action_args);
            }
			else if(typeof parsedJson.ajax_html != 'undefined'){
				$("#"+this_modal_window).find('.modal-content').replaceWith(parsedJson.ajax_html);
				init_js();
            }
			else{
				$( '#main-content' ).empty();
				$( '#main-content' ).append(parsedJson.ajax_html);
				$( "#"+this_modal_window ).modal('hide');
				init_js();
			}
					
        });    
}

function show_message(message, div, type){
	
	//mobile browser switch
	if ($('body').hasClass('mobile')) {
    type = 'modal';	
	div = 'modal_message';
	$('#modal_message').modal('show');
	}
	
	
	if (type == 'modal') {
		if($("#" + div + " .modal_message").length == 0){    
		$('#' + div).find('.modal-body').prepend('<h2 class="modal_message">' + message + '</h2>');
		}
		else{
		$( "#" + div + " .modal_message" ).replaceWith('<h2 class="modal_message">' + message + '</h2>');
		}
	}
	else{		
		if($("#inline_message").length == 0){    
		$( "#"+div ).prepend('<span id="inline_message">' + message + '</span>');
		}
		else{
		$( "#inline_message" ).replaceWith('<span id="inline_message">' + message + '</span>');
		}
		
		window.scrollTo(0, 0);
		
	}
}

function block_ui(message){

	if(message === undefined || message.length < 1){
		message = 'Bitte warten...';
	}
	
	$.blockUI({ message: '<br><br><div style="font-family: Oswald, sans-serif !important;text-transform:uppercase !important;letter-spacing:0.1em !important;font-size: 14px;font-weight: normal;">' + message + '</div><br><br><img src="/files/themes/hostnet/img/ajax-loader4.gif" /><br><br><br><br>',
		css: { 	'border-top-color': '#fff',
				'border-right-color': '#fff',
				'border-bottom-color': '#fff',
				'border-left-color': '#fff',
				top:  ($(window).height() - 262) /2 + 'px', 
                left: ($(window).width() - 262) /2 + 'px', 
                width: '262px',
				'box-shadow': '0px 3px 9px #000'
			
			}
			
	});

}

function unblock_ui(){
$(document).ajaxStop($.unblockUI);
}

function form_reset(form_id){	
$("#" + form_id).find("input[type=text], input[type=email], textarea").val("");
}

//function check_all(checkbox_class){
//	$("."+checkbox_class).attr("checked", true);
//}

function check_all(checkbox_prefix){

	for (count = 1;; count++) {
		if(! document.getElementById(checkbox_prefix + count)) break;

		if(document.getElementById(checkbox_prefix + count)){
		document.getElementById(checkbox_prefix + count).checked=true;
		}
	}

}

//function uncheck_all(checkbox_class){
//    $("."+checkbox_class).attr("checked", false);
//}

function uncheck_all(checkbox_prefix){
	for (count = 1;; count++) {
		if(! document.getElementById(checkbox_prefix + count)) break;

		if(document.getElementById(checkbox_prefix + count)){
		document.getElementById(checkbox_prefix + count).checked=false;
		}
	}

}

function show_hide_password(prefix){
	for (count = 1;; count++) {
		if(! document.getElementById(prefix + count)) break;

		if(document.getElementById(prefix + count).type == 'password'){	
		document.getElementById(prefix + count).type='text';
			if (count == 1) {
				document.getElementById('password_show').style.display='none';
				document.getElementById('password_hide').style.display='block';
			}		
		}
		else{
		document.getElementById(prefix + count).type='password';
			if (count == 1) {
			document.getElementById('password_show').style.display='block';
			document.getElementById('password_hide').style.display='none';
			}
		}
	}
}

function document_submit(this_object, formular, checkbox_prefix){
	
	for (count = 1;; count++) {	
		if(! document.getElementById(checkbox_prefix + count)) break;

		if(document.getElementById(checkbox_prefix + count).checked == true){
		//document.getElementById(formular).submit();
		form_modal_post_submit(this_object);
		}
	}
}

function show_hide_new_vhost_ftp_mysql(id){

	if (document.getElementById(id).style.display == 'none'){
	var domains = document.getElementById('domains');
	var regex =/([^\s]{1,64})/;
	regex.exec(document.getElementById('domains').value);
	var first_domain = RegExp.$1;
	
	var first_domain_clean = first_domain.replace(/\W/g, '_');
	first_domain_clean = first_domain_clean.substr(0, 16);
	var password = getPassword(6,1,1,1,1,1,1,1,1,1);
	
		if(id == 'with_ftp'){
		document.getElementById('ftpuser').value = first_domain_clean;
			if(document.getElementById('ftppass').value == ''){
			document.getElementById('ftppass').value = password;
			}		
		document.getElementById('ftpdescription').value = "FTP " + first_domain_clean;
		}

		if(id == 'with_mysql_db'){
		document.getElementById('db').value = first_domain_clean;
		document.getElementById('dbuser').value = first_domain_clean;
			if(document.getElementById('dbpass').value == ''){
			document.getElementById('dbpass').value = password;
			}
		}

	document.getElementById(id).style.display = 'block';
	}
	else{
	document.getElementById(id).style.display = 'none';
	}

}

function domain_to_serveradmin(id){
if(! id){return};
var domains = $('textarea#domains').val();
var regex =/([A-Za-z0-9-.äöüÄÖÜ]{1,64})/;
regex.exec(domains);
var first_domain = RegExp.$1;

document.getElementById(id).value = 'webmaster@' + punycode.toASCII(first_domain);
}

function domain_to_droot(id){
if(! id){return};
var domains = $('textarea#domains').val();
var regex =/([A-Za-z0-9-.äöüÄÖÜ]{1,64})/;
regex.exec(domains);
var first_domain = RegExp.$1;

document.getElementById(id).value = '/home/httpd/docs/' + punycode.toASCII(first_domain);
}

function domain_to_droot_fb(id){
if(! id){return};
var domains = $('textarea#domains').val();
var regex =/([A-Za-z0-9-.äöüÄÖÜ]{1,64})/;
regex.exec(domains);
var first_domain = RegExp.$1;

document.getElementById(id).value = '/usr/local/www/apache24/noexec/' + punycode.toASCII(first_domain);
}

function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther, latterNumber, latterLower, latterUpper, latterOther) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);


for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
}
return rc;
}

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "23456789";
var lowerChars = "abcdefghkmnopqrstuvwxyz";
var upperChars = "ABCDEFGHJKLMNPQRSTUVWXYZ";
var otherChars = "~@#$%&*-_=+?";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}

function clone_form(this_object, type) {
	if (type == 'change_forward_freefield') {
	// format is freefield5_2
	var regex_string = $(this_object).parent().find('input.change_forward_freefields').last().attr('id');
	var regex = /([\d]+)_([\d]+)$/;
	var match = regex.exec(regex_string);
	var usercount = match[1];
	var freefield_count = match[2];
	freefield_count++;
	$(this_object).before($('#clone_me_change_forward_freefields').html());
	$(this_object).parent().find('input.change_forward_freefields').last().attr({
		'id': 'freefield'+usercount+'_'+freefield_count,
		'name': 'freefield'+usercount+'_'+freefield_count,
		});
	}
}