-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathewxchlist.php
120 lines (100 loc) · 3.35 KB
/
ewxchlist.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
119
120
<?php
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2012 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
function GetChannelsList($order='name,asc')
{
global $DB, $LMS;
if($order=='')
$order='name,asc';
list($order,$direction) = sscanf($order, '%[^,],%s');
($direction=='desc') ? $direction = 'desc' : $direction = 'asc';
switch($order)
{
case 'id':
case 'devcnt':
case 'nodecnt':
case 'downceil':
case 'upceil':
case 'downceil_n':
case 'upceil_n':
case 'cid':
$sqlord = ' ORDER BY '.$order;
break;
default:
$sqlord = ' ORDER BY name';
break;
}
$channels = $DB->GetAll('('
.'SELECT c.id, c.name, c.upceil, c.downceil,
c.upceil_n, c.downceil_n, c.halfduplex, c2.id AS cid,
(SELECT COUNT(*) FROM netdevices WHERE channelid = c.id) AS devcnt,
(SELECT COUNT(*) FROM ewx_stm_nodes n
JOIN ewx_stm_channels ch ON (n.channelid = ch.id)
WHERE ch.cid = c.id) AS nodecnt
FROM ewx_channels c
LEFT JOIN ewx_stm_channels c2 ON (c.id = c2.cid)
)
UNION
(
SELECT 0 AS id, \''.trans('default').'\' AS name,
ch.upceil, ch.downceil, 0 AS upceil_n, 0 AS downceil_n, 0, ch.id AS cid,
(SELECT COUNT(DISTINCT netdev) FROM nodes WHERE netdev > 0 AND id IN (
SELECT nodeid FROM ewx_stm_nodes WHERE channelid = ch.id)) AS devcnt,
(SELECT COUNT(*) FROM ewx_stm_nodes WHERE channelid = ch.id) AS nodecnt
FROM ewx_stm_channels ch
WHERE ch.cid = 0
)'
.($sqlord != '' ? $sqlord.' '.$direction : ''));
$channels['total'] = sizeof($channels);
$channels['order'] = $order;
$channels['direction'] = $direction;
return $channels;
}
if(!isset($_GET['o']))
$SESSION->restore('eclo', $o);
else
$o = $_GET['o'];
$SESSION->save('eclo', $o);
if ($SESSION->is_set('eclp') && !isset($_GET['page']))
$SESSION->restore('eclp', $_GET['page']);
$channels = GetChannelsList($o);
$listdata['total'] = $channels['total'];
$listdata['order'] = $channels['order'];
$listdata['direction'] = $channels['direction'];
unset($channels['total']);
unset($channels['order']);
unset($channels['direction']);
$page = (empty($_GET['page']) ? 1 : $_GET['page']);
$pagelimit = (empty($CONFIG['phpui']['channellist_pagelimit']) ? $listdata['total'] : $CONFIG['phpui']['channellist_pagelimit']);
$start = ($page - 1) * $pagelimit;
$SESSION->save('eclp', $page);
$layout['pagetitle'] = trans('Channels List');
$SESSION->save('backto', $_SERVER['QUERY_STRING']);
$SMARTY->assign('pagelimit', $pagelimit);
$SMARTY->assign('page', $page);
$SMARTY->assign('start', $start);
$SMARTY->assign('channels', $channels);
$SMARTY->assign('listdata', $listdata);
$SMARTY->display('ewxchlist.html');
?>