HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux aritmodecarnaval.es 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: www-data (33)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/www/aritmodecarnaval/wp-content/plugins/wd-manager/assets/js/api.js
jQuery(document).ready(function () {
	if(! WDAPIVars.user_hash && (WDAdminVars.is_multisite && WDAPIVars.network_admin || !WDAdminVars.is_multisite)){
		checkIfLoggedIn();
	}
	if(jQuery("#wd_login").length){
		jQuery(document).keypress(function(e){
			if(e.which == 13){
				wdLogin(); 
				return false;
			}
		});
	}
});

function checkIfLoggedIn(){
    var data = {
		"type" : "user_id"
	}
    jQuery.ajax({
		type: "POST",
		dataType: 'json',
		url: WDAPIVars.user_data_url,
		data: data,
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		complete: function () {
		},
		success: function (response){ 
			//response = JSON.parse(response);
			if( response["user_id"] ){
				saveHash(response);
			}
			else{
				jQuery(".wd_spinner").hide();
				jQuery(".wd-login-sub").show();
			}
		},
		failure: function (errorMsg) {
			console.log('Failure' + errorMsg);
		},
		error: function (error) {
			console.log(error);
		}            
	}); 	
}

function saveHash(response){
	var data_ = {
		"user_hash" : response["user_id"],
		"user_full_name" : response["user_full_name"],
		"user_activation" : response["user_activation"],
		"action" : "get_user_hash",
		"nonce_WDD" : WDAPIVars.nonce
	};
	
	jQuery.post(WDAPIVars.ajax_url, data_, function (response_){
 		if(response_ != 'nohash'){
			window.location.href = 'admin.php?page=WDD_plugins&wdd_logged_in=1';
		}
		else{
			window.location.href = 'admin.php?page=WDD_plugins&err=1';
		} 
	}); 
}

function wdLogin(){
	var data = {};
	data.username = jQuery("#username").val();
	data.password = jQuery("#password").val();
	data.type = 'login_user';
	if(data.username == '' || data.password == ''){
		jQuery("#invalid_password, #activate_account").hide();
		jQuery("#required_fields").show();
		return false;
	}
	
  jQuery("#wd_login span.spinner").css({"visibility":"visible","display":"inline-block"});
  jQuery("#wd_login").addClass("disable");
    jQuery.ajax({
		type: "POST",
		dataType: 'json',
		url: WDAPIVars.user_data_url,
		data: data,
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		complete: function () {
		},
		success: function (response){
			if(response["user_id"]){
				saveHash(response);
				jQuery("#required_fields").hide();
			} else{
				if( response["user_activation"] == "" ){
					jQuery("#invalid_password").show();
				}
				else jQuery("#activate_account").show();
				jQuery("#required_fields").hide();
				jQuery("#wd_login span.spinner").css({"visibility":"hidden","display":"none"});
				jQuery("#wd_login").removeClass("disable");
			}
		},
		failure: function (errorMsg) {
			console.log('Failure' + errorMsg);
		},
		error: function (error) {
			console.log(error);
		}            
	});	
}

function wdLogout(obj){
	var data = {};
	data.type = 'logout_user';
    jQuery.ajax({
		type: "POST",
		dataType: 'json',
		url: WDAPIVars.user_data_url,
		data: data,
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		complete: function () {
		},
		success: function (response){		
			//obj.form.submit();
		},
		failure: function (errorMsg) {
			console.log('Failure' + errorMsg);
		},
		error: function (error) {
			console.log(error);
		}            
	});		
}