check if selected user can access an 'action'
static
boolean
access_control
(string $action, [integer $uid = 0], [integer $gid = 0])
-
string
$action: name of action
-
integer
$uid: user id, current if not given
-
integer
$gid: group id, current if not given
narrows an array down to string
static
string
arr2str
(array $a)
transforms a bool to 'yes' or 'no'
static
string
bool2yn
(boolean $a)
store a checksum locally and compare it, if requested
static
mixed
chksum_query
(string $class, string $name, [string $data = ''])
-
string
$class: 'get' does a comparison and 'put' stores a hash of input
-
string
$name: name
-
string
$data: sha1 hash on 'put' for later comparison
clears a query string from unencoded chars
don't use it on $_GET and $_REQUEST as they are already decoded!
static
string
clear_query_string
(string $a, [string $b = ''])
-
string
$a: query string
-
string
$b: flags: force_decode, strip_html
converts a string to unicode, if not already in this encoding
static
boolean
convert_to_utf8
(array $a)
set a cookie. encrypted by default; not very tight, but (maybe) enough to beat junior black-hats ;) is automatically disabled, if suhosin is detected and it already encrypts cookies.
static
boolean
cookie
(string $a, mixed $b, [mixed $c = 0])
-
string
$a: name of cookie
-
mixed
$b: value to store, set null to remove
-
mixed
$c: expiry time, can be integer or like '3d' for three days
format a date output
static
string
date
([integer $a = 0], [string $b = ''], [boolean $c = false])
-
integer
$a: input timestamp, should be UTC
-
string
$b: resulting date format (default is RFC 822)
-
boolean
$c: if 'true', output is 'human readable'
all-purpose file handler - abstracts common php code snippets
flags: read,write,delete,noroot,local,remote,append,verify,compression=[none|auto|gz|bz2]
static
mixed
file_handler
(string $fd, [string $data = ''], [string $flags = ''])
-
string
$fd: filename
-
string
$data: input stream
-
string
$flags: options - have a look at method for details
get a configuration value
static
mixed
get_cfg
(string $a)
-
string
$a: key or '*' for all
get current supported configuration values
static
array
get_cfg_data
()
get vars from 'vault'
static
array
get_env
()
get group data
static
mixed
get_group
([integer $a = 0])
-
integer
$a: group id, current if not given. '*' returns all.
count set bits in input and returns them as hex
static
string
get_masqueraded_folder
(integer $a)
fetch a list of all tables currently stored in database
static
array
get_table_list
()
get user data - return data, if found, and caches it in class vars
static
array
get_user
([array $uid = 0])
-
array
$uid: user id, current if not given. if array, the first user is returned.
fetches user group from database and store them in class vars
static
true
get_user_group_data
()
hash a bitstream e.g. plaintext password - 256-bit requires php extension (usually available)
static
string
hash
(string $input, [boolean $salt = true], [boolean $ext = true])
-
string
$input: input stream
-
boolean
$salt: add salt to password soup?
-
boolean
$ext: if 'true' returns 256-bit hash, otherwise 160-bit
calculate the hash from input - usuable on non-scalar values
static
string
hash_cache_keys
(mixed $a, [boolean $b = true])
-
mixed
$a: input stream
-
boolean
$b: if 'true', use keys instead of values from input as long as it is an array
returns value if is set otherwise a default
static
mixed
ifset
(string $class, string $name, string $default)
-
string
$class: location to look: 'get', 'post' or other
-
string
$name: name of variable
-
string
$default: default value to return, if not set
well, prepare some fun for inconvenient users *haha*
static
true
init_annoyances
()
initialize basics: check php settings and prepare user input arrays
static
true
init_begin
()
initialize caching system
static
true
init_cache
()
process configuration
static
true
init_cfg
([boolean $safemode = false])
-
boolean
$safemode: use safemode while loading? if 'true', we read it plain from db and do no post processing.
initialize database connection
static
true
init_db
()
set 'action' to run, access checks and set basic template vars
static
true
init_end
()
intialize common variables and prepare database table array
static
true
init_env
()
fetch core language file and detect preferred language by browser settings
static
true
init_i18n
()
load and prepare imageset along stylesheet definitions
static
true
init_style
()
run a scheduled task, if enabled.
static
boolean
init_task
()
prepare smarty template engine handing html outputs
static
true
init_tpl
()
initialize user data and cache group data
static
true
init_user
()
parse a link
static
string
link
(string $action, [mixed $params = array()], [boolean $encode_amp = true])
-
string
$action: use 'action'
-
mixed
$params: any params to append?
-
boolean
$encode_amp: if 'true', ampersands are encoded to '&'
forward an entry to log system deliver input as args: first is level 'system', 'info' or 'error'. any following are combined as message.
odd [1,3,5,...] become a 'description' for an entry. even [2,4,6,...] are its message. you may also pass all args in an array as first argument. example: logger('info','foo','bar','userid',3,'select','false') or logger(array('info','foo','bar','userid',3,'select','false'))
static
boolean
logger
()
parse logging messages for (human readable) output
static
true
logger_parse_message
( &$r, object $r)
-
object
$r: results of log entry from database
-
&$r
output maintenance message and end execution
static
void
maintenance_mode
()
reload configuration table by using safe mode
static
boolean
reload_safe_cfg
()
reset all template vars except common one
static
boolean
reset_tpl
()
scan through folders recursively
static
array
rscandir
(string $base, [boolean $list_files = true], [ &$data = array()], array $data)
-
string
$base: base folder
-
boolean
$list_files: if true, also list files
-
array
$data: data stream
-
&$data
sanitize user inputs - very(!) important
available flags: okifempty,forcestr,enforce,stripspaces,restrict,fullascii,hex,oct,length=,range=,o= 'str,strwbr,path,file' are *sanitizing* (strip illegal chars), others are *validating* (return 'false' on illegal chars) normally we do not allow empty input (zero strlen), use 'okifempty' flag to change this! hex|oct (currently) not support 'range='
static
mixed
sanitize_var
(string $input, string $class, [string $flags = ''])
-
string
$input: input stream
-
string
$class: validate against what type?
-
string
$flags: some flags - see method for details
(de)scramble a string using cryptography
static
string
scramble
(string $a, [string $b = 'auto'], [string $c = 'ARC4'])
-
string
$a: input stream
-
string
$b: use 'auto' mode or 'encrypt' respectively 'decrypt'
-
string
$c: select algorithm: 'ARC4' is fast and 'Blowfish' is slow, but more secure
return last inserted id after sql query
static
mixed
sql_lastId
(string $a)
-
string
$a: resource descriptor - currently only for postgres
perform a sql query
first char can be a flag: ?=debug selects, -=just simulate and !=only output query params === '-' -> do not log query in debug trace AND no check before execution if table exists
static
mixed
sql_query
(string $query, [array $params = array()], [string $method = ''], [integer $line = 0])
-
string
$query: the query
-
array
$params: params for prepared statements
-
string
$method: what method issued it?
-
integer
$line: on which line?
transaction abstraction layer
mysql gets a simulation by locking because it (still/actually) lacks transactions *sigh* you should not use nested transactions to allow using databases not support them
static
boolean
sql_transaction
(string $class, [array $params = array()])
-
string
$class: 'begin', 'commit', 'rollback' or 'is_running', may contain a name separated by colon
-
array
$params: additional table locks for databases not supporting transactions
increase statistic counter by one
static
boolean
statistic
(string $a)
-
string
$a: descriptor - see statistic table for details
strips trailing slashes
static
string
strip_trailing_slash
(string $a)
store a transaction number to session for using in forms
static
boolean
tan
(string $a, [ $b = '+'])
-
string
$a: requested 'action'
-
$b
returns a valid database table name for usage in sql queries
static
string
tbl
(string $a, [boolean $b = false])
-
string
$a: name of table (keys of array XF::tbl()), '*' selects all
-
boolean
$b: if 'true', returns raw value
terminate script execution and output error message
static
void
terminate
(string $msg, [boolean $beautify = false])
-
string
$msg: input stream
-
boolean
$beautify: if 'true', displays some nice error messages for users instead of 'cold' exception report
create a token - useful on creating passwords or digests
int=0-9, strict=a-f0-9, alnum=a-zA-Z0-9, binary=x00-xff
static
string
token
(integer $a, [string $b = 'int'], [string $c = 'weak'])
-
integer
$a: length of token
-
string
$b: choose token type: 'int', 'strict', 'alnum' or 'binary'
-
string
$c: using 'strong' here creates a token for cryptographic use, forces 'binary'
rewire template engine cache to 'pool' when required
static
true
tpl_use_cache_pool
(integer $a, string $b)
-
integer
$a: id translated by 'XF::get_masqueraded_folder()'
-
string
$b: use 'begin' first, then 'change' to alter the folders and 'reset' after work
update the local caches like self::$user with new values
static
boolean
update_local_cache
(string $a, integer $b, string $c, mixed $d)
-
string
$a: cache identifier (currently 'user' only)
-
integer
$b: identifier of cache entry
-
string
$c: name of dataset
-
mixed
$d: new value
create an 'universal unique identifier'.
if we didn't make a mistake on calculation, this should be about 120-bit of randomness... output example: 550e8400-e29b-11d4-a716-446655440000 (not really strict RFC!)
static
string
uuid
()
validates input array for rejected 'false' data
static
boolean
validate_gpc_data
(array $a)
our 'vault': values can be stored here for class-wide reference
flags: pub,rw,required,token=
static
mixed
vault_query
(string $name, [string $value = ''], [string $flags = ''])
-
string
$name: name, '*' fetches all
-
string
$value: data
-
string
$flags: options, default is protected and read-only
start your engines :)
boolean
__construct
([string $mode = 'regular'], [array $options = array()])
-
string
$mode: select mode to execute: 'regular', 'ajax' or 'setup'
-
array
$options: options - see method for details
well, clean up after work and turn off the lights...
void
__destruct
()