Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php include('function/function.php'); $data = json_decode(file_get_contents('php://inpu..
Decoded Output download
<?php include('function/function.php');
$data = json_decode(file_get_contents('php://input'), true);
if (empty($data)) {
$data = json_encode($_POST);
$data = json_decode($data, true);
}
if (filesize("in_request.log") > 10240) {
//unlink("in_request.log");
}
$req_dump = print_r($_REQUEST, TRUE);
$req_files = print_r($_FILES, TRUE);
$fp = fopen('in_request.log', 'a');
fwrite($fp, " #################################### Request added on " . date("Y-m-d H:i:s"));
fwrite($fp, $req_dump);
fwrite($fp, $req_files);
fwrite($fp, print_r($data, TRUE));
fclose($fp);
//exit;
$table_name = "in_request";
$form_data = array(
"body" => $_REQUEST['body'],
"wafrom" => $_REQUEST['from'],
"name" => $_REQUEST['name'],
"type" => $_REQUEST['type'],
"created_at" => $_REQUEST['created_at'],
"reply_to" => $_REQUEST['reply_to'],
"wanumber" => $_REQUEST['wanumber'],
"mobile" => $_REQUEST['mobile'],
"custom_response" => $_REQUEST['custom_response'],
"cdate" => date("Y-m-d H:i:s")
);
dbRowInsert($table_name, $form_data, $debug = 0);
//Checking Message History
record_set('check_msg', 'select id,otpstatus,reply_to from requests where phone_number="' . $form_data['wafrom'] . '" and template="consent_message_v2" and (otpstatus!="verified" or otpstatus is NULL) ORDER BY id DESC limit 1');
$to = $form_data['wafrom'];
$smsphone = substr($form_data['wafrom'], -10);
if ($totalRows_check_msg > 0) {
$check_data = mysqli_fetch_assoc($check_msg);
if ($form_data['body'] == "Yes I am interested" && $check_data['reply_to'] == $form_data['reply_to']) {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP SMS SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$to = $form_data['wafrom'];
$template = "enter_confirmation_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "phone_verified");
dbRowUpdate($table_name, $update_data, " where reply_to = '" . $form_data['reply_to'] . "'");
}
} else if ($form_data['body'] == "May be later" && $check_data['reply_to'] == $form_data['reply_to']) {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/choice',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","choice" : "MAY_BE_LATER"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "MAY_BE_LATER");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$table_name = "requests";
$update_data = array("otpstatus" => "MAY_BE_LATER");
dbRowUpdate($table_name, $update_data, " where reply_to = '" . $form_data['reply_to'] . "'");
}
} else if ($check_data['otpstatus'] == 'phone_verified') {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer_email"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP EMAIL SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$to = $form_data['wafrom'];
$template = "enter_email_confirmation_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "sent");
dbRowUpdate($table_name, $update_data, " where id = '" . $check_data['id'] . "'");
}
} else if ($check_data['otpstatus'] == 'sent') {
if (strlen($form_data['body']) == 6) {
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/verify',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer_email","otp": "' . $form_data['body'] . '"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP SMS SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$template = "acknowledgment";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "verified");
dbRowUpdate($table_name, $update_data, " where id = '" . $check_data['id'] . "'");
} else {
//$template = "regenerating_otp";
$template = "invalid_otp"; //
$params1 = '';
send_watempalte($to, $template, $params1);
}
} else {
$template = "invalid_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
}
}
}
?>
Did this file decode correctly?
Original Code
<?php include('function/function.php');
$data = json_decode(file_get_contents('php://input'), true);
if (empty($data)) {
$data = json_encode($_POST);
$data = json_decode($data, true);
}
if (filesize("in_request.log") > 10240) {
//unlink("in_request.log");
}
$req_dump = print_r($_REQUEST, TRUE);
$req_files = print_r($_FILES, TRUE);
$fp = fopen('in_request.log', 'a');
fwrite($fp, " #################################### Request added on " . date("Y-m-d H:i:s"));
fwrite($fp, $req_dump);
fwrite($fp, $req_files);
fwrite($fp, print_r($data, TRUE));
fclose($fp);
//exit;
$table_name = "in_request";
$form_data = array(
"body" => $_REQUEST['body'],
"wafrom" => $_REQUEST['from'],
"name" => $_REQUEST['name'],
"type" => $_REQUEST['type'],
"created_at" => $_REQUEST['created_at'],
"reply_to" => $_REQUEST['reply_to'],
"wanumber" => $_REQUEST['wanumber'],
"mobile" => $_REQUEST['mobile'],
"custom_response" => $_REQUEST['custom_response'],
"cdate" => date("Y-m-d H:i:s")
);
dbRowInsert($table_name, $form_data, $debug = 0);
//Checking Message History
record_set('check_msg', 'select id,otpstatus,reply_to from requests where phone_number="' . $form_data['wafrom'] . '" and template="consent_message_v2" and (otpstatus!="verified" or otpstatus is NULL) ORDER BY id DESC limit 1');
$to = $form_data['wafrom'];
$smsphone = substr($form_data['wafrom'], -10);
if ($totalRows_check_msg > 0) {
$check_data = mysqli_fetch_assoc($check_msg);
if ($form_data['body'] == "Yes I am interested" && $check_data['reply_to'] == $form_data['reply_to']) {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP SMS SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$to = $form_data['wafrom'];
$template = "enter_confirmation_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "phone_verified");
dbRowUpdate($table_name, $update_data, " where reply_to = '" . $form_data['reply_to'] . "'");
}
} else if ($form_data['body'] == "May be later" && $check_data['reply_to'] == $form_data['reply_to']) {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/choice',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","choice" : "MAY_BE_LATER"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "MAY_BE_LATER");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$table_name = "requests";
$update_data = array("otpstatus" => "MAY_BE_LATER");
dbRowUpdate($table_name, $update_data, " where reply_to = '" . $form_data['reply_to'] . "'");
}
} else if ($check_data['otpstatus'] == 'phone_verified') {
//Send OTP message
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer_email"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP EMAIL SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$to = $form_data['wafrom'];
$template = "enter_email_confirmation_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "sent");
dbRowUpdate($table_name, $update_data, " where id = '" . $check_data['id'] . "'");
}
} else if ($check_data['otpstatus'] == 'sent') {
if (strlen($form_data['body']) == 6) {
$curl = curl_init();
$agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox-api-connect.dhi42cards.in/api/manage/v1/offer/client/otp/verify',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => $agent,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{"phonenumber" : "' . $smsphone . '","otptype" : "newcustomer_email","otp": "' . $form_data['body'] . '"}',
CURLOPT_HTTPHEADER => array(
'x-auth-token: eKUl4fLPoq6jhc0Aps6Pw1bRA81q4Q9KzKfdvJ0f',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
$resp = json_decode($response, true);
curl_close($curl);
$fp = fopen('in_request.log', 'a');
fwrite($fp, "OTP SMS SENT");
fwrite($fp, print_r($response, TRUE));
fclose($fp);
if ($resp['success'] == true) {
$template = "acknowledgment";
$params1 = '';
send_watempalte($to, $template, $params1);
$table_name = "requests";
$update_data = array("otpstatus" => "verified");
dbRowUpdate($table_name, $update_data, " where id = '" . $check_data['id'] . "'");
} else {
//$template = "regenerating_otp";
$template = "invalid_otp"; //
$params1 = '';
send_watempalte($to, $template, $params1);
}
} else {
$template = "invalid_otp";
$params1 = '';
send_watempalte($to, $template, $params1);
}
}
}
Function Calls
None |
Stats
MD5 | 0886c72d2430ec28020294ac22736207 |
Eval Count | 0 |
Decode Time | 77 ms |