Home « Server software «
Documentation: shared/safe.php
class Safe - Safe PHP library
PHP is very powerful and versatile, and this explains its phenomenal on-going success. The drawback of PHP openness and richness is that some run-time may miss the promise. This class attempts to compensate for such discrepancies as smoothly as possible.For example, some ISP (e.g., Free in France) forbid some function calls, such as
set_time_limit()
. In such a case, original code has to be modified to
Safe::set_time_limit()
instead.Most member functions of the Safe class just mimic functions normally provided by the PHP library:
- chdir() -- change current directory
- chmod() -- change file mode
- closedir() -- release a directory resource
- copy() -- copy a file
- error_reporting() -- change reporting level
- ini_set() -- set one configuration option
- is_writable() -- check if a file can be written
- file_get_contents() -- read one file in a string
- file_put_contents() -- make a file out of a string
- filemtime() -- last modification date
- fopen() -- open a file
- fsockopen() -- open a network stream
- get_cfg_var() -- get one parameter
- GetImageSize() -- analyze some image
- gettext() -- localize a string
- glob() -- list matching files
- header() -- change web response
- highlight_string() -- smart rendering of php snippet
- load() -- include a PHP script
- make_path() -- build an entire path in the file system
- mkdir() -- create a directory
- move_uploaded_file() -- move a new file
- ngettext() -- localize a string with numbers
- ob_start() -- buffer output
- opendir() -- get a directory resource
- readdir() -- get next directory entry
- realpath() -- locate some file
- redirect() -- jump to another page
- rename() -- rename a file
- rmdir() -- remove a directory
- set_time_limit() -- extend execution duration
- setcookie() -- save data on browser side
- setlocale() -- set locale parameter
- sleep() -- delay code execution
- stat() -- get file information
- syslog() -- remember some event
- system() -- execute a system command
- tempnam() -- get a temporary file
- touch() -- touch a file
- unlink() -- remove a file
This script is a reference file of this system.
Licence: GNU Lesser General Public License
Auteurs:
- Bernard Paques bernard.paques@bigfoot.com
- GnapZ
chdir() - Change current directory
function chdir($path)
- $path - string target directory
- returns TRUE on success, FALSE on failure
chmod() - Change file mode
function chmod($file_name, $mode = 0777)
- $file_name - string file name
- $mode = 0777 - int mode
- returns TRUE on success, FALSE on failure
closedir() - Release a directory resource
function closedir($handle)
- $handle - resource to close
copy() - Copy a file
function copy($source, $destination)
- $source - string the source file
- $destination - string the destination file
- returns TRUE on success, FALSE on failure
error_reporting() - Change reporting level
function error_reporting($level)
- $level - int new reporting level
- returns int previous reporting level, or FALSE on error
file() - Make an array out of a file
function file($path)
- $path - string the file
- returns array on success, FALSE on failure
file_get_contents() - Read one file in a string
function file_get_contents($file)
- $file - string file to read
- returns a string, or ''
file_put_contents() - Write one string in a file
function file_put_contents($file, $content)
- $file - string file to write, with a path relative to the installation directory
- $content - string new content
- returns int the number of bytes written to the file, or 0 on failure
Warning: this function expects path information relative to the YACS installation directory. This behavior differs from the original PHP function.
filemtime() - Date of last modification
function filemtime($path)
- $path - string name of the file to open
- returns date of last modification, FALSE on failure
filesize() - Get file size
function filesize($path)
- $path - string the file
- returns int on success, FALSE on failure
fopen() - Open a file
function fopen($path, $mode)
- $path - string name of the file to open
- $mode - string mode
- returns resource on success, FALSE on failure
fsockopen() - Open a network stream
function fsockopen($server, $port, &$errno, &$errstr, $timeout)
- $server - string host name
- $port - int socket number
- &$errno - int error index, if any
- &$errstr - string error description, if any
- $timeout - int maximum delay to wait
- returns resource on success, FALSE on failure
get_cfg_var() - Get one run-time parameter
function get_cfg_var($parameter)
- $parameter - string parameter name
- returns string parameter value, or FALSE on failure
GetImageSize() - Get image meta-data
function GetImageSize($name)
- $name - string file name
- returns an array or FALSE
gettext() - Localize a string
function gettext($text)
- $text - string message to localize
header() - Change the web response
function header($attribute)
- $attribute - string a new or updated response attribute
highlight_string() - Beautify some code
function highlight_string($text)
- $text - string the code
- returns string to be sent to the browser
ignore_user_abort() - Ignore user abort
function ignore_user_abort($value)
- $value - boolean new value
- returns previous setting, or FALSE on error
is_uploaded_file() - Ensure a file has been properly uploaded
function is_uploaded_file($path)
- $path - string the file
- returns array on success, FALSE on failure
is_writable() - Check if a file is writable
function is_writable($path)
- $path - string the target file
- returns TRUE if the file can be written, FALSE otherwise
ini_get() - Get the value of a configuration option
function ini_get($name)
- $name - string configuration name
- returns a string or ''
ini_set() - Set the value of a configuration option
function ini_set($name, $value)
- $name - string configuration name
- $value - string the new value
- returns a string or FALSE
glob() - List matching files
function glob($pattern)
- $pattern - string path and file pattern
- returns array on success, FALSE on failure
load() - Include one script
function load($name)
- $name - string file name, relative to installation directory
make_path() - Create a complete path to a file
function make_path($path)
- $path - the target path, relative to installation directory
- returns TRUE on success, or FALSE on failure
mkdir() - Create a directory
function mkdir($path_name, $mode = 0777)
- $path_name - string path name
- $mode = 0777 - int mode
- returns TRUE on success, FALSE on failure
move_uploaded_file() - Move a new file
function move_uploaded_file($source, $destination)
- $source - string the source file
- $destination - string the destination file
- returns TRUE on success, FALSE on failure
ngettext() - Localize a string in singualr/plural form
function ngettext($singular, $plural, $count)
- $singular - string singular message
- $plural - string plural form
- $count - int number of items
- returns a localized string
ob_start() - Start output buffering
function ob_start($handler='ob_gz_handler')
- $handler='ob_gz_handler' - string handler to use
opendir() - Prepare to read content of a directory
function opendir($path)
- $path - string path to read
- returns resource on success, FALSE on failure
readdir() - Get next entry in directory
function readdir($handle)
- $handle - resource handle to browsed directory
- returns string on success, FALSE on failure
realpath() - Locate some file
function realpath($path)
- $path - string path to some file
- returns string on success, FALSE on failure
redirect() - Jump to another web page
function redirect($reference)
- $reference - string the target full web address
rename() - Rename a file
function rename($original, $target)
- $original - string the original file
- $target - string the target file
- returns TRUE on success, FALSE on failure
rmdir() - Remove a directory
function rmdir($path_name)
- $path_name - string path to directory to delete
- returns TRUE on success, FALSE on failure
set_time_limit() - Extends execution time
function set_time_limit($duration)
- $duration - int number of seconds
setcookie() - Save data on browser side
function setcookie($name, $value, $expire, $path)
- $name -
- $value -
- $expire -
- $path -
- returns TRUE on success, FALSE otherwise
setlocale() - Set locale parameter
function setlocale($category, $locale)
- $category - string the target category, as anamed constant
- $locale - string the locale to apply
- returns a string or FALSE
sleep() - Delay execution for some time
function sleep($duration)
- $duration - int number of seconds
stat() - Describe a file
function stat($file_name)
- $file_name - string path to file to document
- returns mixed on success, FALSE on failure
syslog() - Generate a system log message
function syslog($priority, $message)
- $priority - int priority
- $message - string message to save
- returns an integer
system() - Execute a system command
function system($command)
- $command - string the command to execute
- returns a status string, or FALSE
tempnam() - Create a temporary file
function tempnam($path, $prefix)
- $path - string target directory
- $prefix - string file prefix
- returns string a temporary name, or FALSE on failure
touch() - Touch a file
function touch($file_name, $modification_stamp=NULL)
- $file_name - string the target file
- $modification_stamp=NULL - int time of last modification
- returns TRUE on success, FALSE on failure
unlink() - Remove a file
function unlink($file_name)
- $file_name - string path to file to delete
- returns TRUE on success, FALSE on failure