Edit File by line
/home/barbar84/www/wp-conte.../plugins/minioran.../controll...
File: account.php
<?php
[0] Fix | Delete
[1] Fix | Delete
global $MoMmpUtility,$mmp_dirName;
[2] Fix | Delete
[3] Fix | Delete
if ( current_user_can( 'manage_options' ) and isset( $_POST['option'] ) )
[4] Fix | Delete
{
[5] Fix | Delete
$option = trim($_POST['option']);
[6] Fix | Delete
switch($option)
[7] Fix | Delete
{
[8] Fix | Delete
case "mo_wpns_register_customer":
[9] Fix | Delete
mo_mmp_register_customer($_POST);
[10] Fix | Delete
break;
[11] Fix | Delete
case "mo_wpns_verify_customer":
[12] Fix | Delete
mo_mmp_verify_customer($_POST);
[13] Fix | Delete
break;
[14] Fix | Delete
case "mo_wpns_validate_otp":
[15] Fix | Delete
mo_mmp_validate_otp($_POST);
[16] Fix | Delete
break;
[17] Fix | Delete
case "mo_wpns_resend_otp":
[18] Fix | Delete
mo_mmp_send_otp_token(get_option('mo_wpns_admin_email'),"",'EMAIL');
[19] Fix | Delete
break;
[20] Fix | Delete
case "mo_wpns_phone_verification":
[21] Fix | Delete
mo_mmp_send_phone_otp_token($_POST);
[22] Fix | Delete
break;
[23] Fix | Delete
case "mo_wpns_cancel":
[24] Fix | Delete
mo_mmp_revert_back_registration();
[25] Fix | Delete
break;
[26] Fix | Delete
case "mo_wpns_reset_password":
[27] Fix | Delete
mo_mmp_reset_password();
[28] Fix | Delete
case "mo_wpns_log_out":
[29] Fix | Delete
mo_wpns_log_out($_POST);
[30] Fix | Delete
break;
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
[35] Fix | Delete
if(get_option('mo_wpns_registration_status') == 'MO_OTP_DELIVERED_SUCCESS'
[36] Fix | Delete
|| get_option('mo_wpns_registration_status') == 'MO_OTP_VALIDATION_FAILURE'
[37] Fix | Delete
|| get_option('mo_wpns_registration_status') == 'MO_OTP_DELIVERED_FAILURE')
[38] Fix | Delete
{
[39] Fix | Delete
$admin_phone = get_option('mo_wpns_admin_phone') ? get_option('mo_wpns_admin_phone') : "";
[40] Fix | Delete
include $mmp_dirName . 'views'.DIRECTORY_SEPARATOR.'account'.DIRECTORY_SEPARATOR.'verify.php';
[41] Fix | Delete
}
[42] Fix | Delete
else if (! $MoMmpUtility->icr())
[43] Fix | Delete
{
[44] Fix | Delete
delete_option ( 'password_mismatch' );
[45] Fix | Delete
update_option ( 'mo_wpns_new_registration', 'true' );
[46] Fix | Delete
$current_user = wp_get_current_user();
[47] Fix | Delete
$admin_email = get_option('mo_wpns_admin_email') ? get_option('mo_wpns_admin_email') : "";
[48] Fix | Delete
include $mmp_dirName . 'views'.DIRECTORY_SEPARATOR.'account'.DIRECTORY_SEPARATOR.'register.php';
[49] Fix | Delete
}
[50] Fix | Delete
else
[51] Fix | Delete
{
[52] Fix | Delete
$email = get_option('mo_wpns_admin_email');
[53] Fix | Delete
$key = get_option('mo_wpns_admin_customer_key');
[54] Fix | Delete
$api = get_option('mo_wpns_admin_api_key');
[55] Fix | Delete
$token = get_option('mo_wpns_customer_token');
[56] Fix | Delete
include $mmp_dirName . 'views'.DIRECTORY_SEPARATOR.'account'.DIRECTORY_SEPARATOR.'profile.php';
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
[60] Fix | Delete
[61] Fix | Delete
[62] Fix | Delete
[63] Fix | Delete
/* REGISTRATION RELATED FUNCTIONS */
[64] Fix | Delete
[65] Fix | Delete
//Function to register new customer
[66] Fix | Delete
function mo_mmp_register_customer($post)
[67] Fix | Delete
{
[68] Fix | Delete
//validate and sanitize
[69] Fix | Delete
global $MoMmpUtility;
[70] Fix | Delete
$email = sanitize_email($post['email']);
[71] Fix | Delete
$password = sanitize_text_field($post['password']);
[72] Fix | Delete
$confirmPassword = sanitize_text_field($post['confirmPassword']);
[73] Fix | Delete
[74] Fix | Delete
if( strlen( $password ) < 6 || strlen( $confirmPassword ) < 6)
[75] Fix | Delete
{
[76] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('PASS_LENGTH'),'ERROR');
[77] Fix | Delete
return;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
if( $password != $confirmPassword )
[81] Fix | Delete
{
[82] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('PASS_MISMATCH'),'ERROR');
[83] Fix | Delete
return;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
if( $MoMmpUtility->check_empty_or_null( $email ) || $MoMmpUtility->check_empty_or_null( $password )
[87] Fix | Delete
|| $MoMmpUtility->check_empty_or_null( $confirmPassword ) )
[88] Fix | Delete
{
[89] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REQUIRED_FIELDS'),'ERROR');
[90] Fix | Delete
return;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
update_option( 'mo_wpns_admin_email', $email );
[94] Fix | Delete
update_option( 'mo_wpns_password' , $password );
[95] Fix | Delete
[96] Fix | Delete
$customer = new mo_mmp_MocURL();
[97] Fix | Delete
$content = $customer->check_customer($email);
[98] Fix | Delete
[99] Fix | Delete
if(!is_array($content))
[100] Fix | Delete
$content=json_decode($content,true);
[101] Fix | Delete
[102] Fix | Delete
[103] Fix | Delete
switch ($content['status'])
[104] Fix | Delete
{
[105] Fix | Delete
case 'CUSTOMER_NOT_FOUND':
[106] Fix | Delete
mo_mmp_create_customer($email,"",$password);
[107] Fix | Delete
break;
[108] Fix | Delete
default:
[109] Fix | Delete
mo_mmp_get_current_customer($email,$password);
[110] Fix | Delete
break;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
function mo_mmp_create_customer($email, $company, $password)
[116] Fix | Delete
{
[117] Fix | Delete
$customer = new mo_mmp_MocURL();
[118] Fix | Delete
$customerKey = json_decode($customer->create_customer($email, $company, $password, $phone = '', $first_name = '', $last_name = ''), true);
[119] Fix | Delete
[120] Fix | Delete
if(strcasecmp($customerKey['status'], 'CUSTOMER_USERNAME_ALREADY_EXISTS') == 0)
[121] Fix | Delete
{
[122] Fix | Delete
mo_mmp_get_current_customer($email,$password);
[123] Fix | Delete
}
[124] Fix | Delete
else if(strcasecmp($customerKey['status'], 'SUCCESS') == 0)
[125] Fix | Delete
{
[126] Fix | Delete
mo_mmp_save_success_customer_config($customerKey['id'], $customerKey['apiKey'], $customerKey['token'], $customerKey['appSecret']);
[127] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REG_SUCCESS'),'SUCCESS');
[128] Fix | Delete
}else{
[129] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('UNKNOWN_ERROR'),'ERROR');
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
//Function to go back to the registration page
[135] Fix | Delete
function mo_mmp_revert_back_registration()
[136] Fix | Delete
{
[137] Fix | Delete
delete_option('mo_wpns_admin_email');
[138] Fix | Delete
delete_option('mo_wpns_registration_status');
[139] Fix | Delete
delete_option('mo_wpns_verify_customer');
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
[143] Fix | Delete
//Function to reset customer's password
[144] Fix | Delete
function mo_mmp_reset_password()
[145] Fix | Delete
{
[146] Fix | Delete
$customer = new mo_mmp_MocURL();
[147] Fix | Delete
$forgot_password_response = json_decode($customer->mo_wpns_forgot_password());
[148] Fix | Delete
if($forgot_password_response->status == 'SUCCESS')
[149] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('RESET_PASS'),'SUCCESS');
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
[153] Fix | Delete
//Function to verify customer
[154] Fix | Delete
function mo_mmp_verify_customer($post)
[155] Fix | Delete
{
[156] Fix | Delete
global $MoMmpUtility;
[157] Fix | Delete
$email = sanitize_email( $post['email'] );
[158] Fix | Delete
$password = sanitize_text_field( $post['password'] );
[159] Fix | Delete
[160] Fix | Delete
if( $MoMmpUtility->check_empty_or_null( $email ) || $MoMmpUtility->check_empty_or_null( $password ) )
[161] Fix | Delete
{
[162] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REQUIRED_FIELDS'),'ERROR');
[163] Fix | Delete
return;
[164] Fix | Delete
}
[165] Fix | Delete
mo_mmp_get_current_customer($email,$password);
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
[169] Fix | Delete
//Function to validate OTP
[170] Fix | Delete
function mo_mmp_validate_otp($post)
[171] Fix | Delete
{
[172] Fix | Delete
global $MoMmpUtility;
[173] Fix | Delete
$otp_token = sanitize_text_field( $post['otp_token'] );
[174] Fix | Delete
$email = get_option('mo_wpns_admin_email');
[175] Fix | Delete
$company = get_option('mo_wpns_company');
[176] Fix | Delete
$first_name = get_option('mo_wpns_firstName');
[177] Fix | Delete
$last_name = get_option('mo_wpns_lastName');
[178] Fix | Delete
$phone = get_option('mo_wpns_admin_phone');
[179] Fix | Delete
$password = get_option('mo_wpns_password');
[180] Fix | Delete
[181] Fix | Delete
if( $MoMmpUtility->check_empty_or_null( $otp_token ) )
[182] Fix | Delete
{
[183] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REQUIRED_OTP'),'ERROR');
[184] Fix | Delete
update_option('mo_wpns_registration_status','MO_OTP_VALIDATION_FAILURE');
[185] Fix | Delete
return;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
$customer = new mo_mmp_MocURL();
[189] Fix | Delete
$content = json_decode($customer->validate_otp_token(get_option('mo_wpns_transactionId'), $otp_token ),true);
[190] Fix | Delete
if(strcasecmp($content['status'], 'SUCCESS') == 0)
[191] Fix | Delete
{
[192] Fix | Delete
$customerKey = json_decode($customer->create_customer($email, $company, $password, $phone = '', $first_name = '', $last_name = ''), true);
[193] Fix | Delete
if(strcasecmp($customerKey['status'], 'CUSTOMER_USERNAME_ALREADY_EXISTS') == 0)
[194] Fix | Delete
{
[195] Fix | Delete
mo_mmp_get_current_customer($email,$password);
[196] Fix | Delete
}
[197] Fix | Delete
else if(strcasecmp($customerKey['status'], 'SUCCESS') == 0)
[198] Fix | Delete
{
[199] Fix | Delete
mo_mmp_save_success_customer_config($customerKey['id'], $customerKey['apiKey'], $customerKey['token'], $customerKey['appSecret']);
[200] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REG_SUCCESS'),'SUCCESS');
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
else
[204] Fix | Delete
{
[205] Fix | Delete
update_option('mo_wpns_registration_status','MO_OTP_VALIDATION_FAILURE');
[206] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('INVALID_OTP'),'ERROR');
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
[211] Fix | Delete
///Function to send otp token to phone
[212] Fix | Delete
function mo_mmp_send_phone_otp_token($post)
[213] Fix | Delete
{
[214] Fix | Delete
$phone = sanitize_text_field($_POST['phone_number']);
[215] Fix | Delete
$phone = str_replace(' ', '', $phone);
[216] Fix | Delete
$pattern = "/[\+][0-9]{1,3}[0-9]{10}/";
[217] Fix | Delete
if(preg_match($pattern, $phone, $matches, PREG_OFFSET_CAPTURE))
[218] Fix | Delete
{
[219] Fix | Delete
update_option('mo_wpns_admin_phone',$phone);
[220] Fix | Delete
mo_mmp_send_otp_token("",$phone,'PHONE');
[221] Fix | Delete
}
[222] Fix | Delete
else
[223] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('INVALID_PHONE'),'ERROR');
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
[227] Fix | Delete
//Function to send OTP token
[228] Fix | Delete
function mo_mmp_send_otp_token($email,$phone,$auth_type)
[229] Fix | Delete
{
[230] Fix | Delete
$customer = new mo_mmp_MocURL();
[231] Fix | Delete
$content = json_decode($customer->send_otp_token($auth_type,$phone,$email), true);
[232] Fix | Delete
if(strcasecmp($content['status'], 'SUCCESS') == 0)
[233] Fix | Delete
{
[234] Fix | Delete
update_option('mo_wpns_transactionId',$content['txId']);
[235] Fix | Delete
update_option('mo_wpns_registration_status','MO_OTP_DELIVERED_SUCCESS');
[236] Fix | Delete
if($auth_type=='EMAIL')
[237] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('OTP_SENT',array('method'=>$email)),'SUCCESS');
[238] Fix | Delete
else
[239] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('OTP_SENT',array('method'=>$phone)),'SUCCESS');
[240] Fix | Delete
}
[241] Fix | Delete
else
[242] Fix | Delete
{
[243] Fix | Delete
update_option('mo_wpns_registration_status','MO_OTP_DELIVERED_FAILURE');
[244] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('ERR_OTP_EMAIL'),'ERROR');
[245] Fix | Delete
}
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
[249] Fix | Delete
//Function to get customer details
[250] Fix | Delete
function mo_mmp_get_current_customer($email,$password)
[251] Fix | Delete
{
[252] Fix | Delete
$customer = new mo_mmp_MocURL();
[253] Fix | Delete
$content = $customer->get_customer_key($email,$password);
[254] Fix | Delete
$customerKey = json_decode($content, true);
[255] Fix | Delete
if(json_last_error() == JSON_ERROR_NONE)
[256] Fix | Delete
{
[257] Fix | Delete
update_option( 'mo_wpns_admin_phone', $customerKey['phone'] );
[258] Fix | Delete
update_option( 'mo_wpns_admin_email', $email );
[259] Fix | Delete
mo_mmp_save_success_customer_config($customerKey['id'], $customerKey['apiKey'], $customerKey['token'], $customerKey['appSecret']);
[260] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('REG_SUCCESS'),'SUCCESS');
[261] Fix | Delete
}
[262] Fix | Delete
else
[263] Fix | Delete
{
[264] Fix | Delete
update_option('mo_wpns_verify_customer', 'true');
[265] Fix | Delete
delete_option('mo_wpns_new_registration');
[266] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('ACCOUNT_EXISTS'),'ERROR');
[267] Fix | Delete
}
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
[271] Fix | Delete
//Save all required fields on customer registration/retrieval complete.
[272] Fix | Delete
function mo_mmp_save_success_customer_config($id, $apiKey, $token, $appSecret)
[273] Fix | Delete
{
[274] Fix | Delete
update_option( 'mo_wpns_admin_customer_key' , $id );
[275] Fix | Delete
update_option( 'mo_wpns_admin_api_key' , $apiKey );
[276] Fix | Delete
update_option( 'mo_wpns_customer_token' , $token );
[277] Fix | Delete
update_option( 'mo_wpns_app_secret' , $appSecret );
[278] Fix | Delete
update_option( 'mo_wpns_enable_log_requests' , true );
[279] Fix | Delete
update_option( 'mo_wpns_password' , '' );
[280] Fix | Delete
delete_option( 'mo_wpns_verify_customer' );
[281] Fix | Delete
delete_option( 'mo_wpns_registration_status' );
[282] Fix | Delete
delete_option( 'mo_wpns_password' );
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
function mo_wpns_log_out($POSTED){
[286] Fix | Delete
[287] Fix | Delete
$nonce = $POSTED['nonce'];
[288] Fix | Delete
if ( ! wp_verify_nonce( $nonce, 'mo-wpns-log-out' ) ){
[289] Fix | Delete
wp_send_json('ERROR');
[290] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('ERR_ACCOUNT_LOGOUT'),'ERROR');
[291] Fix | Delete
return;
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
delete_option( 'mo_wpns_admin_customer_key' );
[295] Fix | Delete
delete_option( 'mo_wpns_admin_api_key' );
[296] Fix | Delete
delete_option( 'mo_wpns_customer_token' );
[297] Fix | Delete
delete_option( 'mo_wpns_app_secret' );
[298] Fix | Delete
delete_option( 'mo_wpns_enable_log_requests' );
[299] Fix | Delete
delete_option( 'mo_wpns_password' );
[300] Fix | Delete
delete_option('mo_wpns_admin_email' );
[301] Fix | Delete
delete_option('mo_wpns_admin_phone' );
[302] Fix | Delete
do_action('mo_mmp_show_message',MoMmpMessages::showMessage('SUCCESS_ACCOUNT_LOGOUT'),'SUCCESS');
[303] Fix | Delete
}
[304] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function