blob: ab22a9a5e4382ce9dea65a2bc2db0862ce8157ad (
plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
<?php ?>
<div class="admin" id="admin">
<span class="header">Admin</span>
<div class="button close"><a href="?page=">X</a></div>
<?php
global $loggedin;
if($loggedin == true) {
?>
<?php
global $DATA_DIR;
$users = new Users($DATA_DIR . "/users.xml");
if($userid) $UID = $userid;
else $UID = $HTTP_COOKIE_VARS["UserID"];
$user = $users->findUser($UID);
?>
<a class="logout" href="?page=admin&action=logout">Logout <span class="user"><?php echo $UID;?></span></a>
<div class="menu">
<?php
include_once($UTIL_DIR . "/modules.php");
loadAllModules();
foreach($modules as $modulename => $module) {
if($user->checkModule($modulename) == false) continue;
$active = "";
if($m == $modulename) {
$admin_module = $module;
$admin_modulename = $modulename;
$active = " active";
}
echo "<a class=\"entry$active\" href=\"?page=admin&m=$modulename\">";
echo $module->admin_title;
echo "</a>\n";
}
?>
</div>
<div class="submenu">
<?php
if($admin_module && $user->checkModule($admin_modulename)) {
foreach($admin_module->admin_submodules as $submodulename => $submodule) {
$active = "";
if($s == $submodule) {
$admin_submodule = $s;
$admin_submodule_name = $submodulename;
$active = " active";
}
echo "<a class=\"entry$active\" href=\"?page=admin&m=$m&s=$submodule\">";
echo $submodulename;
echo "</a>\n";
}
}
?>
</div>
<div class="form">
<?php
if($admin_submodule) {
echo "<div class=\"header\">$admin_submodule_name</div>\n";
include_once($UTIL_DIR . "/convert.php");
$admin_module->admin($admin_submodule, $a, convert_array($vars));
}
?>
</div>
<?php
} else {
?>
<div class="form">
<form action="?page=admin&action=login" method="post">
<p>UserID: <input name="userid"/></p>
<p>Password: <input name="password" type="password"/></p>
<p><button type="submit">Login</button></p>
</form>
</div>
<?php
}
?>
</div>
<script language="JavaScript" type="text/javascript">
<!--
function ExtractNumber(value)
{
var n = parseInt(value);
return n == null || isNaN(n) ? 0 : n;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function $(id)
{
return document.getElementById(id);
}
InitDragDrop();
function InitDragDrop()
{
document.onmousedown = OnMouseDown;
document.onmouseup = OnMouseUp;
var x = readCookie('admin_x');
var y = readCookie('admin_y');
var _dragElement = document.getElementById('admin');
_dragElement.style.left = x + 'px';
_dragElement.style.top = y + 'px';
}
function OnMouseDown(e)
{
if (e == null)
e = window.event;
var target = e.target != null ? e.target : e.srcElement;
if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'admin') {
_startX = e.clientX;
_startY = e.clientY;
_offsetX = ExtractNumber(target.style.left);
_offsetY = ExtractNumber(target.style.top);
_oldZIndex = target.style.zIndex;
target.style.zIndex = 10000;
_dragElement = target;
document.onmousemove = OnMouseMove;
document.body.focus();
document.onselectstart = function () { return false; };
target.ondragstart = function() { return false; };
return false;
}
}
function OnMouseMove(e)
{
if (e == null)
var e = window.event;
_dragElement.style.left = (_offsetX + e.clientX - _startX) + 'px';
_dragElement.style.top = (_offsetY + e.clientY - _startY) + 'px';
}
function OnMouseUp(e)
{
if (_dragElement != null) {
_dragElement.style.zIndex = _oldZIndex;
document.onmousemove = null;
document.onselectstart = null;
_dragElement.ondragstart = null;
_dragElement = null;
if (e == null)
var e = window.event;
createCookie('admin_x', _offsetX + e.clientX - _startX);
createCookie('admin_y', _offsetY + e.clientY - _startY);
}
}
</script>
|