1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Manage servers
|
5
|
*
|
6
|
* $Id: servers.php,v 1.4 2005/10/18 04:00:19 chriskl Exp $
|
7
|
*/
|
8
|
|
9
|
// Include application functions
|
10
|
$_no_db_connection = true;
|
11
|
include_once('./libraries/lib.inc.php');
|
12
|
|
13
|
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
|
14
|
if (!isset($msg)) $msg = '';
|
15
|
$PHP_SELF = $_SERVER['PHP_SELF'];
|
16
|
|
17
|
function doLogout() {
|
18
|
global $misc, $lang, $_reload_browser;
|
19
|
|
20
|
$server_info = $misc->getServerInfo($_REQUEST['logoutServer']);
|
21
|
$misc->setServerInfo(null, null, $_REQUEST['logoutServer']);
|
22
|
doDefault(sprintf($lang['strlogoutmsg'], $server_info['desc']));
|
23
|
|
24
|
$_reload_browser = true;
|
25
|
}
|
26
|
|
27
|
function doDefault($msg = '') {
|
28
|
global $conf, $misc;
|
29
|
global $PHP_SELF, $lang;
|
30
|
|
31
|
$misc->printTabs('root','servers');
|
32
|
$misc->printMsg($msg);
|
33
|
|
34
|
$servers = $misc->getServers(true);
|
35
|
|
36
|
function svPre(&$rowdata, $actions) {
|
37
|
$actions['logout']['disable'] = empty($rowdata->f['username']);
|
38
|
return $actions;
|
39
|
}
|
40
|
|
41
|
$columns = array(
|
42
|
'server' => array(
|
43
|
'title' => $lang['strserver'],
|
44
|
'field' => 'desc',
|
45
|
),
|
46
|
'host' => array(
|
47
|
'title' => $lang['strhost'],
|
48
|
'field' => 'host',
|
49
|
),
|
50
|
'port' => array(
|
51
|
'title' => $lang['strport'],
|
52
|
'field' => 'port',
|
53
|
),
|
54
|
'username' => array(
|
55
|
'title' => $lang['strusername'],
|
56
|
'field' => 'username',
|
57
|
),
|
58
|
'actions' => array(
|
59
|
'title' => $lang['stractions'],
|
60
|
),
|
61
|
);
|
62
|
|
63
|
$actions = array(
|
64
|
'properties' => array(
|
65
|
'title' => $lang['strproperties'],
|
66
|
'url' => "redirect.php?subject=server&",
|
67
|
'vars' => array('server' => 'id'),
|
68
|
),
|
69
|
'logout' => array(
|
70
|
'title' => $lang['strlogout'],
|
71
|
'url' => "{$PHP_SELF}?action=logout&",
|
72
|
'vars' => array('logoutServer' => 'id'),
|
73
|
),
|
74
|
);
|
75
|
|
76
|
$misc->printTable($servers, $columns, $actions, $lang['strnoobjects'], 'svPre');
|
77
|
}
|
78
|
|
79
|
function doTree() {
|
80
|
global $misc;
|
81
|
|
82
|
$servers = $misc->getServers(true);
|
83
|
|
84
|
$reqvars = $misc->getRequestVars('server');
|
85
|
|
86
|
$attrs = array(
|
87
|
'text' => field('desc'),
|
88
|
|
89
|
// Show different icons for logged in/out
|
90
|
'icon' => ifempty(field('username'), 'serverOut', 'server'),
|
91
|
|
92
|
'toolTip'=> field('id'),
|
93
|
|
94
|
'action' => url('redirect.php',
|
95
|
$reqvars,
|
96
|
array('server' => field('id'))
|
97
|
),
|
98
|
|
99
|
// Only create a branch url if the user has
|
100
|
// logged into the server.
|
101
|
'branch' => ifempty(field('username'), false,
|
102
|
url('all_db.php',
|
103
|
$reqvars,
|
104
|
array(
|
105
|
'action' => 'tree',
|
106
|
'server' => field('id')
|
107
|
)
|
108
|
)
|
109
|
),
|
110
|
);
|
111
|
|
112
|
$misc->printTreeXML($servers, $attrs);
|
113
|
exit;
|
114
|
}
|
115
|
|
116
|
if ($action == 'tree') doTree();
|
117
|
|
118
|
$misc->printHeader($lang['strservers']);
|
119
|
$misc->printBody();
|
120
|
$misc->printTrail('root');
|
121
|
|
122
|
switch ($action) {
|
123
|
case 'logout':
|
124
|
doLogout();
|
125
|
break;
|
126
|
case 'tree':
|
127
|
default:
|
128
|
doDefault($msg);
|
129
|
break;
|
130
|
}
|
131
|
|
132
|
$misc->printFooter();
|
133
|
?>
|