From 161e6408b956924746bef1ab57dfade926e675c6 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 1 Aug 2013 20:52:39 +0000 Subject: [PATCH] Properly define ROOT_PATH --- kb/kb.inc.php | 1 - main.inc.php | 11 ++++++++--- pages/index.php | 1 - scp/staff.inc.php | 1 - 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kb/kb.inc.php b/kb/kb.inc.php index ed0ab8c21..a53c515cb 100644 --- a/kb/kb.inc.php +++ b/kb/kb.inc.php @@ -13,7 +13,6 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ -define('ROOT_PATH','../'); require_once('../client.inc.php'); require_once(INCLUDE_DIR.'class.faq.php'); /* Bail out if knowledgebase is disabled or if we have no public-published FAQs. */ diff --git a/main.inc.php b/main.inc.php index 5ea6cc97f..5f07a80e1 100644 --- a/main.inc.php +++ b/main.inc.php @@ -60,7 +60,12 @@ } #Set Dir constants - if(!defined('ROOT_PATH')) define('ROOT_PATH','./'); //root path. Damn directories + $here = substr(realpath(dirname(__file__)), + strlen($_SERVER['DOCUMENT_ROOT'])); + // Determine the path in the URI used as the base of the osTicket + // installation + if (!defined('ROOT_PATH')) + define('ROOT_PATH', str_replace('\\', '/', $here.'/')); //root path. Damn directories define('ROOT_DIR',str_replace('\\\\', '/', realpath(dirname(__FILE__))).'/'); #Get real path for root dir ---linux and windows define('INCLUDE_DIR',ROOT_DIR.'include/'); //Change this if include is moved outside the web path. @@ -127,8 +132,8 @@ require(INCLUDE_DIR.'mysql.php'); #Cookies - session_set_cookie_params(86400, dirname($_SERVER['PHP_SELF']), - $_SERVER['HTTP_HOST'], osTicket::is_https()); + session_set_cookie_params(86400, ROOT_PATH, $_SERVER['HTTP_HOST'], + osTicket::is_https()); #CURRENT EXECUTING SCRIPT. define('THISPAGE', Misc::currentURL()); diff --git a/pages/index.php b/pages/index.php index 78c49e737..75c5490dd 100644 --- a/pages/index.php +++ b/pages/index.php @@ -15,7 +15,6 @@ vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ @chdir(realpath(dirname(__file__).'/../')); -define('ROOT_PATH','../'); require_once('client.inc.php'); require_once(INCLUDE_DIR.'class.format.php'); diff --git a/scp/staff.inc.php b/scp/staff.inc.php index 503c3cd41..77aa2c9b3 100644 --- a/scp/staff.inc.php +++ b/scp/staff.inc.php @@ -17,7 +17,6 @@ if(basename($_SERVER['SCRIPT_NAME'])==basename(__FILE__)) die('Access denied'); if(!file_exists('../main.inc.php')) die('Fatal error... get technical support'); -define('ROOT_PATH','../'); //Path to the root dir. require_once('../main.inc.php'); if(!defined('INCLUDE_DIR')) die('Fatal error... invalid setting.'); -- GitLab