Packages.template.php 63 KB

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