[svn r19488] FS#3968 - Introducing a function api_is_windows_os() and a constant IS_WINDOWS_OS for unified Windows detection.

skala
Ivan Tcholakov 16 years ago
parent 914d49bfb4
commit bc5a631a90
  1. 32
      main/inc/lib/main_api.lib.php
  2. 9
      main/newscorm/learnpath.class.php

@ -158,6 +158,10 @@ define('PLATFORM_AUTH_SOURCE', 'platform');
//CONSTANT defining the default HotPotatoes files directory
define('DIR_HOTPOTATOES','/HotPotatoes_files');
// This constant is a result of Windows OS detection, it has a boolean value:
// true whether the server runs on Windows OS, false otherwise.
define ('IS_WINDOWS_OS', api_is_windows_os());
/*
==============================================================================
PROTECTION FUNCTIONS
@ -3266,4 +3270,30 @@ function api_is_user_of_course ($course_id,$user_id) {
} else {
return false;
}
}
}
/**
* Checks whether the server's operating system is Windows (TM).
* @return boolean - true if the operating system is Windows, false otherwise
*/
function api_is_windows_os() {
if (function_exists("php_uname")) {
// php_uname() exists since PHP 4.0.2., according to the documentation.
// We expect that this function will always work for Dokeos 1.8.x.
$os = php_uname();
}
// The following methods are not needed, but let them stay, just in case.
elseif (isset($_ENV['OS'])) {
// Sometimes $_ENV['OS'] the may not be present (bugs?)
$os = $_ENV['OS'];
}
elseif (defined('PHP_OS')) {
// PHP_OS means on which OS PHP was compiled, this is why
// using PHP_OS is the last choice for detection.
$os = PHP_OS;
} else {
$os = '';
}
return strtolower(substr($os, 0, 3 )) === 'win' ? true : false;
}

@ -8776,13 +8776,8 @@ EOD;
function create_path($path){
$path_bits = split('/',dirname($path));
if (strpos($path, ':') === false) {
// This should be added only when the platform is non-Windows.
$path_built = '/';
} else {
// This is for Windows platforms.
$path_built = '';
}
// IS_WINDOWS_OS has been defined in main_api.lib.php
$path_built = IS_WINDOWS_OS ? '' : '/';
foreach($path_bits as $bit){
if(!empty($bit)){

Loading…
Cancel
Save