| 24 | | if (! function_exists('error')) { |
|---|
| 25 | | function error($text) { |
|---|
| 26 | | echo "[ERROR] ".$text."<br>"; |
|---|
| 27 | | } |
|---|
| | 19 | /* If Blacklist module version less than 2.7.0.2 is not present then |
|---|
| | 20 | * upgrading to 2.9 will result in a crash. The module MUST be updated |
|---|
| | 21 | * even if it is currenlty disabled. |
|---|
| | 22 | * We don't check this in the module.xml dependencies because if they |
|---|
| | 23 | * don't have blacklist installed then it is ok for them to upgrade and |
|---|
| | 24 | * there is no dependency mode that can express that. |
|---|
| | 25 | */ |
|---|
| | 26 | $ver = modules_getversion('blacklist'); |
|---|
| | 27 | if ($ver !== null && version_compare($ver,'2.7.0.2','lt')) { |
|---|
| | 28 | out(_("Blacklist Module MUST be updated before installing.")); |
|---|
| | 29 | out(sprintf(_("You have %s installed, 2.7.0.2 or higher is required.."),$ver); |
|---|
| | 30 | return false; |
|---|
| 29 | | |
|---|
| 30 | | if (! function_exists('fatal')) { |
|---|
| 31 | | function fatal($text) { |
|---|
| 32 | | echo "[FATAL] ".$text."<br>"; |
|---|
| 33 | | exit(1); |
|---|
| 34 | | } |
|---|
| 35 | | } |
|---|
| 36 | | |
|---|
| 37 | | if (! function_exists('debug')) { |
|---|
| 38 | | function debug($text) { |
|---|
| 39 | | global $debug; |
|---|
| 40 | | |
|---|
| 41 | | if ($debug) echo "[DEBUG-preDB] ".$text."<br>"; |
|---|
| 42 | | } |
|---|
| 43 | | } |
|---|
| 44 | | |
|---|
| 45 | | include dirname(__FILE__)."/libfreepbx.install.php"; |
|---|
| 46 | | |
|---|
| 47 | | global $amp_conf; |
|---|
| 48 | | global $asterisk_conf; |
|---|
| 49 | | |
|---|
| 50 | | $debug = false; |
|---|
| 51 | | $dryrun = false; |
|---|
| 52 | | |
|---|
| 53 | | /** verison_compare that works with freePBX version numbers |
|---|
| 54 | | * included here because there are some older versions of functions.inc.php that do not have |
|---|
| 55 | | * it included as it was added during 2.3.0beta1 |
|---|
| 56 | | */ |
|---|
| 57 | | if (!function_exists('version_compare_freepbx')) { |
|---|
| 58 | | function version_compare_freepbx($version1, $version2, $op = null) { |
|---|
| 59 | | $version1 = str_replace("rc","RC", strtolower($version1)); |
|---|
| 60 | | $version2 = str_replace("rc","RC", strtolower($version2)); |
|---|
| 61 | | if (!is_null($op)) { |
|---|
| 62 | | return version_compare($version1, $version2, $op); |
|---|
| 63 | | } else { |
|---|
| 64 | | return version_compare($version1, $version2); |
|---|
| 65 | | } |
|---|
| 66 | | } |
|---|
| 67 | | } |
|---|
| 68 | | |
|---|
| 69 | | /* |
|---|
| 70 | | * Framework install script |
|---|
| 71 | | */ |
|---|
| 72 | | |
|---|
| 73 | | $htdocs_source = dirname(__FILE__)."/htdocs/*"; |
|---|
| 74 | | $bin_source = dirname(__FILE__)."/bin/*"; |
|---|
| 75 | | $agibin_source = dirname(__FILE__)."/agi-bin/*"; |
|---|
| 76 | | |
|---|
| 77 | | if (!file_exists(dirname($htdocs_source))) { |
|---|
| 78 | | out(sprintf(_("No directory %s, install script not needed"),dirname($htdocs_source))); |
|---|
| 79 | | return true; |
|---|
| 80 | | } |
|---|
| 81 | | |
|---|
| 82 | | // These are required by libfreepbx.install.php library for upgrade routines |
|---|
| 83 | | // |
|---|
| 84 | | define("UPGRADE_DIR", dirname(__FILE__)."/upgrades/"); |
|---|
| 85 | | define("MODULE_DIR", $amp_conf['AMPWEBROOT'].'/modules/'); |
|---|
| 86 | | |
|---|
| 87 | | $htdocs_dest = $amp_conf['AMPWEBROOT']; |
|---|
| 88 | | $bin_dest = isset($amp_conf['AMPBIN']) ? $amp_conf['AMPBIN'] : '/var/lib/asterisk/bin'; |
|---|
| 89 | | $agibin_dest = isset($asterisk_conf['astagidir']) ? $asterisk_conf['astagidir']:'/var/lib/asterisk/agi-bin'; |
|---|
| 90 | | |
|---|
| 91 | | exec("cp -rf $htdocs_source $htdocs_dest 2>&1",$out,$ret); |
|---|
| 92 | | if ($ret != 0) { |
|---|
| 93 | | framework_print_errors($htdocs_source, $htdocs_dest, $out); |
|---|
| 94 | | } |
|---|
| 95 | | |
|---|
| 96 | | exec("cp -rf $bin_source $bin_dest 2>&1",$out,$ret); |
|---|
| 97 | | if ($ret != 0) { |
|---|
| 98 | | framework_print_errors($bin_source, $bin_dest, $out); |
|---|
| 99 | | } |
|---|
| 100 | | |
|---|
| 101 | | exec("cp -rf $agibin_source $agibin_dest 2>&1",$out,$ret); |
|---|
| 102 | | if ($ret != 0) { |
|---|
| 103 | | framework_print_errors($agibin_source, $agibin_dest, $out); |
|---|
| 104 | | } |
|---|
| 105 | | |
|---|
| 106 | | if (function_exists('upgrade_all')) { |
|---|
| 107 | | upgrade_all(getversion()); |
|---|
| 108 | | } else { |
|---|
| 109 | | echo ("[ERROR] Function: 'upgrade_all' not present, libfreepbx.install.php seems not to be installed<br>"); |
|---|
| 110 | | } |
|---|
| 111 | | |
|---|