Packages.template.php 66 KB

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