Packages.template.php 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039
  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. }
  782. function template_servers()
  783. {
  784. global $context, $settings, $options, $txt, $scripturl;
  785. if (!empty($context['package_ftp']['error']))
  786. echo '
  787. <div class="errorbox">
  788. <tt>', $context['package_ftp']['error'], '</tt>
  789. </div>';
  790. echo '
  791. <div id="admincenter">
  792. <div class="cat_bar">
  793. <h3 class="catbg">', $txt['download_new_package'], '</h3>
  794. </div>';
  795. if ($context['package_download_broken'])
  796. {
  797. echo '
  798. <div class="title_bar">
  799. <h3 class="titlebg">', $txt['package_ftp_necessary'], '</h3>
  800. </div>
  801. <div class="windowbg">
  802. <span class="topslice"><span></span></span>
  803. <div class="content">
  804. <p>
  805. ', $txt['package_ftp_why_download'], '
  806. </p>
  807. <form action="', $scripturl, '?action=admin;area=packages;get" method="post" accept-charset="', $context['character_set'], '">
  808. <dl class="settings">
  809. <dt>
  810. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  811. </dt>
  812. <dd>
  813. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text" />
  814. <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" />
  815. </dd>
  816. <dt>
  817. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  818. </dt>
  819. <dd>
  820. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 99%;" class="input_text" />
  821. </dd>
  822. <dt>
  823. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  824. </dt>
  825. <dd>
  826. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_password" />
  827. </dd>
  828. <dt>
  829. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  830. </dt>
  831. <dd>
  832. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 99%;" class="input_text" />
  833. </dd>
  834. </dl>
  835. <div class="righttext">
  836. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit" />
  837. </div>
  838. </form>
  839. </div>
  840. <span class="botslice"><span></span></span>
  841. </div>';
  842. }
  843. echo '
  844. <div class="windowbg2">
  845. <span class="topslice"><span></span></span>
  846. <div class="content">
  847. <fieldset>
  848. <legend>' . $txt['package_servers'] . '</legend>
  849. <ul class="package_servers">';
  850. foreach ($context['servers'] as $server)
  851. echo '
  852. <li class="flow_auto">
  853. <span class="floatleft">' . $server['name'] . '</span>
  854. <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>
  855. <span class="package_server floatright"><a href="' . $scripturl . '?action=admin;area=packages;get;sa=browse;server=' . $server['id'] . '">[ ' . $txt['package_browse'] . ' ]</a></span>
  856. </li>';
  857. echo '
  858. </ul>
  859. </fieldset>
  860. <fieldset>
  861. <legend>' . $txt['add_server'] . '</legend>
  862. <form action="' . $scripturl . '?action=admin;area=packages;get;sa=add" method="post" accept-charset="', $context['character_set'], '">
  863. <dl class="settings">
  864. <dt>
  865. <strong>' . $txt['server_name'] . ':</strong>
  866. </dt>
  867. <dd>
  868. <input type="text" name="servername" size="44" value="SMF" class="input_text" />
  869. </dd>
  870. <dt>
  871. <strong>' . $txt['serverurl'] . ':</strong>
  872. </dt>
  873. <dd>
  874. <input type="text" name="serverurl" size="44" value="http://" class="input_text" />
  875. </dd>
  876. </dl>
  877. <div class="righttext">
  878. <input type="submit" value="' . $txt['add_server'] . '" class="button_submit" />
  879. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  880. </div>
  881. </form>
  882. </fieldset>
  883. <fieldset>
  884. <legend>', $txt['package_download_by_url'], '</legend>
  885. <form action="', $scripturl, '?action=admin;area=packages;get;sa=download;byurl;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  886. <dl class="settings">
  887. <dt>
  888. <strong>' . $txt['serverurl'] . ':</strong>
  889. </dt>
  890. <dd>
  891. <input type="text" name="package" size="44" value="http://" class="input_text" />
  892. </dd>
  893. <dt>
  894. <strong>', $txt['package_download_filename'], ':</strong>
  895. </dt>
  896. <dd>
  897. <input type="text" name="filename" size="44" class="input_text" /><br />
  898. <span class="smalltext">', $txt['package_download_filename_info'], '</span>
  899. </dd>
  900. </dl>
  901. <div class="righttext">
  902. <input type="submit" value="', $txt['download'], '" class="button_submit" />
  903. </div>
  904. </form>
  905. </fieldset>
  906. </div>
  907. <span class="botslice"><span></span></span>
  908. </div>
  909. <br />
  910. <div class="cat_bar">
  911. <h3 class="catbg">' . $txt['package_upload_title'] . '</h3>
  912. </div>
  913. <div class="windowbg">
  914. <span class="topslice"><span></span></span>
  915. <div class="content">
  916. <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;">
  917. <dl class="settings">
  918. <dt>
  919. <strong>' . $txt['package_upload_select'] . ':</strong>
  920. </dt>
  921. <dd>
  922. <input type="file" name="package" size="38" class="input_file" />
  923. </dd>
  924. </dl>
  925. <div class="righttext">
  926. <input type="submit" value="' . $txt['package_upload'] . '" class="button_submit" />
  927. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
  928. </div>
  929. </form>
  930. </div>
  931. <span class="botslice"><span></span></span>
  932. </div>
  933. </div>
  934. <br class="clear" />';
  935. }
  936. function template_package_confirm()
  937. {
  938. global $context, $settings, $options, $txt, $scripturl;
  939. echo '
  940. <div id="admincenter">
  941. <div class="cat_bar">
  942. <h3 class="catbg">', $context['page_title'], '</h3>
  943. </div>
  944. <div class="windowbg">
  945. <span class="topslice"><span></span></span>
  946. <div class="content">
  947. <p>', $context['confirm_message'], '</p>
  948. <a href="', $context['proceed_href'], '">[ ', $txt['package_confirm_proceed'], ' ]</a> <a href="JavaScript:history.go(-1);">[ ', $txt['package_confirm_go_back'], ' ]</a>
  949. </div>
  950. <span class="botslice"><span></span></span>
  951. </div>
  952. </div>
  953. <br class="clear" />';
  954. }
  955. function template_package_list()
  956. {
  957. global $context, $settings, $options, $txt, $scripturl, $smcFunc;
  958. echo '
  959. <div id="admincenter">
  960. <div class="cat_bar">
  961. <h3 class="catbg">' . $context['page_title'] . '</h3>
  962. </div>
  963. <div class="windowbg">
  964. <span class="topslice"><span></span></span>
  965. <div class="content">';
  966. // No packages, as yet.
  967. if (empty($context['package_list']))
  968. echo '
  969. <ul>
  970. <li>', $txt['no_packages'], '</li>
  971. </ul>';
  972. // List out the packages...
  973. else
  974. {
  975. echo '
  976. <ul id="package_list">';
  977. foreach ($context['package_list'] as $i => $packageSection)
  978. {
  979. echo '
  980. <li>
  981. <strong><img id="ps_img_', $i, '" src="', $settings['images_url'], '/upshrink.png" alt="*" style="display: none;" /> ', $packageSection['title'], '</strong>';
  982. if (!empty($packageSection['text']))
  983. echo '
  984. <div class="information">', $packageSection['text'], '</div>';
  985. echo '
  986. <', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
  987. $alt = false;
  988. foreach ($packageSection['items'] as $id => $package)
  989. {
  990. echo '
  991. <li>';
  992. // Textual message. Could be empty just for a blank line...
  993. if ($package['is_text'])
  994. echo '
  995. ', empty($package['name']) ? '&nbsp;' : $package['name'];
  996. // This is supposed to be a rule..
  997. elseif ($package['is_line'])
  998. echo '
  999. <hr class="hrcolor" />';
  1000. // A remote link.
  1001. elseif ($package['is_remote'])
  1002. {
  1003. echo '
  1004. <strong>', $package['link'], '</strong>';
  1005. }
  1006. // A title?
  1007. elseif ($package['is_heading'] || $package['is_title'])
  1008. {
  1009. echo '
  1010. <strong>', $package['name'], '</strong>';
  1011. }
  1012. // Otherwise, it's a package.
  1013. else
  1014. {
  1015. // 1. Some mod [ Download ].
  1016. echo '
  1017. <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'];
  1018. // Mark as installed and current?
  1019. if ($package['is_installed'] && !$package['is_newer'])
  1020. 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'], '" />';
  1021. echo '
  1022. </strong>
  1023. <ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
  1024. // Show the mod type?
  1025. if ($package['type'] != '')
  1026. echo '
  1027. <li class="package_section">', $txt['package_type'], ':&nbsp; ', $smcFunc['ucwords']($smcFunc['strtolower']($package['type'])), '</li>';
  1028. // Show the version number?
  1029. if ($package['version'] != '')
  1030. echo '
  1031. <li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
  1032. // How 'bout the author?
  1033. if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link']))
  1034. echo '
  1035. <li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
  1036. // The homepage....
  1037. if ($package['author']['website']['link'] != '')
  1038. echo '
  1039. <li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
  1040. // Desciption: bleh bleh!
  1041. // Location of file: http://someplace/.
  1042. echo '
  1043. <li class="package_section">', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li>
  1044. <li class="package_section"><div class="information">', $txt['package_description'], ':&nbsp; ', $package['description'], '</div></li>
  1045. </ul>';
  1046. }
  1047. $alt = !$alt;
  1048. echo '
  1049. </li>';
  1050. }
  1051. echo '
  1052. </', $context['list_type'], '>
  1053. </li>';
  1054. }
  1055. echo '
  1056. </ul>';
  1057. }
  1058. echo '
  1059. </div>
  1060. <span class="botslice"><span></span></span>
  1061. </div>
  1062. <div class="padding smalltext floatleft">
  1063. ', $txt['package_installed_key'], '
  1064. <img src="', $settings['images_url'], '/icons/package_installed.gif" alt="" align="middle" style="margin-left: 1ex;" /> ', $txt['package_installed_current'], '
  1065. <img src="', $settings['images_url'], '/icons/package_old.gif" alt="" align="middle" style="margin-left: 2ex;" /> ', $txt['package_installed_old'], '
  1066. </div>
  1067. </div>
  1068. <br class="clear" />
  1069. ';
  1070. // Now go through and turn off all the sections.
  1071. if (!empty($context['package_list']))
  1072. {
  1073. $section_count = count($context['package_list']);
  1074. echo '
  1075. <script type="text/javascript"><!-- // --><![CDATA[';
  1076. foreach ($context['package_list'] as $section => $ps)
  1077. {
  1078. echo '
  1079. var oPackageServerToggle_', $section, ' = new smc_Toggle({
  1080. bToggleEnabled: true,
  1081. bCurrentlyCollapsed: ', count($ps['items']) == 1 || $section_count == 1 ? 'false' : 'true', ',
  1082. aSwappableContainers: [
  1083. \'package_section_', $section, '\'
  1084. ],
  1085. aSwapImages: [
  1086. {
  1087. sId: \'ps_img_', $section, '\',
  1088. srcExpanded: smf_images_url + \'/upshrink.png\',
  1089. altExpanded: \'*\',
  1090. srcCollapsed: smf_images_url + \'/upshrink2.png\',
  1091. altCollapsed: \'*\'
  1092. }
  1093. ]
  1094. });';
  1095. foreach ($ps['items'] as $id => $package)
  1096. {
  1097. if (!$package['is_text'] && !$package['is_line'] && !$package['is_remote'])
  1098. echo '
  1099. var oPackageToggle_', $section, '_pkg_', $id, ' = new smc_Toggle({
  1100. bToggleEnabled: true,
  1101. bCurrentlyCollapsed: true,
  1102. aSwappableContainers: [
  1103. \'package_section_', $section, '_pkg_', $id, '\'
  1104. ],
  1105. aSwapImages: [
  1106. {
  1107. sId: \'ps_img_', $section, '_pkg_', $id, '\',
  1108. srcExpanded: smf_images_url + \'/upshrink.png\',
  1109. altExpanded: \'*\',
  1110. srcCollapsed: smf_images_url + \'/upshrink2.png\',
  1111. altCollapsed: \'*\'
  1112. }
  1113. ]
  1114. });';
  1115. }
  1116. }
  1117. echo '
  1118. // ]]></script>';
  1119. }
  1120. }
  1121. function template_downloaded()
  1122. {
  1123. global $context, $settings, $options, $txt, $scripturl;
  1124. echo '
  1125. <div id="admincenter">
  1126. <div class="cat_bar">
  1127. <h3 class="catbg">', $context['page_title'], '</h3>
  1128. </div>
  1129. <div class="windowbg">
  1130. <span class="topslice"><span></span></span>
  1131. <div class="content">
  1132. <p>', (empty($context['package_server']) ? $txt['package_uploaded_successfully'] : $txt['package_downloaded_successfully']), '</p>
  1133. <ul class="reset">
  1134. <li class="reset"><span class="floatleft"><strong>', $context['package']['name'], '</strong></span>
  1135. <span class="package_server floatright">', $context['package']['list_files']['link'], '</span>
  1136. <span class="package_server floatright">', $context['package']['install']['link'], '</span>
  1137. </li>
  1138. </ul>
  1139. <br /><br />
  1140. <p><a href="', $scripturl, '?action=admin;area=packages;get', (isset($context['package_server']) ? ';sa=browse;server=' . $context['package_server'] : ''), '">[ ', $txt['back'], ' ]</a></p>
  1141. </div>
  1142. <span class="botslice"><span></span></span>
  1143. </div>
  1144. </div>
  1145. <br class="clear" />';
  1146. }
  1147. function template_install_options()
  1148. {
  1149. global $context, $settings, $options, $txt, $scripturl;
  1150. echo '
  1151. <div id="admincenter">
  1152. <div class="cat_bar">
  1153. <h3 class="catbg">', $txt['package_install_options'], '</h3>
  1154. </div>
  1155. <div class="information">
  1156. ', $txt['package_install_options_ftp_why'], '
  1157. </div>
  1158. <div class="windowbg">
  1159. <span class="topslice"><span></span></span>
  1160. <div class="content">
  1161. <form action="', $scripturl, '?action=admin;area=packages;sa=options" method="post" accept-charset="', $context['character_set'], '">
  1162. <dl class="settings">
  1163. <dt>
  1164. <label for="pack_server"><strong>', $txt['package_install_options_ftp_server'], ':</strong></label>
  1165. </dt>
  1166. <dd>
  1167. <input type="text" name="pack_server" id="pack_server" value="', $context['package_ftp_server'], '" size="30" class="input_text" />
  1168. </dd>
  1169. <dt>
  1170. <label for="pack_port"><strong>', $txt['package_install_options_ftp_port'], ':</strong></label>
  1171. </dt>
  1172. <dd>
  1173. <input type="text" name="pack_port" id="pack_port" size="3" value="', $context['package_ftp_port'], '" class="input_text" />
  1174. </dd>
  1175. <dt>
  1176. <label for="pack_user"><strong>', $txt['package_install_options_ftp_user'], ':</strong></label>
  1177. </dt>
  1178. <dd>
  1179. <input type="text" name="pack_user" id="pack_user" value="', $context['package_ftp_username'], '" size="30" class="input_text" />
  1180. </dd>
  1181. </dl>
  1182. <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 />
  1183. <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 />
  1184. <div class="righttext">
  1185. <input type="submit" name="submit" value="', $txt['save'], '" class="button_submit" />
  1186. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1187. </div>
  1188. </form>
  1189. </div>
  1190. <span class="botslice"><span></span></span>
  1191. </div>
  1192. </div>
  1193. <br class="clear" />';
  1194. }
  1195. function template_control_chmod()
  1196. {
  1197. global $context, $settings, $options, $txt, $scripturl;
  1198. // Nothing to do? Brilliant!
  1199. if (empty($context['package_ftp']))
  1200. return false;
  1201. if (empty($context['package_ftp']['form_elements_only']))
  1202. {
  1203. echo '
  1204. ', sprintf($txt['package_ftp_why'], 'document.getElementById(\'need_writable_list\').style.display = \'\'; return false;'), '<br />
  1205. <div id="need_writable_list" class="smalltext">
  1206. ', $txt['package_ftp_why_file_list'], '
  1207. <ul style="display: inline;">';
  1208. if (!empty($context['notwritable_files']))
  1209. foreach ($context['notwritable_files'] as $file)
  1210. echo '
  1211. <li>', $file, '</li>';
  1212. echo '
  1213. </ul>
  1214. </div>';
  1215. }
  1216. echo '
  1217. <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;">
  1218. <tt id="ftp_error_message">', !empty($context['package_ftp']['error']) ? $context['package_ftp']['error'] : '', '</tt>
  1219. </div></div>';
  1220. if (!empty($context['package_ftp']['destination']))
  1221. echo '
  1222. <form action="', $context['package_ftp']['destination'], '" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">';
  1223. echo '
  1224. <fieldset>
  1225. <dl class="settings">
  1226. <dt>
  1227. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  1228. </dt>
  1229. <dd>
  1230. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', $context['package_ftp']['server'], '" class="input_text" />
  1231. <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" />
  1232. </dd>
  1233. <dt>
  1234. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  1235. </dt>
  1236. <dd>
  1237. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', $context['package_ftp']['username'], '" style="width: 98%;" class="input_text" />
  1238. </dd>
  1239. <dt>
  1240. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  1241. </dt>
  1242. <dd>
  1243. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 98%;" class="input_password" />
  1244. </dd>
  1245. <dt>
  1246. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  1247. </dt>
  1248. <dd>
  1249. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 98%;" class="input_text" />
  1250. </dd>
  1251. </dl>
  1252. </fieldset>';
  1253. if (empty($context['package_ftp']['form_elements_only']))
  1254. echo '
  1255. <div class="righttext" style="margin: 1ex;">
  1256. <span id="test_ftp_placeholder_full"></span>
  1257. <input type="submit" value="', $txt['package_proceed'], '" class="button_submit" />
  1258. </div>';
  1259. if (!empty($context['package_ftp']['destination']))
  1260. echo '
  1261. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1262. </form>';
  1263. // Hide the details of the list.
  1264. if (empty($context['package_ftp']['form_elements_only']))
  1265. echo '
  1266. <script type="text/javascript"><!-- // --><![CDATA[
  1267. document.getElementById(\'need_writable_list\').style.display = \'none\';
  1268. // ]]></script>';
  1269. // Quick generate the test button.
  1270. echo '
  1271. <script type="text/javascript"><!-- // --><![CDATA[
  1272. // Generate a "test ftp" button.
  1273. var generatedButton = false;
  1274. function generateFTPTest()
  1275. {
  1276. // Don\'t ever call this twice!
  1277. if (generatedButton)
  1278. return false;
  1279. generatedButton = true;
  1280. // No XML?
  1281. if (!window.XMLHttpRequest || (!document.getElementById("test_ftp_placeholder") && !document.getElementById("test_ftp_placeholder_full")))
  1282. return false;
  1283. var ftpTest = document.createElement("input");
  1284. ftpTest.type = "button";
  1285. ftpTest.onclick = testFTP;
  1286. if (document.getElementById("test_ftp_placeholder"))
  1287. {
  1288. ftpTest.value = "', $txt['package_ftp_test'], '";
  1289. document.getElementById("test_ftp_placeholder").appendChild(ftpTest);
  1290. }
  1291. else
  1292. {
  1293. ftpTest.value = "', $txt['package_ftp_test_connection'], '";
  1294. document.getElementById("test_ftp_placeholder_full").appendChild(ftpTest);
  1295. }
  1296. }
  1297. function testFTPResults(oXMLDoc)
  1298. {
  1299. ajax_indicator(false);
  1300. // This assumes it went wrong!
  1301. var wasSuccess = false;
  1302. var message = "', addcslashes($txt['package_ftp_test_failed'], "'"), '";
  1303. var results = oXMLDoc.getElementsByTagName(\'results\')[0].getElementsByTagName(\'result\');
  1304. if (results.length > 0)
  1305. {
  1306. if (results[0].getAttribute(\'success\') == 1)
  1307. wasSuccess = true;
  1308. message = results[0].firstChild.nodeValue;
  1309. }
  1310. document.getElementById("ftp_error_div").style.display = "";
  1311. document.getElementById("ftp_error_div").style.backgroundColor = wasSuccess ? "green" : "red";
  1312. document.getElementById("ftp_error_innerdiv").style.backgroundColor = wasSuccess ? "#DBFDC7" : "#FDBDBD";
  1313. setInnerHTML(document.getElementById("ftp_error_message"), message);
  1314. }
  1315. generateFTPTest();
  1316. // ]]></script>';
  1317. // Make sure the button gets generated last.
  1318. $context['insert_after_template'] .= '
  1319. <script type="text/javascript"><!-- // --><![CDATA[
  1320. generateFTPTest();
  1321. // ]]></script>';
  1322. }
  1323. function template_ftp_required()
  1324. {
  1325. global $context, $settings, $options, $txt, $scripturl;
  1326. echo '
  1327. <fieldset>
  1328. <legend>
  1329. ', $txt['package_ftp_necessary'], '
  1330. </legend>
  1331. <div class="ftp_details">
  1332. ', template_control_chmod(), '
  1333. </div>
  1334. </fieldset>';
  1335. }
  1336. function template_view_operations()
  1337. {
  1338. global $context, $txt, $settings;
  1339. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  1340. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  1341. <head>
  1342. <title>', $txt['operation_title'], '</title>
  1343. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  1344. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index.css" />
  1345. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/admin.css" />
  1346. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js?fin20"></script>
  1347. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/theme.js?fin20"></script>
  1348. </head>
  1349. <body>
  1350. <div class="padding windowbg">
  1351. <div class="padding">
  1352. ', $context['operations']['search'], '
  1353. </div>
  1354. <div class="padding">
  1355. ', $context['operations']['replace'], '
  1356. </div>
  1357. </div>
  1358. </body>
  1359. </html>';
  1360. }
  1361. function template_file_permissions()
  1362. {
  1363. global $txt, $scripturl, $context, $settings;
  1364. // This will handle expanding the selection.
  1365. echo '
  1366. <script type="text/javascript"><!-- // --><![CDATA[
  1367. var oRadioColors = {
  1368. 0: "#D1F7BF",
  1369. 1: "#FFBBBB",
  1370. 2: "#FDD7AF",
  1371. 3: "#C2C6C0",
  1372. 4: "#EEEEEE"
  1373. }
  1374. var oRadioValues = {
  1375. 0: "read",
  1376. 1: "writable",
  1377. 2: "execute",
  1378. 3: "custom",
  1379. 4: "no_change"
  1380. }
  1381. function dynamicAddMore()
  1382. {
  1383. ajax_indicator(true);
  1384. 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);
  1385. }
  1386. // Getting something back?
  1387. function onNewFolderReceived(oXMLDoc)
  1388. {
  1389. ajax_indicator(false);
  1390. var fileItems = oXMLDoc.getElementsByTagName(\'folders\')[0].getElementsByTagName(\'folder\');
  1391. // No folders, no longer worth going further.
  1392. if (fileItems.length < 1)
  1393. {
  1394. if (oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0])
  1395. {
  1396. var rootName = oXMLDoc.getElementsByTagName(\'roots\')[0].getElementsByTagName(\'root\')[0].firstChild.nodeValue;
  1397. var itemLink = document.getElementById(\'link_\' + rootName);
  1398. // Move the children up.
  1399. for (i = 0; i <= itemLink.childNodes.length; i++)
  1400. itemLink.parentNode.insertBefore(itemLink.childNodes[0], itemLink);
  1401. // And remove the link.
  1402. itemLink.parentNode.removeChild(itemLink);
  1403. }
  1404. return false;
  1405. }
  1406. var tableHandle = false;
  1407. var isMore = false;
  1408. var ident = "";
  1409. var my_ident = "";
  1410. var curLevel = 0;
  1411. for (var i = 0; i < fileItems.length; i++)
  1412. {
  1413. if (fileItems[i].getAttribute(\'more\') == 1)
  1414. {
  1415. isMore = true;
  1416. var curOffset = fileItems[i].getAttribute(\'offset\');
  1417. }
  1418. if (fileItems[i].getAttribute(\'more\') != 1 && document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\')))
  1419. {
  1420. ident = fileItems[i].getAttribute(\'ident\');
  1421. my_ident = fileItems[i].getAttribute(\'my_ident\');
  1422. curLevel = fileItems[i].getAttribute(\'level\') * 5;
  1423. curPath = fileItems[i].getAttribute(\'path\');
  1424. // Get where we\'re putting it next to.
  1425. tableHandle = document.getElementById("insert_div_loc_" + fileItems[i].getAttribute(\'ident\'));
  1426. var curRow = document.createElement("tr");
  1427. curRow.className = "windowbg";
  1428. curRow.id = "content_" + my_ident;
  1429. curRow.style.display = "";
  1430. var curCol = document.createElement("td");
  1431. curCol.className = "smalltext";
  1432. curCol.width = "40%";
  1433. // This is the name.
  1434. var fileName = document.createTextNode(fileItems[i].firstChild.nodeValue);
  1435. // Start by wacking in the spaces.
  1436. setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
  1437. // Create the actual text.
  1438. if (fileItems[i].getAttribute(\'folder\') == 1)
  1439. {
  1440. var linkData = document.createElement("a");
  1441. linkData.name = "fol_" + my_ident;
  1442. linkData.id = "link_" + my_ident;
  1443. linkData.href = \'#\';
  1444. linkData.path = curPath + "/" + fileItems[i].firstChild.nodeValue;
  1445. linkData.ident = my_ident;
  1446. linkData.onclick = dynamicExpandFolder;
  1447. var folderImage = document.createElement("img");
  1448. folderImage.src = \'', addcslashes($settings['default_images_url'], "\\"), '/board.gif\';
  1449. linkData.appendChild(folderImage);
  1450. linkData.appendChild(fileName);
  1451. curCol.appendChild(linkData);
  1452. }
  1453. else
  1454. curCol.appendChild(fileName);
  1455. curRow.appendChild(curCol);
  1456. // Right, the permissions.
  1457. curCol = document.createElement("td");
  1458. curCol.className = "smalltext";
  1459. var writeSpan = document.createElement("span");
  1460. writeSpan.style.color = fileItems[i].getAttribute(\'writable\') ? "green" : "red";
  1461. setInnerHTML(writeSpan, fileItems[i].getAttribute(\'writable\') ? \'', $txt['package_file_perms_writable'], '\' : \'', $txt['package_file_perms_not_writable'], '\');
  1462. curCol.appendChild(writeSpan);
  1463. if (fileItems[i].getAttribute(\'permissions\'))
  1464. {
  1465. var permData = document.createTextNode("\u00a0(', $txt['package_file_perms_chmod'], ': " + fileItems[i].getAttribute(\'permissions\') + ")");
  1466. curCol.appendChild(permData);
  1467. }
  1468. curRow.appendChild(curCol);
  1469. // Now add the five radio buttons.
  1470. for (j = 0; j < 5; j++)
  1471. {
  1472. curCol = document.createElement("td");
  1473. curCol.style.backgroundColor = oRadioColors[j];
  1474. curCol.align = "center";
  1475. var curInput = createNamedElement("input", "permStatus[" + curPath + "/" + fileItems[i].firstChild.nodeValue + "]", j == 4 ? \'checked="checked"\' : "");
  1476. curInput.type = "radio";
  1477. curInput.checked = "checked";
  1478. curInput.value = oRadioValues[j];
  1479. curCol.appendChild(curInput);
  1480. curRow.appendChild(curCol);
  1481. }
  1482. // Put the row in.
  1483. tableHandle.parentNode.insertBefore(curRow, tableHandle);
  1484. // Put in a new dummy section?
  1485. if (fileItems[i].getAttribute(\'folder\') == 1)
  1486. {
  1487. var newRow = document.createElement("tr");
  1488. newRow.id = "insert_div_loc_" + my_ident;
  1489. newRow.style.display = "none";
  1490. tableHandle.parentNode.insertBefore(newRow, tableHandle);
  1491. var newCol = document.createElement("td");
  1492. newCol.colspan = 2;
  1493. newRow.appendChild(newCol);
  1494. }
  1495. }
  1496. }
  1497. // Is there some more to remove?
  1498. if (document.getElementById("content_" + ident + "_more"))
  1499. {
  1500. document.getElementById("content_" + ident + "_more").parentNode.removeChild(document.getElementById("content_" + ident + "_more"));
  1501. }
  1502. // Add more?
  1503. if (isMore && tableHandle)
  1504. {
  1505. // Create the actual link.
  1506. var linkData = document.createElement("a");
  1507. linkData.href = \'#fol_\' + my_ident;
  1508. linkData.path = curPath;
  1509. linkData.offset = curOffset;
  1510. linkData.onclick = dynamicAddMore;
  1511. linkData.appendChild(document.createTextNode(\'', $txt['package_file_perms_more_files'], '\'));
  1512. curRow = document.createElement("tr");
  1513. curRow.className = "windowbg";
  1514. curRow.id = "content_" + ident + "_more";
  1515. tableHandle.parentNode.insertBefore(curRow, tableHandle);
  1516. curCol = document.createElement("td");
  1517. curCol.className = "smalltext";
  1518. curCol.width = "40%";
  1519. setInnerHTML(curCol, repeatString("&nbsp;", curLevel));
  1520. curCol.appendChild(document.createTextNode(\'\\u00ab \'));
  1521. curCol.appendChild(linkData);
  1522. curCol.appendChild(document.createTextNode(\' \\u00bb\'));
  1523. curRow.appendChild(curCol);
  1524. curCol = document.createElement("td");
  1525. curCol.className = "smalltext";
  1526. curRow.appendChild(curCol);
  1527. }
  1528. // Keep track of it.
  1529. var curInput = createNamedElement("input", "back_look[]");
  1530. curInput.type = "hidden";
  1531. curInput.value = curPath;
  1532. curCol.appendChild(curInput);
  1533. }
  1534. // ]]></script>';
  1535. echo '
  1536. <div class="information">
  1537. <div>
  1538. <strong>', $txt['package_file_perms_warning'], ':</strong>
  1539. <div class="smalltext">
  1540. <ol style="margin-top: 2px; margin-bottom: 2px">
  1541. ', $txt['package_file_perms_warning_desc'], '
  1542. </ol>
  1543. </div>
  1544. </div>
  1545. </div>
  1546. <form action="', $scripturl, '?action=admin;area=packages;sa=perms;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  1547. <div class="title_bar">
  1548. <h3 class="titlebg">
  1549. <span class="floatleft">', $txt['package_file_perms'], '</span><span class="fperm floatright">', $txt['package_file_perms_new_status'], '</span>
  1550. </h3>
  1551. </div>
  1552. <table width="100%" class="table_grid">
  1553. <thead>
  1554. <tr class="catbg">
  1555. <th class="first_th lefttext" width="30%">&nbsp;', $txt['package_file_perms_name'], '&nbsp;</th>
  1556. <th width="30%" class="lefttext">', $txt['package_file_perms_status'], '</th>
  1557. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_read'], '</span></th>
  1558. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_write'], '</span></th>
  1559. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_execute'], '</span></th>
  1560. <th align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_custom'], '</span></th>
  1561. <th class="last_th" align="center" width="8%"><span class="filepermissions">', $txt['package_file_perms_status_no_change'], '</span></th>
  1562. </tr>
  1563. </thead>';
  1564. foreach ($context['file_tree'] as $name => $dir)
  1565. {
  1566. echo '
  1567. <tbody>
  1568. <tr class="windowbg2">
  1569. <td width="30%"><strong>';
  1570. if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
  1571. echo '
  1572. <img src="', $settings['default_images_url'], '/board.gif" alt="*" />';
  1573. echo '
  1574. ', $name, '
  1575. </strong></td>
  1576. <td width="30%">
  1577. <span style="color: ', ($dir['perms']['chmod'] ? 'green' : 'red'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span>
  1578. ', ($dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), '
  1579. </td>
  1580. <td align="center" class="perm_read" width="8%"><input type="radio" name="permStatus[', $name, ']" value="read" class="input_radio" /></td>
  1581. <td align="center" class="perm_write" width="8%"><input type="radio" name="permStatus[', $name, ']" value="writable" class="input_radio" /></td>
  1582. <td align="center" class="perm_execute" width="8%"><input type="radio" name="permStatus[', $name, ']" value="execute" class="input_radio" /></td>
  1583. <td align="center" class="perm_custom" width="8%"><input type="radio" name="permStatus[', $name, ']" value="custom" class="input_radio" /></td>
  1584. <td align="center" class="perm_nochange" width="8%"><input type="radio" name="permStatus[', $name, ']" value="no_change" checked="checked" class="input_radio" /></td>
  1585. </tr>
  1586. </tbody>';
  1587. if (!empty($dir['contents']))
  1588. template_permission_show_contents($name, $dir['contents'], 1);
  1589. }
  1590. echo '
  1591. </table>
  1592. <br />
  1593. <div class="cat_bar">
  1594. <h3 class="catbg">', $txt['package_file_perms_change'], '</h3>
  1595. </div>
  1596. <div class="windowbg">
  1597. <span class="topslice"><span></span></span>
  1598. <div class="content">
  1599. <fieldset>
  1600. <dl>
  1601. <dt>
  1602. <input type="radio" name="method" value="individual" checked="checked" id="method_individual" class="input_radio" />
  1603. <label for="method_individual"><strong>', $txt['package_file_perms_apply'], '</strong></label>
  1604. </dt>
  1605. <dd>
  1606. <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>
  1607. </dd>
  1608. <dt>
  1609. <input type="radio" name="method" value="predefined" id="method_predefined" class="input_radio" />
  1610. <label for="method_predefined"><strong>', $txt['package_file_perms_predefined'], ':</strong></label>
  1611. <select name="predefined" onchange="document.getElementById(\'method_predefined\').checked = \'checked\';">
  1612. <option value="restricted" selected="selected">', $txt['package_file_perms_pre_restricted'], '</option>
  1613. <option value="standard">', $txt['package_file_perms_pre_standard'], '</option>
  1614. <option value="free">', $txt['package_file_perms_pre_free'], '</option>
  1615. </select>
  1616. </dt>
  1617. <dd>
  1618. <em class="smalltext">', $txt['package_file_perms_predefined_note'], '</em>
  1619. </dd>
  1620. </dl>
  1621. </fieldset>';
  1622. // Likely to need FTP?
  1623. if (empty($context['ftp_connected']))
  1624. echo '
  1625. <p>
  1626. ', $txt['package_file_perms_ftp_details'], ':
  1627. </p>
  1628. ', template_control_chmod(), '
  1629. <div class="information">', $txt['package_file_perms_ftp_retain'], '</div>';
  1630. echo '
  1631. <span id="test_ftp_placeholder_full"></span>
  1632. <div class="righttext padding">
  1633. <input type="hidden" name="action_changes" value="1" />
  1634. <input type="submit" value="', $txt['package_file_perms_go'], '" name="go" class="button_submit" />
  1635. </div>
  1636. </div>
  1637. <span class="botslice"><span></span></span>
  1638. </div>';
  1639. // Any looks fors we've already done?
  1640. foreach ($context['look_for'] as $path)
  1641. echo '
  1642. <input type="hidden" name="back_look[]" value="', $path, '" />';
  1643. echo '
  1644. </form><br />';
  1645. }
  1646. function template_permission_show_contents($ident, $contents, $level, $has_more = false)
  1647. {
  1648. global $settings, $txt, $scripturl, $context;
  1649. $js_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident);
  1650. // Have we actually done something?
  1651. $drawn_div = false;
  1652. foreach ($contents as $name => $dir)
  1653. {
  1654. if (isset($dir['perms']))
  1655. {
  1656. if (!$drawn_div)
  1657. {
  1658. $drawn_div = true;
  1659. echo '
  1660. </table>
  1661. <table border="0" width="100%" class="table_grid" id="', $js_ident, '">';
  1662. }
  1663. $cur_ident = preg_replace('~[^A-Za-z0-9_\-=:]~', ':-:', $ident . '/' . $name);
  1664. echo '
  1665. <tr class="windowbg" id="content_', $cur_ident, '">
  1666. <td class="smalltext" width="30%">' . str_repeat('&nbsp;', $level * 5), '
  1667. ', (!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, "'\\") . '\');">' : '';
  1668. if (!empty($dir['type']) && ($dir['type'] == 'dir' || $dir['type'] == 'dir_recursive'))
  1669. echo '
  1670. <img src="', $settings['default_images_url'], '/board.gif" alt="*" />';
  1671. echo '
  1672. ', $name, '
  1673. ', (!empty($dir['type']) && $dir['type'] == 'dir_recursive') || !empty($dir['list_contents']) ? '</a>' : '', '
  1674. </td>
  1675. <td class="smalltext">
  1676. <span class="', ($dir['perms']['chmod'] ? 'success' : 'error'), '">', ($dir['perms']['chmod'] ? $txt['package_file_perms_writable'] : $txt['package_file_perms_not_writable']), '</span>
  1677. ', ($dir['perms']['perms'] ? '&nbsp;(' . $txt['package_file_perms_chmod'] . ': ' . substr(sprintf('%o', $dir['perms']['perms']), -4) . ')' : ''), '
  1678. </td>
  1679. <td align="center" width="8%" class="perm_read"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="read" class="input_radio" /></td>
  1680. <td align="center" width="8%" class="perm_write"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="writable" class="input_radio" /></td>
  1681. <td align="center" width="8%" class="perm_execute"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="execute" class="input_radio" /></td>
  1682. <td align="center" width="8%" class="perm_custom"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="custom" class="input_radio" /></td>
  1683. <td align="center" width="8%" class="perm_nochange"><input type="radio" name="permStatus[', $ident . '/' . $name, ']" value="no_change" checked="checked" class="input_radio" /></td>
  1684. </tr>
  1685. <tr id="insert_div_loc_' . $cur_ident . '" style="display: none;"><td></td></tr>';
  1686. if (!empty($dir['contents']))
  1687. {
  1688. template_permission_show_contents($ident . '/' . $name, $dir['contents'], $level + 1, !empty($dir['more_files']));
  1689. }
  1690. }
  1691. }
  1692. // We have more files to show?
  1693. if ($has_more)
  1694. echo '
  1695. <tr class="windowbg" id="content_', $js_ident, '_more">
  1696. <td class="smalltext" width="40%">' . str_repeat('&nbsp;', $level * 5), '
  1697. &#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;
  1698. </td>
  1699. <td colspan="6"></td>
  1700. </tr>';
  1701. if ($drawn_div)
  1702. {
  1703. // Hide anything too far down the tree.
  1704. $isFound = false;
  1705. foreach ($context['look_for'] as $tree)
  1706. {
  1707. if (substr($tree, 0, strlen($ident)) == $ident)
  1708. $isFound = true;
  1709. }
  1710. if ($level > 1 && !$isFound)
  1711. echo '
  1712. </table><script type="text/javascript"><!-- // --><![CDATA[
  1713. expandFolder(\'', $js_ident, '\', \'\');
  1714. // ]]></script>
  1715. <table border="0" width="100%" class="table_grid">
  1716. <tr style="display: none;"><td></td></tr>';
  1717. }
  1718. }
  1719. function template_action_permissions()
  1720. {
  1721. global $txt, $scripturl, $context, $settings;
  1722. $countDown = 3;
  1723. echo '
  1724. <div id="admincenter">
  1725. <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'], '">
  1726. <div class="cat_bar">
  1727. <h3 class="catbg">', $txt['package_file_perms_applying'], '</h3>
  1728. </div>';
  1729. if (!empty($context['skip_ftp']))
  1730. echo '
  1731. <div class="errorbox">
  1732. ', $txt['package_file_perms_skipping_ftp'], '
  1733. </div>';
  1734. // How many have we done?
  1735. $remaining_items = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
  1736. $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']);
  1737. $progress_percent = round(($context['total_items'] - $remaining_items) / $context['total_items'] * 100, 1);
  1738. echo '
  1739. <div class="windowbg">
  1740. <span class="topslice"><span></span></span>
  1741. <div class="content">
  1742. <div style="padding-left: 20%; padding-right: 20%; margin-top: 1ex;">
  1743. <strong>', $progress_message, '</strong>
  1744. <div style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
  1745. <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>
  1746. <div style="width: ', $progress_percent, '%; height: 12pt; z-index: 1; background-color: #98b8f4;">&nbsp;</div>
  1747. </div>
  1748. </div>';
  1749. // Second progress bar for a specific directory?
  1750. if ($context['method'] != 'individual' && !empty($context['total_files']))
  1751. {
  1752. $file_progress_message = sprintf($txt['package_file_perms_files_done'], $context['file_offset'], $context['total_files']);
  1753. $file_progress_percent = round($context['file_offset'] / $context['total_files'] * 100, 1);
  1754. echo '
  1755. <br />
  1756. <div style="padding-left: 20%; padding-right: 20%; margin-top: 1ex;">
  1757. <strong>', $file_progress_message, '</strong>
  1758. <div style="font-size: 8pt; height: 12pt; border: 1px solid black; background-color: white; padding: 1px; position: relative;">
  1759. <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>
  1760. <div style="width: ', $file_progress_percent, '%; height: 12pt; z-index: 1; background-color: #c1ffc1;">&nbsp;</div>
  1761. </div>
  1762. </div>';
  1763. }
  1764. echo '
  1765. <br />';
  1766. // Put out the right hidden data.
  1767. if ($context['method'] == 'individual')
  1768. echo '
  1769. <input type="hidden" name="custom_value" value="', $context['custom_value'], '" />
  1770. <input type="hidden" name="totalItems" value="', $context['total_items'], '" />
  1771. <input type="hidden" name="toProcess" value="', base64_encode(serialize($context['to_process'])), '" />';
  1772. else
  1773. echo '
  1774. <input type="hidden" name="predefined" value="', $context['predefined_type'], '" />
  1775. <input type="hidden" name="fileOffset" value="', $context['file_offset'], '" />
  1776. <input type="hidden" name="totalItems" value="', $context['total_items'], '" />
  1777. <input type="hidden" name="dirList" value="', base64_encode(serialize($context['directory_list'])), '" />
  1778. <input type="hidden" name="specialFiles" value="', base64_encode(serialize($context['special_files'])), '" />';
  1779. // Are we not using FTP for whatever reason.
  1780. if (!empty($context['skip_ftp']))
  1781. echo '
  1782. <input type="hidden" name="skip_ftp" value="1" />';
  1783. // Retain state.
  1784. foreach ($context['back_look_data'] as $path)
  1785. echo '
  1786. <input type="hidden" name="back_look[]" value="', $path, '" />';
  1787. echo '
  1788. <input type="hidden" name="method" value="', $context['method'], '" />
  1789. <input type="hidden" name="action_changes" value="1" />
  1790. <div class="righttext padding">
  1791. <input type="submit" name="go" id="cont" value="', $txt['not_done_continue'], '" class="button_submit" />
  1792. </div>
  1793. </div>
  1794. <span class="botslice"><span></span></span>
  1795. </div>
  1796. </form>
  1797. </div>
  1798. <br class="clear" />';
  1799. // Just the countdown stuff
  1800. echo '
  1801. <script type="text/javascript"><!-- // --><![CDATA[
  1802. var countdown = ', $countDown, ';
  1803. doAutoSubmit();
  1804. function doAutoSubmit()
  1805. {
  1806. if (countdown == 0)
  1807. document.forms.perm_submit.submit();
  1808. else if (countdown == -1)
  1809. return;
  1810. document.getElementById(\'cont\').value = "', $txt['not_done_continue'], ' (" + countdown + ")";
  1811. countdown--;
  1812. setTimeout("doAutoSubmit();", 1000);
  1813. }
  1814. // ]]></script>';
  1815. }
  1816. ?>