index.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2024
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //set a timeout
  22. set_time_limit(15*60); //15 minutes
  23. //includes files
  24. require_once dirname(__DIR__, 2) . "/resources/require.php";
  25. require_once "resources/check_auth.php";
  26. //check the permission
  27. if (
  28. !permission_exists('upgrade_source') &&
  29. !permission_exists('upgrade_schema') &&
  30. !permission_exists('upgrade_apps') &&
  31. !permission_exists('menu_restore') &&
  32. !permission_exists('group_edit')
  33. ) {
  34. echo "access denied";
  35. exit;
  36. }
  37. //connect to the database
  38. $database = new database;
  39. //add multi-lingual support
  40. $language = new text;
  41. $text = $language->get();
  42. //set a default message_timeout
  43. $message_timeout = 4*1000;
  44. //find optional apps with repos
  45. $updateable_repos = git_find_repos($_SERVER["PROJECT_ROOT"]."/app");
  46. if (!empty($updateable_repos) && is_array($updateable_repos) && @sizeof($updateable_repos) != 0) {
  47. foreach ($updateable_repos as $app_path => $repo) {
  48. $x = 0;
  49. include $app_path.'/app_config.php';
  50. $updateable_repos[$app_path]['app'] = $repo[0];
  51. $updateable_repos[$app_path]['name'] = $apps[$x]['name'];
  52. $updateable_repos[$app_path]['uuid'] = $apps[$x]['uuid'];
  53. $updateable_repos[$app_path]['version'] = $apps[$x]['version'];
  54. $updateable_repos[$app_path]['description'] = $apps[$x]['description'][$_SESSION['domain']['language']['code']];
  55. unset($apps, $updateable_repos[$app_path][0]);
  56. }
  57. }
  58. //count upgradeable repos including + main repo
  59. $repos_count = 0;
  60. if (is_array($updateable_repos)) { $repos_count = @sizeof($updateable_repos); }
  61. $repos_count++;
  62. //process the http post
  63. if (!empty($_POST) && @sizeof($_POST) > 0) {
  64. //get the action options: source, schema, app_defaults, menu_defaults, permisisons
  65. $action = $_POST['action'] ?? null;
  66. //run source update
  67. if (!empty($action["upgrade_source"]) && permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx")) {
  68. $project_update_status = git_pull($_SERVER["PROJECT_ROOT"]);
  69. $_SESSION["response"]["upgrade_source"] = $project_update_status['message'];
  70. if (!empty($project_update_status['result'])) {
  71. message::add($text['message-upgrade_source'], null, $message_timeout);
  72. }
  73. else {
  74. message::add($text['message-upgrade_source_failed'], 'negative', $message_timeout);
  75. }
  76. }
  77. //run optional app source updates
  78. if (!empty($action["optional_apps"]) && permission_exists("upgrade_source")) {
  79. $apps_updated = $apps_failed = 0;
  80. if (is_array($action["optional_apps"])) {
  81. foreach ($updateable_repos as $app_path => $app_details) {
  82. if (array_search(basename($app_path), $action["optional_apps"]) !== false) {
  83. $git_result = git_pull($app_path);
  84. if (!empty($git_result['result'])) {
  85. $apps_updated++;
  86. }
  87. else {
  88. $apps_failed++;
  89. }
  90. $_SESSION["response"]["optional_apps"][$app_details['name']] = $git_result['message'];
  91. }
  92. }
  93. }
  94. if ($apps_updated != 0) { message::add($text['message-optional_apps_upgrade_source'], null, $message_timeout); }
  95. if ($apps_failed != 0) { message::add($text['message-optional_apps_upgrade_source_failed'], 'negative', $message_timeout); }
  96. }
  97. //load an array of the database schema and compare it with the active database
  98. if (!empty($action["upgrade_schema"]) && permission_exists("upgrade_schema")) {
  99. require_once "resources/classes/schema.php";
  100. $obj = new schema();
  101. if (isset($action["data_types"]) && $action["data_types"] == 'true') {
  102. $obj->data_types = true;
  103. }
  104. $_SESSION["response"]["schema"] = $obj->schema("html");
  105. message::add($text['message-upgrade_schema'], null, $message_timeout);
  106. }
  107. //process the apps defaults
  108. if (!empty($action["app_defaults"]) && permission_exists("upgrade_apps")) {
  109. require_once "resources/classes/domains.php";
  110. $domain = new domains;
  111. $domain->upgrade();
  112. message::add($text['message-upgrade_apps'], null, $message_timeout);
  113. }
  114. //restore defaults of the selected menu
  115. if (!empty($action["menu_defaults"]) && permission_exists("menu_restore")) {
  116. $sel_menu = explode('|', check_str($_POST["sel_menu"]));
  117. $menu_uuid = $sel_menu[0];
  118. $menu_language = $sel_menu[1];
  119. $included = true;
  120. require_once("core/menu/menu_restore_default.php");
  121. unset($sel_menu);
  122. $text = $language->get(null, '/core/upgrade');
  123. message::add($text['message-upgrade_menu'], null, $message_timeout);
  124. }
  125. //restore default permissions
  126. if (!empty($action["permission_defaults"]) && permission_exists("group_edit")) {
  127. $included = true;
  128. require_once("core/groups/permissions_default.php");
  129. $text = $language->get(null, '/core/upgrade');
  130. message::add($text['message-upgrade_permissions'], null, $message_timeout);
  131. }
  132. //redirect the browser
  133. header("Location: ".PROJECT_PATH."/core/upgrade/index.php");
  134. exit;
  135. }
  136. //process the http get (source preview)
  137. if (!empty($_GET['preview'])) {
  138. if (!empty($updateable_repos)) {
  139. foreach ($updateable_repos as $app_path => $app) {
  140. $repo_info = git_repo_info($app_path);
  141. if (empty($repo_info)) { continue; }
  142. $source_code[$app['app']] = $app_path;
  143. }
  144. }
  145. if ($_GET['preview'] == 'core') {
  146. $command = 'cd '.$_SERVER['PROJECT_ROOT'].' && git fetch && git diff --name-only @ @{u}';
  147. }
  148. else if (array_key_exists($_GET['preview'], $source_code)) {
  149. $command = 'cd '.$source_code[$_GET['preview']].' && git fetch && git diff --name-only @ @{u}';
  150. }
  151. if (!empty($command)) {
  152. $response = explode(PHP_EOL, shell_exec($command));
  153. // simplify response
  154. if (!empty($response)) {
  155. foreach ($response as $l => $line) {
  156. if (empty($line)) { unset($response[$l]); }
  157. if (substr($line, 0, 8) == 'remote: ') { unset($response[$l]); }
  158. if (substr($line, 0, 8) == 'remote: ') { unset($response[$l]); }
  159. if (substr($line, 0, 19) == 'Unpacking objects: ') { unset($response[$l]); }
  160. if (substr($line, 0, 5) == 'From ') { unset($response[$l]); }
  161. if (substr($line, 0, 3) == ' ') { unset($response[$l]); }
  162. }
  163. }
  164. echo "<button type='button' class='btn btn-default' style='float: right;' onclick=\"$('#source_preview_layer').fadeOut(200);\">".$text['button-close']."</button>\n";
  165. echo "<b>".$text['header-source_code_upgrade_preview']."</b>\n";
  166. echo "<br><br>\n";
  167. if (!empty($response) && is_array($response)) {
  168. echo str_replace('APP_NAME', (!empty($_GET['title']) ? "<strong>".$_GET['title']."</strong>" : null), $text['description-source_code_changes_found']);
  169. echo "<br><br><br>\n";
  170. echo "<div style='width: 100%; max-height: 250px; overflow: auto; border: 1px solid ".($_SESSION['theme']['table_row_border_color']['text'] ?? '#c5d1e5')."; padding: 12px 15px; background-color: ".($_SESSION['theme']['table_row_background_color_light']['text'] ?? '#fff')."; font-family: monospace; font-size: 85%; color: green;'>\n";
  171. if (!empty($response) && is_array($response)) {
  172. echo implode("<br>\n<hr style='margin: 3px 0;'>\n", $response);
  173. }
  174. echo "</div>\n";
  175. }
  176. else {
  177. echo str_replace('APP_NAME', (!empty($_GET['title']) ? "<strong>".$_GET['title']."</strong>" : null), $text['description-source_code_no_changes_found']);
  178. }
  179. echo "<br><br>\n";
  180. echo "<center>\n";
  181. echo " <button type='button' class='btn btn-default' style='margin-top: 15px;' onclick=\"$('#source_preview_layer').fadeOut(200);\">".$text['button-close']."</button>\n";
  182. echo "</center>\n";
  183. exit;
  184. }
  185. }
  186. //adjust color and initialize step counter
  187. $step = 1;
  188. $step_color = isset($_SESSION['theme']['upgrade_step_color']['text']) ? $_SESSION['theme']['upgrade_step_color']['text'] : color_adjust((!empty($_SESSION['theme']['form_table_label_background_color']['text']) ? $_SESSION['theme']['form_table_label_background_color']['text'] : '#e5e9f0'), -0.1);
  189. $step_container_style = "width: 30px; height: 30px; border: 2px solid ".$step_color."; border-radius: 50%; float: left; text-align: center; vertical-align: middle;";
  190. $step_number_style = "font-size: 150%; font-weight: 600; color: ".$step_color.";";
  191. //include the header and set the title
  192. $document['title'] = $text['title-upgrade'];
  193. require_once "resources/header.php";
  194. //source preview layer
  195. echo "<style>\n";
  196. echo " #source_preview_layer {\n";
  197. echo " z-index: 999999;\n";
  198. echo " position: absolute;\n";
  199. echo " left: 0px;\n";
  200. echo " top: 0px;\n";
  201. echo " right: 0px;\n";
  202. echo " bottom: 0px;\n";
  203. echo " text-align: center;\n";
  204. echo " vertical-align: middle;\n";
  205. echo " }\n";
  206. echo " #source_preview_container {\n";
  207. echo " display: block;\n";
  208. echo " overflow: auto;\n";
  209. echo " background-color: #fff;\n";
  210. echo " padding: 25px 25px;\n";
  211. if (http_user_agent('mobile')) {
  212. echo " margin: 0;\n";
  213. }
  214. else {
  215. echo " margin: auto 10%;\n";
  216. }
  217. echo " text-align: left;\n";
  218. echo " -webkit-box-shadow: 0px 1px 20px #888;\n";
  219. echo " -moz-box-shadow: 0px 1px 20px #888;\n";
  220. echo " box-shadow: 0px 1px 20px #888;\n";
  221. echo " }\n";
  222. echo "</style>\n";
  223. echo "<div id='source_preview_layer' style='display: none;'>\n";
  224. echo " <table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>\n";
  225. echo " <tr>\n";
  226. echo " <td align='center' valign='middle'>\n";
  227. echo " <span id='source_preview_container'></span>\n";
  228. echo " </td>\n";
  229. echo " </tr>\n";
  230. echo " </table>\n";
  231. echo "</div>\n";
  232. //show the content
  233. echo "<form name='frm' id='frm' method='post'>\n";
  234. echo "<div class='action_bar' id='action_bar'>\n";
  235. echo " <div class='heading'><b>".$text['header-upgrade']."</b></div>\n";
  236. echo " <div class='actions'>\n";
  237. echo button::create(['type'=>'submit','label'=>$text['button-upgrade_execute'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','collapse'=>'never']);
  238. echo " </div>\n";
  239. echo " <div style='clear: both;'></div>\n";
  240. echo "</div>\n";
  241. echo $text['description-upgrade'];
  242. echo "<br /><br />";
  243. echo "<div class='card'>\n";
  244. if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx") && is_writeable($_SERVER["PROJECT_ROOT"]."/.git")) {
  245. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  246. echo "<tr onclick=\"$('#tr_applications').slideToggle('fast');\">\n";
  247. echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
  248. echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
  249. echo " <div class='mt-1'>".$text['label-upgrade_source']."</div>\n";
  250. echo " </td>\n";
  251. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  252. echo " <div style='float: left; clear: both;'>\n";
  253. echo " <input type='checkbox' id='view_source_code_options' onclick=\"event.stopPropagation(); if (!$(this).prop('checked')) { $('#do_source').prop('checked', false); $('.do_optional_app').prop('checked', false); } else { $('#tr_applications').slideDown('fast'); $('#do_source').prop('checked', true); $('.do_optional_app').prop('checked', true); }\">\n";
  254. echo " </div>\n";
  255. echo " <div style='overflow: hidden;'>\n";
  256. echo " <span onclick=\"event.stopPropagation(); $('#tr_applications').slideToggle('fast');\">&nbsp;&nbsp;".$text['description-update_all_source_files']." (".$repos_count.")</span>\n";
  257. echo " </div>\n";
  258. echo " </td>\n";
  259. echo "</tr>\n";
  260. echo "</table>\n";
  261. echo "<div id='tr_applications' style='display: none;'>\n";
  262. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  263. echo "<tr onclick=\"if (document.getElementById('do_source')) { document.getElementById('do_source').checked = !document.getElementById('do_source').checked; if (document.getElementById('do_source').checked == false) { document.getElementById('view_source_code_options').checked = false; } }\">\n";
  264. echo " <td width='30%' class='vncell' style='vertical-align: middle;'>\n";
  265. echo " ".(isset($_SESSION['theme']['title']['text']) ? $_SESSION['theme']['title']['text'] : 'FusionPBX')."\n";
  266. echo " </td>\n";
  267. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  268. echo " <input type='checkbox' name='action[upgrade_source]' id='do_source' value='1' onclick=\"event.stopPropagation(); if (this.checked == false) { document.getElementById('view_source_code_options').checked = false; }\">\n";
  269. echo " &nbsp;".$text['description-upgrade_source']."<br />\n";
  270. //show current git version info
  271. chdir($_SERVER["PROJECT_ROOT"]);
  272. exec("git rev-parse --abbrev-ref HEAD 2>&1", $git_current_branch, $branch_return_value);
  273. $git_current_branch = $git_current_branch[0];
  274. exec("git log --pretty=format:'%H' -n 1 2>&1", $git_current_commit, $commit_return_value);
  275. $git_current_commit = $git_current_commit[0];
  276. if (!is_numeric($git_current_branch)) {
  277. echo " <span style='font-weight: 600;'>".software::version()."</span>\n";
  278. }
  279. if ($branch_return_value == 0 && $commit_return_value == 0) {
  280. echo " <a href='https://github.com/fusionpbx/fusionpbx/compare/".$git_current_commit."...".$git_current_branch."' target='_blank' title='".$git_current_commit."' onclick=\"event.stopPropagation();\"><i>".$git_current_branch."</i></a>";
  281. echo "&nbsp;&nbsp;<button type='button' class='btn btn-link btn-xs' onclick=\"event.stopPropagation(); source_preview('core','".(isset($_SESSION['theme']['title']['text']) ? $_SESSION['theme']['title']['text'] : 'FusionPBX')."');\">".$text['button-preview']."</button>\n";
  282. }
  283. echo " </td>\n";
  284. echo "</tr>\n";
  285. echo "</table>\n";
  286. if (!empty($updateable_repos) && is_array($updateable_repos)) {
  287. foreach ($updateable_repos as $app_path => $app) {
  288. $repo_info = git_repo_info($app_path);
  289. $pull_method = substr($repo_info['url'], 0, 4) == 'http' ? 'http' : 'ssh';
  290. if (empty($repo_info)) { continue; }
  291. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  292. echo "<tr onclick=\"if (document.getElementById('do_".$app['app']."')) { document.getElementById('do_".$app['app']."').checked = !document.getElementById('do_".$app['app']."').checked; if (document.getElementById('do_".$app['app']."').checked == false) { document.getElementById('view_source_code_options').checked = false; } }\">\n";
  293. echo " <td width='30%' class='vncell' style='vertical-align: middle;'>\n";
  294. echo " ".$app['name']."\n";
  295. echo " </td>\n";
  296. echo " <td width='70%' class='vtable' style='height: 50px; cursor: ".($pull_method == 'http' ? "pointer;'" : "help;' title=\"".$text['message-upgrade_manually'].": ".$repo_info['url']."\"").">\n";
  297. if ($pull_method == 'http') {
  298. echo " <input type='checkbox' name='action[optional_apps][]' class='do_optional_app' id='do_".$app['app']."' value='".$app['app']."' onclick=\"event.stopPropagation(); if (this.checked == false) { document.getElementById('view_source_code_options').checked = false; }\"> &nbsp;".$app['description']."<br />\n";
  299. }
  300. else {
  301. echo " <i class='fas fa-ban mr-3' style='opacity: 0.3; margin: 0 1px;'></i> ".$app['description']."<br>\n";
  302. }
  303. echo " <span style='font-weight: 600;'>".$app['version']."</span>&nbsp;&nbsp;<i><a href='".str_replace(['git@','.com:'],['https://','.com/'], $repo_info['url'])."/compare/".$repo_info['commit']."...".$repo_info['branch']." 'target='_blank' title='".$repo_info['commit']."'>".$repo_info['branch']."</i></a>\n";
  304. echo " &nbsp;&nbsp;<button type='button' class='btn btn-link btn-xs' onclick=\"event.stopPropagation(); source_preview('".$app['app']."','".$app['name']."');\">".$text['button-preview']."</button>\n";
  305. echo " </td>\n";
  306. echo "</tr>\n";
  307. echo "</table>\n";
  308. }
  309. }
  310. echo "</div>\n";
  311. $step++;
  312. }
  313. if (permission_exists("upgrade_schema")) {
  314. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  315. echo "<tr onclick=\"document.getElementById('do_schema').checked = !document.getElementById('do_schema').checked; (!document.getElementById('do_schema').checked ? $('#do_data_types').prop('checked', false) : null); $('#tr_data_types').slideToggle('fast');\">\n";
  316. echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
  317. echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
  318. echo " <div class='mt-1'>".$text['label-upgrade_schema']."</div>\n";
  319. echo " </td>\n";
  320. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  321. echo " <input type='checkbox' name='action[upgrade_schema]' id='do_schema' value='1' onclick=\"event.stopPropagation(); $('#tr_data_types').slideToggle('fast'); (!document.getElementById('do_schema').checked ? $('#do_data_types').prop('checked', false) : null);\"> &nbsp;".$text['description-upgrade_schema']."\n";
  322. echo " </td>\n";
  323. echo "</tr>\n";
  324. echo "</table>\n";
  325. echo "<div id='tr_data_types' style='display: none;'>\n";
  326. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  327. echo "<tr onclick=\"document.getElementById('do_data_types').checked = !document.getElementById('do_data_types').checked;\">\n";
  328. echo " <td width='30%' class='vncell' style='vertical-align: middle;'>\n";
  329. echo " ".$text['label-upgrade_data_types'];
  330. echo " </td>\n";
  331. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  332. echo " <input type='checkbox' name='action[data_types]' id='do_data_types' value='true' onclick=\"event.stopPropagation();\"> &nbsp;".$text['description-upgrade_data_types']."\n";
  333. echo " </td>\n";
  334. echo "</tr>\n";
  335. echo "</table>\n";
  336. echo "</div>\n";
  337. $step++;
  338. }
  339. if (permission_exists("upgrade_apps")) {
  340. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  341. echo "<tr onclick=\"document.getElementById('do_apps').checked = !document.getElementById('do_apps').checked;\">\n";
  342. echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
  343. echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
  344. echo " <div class='mt-1'>".$text['label-upgrade_apps']."</div>\n";
  345. echo " </td>\n";
  346. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  347. echo " <input type='checkbox' name='action[app_defaults]' id='do_apps' value='1' onclick=\"event.stopPropagation();\"> &nbsp;".$text['description-upgrade_apps']."\n";
  348. echo " </td>\n";
  349. echo "</tr>\n";
  350. echo "</table>\n";
  351. $step++;
  352. }
  353. if (permission_exists("menu_restore")) {
  354. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  355. echo "<tr onclick=\"document.getElementById('do_menu').checked = !document.getElementById('do_menu').checked; $('#sel_menu').fadeToggle('fast');\">\n";
  356. echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
  357. echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
  358. echo " <div class='mt-1'>".$text['label-upgrade_menu']."</div>\n";
  359. echo " </td>\n";
  360. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  361. echo "<input type='checkbox' name='action[menu_defaults]' id='do_menu' value='1' onclick=\"event.stopPropagation(); $('#sel_menu').fadeToggle('fast');\">";
  362. echo "<select name='sel_menu' id='sel_menu' class='formfld' style='display: none; vertical-align: middle; margin-left: 5px;' onclick=\"event.stopPropagation();\">";
  363. $sql = "select * from v_menus order by menu_name asc;";
  364. $result = $database->select($sql, null, 'all');
  365. if (is_array($result) && sizeof($result) != 0) {
  366. foreach ($result as $row) {
  367. if ($row["menu_name"] == 'default') {
  368. echo "<option selected value='".$row["menu_uuid"]."|".$row["menu_language"]."'>".$row["menu_name"]."</option>";
  369. }
  370. else {
  371. echo "<option value='".$row["menu_uuid"]."|".$row["menu_language"]."'>".$row["menu_name"]."</option>";
  372. }
  373. }
  374. }
  375. unset ($sql, $result);
  376. echo "</select>";
  377. echo " &nbsp;".$text['description-upgrade_menu'];
  378. echo " </td>\n";
  379. echo "</tr>\n";
  380. echo "</table>\n";
  381. $step++;
  382. }
  383. if (permission_exists("group_edit")) {
  384. echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
  385. echo "<tr onclick=\"document.getElementById('do_permissions').checked = !document.getElementById('do_permissions').checked;\">\n";
  386. echo " <td width='30%' class='vncellreq' style='vertical-align: middle;'>\n";
  387. echo " <div style='".$step_container_style."'><span style='".$step_number_style."'>".$step."</span></div>";
  388. echo " <div class='mt-1'>".$text['label-upgrade_permissions']."</div>\n";
  389. echo " </td>\n";
  390. echo " <td width='70%' class='vtable' style='height: 50px; cursor: pointer;'>\n";
  391. echo " <input type='checkbox' name='action[permission_defaults]' id='do_permissions' value='1' onclick=\"event.stopPropagation();\"> &nbsp;".$text['description-upgrade_permissions']."\n";
  392. echo " </td>\n";
  393. echo "</tr>\n";
  394. echo "</table>\n";
  395. $step++;
  396. }
  397. echo "</div>\n";
  398. echo "</form>\n";
  399. echo "<br />";
  400. if (!empty($_SESSION["response"]) && is_array($_SESSION["response"])) {
  401. foreach($_SESSION["response"] as $part => $response){
  402. echo "<div class='card'>\n";
  403. echo "<b>".$text["label-results"]." - ".$text["label-{$part}"];
  404. echo "</b><br /><br />";
  405. $error_found = false;
  406. if ($part == "optional_apps") {
  407. foreach ($response as $app_name => $app_response) {
  408. echo "<strong>".$app_name."</strong><br>\n";
  409. $error_found = false;
  410. foreach ($app_response as $l => $response_line) {
  411. if (substr_count($response_line, 'error: ') != 0) {
  412. $error_found = true;
  413. $app_response[$l] = str_replace('error:', 'Error:', $response_line);
  414. }
  415. }
  416. if ($error_found) { $error_style = 'color: red;'; }
  417. echo "<pre".(!empty($error_style) ? " style='".$error_style."'" : null).">\n";
  418. foreach ($app_response as $response_line) {
  419. echo htmlspecialchars($response_line) . "\n";
  420. }
  421. echo "</pre>\n";
  422. unset($error_found, $error_style);
  423. }
  424. }
  425. else if (is_array($response)) {
  426. foreach ($response as $l => $response_line) {
  427. if (substr_count($response_line, 'error: ') != 0) {
  428. $error_found = true;
  429. $response[$l] = str_replace('error:', 'Error:', $response_line);
  430. }
  431. }
  432. if ($error_found) { $error_style = 'color: red;'; }
  433. echo "<pre".(!empty($error_style) ? " style='".$error_style."'" : null).">\n";
  434. echo implode("\n", $response);
  435. echo "</pre>";
  436. unset($error_found, $error_style);
  437. }
  438. else {
  439. echo $response;
  440. }
  441. echo "</div>\n";
  442. }
  443. unset($_SESSION["response"]);
  444. }
  445. //source preview script
  446. echo "<script>\n";
  447. echo "function source_preview(source, title) {\n";
  448. echo " $.ajax({\n";
  449. echo " url: '".$_SERVER['PHP_SELF']."?preview=' + source + '&title=' + title,\n";
  450. echo " type: 'get',\n";
  451. echo " processData: false,\n";
  452. echo " contentType: false,\n";
  453. echo " cache: false,\n";
  454. echo " success: function(response){\n";
  455. echo " $('#source_preview_container').html(response);\n";
  456. echo " $('#source_preview_layer').fadeIn(400);\n";
  457. echo " }\n";
  458. echo " });\n";
  459. echo "}\n";
  460. echo "</script>\n";
  461. //include the footer
  462. require_once "resources/footer.php";
  463. ?>