Classes | |
class | utyResult |
Execution result. More... | |
Modules | |
enum UTY_ERR | |
enum UTY_DIRTYPE | |
enum UTY_SORT | |
enum UTY_RC | |
Functions | |
uty_set_error_handler ($debug=FALSE) | |
uty_set_log ($log_path="./log", $log_level=UTY_ERR_USR) | |
uty_log ($level, $message) | |
uty_error_handler ($php_level, $message, $file, $line) | |
uty_fullurl () | |
uty_exit ($status_code, $status_text="OK", $content="", $content_type="text/plain; charset:utf-8") | |
uty_check_file_ext ($basename, $whitelist=NULL, $blacklist=NULL) | |
uty_normalize_path ($path, $dir=FALSE) | |
uty_check_path ($path, $root="/") | |
uty_dir ($path, $sortkey=NULL, $sortorder=UTY_SORT_ASC) | |
uty_remove ($path, $whitelist=NULL, $blacklist=NULL) | |
uty_copy ($source, $dest, $overwrite=FALSE, $whitelist=NULL, $blacklist=NULL) | |
uty_include_js ($basename, $path=NULL) | |
uty_postval ($name) | |
uty_check_md5 ($value) | |
Variables | |
$_UTY_JS = array() | |
$_UTY_CSS = array() | |
$_UTY_ERRORS = array() | |
$_UTY_LOG = "" | |
$_UTY_LOG_LEVEL = 0 | |
$_UTY_DEBUG = FALSE |
uty_check_file_ext | ( | $ | basename, | |
$ | whitelist = NULL , |
|||
$ | blacklist = NULL | |||
) |
Performs multiple file extensions check.
basename | (string) the basename of the file to check | |
[whitelist] | (array) case sensitive list of allowed extension, default=NULL | |
[blacklist] | (array) case insensitive list of forbidden extension, default=NULL |
uty_check_md5 | ( | $ | value | ) |
value | (string) the 32 hex digit string to check |
uty_check_path | ( | $ | path, | |
$ | root = "/" | |||
) |
Takes two (absolute or relative) paths and determines if one is a subdirectory of the other it doesn't care if it is an immediate child or 10 subdirectories deep... use absolute paths for both for best results NB: path MUST exist!
path | (string) the absolute or relative path to check | |
[root] | (string) the folder path must belong to, default="/" |
uty_copy | ( | $ | source, | |
$ | dest, | |||
$ | overwrite = FALSE , |
|||
$ | whitelist = NULL , |
|||
$ | blacklist = NULL | |||
) |
Copy file/folder $source to $dest. If $source is a folder use recursion
$source | (string) the path (absolute or relative) to the source file/folder | |
$dest | (string) the path (absolute or relative) to the source file/folder | |
[$overwrite] | [bool] if TRUE overwrite existing files, if FALSE and a file exists stops and return error, default=FALSE | |
[whitelist] | (array) case sensitive list of allowed extension, default=NULL | |
[blacklist] | (array) case insensitive list of forbidden extension, default=NULL |
uty_dir | ( | $ | path, | |
$ | sortkey = NULL , |
|||
$ | sortorder = UTY_SORT_ASC | |||
) |
list all files/directories in path as an array of "stat" where stat is the associative array returned by the stat function PLUS this xtra information: stat['basename'] = basename stat['fullname'] = path.'/'.basename stat['dirtype'] = UTY_DIRTYPE_FOLDER or UTY_DIRTYPE_FILE
path | (string) the path to get list of | |
[sortkey] | (string) 'basename', 'size' or 'ctime', if NULL the filesystem decide the order, default=NULL | |
[sortorder] | (int) sort order(*), default=UTY_SORT_ASC |
NB: basename sort is case insensitive
uty_error_handler | ( | $ | php_level, | |
$ | message, | |||
$ | file, | |||
$ | line | |||
) |
THIS IS NOT AN APY, THIS IS PHP ERROR HANDLER CALLBACK. After you called uty_error_reporting, ALL php error are sent here!
If (level & error_reporting(setted in uty_set_error_handler)) append to $_UTY_ERRORS a new utyResult with:
NOTABENE:
php_level | php error level. NB don't mismatch this with UTY_ERR_* error level | |
message | php error message | |
file | php error file | |
line | php error line |
uty_exit | ( | $ | status_code, | |
$ | status_text = "OK" , |
|||
$ | content = "" , |
|||
$ | content_type = "text/plain; charset:utf-8" | |||
) |
Set http status line, prints content and die.
NB: MUST be called BEFORE any content has been print to output (useful for ajax responses)
status_code | (int) http status code (200=OK, 1xx information, 2xx success, 3xx redirection, 4xx client error, 5xx server error | |
[status_text] | (string) http status text, default = "OK" (*) | |
[content] | (string) response content, default = "" | |
[content_type] | (string) Content-Type header value, default="text/plain; charset:utf-8" |
NOTABENE:
uty_fullurl | ( | ) |
uty_include_js | ( | $ | basename, | |
$ | path = NULL | |||
) |
Outuputs the $path/$basename script tag once. (resamble include_once) Automatically resolves javascript dependancies for utillyty scripts
basename | (string) the basename of the javascript file, i.e: 'uty.js' | |
[path] | (string) the path (WITHOUT trailing '/') to the script. NULL for utilliyty's js, default=NULL |
NOTABENE:
uty_log | ( | $ | level, | |
$ | message | |||
) |
Write message to the log if level>=_UTY_LOG_LEVEL
level | (int) the message log level, one of the UTY_ERR_* const. | |
message | (mixed) any string or object to be logged (print_r is used) |
uty_normalize_path | ( | $ | path, | |
$ | dir = FALSE | |||
) |
Replace any '\' with '/'
$path | (string) the path to normalize | |
[$dir] | (bool) if TRUE append a trailing '/' (if not present), default=FALSE |
uty_postval | ( | $ | name | ) |
name | (string) the post variable name |
uty_remove | ( | $ | path, | |
$ | whitelist = NULL , |
|||
$ | blacklist = NULL | |||
) |
Removes a file or a folder using recursion.
$path | (string) the path (absolute or relative) of the file/folder to remove | |
[whitelist] | (array) case sensitive list of allowed extension, default=NULL | |
[blacklist] | (array) case insensitive list of forbidden extension, default=NULL |
uty_set_error_handler | ( | $ | debug = FALSE |
) |
Custom error reportings: Sets $_UTY_DEBUG to $debug, php error handler to uty_error_handler, and php error_reporting to -1 if debug or E_ALL & ~E_NOTICE otherwise. Sets also display_errors = debug
NOTABENE:
[debug] | (bool) the utillyty debug status, default = FALSE |
uty_set_log | ( | $ | log_path = "./log" , |
|
$ | log_level = UTY_ERR_USR | |||
) |
log settings
[log_path] | (string) the path where log files are stored WITHOUT trailing '/', default='./log'. if log_path="" NO log will be saved. | |
[log_level] | (UTY_ERR) one of UTY_ERR_* const. uty_log will log messages with level>=log_level (NB: utyResult calls uty_log when created), default = UTY_ERR_USR. |
$_UTY_CSS = array() |
(array) list of included stylesheets paths (not yet used...)
$_UTY_DEBUG = FALSE |
(bool) if TRUE utyResult will include backtrace.
class definitions =======================================================
/* * @ brief Detailed context information for the utyResult class. / class utyStackFrame { public $program; /**< (string) automatically set to uty_fullurl() * / public $file; /**< (string) php script file name* / public $line; /**< (int) line number in the file * / public $func; /**< (string) function name * / public $args; /**< (array) name=>value list of arguments * / public $time; /**< (string )unix time* / public $etc; /**< (array) contains: 'post'=>print_r($_POST, true), you can add anything else you want * /
/** Create utyStackFrame with the specified info.
file | (string) __FILE__ (php executing file name) | |
line | (int) __LINE__ (php file line number) | |
func | (string) __FUNCTION__ (function name) | |
[args] | (array) name=>value pairs of calling arguments, default=NULL / function utyStackFrame($file, $line, $func, $args=NULL) { $this->time = microtime(); $this->program = uty_fullurl(); $this->file = $file; $this->line = $line; $this->func = $func; $this->args = $args; $this->etc = array('post' => print_r($_POST, TRUE)); } /** Push an argument to the arguments list. | |
argn | (string) argument name | |
argv | (mixed) argument value / function arg($argn, $argv) { if (!$this->$args) $this->$args = array(); $this->$args[$argn] = $argv; } }; |
$_UTY_ERRORS = array() |
(array) list of utyResult containing not catched runtime errors. you must call uty_set_error_reporting
$_UTY_JS = array() |
(array) list of included javascript paths(used by uty_include_js)
$_UTY_LOG = "" |
(string) path to the folder where errors are logged.
$_UTY_LOG_LEVEL = 0 |
(int) UTY_ERR_* level of messages to log.
Copyright © 2010 Attilio Pavone - www.utillyty.eu