瀏覽代碼

fixes so cli installs/upgrades work.
Also another step along the way allowing freeswitch to run -u -g freeswitch and fusionpbx to run -u -g www-data

Harry G. Coin 9 年之前
父節點
當前提交
f286ff198c

+ 4 - 1
core/databases/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/default_settings/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/domain_settings/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/install/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/menu/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/upgrade/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 9 - 6
core/upgrade/upgrade.php

@@ -25,14 +25,17 @@
 */
 
 //check the permission
+
 	if(defined('STDIN')) {
-		$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
-		preg_match("/^(.*)\/core\/.*$/", $document_root, $matches);
-		$document_root = $matches[1];
-		set_include_path($document_root);
-		require_once "resources/require.php";
-		$_SERVER["DOCUMENT_ROOT"] = $document_root;
+//		$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
+//		preg_match("/^(.*)\/core\/.*$/", $document_root, $matches);
+//		$document_root = $matches[1];
+//		set_include_path($document_root);
 		$format = 'text'; //html, text
+            	include "root.php";
+		require_once "resources/require.php";
+
+//		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 	}
 	else {
 		include "root.php";

+ 1 - 0
core/upgrade/upgrade_domains.php

@@ -52,6 +52,7 @@
 	}
 
 //run all app_defaults.php files
+	require_once "resources/classes/config.php";
 	require_once "resources/classes/domains.php";
 	$domain = new domains;
 	$domain->upgrade();

+ 4 - 1
core/user_settings/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
core/users/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
resources/captcha/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
resources/classes/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
resources/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {

+ 4 - 1
themes/default/root.php

@@ -25,6 +25,7 @@
 */
 
 // make sure the PATH_SEPARATOR is defined
+        umask(2);
 	if (!defined("PATH_SEPARATOR")) {
 		if (strpos($_ENV["OS"], "Win") !== false) {
 			define("PATH_SEPARATOR", ";");
@@ -33,10 +34,12 @@
 		}
 	}
 
+        if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
+        
 	// make sure the document_root is set
 	$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
 	if(PHP_SAPI == 'cli'){
-		chdir(pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME));
+		chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
 		$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
 		$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
 		if (file_exists('/project_root.php')) {