Packages.template.php 67 KB

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