1 | <?php |
||
2 | /** |
||
3 | * Simple Machines Forum (SMF) |
||
4 | * |
||
5 | * @package SMF |
||
6 | * @author Simple Machines https://www.simplemachines.org |
||
7 | * @copyright 2022 Simple Machines and individual contributors |
||
8 | * @license https://www.simplemachines.org/about/smf/license.php BSD |
||
9 | * |
||
10 | * @version 2.1.3 |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * The main template |
||
15 | */ |
||
16 | function template_main() |
||
17 | { |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * View package details when installing/uninstalling |
||
22 | */ |
||
23 | function template_view_package() |
||
24 | { |
||
25 | global $context, $settings, $txt, $scripturl; |
||
26 | |||
27 | echo ' |
||
28 | <div class="cat_bar"> |
||
29 | <h3 class="catbg">', $txt[($context['uninstalling'] ? 'uninstall' : ('install_' . $context['extract_type']))], '</h3> |
||
30 | </div> |
||
31 | <div class="information">'; |
||
32 | |||
33 | if ($context['is_installed']) |
||
34 | echo ' |
||
35 | <strong>', $txt['package_installed_warning1'], '</strong><br> |
||
36 | <br> |
||
37 | ', $txt['package_installed_warning2'], '<br> |
||
38 | <br>'; |
||
39 | |||
40 | echo $txt['package_installed_warning3'], ' |
||
41 | </div> |
||
42 | <br>'; |
||
43 | |||
44 | if (!empty($context['package_blacklist_found'])) |
||
45 | echo ' |
||
46 | <div class="errorbox">', $txt['package_validation_blacklist_found'], ' |
||
47 | </div>'; |
||
48 | |||
49 | // Do errors exist in the install? If so light them up like a christmas tree. |
||
50 | if ($context['has_failure']) |
||
51 | echo ' |
||
52 | <div class="errorbox"> |
||
53 | ', sprintf($txt['package_will_fail_title'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), '<br> |
||
54 | ', sprintf($txt['package_will_fail_warning'], $txt['package_' . ($context['uninstalling'] ? 'uninstall' : 'install')]), |
||
55 | !empty($context['failure_details']) ? '<br><br><strong>' . $context['failure_details'] . '</strong>' : '', ' |
||
56 | </div>'; |
||
57 | |||
58 | // Validation info? |
||
59 | if (!empty($context['validation_tests'])) |
||
60 | { |
||
61 | echo ' |
||
62 | <div class="title_bar"> |
||
63 | <h3 class="titlebg">', $txt['package_validaiton_results'], '</h3> |
||
64 | </div> |
||
65 | <div id="package_validation"> |
||
66 | <table class="table_grid">'; |
||
67 | |||
68 | foreach ($context['validation_tests'] as $id_server => $result) |
||
69 | { |
||
70 | echo ' |
||
71 | <tr> |
||
72 | <td>', $context['package_servers'][$id_server]['name'], '</td> |
||
73 | <td>', $txt[isset($result[$context['package_sha256_hash']]) ? $result[$context['package_sha256_hash']] : 'package_validation_status_unknown'], '</td> |
||
74 | </tr>'; |
||
75 | } |
||
76 | |||
77 | echo ' |
||
78 | </table> |
||
79 | </div> |
||
80 | <br>'; |
||
81 | } |
||
82 | |||
83 | // Display the package readme if one exists |
||
84 | if (isset($context['package_readme'])) |
||
85 | { |
||
86 | echo ' |
||
87 | <div class="cat_bar"> |
||
88 | <h3 class="catbg">', $txt['package_' . ($context['uninstalling'] ? 'un' : '') . 'install_readme'], '</h3> |
||
89 | </div> |
||
90 | <div class="windowbg"> |
||
91 | ', $context['package_readme'], ' |
||
92 | <span class="floatright">', $txt['package_available_readme_language'], ' |
||
93 | <select name="readme_language" id="readme_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=', $context['uninstalling'] ? 'uninstall' : 'install', ';package=', $context['filename'], ';license=\' + this.options[this.selectedIndex].value + \';readme=\' + get_selected(\'readme_language\'));">'; |
||
94 | |||
95 | foreach ($context['readmes'] as $a => $b) |
||
96 | echo ' |
||
97 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_readme_default'] : ucfirst($b), '</option>'; |
||
98 | |||
99 | echo ' |
||
100 | </select> |
||
101 | </span> |
||
102 | </div> |
||
103 | <br>'; |
||
104 | } |
||
105 | |||
106 | // Did they specify a license to display? |
||
107 | if (isset($context['package_license'])) |
||
108 | { |
||
109 | echo ' |
||
110 | <div class="cat_bar"> |
||
111 | <h3 class="catbg">', $txt['package_install_license'], '</h3> |
||
112 | </div> |
||
113 | <div class="windowbg"> |
||
114 | ', $context['package_license'], ' |
||
115 | <span class="floatright">', $txt['package_available_license_language'], ' |
||
116 | <select name="license_language" id="license_language" onchange="if (this.options[this.selectedIndex].value) window.location.href = smf_prepareScriptUrl(smf_scripturl + \'', '?action=admin;area=packages;sa=install', ';package=', $context['filename'], ';readme=\' + this.options[this.selectedIndex].value + \';license=\' + get_selected(\'license_language\'));">'; |
||
117 | |||
118 | foreach ($context['licenses'] as $a => $b) |
||
119 | echo ' |
||
120 | <option value="', $b, '"', $a === 'selected' ? ' selected' : '', '>', $b == 'default' ? $txt['package_license_default'] : ucfirst($b), '</option>'; |
||
121 | echo ' |
||
122 | </select> |
||
123 | </span> |
||
124 | </div> |
||
125 | <br>'; |
||
126 | } |
||
127 | |||
128 | echo ' |
||
129 | <form action="', !empty($context['post_url']) ? $context['post_url'] : '#', '" onsubmit="submitonce(this);" method="post" accept-charset="', $context['character_set'], '" id="view_package"> |
||
130 | <div class="cat_bar"> |
||
131 | <h3 class="catbg"> |
||
132 | ', $context['uninstalling'] ? $txt['package_uninstall_actions'] : $txt['package_install_actions'], ' "', $context['package_name'], '" |
||
133 | </h3> |
||
134 | </div>'; |
||
135 | |||
136 | // Are there data changes to be removed? |
||
137 | if ($context['uninstalling'] && !empty($context['database_changes'])) |
||
138 | { |
||
139 | // This is really a special case so we're adding style inline |
||
140 | echo ' |
||
141 | <div class="windowbg" style="margin: 0; border-radius: 0;"> |
||
142 | <label><input type="checkbox" name="do_db_changes">', $txt['package_db_uninstall'], '</label> |
||
143 | <div id="db_changes_div"> |
||
144 | ', $txt['package_db_uninstall_actions'], ': |
||
145 | <ul class="normallist smalltext">'; |
||
146 | |||
147 | foreach ($context['database_changes'] as $change) |
||
148 | echo ' |
||
149 | <li>', $change, '</li>'; |
||
150 | |||
151 | echo ' |
||
152 | </ul> |
||
153 | </div> |
||
154 | </div>'; |
||
155 | } |
||
156 | |||
157 | echo ' |
||
158 | <div class="information">'; |
||
159 | |||
160 | if (empty($context['actions']) && empty($context['database_changes'])) |
||
161 | echo ' |
||
162 | <br> |
||
163 | <div class="errorbox"> |
||
164 | ', $txt['corrupt_compatible'], ' |
||
165 | </div> |
||
166 | </div><!-- .information -->'; |
||
167 | else |
||
168 | { |
||
169 | echo ' |
||
170 | ', $txt['perform_actions'], ' |
||
171 | </div><!-- .information --> |
||
172 | <br> |
||
173 | <table class="table_grid"> |
||
174 | <thead> |
||
175 | <tr class="title_bar"> |
||
176 | <th scope="col"></th> |
||
177 | <th scope="col" width="30"></th> |
||
178 | <th scope="col" class="lefttext">', $txt['package_install_type'], '</th> |
||
179 | <th scope="col" class="lefttext" width="50%">', $txt['package_install_action'], '</th> |
||
180 | <th class="lefttext" scope="col" width="20%">', $txt['package_install_desc'], '</th> |
||
181 | </tr> |
||
182 | </thead> |
||
183 | <tbody>'; |
||
184 | |||
185 | $i = 1; |
||
186 | $j = 1; |
||
187 | $action_num = 1; |
||
188 | $js_operations = array(); |
||
189 | foreach ($context['actions'] as $packageaction) |
||
190 | { |
||
191 | // Did we pass or fail? Need to now for later on. |
||
192 | $js_operations[$action_num] = isset($packageaction['failed']) ? $packageaction['failed'] : 0; |
||
193 | |||
194 | echo ' |
||
195 | <tr class="bg ', $i % 2 == 0 ? 'even' : 'odd', '"> |
||
196 | <td>', isset($packageaction['operations']) ? '<img id="operation_img_' . $action_num . '" src="' . $settings['images_url'] . '/selected_open.png" alt="*" style="display: none;">' : '', '</td> |
||
197 | <td style="width: 30px;">', $i++, '.</td> |
||
198 | <td style="width: 23%;">', $packageaction['type'], '</td> |
||
199 | <td style="width: 50%;">', $packageaction['action'], '</td> |
||
200 | <td style="width: 20%;"><strong', !empty($packageaction['failed']) ? ' class="error"' : '', '>', $packageaction['description'], '</strong></td> |
||
201 | </tr>'; |
||
202 | |||
203 | // Is there water on the knee? Operation! |
||
204 | if (isset($packageaction['operations'])) |
||
205 | { |
||
206 | echo ' |
||
207 | <tr id="operation_', $action_num, '"> |
||
208 | <td colspan="5"> |
||
209 | <table class="full_width">'; |
||
210 | |||
211 | // Show the operations. |
||
212 | $operation_num = 1; |
||
213 | foreach ($packageaction['operations'] as $operation) |
||
214 | { |
||
215 | // Determine the position text. |
||
216 | $operation_text = $operation['position'] == 'replace' ? 'operation_replace' : ($operation['position'] == 'before' ? 'operation_after' : 'operation_before'); |
||
217 | |||
218 | echo ' |
||
219 | <tr class="bg ', $operation_num % 2 == 0 ? 'even' : 'odd', '"> |
||
220 | <td class="righttext"> |
||
221 | <a href="', $scripturl, '?action=admin;area=packages;sa=showoperations;operation_key=', $operation['operation_key'], !empty($context['install_id']) ? ';install_id=' . $context['install_id'] : '', ';package=', $_REQUEST['package'], ';filename=', $operation['filename'], ($operation['is_boardmod'] ? ';boardmod' : ''), (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'uninstall' ? ';reverse' : ''), '" onclick="return reqWin(this.href, 600, 400, false);"> |
||
222 | <span class="main_icons package_ops"></span> |
||
223 | </a> |
||
224 | </td> |
||
225 | <td width="30">', $operation_num++, '.</td> |
||
226 | <td width="23%">', $txt[$operation_text], '</td> |
||
227 | <td width="50%">', $operation['action'], '</td> |
||
228 | <td width="20%"><strong', !empty($operation['failed']) ? ' class="error"' : '', '>', $operation['description'], !empty($operation['ignore_failure']) ? ' (' . $txt['operation_ignore'] . ')' : '', '</strong></td> |
||
229 | </tr>'; |
||
230 | } |
||
231 | |||
232 | echo ' |
||
233 | </table> |
||
234 | </td> |
||
235 | </tr>'; |
||
236 | |||
237 | // Increase it. |
||
238 | $action_num++; |
||
239 | } |
||
240 | } |
||
241 | echo ' |
||
242 | </tbody> |
||
243 | </table>'; |
||
244 | |||
245 | // What if we have custom themes we can install into? List them too! |
||
246 | if (!empty($context['theme_actions'])) |
||
247 | { |
||
248 | echo ' |
||
249 | <br> |
||
250 | <div class="cat_bar"> |
||
251 | <h3 class="catbg"> |
||
252 | ', $context['uninstalling'] ? $txt['package_other_themes_uninstall'] : $txt['package_other_themes'], ' |
||
253 | </h3> |
||
254 | </div> |
||
255 | <div id="custom_changes"> |
||
256 | <div class="information"> |
||
257 | ', $txt['package_other_themes_desc'], ' |
||
258 | </div> |
||
259 | <table class="table_grid">'; |
||
260 | |||
261 | // Loop through each theme and display it's name, and then it's details. |
||
262 | foreach ($context['theme_actions'] as $id => $theme) |
||
263 | { |
||
264 | // Pass? |
||
265 | $js_operations[$action_num] = !empty($theme['has_failure']); |
||
266 | |||
267 | echo ' |
||
268 | <tr class="title_bar"> |
||
269 | <td class="righttext" colspan="2">'; |
||
270 | |||
271 | if (!empty($context['themes_locked'])) |
||
272 | echo ' |
||
273 | <input type="hidden" name="custom_theme[]" value="', $id, '">'; |
||
274 | echo ' |
||
275 | <input type="checkbox" name="custom_theme[]" id="custom_theme_', $id, '" value="', $id, '" onclick="', (!empty($theme['has_failure']) ? 'if (this.form.custom_theme_' . $id . '.checked && !confirm(\'' . $txt['package_theme_failure_warning'] . '\')) return false;' : ''), 'invertAll(this, this.form, \'dummy_theme_', $id, '\', true);"', !empty($context['themes_locked']) ? ' disabled checked' : '', '> |
||
276 | </td> |
||
277 | <td colspan="3"> |
||
278 | ', $theme['name'], ' |
||
279 | </td> |
||
280 | </tr>'; |
||
281 | |||
282 | foreach ($theme['actions'] as $action) |
||
283 | { |
||
284 | echo ' |
||
285 | <tr class="bg ', $j++ % 2 == 0 ? 'even' : 'odd', '"> |
||
286 | <td colspan="2">', isset($packageaction['operations']) ? |
||
287 | '<img id="operation_img_' . $action_num . '" src="' . $settings['images_url'] . '/selected_open.png" alt="*" style="display: none;">' : '', ' |
||
288 | <input type="checkbox" name="theme_changes[]" value="', !empty($action['value']) ? $action['value'] : '', '" id="dummy_theme_', $id, '"', (!empty($action['not_mod']) ? '' : ' disabled'), !empty($context['themes_locked']) ? ' checked' : '', ' class="floatright"> |
||
289 | </td> |
||
290 | <td width="23%">', $action['type'], '</td> |
||
291 | <td width="50%">', $action['action'], '</td> |
||
292 | <td width="20%"><strong', !empty($action['failed']) ? ' class="error"' : '', '>', $action['description'], '</strong></td> |
||
293 | </tr>'; |
||
294 | |||
295 | // Is there water on the knee? Operation! |
||
296 | if (isset($action['operations'])) |
||
297 | { |
||
298 | echo ' |
||
299 | <tr id="operation_', $action_num, '"> |
||
300 | <td colspan="5"> |
||
301 | <table class="full_width">'; |
||
302 | |||
303 | $operation_num = 1; |
||
304 | foreach ($action['operations'] as $operation) |
||
305 | { |
||
306 | // Determine the position text. |
||
307 | $operation_text = $operation['position'] == 'replace' ? 'operation_replace' : ($operation['position'] == 'before' ? 'operation_after' : 'operation_before'); |
||
308 | |||
309 | echo ' |
||
310 | <tr class="bg ', $operation_num % 2 == 0 ? 'even' : 'odd', '"> |
||
311 | <td class="righttext"> |
||
312 | <a href="', $scripturl, '?action=admin;area=packages;sa=showoperations;operation_key=', $operation['operation_key'], !empty($context['install_id']) ? ';install_id=' . $context['install_id'] : '', ';package=', $_REQUEST['package'], ';filename=', $operation['filename'], ($operation['is_boardmod'] ? ';boardmod' : ''), (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'uninstall' ? ';reverse' : ''), '" onclick="return reqWin(this.href, 600, 400, false);"> |
||
313 | <span class="main_icons package_ops"></span> |
||
314 | </a> |
||
315 | </td> |
||
316 | <td width="30">', $operation_num++, '.</td> |
||
317 | <td width="23%">', $txt[$operation_text], '</td> |
||
318 | <td width="50%">', $operation['action'], '</td> |
||
319 | <td width="20%"><strong', !empty($operation['failed']) ? ' class="error"' : '', '>', $operation['description'], !empty($operation['ignore_failure']) ? ' (' . $txt['operation_ignore'] . ')' : '', '</strong></td> |
||
320 | </tr>'; |
||
321 | } |
||
322 | |||
323 | echo ' |
||
324 | </table> |
||
325 | </td> |
||
326 | </tr>'; |
||
327 | |||
328 | // Increase it. |
||
329 | $action_num++; |
||
330 | } |
||
331 | } |
||
332 | } |
||
333 | |||
334 | echo ' |
||
335 | </table> |
||
336 | </div><!-- #custom_changes -->'; |
||
337 | } |
||
338 | } |
||
339 | |||
340 | // Are we effectively ready to install? |
||
341 | if (!$context['ftp_needed'] && (!empty($context['actions']) || !empty($context['database_changes']))) |
||
342 | echo ' |
||
343 | <div class="righttext padding"> |
||
344 | <input type="submit" value="', $context['uninstalling'] ? $txt['package_uninstall_now'] : $txt['package_install_now'], '" onclick="return ', !empty($context['has_failure']) ? '(submitThisOnce(this) && confirm(\'' . ($context['uninstalling'] ? $txt['package_will_fail_popup_uninstall'] : $txt['package_will_fail_popup']) . '\'))' : 'submitThisOnce(this)', ';" class="button"> |
||
345 | </div>'; |
||
346 | |||
347 | // If we need ftp information then demand it! |
||
348 | elseif ($context['ftp_needed']) |
||
349 | echo ' |
||
350 | <div class="cat_bar"> |
||
351 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
||
352 | </div> |
||
353 | <div> |
||
354 | ', template_control_chmod(), ' |
||
355 | </div>'; |
||
356 | |||
357 | echo ' |
||
358 | |||
359 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">', (isset($context['form_sequence_number']) && !$context['ftp_needed']) ? ' |
||
360 | <input type="hidden" name="seqnum" value="' . $context['form_sequence_number'] . '">' : '', ' |
||
361 | </form>'; |
||
362 | |||
363 | // Toggle options. |
||
364 | echo ' |
||
365 | <script>'; |
||
366 | |||
367 | // Operations. |
||
368 | if (!empty($js_operations)) |
||
369 | foreach ($js_operations as $key => $operation) |
||
370 | echo ' |
||
371 | new smc_Toggle({ |
||
372 | bToggleEnabled: true, |
||
373 | bNoAnimate: true, |
||
374 | bCurrentlyCollapsed: ', $operation ? 'false' : 'true', ', |
||
375 | aSwappableContainers: [ |
||
376 | \'operation_', $key, '\' |
||
377 | ], |
||
378 | aSwapImages: [ |
||
379 | { |
||
380 | sId: \'operation_img_', $key, '\', |
||
381 | srcExpanded: smf_images_url + \'/selected_open.png\', |
||
382 | altExpanded: \'*\', |
||
383 | srcCollapsed: smf_images_url + \'/selected.png\', |
||
384 | altCollapsed: \'*\' |
||
385 | } |
||
386 | ] |
||
387 | });'; |
||
388 | |||
389 | // Get the currently selected item from a select list |
||
390 | echo ' |
||
391 | function get_selected(id) |
||
392 | { |
||
393 | var aSelected = document.getElementById(id); |
||
394 | for (var i = 0; i < aSelected.options.length; i++) |
||
395 | { |
||
396 | if (aSelected.options[i].selected == true) |
||
397 | return aSelected.options[i].value; |
||
398 | } |
||
399 | return aSelected.options[0]; |
||
400 | }'; |
||
401 | |||
402 | // And a bit more for database changes. |
||
403 | if ($context['uninstalling'] && !empty($context['database_changes'])) |
||
404 | echo ' |
||
405 | makeToggle(document.getElementById(\'db_changes_div\'), ', JavaScriptEscape($txt['package_db_uninstall_details']), ');'; |
||
406 | |||
407 | echo ' |
||
408 | </script>'; |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * Extract package contents |
||
413 | */ |
||
414 | function template_extract_package() |
||
415 | { |
||
416 | global $context, $txt, $scripturl; |
||
417 | |||
418 | echo ' |
||
419 | <div class="cat_bar"> |
||
420 | <h3 class="catbg">'; |
||
421 | |||
422 | if (empty($context['redirect_url'])) |
||
423 | echo $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']; |
||
424 | else |
||
425 | echo $txt['package_installed_redirecting']; |
||
426 | |||
427 | echo '</h3> |
||
428 | </div> |
||
429 | <div class="windowbg">'; |
||
430 | |||
431 | // If we are going to redirect we have a slightly different agenda. |
||
432 | if (!empty($context['redirect_url'])) |
||
433 | echo ' |
||
434 | ', $context['redirect_text'], '<br><br> |
||
435 | <a href="', $context['redirect_url'], '">', $txt['package_installed_redirect_go_now'], '</a><span id="countdown" class="hidden"> (5) </span> | <a href="', $scripturl, '?action=admin;area=packages;sa=browse">', $txt['package_installed_redirect_cancel'], '</a> |
||
436 | <script> |
||
437 | var countdown = ', $context['redirect_timeout'], '; |
||
438 | var el = document.getElementById(\'countdown\'); |
||
439 | var loop = setInterval(doCountdown, 1000); |
||
440 | |||
441 | function doCountdown() |
||
442 | { |
||
443 | countdown--; |
||
444 | el.textContent = " (" + countdown + ") "; |
||
445 | |||
446 | if (countdown == 0) |
||
447 | { |
||
448 | clearInterval(loop); |
||
449 | window.location = "', $context['redirect_url'], '"; |
||
450 | } |
||
451 | } |
||
452 | el.classList.remove(\'hidden\'); |
||
453 | el.value = " (" + countdown + ") "; |
||
454 | </script>'; |
||
455 | |||
456 | elseif ($context['uninstalling']) |
||
457 | echo ' |
||
458 | ', $txt['package_uninstall_done'] .' <br> |
||
459 | ', '<a href="', $context['keep_url'], '" class="button">', $txt['package_keep'], '</a>', '<a href="', $context['remove_url'], '" class="button">', $txt['package_delete2'], '</a>'; |
||
460 | |||
461 | elseif ($context['install_finished']) |
||
462 | { |
||
463 | if ($context['extract_type'] == 'avatar') |
||
464 | echo ' |
||
465 | ', $txt['avatars_extracted']; |
||
466 | |||
467 | elseif ($context['extract_type'] == 'language') |
||
468 | echo ' |
||
469 | ', $txt['language_extracted']; |
||
470 | |||
471 | else |
||
472 | echo ' |
||
473 | ', $txt['package_installed_done']; |
||
474 | } |
||
475 | else |
||
476 | echo ' |
||
477 | ', $txt['corrupt_compatible']; |
||
478 | |||
479 | echo ' |
||
480 | </div><!-- .windowbg -->'; |
||
481 | |||
482 | // Show the "restore permissions" screen? |
||
483 | if (function_exists('template_show_list') && !empty($context['restore_file_permissions']['rows'])) |
||
484 | { |
||
485 | echo '<br>'; |
||
486 | template_show_list('restore_file_permissions'); |
||
487 | } |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * List files in a package |
||
492 | */ |
||
493 | function template_list() |
||
494 | { |
||
495 | global $context, $txt, $scripturl; |
||
496 | |||
497 | echo ' |
||
498 | <div class="cat_bar"> |
||
499 | <h3 class="catbg">', $txt['list_file'], '</h3> |
||
500 | </div> |
||
501 | <div class="title_bar"> |
||
502 | <h4 class="titlebg">', $txt['files_archive'], ' ', $context['filename'], ':</h4> |
||
503 | </div> |
||
504 | <div class="windowbg"> |
||
505 | <ol>'; |
||
506 | |||
507 | foreach ($context['files'] as $fileinfo) |
||
508 | echo ' |
||
509 | <li><a href="', $scripturl, '?action=admin;area=packages;sa=examine;package=', $context['filename'], ';file=', $fileinfo['filename'], '" title="', $txt['view'], '">', $fileinfo['filename'], '</a> (', $fileinfo['size'], ' ', $txt['package_bytes'], ')</li>'; |
||
510 | |||
511 | echo ' |
||
512 | </ol> |
||
513 | <br> |
||
514 | <a href="', $scripturl, '?action=admin;area=packages">[ ', $txt['back'], ' ]</a> |
||
515 | </div>'; |
||
516 | } |
||
517 | |||
518 | /** |
||
519 | * Examine a single file within a package |
||
520 | */ |
||
521 | function template_examine() |
||
522 | { |
||
523 | global $context, $txt, $scripturl; |
||
524 | |||
525 | echo ' |
||
526 | <div class="cat_bar"> |
||
527 | <h3 class="catbg">', $txt['package_examine_file'], '</h3> |
||
528 | </div> |
||
529 | <div class="title_bar"> |
||
530 | <h4 class="titlebg">', $txt['package_file_contents'], ' ', $context['filename'], ':</h4> |
||
531 | </div> |
||
532 | <div class="windowbg"> |
||
533 | <pre class="file_content">', $context['filedata'], '</pre> |
||
534 | <a href="', $scripturl, '?action=admin;area=packages;sa=list;package=', $context['package'], '">[ ', $txt['list_files'], ' ]</a> |
||
535 | </div>'; |
||
536 | } |
||
537 | |||
538 | /** |
||
539 | * List all packages |
||
540 | */ |
||
541 | function template_browse() |
||
542 | { |
||
543 | global $context, $txt, $scripturl, $modSettings; |
||
544 | |||
545 | echo ' |
||
546 | <div id="update_section"></div> |
||
547 | <div id="admin_form_wrapper"> |
||
548 | <div class="cat_bar"> |
||
549 | <h3 class="catbg"> |
||
550 | ', $txt['packages_adding_title'], ' |
||
551 | </h3> |
||
552 | </div> |
||
553 | <div class="information"> |
||
554 | ', $txt['packages_adding'], ' |
||
555 | </div> |
||
556 | |||
557 | <script> |
||
558 | window.smfForum_scripturl = smf_scripturl; |
||
559 | window.smfForum_sessionid = smf_session_id; |
||
560 | window.smfForum_sessionvar = smf_session_var;'; |
||
561 | |||
562 | // Make a list of already installed mods so nothing is listed twice ;). |
||
563 | echo ' |
||
564 | window.smfInstalledPackages = ["', implode('", "', $context['installed_mods']), '"]; |
||
565 | window.smfVersion = "', $context['forum_version'], '"; |
||
566 | </script> |
||
567 | <div id="yourVersion" style="display:none">', $context['forum_version'], '</div>'; |
||
568 | |||
569 | if (empty($modSettings['disable_smf_js'])) |
||
570 | echo ' |
||
571 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
||
572 | |||
573 | // This sets the announcements and current versions themselves ;). |
||
574 | echo ' |
||
575 | <script> |
||
576 | var oAdminIndex = new smf_AdminIndex({ |
||
577 | sSelf: \'oAdminCenter\', |
||
578 | bLoadAnnouncements: false, |
||
579 | bLoadVersions: false, |
||
580 | bLoadUpdateNotification: true, |
||
581 | sUpdateNotificationContainerId: \'update_section\', |
||
582 | sUpdateNotificationDefaultTitle: ', JavaScriptEscape($txt['update_available']), ', |
||
583 | sUpdateNotificationDefaultMessage: ', JavaScriptEscape($txt['update_message']), ', |
||
584 | sUpdateNotificationTemplate: ', JavaScriptEscape(' |
||
585 | <h3 id="update_title"> |
||
586 | %title% |
||
587 | </h3> |
||
588 | <div id="update_message" class="smalltext"> |
||
589 | %message% |
||
590 | </div> |
||
591 | '), ', |
||
592 | sUpdateNotificationLink: smf_scripturl + ', JavaScriptEscape('?action=admin;area=packages;pgdownload;auto;package=%package%;' . $context['session_var'] . '=' . $context['session_id']), ' |
||
593 | }); |
||
594 | </script>'; |
||
595 | |||
596 | echo ' |
||
597 | </div><!-- #admin_form_wrapper -->'; |
||
598 | |||
599 | if ($context['available_packages'] == 0) |
||
600 | echo ' |
||
601 | <div class="noticebox">', $txt['no_packages'], '</div>'; |
||
602 | else |
||
603 | { |
||
604 | foreach ($context['modification_types'] as $type) |
||
605 | if (!empty($context['packages_lists_' . $type]['rows'])) |
||
606 | template_show_list('packages_lists_' . $type); |
||
607 | |||
608 | echo ' |
||
609 | <br>'; |
||
610 | } |
||
611 | |||
612 | // The advanced (emulation) box, collapsed by default |
||
613 | echo ' |
||
614 | <form action="', $scripturl, '?action=admin;area=packages;sa=browse" method="get"> |
||
615 | <div id="advanced_box"> |
||
616 | <div class="cat_bar"> |
||
617 | <h3 class="catbg"> |
||
618 | <span id="advanced_panel_toggle" class="floatright" style="display: none;"></span> |
||
619 | <a href="#" id="advanced_panel_link">', $txt['package_advanced_button'], '</a> |
||
620 | </h3> |
||
621 | </div> |
||
622 | <div id="advanced_panel_div" class="windowbg"> |
||
623 | <p> |
||
624 | ', $txt['package_emulate_desc'], ' |
||
625 | </p> |
||
626 | <dl class="settings"> |
||
627 | <dt> |
||
628 | <strong>', $txt['package_emulate'], ':</strong><br> |
||
629 | <span class="smalltext"> |
||
630 | <a href="#" onclick="return revert();">', $txt['package_emulate_revert'], '</a> |
||
631 | </span> |
||
632 | </dt> |
||
633 | <dd> |
||
634 | <a id="revert" name="revert"></a> |
||
635 | <select name="version_emulate" id="ve">'; |
||
636 | |||
637 | foreach ($context['emulation_versions'] as $version) |
||
638 | echo ' |
||
639 | <option value="', $version, '"', ($version == $context['selected_version'] ? ' selected="selected"' : ''), '>', $version, '</option>'; |
||
640 | |||
641 | echo ' |
||
642 | </select> |
||
643 | </dd> |
||
644 | </dl> |
||
645 | <div class="righttext padding"> |
||
646 | <input type="submit" value="', $txt['package_apply'], '" class="button"> |
||
647 | </div> |
||
648 | </div><!-- #advanced_panel_div --> |
||
649 | </div><!-- #advanced_box --> |
||
650 | <input type="hidden" name="action" value="admin"> |
||
651 | <input type="hidden" name="area" value="packages"> |
||
652 | <input type="hidden" name="sa" value="browse"> |
||
653 | </form> |
||
654 | <script> |
||
655 | var oAdvancedPanelToggle = new smc_Toggle({ |
||
656 | bToggleEnabled: true, |
||
657 | bCurrentlyCollapsed: true, |
||
658 | aSwappableContainers: [ |
||
659 | \'advanced_panel_div\' |
||
660 | ], |
||
661 | aSwapImages: [ |
||
662 | { |
||
663 | sId: \'advanced_panel_toggle\', |
||
664 | altExpanded: ', JavaScriptEscape($txt['hide']), ', |
||
665 | altCollapsed: ', JavaScriptEscape($txt['show']), ' |
||
666 | } |
||
667 | ], |
||
668 | aSwapLinks: [ |
||
669 | { |
||
670 | sId: \'advanced_panel_link\', |
||
671 | msgExpanded: ', JavaScriptEscape($txt['package_advanced_button']), ', |
||
672 | msgCollapsed: ', JavaScriptEscape($txt['package_advanced_button']), ' |
||
673 | } |
||
674 | ] |
||
675 | }); |
||
676 | function revert() |
||
677 | { |
||
678 | var default_version = "', $context['default_version'], '"; |
||
679 | $("#ve").find("option").filter(function(index) { |
||
680 | return default_version === $(this).text(); |
||
681 | }).attr("selected", "selected"); |
||
682 | return false; |
||
683 | } |
||
684 | </script>'; |
||
685 | } |
||
686 | |||
687 | /** |
||
688 | * List package servers |
||
689 | */ |
||
690 | function template_servers() |
||
691 | { |
||
692 | global $context, $txt, $scripturl; |
||
693 | |||
694 | if (!empty($context['package_ftp']['error'])) |
||
695 | echo ' |
||
696 | <div class="errorbox"> |
||
697 | <pre>', $context['package_ftp']['error'], '</pre> |
||
698 | </div>'; |
||
699 | |||
700 | echo ' |
||
701 | <div id="admin_form_wrapper"> |
||
702 | <div class="cat_bar"> |
||
703 | <h3 class="catbg">', $txt['package_upload_title'], '</h3> |
||
704 | </div> |
||
705 | <div class="windowbg"> |
||
706 | <form action="', $scripturl, '?action=admin;area=packages;get;sa=upload" method="post" accept-charset="', $context['character_set'], '" enctype="multipart/form-data"> |
||
707 | <dl class="settings"> |
||
708 | <dt> |
||
709 | <strong>', $txt['package_upload_select'], ':</strong> |
||
710 | </dt> |
||
711 | <dd> |
||
712 | <input type="file" name="package" size="38"> |
||
713 | </dd> |
||
714 | </dl> |
||
715 | <input type="submit" value="', $txt['upload'], '" class="button"> |
||
716 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
717 | </form> |
||
718 | </div> |
||
719 | <div class="cat_bar"> |
||
720 | <h3 class="catbg"> |
||
721 | <a class="download_new_package"> |
||
722 | <span class="toggle_down floatright" alt="*" title="', $txt['show'], '"></span> |
||
723 | ', $txt['download_new_package'], ' |
||
724 | </a> |
||
725 | </h3> |
||
726 | </div> |
||
727 | <div class="new_package_content">'; |
||
728 | |||
729 | if ($context['package_download_broken']) |
||
730 | { |
||
731 | echo ' |
||
732 | <div class="cat_bar"> |
||
733 | <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3> |
||
734 | </div> |
||
735 | <div class="windowbg"> |
||
736 | <p> |
||
737 | ', $txt['package_ftp_why_download'], ' |
||
738 | </p> |
||
739 | <form action="', $scripturl, '?action=admin;area=packages;get" method="post" accept-charset="', $context['character_set'], '"> |
||
740 | <dl class="settings"> |
||
741 | <dt> |
||
742 | <label for="ftp_server">', $txt['package_ftp_server'], ':</label> |
||
743 | </dt> |
||
744 | <dd> |
||
745 | <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '"> |
||
746 | <label for="ftp_port">', $txt['package_ftp_port'], ':</label> |
||
747 | <input type="text" size="3" name="ftp_port" id="ftp_port" value="', $context['package_ftp']['port'], '"> |
||
748 | </dd> |
||
749 | <dt> |
||
750 | <label for="ftp_username">', $txt['package_ftp_username'], ':</label> |
||
751 | </dt> |
||
752 | <dd> |
||
753 | <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '"> |
||
754 | </dd> |
||
755 | <dt> |
||
756 | <label for="ftp_password">', $txt['package_ftp_password'], ':</label> |
||
757 | </dt> |
||
758 | <dd> |
||
759 | <input type="password" size="50" name="ftp_password" id="ftp_password"> |
||
760 | </dd> |
||
761 | <dt> |
||
762 | <label for="ftp_path">', $txt['package_ftp_path'], ':</label> |
||
763 | </dt> |
||
764 | <dd> |
||
765 | <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '"> |
||
766 | </dd> |
||
767 | </dl> |
||
768 | <div class="righttext"> |
||
769 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
||
770 | </div> |
||
771 | </form> |
||
772 | </div><!-- .windowbg -->'; |
||
773 | } |
||
774 | |||
775 | echo ' |
||
776 | <div class="windowbg"> |
||
777 | <fieldset> |
||
778 | <legend>' . $txt['package_servers'] . '</legend> |
||
779 | <ul class="package_servers">'; |
||
780 | |||
781 | foreach ($context['servers'] as $server) |
||
782 | echo ' |
||
783 | <li class="flow_auto"> |
||
784 | <span class="floatleft">' . $server['name'] . '</span> |
||
785 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=remove;server=' . $server['id'] . ';', $context['session_var'], '=', $context['session_id'], '">[ ' . $txt['delete'] . ' ]</a></span> |
||
786 | <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span> |
||
787 | </li>'; |
||
788 | echo ' |
||
789 | </ul> |
||
790 | </fieldset> |
||
791 | <fieldset> |
||
792 | <legend>' . $txt['add_server'] . '</legend> |
||
793 | <form action="' . $scripturl . '?action=admin;area=packages;get;sa=add" method="post" accept-charset="', $context['character_set'], '"> |
||
794 | <dl class="settings"> |
||
795 | <dt> |
||
796 | <strong>' . $txt['server_name'] . ':</strong> |
||
797 | </dt> |
||
798 | <dd> |
||
799 | <input type="text" name="servername" size="44" value="SMF"> |
||
800 | </dd> |
||
801 | <dt> |
||
802 | <strong>' . $txt['serverurl'] . ':</strong> |
||
803 | </dt> |
||
804 | <dd> |
||
805 | <input type="text" name="serverurl" size="44" value="https://"> |
||
806 | </dd> |
||
807 | </dl> |
||
808 | <div class="righttext"> |
||
809 | <input type="submit" value="' . $txt['add_server'] . '" class="button"> |
||
810 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
||
811 | </div> |
||
812 | </form> |
||
813 | </fieldset> |
||
814 | <fieldset> |
||
815 | <legend>', $txt['package_download_by_url'], '</legend> |
||
816 | <form action="', $scripturl, '?action=admin;area=packages;get;sa=download;byurl;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '"> |
||
817 | <dl class="settings"> |
||
818 | <dt> |
||
819 | <strong>' . $txt['serverurl'] . ':</strong> |
||
820 | </dt> |
||
821 | <dd> |
||
822 | <input type="text" name="package" size="44" value="https://"> |
||
823 | </dd> |
||
824 | <dt> |
||
825 | <strong>', $txt['package_download_filename'], ':</strong> |
||
826 | </dt> |
||
827 | <dd> |
||
828 | <input type="text" name="filename" size="44"><br> |
||
829 | <span class="smalltext">', $txt['package_download_filename_info'], '</span> |
||
830 | </dd> |
||
831 | </dl> |
||
832 | <input type="submit" value="', $txt['download'], '" class="button"> |
||
833 | </form> |
||
834 | </fieldset> |
||
835 | </div><!-- .windowbg --> |
||
836 | </div><!-- .new_package_content --> |
||
837 | </div><!-- #admin_form_wrapper -->'; |
||
838 | } |
||
839 | |||
840 | /** |
||
841 | * Confirm package operation |
||
842 | */ |
||
843 | function template_package_confirm() |
||
844 | { |
||
845 | global $context, $txt; |
||
846 | |||
847 | echo ' |
||
848 | <div class="cat_bar"> |
||
849 | <h3 class="catbg">', $context['page_title'], '</h3> |
||
850 | </div> |
||
851 | <div class="windowbg"> |
||
852 | <p>', $context['confirm_message'], '</p> |
||
853 | <a href="', $context['proceed_href'], '">[ ', $txt['package_confirm_proceed'], ' ]</a> <a href="JavaScript:history.go(-1);">[ ', $txt['package_confirm_go_back'], ' ]</a> |
||
854 | </div>'; |
||
855 | } |
||
856 | |||
857 | /** |
||
858 | * List packages. |
||
859 | */ |
||
860 | function template_package_list() |
||
861 | { |
||
862 | global $context, $txt, $smcFunc; |
||
863 | |||
864 | echo ' |
||
865 | <div class="cat_bar"> |
||
866 | <h3 class="catbg">', $context['page_title'], '</h3> |
||
867 | </div> |
||
868 | <div class="windowbg">'; |
||
869 | |||
870 | // No packages, as yet. |
||
871 | if (empty($context['package_list'])) |
||
872 | echo ' |
||
873 | <ul> |
||
874 | <li>', $txt['no_packages'], '</li> |
||
875 | </ul>'; |
||
876 | |||
877 | // List out the packages... |
||
878 | else |
||
879 | { |
||
880 | echo ' |
||
881 | <ul id="package_list">'; |
||
882 | |||
883 | foreach ($context['package_list'] as $i => $packageSection) |
||
884 | { |
||
885 | echo ' |
||
886 | <li> |
||
887 | <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>'; |
||
888 | |||
889 | if (!empty($packageSection['text'])) |
||
890 | echo ' |
||
891 | <div class="sub_bar"> |
||
892 | <h3 class="subbg">', $packageSection['text'], '</h3> |
||
893 | </div>'; |
||
894 | |||
895 | echo ' |
||
896 | <', $context['list_type'], ' id="package_section_', $i, '" class="packages">'; |
||
897 | |||
898 | foreach ($packageSection['items'] as $id => $package) |
||
899 | { |
||
900 | echo ' |
||
901 | <li>'; |
||
902 | |||
903 | // Textual message. Could be empty just for a blank line... |
||
904 | if ($package['is_text']) |
||
905 | echo ' |
||
906 | ', empty($package['name']) ? ' ' : $package['name']; |
||
907 | |||
908 | // This is supposed to be a rule.. |
||
909 | elseif ($package['is_line']) |
||
910 | echo ' |
||
911 | <hr>'; |
||
912 | |||
913 | // A remote link. |
||
914 | elseif ($package['is_remote']) |
||
915 | echo ' |
||
916 | <strong>', $package['link'], '</strong>'; |
||
917 | |||
918 | // A title? |
||
919 | elseif ($package['is_heading'] || $package['is_title']) |
||
920 | echo ' |
||
921 | <strong>', $package['name'], '</strong>'; |
||
922 | |||
923 | // Otherwise, it's a package. |
||
924 | else |
||
925 | { |
||
926 | // 1. Some mod [ Download ]. |
||
927 | echo ' |
||
928 | <strong><span id="ps_img_', $i, '_pkg_', $id, '" class="toggle_up" alt="*" style="display: none;"></span> ', $package['can_install'] || !empty($package['can_emulate_install']) ? '<strong>' . $package['name'] . '</strong> <a href="' . $package['download']['href'] . '">[ ' . $txt['download'] . ' ]</a>' : $package['name'], '</strong> |
||
929 | <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">'; |
||
930 | |||
931 | // Show the mod type? |
||
932 | if ($package['type'] != '') |
||
933 | echo ' |
||
934 | <li class="package_section"> |
||
935 | ', $txt['package_type'], ': ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), ' |
||
936 | </li>'; |
||
937 | |||
938 | // Show the version number? |
||
939 | if ($package['version'] != '') |
||
940 | echo ' |
||
941 | <li class="package_section"> |
||
942 | ', $txt['mod_version'], ': ', $package['version'], ' |
||
943 | </li>'; |
||
944 | |||
945 | // How 'bout the author? |
||
946 | if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) |
||
947 | echo ' |
||
948 | <li class="package_section"> |
||
949 | ', $txt['mod_author'], ': ', $package['author']['link'], ' |
||
950 | </li>'; |
||
951 | |||
952 | // The homepage... |
||
953 | if ($package['author']['website']['link'] != '') |
||
954 | echo ' |
||
955 | <li class="package_section"> |
||
956 | ', $txt['author_website'], ': ', $package['author']['website']['link'], ' |
||
957 | </li>'; |
||
958 | |||
959 | // Description: bleh bleh! |
||
960 | // Location of file: http://someplace/. |
||
961 | echo ' |
||
962 | <li class="package_section"> |
||
963 | ', $txt['file_location'], ': <a href="', $package['href'], '">', $package['href'], '</a> |
||
964 | </li> |
||
965 | <li class="package_section"> |
||
966 | <div class="information"> |
||
967 | ', $txt['package_description'], ': ', $package['description'], ' |
||
968 | </div> |
||
969 | </li> |
||
970 | </ul>'; |
||
971 | } |
||
972 | |||
973 | echo ' |
||
974 | </li>'; |
||
975 | } |
||
976 | echo ' |
||
977 | </', $context['list_type'], '> |
||
978 | </li>'; |
||
979 | } |
||
980 | echo ' |
||
981 | </ul>'; |
||
982 | } |
||
983 | |||
984 | echo ' |
||
985 | </div><!-- .windowbg -->'; |
||
986 | |||
987 | // Now go through and turn off all the sections. |
||
988 | if (!empty($context['package_list'])) |
||
989 | { |
||
990 | $section_count = count($context['package_list']); |
||
991 | |||
992 | echo ' |
||
993 | <script>'; |
||
994 | |||
995 | foreach ($context['package_list'] as $section => $ps) |
||
996 | { |
||
997 | echo ' |
||
998 | var oPackageServerToggle_', $section, ' = new smc_Toggle({ |
||
999 | bToggleEnabled: true, |
||
1000 | bCurrentlyCollapsed: ', count($ps['items']) == 1 || $section_count == 1 ? 'false' : 'true', ', |
||
1001 | aSwappableContainers: [ |
||
1002 | \'package_section_', $section, '\' |
||
1003 | ], |
||
1004 | aSwapImages: [ |
||
1005 | { |
||
1006 | sId: \'ps_img_', $section, '\', |
||
1007 | altExpanded: \'*\', |
||
1008 | altCollapsed: \'*\' |
||
1009 | } |
||
1010 | ] |
||
1011 | });'; |
||
1012 | |||
1013 | foreach ($ps['items'] as $id => $package) |
||
1014 | { |
||
1015 | if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote']) |
||
1016 | echo ' |
||
1017 | var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({ |
||
1018 | bToggleEnabled: true, |
||
1019 | bCurrentlyCollapsed: true, |
||
1020 | aSwappableContainers: [ |
||
1021 | \'package_section_', $section, '_pkg_', $id, '\' |
||
1022 | ], |
||
1023 | aSwapImages: [ |
||
1024 | { |
||
1025 | sId: \'ps_img_', $section, '_pkg_', $id, '\', |
||
1026 | altExpanded: \'*\', |
||
1027 | altCollapsed: \'*\' |
||
1028 | } |
||
1029 | ] |
||
1030 | });'; |
||
1031 | } |
||
1032 | } |
||
1033 | |||
1034 | echo ' |
||
1035 | </script>'; |
||
1036 | } |
||
1037 | } |
||
1038 | |||
1039 | /** |
||
1040 | * Confirmation page showing a package was uploaded/downloaded successfully. |
||
1041 | */ |
||
1042 | function template_downloaded() |
||
1043 | { |
||
1044 | global $context, $txt, $scripturl; |
||
1045 | |||
1046 | echo ' |
||
1047 | <div class="cat_bar"> |
||
1048 | <h3 class="catbg">', $context['page_title'], '</h3> |
||
1049 | </div> |
||
1050 | <div class="windowbg"> |
||
1051 | <p> |
||
1052 | ', (empty($context['package_server']) ? $txt['package_uploaded_successfully'] : $txt['package_downloaded_successfully']), ' |
||
1053 | </p> |
||
1054 | <ul> |
||
1055 | <li> |
||
1056 | <span class="floatleft"><strong>', $context['package']['name'], '</strong></span> |
||
1057 | <span class="package_server floatright">', $context['package']['list_files']['link'], '</span> |
||
1058 | <span class="package_server floatright">', $context['package']['install']['link'], '</span> |
||
1059 | </li> |
||
1060 | </ul> |
||
1061 | <br><br> |
||
1062 | <p><a href="', $scripturl, '?action=admin;area=packages;get', (isset($context['package_server']) ? ';sa=browse;server=' . $context['package_server'] : ''), '">[ ', $txt['back'], ' ]</a></p> |
||
1063 | </div>'; |
||
1064 | } |
||
1065 | |||
1066 | /** |
||
1067 | * Installation options - FTP info and backup settings |
||
1068 | */ |
||
1069 | function template_install_options() |
||
1070 | { |
||
1071 | global $context, $txt, $scripturl; |
||
1072 | |||
1073 | if (!empty($context['saved_successful'])) |
||
1074 | echo ' |
||
1075 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
||
1076 | |||
1077 | echo ' |
||
1078 | <div class="cat_bar"> |
||
1079 | <h3 class="catbg">', $txt['package_install_options'], '</h3> |
||
1080 | </div> |
||
1081 | <div class="information noup"> |
||
1082 | ', $txt['package_install_options_ftp_why'], ' |
||
1083 | </div> |
||
1084 | <div class="windowbg noup"> |
||
1085 | <form action="', $scripturl, '?action=admin;area=packages;sa=options" method="post" accept-charset="', $context['character_set'], '"> |
||
1086 | <dl class="settings"> |
||
1087 | <dt> |
||
1088 | <label for="pack_server"><strong>', $txt['package_install_options_ftp_server'], ':</strong></label> |
||
1089 | </dt> |
||
1090 | <dd> |
||
1091 | <input type="text" name="pack_server" id="pack_server" value="', $context['package_ftp_server'], '" size="30"> |
||
1092 | </dd> |
||
1093 | <dt> |
||
1094 | <label for="pack_port"><strong>', $txt['package_install_options_ftp_port'], ':</strong></label> |
||
1095 | </dt> |
||
1096 | <dd> |
||
1097 | <input type="text" name="pack_port" id="pack_port" size="3" value="', $context['package_ftp_port'], '"> |
||
1098 | </dd> |
||
1099 | <dt> |
||
1100 | <label for="pack_user"><strong>', $txt['package_install_options_ftp_user'], ':</strong></label> |
||
1101 | </dt> |
||
1102 | <dd> |
||
1103 | <input type="text" name="pack_user" id="pack_user" value="', $context['package_ftp_username'], '" size="30"> |
||
1104 | </dd> |
||
1105 | <dt> |
||
1106 | <label for="package_make_backups">', $txt['package_install_options_make_backups'], '</label> |
||
1107 | </dt> |
||
1108 | <dd> |
||
1109 | <input type="checkbox" name="package_make_backups" id="package_make_backups" value="1"', $context['package_make_backups'] ? ' checked' : '', '> |
||
1110 | </dd> |
||
1111 | <dt> |
||
1112 | <label for="package_make_full_backups">', $txt['package_install_options_make_full_backups'], '</label> |
||
1113 | </dt> |
||
1114 | <dd> |
||
1115 | <input type="checkbox" name="package_make_full_backups" id="package_make_full_backups" value="1"', $context['package_make_full_backups'] ? ' checked' : '', '> |
||
1116 | </dd> |
||
1117 | </dl> |
||
1118 | |||
1119 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
||
1120 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
1121 | </form> |
||
1122 | </div><!-- .windowbg -->'; |
||
1123 | } |
||
1124 | |||
1125 | /** |
||
1126 | * CHMOD control form |
||
1127 | * |
||
1128 | * @return bool False if nothing to do. |
||
1129 | */ |
||
1130 | function template_control_chmod() |
||
1131 | { |
||
1132 | global $context, $txt; |
||
1133 | |||
1134 | // Nothing to do? Brilliant! |
||
1135 | if (empty($context['package_ftp'])) |
||
1136 | return false; |
||
1137 | |||
1138 | if (empty($context['package_ftp']['form_elements_only'])) |
||
1139 | { |
||
1140 | echo ' |
||
1141 | ', sprintf($txt['package_ftp_why'], 'document.getElementById(\'need_writable_list\').style.display = \'\'; return false;'), '<br> |
||
1142 | <div id="need_writable_list" class="smalltext"> |
||
1143 | ', $txt['package_ftp_why_file_list'], ' |
||
1144 | <ul style="display: inline;">'; |
||
1145 | |||
1146 | if (!empty($context['notwritable_files'])) |
||
1147 | foreach ($context['notwritable_files'] as $file) |
||
1148 | echo ' |
||
1149 | <li>', $file, '</li>'; |
||
1150 | |||
1151 | echo ' |
||
1152 | </ul>'; |
||
1153 | |||
1154 | if (!$context['server']['is_windows']) |
||
1155 | echo ' |
||
1156 | <hr> |
||
1157 | ', $txt['package_chmod_linux'], '<br> |
||
1158 | <samp># chmod a+w ', implode(' ', $context['notwritable_files']), '</samp>'; |
||
1159 | |||
1160 | echo ' |
||
1161 | </div><!-- #need_writable_list -->'; |
||
1162 | } |
||
1163 | |||
1164 | echo ' |
||
1165 | <div class="bordercolor" id="ftp_error_div" style="', (!empty($context['package_ftp']['error']) ? '' : 'display:none;'), 'padding: 1px; margin: 1ex;"> |
||
1166 | <div class="windowbg" id="ftp_error_innerdiv" style="padding: 1ex;"> |
||
1167 | <samp id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</samp> |
||
1168 | </div> |
||
1169 | </div>'; |
||
1170 | |||
1171 | if (!empty($context['package_ftp']['destination'])) |
||
1172 | echo ' |
||
1173 | <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '">'; |
||
1174 | |||
1175 | echo ' |
||
1176 | <fieldset> |
||
1177 | <dl class="settings"> |
||
1178 | <dt> |
||
1179 | <label for="ftp_server">', $txt['package_ftp_server'], ':</label> |
||
1180 | </dt> |
||
1181 | <dd> |
||
1182 | <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '"> |
||
1183 | <label for="ftp_port">', $txt['package_ftp_port'], ':</label> |
||
1184 | <input type="text" size="3" name="ftp_port" id="ftp_port" value="', $context['package_ftp']['port'], '"> |
||
1185 | </dd> |
||
1186 | <dt> |
||
1187 | <label for="ftp_username">', $txt['package_ftp_username'], ':</label> |
||
1188 | </dt> |
||
1189 | <dd> |
||
1190 | <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '"> |
||
1191 | </dd> |
||
1192 | <dt> |
||
1193 | <label for="ftp_password">', $txt['package_ftp_password'], ':</label> |
||
1194 | </dt> |
||
1195 | <dd> |
||
1196 | <input type="password" size="50" name="ftp_password" id="ftp_password"> |
||
1197 | </dd> |
||
1198 | <dt> |
||
1199 | <label for="ftp_path">', $txt['package_ftp_path'], ':</label> |
||
1200 | </dt> |
||
1201 | <dd> |
||
1202 | <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '"> |
||
1203 | </dd> |
||
1204 | </dl> |
||
1205 | </fieldset>'; |
||
1206 | |||
1207 | if (empty($context['package_ftp']['form_elements_only'])) |
||
1208 | echo ' |
||
1209 | <div class="righttext" style="margin: 1ex;"> |
||
1210 | <span id="test_ftp_placeholder_full"></span> |
||
1211 | <input type="submit" value="', $txt['package_proceed'], '" class="button"> |
||
1212 | </div>'; |
||
1213 | |||
1214 | if (!empty($context['package_ftp']['destination'])) |
||
1215 | echo ' |
||
1216 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
||
1217 | </form>'; |
||
1218 | |||
1219 | // Hide the details of the list. |
||
1220 | if (empty($context['package_ftp']['form_elements_only'])) |
||
1221 | echo ' |
||
1222 | <script> |
||
1223 | document.getElementById(\'need_writable_list\').style.display = \'none\'; |
||
1224 | </script>'; |
||
1225 | |||
1226 | // Quick generate the test button. |
||
1227 | echo ' |
||
1228 | <script> |
||
1229 | // Generate a "test ftp" button. |
||
1230 | var generatedButton = false; |
||
1231 | function generateFTPTest() |
||
1232 | { |
||
1233 | // Don\'t ever call this twice! |
||
1234 | if (generatedButton) |
||
1235 | return false; |
||
1236 | generatedButton = true; |
||
1237 | |||
1238 | // No XML? |
||
1239 | if (!window.XMLHttpRequest || (!document.getElementById("test_ftp_placeholder") && !document.getElementById("test_ftp_placeholder_full"))) |
||
1240 | return false; |
||
1241 | |||
1242 | var ftpTest = document.createElement("input"); |
||
1243 | ftpTest.type = "button"; |
||
1244 | ftpTest.onclick = testFTP; |
||
1245 | |||
1246 | if (document.getElementById("test_ftp_placeholder")) |
||
1247 | { |
||
1248 | ftpTest.value = "', $txt['package_ftp_test'], '"; |
||
1249 | document.getElementById("test_ftp_placeholder").appendChild(ftpTest); |
||
1250 | } |
||
1251 | else |
||
1252 | { |
||
1253 | ftpTest.value = "', $txt['package_ftp_test_connection'], '"; |
||
1254 | document.getElementById("test_ftp_placeholder_full").appendChild(ftpTest); |
||
1255 | } |
||
1256 | } |
||
1257 | function testFTPResults(oXMLDoc) |
||
1258 | { |
||
1259 | ajax_indicator(false); |
||
1260 | |||
1261 | // This assumes it went wrong! |
||
1262 | var wasSuccess = false; |
||
1263 | var message = "', addcslashes($txt['package_ftp_test_failed'], "'"), '"; |
||
1264 | |||
1265 | var results = oXMLDoc.getElementsByTagName(\'results\')[0].getElementsByTagName(\'result\'); |
||
1266 | if (results.length > 0) |
||
1267 | { |
||
1268 | if (results[0].getAttribute(\'success\') == 1) |
||
1269 | wasSuccess = true; |
||
1270 | message = results[0].firstChild.nodeValue; |
||
1271 | } |
||
1272 | |||
1273 | document.getElementById("ftp_error_div").style.display = ""; |
||
1274 | document.getElementById("ftp_error_div").style.backgroundColor = wasSuccess ? "green" : "red"; |
||
1275 | document.getElementById("ftp_error_innerdiv").style.backgroundColor = wasSuccess ? "#DBFDC7" : "#FDBDBD"; |
||
1276 | |||
1277 | setInnerHTML(document.getElementById("ftp_error_message"), message); |
||
1278 | } |
||
1279 | generateFTPTest(); |
||
1280 | </script>'; |
||
1281 | |||
1282 | // Make sure the button gets generated last. |
||
1283 | $context['insert_after_template'] .= ' |
||
1284 | <script> |
||
1285 | generateFTPTest(); |
||
1286 | </script>'; |
||
1287 | } |
||
1288 | |||
1289 | /** |
||
1290 | * Wrapper for the above template function showing that FTP is required |
||
1291 | */ |
||
1292 | function template_ftp_required() |
||
1293 | { |
||
1294 | global $txt; |
||
1295 | |||
1296 | echo ' |
||
1297 | <fieldset> |
||
1298 | <legend> |
||
1299 | ', $txt['package_ftp_necessary'], ' |
||
1300 | </legend> |
||
1301 | <div class="ftp_details"> |
||
1302 | ', template_control_chmod(), ' |
||
1303 | </div> |
||
1304 | </fieldset>'; |
||
1305 | } |
||
1306 | |||
1307 | /** |
||
1308 | * View operation details. |
||
1309 | */ |
||
1310 | function template_view_operations() |
||
1311 | { |
||
1312 | global $context, $txt, $settings, $modSettings; |
||
1313 | |||
1314 | echo '<!DOCTYPE html> |
||
1315 | <html', $context['right_to_left'] ? ' dir="rtl"' : '', '> |
||
1316 | <head> |
||
1317 | <meta charset="', $context['character_set'], '"> |
||
1318 | <title>', $txt['operation_title'], '</title> |
||
1319 | ', template_css(); |
||
0 ignored issues
–
show
|
|||
1320 | |||
1321 | template_javascript(); |
||
1322 | |||
1323 | echo ' |
||
1324 | </head> |
||
1325 | <body> |
||
1326 | <div class="padding windowbg"> |
||
1327 | <div class="padding"> |
||
1328 | ', $context['operations']['search'], ' |
||
1329 | </div> |
||
1330 | <div class="padding"> |
||
1331 | ', $context['operations']['replace'], ' |
||
1332 | </div> |
||
1333 | </div> |
||
1334 | </body> |
||
1335 | </html>'; |
||
1336 | } |
||
1337 | |||
1338 | /** |
||
1339 | * The file permissions page. |
||
1340 | */ |
||
1341 | function template_file_permissions() |
||
1342 | { |
||
1343 | global $txt, $scripturl, $context; |
||
1344 | |||
1345 | // This will handle expanding the selection. |
||
1346 | echo ' |
||
1347 | <script> |
||
1348 | var oRadioValues = { |
||
1349 | 0: "read", |
||
1350 | 1: "writable", |
||
1351 | 2: "execute", |
||
1352 | 3: "custom", |
||
1353 | 4: "no_change" |
||
1354 | } |
||
1355 | function dynamicAddMore() |
||
1356 | { |
||
1357 | ajax_indicator(true); |
||
1358 | |||
1359 | getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=admin;area=packages;fileoffset=\' + (parseInt(this.offset) + ', $context['file_limit'], ') + \';onlyfind=\' + escape(this.path) + \';sa=perms;xml;', $context['session_var'], '=', $context['session_id'], '\', onNewFolderReceived); |
||
1360 | } |
||
1361 | |||
1362 | // Getting something back? |
||
1363 | function onNewFolderReceived(oXMLDoc) |
||
1364 | { |
||
1365 | ajax_indicator(false); |
||
1366 | |||
1367 | var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\'); |
||
1368 | |||
1369 | // No folders, no longer worth going further. |
||
1370 | if (fileItems.length < 1) |
||
1371 | { |
||
1372 | if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0]) |
||
1373 | { |
||
1374 | var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue; |
||
1375 | var itemLink = document.getElementById(\'link_\' + rootName); |
||
1376 | |||
1377 | // Move the children up. |
||
1378 | for (i = 0; i <= itemLink.childNodes.length; i++) |
||
1379 | itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink); |
||
1380 | |||
1381 | // And remove the link. |
||
1382 | itemLink.parentNode.removeChild(itemLink); |
||
1383 | } |
||
1384 | return false; |
||
1385 | } |
||
1386 | var tableHandle = false; |
||
1387 | var isMore = false; |
||
1388 | var ident = ""; |
||
1389 | var my_ident = ""; |
||
1390 | var curLevel = 0; |
||
1391 | |||
1392 | for (var i = 0; i < fileItems.length; i++) |
||
1393 | { |
||
1394 | if (fileItems[i].getAttribute(\'more\') == 1) |
||
1395 | { |
||
1396 | isMore = true; |
||
1397 | var curOffset = fileItems[i].getAttribute(\'offset\'); |
||
1398 | } |
||
1399 | |||
1400 | if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'))) |
||
1401 | { |
||
1402 | ident = fileItems[i].getAttribute(\'ident\'); |
||
1403 | my_ident = fileItems[i].getAttribute(\'my_ident\'); |
||
1404 | curLevel = fileItems[i].getAttribute(\'level\') * 5; |
||
1405 | curPath = fileItems[i].getAttribute(\'path\'); |
||
1406 | |||
1407 | // Get where we\'re putting it next to. |
||
1408 | tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')); |
||
1409 | |||
1410 | var curRow = document.createElement("tr"); |
||
1411 | curRow.className = "windowbg"; |
||
1412 | curRow.id = "content_" + my_ident; |
||
1413 | curRow.style.display = ""; |
||
1414 | var curCol = document.createElement("td"); |
||
1415 | curCol.className = "smalltext"; |
||
1416 | curCol.width = "40%"; |
||
1417 | |||
1418 | // This is the name. |
||
1419 | var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue); |
||
1420 | |||
1421 | // Start by wacking in the spaces. |
||
1422 | setInnerHTML(curCol, repeatString(" ", curLevel)); |
||
1423 | |||
1424 | // Create the actual text. |
||
1425 | if (fileItems[i].getAttribute(\'folder\') == 1) |
||
1426 | { |
||
1427 | var linkData = document.createElement("a"); |
||
1428 | linkData.name = "fol_" + my_ident; |
||
1429 | linkData.id = "link_" + my_ident; |
||
1430 | linkData.href = \'#\'; |
||
1431 | linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue; |
||
1432 | linkData.ident = my_ident; |
||
1433 | linkData.onclick = dynamicExpandFolder; |
||
1434 | |||
1435 | var folderImage = document.createElement("span"); |
||
1436 | folderImage.className = "main_icons folder"; |
||
1437 | linkData.appendChild(folderImage); |
||
1438 | |||
1439 | linkData.appendChild(fileName); |
||
1440 | curCol.appendChild(linkData); |
||
1441 | } |
||
1442 | else |
||
1443 | curCol.appendChild(fileName); |
||
1444 | |||
1445 | curRow.appendChild(curCol); |
||
1446 | |||
1447 | // Right, the permissions. |
||
1448 | curCol = document.createElement("td"); |
||
1449 | curCol.className = "smalltext"; |
||
1450 | |||
1451 | var writeSpan = document.createElement("span"); |
||
1452 | writeSpan.className = fileItems[i].getAttribute(\'writable\') ? "green" : "red"; |
||
1453 | setInnerHTML(writeSpan, fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\'); |
||
1454 | curCol.appendChild(writeSpan); |
||
1455 | |||
1456 | if (fileItems[i].getAttribute(\'permissions\')) |
||
1457 | { |
||
1458 | var permData = document.createTextNode("\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")"); |
||
1459 | curCol.appendChild(permData); |
||
1460 | } |
||
1461 | |||
1462 | curRow.appendChild(curCol); |
||
1463 | |||
1464 | // Now add the five radio buttons. |
||
1465 | for (j = 0; j < 5; j++) |
||
1466 | { |
||
1467 | curCol = document.createElement("td"); |
||
1468 | curCol.className = "centertext perm_" + oRadioValues[j]; |
||
1469 | curCol.align = "center"; |
||
1470 | |||
1471 | var curInput = createNamedElement("input", "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]", j == 4 ? "checked" : ""); |
||
1472 | curInput.type = "radio"; |
||
1473 | curInput.checked = "checked"; |
||
1474 | curInput.value = oRadioValues[j]; |
||
1475 | |||
1476 | curCol.appendChild(curInput); |
||
1477 | curRow.appendChild(curCol); |
||
1478 | } |
||
1479 | |||
1480 | // Put the row in. |
||
1481 | tableHandle.parentNode.insertBefore(curRow, tableHandle); |
||
1482 | |||
1483 | // Put in a new dummy section? |
||
1484 | if (fileItems[i].getAttribute(\'folder\') == 1) |
||
1485 | { |
||
1486 | var newRow = document.createElement("tr"); |
||
1487 | newRow.id = "insert_div_loc_" + my_ident; |
||
1488 | newRow.style.display = "none"; |
||
1489 | tableHandle.parentNode.insertBefore(newRow, tableHandle); |
||
1490 | var newCol = document.createElement("td"); |
||
1491 | newCol.colspan = 2; |
||
1492 | newRow.appendChild(newCol); |
||
1493 | } |
||
1494 | } |
||
1495 | } |
||
1496 | |||
1497 | // Is there some more to remove? |
||
1498 | if (document.getElementById("content_" + ident + "_more")) |
||
1499 | { |
||
1500 | document.getElementById("content_" + ident + "_more").parentNode.removeChild(document.getElementById("content_" + ident + "_more")); |
||
1501 | } |
||
1502 | |||
1503 | // Add more? |
||
1504 | if (isMore && tableHandle) |
||
1505 | { |
||
1506 | // Create the actual link. |
||
1507 | var linkData = document.createElement("a"); |
||
1508 | linkData.href = \'#fol_\' + my_ident; |
||
1509 | linkData.path = curPath; |
||
1510 | linkData.offset = curOffset; |
||
1511 | linkData.onclick = dynamicAddMore; |
||
1512 | |||
1513 | linkData.appendChild(document.createTextNode(\'', $txt['package_file_perms_more_files'], '\')); |
||
1514 | |||
1515 | curRow = document.createElement("tr"); |
||
1516 | curRow.className = "windowbg"; |
||
1517 | curRow.id = "content_" + ident + "_more"; |
||
1518 | tableHandle.parentNode.insertBefore(curRow, tableHandle); |
||
1519 | curCol = document.createElement("td"); |
||
1520 | curCol.className = "smalltext"; |
||
1521 | curCol.width = "40%"; |
||
1522 | |||
1523 | setInnerHTML(curCol, repeatString(" ", curLevel)); |
||
1524 | curCol.appendChild(document.createTextNode(\'\\u00ab \')); |
||
1525 | curCol.appendChild(linkData); |
||
1526 | curCol.appendChild(document.createTextNode(\' \\u00bb\')); |
||
1527 | |||
1528 | curRow.appendChild(curCol); |
||
1529 | curCol = document.createElement("td"); |
||
1530 | curCol.className = "smalltext"; |
||
1531 | curRow.appendChild(curCol); |
||
1532 | } |
||
1533 | |||
1534 | // Keep track of it. |
||
1535 | var curInput = createNamedElement("input", "back_look[]"); |
||
1536 | curInput.type = "hidden"; |
||
1537 | curInput.value = curPath; |
||
1538 | |||
1539 | curCol.appendChild(curInput); |
||
1540 | } |
||
1541 | </script>'; |
||
1542 | |||
1543 | echo ' |
||
1544 | <div class="noticebox"> |
||
1545 | <div> |
||
1546 | <strong>', $txt['package_file_perms_warning'], ':</strong> |
||
1547 | <div class="smalltext"> |
||
1548 | <ol style="margin-top: 2px; margin-bottom: 2px"> |
||
1549 | ', $txt['package_file_perms_warning_desc'], ' |
||
1550 | </ol> |
||
1551 | </div> |
||
1552 | </div> |
||
1553 | </div> |
||
1554 | |||
1555 | <form action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '"> |
||
1556 | <div class="cat_bar"> |
||
1557 | <h3 class="catbg"> |
||
1558 | <span class="floatleft">', $txt['package_file_perms'], '</span><span class="perms_status floatright">', $txt['package_file_perms_new_status'], '</span> |
||
1559 | </h3> |
||
1560 | </div> |
||
1561 | <table class="table_grid"> |
||
1562 | <thead> |
||
1563 | <tr class="title_bar"> |
||
1564 | <th class="lefttext" width="30%">', $txt['package_file_perms_name'], '</th> |
||
1565 | <th width="30%" class="lefttext">', $txt['package_file_perms_status'], '</th> |
||
1566 | <th width="8%"><span class="file_permissions">', $txt['package_file_perms_status_read'], '</span></th> |
||
1567 | <th width="8%"><span class="file_permissions">', $txt['package_file_perms_status_write'], '</span></th> |
||
1568 | <th width="8%"><span class="file_permissions">', $txt['package_file_perms_status_execute'], '</span></th> |
||
1569 | <th width="8%"><span class="file_permissions">', $txt['package_file_perms_status_custom'], '</span></th> |
||
1570 | <th width="8%"><span class="file_permissions">', $txt['package_file_perms_status_no_change'], '</span></th> |
||
1571 | </tr> |
||
1572 | </thead> |
||
1573 | <tbody>'; |
||
1574 | |||
1575 | foreach ($context['file_tree'] as $name => $dir) |
||
1576 | { |
||
1577 | echo ' |
||
1578 | <tr class="windowbg"> |
||
1579 | <td width="30%"> |
||
1580 | <strong>'; |
||
1581 | |||
1582 | if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
||
1583 | echo ' |
||
1584 | <span class="main_icons folder"></span>'; |
||
1585 | |||
1586 | echo ' |
||
1587 | ', $name, ' |
||
1588 | </strong> |
||
1589 | </td> |
||
1590 | <td width="30%"> |
||
1591 | <span style="color: ', ($dir['perms']['chmod'] ? 'green' : 'red'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span> |
||
1592 | ', ($dir['perms']['perms'] ? ' (' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), ' |
||
1593 | </td> |
||
1594 | <td class="centertext perm_read"> |
||
1595 | <input type="radio" name="permStatus[', $name, ']" value="read" class="centertext"> |
||
1596 | </td> |
||
1597 | <td class="centertext perm_writable"> |
||
1598 | <input type="radio" name="permStatus[', $name, ']" value="writable" class="centertext"> |
||
1599 | </td> |
||
1600 | <td class="centertext perm_execute"> |
||
1601 | <input type="radio" name="permStatus[', $name, ']" value="execute" class="centertext"> |
||
1602 | </td> |
||
1603 | <td class="centertext perm_custom"> |
||
1604 | <input type="radio" name="permStatus[', $name, ']" value="custom" class="centertext"> |
||
1605 | </td> |
||
1606 | <td class="centertext perm_no_change"> |
||
1607 | <input type="radio" name="permStatus[', $name, ']" value="no_change" checked class="centertext"> |
||
1608 | </td> |
||
1609 | </tr>'; |
||
1610 | |||
1611 | if (!empty($dir['contents'])) |
||
1612 | template_permission_show_contents($name, $dir['contents'], 1); |
||
1613 | } |
||
1614 | |||
1615 | echo ' |
||
1616 | </tbody> |
||
1617 | </table> |
||
1618 | <br> |
||
1619 | <div class="cat_bar"> |
||
1620 | <h3 class="catbg">', $txt['package_file_perms_change'], '</h3> |
||
1621 | </div> |
||
1622 | <div class="windowbg"> |
||
1623 | <fieldset> |
||
1624 | <dl> |
||
1625 | <dt> |
||
1626 | <input type="radio" name="method" value="individual" checked id="method_individual"> |
||
1627 | <label for="method_individual"><strong>', $txt['package_file_perms_apply'], '</strong></label> |
||
1628 | </dt> |
||
1629 | <dd> |
||
1630 | <em class="smalltext">', $txt['package_file_perms_custom'], ': <input type="text" name="custom_value" value="0755" maxlength="4" size="5"> <a href="', $scripturl, '?action=helpadmin;help=chmod_flags" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></em> |
||
1631 | </dd> |
||
1632 | <dt> |
||
1633 | <input type="radio" name="method" value="predefined" id="method_predefined"> |
||
1634 | <label for="method_predefined"><strong>', $txt['package_file_perms_predefined'], ':</strong></label> |
||
1635 | <select name="predefined" onchange="document.getElementById(\'method_predefined\').checked = \'checked\';"> |
||
1636 | <option value="restricted" selected>', $txt['package_file_perms_pre_restricted'], '</option> |
||
1637 | <option value="standard">', $txt['package_file_perms_pre_standard'], '</option> |
||
1638 | <option value="free">', $txt['package_file_perms_pre_free'], '</option> |
||
1639 | </select> |
||
1640 | </dt> |
||
1641 | <dd> |
||
1642 | <em class="smalltext">', $txt['package_file_perms_predefined_note'], '</em> |
||
1643 | </dd> |
||
1644 | </dl> |
||
1645 | </fieldset>'; |
||
1646 | |||
1647 | // Likely to need FTP? |
||
1648 | if (empty($context['ftp_connected'])) |
||
1649 | echo ' |
||
1650 | <p> |
||
1651 | ', $txt['package_file_perms_ftp_details'], ': |
||
1652 | </p> |
||
1653 | ', template_control_chmod(), ' |
||
1654 | <div class="noticebox">', $txt['package_file_perms_ftp_retain'], '</div>'; |
||
1655 | |||
1656 | echo ' |
||
1657 | <span id="test_ftp_placeholder_full"></span> |
||
1658 | <input type="hidden" name="action_changes" value="1"> |
||
1659 | <input type="submit" value="', $txt['package_file_perms_go'], '" name="go" class="button"> |
||
1660 | </div><!-- .windowbg -->'; |
||
1661 | |||
1662 | // Any looks fors we've already done? |
||
1663 | foreach ($context['look_for'] as $path) |
||
1664 | echo ' |
||
1665 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
||
1666 | |||
1667 | echo ' |
||
1668 | </form> |
||
1669 | <br>'; |
||
1670 | } |
||
1671 | |||
1672 | /** |
||
1673 | * Shows permissions for items within a directory (called from template_file_permissions) |
||
1674 | * |
||
1675 | * @param string $ident A unique ID - typically the directory name |
||
1676 | * @param array $contents An array of items within the directory |
||
1677 | * @param int $level How far to go inside the directory |
||
1678 | * @param bool $has_more Whether there are more files to display besides what's in $contents |
||
1679 | */ |
||
1680 | function template_permission_show_contents($ident, $contents, $level, $has_more = false) |
||
1681 | { |
||
1682 | global $txt, $scripturl, $context; |
||
1683 | $js_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident); |
||
1684 | |||
1685 | // Have we actually done something? |
||
1686 | $drawn_div = false; |
||
1687 | |||
1688 | foreach ($contents as $name => $dir) |
||
1689 | { |
||
1690 | if (isset($dir['perms'])) |
||
1691 | { |
||
1692 | if (!$drawn_div) |
||
1693 | { |
||
1694 | $drawn_div = true; |
||
1695 | echo ' |
||
1696 | </tbody> |
||
1697 | <tbody class="table_grid" id="', $js_ident, '">'; |
||
1698 | } |
||
1699 | |||
1700 | $cur_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident . '/' . $name); |
||
1701 | |||
1702 | echo ' |
||
1703 | <tr class="windowbg" id="content_', $cur_ident, '"> |
||
1704 | <td class="smalltext" width="30%">' . str_repeat(' ', $level * 5), ' |
||
1705 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '<a id="link_' . $cur_ident . '" href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident . '/' . $name) . ';back_look=' . $context['back_look_data'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . $cur_ident . '" onclick="return expandFolder(\'' . $cur_ident . '\', \'' . addcslashes($ident . '/' . $name, "'\\") . '\');">' : ''; |
||
1706 | |||
1707 | if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive')) |
||
1708 | echo ' |
||
1709 | <span class="main_icons folder"></span>'; |
||
1710 | |||
1711 | echo ' |
||
1712 | ', $name, ' |
||
1713 | ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '</a>' : '', ' |
||
1714 | </td> |
||
1715 | <td class="smalltext"> |
||
1716 | <span class="', ($dir['perms']['chmod'] ? 'success' : 'error'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span> |
||
1717 | ', ($dir['perms']['perms'] ? ' (' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), ' |
||
1718 | </td> |
||
1719 | <td class="centertext perm_read"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="read"></td> |
||
1720 | <td class="centertext perm_writable"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="writable"></td> |
||
1721 | <td class="centertext perm_execute"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="execute"></td> |
||
1722 | <td class="centertext perm_custom"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="custom"></td> |
||
1723 | <td class="centertext perm_no_change"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="no_change" checked></td> |
||
1724 | </tr> |
||
1725 | <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>'; |
||
1726 | |||
1727 | if (!empty($dir['contents'])) |
||
1728 | template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files'])); |
||
1729 | } |
||
1730 | } |
||
1731 | |||
1732 | // We have more files to show? |
||
1733 | if ($has_more) |
||
1734 | echo ' |
||
1735 | <tr class="windowbg" id="content_', $js_ident, '_more"> |
||
1736 | <td class="smalltext" width="40%">' . str_repeat(' ', $level * 5), ' |
||
1737 | <a href="' . $scripturl . '?action=admin;area=packages;sa=perms;find=' . base64_encode($ident) . ';fileoffset=', ($context['file_offset'] + $context['file_limit']), ';' . $context['session_var'] . '=' . $context['session_id'] . '#fol_' . preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident) . '">', $txt['package_file_perms_more_files'], '</a> |
||
1738 | </td> |
||
1739 | <td colspan="6"></td> |
||
1740 | </tr>'; |
||
1741 | |||
1742 | if ($drawn_div) |
||
1743 | { |
||
1744 | // Hide anything too far down the tree. |
||
1745 | $isFound = false; |
||
1746 | foreach ($context['look_for'] as $tree) |
||
1747 | if (substr($tree, 0, strlen($ident)) == $ident) |
||
1748 | $isFound = true; |
||
1749 | |||
1750 | if ($level > 1 && !$isFound) |
||
1751 | echo ' |
||
1752 | <script> |
||
1753 | expandFolder(\'', $js_ident, '\', \'\'); |
||
1754 | </script>'; |
||
1755 | } |
||
1756 | } |
||
1757 | |||
1758 | /** |
||
1759 | * A progress page showing what permissions changes are being applied |
||
1760 | */ |
||
1761 | function template_action_permissions() |
||
1762 | { |
||
1763 | global $txt, $scripturl, $context; |
||
1764 | |||
1765 | $countDown = 3; |
||
1766 | |||
1767 | echo ' |
||
1768 | <form action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" id="perm_submit" method="post" accept-charset="', $context['character_set'], '"> |
||
1769 | <div class="cat_bar"> |
||
1770 | <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3> |
||
1771 | </div>'; |
||
1772 | |||
1773 | if (!empty($context['skip_ftp'])) |
||
1774 | echo ' |
||
1775 | <div class="errorbox"> |
||
1776 | ', $txt['package_file_perms_skipping_ftp'], ' |
||
1777 | </div>'; |
||
1778 | |||
1779 | // How many have we done? |
||
1780 | $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']); |
||
1781 | $progress_message = sprintf($context['method'] == 'individual' ? $txt['package_file_perms_items_done'] : $txt['package_file_perms_dirs_done'], $context['total_items'] - $remaining_items, $context['total_items']); |
||
1782 | $progress_percent = round(($context['total_items'] - $remaining_items) / $context['total_items'] * 100, 1); |
||
1783 | |||
1784 | echo ' |
||
1785 | <div class="windowbg"> |
||
1786 | <div> |
||
1787 | <strong>', $progress_message, '</strong><br> |
||
1788 | <div class="progress_bar progress_blue"> |
||
1789 | <span>', $progress_percent, '%</span> |
||
1790 | <div class="bar" style="width: ', $progress_percent, '%;"></div> |
||
1791 | </div> |
||
1792 | </div>'; |
||
1793 | |||
1794 | // Second progress bar for a specific directory? |
||
1795 | if ($context['method'] != 'individual' && !empty($context['total_files'])) |
||
1796 | { |
||
1797 | $file_progress_message = sprintf($txt['package_file_perms_files_done'], $context['file_offset'], $context['total_files']); |
||
1798 | $file_progress_percent = round($context['file_offset'] / $context['total_files'] * 100, 1); |
||
1799 | |||
1800 | echo ' |
||
1801 | <br> |
||
1802 | <div> |
||
1803 | <strong>', $file_progress_message, '</strong><br> |
||
1804 | <div class="progress_bar"> |
||
1805 | <span>', $file_progress_percent, '%</span> |
||
1806 | <div class="bar" style="width: ', $file_progress_percent, '%;"></div> |
||
1807 | </div> |
||
1808 | </div>'; |
||
1809 | } |
||
1810 | |||
1811 | echo ' |
||
1812 | <br>'; |
||
1813 | |||
1814 | // Put out the right hidden data. |
||
1815 | if ($context['method'] == 'individual') |
||
1816 | echo ' |
||
1817 | <input type="hidden" name="custom_value" value="', $context['custom_value'], '"> |
||
1818 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
||
1819 | <input type="hidden" name="toProcess" value="', $context['to_process_encode'], '">'; |
||
1820 | else |
||
1821 | echo ' |
||
1822 | <input type="hidden" name="predefined" value="', $context['predefined_type'], '"> |
||
1823 | <input type="hidden" name="fileOffset" value="', $context['file_offset'], '"> |
||
1824 | <input type="hidden" name="totalItems" value="', $context['total_items'], '"> |
||
1825 | <input type="hidden" name="dirList" value="', $context['directory_list_encode'], '"> |
||
1826 | <input type="hidden" name="specialFiles" value="', $context['special_files_encode'], '">'; |
||
1827 | |||
1828 | // Are we not using FTP for whatever reason. |
||
1829 | if (!empty($context['skip_ftp'])) |
||
1830 | echo ' |
||
1831 | <input type="hidden" name="skip_ftp" value="1">'; |
||
1832 | |||
1833 | // Retain state. |
||
1834 | foreach ($context['back_look_data'] as $path) |
||
1835 | echo ' |
||
1836 | <input type="hidden" name="back_look[]" value="', $path, '">'; |
||
1837 | |||
1838 | echo ' |
||
1839 | <input type="hidden" name="method" value="', $context['method'], '"> |
||
1840 | <input type="hidden" name="action_changes" value="1"> |
||
1841 | <div class="righttext padding"> |
||
1842 | <input type="submit" name="go" id="cont" value="', $txt['not_done_continue'], '" class="button"> |
||
1843 | </div> |
||
1844 | </div><!-- .windowbg --> |
||
1845 | </form>'; |
||
1846 | |||
1847 | // Just the countdown stuff |
||
1848 | echo ' |
||
1849 | <script> |
||
1850 | var countdown = ', $countDown, '; |
||
1851 | doAutoSubmit(); |
||
1852 | |||
1853 | function doAutoSubmit() |
||
1854 | { |
||
1855 | if (countdown == 0) |
||
1856 | document.forms.perm_submit.submit(); |
||
1857 | else if (countdown == -1) |
||
1858 | return; |
||
1859 | |||
1860 | document.getElementById(\'cont\').value = "', $txt['not_done_continue'], ' (" + countdown + ")"; |
||
1861 | countdown--; |
||
1862 | |||
1863 | setTimeout("doAutoSubmit();", 1000); |
||
1864 | } |
||
1865 | </script>'; |
||
1866 | } |
||
1867 | |||
1868 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.