diff --git a/app/access_controls/root.php b/app/access_controls/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/access_controls/root.php +++ b/app/access_controls/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/adminer/root.php b/app/adminer/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/adminer/root.php +++ b/app/adminer/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/backup/root.php b/app/backup/root.php index 7b882438ea..90a856f3a9 100755 --- a/app/backup/root.php +++ b/app/backup/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/call_block/root.php b/app/call_block/root.php index e791876a14..90a856f3a9 100644 --- a/app/call_block/root.php +++ b/app/call_block/root.php @@ -22,31 +22,44 @@ Contributor(s): Mark J Crane - - Callblock is written by Gerrit Visser */ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/call_broadcast/root.php b/app/call_broadcast/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/call_broadcast/root.php +++ b/app/call_broadcast/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/call_center_active/root.php b/app/call_center_active/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/call_center_active/root.php +++ b/app/call_center_active/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/call_centers/root.php b/app/call_centers/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/call_centers/root.php +++ b/app/call_centers/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/call_flows/root.php b/app/call_flows/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/call_flows/root.php +++ b/app/call_flows/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/calls/root.php b/app/calls/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/calls/root.php +++ b/app/calls/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/calls_active/root.php b/app/calls_active/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/calls_active/root.php +++ b/app/calls_active/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/click_to_call/root.php b/app/click_to_call/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/click_to_call/root.php +++ b/app/click_to_call/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/conference_centers/root.php b/app/conference_centers/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/conference_centers/root.php +++ b/app/conference_centers/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/conferences/root.php b/app/conferences/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/conferences/root.php +++ b/app/conferences/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/conferences_active/root.php b/app/conferences_active/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/conferences_active/root.php +++ b/app/conferences_active/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/contacts/root.php b/app/contacts/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/contacts/root.php +++ b/app/contacts/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/destinations/root.php b/app/destinations/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/destinations/root.php +++ b/app/destinations/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/devices/root.php b/app/devices/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/devices/root.php +++ b/app/devices/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/dialplan/root.php b/app/dialplan/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/dialplan/root.php +++ b/app/dialplan/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/dialplan_inbound/root.php b/app/dialplan_inbound/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/dialplan_inbound/root.php +++ b/app/dialplan_inbound/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/dialplan_outbound/root.php b/app/dialplan_outbound/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/dialplan_outbound/root.php +++ b/app/dialplan_outbound/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/edit/root.php b/app/edit/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/edit/root.php +++ b/app/edit/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/emails/root.php b/app/emails/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/emails/root.php +++ b/app/emails/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/exec/root.php b/app/exec/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/exec/root.php +++ b/app/exec/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/extensions/root.php b/app/extensions/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/extensions/root.php +++ b/app/extensions/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/fax/root.php b/app/fax/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/fax/root.php +++ b/app/fax/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/fifo/root.php b/app/fifo/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/fifo/root.php +++ b/app/fifo/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/fifo_list/root.php b/app/fifo_list/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/fifo_list/root.php +++ b/app/fifo_list/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/follow_me/root.php b/app/follow_me/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/follow_me/root.php +++ b/app/follow_me/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/gateways/root.php b/app/gateways/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/gateways/root.php +++ b/app/gateways/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/ivr_menus/root.php b/app/ivr_menus/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/ivr_menus/root.php +++ b/app/ivr_menus/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/log_viewer/root.php b/app/log_viewer/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/log_viewer/root.php +++ b/app/log_viewer/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/modules/root.php b/app/modules/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/modules/root.php +++ b/app/modules/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/music_on_hold/root.php b/app/music_on_hold/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/music_on_hold/root.php +++ b/app/music_on_hold/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/operator_panel/root.php b/app/operator_panel/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/operator_panel/root.php +++ b/app/operator_panel/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/phrases/root.php b/app/phrases/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/phrases/root.php +++ b/app/phrases/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/provision/root.php b/app/provision/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/provision/root.php +++ b/app/provision/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/recordings/root.php b/app/recordings/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/recordings/root.php +++ b/app/recordings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/registrations/root.php b/app/registrations/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/registrations/root.php +++ b/app/registrations/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/ring_groups/root.php b/app/ring_groups/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/ring_groups/root.php +++ b/app/ring_groups/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/services/root.php b/app/services/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/services/root.php +++ b/app/services/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/settings/root.php b/app/settings/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/settings/root.php +++ b/app/settings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/sip_profiles/root.php b/app/sip_profiles/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/sip_profiles/root.php +++ b/app/sip_profiles/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/sip_status/root.php b/app/sip_status/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/sip_status/root.php +++ b/app/sip_status/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/sql_query/root.php b/app/sql_query/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/sql_query/root.php +++ b/app/sql_query/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/system/root.php b/app/system/root.php index 321ba2ea9b..90a856f3a9 100644 --- a/app/system/root.php +++ b/app/system/root.php @@ -22,7 +22,6 @@ Contributor(s): Mark J Crane - Matthew Vale */ // make sure the PATH_SEPARATOR is defined diff --git a/app/time_conditions/root.php b/app/time_conditions/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/time_conditions/root.php +++ b/app/time_conditions/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/traffic_graph/root.php b/app/traffic_graph/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/traffic_graph/root.php +++ b/app/traffic_graph/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/vars/root.php b/app/vars/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/vars/root.php +++ b/app/vars/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/voicemail_greetings/root.php b/app/voicemail_greetings/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/voicemail_greetings/root.php +++ b/app/voicemail_greetings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/voicemails/root.php b/app/voicemails/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/voicemails/root.php +++ b/app/voicemails/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/app/xml_cdr/root.php b/app/xml_cdr/root.php index 7b882438ea..90a856f3a9 100644 --- a/app/xml_cdr/root.php +++ b/app/xml_cdr/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/apps/root.php b/core/apps/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/apps/root.php +++ b/core/apps/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/databases/root.php b/core/databases/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/databases/root.php +++ b/core/databases/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/default_settings/root.php b/core/default_settings/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/default_settings/root.php +++ b/core/default_settings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/domain_settings/root.php b/core/domain_settings/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/domain_settings/root.php +++ b/core/domain_settings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/install/root.php b/core/install/root.php index 884d2b08a3..90a856f3a9 100644 --- a/core/install/root.php +++ b/core/install/root.php @@ -1,50 +1,65 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -// make sure the PATH_SEPARATOR is defined - if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } - } - -// make sure the document_root is set - $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; - -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); - } - + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + ?> \ No newline at end of file diff --git a/core/menu/root.php b/core/menu/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/menu/root.php +++ b/core/menu/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/notifications/root.php b/core/notifications/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/notifications/root.php +++ b/core/notifications/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/upgrade/root.php b/core/upgrade/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/upgrade/root.php +++ b/core/upgrade/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/core/user_settings/root.php b/core/user_settings/root.php index c7906e24a5..90a856f3a9 100644 --- a/core/user_settings/root.php +++ b/core/user_settings/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } -?> +?> \ No newline at end of file diff --git a/core/users/root.php b/core/users/root.php index 7b882438ea..90a856f3a9 100644 --- a/core/users/root.php +++ b/core/users/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/resources/captcha/root.php b/resources/captcha/root.php index cf38657a09..90a856f3a9 100644 --- a/resources/captcha/root.php +++ b/resources/captcha/root.php @@ -23,26 +23,43 @@ Contributor(s): Mark J Crane */ + // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - define('PROJECT_PATH', '/fusionpbx'); - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - define('PROJECT_PATH', ''); - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/resources/classes/root.php b/resources/classes/root.php index 7b882438ea..90a856f3a9 100644 --- a/resources/classes/root.php +++ b/resources/classes/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/resources/root.php b/resources/root.php index c7906e24a5..90a856f3a9 100644 --- a/resources/root.php +++ b/resources/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } -?> +?> \ No newline at end of file diff --git a/root.php b/root.php index 7b882438ea..90a856f3a9 100644 --- a/root.php +++ b/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/secure/root.php b/secure/root.php index 7b882438ea..90a856f3a9 100644 --- a/secure/root.php +++ b/secure/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/themes/accessible/root.php b/themes/accessible/root.php index 7b882438ea..90a856f3a9 100644 --- a/themes/accessible/root.php +++ b/themes/accessible/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/themes/enhanced/root.php b/themes/enhanced/root.php index 7b882438ea..90a856f3a9 100644 --- a/themes/enhanced/root.php +++ b/themes/enhanced/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file diff --git a/themes/minimized/root.php b/themes/minimized/root.php index 7b882438ea..90a856f3a9 100644 --- a/themes/minimized/root.php +++ b/themes/minimized/root.php @@ -26,25 +26,40 @@ // make sure the PATH_SEPARATOR is defined if (!defined("PATH_SEPARATOR")) { - if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } } // make sure the document_root is set $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); - //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; - //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; - //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// if the project directory exists then add it to the include path otherwise add the document root to the include path - if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); - } - else { - if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } - set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'fusionpbx')) { + define('PROJECT_PATH', DIRECTORY_SEPARATOR . 'fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'README.md')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= DIRECTORY_SEPARATOR . $dirs[$i]; + if (file_exists($path . DIRECTORY_SEPARATOR . 'README.md')) { + break; + } + $i++; + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); } ?> \ No newline at end of file