File manager - Edit - /home/autoph/public_html/api/aha/PWRecoverySendLink.php
Back
<?php include '../../../cfg/ahaconn.php'; $mykey = $_GET['keyID']; if($mykey =="OTP-6e59e008b5348b452bsendOTOP615a3033729daae383-email"){ //########################################################################## // ITEXMO SEND SMS API - PHP - CURL-LESS METHOD // Visit www.itexmo.com/developers.php for more info about this API //########################################################################## //########################################################################## function itexmoAA($number,$message,$MyAPIcode,$MyPasswd,$itexMoEmail,$itexMoPassword,$itexMoAPICode,$senderID){ $SendToNumber = $number; try { $ch = curl_init(); $itexmo = array( 'Email' => $itexMoEmail, 'Password' => $itexMoPassword, 'ApiCode' => $itexMoAPICode, 'SenderId'=> $senderID, 'Recipients' => [$SendToNumber], 'Message' => $message ); //curl_setopt($ch, CURLOPT_URL,"https://api.itexmo.com/api/broadcast"); curl_setopt($ch, CURLOPT_URL,"https://api.itexmo.com/api/broadcast-otp"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($itexmo)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); //return curl_exec ($ch); curl_close ($ch); return $response; }catch (Exception $ex){ return $ex->getMessage(); } } //########################################################################## function maskMobileNumber($number) { // Ensure the number is a string $number = (string) $number; // Get the length of the number $length = strlen($number); // Ensure the number has enough digits to mask if ($length < 10) { return $number; // Not enough digits to mask, return as is } // Determine the parts of the number to keep visible $firstVisibleDigits = substr($number, 0, 3); // First 3 digits $lastVisibleDigits = substr($number, -3); // Last 2 digits // Mask the middle part of the number $maskedDigits = str_repeat('*', $length - 5); // Mask all but first 3 and last 2 digits // Combine the visible and masked parts $maskedNumber = $firstVisibleDigits . $maskedDigits . $lastVisibleDigits; return $maskedNumber; } //########################################################################## function generateSecureNumericOTP($length = 6) { $otp = ""; for ($i = 0; $i < $length; $i++) { $otp .= random_int(0, 9); } return $otp; } //######################################################################## //######################################################################## $myOTPCode = generateSecureNumericOTP(); // Example output: 837592 //########################################################################## $emailAdd = $_GET['emailAddress']; $SMSMessage = "Your OTP code is ". $myOTPCode; // Check if e-mail exist in new customer data $sqlR = "SELECT * FROM `customers` WHERE `isActive` = 1 AND `email`='$emailAdd'"; $sqlQ =mysqli_query($conn,$sqlR); $sqlQC = mysqli_num_rows($sqlQ); if ($sqlQC > 0) { while($row= mysqli_fetch_array($sqlQ)){ $custMobile = $row['mobile']; $ahaUserID = $row['aha_user_id']; } //GET aha_tag $sqlT = "SELECT * FROM `aha_pwd` WHERE `deleted` = 0 AND `aha_user_id`='$ahaUserID' LIMIT 1"; $sqlTag =mysqli_query($conn,$sqlT); while($row= mysqli_fetch_array($sqlTag)){ $ahaTag = $row['aha_tag']; } $viewValidationForm="visible"; $migrateDB = 0; $maskMobile = "OTP has been sent to Mobile Number " . maskMobileNumber($custMobile); }else{ // Check if e-mail exist in old_aha_database $sqlOD = "SELECT * FROM `aha_old_customer_data` WHERE `email_a`='$emailAdd' LIMIT 1"; $sqlOld =mysqli_query($conn,$sqlOD); $sqlOLD = mysqli_num_rows($sqlOld); if ($sqlOLD > 0) { while($row = mysqli_fetch_array($sqlOld)){ $custMobile = $row['mobile_a']; $ahaUserID = ""; } $migrateDB = 1; $viewDataMigrationForm = ""; $askEmail =$emailAdd; $viewValidationForm ="visible"; //HIDE OTP INPUT BOX IN APP $myClass = "successClass"; $returnMessage = "OPT has been sent to your registered mobile number."; $maskMobile = "OTP has been sent to Mobile Number " . maskMobileNumber($custMobile); }else{ $migrateDB = 0; $viewDataMigrationForm = ""; $askEmailForm ="visible"; $viewValidationForm =""; //HIDE OTP INPUT BOX IN APP $myClass = "errorClass"; $returnMessage="E-mail address cannot be found."; $maskMobile = "E-mail address cannot be found."; } } //$sendOTP = itexmoAA($custMobile, $SMSMessage,$MyAPIcode,$MyPasswd); $sendOTP = itexmoAA($custMobile,$SMSMessage,$MyAPIcode,$MyPasswd,$itexMoEmail,$itexMoPassword,$itexMoAPICode,$senderID); if ($sendOTP == ""){ $askEmail ="visible"; $myClass = "errorClass"; }else if ($sendOTP == 0){ $askEmail =""; $myClass = "successClass"; }else{ //echo "Error Num '. $sendOTP . ' was encountered!'"; $askEmail ="visible"; $returnMessage = "OTP has been sent to Mobile Number " . maskMobileNumber($custMobile); } echo json_encode(["ahaTag"=>"$ahaTag","status" => "$returnMessage","class" => "$myClass","viewOTPValidationForm" =>"$viewValidationForm","OTPCode" =>"$myOTPCode", "migrateDB" => "$migrateDB", "maskMobile"=>"$maskMobile","askEmailForm"=>"$askEmailForm","ahauserID"=>"$ahaUserID","viewDataMigrationForm"=>"$viewDataMigrationForm"]); } //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ if($mykey =="OTP-6e59e008b5348b452bsendOTOP615a3033729daae383-mobile"){ $emailAdd = $_GET['email_address']; $userID = $_GET['userID']; function generateSecureNumericOTP($length = 6) { $otp = ""; for ($i = 0; $i < $length; $i++) { $otp .= random_int(0, 9); } return $otp; } $myOTPCode = generateSecureNumericOTP(); // Example output: 837592 } //FETCH DATA FORM OLD AHA DATABASE FOR MIGRATION //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ if($mykey =="fetch-6e59e008b5348b452bsendOTOP615a3033729daae383-migrateDB"){ $emailAdd = $_GET['emailAddress']; $sqlM = "SELECT * FROM `aha_old_customer_data` WHERE `email_a`='$emailAdd'"; $mgSQL = mysqli_query($conn,$sqlM); $result = mysqli_num_rows($mgSQL); if ($result > 0) { while($row = mysqli_fetch_array($mgSQL)) { $recID = $row['id']; $cust_id = $row['cust_id']; $firstname = $row['fname']; $middlename = $row['mname']; $lastname = $row['lname']; $mobileA = $row['mobile_a']; $gender = $row['gender']; $facebook = $row['facebook ']; $email = $row['email_a']; } $viewOTPValidationForm = ""; $viewPreRegistrationForm ="Visible"; $viewAskEmailForm = ""; } echo json_encode(["recID"=>"$recID", "emailAdd"=>"$emailAdd", "cust_id" => "$cust_id", "firstname"=>"$firstname", "middlename" =>"$middlename", "lastname" => "$lastname", "mobileA"=>"$mobileA", "gender"=>"$gender", "facebook"=>"$facebook", "viewOTPValidationForm"=>"$viewOTPValidationForm", "viewPreRegistrationForm"=>"$viewPreRegistrationForm", "viewAskEmailForm"=>"$viewAskEmailForm"]); } //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ if($mykey =="OTP-6e59e008b5348b452bsendOTOP615a3033729daae383-ACTIVATE"){ //########################################################################## // ITEXMO SEND SMS API - PHP - CURL-LESS METHOD // Visit www.itexmo.com/developers.php for more info about this API //########################################################################## //########################################################################## function itexmoAA($number,$message,$MyAPIcode,$MyPasswd,$itexMoEmail,$itexMoPassword,$itexMoAPICode,$senderID){ $SendToNumber = $number; try { $ch = curl_init(); $itexmo = array( 'Email' => $itexMoEmail, 'Password' => $itexMoPassword, 'ApiCode' => $itexMoAPICode, 'SenderId'=> $senderID, 'Recipients' => [$SendToNumber], 'Message' => $message ); //curl_setopt($ch, CURLOPT_URL,"https://api.itexmo.com/api/broadcast"); curl_setopt($ch, CURLOPT_URL,"https://api.itexmo.com/api/broadcast-otp"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($itexmo)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); //return curl_exec ($ch); curl_close ($ch); return $response; }catch (Exception $ex){ return $ex->getMessage(); } } //######################################################################### $emailAdd = $_GET['emailAddress']; $mobileNumber = $_GET['mobileNumber']; function generateSecureNumericOTP($length = 6) { $otp = ""; for ($i = 0; $i < $length; $i++) { $otp .= random_int(0, 9); } return $otp; } $activationOTPCode = generateSecureNumericOTP(); $activationCode = "Your Activation OTP Code is ". $activationOTPCode; //######################################################################## //######################################################################## //$sendOTP = itexmoAA($mobileNumber, $activationCode,$MyAPIcode,$MyPasswd); $sendOTP = itexmoAA($mobileNumber,$activationCode,$MyAPIcode,$MyPasswd,$itexMoEmail,$itexMoPassword,$itexMoAPICode,$senderID); if ($sendOTP == ""){ $askEmail ="visible"; $myClass = "errorClass"; }else if ($sendOTP == 0){ $askEmail =""; $myClass = "successClass"; }else{ //echo "Error Num '. $sendOTP . ' was encountered!'"; $askEmail ="visible"; } //######################################################################## //######################################################################## echo json_encode(["e-mail"=>"$emailAdd", "mobileNumber"=>"$mobileNumber", "myOTPCode"=>"$activationOTPCode"]); } $conn->close(); ?>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings