File: //var/www/html/qcr24/app/application/helpers/otp_helper.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*function sendsms($otp,$phoneno){
$error = '';
$data = array();
$ch = curl_init();
$baseurl = 'http://dndopen.jhaveritechno.com/api/v4/?api_key=Acbb9b01166125066737f7170c4f573d3';
$message = "OTP for Login Transaction on SYSCENTRIC is ".$otp.". Do not share this OTP to anyone for security reasons.";
$url = $baseurl.'&method=sms&message='.$message.'&to='.$phoneno.'&sender=SYSCNT&entity_id=1301163999688234159&template_id=1507165971342532874';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error = 'Error:' . curl_error($ch);
}
curl_close($ch);
$data['error'] = $error;
$data['response'] = json_decode($result);
//echo "<pre>"; print_r($data);
return $data;
}
function generateotp($phone){
$data = array();
$otp = random_int(100000, 999999);
$data= sendsms($otp,$phone);
$data['otp'] = $otp;
return $data;
}*/
function generateotp($phone, $type)
{
$data = array();
$otp = random_int(100000, 999999);
$data= sendsms($otp, $phone, $type);
$data['otp'] = $otp;
return $data;
}
function sendsms($otp, $phoneno, $type)
{
$error = '';
$data = array();
$ch = curl_init();
$baseurl = 'https://2factor.in/API/R1/';
$message = '';
switch ($type) {
case 'login':
$message = "Your OTP for login to www.prdtourism.in is " . $otp . " .This OTP is valid for 60 seconds. Please do not share this OTP with others. -PRD Department";
break;
case 'register':
$message = "Your OTP for signup with www.prdtourism.in is " . $otp . " . This OTP is valid for 60 seconds. Please do not share this OTP with others. -PRD Department";
break;
}
$postfields = 'module=TRANS_SMS&apikey=7724f759-3a60-11ed-9c12-0200cd936042&to=' . $phoneno . '&from=WBPNRD&msg=' . $message;
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$result = curl_exec($ch);
if (curl_errno($ch)) {
$error = 'Error:' . curl_error($ch);
}
curl_close($ch);
$data['error'] = $error;
$data['response'] = json_decode($result);
//echo "<pre>"; print_r($data);
return $data;
}
?>