Packages.template.php 65 KB

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