Packages.template.php 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827
  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 src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  600. <script><!-- // --><![CDATA[
  601. var oAddVersionSuggest = new smc_AutoSuggest({
  602. sSelf: \'oAddVersionSuggest\',
  603. sSessionId: smf_session_id,
  604. sSessionVar: smf_session_var,
  605. sControlId: \'ve\',
  606. sSearchType: \'versions\',
  607. bItemList: false
  608. });
  609. // ]]></script>';
  610. }
  611. function template_servers()
  612. {
  613. global $context, $txt, $scripturl;
  614. if (!empty($context['package_ftp']['error']))
  615. echo '
  616. <div class="errorbox">
  617. <tt>', $context['package_ftp']['error'], '</tt>
  618. </div>';
  619. echo '
  620. <div id="admin_form_wrapper">
  621. <div class="cat_bar">
  622. <h3 class="catbg">' . $txt['package_upload_title'] . '</h3>
  623. </div>
  624. <div class="windowbg">
  625. <div class="content">
  626. <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;">
  627. <dl class="settings">
  628. <dt>
  629. <strong>' . $txt['package_upload_select'] . ':</strong>
  630. </dt>
  631. <dd>
  632. <input type="file" name="package" size="38" class="input_file">
  633. </dd>
  634. </dl>
  635. <hr class="hrcolor">
  636. <input type="submit" value="' . $txt['package_upload'] . '" class="button_submit">
  637. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
  638. </form>
  639. </div>
  640. </div>
  641. <br>
  642. <div class="cat_bar">
  643. <h3 class="catbg"><a class="download_new_package">', $txt['download_new_package'], '</a></h3>
  644. </div>
  645. <div class="new_package_content">';
  646. if ($context['package_download_broken'])
  647. {
  648. echo '
  649. <div class="cat_bar">
  650. <h3 class="catbg">', $txt['package_ftp_necessary'], '</h3>
  651. </div>
  652. <div class="windowbg">
  653. <div class="content">
  654. <p>
  655. ', $txt['package_ftp_why_download'], '
  656. </p>
  657. <form action="', $scripturl, '?action=admin;area=packages;get" method="post" accept-charset="', $context['character_set'], '">
  658. <dl class="settings">
  659. <dt>
  660. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  661. </dt>
  662. <dd>
  663. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text">
  664. <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">
  665. </dd>
  666. <dt>
  667. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  668. </dt>
  669. <dd>
  670. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 99%;" class="input_text">
  671. </dd>
  672. <dt>
  673. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  674. </dt>
  675. <dd>
  676. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_password">
  677. </dd>
  678. <dt>
  679. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  680. </dt>
  681. <dd>
  682. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 99%;" class="input_text">
  683. </dd>
  684. </dl>
  685. <div class="righttext">
  686. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit">
  687. </div>
  688. </form>
  689. </div>
  690. </div>';
  691. }
  692. echo '
  693. <div class="windowbg2">
  694. <div class="content">
  695. <fieldset>
  696. <legend>' . $txt['package_servers'] . '</legend>
  697. <ul class="package_servers">';
  698. foreach ($context['servers'] as $server)
  699. echo '
  700. <li class="flow_auto">
  701. <span class="floatleft">' . $server['name'] . '</span>
  702. <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>
  703. <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
  704. </li>';
  705. echo '
  706. </ul>
  707. </fieldset>
  708. <fieldset>
  709. <legend>' . $txt['add_server'] . '</legend>
  710. <form action="' . $scripturl . '?action=admin;area=packages;get;sa=add" method="post" accept-charset="', $context['character_set'], '">
  711. <dl class="settings">
  712. <dt>
  713. <strong>' . $txt['server_name'] . ':</strong>
  714. </dt>
  715. <dd>
  716. <input type="text" name="servername" size="44" value="SMF" class="input_text">
  717. </dd>
  718. <dt>
  719. <strong>' . $txt['serverurl'] . ':</strong>
  720. </dt>
  721. <dd>
  722. <input type="text" name="serverurl" size="44" value="http://" class="input_text">
  723. </dd>
  724. </dl>
  725. <div class="righttext">
  726. <input type="submit" value="' . $txt['add_server'] . '" class="button_submit">
  727. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
  728. </div>
  729. </form>
  730. </fieldset>
  731. <fieldset>
  732. <legend>', $txt['package_download_by_url'], '</legend>
  733. <form action="', $scripturl, '?action=admin;area=packages;get;sa=download;byurl;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  734. <dl class="settings">
  735. <dt>
  736. <strong>' . $txt['serverurl'] . ':</strong>
  737. </dt>
  738. <dd>
  739. <input type="text" name="package" size="44" value="http://" class="input_text">
  740. </dd>
  741. <dt>
  742. <strong>', $txt['package_download_filename'], ':</strong>
  743. </dt>
  744. <dd>
  745. <input type="text" name="filename" size="44" class="input_text"><br>
  746. <span class="smalltext">', $txt['package_download_filename_info'], '</span>
  747. </dd>
  748. </dl>
  749. <div class="righttext">
  750. <input type="submit" value="', $txt['download'], '" class="button_submit">
  751. </div>
  752. </form>
  753. </fieldset>
  754. </div>
  755. </div>
  756. </div>
  757. </div>';
  758. }
  759. function template_package_confirm()
  760. {
  761. global $context, $txt, $scripturl;
  762. echo '
  763. <div id="admincenter">
  764. <div class="cat_bar">
  765. <h3 class="catbg">', $context['page_title'], '</h3>
  766. </div>
  767. <div class="windowbg">
  768. <div class="content">
  769. <p>', $context['confirm_message'], '</p>
  770. <a href="', $context['proceed_href'], '">[ ', $txt['package_confirm_proceed'], ' ]</a> <a href="JavaScript:history.go(-1);">[ ', $txt['package_confirm_go_back'], ' ]</a>
  771. </div>
  772. </div>
  773. </div>';
  774. }
  775. function template_package_list()
  776. {
  777. global $context, $txt, $scripturl, $smcFunc;
  778. echo '
  779. <div id="admincenter">
  780. <div class="cat_bar">
  781. <h3 class="catbg">' . $context['page_title'] . '</h3>
  782. </div>
  783. <div class="windowbg">
  784. <div class="content">';
  785. // No packages, as yet.
  786. if (empty($context['package_list']))
  787. echo '
  788. <ul>
  789. <li>', $txt['no_packages'], '</li>
  790. </ul>';
  791. // List out the packages...
  792. else
  793. {
  794. echo '
  795. <ul id="package_list">';
  796. foreach ($context['package_list'] as $i => $packageSection)
  797. {
  798. echo '
  799. <li>
  800. <strong><span id="ps_img_', $i, '" class="toggle_up" alt="*" style="display: none;"></span> ', $packageSection['title'], '</strong>';
  801. if (!empty($packageSection['text']))
  802. echo '
  803. <div class="information">', $packageSection['text'], '</div>';
  804. echo '
  805. <', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
  806. $alt = false;
  807. foreach ($packageSection['items'] as $id => $package)
  808. {
  809. echo '
  810. <li>';
  811. // Textual message. Could be empty just for a blank line...
  812. if ($package['is_text'])
  813. echo '
  814. ', empty($package['name']) ? '&nbsp;' : $package['name'];
  815. // This is supposed to be a rule..
  816. elseif ($package['is_line'])
  817. echo '
  818. <hr class="hrcolor">';
  819. // A remote link.
  820. elseif ($package['is_remote'])
  821. {
  822. echo '
  823. <strong>', $package['link'], '</strong>';
  824. }
  825. // A title?
  826. elseif ($package['is_heading'] || $package['is_title'])
  827. {
  828. echo '
  829. <strong>', $package['name'], '</strong>';
  830. }
  831. // Otherwise, it's a package.
  832. else
  833. {
  834. // 1. Some mod [ Download ].
  835. echo '
  836. <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'];
  837. // Mark as installed and current?
  838. if ($package['is_installed'] && !$package['is_newer'])
  839. 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>';
  840. echo '
  841. </strong>
  842. <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
  843. // Show the mod type?
  844. if ($package['type'] != '')
  845. echo '
  846. <li class="package_section">', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>';
  847. // Show the version number?
  848. if ($package['version'] != '')
  849. echo '
  850. <li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
  851. // How 'bout the author?
  852. if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
  853. echo '
  854. <li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
  855. // The homepage....
  856. if ($package['author']['website']['link'] != '')
  857. echo '
  858. <li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
  859. // Desciption: bleh bleh!
  860. // Location of file: http://someplace/.
  861. echo '
  862. <li class="package_section">', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li>
  863. <li class="package_section"><div class="information">', $txt['package_description'], ':&nbsp; ', $package['description'], '</div></li>
  864. </ul>';
  865. }
  866. $alt = !$alt;
  867. echo '
  868. </li>';
  869. }
  870. echo '
  871. </', $context['list_type'], '>
  872. </li>';
  873. }
  874. echo '
  875. </ul>';
  876. }
  877. echo '
  878. </div>
  879. </div>
  880. <div class="padding smalltext floatleft">
  881. ', $txt['package_installed_key'], '
  882. <span class="generic_icons current centericon" style="margin-left: 1ex;"></span> ', $txt['package_installed_current'], '
  883. <span class="generic_icons old centericon" style="margin-left: 2ex;"></span> ', $txt['package_installed_old'], '
  884. </div>
  885. </div>
  886. ';
  887. // Now go through and turn off all the sections.
  888. if (!empty($context['package_list']))
  889. {
  890. $section_count = count($context['package_list']);
  891. echo '
  892. <script><!-- // --><![CDATA[';
  893. foreach ($context['package_list'] as $section => $ps)
  894. {
  895. echo '
  896. var oPackageServerToggle_', $section, ' = new smc_Toggle({
  897. bToggleEnabled: true,
  898. bCurrentlyCollapsed: ', count($ps['items']) == 1 || $section_count == 1 ? 'false' : 'true', ',
  899. aSwappableContainers: [
  900. \'package_section_', $section, '\'
  901. ],
  902. aSwapImages: [
  903. {
  904. sId: \'ps_img_', $section, '\',
  905. altExpanded: \'*\',
  906. altCollapsed: \'*\'
  907. }
  908. ]
  909. });';
  910. foreach ($ps['items'] as $id => $package)
  911. {
  912. if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
  913. echo '
  914. var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
  915. bToggleEnabled: true,
  916. bCurrentlyCollapsed: true,
  917. aSwappableContainers: [
  918. \'package_section_', $section, '_pkg_', $id, '\'
  919. ],
  920. aSwapImages: [
  921. {
  922. sId: \'ps_img_', $section, '_pkg_', $id, '\',
  923. altExpanded: \'*\',
  924. altCollapsed: \'*\'
  925. }
  926. ]
  927. });';
  928. }
  929. }
  930. echo '
  931. // ]]></script>';
  932. }
  933. }
  934. function template_downloaded()
  935. {
  936. global $context, $txt, $scripturl;
  937. echo '
  938. <div id="admincenter">
  939. <div class="cat_bar">
  940. <h3 class="catbg">', $context['page_title'], '</h3>
  941. </div>
  942. <div class="windowbg">
  943. <div class="content">
  944. <p>', (empty($context['package_server']) ? $txt['package_uploaded_successfully'] : $txt['package_downloaded_successfully']), '</p>
  945. <ul class="reset">
  946. <li class="reset"><span class="floatleft"><strong>', $context['package']['name'], '</strong></span>
  947. <span class="package_server floatright">', $context['package']['list_files']['link'], '</span>
  948. <span class="package_server floatright">', $context['package']['install']['link'], '</span>
  949. </li>
  950. </ul>
  951. <br><br>
  952. <p><a href="', $scripturl, '?action=admin;area=packages;get', (isset($context['package_server']) ? ';sa=browse;server=' . $context['package_server'] : ''), '">[ ', $txt['back'], ' ]</a></p>
  953. </div>
  954. </div>
  955. </div>';
  956. }
  957. function template_install_options()
  958. {
  959. global $context, $txt, $scripturl;
  960. if (!empty($context['saved_successful']))
  961. echo '
  962. <div class="infobox">', $txt['settings_saved'], '</div>';
  963. echo '
  964. <div id="admincenter">
  965. <div class="cat_bar">
  966. <h3 class="catbg">', $txt['package_install_options'], '</h3>
  967. </div>
  968. <div class="information">
  969. ', $txt['package_install_options_ftp_why'], '
  970. </div>
  971. <div class="windowbg">
  972. <div class="content">
  973. <form action="', $scripturl, '?action=admin;area=packages;sa=options" method="post" accept-charset="', $context['character_set'], '">
  974. <dl class="settings">
  975. <dt>
  976. <label for="pack_server"><strong>', $txt['package_install_options_ftp_server'], ':</strong></label>
  977. </dt>
  978. <dd>
  979. <input type="text" name="pack_server" id="pack_server" value="', $context['package_ftp_server'], '" size="30" class="input_text">
  980. </dd>
  981. <dt>
  982. <label for="pack_port"><strong>', $txt['package_install_options_ftp_port'], ':</strong></label>
  983. </dt>
  984. <dd>
  985. <input type="text" name="pack_port" id="pack_port" size="3" value="', $context['package_ftp_port'], '" class="input_text">
  986. </dd>
  987. <dt>
  988. <label for="pack_user"><strong>', $txt['package_install_options_ftp_user'], ':</strong></label>
  989. </dt>
  990. <dd>
  991. <input type="text" name="pack_user" id="pack_user" value="', $context['package_ftp_username'], '" size="30" class="input_text">
  992. </dd>
  993. <dt>
  994. <label for="package_make_backups">', $txt['package_install_options_make_backups'], '</label>
  995. </dt>
  996. <dd>
  997. <input type="checkbox" name="package_make_backups" id="package_make_backups" value="1" class="input_check"', $context['package_make_backups'] ? ' checked' : '', '>
  998. </dd>
  999. <dt>
  1000. <label for="package_make_full_backups">', $txt['package_install_options_make_full_backups'], '</label>
  1001. </dt>
  1002. <dd>
  1003. <input type="checkbox" name="package_make_full_backups" id="package_make_full_backups" value="1" class="input_check"', $context['package_make_full_backups'] ? ' checked' : '', '>
  1004. </dd>
  1005. </dl>
  1006. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
  1007. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  1008. </form>
  1009. </div>
  1010. </div>
  1011. </div>';
  1012. }
  1013. function template_control_chmod()
  1014. {
  1015. global $context, $txt, $scripturl;
  1016. // Nothing to do? Brilliant!
  1017. if (empty($context['package_ftp']))
  1018. return false;
  1019. if (empty($context['package_ftp']['form_elements_only']))
  1020. {
  1021. echo '
  1022. ', sprintf($txt['package_ftp_why'], 'document.getElementById(\'need_writable_list\').style.display = \'\'; return false;'), '<br>
  1023. <div id="need_writable_list" class="smalltext">
  1024. ', $txt['package_ftp_why_file_list'], '
  1025. <ul style="display: inline;">';
  1026. if (!empty($context['notwritable_files']))
  1027. foreach ($context['notwritable_files'] as $file)
  1028. echo '
  1029. <li>', $file, '</li>';
  1030. echo '
  1031. </ul>
  1032. </div>';
  1033. }
  1034. echo '
  1035. <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;">
  1036. <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt>
  1037. </div></div>';
  1038. if (!empty($context['package_ftp']['destination']))
  1039. echo '
  1040. <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
  1041. echo '
  1042. <fieldset>
  1043. <dl class="settings">
  1044. <dt>
  1045. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  1046. </dt>
  1047. <dd>
  1048. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text">
  1049. <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">
  1050. </dd>
  1051. <dt>
  1052. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  1053. </dt>
  1054. <dd>
  1055. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 98%;" class="input_text">
  1056. </dd>
  1057. <dt>
  1058. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  1059. </dt>
  1060. <dd>
  1061. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 98%;" class="input_password">
  1062. </dd>
  1063. <dt>
  1064. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  1065. </dt>
  1066. <dd>
  1067. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 98%;" class="input_text">
  1068. </dd>
  1069. </dl>
  1070. </fieldset>';
  1071. if (empty($context['package_ftp']['form_elements_only']))
  1072. echo '
  1073. <div class="righttext" style="margin: 1ex;">
  1074. <span id="test_ftp_placeholder_full"></span>
  1075. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit">
  1076. </div>';
  1077. if (!empty($context['package_ftp']['destination']))
  1078. echo '
  1079. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  1080. </form>';
  1081. // Hide the details of the list.
  1082. if (empty($context['package_ftp']['form_elements_only']))
  1083. echo '
  1084. <script><!-- // --><![CDATA[
  1085. document.getElementById(\'need_writable_list\').style.display = \'none\';
  1086. // ]]></script>';
  1087. // Quick generate the test button.
  1088. echo '
  1089. <script><!-- // --><![CDATA[
  1090. // Generate a "test ftp" button.
  1091. var generatedButton = false;
  1092. function generateFTPTest()
  1093. {
  1094. // Don\'t ever call this twice!
  1095. if (generatedButton)
  1096. return false;
  1097. generatedButton = true;
  1098. // No XML?
  1099. if (!window.XMLHttpRequest || (!document.getElementById("test_ftp_placeholder") && !document.getElementById("test_ftp_placeholder_full")))
  1100. return false;
  1101. var ftpTest = document.createElement("input");
  1102. ftpTest.type = "button";
  1103. ftpTest.onclick = testFTP;
  1104. if (document.getElementById("test_ftp_placeholder"))
  1105. {
  1106. ftpTest.value = "', $txt['package_ftp_test'], '";
  1107. document.getElementById("test_ftp_placeholder").appendChild(ftpTest);
  1108. }
  1109. else
  1110. {
  1111. ftpTest.value = "', $txt['package_ftp_test_connection'], '";
  1112. document.getElementById("test_ftp_placeholder_full").appendChild(ftpTest);
  1113. }
  1114. }
  1115. function testFTPResults(oXMLDoc)
  1116. {
  1117. ajax_indicator(false);
  1118. // This assumes it went wrong!
  1119. var wasSuccess = false;
  1120. var message = "', addcslashes($txt['package_ftp_test_failed'], "'"), '";
  1121. var results = oXMLDoc.getElementsByTagName(\'results\')[0].getElementsByTagName(\'result\');
  1122. if (results.length > 0)
  1123. {
  1124. if (results[0].getAttribute(\'success\') == 1)
  1125. wasSuccess = true;
  1126. message = results[0].firstChild.nodeValue;
  1127. }
  1128. document.getElementById("ftp_error_div").style.display = "";
  1129. document.getElementById("ftp_error_div").style.backgroundColor = wasSuccess ? "green" : "red";
  1130. document.getElementById("ftp_error_innerdiv").style.backgroundColor = wasSuccess ? "#DBFDC7" : "#FDBDBD";
  1131. setInnerHTML(document.getElementById("ftp_error_message"), message);
  1132. }
  1133. generateFTPTest();
  1134. // ]]></script>';
  1135. // Make sure the button gets generated last.
  1136. $context['insert_after_template'] .= '
  1137. <script><!-- // --><![CDATA[
  1138. generateFTPTest();
  1139. // ]]></script>';
  1140. }
  1141. function template_ftp_required()
  1142. {
  1143. global $txt;
  1144. echo '
  1145. <fieldset>
  1146. <legend>
  1147. ', $txt['package_ftp_necessary'], '
  1148. </legend>
  1149. <div class="ftp_details">
  1150. ', template_control_chmod(), '
  1151. </div>
  1152. </fieldset>';
  1153. }
  1154. function template_view_operations()
  1155. {
  1156. global $context, $txt, $settings;
  1157. echo '<!DOCTYPE html>
  1158. <html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  1159. <head>
  1160. <title>', $txt['operation_title'], '</title>
  1161. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '">
  1162. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21">
  1163. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/admin.css?alp21">
  1164. <script src="', $settings['default_theme_url'], '/scripts/script.js?alp21"></script>
  1165. <script src="', $settings['default_theme_url'], '/scripts/theme.js?alp21"></script>
  1166. </head>
  1167. <body>
  1168. <div class="padding windowbg">
  1169. <div class="padding">
  1170. ', $context['operations']['search'], '
  1171. </div>
  1172. <div class="padding">
  1173. ', $context['operations']['replace'], '
  1174. </div>
  1175. </div>
  1176. </body>
  1177. </html>';
  1178. }
  1179. function template_file_permissions()
  1180. {
  1181. global $txt, $scripturl, $context, $settings;
  1182. // This will handle expanding the selection.
  1183. echo '
  1184. <script><!-- // --><![CDATA[
  1185. var oRadioColors = {
  1186. 0: "#D1F7BF",
  1187. 1: "#FFBBBB",
  1188. 2: "#FDD7AF",
  1189. 3: "#C2C6C0",
  1190. 4: "#EEEEEE"
  1191. }
  1192. var oRadioValues = {
  1193. 0: "read",
  1194. 1: "writable",
  1195. 2: "execute",
  1196. 3: "custom",
  1197. 4: "no_change"
  1198. }
  1199. function dynamicAddMore()
  1200. {
  1201. ajax_indicator(true);
  1202. 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);
  1203. }
  1204. // Getting something back?
  1205. function onNewFolderReceived(oXMLDoc)
  1206. {
  1207. ajax_indicator(false);
  1208. var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\');
  1209. // No folders, no longer worth going further.
  1210. if (fileItems.length < 1)
  1211. {
  1212. if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0])
  1213. {
  1214. var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue;
  1215. var itemLink = document.getElementById(\'link_\' + rootName);
  1216. // Move the children up.
  1217. for (i = 0; i <= itemLink.childNodes.length; i++)
  1218. itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink);
  1219. // And remove the link.
  1220. itemLink.parentNode.removeChild(itemLink);
  1221. }
  1222. return false;
  1223. }
  1224. var tableHandle = false;
  1225. var isMore = false;
  1226. var ident = "";
  1227. var my_ident = "";
  1228. var curLevel = 0;
  1229. for (var i = 0; i < fileItems.length; i++)
  1230. {
  1231. if (fileItems[i].getAttribute(\'more\') == 1)
  1232. {
  1233. isMore = true;
  1234. var curOffset = fileItems[i].getAttribute(\'offset\');
  1235. }
  1236. if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')))
  1237. {
  1238. ident = fileItems[i].getAttribute(\'ident\');
  1239. my_ident = fileItems[i].getAttribute(\'my_ident\');
  1240. curLevel = fileItems[i].getAttribute(\'level\') * 5;
  1241. curPath = fileItems[i].getAttribute(\'path\');
  1242. // Get where we\'re putting it next to.
  1243. tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'));
  1244. var curRow = document.createElement("tr");
  1245. curRow.className = "windowbg";
  1246. curRow.id = "content_" + my_ident;
  1247. curRow.style.display = "";
  1248. var curCol = document.createElement("td");
  1249. curCol.className = "smalltext";
  1250. curCol.width = "40%";
  1251. // This is the name.
  1252. var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue);
  1253. // Start by wacking in the spaces.
  1254. setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
  1255. // Create the actual text.
  1256. if (fileItems[i].getAttribute(\'folder\') == 1)
  1257. {
  1258. var linkData = document.createElement("a");
  1259. linkData.name = "fol_" + my_ident;
  1260. linkData.id = "link_" + my_ident;
  1261. linkData.href = \'#\';
  1262. linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue;
  1263. linkData.ident = my_ident;
  1264. linkData.onclick = dynamicExpandFolder;
  1265. var folderImage = document.createElement("img");
  1266. folderImage.src = \'', addcslashes($settings['default_images_url'], "\\"), '/board.png\';
  1267. linkData.appendChild(folderImage);
  1268. linkData.appendChild(fileName);
  1269. curCol.appendChild(linkData);
  1270. }
  1271. else
  1272. curCol.appendChild(fileName);
  1273. curRow.appendChild(curCol);
  1274. // Right, the permissions.
  1275. curCol = document.createElement("td");
  1276. curCol.className = "smalltext";
  1277. var writeSpan = document.createElement("span");
  1278. writeSpan.style.color = fileItems[i].getAttribute(\'writable\') ? "green" : "red";
  1279. setInnerHTML(writeSpan, fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\');
  1280. curCol.appendChild(writeSpan);
  1281. if (fileItems[i].getAttribute(\'permissions\'))
  1282. {
  1283. var permData = document.createTextNode("\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")");
  1284. curCol.appendChild(permData);
  1285. }
  1286. curRow.appendChild(curCol);
  1287. // Now add the five radio buttons.
  1288. for (j = 0; j < 5; j++)
  1289. {
  1290. curCol = document.createElement("td");
  1291. curCol.style.backgroundColor = oRadioColors[j];
  1292. curCol.align = "center";
  1293. var curInput = createNamedElement("input", "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]", j == 4 ? "checked" : "");
  1294. curInput.type = "radio";
  1295. curInput.checked = "checked";
  1296. curInput.value = oRadioValues[j];
  1297. curCol.appendChild(curInput);
  1298. curRow.appendChild(curCol);
  1299. }
  1300. // Put the row in.
  1301. tableHandle.parentNode.insertBefore(curRow, tableHandle);
  1302. // Put in a new dummy section?
  1303. if (fileItems[i].getAttribute(\'folder\') == 1)
  1304. {
  1305. var newRow = document.createElement("tr");
  1306. newRow.id = "insert_div_loc_" + my_ident;
  1307. newRow.style.display = "none";
  1308. tableHandle.parentNode.insertBefore(newRow, tableHandle);
  1309. var newCol = document.createElement("td");
  1310. newCol.colspan = 2;
  1311. newRow.appendChild(newCol);
  1312. }
  1313. }
  1314. }
  1315. // Is there some more to remove?
  1316. if (document.getElementById("content_" + ident + "_more"))
  1317. {
  1318. document.getElementById("content_" + ident + "_more").parentNode.removeChild(document.getElementById("content_" + ident + "_more"));
  1319. }
  1320. // Add more?
  1321. if (isMore && tableHandle)
  1322. {
  1323. // Create the actual link.
  1324. var linkData = document.createElement("a");
  1325. linkData.href = \'#fol_\' + my_ident;
  1326. linkData.path = curPath;
  1327. linkData.offset = curOffset;
  1328. linkData.onclick = dynamicAddMore;
  1329. linkData.appendChild(document.createTextNode(\'', $txt['package_file_perms_more_files'], '\'));
  1330. curRow = document.createElement("tr");
  1331. curRow.className = "windowbg";
  1332. curRow.id = "content_" + ident + "_more";
  1333. tableHandle.parentNode.insertBefore(curRow, tableHandle);
  1334. curCol = document.createElement("td");
  1335. curCol.className = "smalltext";
  1336. curCol.width = "40%";
  1337. setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
  1338. curCol.appendChild(document.createTextNode(\'\\u00ab \'));
  1339. curCol.appendChild(linkData);
  1340. curCol.appendChild(document.createTextNode(\' \\u00bb\'));
  1341. curRow.appendChild(curCol);
  1342. curCol = document.createElement("td");
  1343. curCol.className = "smalltext";
  1344. curRow.appendChild(curCol);
  1345. }
  1346. // Keep track of it.
  1347. var curInput = createNamedElement("input", "back_look[]");
  1348. curInput.type = "hidden";
  1349. curInput.value = curPath;
  1350. curCol.appendChild(curInput);
  1351. }
  1352. // ]]></script>';
  1353. echo '
  1354. <div class="noticebox">
  1355. <div>
  1356. <strong>', $txt['package_file_perms_warning'], ':</strong>
  1357. <div class="smalltext">
  1358. <ol style="margin-top: 2px; margin-bottom: 2px">
  1359. ', $txt['package_file_perms_warning_desc'], '
  1360. </ol>
  1361. </div>
  1362. </div>
  1363. </div>
  1364. <form action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  1365. <div class="cat_bar">
  1366. <h3 class="catbg">
  1367. <span class="floatleft">', $txt['package_file_perms'], '</span><span class="fperm floatright">', $txt['package_file_perms_new_status'], '</span>
  1368. </h3>
  1369. </div>
  1370. <table class="table_grid">
  1371. <thead>
  1372. <tr class="catbg">
  1373. <th class="first_th lefttext" width="30%">&nbsp;', $txt['package_file_perms_name'], '&nbsp;</th>
  1374. <th width="30%" class="lefttext">', $txt['package_file_perms_status'], '</th>
  1375. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_read'], '</span></th>
  1376. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_write'], '</span></th>
  1377. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_execute'], '</span></th>
  1378. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_custom'], '</span></th>
  1379. <th class="last_th" align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_no_change'], '</span></th>
  1380. </tr>
  1381. </thead>
  1382. <tbody>';
  1383. foreach ($context['file_tree'] as $name => $dir)
  1384. {
  1385. echo '
  1386. <tr class="windowbg2">
  1387. <td width="30%"><strong>';
  1388. if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
  1389. echo '
  1390. <img src="', $settings['default_images_url'], '/board.png" alt="*">';
  1391. echo '
  1392. ', $name, '
  1393. </strong></td>
  1394. <td width="30%">
  1395. <span style="color: ', ($dir['perms']['chmod'] ? 'green' : 'red'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span>
  1396. ', ($dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), '
  1397. </td>
  1398. <td align="center" class="perm_read"><input type="radio" name="permStatus[', $name, ']" value="read" class="input_radio"></td>
  1399. <td align="center" class="perm_write"><input type="radio" name="permStatus[', $name, ']" value="writable" class="input_radio"></td>
  1400. <td align="center" class="perm_execute"><input type="radio" name="permStatus[', $name, ']" value="execute" class="input_radio"></td>
  1401. <td align="center" class="perm_custom"><input type="radio" name="permStatus[', $name, ']" value="custom" class="input_radio"></td>
  1402. <td align="center" class="perm_nochange"><input type="radio" name="permStatus[', $name, ']" value="no_change" checked class="input_radio"></td>
  1403. </tr>
  1404. ';
  1405. if (!empty($dir['contents']))
  1406. template_permission_show_contents($name, $dir['contents'], 1);
  1407. }
  1408. echo '
  1409. </tbody>
  1410. </table>
  1411. <br>
  1412. <div class="cat_bar">
  1413. <h3 class="catbg">', $txt['package_file_perms_change'], '</h3>
  1414. </div>
  1415. <div class="windowbg">
  1416. <div class="content">
  1417. <fieldset>
  1418. <dl>
  1419. <dt>
  1420. <input type="radio" name="method" value="individual" checked id="method_individual" class="input_radio">
  1421. <label for="method_individual"><strong>', $txt['package_file_perms_apply'], '</strong></label>
  1422. </dt>
  1423. <dd>
  1424. <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>
  1425. </dd>
  1426. <dt>
  1427. <input type="radio" name="method" value="predefined" id="method_predefined" class="input_radio">
  1428. <label for="method_predefined"><strong>', $txt['package_file_perms_predefined'], ':</strong></label>
  1429. <select name="predefined" onchange="document.getElementById(\'method_predefined\').checked = \'checked\';">
  1430. <option value="restricted" selected>', $txt['package_file_perms_pre_restricted'], '</option>
  1431. <option value="standard">', $txt['package_file_perms_pre_standard'], '</option>
  1432. <option value="free">', $txt['package_file_perms_pre_free'], '</option>
  1433. </select>
  1434. </dt>
  1435. <dd>
  1436. <em class="smalltext">', $txt['package_file_perms_predefined_note'], '</em>
  1437. </dd>
  1438. </dl>
  1439. </fieldset>';
  1440. // Likely to need FTP?
  1441. if (empty($context['ftp_connected']))
  1442. echo '
  1443. <p>
  1444. ', $txt['package_file_perms_ftp_details'], ':
  1445. </p>
  1446. ', template_control_chmod(), '
  1447. <div class="descbox">', $txt['package_file_perms_ftp_retain'], '</div>';
  1448. echo '
  1449. <span id="test_ftp_placeholder_full"></span>
  1450. <input type="hidden" name="action_changes" value="1">
  1451. <input type="submit" value="', $txt['package_file_perms_go'], '" name="go" class="button_submit">
  1452. </div>
  1453. </div>';
  1454. // Any looks fors we've already done?
  1455. foreach ($context['look_for'] as $path)
  1456. echo '
  1457. <input type="hidden" name="back_look[]" value="', $path, '">';
  1458. echo '
  1459. </form><br>';
  1460. }
  1461. function template_permission_show_contents($ident, $contents, $level, $has_more = false)
  1462. {
  1463. global $settings, $txt, $scripturl, $context;
  1464. $js_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident);
  1465. // Have we actually done something?
  1466. $drawn_div = false;
  1467. foreach ($contents as $name => $dir)
  1468. {
  1469. if (isset($dir['perms']))
  1470. {
  1471. if (!$drawn_div)
  1472. {
  1473. $drawn_div = true;
  1474. echo '
  1475. </tbody>
  1476. </table>
  1477. <table border="0" class="table_grid" id="', $js_ident, '">
  1478. <tbody>';
  1479. }
  1480. $cur_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident . '/' . $name);
  1481. echo '
  1482. <tr class="windowbg" id="content_', $cur_ident, '">
  1483. <td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
  1484. ', (!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, "'\\") . '\');">' : '';
  1485. if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
  1486. echo '<img src="', $settings['default_images_url'], '/board.png" alt="*">';
  1487. echo '
  1488. ', $name, '
  1489. ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '</a>' : '', '
  1490. </td>
  1491. <td class="smalltext">
  1492. <span class="', ($dir['perms']['chmod'] ? 'success' : 'error'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span>
  1493. ', ($dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), '
  1494. </td>
  1495. <td align="center" class="perm_read"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="read" class="input_radio"></td>
  1496. <td align="center" class="perm_write"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="writable" class="input_radio"></td>
  1497. <td align="center" class="perm_execute"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="execute" class="input_radio"></td>
  1498. <td align="center" class="perm_custom"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="custom" class="input_radio"></td>
  1499. <td align="center" class="perm_nochange"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="no_change" checked class="input_radio"></td>
  1500. </tr>
  1501. <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>';
  1502. if (!empty($dir['contents']))
  1503. {
  1504. template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
  1505. }
  1506. }
  1507. }
  1508. // We have more files to show?
  1509. if ($has_more)
  1510. echo '
  1511. <tr class="windowbg" id="content_', $js_ident, '_more">
  1512. <td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
  1513. &#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;
  1514. </td>
  1515. <td colspan="6"></td>
  1516. </tr>';
  1517. if ($drawn_div)
  1518. {
  1519. // Hide anything too far down the tree.
  1520. $isFound = false;
  1521. foreach ($context['look_for'] as $tree)
  1522. {
  1523. if (substr($tree, 0, strlen($ident)) == $ident)
  1524. $isFound = true;
  1525. }
  1526. if ($level > 1 && !$isFound)
  1527. echo '
  1528. </tbody>
  1529. </table><script><!-- // --><![CDATA[
  1530. expandFolder(\'', $js_ident, '\', \'\');
  1531. // ]]></script>
  1532. <table border="0" class="table_grid">
  1533. <tbody>
  1534. <tr style="display: none;"><td></td></tr>';
  1535. }
  1536. }
  1537. function template_action_permissions()
  1538. {
  1539. global $txt, $scripturl, $context;
  1540. $countDown = 3;
  1541. echo '
  1542. <div id="admincenter">
  1543. <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'], '">
  1544. <div class="cat_bar">
  1545. <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
  1546. </div>';
  1547. if (!empty($context['skip_ftp']))
  1548. echo '
  1549. <div class="errorbox">
  1550. ', $txt['package_file_perms_skipping_ftp'], '
  1551. </div>';
  1552. // How many have we done?
  1553. $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
  1554. $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']);
  1555. $progress_percent = round(($context['total_items'] - $remaining_items) / $context['total_items'] * 100, 1);
  1556. echo '
  1557. <div class="windowbg">
  1558. <div class="content">
  1559. <div>
  1560. <strong>', $progress_message, '</strong><br><br>
  1561. <div class="progress_bar">
  1562. <div class="full_bar">', $progress_percent, '%</div>
  1563. <div class="blue_percent" style="width: ', $progress_percent, '%;">&nbsp;</div>
  1564. </div>
  1565. </div>';
  1566. // Second progress bar for a specific directory?
  1567. if ($context['method'] != 'individual' && !empty($context['total_files']))
  1568. {
  1569. $file_progress_message = sprintf($txt['package_file_perms_files_done'], $context['file_offset'], $context['total_files']);
  1570. $file_progress_percent = round($context['file_offset'] / $context['total_files'] * 100, 1);
  1571. echo '
  1572. <br>
  1573. <div>
  1574. <strong>', $file_progress_message, '</strong><br><br>
  1575. <div class="progress_bar">
  1576. <div class="full_bar">', $file_progress_percent, '%</div>
  1577. <div class="green_percent" style="width: ', $file_progress_percent, '%;">&nbsp;</div>
  1578. </div>
  1579. </div>';
  1580. }
  1581. echo '
  1582. <br>';
  1583. // Put out the right hidden data.
  1584. if ($context['method'] == 'individual')
  1585. echo '
  1586. <input type="hidden" name="custom_value" value="', $context['custom_value'], '">
  1587. <input type="hidden" name="totalItems" value="', $context['total_items'], '">
  1588. <input type="hidden" name="toProcess" value="', base64_encode(serialize($context['to_process'])), '">';
  1589. else
  1590. echo '
  1591. <input type="hidden" name="predefined" value="', $context['predefined_type'], '">
  1592. <input type="hidden" name="fileOffset" value="', $context['file_offset'], '">
  1593. <input type="hidden" name="totalItems" value="', $context['total_items'], '">
  1594. <input type="hidden" name="dirList" value="', base64_encode(serialize($context['directory_list'])), '">
  1595. <input type="hidden" name="specialFiles" value="', base64_encode(serialize($context['special_files'])), '">';
  1596. // Are we not using FTP for whatever reason.
  1597. if (!empty($context['skip_ftp']))
  1598. echo '
  1599. <input type="hidden" name="skip_ftp" value="1">';
  1600. // Retain state.
  1601. foreach ($context['back_look_data'] as $path)
  1602. echo '
  1603. <input type="hidden" name="back_look[]" value="', $path, '">';
  1604. echo '
  1605. <input type="hidden" name="method" value="', $context['method'], '">
  1606. <input type="hidden" name="action_changes" value="1">
  1607. <div class="righttext padding">
  1608. <input type="submit" name="go" id="cont" value="', $txt['not_done_continue'], '" class="button_submit">
  1609. </div>
  1610. </div>
  1611. </div>
  1612. </form>
  1613. </div>';
  1614. // Just the countdown stuff
  1615. echo '
  1616. <script><!-- // --><![CDATA[
  1617. var countdown = ', $countDown, ';
  1618. doAutoSubmit();
  1619. function doAutoSubmit()
  1620. {
  1621. if (countdown == 0)
  1622. document.forms.perm_submit.submit();
  1623. else if (countdown == -1)
  1624. return;
  1625. document.getElementById(\'cont\').value = "', $txt['not_done_continue'], ' (" + countdown + ")";
  1626. countdown--;
  1627. setTimeout("doAutoSubmit();", 1000);
  1628. }
  1629. // ]]></script>';
  1630. }
  1631. ?>