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