Packages.template.php 63 KB

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