Forums / Install & configuration / my final patch for php-cgi

my final patch for php-cgi

Author Message

Andreas Bockler

Friday 23 May 2003 5:46:41 am

Hi,

i finally got mostly everything working, but you have to change some things:
- forms should be always method=post
- every url-parameters in your templates which begins with ? (e.g. ?SearchText) should be changed to & since the ? is set automaticly from the system.

here's the complete patch. The PHPSESSID-Code is redundant, but who cares:
================ snip =================
--- ezpublish.orig/lib/ezutils/classes/ezsys.php 18 Apr 2003 10:20:48 -0000 1.2
+++ ezpublish/lib/ezutils/classes/ezsys.php 22 May 2003 22:47:43 -0000 1.5
@@ -271,7 +271,7 @@
if ( count( $this->AccessPath ) > 0 )
{
// if ( $text != "" )
- $text .= "/";
+ $text .= "?/";
$text .= implode( '/', $this->AccessPath );
}
return $text;
@@ -522,29 +522,19 @@
else if ( ereg( "(.*)/([^\/]+\.php)$", $phpSelf, $regs ) )
$wwwDir = $regs[1];

- $requestURI = eZSys::serverVariable( 'REQUEST_URI' );
+ $requestURI = eZSys::serverVariable( 'QUERY_STRING' );
+
+ // take out PHPSESSID, if url-encoded
+ if( preg_match("/(.*)&PHPSESSID=[^&]+(.*)/",$requestURI,$matches ) ) {
+ $requestURI = $matches[1].$matches[2];
+ }

// Fallback... Finding the paths above failed, so $_SERVER['PHP_SELF'] is not set right.
if ( $siteDir == "./" )
$phpSelf = $requestURI;

- $def_index_reg = str_replace( ".", "\\.", $def_index );
- // Trick: Rewrite setup doesn't have index.php in $_SERVER['PHP_SELF'], so we don't want an $index
- if ( ! ereg( ".*$def_index_reg.*", $phpSelf ) )
- $index = "";
- else
- {
- if ( eZSys::isDebugEnabled() )
- eZDebug::writeNotice( "$wwwDir$index", '$wwwDir$index' );
- // Get the right $_SERVER['REQUEST_URI'], when using nVH setup.
- if ( ereg( "^$wwwDir$index(.*)", $phpSelf, $req ) )
- {
- $requestURI = $req[1];
- }
- }
-
// Remove url parameters
- if ( ereg( "([^?]+)", $requestURI, $regs ) )
+ if ( ereg( "(\/[^&]+)", $requestURI, $regs ) )
{
$requestURI = $regs[1];
}

michael e

Monday 26 May 2003 11:06:25 pm

This works great!!! Just incorporated it and am now up and running with v3.x on a shared server (PHP via CGI).

One suggestion, you may want to be a little more verbose with the instructions on how to effect this patch - the line numbers 271/522 indicate where the code begins that you need to replace. The lines beginning with a '-' should be deleted. The lines beginning with a '+' should be kept. Lines without a qualifier just leave as is.

Thanks.

Michael

Stéphane Cloutier

Wednesday 10 September 2003 11:43:56 am

This works fine for me ! I'm running another machine with php 4.3.3 as CGI. I applied this patch above to eZpublish 3.1 and the 404 error page or the "No Input File found" are gone. Thanks!

Qupanuaq - Snow bunting

Tom Erik Thorsen

Monday 20 October 2003 4:33:37 am

This looks very interesting.

How do I use this patch?

</n00b>

Tom Erik Thorsen

Wednesday 22 October 2003 1:34:43 am

Nevermind :)

Rodrigo Pinheiro

Sunday 23 November 2003 8:18:36 pm

I'm trying to install ezpublish 3.2-3 on a phpsuexec (CGI) configured server. After modifying the ezsys.php I still get the "No input file specified." error...

Can anybody help me with this problem?

Michael M

Saturday 03 January 2004 10:06:10 am

As far as I can tell, this is the same patch for 3.3. However, it doesn't work yet for me on my 1and1.com hosted service so I can't be sure. (I guess I need install the older version with the previous patch to work out whether this is the hosting service or my poorly applied patch.)

Thought it might be useful for other 3.3. users though. For part-time unix users, note that this is generated with diff -U 3 and can be applied using patch

--- ezsys.php.safe Sat Jan 3 12:13:22 2004
+++ ezsys.php Sat Jan 3 13:01:52 2004
@@ -486,7 +486,7 @@
if ( $withAccessList and count( $this->AccessPath ) > 0 )
{
// if ( $text != "" )
- $text .= "/";
+ $text .= "?/";
$text .= implode( '/', $this->AccessPath );
}
return $text;
@@ -742,29 +742,19 @@
else if ( ereg( "(.*)/([^\/]+\.php)$", $phpSelf, $regs ) )
$wwwDir = $regs[1];

- $requestURI = eZSys::serverVariable( 'REQUEST_URI' );
+ $requestURI = eZSys::serverVariable( 'QUERY_STRING' );
+
+ // take out PHPSESSID, if url-encoded
+ if( preg_match("/(.*)&PHPSESSID=[^&]+(.*)/",$requestURI,$matches ) ) {
+ $requestURI = $matches[1].$matches[2];
+ }

// Fallback... Finding the paths above failed, so $_SERVER['PHP_SELF'] is not set right.
if ( $siteDir == "./" )
$phpSelf = $requestURI;

- $def_index_reg = str_replace( ".", "\\.", $def_index );
- // Trick: Rewrite setup doesn't have index.php in $_SERVER['PHP_SELF'], so we don't want an $index
- if ( ! ereg( ".*$def_index_reg.*", $phpSelf ) )
- $index = "";
- else
- {
- if ( eZSys::isDebugEnabled() )
- eZDebug::writeNotice( "$wwwDir$index", '$wwwDir$index' );
- // Get the right $_SERVER['REQUEST_URI'], when using nVH setup.
- if ( ereg( "^$wwwDir$index(.*)", $phpSelf, $req ) )
- {
- $requestURI = $req[1];
- }
- }
-
// Remove url parameters
- if ( ereg( "([^?]+)", $requestURI, $regs ) )
+ if ( ereg( "(\/[^&]+)", $requestURI, $regs ) )
{
$requestURI = $regs[1];
}

Antonio Rugna

Monday 12 January 2004 5:04:35 pm

Can someone tell me how it is supposed to work please?

I have applied the patch and I get the following two cases:

1) I type
www.host.com/ez/
and www.host.com/ez/index.php will show at the address bar in IE. My frontpage opens up but whatever link I click on URLs will show for ex. as
...index.php/corporate (without ?)
and they won't work (No input file specified)

2) typing www.host.com/ez/index.php?/corporate I get my frontpage again and now when I click on any link URLs will show as
...index.php?/corporate (with ?)
and pages will open up correctly

Is this the expected beaviour? Shouldn't I get the question mark automatically added by the system right from the beginning (simply typing www.host.com/ez/)?

Please let me know?
Regards
Antonio

Francis Nart

Wednesday 04 February 2004 1:15:43 pm

I get the exact same pb as Antonio when applying the patch on a ez 3.3 install can anybody help ?

Dzevad Fazlic

Thursday 05 February 2004 1:26:45 am

Hello
How do i can aply that patch
my ezsys.php is totaly diferent
here is my ezsys.php

AccessPath<?php
//
// Definition of eZSys class
//
// Created on: <01-Mar-2002 13:48:53 amos>
//
// Copyright (C) 1999-2004 eZ systems as. All rights reserved.
//
// This source file is part of the eZ publish (tm) Open Source Content
// Management System.
//
// This file may be distributed and/or modified under the terms of the
// "GNU General Public License" version 2 as published by the Free
// Software Foundation and appearing in the file LICENSE.GPL included in
// the packaging of this file.
//
// Licencees holding valid "eZ publish professional licences" may use this
// file in accordance with the "eZ publish professional licence" Agreement
// provided with the Software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
// THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE.
//
// The "eZ publish professional licence" is available at
// http://ez.no/products/licences/professional/. For pricing of this licence
// please contact us via e-mail to licence@ez.no. Further contact
// information is available at http://ez.no/home/contact/.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//

/*!
\class eZSys ezsys.php
\ingroup eZUtils
\brief Easy access to various system settings

The system is checked to see whether a virtualhost-less setup is used
and sets the appropriate variables which can be fetched with
siteDir(), wwwDir() and indexFile().
It also detects file and enviroment separators, fetch them with
fileSeparator() and envSeparator().
In addition userIndexFile(), adminIndexFile() and xmlrpcIndexFile()
can be used to fetch the index file of the user page, admin page and
xmlrpc interface.

Example:
\code
// Run the init in the index file
eZSys::init( eZINI::instance() );
print( eZSys::indexFile() );
print( eZSys::wwwDir() );
\endcode
*/

define( "EZ_SYS_DEBUG_INTERNALS", false );

class eZSys
{
/*!
Initializes the object with settings taken from the current script run.
*/
function eZSys()
{
$this->Attributes = array( "magickQuotes" => true,
"hostname" => true );
// Determine OS specific settings
if ( substr( php_uname(), 0, 7 ) == "Windows" )
{
$this->OSType = "win32";
$this->FileSystemType = "win32";
$this->FileSeparator = "\\";
$this->LineSeparator= "\r\n";
$this->EnvSeparator = ";";
$this->ShellEscapeCharacter = '"';
$this->BackupFilename = '.bak';
}
else if ( substr( php_uname(), 0, 3 ) == "Mac" )
{
$this->OSType = "mac";
$this->FileSystemType = "unix";
$this->FileSeparator = "/";
$this->LineSeparator= "\r";
$this->EnvSeparator = ":";
$this->ShellEscapeCharacter = "'";
$this->BackupFilename = '~';
}
else
{
$this->OSType = "unix";
$this->FileSystemType = "unix";
$this->FileSeparator = "/";
$this->LineSeparator= "\n";
$this->EnvSeparator = ":";
$this->ShellEscapeCharacter = "'";
$this->BackupFilename = '~';
}

$magicQuote = get_magic_quotes_gpc();

if ( $magicQuote == 1 )
{
eZSys::removeMagicQuotes();
}
}

function removeMagicQuotes()
{
$globalVariables = array( '_SERVER', '_ENV' );
foreach ( $globalVariables as $globalVariable )
{
foreach ( array_keys( $GLOBALS[$globalVariable] ) as $key )
{
if ( !is_array( $GLOBALS[$globalVariable][$key] ) )
{
$GLOBALS[$globalVariable][$key] = stripslashes( $GLOBALS[$globalVariable][$key] );
}
}
}
}

/*!
\static
\return the os type, either \c "win32", \c "unix" or \c "mac"
*/
function osType()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->OSType;
}

/*!
\static
\return the filesystem type, either \c "win32" or \c "unix"
*/
function filesystemType()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->FileSystemType;
}

/*!
Returns the string which is used for file separators on the current OS (server).
\static
*/
function fileSeparator()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->FileSeparator;
}

/*!
\static
\return the PHP version as text.
\note Calls phpversion().
*/
function phpVersionText()
{
return phpversion();
}

/*!
\static
\return the PHP version as an array with the version elements.
\example
array( 4, 3, 4 )
\endexample
*/
function phpVersion()
{
$text = eZSys::phpVersionText();
$elements = explode( '.', $text );
return $elements;
}

/*!
\return \c true if the PHP version is equal or higher than \a $requiredVersion.
\param $requiredVersion must be an array with version number.

\code
eZSys::isPHPVersionSufficient( array( 4, 1, 0 ) );
\endcode
*/
function isPHPVersionSufficient( $requiredVersion )
{
if ( !is_array( $requiredVersion ) )
return false;
$phpVersion = eZSys::phpVersion();
$len = min( count( $phpVersion ), count( $requiredVersion ) );
for ( $i = 0; $i < $len; ++$i )
{
if ( $phpVersion[$i] > $requiredVersion[$i] )
return true;
if ( $phpVersion[$i] < $requiredVersion[$i] )
return false;
}
return true;
}

/*!
\static
Escape a string to be used as a shell argument and return it.
*/
function escapeShellArgument( $argument )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
$escapeChar = $this->ShellEscapeCharacter;
$argument = str_replace( "\\", "\\\\", $argument );
$argument = str_replace( $escapeChar, "\\" . $escapeChar, $argument );
$argument = $escapeChar . $argument . $escapeChar;
return $argument;
}

/*!
\static
Replaces % elements in the argument text \a $argumentText using the replace list \a $replaceList.
It will also properly escape the argument.
\sa splitArgumentIntoElements, mergeArgumentElements
*/
function createShellArgument( $argumentText, $replaceList )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
$elements = $this->splitArgumentIntoElements( $argumentText );
$replacedElements = array();
foreach ( $elements as $element )
{
if ( is_string( $element ) )
{
$replacedElements[] = strtr( $element, $replaceList );
continue;
}
$replacedElements[] = $element;
}
$text = $this->mergeArgumentElements( $replacedElements );
return $text;
}

/*!
\static
Splits the argument text into argument array elements.
It will split text on spaces and set them as strings in the array,
spaces will be counted and inserted as integers with the space count.
Text placed in quotes will also be parsed, this allows for spaces in the text.
\code
$list = splitArgumentIntoElements( "-geometry 100x100" );

var_dump( $list ); // will give: array( "-geometry", 1, "100x100" );
\endcode

You can then easily modify the elements separately and create the argument text with mergeArgumentElements().
*/
function splitArgumentIntoElements( $argumentText )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
$argumentElements = array();
$pos = 0;

while ( $pos < strlen( $argumentText ) )
{
if ( $argumentText[$pos] == '"' )
{
$quoteStartPos = $pos + 1;
$quoteEndPos = $pos + 1;
while ( $quoteEndPos < strlen( $argumentText ) )
{
$tmpPos = strpos( $argumentText, '"', $quoteEndPos );
if ( $tmpPos !== false and
$argumentText[$tmpPos - 1] != "\\" );
{
$quoteEndPos = $tmpPos;
break;
}
if ( $tmpPos === false )
{
$quoteEndPos = strlen( $argumentText );
break;
}
$quoteEndPos = $tmpPos + 1;
}
$argumentElements[] = substr( $argumentText, $quoteStartPos, $quoteEndPos - $quoteStartPos );
$pos = $quoteEndPos + 1;
}
else if ( $argumentText[$pos] == ' ' )
{
$spacePos = $pos;
$spaceEndPos = $pos;
while ( $spaceEndPos < strlen( $argumentText ) )
{
if ( $argumentText[$spaceEndPos] != ' ' )
break;
++$spaceEndPos;
}
$spaceText = substr( $argumentText, $spacePos, $spaceEndPos - $spacePos );
$spaceCount = strlen( $spaceText );
if ( $spaceCount > 0 )
$argumentElements[] = $spaceCount;
$pos = $spaceEndPos;
}
else
{
$spacePos = strpos( $argumentText, ' ', $pos );
if ( $spacePos !== false )
{
$argumentElements[] = substr( $argumentText, $pos, $spacePos - $pos );
$spaceEndPos = $spacePos + 1;
while ( $spaceEndPos < strlen( $argumentText ) )
{
if ( $argumentText[$spaceEndPos] != ' ' )
break;
++$spaceEndPos;
}
$spaceText = substr( $argumentText, $spacePos, $spaceEndPos - $spacePos );
$spaceCount = strlen( $spaceText );
if ( $spaceCount > 0 )
$argumentElements[] = $spaceCount;
$pos = $spaceEndPos;
}
else
{
$argumentElements[] = substr( $argumentText, $pos );
$pos = strlen( $argumentText );
}
}
}
return $argumentElements;
}

/*!
\static
Merges an argument list created by splitArgumentIntoElements() back into a text string.
The argument text will be properly quoted.
*/
function mergeArgumentElements( $argumentElements )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
$argumentText = '';
foreach ( $argumentElements as $element )
{
if ( is_int( $element ) )
{
$argumentText .= str_repeat( ' ', $element );
}
else if ( is_string( $element ) )
{
$argumentText .= $this->escapeShellArgument( $element );
}
}
return $argumentText;
}

/*!
\static
\return the backup filename for this platform, returns .bak for win32 and ~ for unix and mac.
*/
function backupFilename()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->BackupFilename;
}

/*!
Returns the string which is used for line separators on the current OS (server).
\static
*/
function lineSeparator()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->LineSeparator;
}

/*!
Returns the string which is used for enviroment separators on the current OS (server).
\static
*/
function envSeparator()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->EnvSeparator;
}

/*!
\static
\return the directory used for storing various kinds of files like cache, temporary files and logs.
*/
function varDirectory()
{
include_once( 'lib/ezutils/classes/ezini.php' );
$ini =& eZINI::instance();
return $ini->variable( 'FileSettings', 'VarDir' );
}

/*!
\static
\ return the directory used for storing various kinds of files like images, audio and more.
\Note This will include the varDirectory().
*/
function storageDirectory()
{
include_once( 'lib/ezutils/classes/ezini.php' );
include_once( 'lib/ezutils/classes/ezdir.php' );
$ini =& eZINI::instance();
$varDir = eZSys::varDirectory();
$storageDir = $ini->variable( 'FileSettings', 'StorageDir' );
return eZDir::path( array( $varDir, $storageDir ) );
}

/*!
\static
\return the directory used for storing cache files.
\note This will include the varDirectory().
*/
function cacheDirectory()
{
include_once( 'lib/ezutils/classes/ezini.php' );
$ini =& eZINI::instance();
$cacheDir = $ini->variable( 'FileSettings', 'CacheDir' );

include_once( 'lib/ezutils/classes/ezdir.php' );
if ( $cacheDir[0] == "/" )
{
return eZDir::path( array( $cacheDir ) );
}
else
{
return eZDir::path( array( eZSys::varDirectory(), $cacheDir ) );
}
}

/*!
The path to where all the code resides.
\static
*/
function siteDir()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->SiteDir;
}

/*!
The relative directory path of the vhless setup.
\static
*/
function wwwDir()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->WWWDir;
}

/*!
The filepath for the index file.
\static
*/
function indexDir( $withAccessList = true )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->wwwDir() . $this->indexFile( $withAccessList );
}

/*!
The filepath for the index file with the access path appended.
\static
\sa indexFileName
*/
function indexFile( $withAccessList = true )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
$text = $this->IndexFile;
if ( $withAccessList and count( $this->AccessPath ) > 0 )
{
// if ( $text != "" )
$text .= "/";
$text .= implode( '/', $this->AccessPath );
}
return $text;
}

/*!
The filepath for the index file.
\static
*/
function indexFileName()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->IndexFile;
}

/*!
Returns the current hostname.
\static
*/
function hostname()
{
return eZSys::serverVariable( 'HTTP_HOST' );
}

/*!
\static
\return the port of the server.
*/
function serverPort()
{
$port =& $GLOBALS['eZSysServerPort'];
if ( !isset( $port ) )
{
$port = eZSys::serverVariable( 'SERVER_PORT' );
$hostname = eZSys::serverVariable( 'HTTP_HOST' );
if ( preg_match( "/.*:([0-9]+)/", $hostname, $regs ) )
{
$port = $regs[1];
}
}
return $port;
}

/*!
Returns true if magick quotes is enabled.
\static
*/
function magickQuotes()
{

}

/*!
\return the variable named \a $variableName in the global \c $_SERVER variable.
If the variable is not present an error is shown and \c null is returned.
*/
function &serverVariable( $variableName, $quiet = false )
{
$_SERVER;
if ( !isset( $_SERVER[$variableName] ) )
{
if ( !$quiet )
eZDebug::writeError( "Server variable '$variableName' does not exist", 'eZSys::serverVariable' );
return null;
}
return $_SERVER[$variableName];
}

/*!
Sets the server variable named \a $variableName to \a $variableValue.
\note Variables are only set for the current page view.
*/
function setServerVariable( $variableName, $variableValue )
{
$_SERVER;
$_SERVER[$variableName] = $variableValue;
}

/*!
\return the path string for the server.
*/
function &path( $quiet = false )
{
return eZSys::serverVariable( 'PATH', $quiet );
}

/*!
\return the variable named \a $variableName in the global \c $_ENV variable.
If the variable is not present an error is shown and \c null is returned.
*/
function &environmentVariable( $variableName, $quiet = false )
{
$_ENV;
if ( !isset( $_ENV[$variableName] ) )
{
if ( !$quiet )
eZDebug::writeError( "Environment variable '$variableName' does not exist", 'eZSys::environmentVariable' );
return null;
}
return $_ENV[$variableName];
}

/*!
Sets the environment variable named \a $variableName to \a $variableValue.
\note Variables are only set for the current page view.
*/
function setEnvironmentVariable( $variableName, $variableValue )
{
$_ENV;
$_ENV[$variableName] = $variableValue;
}

/*!
Return true if the attribute $attr is set. Available attributes are
wwwdir, sitedir or indexfile
*/
function hasAttribute( $attr )
{
return ( isset( $this->Attributes[$attr] )
or $attr == "wwwdir"
or $attr == "sitedir"
or $attr == "indexfile"
or $attr == "indexdir" );
}

/*!
Returns the attribute value for $attr or null if the attribute does not exist.
*/
function &attribute( $attr )
{
if ( isset( $this->Attributes[$attr] ) )
{
$mname = $attr;
return $this->$mname();
}
else if ( $attr == 'wwwdir' )
{
return $this->wwwDir();
}
else if ( $attr == 'sitedir' )
{
return $this->siteDir();
}
else if ( $attr == 'indexfile' )
{
return $this->indexFile();
}
else if ( $attr == 'indexdir' )
{
return $this->indexDir();
}
else
{
return null;
}
}

/*!
\static
Sets the access path which is appended to the index file.
\sa indexFile
*/
function addAccessPath( $path )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
if ( !is_array( $path ) )
$path = array( $path );
$this->AccessPath = array_merge( $this->AccessPath, $path );
}

/*!
\static
\return true if debugging of internals is enabled, this will display
which server variables are read.
Set the option with setIsDebugEnabled().
*/
function isDebugEnabled()
{
if ( !isset( $GLOBALS['eZSysDebugInternalsEnabled'] ) )
$GLOBALS['eZSysDebugInternalsEnabled'] = EZ_SYS_DEBUG_INTERNALS;
return $GLOBALS['eZSysDebugInternalsEnabled'];
}

/*!
\static
Sets whether internal debugging is enabled or not.
*/
function setIsDebugEnabled( $debug )
{
$GLOBALS['eZSysDebugInternalsEnabled'] = $debug;
}

/*!
Initializes some variables according to some global PHP values.
This function should be called once in the index file with the parameters
stated in the parameter list.
\static
*/
function init( $def_index = "index.php" )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();

if ( eZSys::isDebugEnabled() )
{
eZDebug::writeNotice( eZSys::serverVariable( 'PHP_SELF' ), 'PHP_SELF' );
eZDebug::writeNotice( eZSys::serverVariable( 'SCRIPT_FILENAME' ), 'SCRIPT_FILENAME' );
eZDebug::writeNotice( eZSys::serverVariable( 'DOCUMENT_ROOT' ), 'DOCUMENT_ROOT' );
eZDebug::writeNotice( ini_get( 'include_path' ), 'include_path' );
}

$phpSelf = eZSys::serverVariable( 'PHP_SELF' );

// Find out, where our files are.
if ( ereg( "(.*/)([^\/]+\.php)$", eZSys::serverVariable( 'SCRIPT_FILENAME' ), $regs ) )
{
$siteDir = $regs[1];
$index = "/" . $regs[2];
}
elseif ( ereg( "(.*/)([^\/]+\.php)/?", $phpSelf, $regs ) )
{
// Some people using CGI have their $_SERVER['SCRIPT_FILENAME'] not right... so we are trying this.
$siteDir = eZSys::serverVariable( 'DOCUMENT_ROOT' ) . $regs[1];
$index = "/" . $regs[2];
}
else
{
// Fallback... doesn't work with virtual-hosts, but better than nothing
$siteDir = "./";
$index = "/$def_index";
}

// Setting the right include_path
$includePath = ini_get( "include_path" );
if ( trim( $includePath ) != "" )

// Old line:
//$includePath .= $this->envSeparator() . $siteDir;

// New line:
$includePath = $siteDir . $this->envSeparator() . $includePath;

else
$includePath = $siteDir;
ini_set( "include_path", $includePath );

$scriptName = eZSys::serverVariable( 'SCRIPT_NAME' );
// Get the webdir.
if ( ereg( "(.*)/([^\/]+\.php)$", $scriptName, $regs ) )
$wwwDir = $regs[1];
else if ( ereg( "(.*)/([^\/]+\.php)$", $phpSelf, $regs ) )
$wwwDir = $regs[1];

$requestURI = eZSys::serverVariable( 'REQUEST_URI' );

// Fallback... Finding the paths above failed, so $_SERVER['PHP_SELF'] is not set right.
if ( $siteDir == "./" )
$phpSelf = $requestURI;

$def_index_reg = str_replace( ".", "\\.", $def_index );
// Trick: Rewrite setup doesn't have index.php in $_SERVER['PHP_SELF'], so we don't want an $index
if ( ! ereg( ".*$def_index_reg.*", $phpSelf ) )
$index = "";
else
{
if ( eZSys::isDebugEnabled() )
eZDebug::writeNotice( "$wwwDir$index", '$wwwDir$index' );
// Get the right $_SERVER['REQUEST_URI'], when using nVH setup.
if ( ereg( "^$wwwDir$index(.*)", $phpSelf, $req ) )
{
$requestURI = $req[1];
}
}

// Remove url parameters
if ( ereg( "([^?]+)", $requestURI, $regs ) )
{
$requestURI = $regs[1];
}

// Remove internal links
if ( ereg( "([^#]+)", $requestURI, $regs ) )
{
$requestURI = $regs[1];
}

$this->AccessPath = array();
$this->SiteDir =& $siteDir;
$this->WWWDir =& $wwwDir;
$this->IndexFile =& $index;
$this->RequestURI = $requestURI;

if ( eZSys::isDebugEnabled() )
{
eZDebug::writeNotice( $this->SiteDir, 'SiteDir' );
eZDebug::writeNotice( $this->WWWDir, 'WWWDir' );
eZDebug::writeNotice( $this->IndexFile, 'IndexFile' );
eZDebug::writeNotice( eZSys::requestURI(), 'eZSys::requestURI()' );
}
}

/*!
\return the URI used for parsing modules, views and parameters, may differ from $_SERVER['REQUEST_URI'].
*/
function requestURI()
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
return $this->RequestURI;
}

/*!
Initializes some variables which are read from site.ini
\warning Do not call this before init()
*/
function initIni( &$ini )
{
if ( !isset( $this ) or get_class( $this ) != "ezsys" )
$this =& eZSys::instance();
}

/*!
Returns the only legal instance of the eZSys class.
\static
*/
function &instance()
{
$instance =& $GLOBALS["eZSysInstance"];
if ( get_class( $instance ) != "ezsys" )
{
$instance = new eZSys();
}
return $instance;
}

/// The line separator used in files
var $LineSeparator;
/// The directory separator used for files
var $FileSeparator;
/// The list separator used for env variables
var $EnvSeparator;
/// The path to where all the code resides
var $SiteDir;
/// The access path of the current site view
var $AccessPath;
/// The relative directory path of the vhless setup
var $WWWDir;
/// The filepath for the index
var $IndexFile;
/// The uri which is used for parsing module/view information from, may differ from $_SERVER['REQUEST_URI']
var $RequestURI;
/// The type of filesystem, is either win32 or unix. This often used to determine os specific paths.
var $FileSystemType;
/// The character to be used in shell escaping, this character is OS specific
var $ShellEscapeCharacter;
var $OSType;
}

?>

Menno van Drunen

Thursday 12 February 2004 9:43:52 am

Could anyone put a complete ezsys.php with the patch applied for ez 3.3 somewhere here on the forum? It looks like thios patch is outdated...

Thanks,

Menno

James Packham

Monday 23 February 2004 4:03:11 am

Yeah, Im struggling a bit too - At the moment I can't even get the setup wizard to load (error 403/500). I don't mind working from a patch though - as long as it's tested to work on EZ P 3.3-3.

A bit more detail on my problems:

I can't seem to get either patch to work, this is what I did

copy and paste patch text into a file (new).
Then from the lib/ezutils/classes directory:
# diff -U 3 ezsys.php new > patch
# patch ezsys.php patch
patching file ezsys.php

But when I upload the file to overwrite the unpatched version and navigate to my site I still get 500/403 errors (depending on how I use .htaccess). Am I doing anything wrong? Do I need to add some commands to patch?

Thanks,

James

James Packham

Monday 23 February 2004 6:48:29 am

Tried another approach: changing the appropiate lines by hand still no luck. Can anyone help me out?