forked from oioki/asterisk-users-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
55 lines (41 loc) · 1.24 KB
/
index.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
<?php
////////////////////////////////////////////////////
// Web interface for managing SIP users
// by Tarasov Alexander aka oioki
// Requirements: pdo-mysql, smarty
////////////////////////////////////////////////////
#ini_set('display_errors',1);
#error_reporting(E_ALL);
require('auth.php');
$smarty->debugging = false;
$smarty->caching = false;
$sql = "SELECT *, FROM_UNIXTIME(`regseconds`) AS `regtime`
FROM `sip_users` JOIN `sip_contexts` ON `sip_users`.`context` = `sip_contexts`.`contextname` ORDER BY `sip_users`.`name`";
$sth = $dbh->prepare($sql);
$sth->execute() or die( $sql );
$rows = array();
while ( $row = $sth->fetch() )
{
$row['location'] = ip2location($row['ipaddr']);
if ( preg_match('/^sip:.+@(\d+\.\d+\.\d+.\d+)/', $row['fullcontact'], $m) )
$row['interip'] = ($m[1]==$row['ipaddr']) ? '' : $m[1];
else
$row['interip'] = '';
$rows[] = $row;
}
$sql = "SELECT * FROM `sip_extensions` ORDER BY `name`";
$sth = $dbh->prepare($sql);
$sth->execute() or die( $sql );
while ( $row = $sth->fetch() )
{
$row['type'] = 'ext';
$rows[] = $row;
}
function cmp($a, $b)
{
return ( $a['name'] > $b['name'] );
}
usort($rows, "cmp");
$smarty->assign('users', $rows);
$smarty->display('index.tpl');
?>