-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialPushCheck.php
executable file
·118 lines (90 loc) · 2.82 KB
/
dialPushCheck.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
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
<?php
session_start();
// Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Report all errors
error_reporting(E_ALL);
session_start();
$ipv4=$_POST["phoneip"];
$number2dial=$_POST["number"];
$_SESSION['phoneip'] = $ipv4;
$_SESSION['number2dial'] = $number2dial;
//Generate random code
$code = mt_rand(1000,9999);
$_SESSION['code'] = $code;
//Create xml element
$xml = new SimpleXMLElement('<CiscoIPPhoneText/>');
$title = $xml->addChild('Title', "Authentication Code: $code");
$text = $xml->addChild('Text', "Enter code above into browser to dial $number2dial");
//remove version tag
$dom = dom_import_simplexml($xml);
$xmlOut = $dom->ownerDocument->saveXML($dom->ownerDocument->documentElement);
//Write to file
$myfile = fopen($ipv4."-code.php", "w") or die("Unable to open file!");
fwrite($myfile, '<?header("Content-type: text/xml");');
fwrite($myfile, 'header("Connection: close");');
fwrite($myfile, 'header("Expires: -1");?>');
fwrite($myfile, $xmlOut);
fclose($myfile);
//echo "<a href='http://192.168.1.7/ciscoServices/dialFromWeb/".$ipv4."-code.php'>file</a>";
// Push file to phone
//$url="http://192.168.1.7/ciscoServices/dialFromWeb/".$ipv4."-code.xml"
$command='<CiscoIPPhoneExecute><ExecuteItem Priority="0" URL="http://192.168.1.7/ciscoServices/dialFromWeb/'.$ipv4.'-code.php"/></CiscoIPPhoneExecute>';
// echo "$command";
// echo "<br>";
// echo "Command sent to phone.";
// 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);
// push xml-like packet to cisco voip phone...
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;
}
//echo $response;
//echo 'here';
//Check if code is set, if so display form.
if (isset($code)){
?>
<html>
<title>Phone Dial Tool</title>
<body>
<h2>Phone number dial tool</h2>
<h3>To dial <? echo $number2dial; ?>,
enter the code from the phone screen</h3>
<form action="dialPushCheckCode.php" method="post">
Code: <input type="number" name="enteredCode" required><br>
<br>
<input type="submit">
</form>
<h5>Sam Turner 28/5/16</h5>
</body>
</html>
<?php
}
else{ ?>
<html>
<h1>Error</h1>
</html>
<?php
}
return;
?>