Packages.template.php 67 KB

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