lib/ezutils/classes/ezsys.php

Show: inherited
Table of Contents

File containing the eZSys class.

Portions are modifications of patches by Andreas Böckler and Francis Nart

Copyright
Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.  
License
eZ Business Use License Agreement Version 2.0  
Package
lib  
Version
4.6.0  

\eZSys

Package: lib\ezutils

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 environment separators, fetch them with fileSeparator() and envSeparator().

// Run the init in the index file
eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' );
echo eZSys::indexFile();
echo eZSys::wwwDir();

Properties

Propertyprotectedarray  $AccessPath= ''

The access path of the current site view, associated array of associated arrays.

On first level key is 'siteaccess' and 'path' to distinguish between siteaccess and general path. On second level you have (string)'name' and (array)'url', where url is the path and name is the name of the source (used to match siteaccess in {@link eZSys::indexFile()} for RemoveSiteAccessIfDefaultAccess matching) .

Details
Type
array
Propertypublicstring  $EnvSeparator= ''

The list separator used for env variables (':' or ';')

Details
Type
string
Propertypublicstring  $FileSeparator= ''

The directory separator used for files, '/' or '\'

Details
Type
string
Propertypublicstring  $FileSystemType= ''

The type of filesystem, is either win32 or unix. This often used to determine OS specific paths.

Details
Type
string
Propertypublicstring  $IndexFile= ''

The index file name (eg: 'index.php')

Details
Type
string
Propertypublicstring  $LineSeparator= ''

The line separator used in files, "\n" / "\n\r" / "\r"

Details
Type
string
Propertypublicstring  $OSType= ''

The type of OS, is either win32, mac or unix.

Details
Type
string
Propertyprotectedarray  $Params= ''

Holds server variables as read automatically or provided by unit tests Only used by init functionality as other calls will need to use live data direclty from globals.

Details
Type
array
Propertyprotectedstring  $QueryString= ''

Query string for the current request In the form of "?param1=value1&param2=value2

Details
Type
string
Propertypublicstring  $RequestURI= ''

The uri which is used for parsing module/view information from, may differ from $_SERVER['REQUEST_URI']

Details
Type
string
Propertypublicstring  $RootDir= ''

The absolute path to the root directory.

Details
Type
string
Propertypublic\stringt  $ShellEscapeCharacter= ''

The character to be used in shell escaping, this character is OS specific

Details
Type
\stringt
Propertypublicstring  $SiteDir= ''

The system path to where all the code resides

Details
Type
string
Propertypublicstring  $WWWDir= ''

The relative directory path of the vhless setup

Details
Type
string
Propertyprotected\eZSys|null  $instance= 'null'
static

Holds eZSys instance

Default valuenullDetails
Type
\eZSys | null

Methods

methodpublic__construct( array $serverParams = array() ) : void

Initialize the object with settings taken from the current script run.

Parameters
Name Type Description
$serverParams array

For unit testing use, see first few lines for content

methodpublic__get( string $propertyName ) : mixed

Magic function to get access readonly properties (protected)

Parameters
Name Type Description
$propertyName string
Returns
Type Description
mixed
Throws
Exception Description
\ezcBasePropertyNotFoundException
methodpublicaddAccessPath( array | string $path, string $name = 'undefined', bool $siteaccess = true ) : void
static

Appends the access path (parts of url that identifies siteaccess), used by {@link eZSys::indexFile()} NOTE: Does not make sense to use for siteaccess, as you would want to clear current path and set new one normally, so preferably use {@link eZSys::setAccessPath()} in this case.

Parameters
Name Type Description
$path array | string
$name string

An identifer of the name of the path provided {@link $AccessPath}

$siteaccess bool

Hints if path is siteaccess related or not, needed in case subsequesnt code suddenly changes siteaccess and needs to clear siteaccess scope

methodpublicattribute( string $attr ) : null | string

Returns the attribute value for $attr or null if the attribute does not exist

Parameters
Name Type Description
$attr string
Returns
Type Description
null | string
methodpublicattributes( ) : array

Make sure that certain attribute keys are available in $this->Attributes

Returns
Type Description
array
methodpublicbackupFilename( ) : string
static

Returns the backup filename for this platform

Possible values: .bak (win32), ~ (unix, mac)

Returns
Type Description
string
methodpubliccacheDirectory( ) : string
static

Returns the current cache directory.

Returns
Type Description
string
methodpublicclearAccessPath( bool $siteaccess = true ) : void
static

Clears the access path, used by {@link eZSys::indexFile()}

Parameters
Name Type Description
$siteaccess bool
methodpublicclientIP( ) : string
static

Returns the client IP whether he's behind a proxy or not

Use [HTTPHeaderSettings].ClientIpByCustomHTTPHeader in site.ini if you want to use a custom http header such as X-Forwarded-For

Note: X-Forwarded-For is transformed by PHP into $_SERVER['HTTP_X_FORWARDED_FOR]

Returns
Type Description
string
methodpubliccreateShellArgument( string $argumentText, array $replaceList ) : string
static

Replaces % elements in $argumentText using $replaceList, and also properly escape the argument

Parameters
Name Type Description
$argumentText string
$replaceList array
Returns
Type Description
string
methodpublicenvSeparator( ) : string
static

Returns the string used as environment separator on the current system

Returns
Type Description
string
methodpublicenvironmentVariable( string $variableName, bool $quiet = false ) : null | string
static

Returns an environment variable or null if it is not available

If the variable is not available, trigger an error message

Parameters
Name Type Description
$variableName string
$quiet bool
Returns
Type Description
null | string
methodpublicescapeShellArgument( string $argument ) : string
static

Returns an escaped string to be used as a shell argument

Parameters
Name Type Description
$argument string
Returns
Type Description
string
methodpublicezcrc32(  $string ) : int | string
static

A wrapper for PHP's crc32 function. Returns the crc32 polynomial as unsigned int

Parameters
Name Type Description
$string
Returns
Type Description
int | string
methodpublicfileSeparator( ) : string
static

Returns the string used as the file separator on the current system

Returns
Type Description
string
methodpublicfilesystemType( ) : string
static

Returns the filesystem type

Possible values: win32, unix

Returns
Type Description
string
methodprotectedgetValidwwwDir( string $phpSelf, string $scriptFileName, string $index ) : string | null | false
static

Generate wwwdir from phpSelf if valid accoring to scriptFileName and return null if invalid and false if there is no index in phpSelf

Parameters
Name Type Description
$phpSelf string
$scriptFileName string
$index string
Returns
Type Description
string | null | false String in form 'path/path2' if valid, null if not and false if $index is not part of phpself
methodpublicglobBrace( string $pattern, int $flags = 0 ) : array
static

Wraps around the built-in glob() function to provide same functionality for systems (e.g Solaris) that does not support GLOB_BRACE.

Parameters
Name Type Description
$pattern string
$flags int
Returns
Type Description
array
methodpublichasAttribute( string $attr ) : bool

Checks if the attribute $attr is set.

Parameters
Name Type Description
$attr string
Returns
Type Description
bool
methodpublichasEnvironmentVariable( string $variableName ) : bool
static

Checks if an environment variable is available

Parameters
Name Type Description
$variableName string
Returns
Type Description
bool
methodpublichostname( ) : string
static

Returns the current hostname.

First tries to use X-Forward-Host before it goes on to use host in header, if none of them exists fallback to use host part of site.ini[SiteSettings]|SiteURL setting.

Returns
Type Description
string
methodpublicindexDir( bool $withAccessList = true ) : string
static

Returns the filepath for the index file.

Parameters
Name Type Description
$withAccessList bool
Returns
Type Description
string
methodpublicindexFile( bool $withAccessPath = true ) : string
static

Returns the filepath for the index file with the access path appended

Parameters
Name Type Description
$withAccessPath bool
Returns
Type Description
string
methodpublicindexFileName( ) : string
static

Returns the filepath for the index file

Returns
Type Description
string
methodpublicinit( string $index = 'index.php', bool $forceVirtualHost = null ) : void
static

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.

Parameters
Name Type Description
$index string

The current index file, needed for virtual host mode detection.

$forceVirtualHost bool

Virtual host mode is normally autodetected, but if not this can be forced by setting this to true.

methodpublicinstance( ) : \eZSys
static

Returns a shared instance of the eZSys class

Returns
Type Description
\eZSys
methodpublicisDebugEnabled( ) : bool
static

Returns true if debugging of internals is enabled, this will display which server variables are read.

Set the option with setIsDebugEnabled().

Returns
Type Description
bool
Details
Deprecated
Since 4.5, not used  
methodpublicisPHPVersionSufficient( array $requiredVersion ) : bool
static

Checks if the given version is greater than or equal to the current PHP version

Usage:

eZSys::isPHPVersionSufficient( array( 4, 1, 0 ) );
Parameters
Name Type Description
$requiredVersion array

Must be an array with version number

Returns
Type Description
bool
Details
Deprecated
Since 4.5  
methodpublicisSSLNow( ) : bool
static

Determines if SSL is enabled and protocol HTTPS is used.

Returns
Type Description
bool
methodpublicisShellExecution( ) : bool
static

Determines if the current process has been started from the web or the shell

Returns
Type Description
bool
methodpubliclineSeparator( ) : string
static

Returns the string used as line separator on the current system

Returns
Type Description
string
methodpublicmagickQuotes( ) : null
static

Should return true when magick quotes are enabled, but instead return null.

Returns
Type Description
null
Details
Deprecated
since 4.5  
methodpublicmergeArgumentElements( array $argumentElements ) : string
static

Merges an argument list created by eZSys::splitArgumentIntoElements() back into a text string

Parameters
Name Type Description
$argumentElements array
Returns
Type Description
string
methodpublicosName( ) : string | bool
static

Returns the current OS name or false if it can not be determined.

Possible values: windows, linux, freebsd, darwin

Returns
Type Description
string | bool
methodpublicosType( ) : string
static

Returns the OS type

Possible values: win32, unix

Returns
Type Description
string
methodpublicpath( bool $quiet = false ) : mixed | null
static

Returns the server's path string

Parameters
Name Type Description
$quiet bool
Returns
Type Description
mixed | null
methodpublicphpVersion( ) : array
static

Returns the PHP version as an array with the version elements.

Returns
Type Description
array
Details
Deprecated
Since 4.5  
methodpublicphpVersionText( ) : string
static

The PHP version as text.

Returns
Type Description
string
Details
Deprecated
Since 4.5, use PHP_VERSION  
methodpublicprotocolSchema( ) : string
static

Returns the schema of the request.

Returns
Type Description
string
methodpublicqueryString( ) : string
static

Returns the query string for the current request.

?param1=value1¶m2=value2
Returns
Type Description
string
methodpublicremoveMagicQuotes( ) : void
static

Removes magic quotes

Details
Deprecated
Since 4.5, magic quotes setting has been deprecated in PHP 5.3  
methodpublicrequestURI( ) : string
static

Returns the URI used for parsing modules, views and parameters

May differ from $_SERVER['REQUEST_URI'].

Returns
Type Description
string
methodpublicrootDir( ) : string | null
static

Returns the absolute path to the eZ Publish root directory

Returns
Type Description
string | null
methodpublicserverPort( ) : int
static

Returns the server port or 80 as default if the server port can not be retrieved from the hostname or the server variable 'SERVER_PORT'

Returns
Type Description
int
methodpublicserverProtocol( ) : string
static

Returns the current server protocol depending on if SSL is enabled or not.

Returns
Type Description
string
methodpublicserverURL( ) : string
static

Returns the server URL (protocol and hostname and port)

Returns
Type Description
string
methodpublicserverVariable( string $variableName, bool $quiet = false ) : mixed | null
static

Returns the value of $_SERVER[$variableName] if it is set.

If it isn't set, trigger an error message if $quiet is false

Parameters
Name Type Description
$variableName string
$quiet bool
Returns
Type Description
mixed | null
methodpublicsetAccessPath( array $path = array(), string $name = 'undefined', bool $siteaccess = true ) : void
static

Set access path (parts of url that identifies siteaccess), used by {@link eZSys::indexFile()}

Parameters
Name Type Description
$path array
$name string

An identifer of the name of the path provided {@link $AccessPath}

$siteaccess bool

Hints if path is siteaccess related or not, needed in case subsequesnt code suddenly changes siteaccess and needs to clear siteaccess scope

methodpublicsetEnvironmentVariable( string $variableName, mixed $variableValue ) : void
static

Sets an environment variable for the current process/page view

Parameters
Name Type Description
$variableName string
$variableValue mixed
methodpublicsetInstance( \eZSys $instance = null ) : void
static

Sets eZSys instance or clears it if left undefined.

Parameters
Name Type Description
$instance \eZSys
methodpublicsetIsDebugEnabled( bool $debug ) : void
static

Sets whether internal debugging is enabled or not.

Parameters
Name Type Description
$debug bool
Details
Deprecated
Since 4.5, has not effect anymore  
methodpublicsetServerVariable( string $variableName, mixed $variableValue ) : void
static

Sets a server variable in the global array $_SERVER

Note: Variables are only set for the current process/page view

Parameters
Name Type Description
$variableName string
$variableValue mixed
methodprotectedsimulateGlobBrace(  $filenames ) : array
static

Expands a list of filenames like GLOB_BRACE does.

GLOB_BRACE is non POSIX and only available in GNU glibc. This is needed to support operating systems like Solars.

Parameters
Name Type Description
$filenames
Returns
Type Description
array
methodpublicsiteDir( ) : string
static

Returns the path to where all the code resides.

Returns
Type Description
string
methodpublicsplitArgumentIntoElements( string $argumentText ) : array
static

Splits $argumentText on boundaries formed by one or more spaces and save them into an array of separate arguments.

The number of spaces between to arguments is inserted as an integer value between two argument values.

Example:

$list = splitArgumentIntoElements( "-geometry 100x100" );
var_dump( $list ); // Output: array( "-geometry", 1, "100x100" );

You can then easily modify the elements separately and create the argument text with eZSys::mergeArgumentElements()

Parameters
Name Type Description
$argumentText string
Returns
Type Description
array
methodpublicstorageDirectory( ) : string
static

Returns the current storage directory

Returns
Type Description
string
methodpublicvarDirectory( ) : string
static

Returns the path of the current var directory

Returns
Type Description
string
methodpublicwwwDir( ) : string
static

Returns the relative directory path of the vhless setup.

Returns
Type Description
string
Documentation was generated by DocBlox 0.18.1.