-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialPushCheckCode.php
executable file
·70 lines (49 loc) · 1.57 KB
/
dialPushCheckCode.php
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
<?php
session_start();
//Get entered code from form
$enteredCode = $_POST["enteredCode"];
//echo ($_POST["enteredCode"]);
//Get other info from session.
$code = $_SESSION['code'];
$ipv4 = $_SESSION['phoneip'];
$number2dial = $_SESSION['number2dial'];
//echo $code;
//echo $enteredCode;
$command='<CiscoIPPhoneExecute><ExecuteItem Priority="1" URL="Dial:'.$number2dial.'"/></CiscoIPPhoneExecute>';
//Compare entered code and session code
if ($enteredCode == $code){
echo '<h3>Code Correct.</h3>';
echo "<br>";
echo '<h3>Dialling '.$number2dial.'... </h3>';
echo "<br>";
echo "<a href='http://192.168.1.7/ciscoServices/dialFromWeb/webDial.html'>New Call</a>";
$response=cisco_voip_phone_xml_push($ipv4,$command);
}
else {
echo 'Code wrong!';
echo "<br>";
echo "<a href='http://192.168.1.7/ciscoServices/dialFromWeb/webDial.html'>New Call</a>";
}
function cisco_voip_phone_xml_push($ipv4,$command,$uid="root",$pwd="test2")
{
$auth=base64_encode($uid.":".$pwd);
$xml="XML=".urlencode($command);
$post="POST /CGI/Execute HTTP/1.0\r\n";
$post.="Host: $ipv4\r\n";
$post.="Authorization: Basic $auth\r\n";
$post.="Connection: close\r\n";
$post.="Content-Type: application/x-www-form-urlencoded\r\n";
$post.="Content-Length: ".strlen($xml)."\r\n\r\n";
$response="";
$fp=fsockopen($ipv4,80,$errno,$errstr,30);
if(!$fp) return false;
fputs($fp,$post.$xml);
while(!feof($fp))
{
$response=fgets($fp,128);
}
fclose($fp);
return $response;
echo $response;
}
?>