-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphverify.php
More file actions
120 lines (85 loc) · 2.43 KB
/
phverify.php
File metadata and controls
120 lines (85 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
include 'config.php';
/*$phone_no = "918657753917";
$lat="12";
$long="34";*/
$phone_no = $_POST['phone_no'];
$lat = $_POST["lat"];
$long= $_POST["long"];
$conn = new mysqli($servername, $username, $password, $dbname);
//Check connection
if ($conn->connect_error) {
// echo "failed";//die("Connection failed: " . $conn->connect_error);
}else {
// echo "SUccess";
}
$seed = str_split('0123456789'.$phone_no);
shuffle($seed); // optional since array_is randomized; this may be redundant
$rand = '';
foreach (array_rand($seed, 4) as $k) $rand .= $seed[$k];
//echo $rand;
$sql = "INSERT INTO Web_Authentication (id, phone_no, link, latitude, longitude) VALUES ('NULL', $phone_no, '$rand', '$lat', '$long')";
//echo $sql;
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
//Send SMS
function sendMsg(){
global $phone_no;
global $rand;
//exotel
$post_data = array(
'From' => '8808891988',
'To' => $phone_no,
'Priority' => 'high',
'Body' => 'OTP from OyeOK = '.$rand.'. Thank you for registering',
);
$exotel_sid = "nexchanges1";
$exotel_token = "5347ce6a334ccc65d2ac9612dd4814824dc9e618";
$url = "https://".$exotel_sid.":".$exotel_token."@twilix.exotel.in/v1/Accounts/".$exotel_sid."/Sms/send";
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
$http_result = curl_exec($ch);
echo $http_result;
$error = curl_error($ch);
echo $error;
$http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE);
curl_close($ch);
/*
$url = 'https://rest.nexmo.com/sms/json?' . http_build_query([
'api_key' => de1cc5e1,
'api_secret' => ritesh,
'to' => $phone_no,
'from' => 'OyeOK',
'text' => 'Your OyeOK OTP is . '.$rand.''
]);
print file_get_contents($url);
//$url = 'http://example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
echo $result;
curl_close ($ch);
*/
return;
}
if(isset($_POST['phone_no']))
{
echo "1";
$t=sendMsg();
echo $t;
}
else
{
echo "0";
}
?>