Packages.template.php 65 KB

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