Packages.template.php 76 KB

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