Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 494 → Rev 495

/trunk/includes/classes/OIDplus.class.php
802,7 → 802,7
if ($res !== '') {
return rtrim($res,'/').'/';
}
if (php_sapi_name() == 'cli') {
if (PHP_SAPI == 'cli') {
try {
return OIDplus::config()->getValue('last_known_system_url', false);
} catch (Exception $e) {
811,21 → 811,32
}
}
 
if (!isset($_SERVER["SCRIPT_NAME"]) && !isset($_SERVER["SCRIPT_FILENAME"])) return false;
 
// First, try to find out how many levels we need to go up
if (PHP_SAPI == 'cli') {
global $argv;
$test_dir = dirname(realpath($argv[0]));
} else {
if (!isset($_SERVER["SCRIPT_FILENAME"])) return false;
$test_dir = dirname($_SERVER['SCRIPT_FILENAME']);
}
$test_dir = str_replace('\\', '/', $test_dir);
$c = 0;
$steps_up = 0;
while (!file_exists($test_dir.'/oidplus.min.css.php')) { // We just assume that only the OIDplus base directory contains "oidplus.min.css.php" and not any subsequent directory!
$test_dir = dirname($test_dir);
$c++;
if ($c == 1000) return false; // to make sure there will never be an infinite loop
$steps_up++;
if ($steps_up == 1000) return false; // to make sure there will never be an infinite loop
}
 
// Now go up these amount of levels, based on SCRIPT_NAME
if (PHP_SAPI == 'cli') {
if ($relative) {
return str_repeat('../',$steps_up);
} else {
return false;
}
} else {
$res = dirname($_SERVER['SCRIPT_NAME'].'index.php'); // This fake 'index.php' ensures that SCRIPT_NAME does not end with '/', which would make dirname() fail
for ($i=1; $i<=$c; $i++) {
for ($i=0; $i<$steps_up; $i++) {
$res = dirname($res);
}
$res = str_replace('\\', '/', $res);
842,6 → 853,7
 
return $res;
}
}
 
private static $system_id_cache = null;
public static function getSystemId($oid=false) {
979,7 → 991,7
public static function isSslAvailable() {
if (!is_null(self::$sslAvailableCache)) return self::$sslAvailableCache;
 
if (php_sapi_name() == 'cli') {
if (PHP_SAPI == 'cli') {
self::$sslAvailableCache = false;
return false;
}