Could you try replacing the block (including the line to define ROOT_PATH) with this
#Set Dir constants
$root = str_replace('\\', '/', realpath(dirname(__file__)));
$root2 = str_replace('\\','/', $_SERVER);
$path = '';
while (strpos($_SERVER, $root) === false) {
$lastslash = strrpos($root, '/');
$path = substr($root, $lastslash) . $path;
$root = substr($root, 0, $lastslash);
}
// Determine the path in the URI used as the base of the osTicket
// installation
if (!defined('ROOT_PATH'))
define('ROOT_PATH', $path.'/'); //root path. Damn directories