|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
include('../../../include/cp_header.php'); |
|
3
|
|
|
include_once('admin_header.php'); |
|
4
|
|
|
include_once(XOOPS_ROOT_PATH . '/class/pagenav.php'); |
|
5
|
|
|
|
|
6
|
|
|
global $xoopsModule; |
|
|
|
|
|
|
7
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
8
|
|
|
$start = $limit = 0; |
|
9
|
|
View Code Duplication |
if (isset($_REQUEST['limit'])) { |
|
10
|
|
|
$limit = intval($_REQUEST['limit']); |
|
11
|
|
|
} else { |
|
12
|
|
|
$limit = 15; |
|
13
|
|
|
} |
|
14
|
|
|
if (isset($_REQUEST['start'])) { |
|
15
|
|
|
$start = intval($_REQUEST['start']); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
$aSortBy = array('mime_id' => _AM_XHELP_MIME_ID, 'mime_name' => _AM_XHELP_MIME_NAME, 'mime_ext' => _AM_XHELP_MIME_EXT, |
|
19
|
|
|
'mime_admin' => _AM_XHELP_MIME_ADMIN, 'mime_user' => _AM_XHELP_MIME_USER); |
|
20
|
|
|
$aOrderBy = array('ASC' => _AM_XHELP_TEXT_ASCENDING, 'DESC' => _AM_XHELP_TEXT_DESCENDING); |
|
21
|
|
|
$aLimitBy = array('10' => 10, '15' => 15, '20' => 20, '25' => 25, '50' => 50, '100' => 100); |
|
22
|
|
|
$aSearchBy = array('mime_id' => _AM_XHELP_MIME_ID, 'mime_name' => _AM_XHELP_MIME_NAME, 'mime_ext' => _AM_XHELP_MIME_EXT); |
|
23
|
|
|
|
|
24
|
|
|
$hMime =& xhelpGetHandler('mimetype'); |
|
25
|
|
|
$op = 'default'; |
|
26
|
|
|
|
|
27
|
|
|
if ( isset( $_REQUEST['op'] ) ) |
|
28
|
|
|
{ |
|
29
|
|
|
$op = $_REQUEST['op']; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
switch ( $op ) |
|
33
|
|
|
{ |
|
34
|
|
|
case "add": |
|
35
|
|
|
add(); |
|
36
|
|
|
break; |
|
37
|
|
|
|
|
38
|
|
|
case "delete": |
|
39
|
|
|
delete(); |
|
40
|
|
|
break; |
|
41
|
|
|
|
|
42
|
|
|
case "edit": |
|
43
|
|
|
edit(); |
|
44
|
|
|
break; |
|
45
|
|
|
|
|
46
|
|
|
case "search": |
|
47
|
|
|
search(); |
|
48
|
|
|
break; |
|
49
|
|
|
|
|
50
|
|
|
case "updateMimeValue": |
|
51
|
|
|
updateMimeValue(); |
|
52
|
|
|
break; |
|
53
|
|
|
|
|
54
|
|
|
case "clearAddSession": |
|
55
|
|
|
clearAddSession(); |
|
56
|
|
|
break; |
|
57
|
|
|
|
|
58
|
|
|
case "clearEditSession": |
|
59
|
|
|
clearEditSession(); |
|
60
|
|
|
break; |
|
61
|
|
|
|
|
62
|
|
|
case "manage": |
|
63
|
|
|
default: |
|
64
|
|
|
manage(); |
|
65
|
|
|
break; |
|
66
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
function add() |
|
|
|
|
|
|
70
|
|
|
{ |
|
71
|
|
|
global $hMime, $limit, $start; |
|
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
if(!isset($_POST['add_mime'])){ |
|
74
|
|
|
xoops_cp_header(); |
|
75
|
|
|
//echo $oAdminButton->renderButtons('mimetypes'); |
|
76
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
77
|
|
|
echo $indexAdmin->addNavigation('mimetypes.php'); |
|
78
|
|
|
|
|
79
|
|
|
$session = Session::singleton(); |
|
80
|
|
|
$mime_type = $session->get('xhelp_addMime'); |
|
81
|
|
|
$mime_errors = $session->get('xhelp_addMimeErr'); |
|
82
|
|
|
|
|
83
|
|
|
//Display any form errors |
|
84
|
|
View Code Duplication |
if (! $mime_errors === false) { |
|
85
|
|
|
xhelpRenderErrors($mime_errors, xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'clearAddSession'))); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if ($mime_type === false) { |
|
89
|
|
|
$mime_ext = ''; |
|
90
|
|
|
$mime_name = ''; |
|
91
|
|
|
$mime_types = ''; |
|
92
|
|
|
$mime_admin = 1; |
|
93
|
|
|
$mime_user = 1; |
|
94
|
|
View Code Duplication |
} else { |
|
95
|
|
|
$mime_ext = $mime_type['mime_ext']; |
|
96
|
|
|
$mime_name = $mime_type['mime_name']; |
|
97
|
|
|
$mime_types = $mime_type['mime_types']; |
|
98
|
|
|
$mime_admin = $mime_type['mime_admin']; |
|
99
|
|
|
$mime_user = $mime_type['mime_user']; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// Display add form |
|
103
|
|
|
echo "<form action='mimetypes.php?op=add' method='post'>"; |
|
104
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
105
|
|
|
echo "<tr><th colspan='2'>"._AM_XHELP_MIME_CREATEF."</th></tr>"; |
|
106
|
|
|
echo "<tr valign='top'> |
|
107
|
|
|
<td class='head'>"._AM_XHELP_MIME_EXTF."</td> |
|
108
|
|
|
<td class='even'><input type='text' name='mime_ext' id='mime_ext' value='$mime_ext' size='5' /></td> |
|
109
|
|
|
</tr>"; |
|
110
|
|
|
echo "<tr valign='top'> |
|
111
|
|
|
<td class='head'>"._AM_XHELP_MIME_NAMEF."</td> |
|
112
|
|
|
<td class='even'><input type='text' name='mime_name' id='mime_name' value='$mime_name' /></td> |
|
113
|
|
|
</tr>"; |
|
114
|
|
|
echo "<tr valign='top'> |
|
115
|
|
|
<td class='head'>"._AM_XHELP_MIME_TYPEF."</td> |
|
116
|
|
|
<td class='even'><textarea name='mime_types' id='mime_types' cols='60' rows='5'>$mime_types</textarea></td> |
|
117
|
|
|
</tr>"; |
|
118
|
|
|
echo "<tr valign='top'> |
|
119
|
|
|
<td class='head'>"._AM_XHELP_MIME_ADMINF."</td> |
|
120
|
|
|
<td class='even'>"; |
|
121
|
|
|
|
|
122
|
|
|
echo "<input type='radio' name='mime_admin' value='1' ". ($mime_admin == 1 ? "checked='checked'" : "")." />"._XHELP_TEXT_YES; |
|
123
|
|
|
echo "<input type='radio' name='mime_admin' value='0' ".($mime_admin == 0 ? "checked='checked'" : ""). " />"._XHELP_TEXT_NO." |
|
124
|
|
|
</td> |
|
125
|
|
|
</tr>"; |
|
126
|
|
|
echo "<tr valign='top'> |
|
127
|
|
|
<td class='head'>"._AM_XHELP_MIME_USERF."</td> |
|
128
|
|
|
<td class='even'>"; |
|
129
|
|
|
echo "<input type='radio' name='mime_user' value='1'" . ($mime_user == 1 ? "checked='checked'" : "")." />"._XHELP_TEXT_YES; |
|
130
|
|
|
echo "<input type='radio' name='mime_user' value='0'". ($mime_user == 0 ? "checked='checked'" : "")."/>"._XHELP_TEXT_NO." |
|
131
|
|
|
</td> |
|
132
|
|
|
</tr>"; |
|
133
|
|
|
echo "<tr valign='top'> |
|
134
|
|
|
<td class='head'></td> |
|
135
|
|
|
<td class='even'> |
|
136
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='"._AM_XHELP_BUTTON_SUBMIT."' class='formButton' /> |
|
137
|
|
|
<input type='button' name='cancel' value='"._AM_XHELP_BUTTON_CANCEL."' onclick='history.go(-1)' class='formButton' /> |
|
138
|
|
|
</td> |
|
139
|
|
|
</tr>"; |
|
140
|
|
|
echo "</table></form>"; |
|
141
|
|
|
// end of add form |
|
142
|
|
|
|
|
143
|
|
|
// Find new mimetypes table |
|
144
|
|
|
echo "<form action='http://www.filext.com' method='post'>"; |
|
145
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
146
|
|
|
echo "<tr><th colspan='2'>"._AM_XHELP_MIME_FINDMIMETYPE."</th></tr>"; |
|
147
|
|
|
|
|
148
|
|
|
echo "<tr class='foot'> |
|
149
|
|
|
<td colspan='2'><input type='submit' name='find_mime' id='find_mime' value='"._AM_XHELP_MIME_FINDIT."' class='formButton' /></td> |
|
150
|
|
|
</tr>"; |
|
151
|
|
|
|
|
152
|
|
|
echo "</table></form>"; |
|
153
|
|
|
|
|
154
|
|
|
include_once "admin_footer.php"; |
|
155
|
|
|
} else { |
|
156
|
|
|
$has_errors = false; |
|
157
|
|
|
$error = array(); |
|
158
|
|
|
$mime_ext = $_POST['mime_ext']; |
|
159
|
|
|
$mime_name = $_POST['mime_name']; |
|
160
|
|
|
$mime_types = $_POST['mime_types']; |
|
161
|
|
|
$mime_admin = intval($_POST['mime_admin']); |
|
162
|
|
|
$mime_user = intval($_POST['mime_user']); |
|
163
|
|
|
|
|
164
|
|
|
//Validate Mimetype entry |
|
165
|
|
View Code Duplication |
if (strlen(trim($mime_ext)) == 0) { |
|
166
|
|
|
$has_errors = true; |
|
167
|
|
|
$error['mime_ext'][] = _AM_XHELP_VALID_ERR_MIME_EXT; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
View Code Duplication |
if (strlen(trim($mime_name)) == 0) { |
|
171
|
|
|
$has_errors = true; |
|
172
|
|
|
$error['mime_name'][] = _AM_XHELP_VALID_ERR_MIME_NAME; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
View Code Duplication |
if (strlen(trim($mime_types)) == 0) { |
|
176
|
|
|
$has_errors = true; |
|
177
|
|
|
$error['mime_types'][] = _AM_XHELP_VALID_ERR_MIME_TYPES; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
if ($has_errors) { |
|
181
|
|
|
$session = Session::singleton(); |
|
182
|
|
|
$mime = array(); |
|
183
|
|
|
$mime['mime_ext'] = $mime_ext; |
|
184
|
|
|
$mime['mime_name'] = $mime_name; |
|
185
|
|
|
$mime['mime_types'] = $mime_types; |
|
186
|
|
|
$mime['mime_admin'] = $mime_admin; |
|
187
|
|
|
$mime['mime_user'] = $mime_user; |
|
188
|
|
|
$session->set('xhelp_addMime', $mime); |
|
189
|
|
|
$session->set('xhelp_addMimeErr', $error); |
|
190
|
|
|
header('Location: '. xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'add'), false)); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
$mimetype =& $hMime->create(); |
|
194
|
|
|
$mimetype->setVar('mime_ext', $mime_ext); |
|
195
|
|
|
$mimetype->setVar('mime_name', $mime_name); |
|
196
|
|
|
$mimetype->setVar('mime_types', $mime_types); |
|
197
|
|
|
$mimetype->setVar('mime_admin', $mime_admin); |
|
198
|
|
|
$mimetype->setVar('mime_user', $mime_user); |
|
199
|
|
|
|
|
200
|
|
|
if(!$hMime->insert($mimetype)){ |
|
201
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?op=manage&limit=$limit&start=$start", 3, _AM_XHELP_MESSAGE_ADD_MIME_ERROR); |
|
202
|
|
|
} else { |
|
203
|
|
|
_clearAddSessionVars(); |
|
204
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=manage&limit=$limit&start=$start"); |
|
205
|
|
|
} |
|
206
|
|
|
} |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
function delete() |
|
|
|
|
|
|
210
|
|
|
{ |
|
211
|
|
|
global $hMime, $start, $limit; |
|
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
if(!isset($_REQUEST['id'])){ |
|
214
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php", 3, _AM_XHELP_MESSAGE_NO_ID); |
|
215
|
|
|
} else { |
|
216
|
|
|
$mime_id = intval($_REQUEST['id']); |
|
217
|
|
|
} |
|
218
|
|
|
$mimetype =& $hMime->get($mime_id); // Retrieve mimetype object |
|
|
|
|
|
|
219
|
|
View Code Duplication |
if(!$hMime->delete($mimetype, true)){ |
|
220
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?op=manage&id=$mime_id&limit=$limit&start=$start", 3, _AM_XHELP_MESSAGE_DELETE_MIME_ERROR); |
|
221
|
|
|
} else { |
|
222
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=manage&limit=$limit&start=$start"); |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
function edit() |
|
|
|
|
|
|
227
|
|
|
{ |
|
228
|
|
|
global $hMime, $start, $limit; |
|
|
|
|
|
|
229
|
|
|
|
|
230
|
|
|
if(!isset($_REQUEST['id'])){ |
|
231
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php", 3, _AM_XHELP_MESSAGE_NO_ID); |
|
232
|
|
|
} else { |
|
233
|
|
|
$mime_id = intval($_REQUEST['id']); |
|
234
|
|
|
} |
|
235
|
|
|
$mimetype =& $hMime->get($mime_id); // Retrieve mimetype object |
|
|
|
|
|
|
236
|
|
|
|
|
237
|
|
|
if(!isset($_POST['edit_mime'])){ |
|
238
|
|
|
$session = Session::singleton(); |
|
239
|
|
|
$mime_type = $session->get("xhelp_editMime_$mime_id"); |
|
240
|
|
|
$mime_errors = $session->get("xhelp_editMimeErr_$mime_id"); |
|
241
|
|
|
|
|
242
|
|
|
// Display header |
|
243
|
|
|
xoops_cp_header(); |
|
244
|
|
|
//echo $oAdminButton->renderButtons('mimetypes'); |
|
245
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
246
|
|
|
echo $indexAdmin->addNavigation('mimetypes.php'); |
|
247
|
|
|
|
|
248
|
|
|
//Display any form errors |
|
249
|
|
View Code Duplication |
if (! $mime_errors === false) { |
|
250
|
|
|
xhelpRenderErrors($mime_errors, xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'clearEditSession', 'id'=>$mime_id))); |
|
251
|
|
|
} |
|
252
|
|
|
|
|
253
|
|
|
if ($mime_type === false) { |
|
254
|
|
|
$mime_ext = $mimetype->getVar('mime_ext'); |
|
255
|
|
|
$mime_name = $mimetype->getVar('mime_name', 'e'); |
|
256
|
|
|
$mime_types = $mimetype->getVar('mime_types', 'e'); |
|
257
|
|
|
$mime_admin = $mimetype->getVar('mime_admin'); |
|
258
|
|
|
$mime_user = $mimetype->getVar('mime_user'); |
|
259
|
|
View Code Duplication |
} else { |
|
260
|
|
|
$mime_ext = $mime_type['mime_ext']; |
|
261
|
|
|
$mime_name = $mime_type['mime_name']; |
|
262
|
|
|
$mime_types = $mime_type['mime_types']; |
|
263
|
|
|
$mime_admin = $mime_type['mime_admin']; |
|
264
|
|
|
$mime_user = $mime_type['mime_user']; |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
// Display edit form |
|
268
|
|
|
echo "<form action='mimetypes.php?op=edit&id=".$mime_id."' method='post'>"; |
|
269
|
|
|
echo "<input type='hidden' name='limit' value='".$limit."' />"; |
|
270
|
|
|
echo "<input type='hidden' name='start' value='".$start."' />"; |
|
271
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
272
|
|
|
echo "<tr><th colspan='2'>"._AM_XHELP_MIME_MODIFYF."</th></tr>"; |
|
273
|
|
|
echo "<tr valign='top'> |
|
274
|
|
|
<td class='head'>"._AM_XHELP_MIME_EXTF."</td> |
|
275
|
|
|
<td class='even'><input type='text' name='mime_ext' id='mime_ext' value='$mime_ext' size='5' /></td> |
|
276
|
|
|
</tr>"; |
|
277
|
|
|
echo "<tr valign='top'> |
|
278
|
|
|
<td class='head'>"._AM_XHELP_MIME_NAMEF."</td> |
|
279
|
|
|
<td class='even'><input type='text' name='mime_name' id='mime_name' value='$mime_name' /></td> |
|
280
|
|
|
</tr>"; |
|
281
|
|
|
echo "<tr valign='top'> |
|
282
|
|
|
<td class='head'>"._AM_XHELP_MIME_TYPEF."</td> |
|
283
|
|
|
<td class='even'><textarea name='mime_types' id='mime_types' cols='60' rows='5'>$mime_types</textarea></td> |
|
284
|
|
|
</tr>"; |
|
285
|
|
|
echo "<tr valign='top'> |
|
286
|
|
|
<td class='head'>"._AM_XHELP_MIME_ADMINF."</td> |
|
287
|
|
|
<td class='even'> |
|
288
|
|
|
<input type='radio' name='mime_admin' value='1' ".($mime_admin == 1 ? "checked='checked'" : '')." />"._XHELP_TEXT_YES." |
|
289
|
|
|
<input type='radio' name='mime_admin' value='0' ".($mime_admin == 0 ? "checked='checked'" : '')." />"._XHELP_TEXT_NO." |
|
290
|
|
|
</td> |
|
291
|
|
|
</tr>"; |
|
292
|
|
|
echo "<tr valign='top'> |
|
293
|
|
|
<td class='head'>"._AM_XHELP_MIME_USERF."</td> |
|
294
|
|
|
<td class='even'> |
|
295
|
|
|
<input type='radio' name='mime_user' value='1' ".($mime_user == 1 ? "checked='checked'" : '')." />"._XHELP_TEXT_YES." |
|
296
|
|
|
<input type='radio' name='mime_user' value='0' ".($mime_user == 0 ? "checked='checked'" : '')." />"._XHELP_TEXT_NO." |
|
297
|
|
|
</td> |
|
298
|
|
|
</tr>"; |
|
299
|
|
|
echo "<tr valign='top'> |
|
300
|
|
|
<td class='head'></td> |
|
301
|
|
|
<td class='even'> |
|
302
|
|
|
<input type='submit' name='edit_mime' id='edit_mime' value='"._AM_XHELP_BUTTON_UPDATE."' class='formButton' /> |
|
303
|
|
|
<input type='button' name='cancel' value='"._AM_XHELP_BUTTON_CANCEL."' onclick='history.go(-1)' class='formButton' /> |
|
304
|
|
|
</td> |
|
305
|
|
|
</tr>"; |
|
306
|
|
|
echo "</table></form>"; |
|
307
|
|
|
// end of edit form |
|
308
|
|
|
|
|
309
|
|
|
include_once "admin_footer.php"; |
|
310
|
|
|
} else { |
|
311
|
|
|
$mime_admin = 0; |
|
312
|
|
|
$mime_user = 0; |
|
313
|
|
|
if(isset($_POST['mime_admin']) && $_POST['mime_admin'] == 1){ |
|
314
|
|
|
$mime_admin = 1; |
|
315
|
|
|
} |
|
316
|
|
|
if(isset($_POST['mime_user']) && $_POST['mime_user'] == 1){ |
|
317
|
|
|
$mime_user = 1; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
//Validate Mimetype entry |
|
321
|
|
View Code Duplication |
if (strlen(trim($_POST['mime_ext'])) == 0) { |
|
322
|
|
|
$has_errors = true; |
|
323
|
|
|
$error['mime_ext'][] = _AM_XHELP_VALID_ERR_MIME_EXT; |
|
|
|
|
|
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
View Code Duplication |
if (strlen(trim($_POST['mime_name'])) == 0) { |
|
327
|
|
|
$has_errors = true; |
|
328
|
|
|
$error['mime_name'][] = _AM_XHELP_VALID_ERR_MIME_NAME; |
|
|
|
|
|
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
View Code Duplication |
if (strlen(trim($_POST['mime_types'])) == 0) { |
|
332
|
|
|
$has_errors = true; |
|
333
|
|
|
$error['mime_types'][] = _AM_XHELP_VALID_ERR_MIME_TYPES; |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
if ($has_errors) { |
|
|
|
|
|
|
337
|
|
|
$session = Session::singleton(); |
|
338
|
|
|
$mime = array(); |
|
339
|
|
|
$mime['mime_ext'] = $_POST['mime_ext']; |
|
340
|
|
|
$mime['mime_name'] = $_POST['mime_name']; |
|
341
|
|
|
$mime['mime_types'] = $_POST['mime_types']; |
|
342
|
|
|
$mime['mime_admin'] = $mime_admin; |
|
343
|
|
|
$mime['mime_user'] = $mime_user; |
|
344
|
|
|
$session->set('xhelp_editMime_'. $mime_id, $mime); |
|
345
|
|
|
$session->set('xhelp_editMimeErr_'. $mime_id, $error); |
|
346
|
|
|
header('Location: '. xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'edit', 'id'=>$mime_id), false)); |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
$mimetype->setVar('mime_ext', $_POST['mime_ext']); |
|
350
|
|
|
$mimetype->setVar('mime_name', $_POST['mime_name']); |
|
351
|
|
|
$mimetype->setVar('mime_types', $_POST['mime_types']); |
|
352
|
|
|
$mimetype->setVar('mime_admin', $mime_admin); |
|
353
|
|
|
$mimetype->setVar('mime_user', $mime_user); |
|
354
|
|
|
|
|
355
|
|
|
if(!$hMime->insert($mimetype, true)){ |
|
356
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?op=edit&id=$mime_id", 3, _AM_XHELP_MESSAGE_EDIT_MIME_ERROR); |
|
357
|
|
|
} else { |
|
358
|
|
|
_clearEditSessionVars($mime_id); |
|
359
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=manage&limit=$limit&start=$start"); |
|
360
|
|
|
} |
|
361
|
|
|
} |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
function manage() |
|
|
|
|
|
|
365
|
|
|
{ |
|
366
|
|
|
global $hMime, $imagearray, $start, $limit, $aSortBy, $aOrderBy, $aLimitBy, $aSearchBy; |
|
|
|
|
|
|
367
|
|
|
|
|
368
|
|
View Code Duplication |
if(isset($_POST['deleteMimes'])){ |
|
369
|
|
|
$aMimes = $_POST['mimes']; |
|
370
|
|
|
|
|
371
|
|
|
$crit = new Criteria('mime_id', "(". implode($aMimes, ',') .")", "IN"); |
|
372
|
|
|
|
|
373
|
|
|
if($hMime->deleteAll($crit)){ |
|
374
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start"); |
|
375
|
|
|
} else { |
|
376
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start", 3, _AM_XHELP_MESSAGE_DELETE_MIME_ERROR); |
|
377
|
|
|
} |
|
378
|
|
|
} |
|
379
|
|
View Code Duplication |
if(isset($_POST['add_mime'])){ |
|
380
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=add&start=$start&limit=$limit"); |
|
381
|
|
|
exit(); |
|
|
|
|
|
|
382
|
|
|
} |
|
383
|
|
|
if(isset($_POST['mime_search'])){ |
|
384
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=search"); |
|
385
|
|
|
exit(); |
|
|
|
|
|
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
xoops_cp_header(); |
|
389
|
|
|
//echo $oAdminButton->renderButtons('mimetypes'); |
|
390
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
391
|
|
|
echo $indexAdmin->addNavigation('mimetypes.php'); |
|
392
|
|
|
|
|
393
|
|
|
$crit = new Criteria('', ''); |
|
394
|
|
|
if(isset($_REQUEST['order'])){ |
|
395
|
|
|
$order = $_REQUEST['order']; |
|
396
|
|
|
} else { |
|
397
|
|
|
$order = "ASC"; |
|
398
|
|
|
} |
|
399
|
|
|
if(isset($_REQUEST['sort'])) { |
|
400
|
|
|
$sort = $_REQUEST['sort']; |
|
401
|
|
|
} else { |
|
402
|
|
|
$sort = "mime_ext"; |
|
403
|
|
|
} |
|
404
|
|
|
$crit->setOrder($order); |
|
405
|
|
|
$crit->setStart($start); |
|
406
|
|
|
$crit->setLimit($limit); |
|
407
|
|
|
$crit->setSort($sort); |
|
408
|
|
|
$mimetypes =& $hMime->getObjects($crit); // Retrieve a list of all mimetypes |
|
409
|
|
|
$mime_count =& $hMime->getCount(); |
|
410
|
|
|
$nav = new XoopsPageNav($mime_count, $limit, $start, 'start', "op=manage&limit=$limit"); |
|
411
|
|
|
|
|
412
|
|
|
echo '<script type="text/javascript" src="'.XHELP_BASE_URL.'/include/functions.js"></script>'; |
|
413
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
414
|
|
|
echo "<tr><td colspan='6' align='right'>"; |
|
415
|
|
|
echo "<form action='". XHELP_ADMIN_URL."/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
|
416
|
|
|
echo "<table>"; |
|
417
|
|
|
echo "<tr>"; |
|
418
|
|
|
echo "<td align='right'>". _AM_XHELP_TEXT_SEARCH_BY . "</td>"; |
|
419
|
|
|
echo "<td align='left'><select name='search_by'>"; |
|
420
|
|
View Code Duplication |
foreach($aSearchBy as $value=>$text){ |
|
421
|
|
|
($sort == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
422
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
423
|
|
|
} |
|
424
|
|
|
echo "</select></td>"; |
|
425
|
|
|
echo "<td align='right'>"._AM_XHELP_TEXT_SEARCH_TEXT."</td>"; |
|
426
|
|
|
echo "<td align='left'><input type='text' name='search_text' id='search_text' value='' /></td>"; |
|
427
|
|
|
echo "<td><input type='submit' name='mime_search' id='mime_search' value='"._AM_XHELP_BUTTON_SEARCH."' /></td>"; |
|
428
|
|
|
echo "</tr></table></form></td></tr>"; |
|
429
|
|
|
|
|
430
|
|
|
echo "<tr><td colspan='6'>"; |
|
431
|
|
|
echo "<form action='". XHELP_ADMIN_URL."/mimetypes.php?op=manage' style='margin:0; padding:0;' method='post'>"; |
|
432
|
|
|
echo "<table width='100%'>"; |
|
433
|
|
|
echo "<tr><td align='right'>"._AM_XHELP_TEXT_SORT_BY." |
|
434
|
|
|
<select name='sort'>"; |
|
435
|
|
View Code Duplication |
foreach($aSortBy as $value=>$text){ |
|
436
|
|
|
($sort == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
437
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
438
|
|
|
} |
|
439
|
|
|
echo "</select> |
|
440
|
|
|
|
|
441
|
|
|
"._AM_XHELP_TEXT_ORDER_BY." |
|
442
|
|
|
<select name='order'>"; |
|
443
|
|
View Code Duplication |
foreach($aOrderBy as $value=>$text){ |
|
444
|
|
|
($order == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
445
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
446
|
|
|
} |
|
447
|
|
|
echo "</select> |
|
448
|
|
|
|
|
449
|
|
|
"._AM_XHELP_TEXT_NUMBER_PER_PAGE." |
|
450
|
|
|
<select name='limit'>"; |
|
451
|
|
View Code Duplication |
foreach($aLimitBy as $value=>$text){ |
|
452
|
|
|
($limit == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
453
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
454
|
|
|
} |
|
455
|
|
|
echo "</select> |
|
456
|
|
|
<input type='submit' name='mime_sort' id='mime_sort' value='"._AM_XHELP_BUTTON_SUBMIT."' /> |
|
457
|
|
|
</td> |
|
458
|
|
|
</tr>"; |
|
459
|
|
|
echo "</table>"; |
|
460
|
|
|
echo "</td></tr>"; |
|
461
|
|
|
echo "<tr><th colspan='6'>"._AM_XHELP_MENU_MIMETYPES."</th></tr>"; |
|
462
|
|
|
echo "<tr class='head'> |
|
463
|
|
|
<td>"._AM_XHELP_MIME_ID."</td> |
|
464
|
|
|
<td>"._AM_XHELP_MIME_NAME."</td> |
|
465
|
|
|
<td>"._AM_XHELP_MIME_EXT."</td> |
|
466
|
|
|
<td>"._AM_XHELP_MIME_ADMIN."</td> |
|
467
|
|
|
<td>"._AM_XHELP_MIME_USER."</td> |
|
468
|
|
|
<td>"._AM_XHELP_MINDEX_ACTION."</td> |
|
469
|
|
|
</tr>"; |
|
470
|
|
View Code Duplication |
foreach($mimetypes as $mime){ |
|
471
|
|
|
echo "<tr class='even'> |
|
472
|
|
|
<td><input type='checkbox' name='mimes[]' value='".$mime->getVar('mime_id')."' />".$mime->getVar('mime_id')."</td> |
|
473
|
|
|
<td>".$mime->getVar('mime_name')."</td> |
|
474
|
|
|
<td>".$mime->getVar('mime_ext')."</td> |
|
475
|
|
|
<td> |
|
476
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=updateMimeValue&id=".$mime->getVar('mime_id')."&mime_admin=".$mime->getVar('mime_admin')."&limit=".$limit."&start=".$start."'> |
|
477
|
|
|
".($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline'])."</a> |
|
478
|
|
|
</td> |
|
479
|
|
|
<td> |
|
480
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=updateMimeValue&id=".$mime->getVar('mime_id')."&mime_user=".$mime->getVar('mime_user')."&limit=".$limit."&start=".$start."'> |
|
481
|
|
|
".($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline'])."</a> |
|
482
|
|
|
</td> |
|
483
|
|
|
<td> |
|
484
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=edit&id=".$mime->getVar('mime_id')."&limit=".$limit."&start=".$start."'>".$imagearray['editimg']."</a> |
|
485
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=delete&id=".$mime->getVar('mime_id')."&limit=".$limit."&start=".$start."'>".$imagearray['deleteimg']."</a> |
|
486
|
|
|
</td> |
|
487
|
|
|
</tr>"; |
|
488
|
|
|
} |
|
489
|
|
|
echo "<tr class='foot'> |
|
490
|
|
|
<td colspan='6' valign='top'> |
|
491
|
|
|
<a href='http://www.filext.com' style='float: right' target='_blank'>"._AM_XHELP_MIME_FINDMIMETYPE."</a> |
|
492
|
|
|
<input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);' /> |
|
493
|
|
|
<input type='submit' name='deleteMimes' id='deleteMimes' value='"._AM_XHELP_BUTTON_DELETE."' /> |
|
494
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='"._AM_XHELP_MIME_CREATEF."' class='formButton' /> |
|
495
|
|
|
</td> |
|
496
|
|
|
</tr>"; |
|
497
|
|
|
echo "</table>"; |
|
498
|
|
|
echo "<div id='staff_nav'>".$nav->renderNav()."</div>"; |
|
499
|
|
|
|
|
500
|
|
|
include_once "admin_footer.php"; |
|
501
|
|
|
} |
|
502
|
|
|
|
|
503
|
|
|
function search() |
|
|
|
|
|
|
504
|
|
|
{ |
|
505
|
|
|
global $hMime, $limit, $start, $imagearray, $aSearchBy, $aOrderBy, $aLimitBy, $aSortBy; |
|
|
|
|
|
|
506
|
|
|
|
|
507
|
|
View Code Duplication |
if(isset($_POST['deleteMimes'])){ |
|
508
|
|
|
$aMimes = $_POST['mimes']; |
|
509
|
|
|
|
|
510
|
|
|
$crit = new Criteria('mime_id', "(". implode($aMimes, ',') .")", "IN"); |
|
511
|
|
|
|
|
512
|
|
|
if($hMime->deleteAll($crit)){ |
|
513
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start"); |
|
514
|
|
|
} else { |
|
515
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start", 3, _AM_XHELP_MESSAGE_DELETE_MIME_ERROR); |
|
516
|
|
|
} |
|
517
|
|
|
} |
|
518
|
|
View Code Duplication |
if(isset($_POST['add_mime'])){ |
|
519
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?op=add&start=$start&limit=$limit"); |
|
520
|
|
|
exit(); |
|
|
|
|
|
|
521
|
|
|
} |
|
522
|
|
|
if(isset($_REQUEST['order'])){ |
|
523
|
|
|
$order = $_REQUEST['order']; |
|
524
|
|
|
} else { |
|
525
|
|
|
$order = "ASC"; |
|
526
|
|
|
} |
|
527
|
|
|
if(isset($_REQUEST['sort'])) { |
|
528
|
|
|
$sort = $_REQUEST['sort']; |
|
529
|
|
|
} else { |
|
530
|
|
|
$sort = "mime_name"; |
|
531
|
|
|
} |
|
532
|
|
|
|
|
533
|
|
|
xoops_cp_header(); |
|
534
|
|
|
//echo $oAdminButton->renderButtons('mimetypes'); |
|
535
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
536
|
|
|
echo $indexAdmin->addNavigation('mimetypes.php'); |
|
537
|
|
|
|
|
538
|
|
|
if(!isset($_REQUEST['mime_search'])){ |
|
539
|
|
|
|
|
540
|
|
|
echo "<form action='mimetypes.php?op=search' method='post'>"; |
|
541
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
542
|
|
|
echo "<tr><th colspan='2'>"._AM_XHELP_TEXT_SEARCH_MIME."</th></tr>"; |
|
543
|
|
|
echo "<tr><td class='head' width='20%'>"._AM_XHELP_TEXT_SEARCH_BY."</td> |
|
544
|
|
|
<td class='even'> |
|
545
|
|
|
<select name='search_by'>"; |
|
546
|
|
|
foreach($aSortBy as $value=>$text){ |
|
547
|
|
|
echo "<option value='$value'>$text</option>"; |
|
548
|
|
|
} |
|
549
|
|
|
echo "</select> |
|
550
|
|
|
</td> |
|
551
|
|
|
</tr>"; |
|
552
|
|
|
echo "<tr><td class='head'>"._AM_XHELP_TEXT_SEARCH_TEXT."</td> |
|
553
|
|
|
<td class='even'> |
|
554
|
|
|
<input type='text' name='search_text' id='search_text' value='' /> |
|
555
|
|
|
</td> |
|
556
|
|
|
</tr>"; |
|
557
|
|
|
echo "<tr class='foot'> |
|
558
|
|
|
<td colspan='2'> |
|
559
|
|
|
<input type='submit' name='mime_search' id='mime_search' value='"._AM_XHELP_BUTTON_SEARCH."' /> |
|
560
|
|
|
</td> |
|
561
|
|
|
</tr>"; |
|
562
|
|
|
echo "</table></form>"; |
|
563
|
|
|
} else { |
|
564
|
|
|
$search_field = $_REQUEST['search_by']; |
|
565
|
|
|
$search_text = $_REQUEST['search_text']; |
|
566
|
|
|
|
|
567
|
|
|
$crit = new Criteria($search_field, "%$search_text%", 'LIKE'); |
|
568
|
|
|
$crit->setSort($sort); |
|
569
|
|
|
$crit->setOrder($order); |
|
570
|
|
|
$crit->setLimit($limit); |
|
571
|
|
|
$crit->setStart($start); |
|
572
|
|
|
$mime_count =& $hMime->getCount($crit); |
|
573
|
|
|
$mimetypes =& $hMime->getObjects($crit); |
|
574
|
|
|
$nav = new XoopsPageNav($mime_count, $limit, $start, 'start', "op=search&limit=$limit&order=$order&sort=$sort&mime_search=1&search_by=$search_field&search_text=$search_text"); |
|
575
|
|
|
// Display results |
|
576
|
|
|
echo '<script type="text/javascript" src="'.XHELP_BASE_URL.'/include/functions.js"></script>'; |
|
577
|
|
|
|
|
578
|
|
|
echo "<table width='100%' cellspacing='1' class='outer'>"; |
|
579
|
|
|
echo "<tr><td colspan='6' align='right'>"; |
|
580
|
|
|
echo "<form action='". XHELP_ADMIN_URL."/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
|
581
|
|
|
echo "<table>"; |
|
582
|
|
|
echo "<tr>"; |
|
583
|
|
|
echo "<td align='right'>". _AM_XHELP_TEXT_SEARCH_BY . "</td>"; |
|
584
|
|
|
echo "<td align='left'><select name='search_by'>"; |
|
585
|
|
View Code Duplication |
foreach($aSearchBy as $value=>$text){ |
|
586
|
|
|
($search_field == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
587
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
588
|
|
|
} |
|
589
|
|
|
echo "</select></td>"; |
|
590
|
|
|
echo "<td align='right'>"._AM_XHELP_TEXT_SEARCH_TEXT."</td>"; |
|
591
|
|
|
echo "<td align='left'><input type='text' name='search_text' id='search_text' value='$search_text' /></td>"; |
|
592
|
|
|
echo "<td><input type='submit' name='mime_search' id='mime_search' value='"._AM_XHELP_BUTTON_SEARCH."' /></td>"; |
|
593
|
|
|
echo "</tr></table></form></td></tr>"; |
|
594
|
|
|
|
|
595
|
|
|
echo "<tr><td colspan='6'>"; |
|
596
|
|
|
echo "<form action='". XHELP_ADMIN_URL."/mimetypes.php?op=search' style='margin:0; padding:0;' method='post'>"; |
|
597
|
|
|
echo "<table width='100%'>"; |
|
598
|
|
|
echo "<tr><td align='right'>"._AM_XHELP_TEXT_SORT_BY." |
|
599
|
|
|
<select name='sort'>"; |
|
600
|
|
View Code Duplication |
foreach($aSortBy as $value=>$text){ |
|
601
|
|
|
($sort == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
602
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
603
|
|
|
} |
|
604
|
|
|
echo "</select> |
|
605
|
|
|
|
|
606
|
|
|
"._AM_XHELP_TEXT_ORDER_BY." |
|
607
|
|
|
<select name='order'>"; |
|
608
|
|
View Code Duplication |
foreach($aOrderBy as $value=>$text){ |
|
609
|
|
|
($order == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
610
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
611
|
|
|
} |
|
612
|
|
|
echo "</select> |
|
613
|
|
|
|
|
614
|
|
|
"._AM_XHELP_TEXT_NUMBER_PER_PAGE." |
|
615
|
|
|
<select name='limit'>"; |
|
616
|
|
View Code Duplication |
foreach($aLimitBy as $value=>$text){ |
|
617
|
|
|
($limit == $value) ? $selected = "selected='selected'" : $selected = ''; |
|
618
|
|
|
echo "<option value='$value' $selected>$text</option>"; |
|
619
|
|
|
} |
|
620
|
|
|
echo "</select> |
|
621
|
|
|
<input type='submit' name='mime_sort' id='mime_sort' value='"._AM_XHELP_BUTTON_SUBMIT."' /> |
|
622
|
|
|
<input type='hidden' name='mime_search' id='mime_search' value='1' /> |
|
623
|
|
|
<input type='hidden' name='search_by' id='search_by' value='$search_field' /> |
|
624
|
|
|
<input type='hidden' name='search_text' id='search_text' value='$search_text' /> |
|
625
|
|
|
</td> |
|
626
|
|
|
</tr>"; |
|
627
|
|
|
echo "</table>"; |
|
628
|
|
|
echo "</td></tr>"; |
|
629
|
|
|
if(count($mimetypes) > 0){ |
|
630
|
|
|
echo "<tr><th colspan='6'>"._AM_XHELP_TEXT_SEARCH_MIME."</th></tr>"; |
|
631
|
|
|
echo "<tr class='head'> |
|
632
|
|
|
<td>"._AM_XHELP_MIME_ID."</td> |
|
633
|
|
|
<td>"._AM_XHELP_MIME_NAME."</td> |
|
634
|
|
|
<td>"._AM_XHELP_MIME_EXT."</td> |
|
635
|
|
|
<td>"._AM_XHELP_MIME_ADMIN."</td> |
|
636
|
|
|
<td>"._AM_XHELP_MIME_USER."</td> |
|
637
|
|
|
<td>"._AM_XHELP_MINDEX_ACTION."</td> |
|
638
|
|
|
</tr>"; |
|
639
|
|
View Code Duplication |
foreach($mimetypes as $mime){ |
|
640
|
|
|
echo "<tr class='even'> |
|
641
|
|
|
<td><input type='checkbox' name='mimes[]' value='".$mime->getVar('mime_id')."' />".$mime->getVar('mime_id')."</td> |
|
642
|
|
|
<td>".$mime->getVar('mime_name')."</td> |
|
643
|
|
|
<td>".$mime->getVar('mime_ext')."</td> |
|
644
|
|
|
<td> |
|
645
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=updateMimeValue&id=".$mime->getVar('mime_id')."&mime_admin=".$mime->getVar('mime_admin')."&limit=".$limit."&start=".$start."'> |
|
646
|
|
|
".($mime->getVar('mime_admin') ? $imagearray['online'] : $imagearray['offline'])."</a> |
|
647
|
|
|
</td> |
|
648
|
|
|
<td> |
|
649
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=updateMimeValue&id=".$mime->getVar('mime_id')."&mime_user=".$mime->getVar('mime_user')."&limit=".$limit."&start=".$start."'> |
|
650
|
|
|
".($mime->getVar('mime_user') ? $imagearray['online'] : $imagearray['offline'])."</a> |
|
651
|
|
|
</td> |
|
652
|
|
|
<td> |
|
653
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=edit&id=".$mime->getVar('mime_id')."&limit=".$limit."&start=".$start."'>".$imagearray['editimg']."</a> |
|
654
|
|
|
<a href='".XHELP_ADMIN_URL."/mimetypes.php?op=delete&id=".$mime->getVar('mime_id')."&limit=".$limit."&start=".$start."'>".$imagearray['deleteimg']."</a> |
|
655
|
|
|
</td> |
|
656
|
|
|
</tr>"; |
|
657
|
|
|
} |
|
658
|
|
|
echo "<tr class='foot'> |
|
659
|
|
|
<td colspan='6' valign='top'> |
|
660
|
|
|
<a href='http://www.filext.com' style='float: right' target='_blank'>"._AM_XHELP_MIME_FINDMIMETYPE."</a> |
|
661
|
|
|
<input type='checkbox' name='checkAllMimes' value='0' onclick='selectAll(this.form,\"mimes[]\",this.checked);' /> |
|
662
|
|
|
<input type='submit' name='deleteMimes' id='deleteMimes' value='"._AM_XHELP_BUTTON_DELETE."' /> |
|
663
|
|
|
<input type='submit' name='add_mime' id='add_mime' value='"._AM_XHELP_MIME_CREATEF."' class='formButton' /> |
|
664
|
|
|
</td> |
|
665
|
|
|
</tr>"; |
|
666
|
|
|
} else { |
|
667
|
|
|
echo "<tr><th>"._AM_XHELP_TEXT_SEARCH_MIME."</th></tr>"; |
|
668
|
|
|
echo "<tr class='even'> |
|
669
|
|
|
<td>"._AM_XHELP_TEXT_NO_RECORDS."</td> |
|
670
|
|
|
</tr>"; |
|
671
|
|
|
} |
|
672
|
|
|
echo "</table>"; |
|
673
|
|
|
echo "<div id='pagenav'>".$nav->renderNav()."</div>"; |
|
674
|
|
|
} |
|
675
|
|
|
include_once "admin_footer.php"; |
|
676
|
|
|
} |
|
677
|
|
|
|
|
678
|
|
|
function updateMimeValue() |
|
|
|
|
|
|
679
|
|
|
{ |
|
680
|
|
|
global $hMime; |
|
|
|
|
|
|
681
|
|
|
$start = $limit = 0; |
|
682
|
|
|
|
|
683
|
|
|
if (isset($_GET['limit'])) { |
|
684
|
|
|
$limit = intval($_GET['limit']); |
|
685
|
|
|
} |
|
686
|
|
|
if (isset($_GET['start'])) { |
|
687
|
|
|
$start = intval($_GET['start']); |
|
688
|
|
|
} |
|
689
|
|
|
|
|
690
|
|
|
if(!isset($_REQUEST['id'])){ |
|
691
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php", 3, _AM_XHELP_MESSAGE_NO_ID); |
|
692
|
|
|
} else { |
|
693
|
|
|
$mime_id = intval($_REQUEST['id']); |
|
694
|
|
|
} |
|
695
|
|
|
|
|
696
|
|
|
$mimetype =& $hMime->get($mime_id); |
|
|
|
|
|
|
697
|
|
|
|
|
698
|
|
View Code Duplication |
if(isset($_REQUEST['mime_admin'])){ |
|
699
|
|
|
$mime_admin = intval($_REQUEST['mime_admin']); |
|
700
|
|
|
$mime_admin = _changeMimeValue($mime_admin); |
|
701
|
|
|
$mimetype->setVar('mime_admin', $mime_admin); |
|
702
|
|
|
} |
|
703
|
|
View Code Duplication |
if(isset($_REQUEST['mime_user'])){ |
|
704
|
|
|
$mime_user = intval($_REQUEST['mime_user']); |
|
705
|
|
|
$mime_user = _changeMimeValue($mime_user); |
|
706
|
|
|
$mimetype->setVar('mime_user', $mime_user); |
|
707
|
|
|
} |
|
708
|
|
View Code Duplication |
if($hMime->insert($mimetype, true)){ |
|
709
|
|
|
header("Location: ".XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start"); |
|
710
|
|
|
} else { |
|
711
|
|
|
redirect_header(XHELP_ADMIN_URL."/mimetypes.php?limit=$limit&start=$start", 3); |
|
712
|
|
|
} |
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
|
|
function _changeMimeValue($mime_value) |
|
716
|
|
|
{ |
|
717
|
|
|
if($mime_value == 1){ |
|
718
|
|
|
$mime_value = 0; |
|
719
|
|
|
} else { |
|
720
|
|
|
$mime_value = 1; |
|
721
|
|
|
} |
|
722
|
|
|
|
|
723
|
|
|
return $mime_value; |
|
724
|
|
|
} |
|
725
|
|
|
|
|
726
|
|
|
function _clearAddSessionVars() |
|
|
|
|
|
|
727
|
|
|
{ |
|
728
|
|
|
$session = Session::singleton(); |
|
729
|
|
|
$session->del('xhelp_addMime'); |
|
730
|
|
|
$session->del('xhelp_addMimeErr'); |
|
731
|
|
|
} |
|
732
|
|
|
|
|
733
|
|
|
function clearAddSession() |
|
|
|
|
|
|
734
|
|
|
{ |
|
735
|
|
|
_clearAddSessionVars(); |
|
736
|
|
|
header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'add'), false)); |
|
737
|
|
|
} |
|
738
|
|
|
|
|
739
|
|
View Code Duplication |
function _clearEditSessionVars($id) |
|
|
|
|
|
|
740
|
|
|
{ |
|
741
|
|
|
$id = intval($id); |
|
742
|
|
|
$session = Session::singleton(); |
|
743
|
|
|
$session->del("xhelp_editMime_$id"); |
|
744
|
|
|
$session->del("xhelp_editMimeErr_$id"); |
|
745
|
|
|
} |
|
746
|
|
|
|
|
747
|
|
|
function clearEditSession() |
|
|
|
|
|
|
748
|
|
|
{ |
|
749
|
|
|
$mimeid = $_REQUEST['id']; |
|
750
|
|
|
_clearEditSessionVars($mimeid); |
|
751
|
|
|
header('Location: ' . xhelpMakeURI(XHELP_ADMIN_URL.'/mimetypes.php', array('op'=>'edit', 'id'=>$mimeid), false)); |
|
752
|
|
|
} |
|
753
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.