-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdirectory.php
68 lines (59 loc) · 1.87 KB
/
directory.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
<?php
$serverIp = "10.0.0.1";
$companyName = "My company";
require_once ('MysqliDb.php');
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
if (empty ($_GET['directory'])) {
echo "<CiscoIPPhoneMenu>
<MenuItem>
<Name>{$companyName} phone book</Name>
<URL>http://{$serverIp}/directory.php?directory=contacts</URL>
</MenuItem>
<MenuItem>
<Name>Search in {$companyName}</Name>
<URL>http://{$serverIp}/directory.php?directory=search</URL>
</MenuItem>
</CiscoIPPhoneMenu>";
exit;
} else if ($_GET['directory'] == 'search') {
echo "<CiscoIPPhoneInput>
<Title>Directory search</Title>
<Prompt>Enter person name: </Prompt>
<URL>http://{$serverIp}/directory.php?directory=contacts</URL>
<InputItem>
<DisplayName>First Name</DisplayName>
<QueryStringParam>firstName</QueryStringParam>
<InputFlags>U</InputFlags>
</InputItem>
<InputItem>
<DisplayName>Last Name</DisplayName>
<QueryStringParam>lastName</QueryStringParam>
<InputFlags>U</InputFlags>
</InputItem>
<InputItem>
<DisplayName>Extension</DisplayName>
<QueryStringParam>extNum</QueryStringParam>
<InputFlags>T</InputFlags>
</InputItem>
</CiscoIPPhoneInput>";
exit;
}
$db = new Mysqlidb ('localhost', 'asteriskuser', 'amp109', 'asterisk');
$name = $_GET['firstName'] . "% ". $_GET['lastName'] . "%";
$db->where ("description", Array ('LIKE'=> $name));
if (!empty ($_GET['extNum']))
$db->where ("id", Array ('LIKE' => $_GET['extNum']."%"));
$users = $db->get("devices", 32);
foreach ($users as $u) {
$list .= "<DirectoryEntry>
<Name>{$u['description']}</Name>
<Telephone>{$u['id']}</Telephone>
</DirectoryEntry>";
}
echo "<CiscoIPPhoneDirectory>
<Title>{$companyName} Phone Directory</Title>
<Prompt>People reachable via VoIP</Prompt>";
echo $list;
echo "</CiscoIPPhoneDirectory>";