Packages.template.php 74 KB

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