upgrade.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //check the permission
  22. if(defined('STDIN')) {
  23. $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
  24. preg_match("/^(.*)\/core\/.*$/", $document_root, $matches);
  25. $document_root = $matches[1];
  26. set_include_path($document_root);
  27. require_once "resources/require.php";
  28. $_SERVER["DOCUMENT_ROOT"] = $document_root;
  29. $display_type = 'text'; //html, text
  30. }
  31. else {
  32. require_once "root.php";
  33. require_once "resources/require.php";
  34. require_once "resources/check_auth.php";
  35. if (permission_exists('upgrade_schema') || permission_exists('upgrade_source') || if_group("superadmin")) {
  36. //echo "access granted";
  37. }
  38. else {
  39. echo "access denied";
  40. exit;
  41. }
  42. $display_type = 'html'; //html, text
  43. }
  44. //add multi-lingual support
  45. require_once "resources/classes/text.php";
  46. $language = new text;
  47. $text = $language->get();
  48. //show the title
  49. if ($display_type == 'text') {
  50. echo "\n";
  51. echo $text['label-upgrade']."\n";
  52. echo "-----------------------------------------\n";
  53. echo "\n";
  54. echo $text['label-database']."\n";
  55. }
  56. //make sure the database schema and installation have performed all necessary tasks
  57. require_once "resources/classes/schema.php";
  58. $obj = new schema;
  59. echo $obj->schema("text");
  60. //run all app_defaults.php files
  61. require_once "resources/classes/domains.php";
  62. $domain = new domains;
  63. $domain->display_type = $display_type;
  64. $domain->upgrade();
  65. //show the content
  66. if ($display_type == 'html') {
  67. echo "<div align='center'>\n";
  68. echo "<table width='40%'>\n";
  69. echo "<tr>\n";
  70. echo "<th align='left'>".$text['header-message']."</th>\n";
  71. echo "</tr>\n";
  72. echo "<tr>\n";
  73. echo "<td class='row_style1'><strong>".$text['message-upgrade']."</strong></td>\n";
  74. echo "</tr>\n";
  75. echo "</table>\n";
  76. echo "</div>\n";
  77. echo "<br />\n";
  78. echo "<br />\n";
  79. echo "<br />\n";
  80. echo "<br />\n";
  81. echo "<br />\n";
  82. echo "<br />\n";
  83. echo "<br />\n";
  84. }
  85. elseif ($display_type == 'text') {
  86. echo "\n";
  87. }
  88. //include the footer
  89. if ($display_type == "html") {
  90. require_once "resources/footer.php";
  91. }
  92. ?>