[Nextcms-commits] CVS: nextcms utils.php,1.5,1.6
Status: Alpha
Brought to you by:
andrejb
|
From: Andrej B. <an...@us...> - 2002-12-31 03:48:48
|
Update of /cvsroot/nextcms/nextcms
In directory sc8-pr-cvs1:/tmp/cvs-serv19271
Modified Files:
utils.php
Log Message:
remind: The was only tested on Apache and Apache 2
----------------------------------------------------------------------
Index: utils.php
===================================================================
RCS file: /cvsroot/nextcms/nextcms/utils.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** utils.php 14 Jul 2002 13:54:32 -0000 1.5
--- utils.php 31 Dec 2002 03:48:45 -0000 1.6
***************
*** 13,91 ****
}
! function getOS() {
! $SERVER_SOFTWARE = getenv('SERVER_SOFTWARE');
! $PATH = getenv('PATH');
!
! if (stristr($SERVER_SOFTWARE, 'Win'))
! return 'win';
! if (stristr ($SERVER_SOFTWARE, 'Microsoft'))
! return 'win';
! if (stristr ($SERVER_SOFTWARE, 'Unix'))
! return 'nix';
!
! if (stristr ($PATH, 'C:'))
! return 'win';
! if (stristr ($PATH, '/X11'))
! return 'nix';
! }
function getDocRoot() {
! $PATH_TRANSLATED = $GLOBALS['HTTP_SERVER_VARS']['PATH_TRANSLATED'];
! $SCRIPT_FILENAME = getenv('SCRIPT_FILENAME');
! $SelfDir = getScriptPath();
! if ( getOS() == 'win' ) {
! $SelfDir = strtolower($SelfDir);
! $Directory = $PATH_TRANSLATED;
! $Directory = str_replace ('\\\\', '\\', $Directory );
! $temp = str_replace ('\\', '/', $Directory );
! $SelfPos = strpos ( $temp, $SelfDir );
! } else {
! if (getAPI() == 'cgi' AND isset ($PATH_TRANSLATED))
! $Directory = $PATH_TRANSLATED;
! else
! $Directory = $SCRIPT_FILENAME;
! if (!empty($SelfDir))
! $SelfPos = strpos ( $Directory, $SelfDir );
! else
! $SelfPos = false;
! }
! return str_replace ('\\', '/', substr ( $Directory, 0, $SelfPos ) );
! }
! function getScriptPath() {
! $SCRIPT_NAME = getenv('SCRIPT_NAME');
! // may be not correct
! $PATH_INFO = getenv('PATH_INFO');
! if (getAPI() == 'cgi')
! if (getOS() == 'win')
! return dirname ($PATH_INFO);
! else
! if (getOS() == 'nix' AND !empty($PATH_INFO))
! return dirname ($PATH_INFO);
! return dirname ($SCRIPT_NAME);
! }
! function getAPI() {
! $SERVER_SOFTWARE = getenv('SERVER_SOFTWARE');
! $sapi_type = php_sapi_name();
! if (stristr($sapi_type,"apache"))
! return 'mod';
! if (stristr($sapi_type , "isapi"))
! return 'mod';
! if (stristr($sapi_type , "cgi"))
! return 'cgi';
! if ( stristr( $SERVER_SOFTWARE, 'PHP' ) AND !stristr( $SERVER_SOFTWARE, 'SCRIPT' ))
! return 'mod';
! return 'cgi';
}
/**
* relToAbs() turns a relative path into a absolute
--- 13,107 ----
}
!
! /**
! * getDocRoot() determines the document root. This function is now free of
! * phpCMS code.
! * Reminder: only tested on apache and apache 2
! *
! */
function getDocRoot() {
! global $SERVER;
! if (isset($SERVER['PHP_SELF']))
! $PHP_SELF = $SERVER['PHP_SELF'];
! else if (isset($GLOBALS['$PHP_SELF']))
! $PHP_SELF = $GLOBALS['PHP_SELF'];
! if (isset($SERVER['SCRIPT_NAME']))
! $SCRIPT_NAME = $SERVER['SCRIPT_NAME'];
!
! if (isset($SERVER['SCRIPT_FILENAME']))
! $SCRIPT_FILENAME = $SERVER['SCRIPT_FILENAME'];
! if (isset($SERVER['PATH_TRANSLATED']))
! $PATH_TRANSLATED = $SERVER['PATH_TRANSLATED'];
!
! if (isset($SERVER['PATH_INFO']))
! $PATH_INFO = $SERVER['PATH_INFO'];
!
! if (isset($SERVER['$SERVER_SOFTWARE']))
! $SERVER_SOFTWARE = $SERVER['$SERVER_SOFTWARE'];
!
! if (isset($PHP_SELF))
! $scriptName = $PHP_SELF;
! else if (isset($SCRIPT_NAME))
! $scriptName = $SCRIPT_NAME;
! else if (isset($PATH_INFO))
! $scriptName = $PATH_INFO;
! else
! printError("Can't autodetect document root.");
!
! $scriptName = str_replace('//','/', str_replace('\\','/',$scriptName));
!
! // workaround for unix homedirs e.g. http://domain.tld/~username
! $scriptName = ereg_replace ("/~[^/]+", '', $scriptName);
! if (isset($SCRIPT_FILENAME))
! $scriptPath = $SCRIPT_FILENAME;
! else if (isset($PATH_TRANSLATED))
! $scriptPath = $PATH_TRANSLATED;
! else
! printError("Can't autodetect document root.");
! $scriptPath = str_replace('//','/', str_replace('\\','/',$scriptPath));
!
!
! $documentRoot = substr_replace($scriptPath, '', strlen($scriptPath) - strlen($scriptName));
!
! /*
!
! // just some testing stuff
! if (!isset($SERVER_SOFTWARE)) $SERVER_SOFTWARE = '';
! if (!isset($PATH_INFO)) $PATH_INFO = '';
! if (!isset($PATH_TRANSLATED)) $PATH_TRANSLATED = '';
!
! print "\$SERVER_SOFTWARE = '$SERVER_SOFTWARE'<br/>\n";
! print "\$DOCUMENT_ROOT = '".$SERVER['DOCUMENT_ROOT']."'<br/>\n";
! print "<p><b>Scriptnames:</b><br/>\n";
! print "\$SCRIPT_NAME = '$SCRIPT_NAME'<br/>\n";
! print "\$PHP_SELF = '$PHP_SELF'<br/>\n";
! print "\$PATH_INFO = '$PATH_INFO'<br/>\n";
! print "</p>";
!
! print "<p><b>Scriptpath:</b><br/>\n";
! print "\$SCRIPT_FILENAME = '$SCRIPT_FILENAME'<br/>\n";
! print "\$PATH_TRANSLATED = '$PATH_TRANSLATED'<br/>\n";
! print "</p>";
! print "<br/>\$scriptName = '$scriptName'<br/>\n";
! print "\$scriptPath = '$scriptPath'<br/>\n";
! print "\$documentRoot = '$documentRoot'<br/>\n";
!
! */
!
! return $documentRoot;
}
+
/**
* relToAbs() turns a relative path into a absolute
***************
*** 169,173 ****
--- 185,197 ----
$GLOBALS['loaded_files_enabled'] = true;
+ // collect SERVER variables
+ if (is_array($_SERVER))
+ $GLOBALS['SERVER'] = $_SERVER;
+ else
+ $GLOBALS['SERVER'] = $GLOBALS['HTTP_GET_VARS'];
+
if (!isset($GLOBALS['document_root']))
$document_root = getDocRoot();
+
+
?>
|