Packages.template.php 63 KB

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