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 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
set a cookie
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
-
string
$b: resulting date format
-
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_directory
(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
()
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
()
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, [string $params = ''], [boolean $full = false], [boolean $encode_amp = true])
-
string
$action: use 'action'
-
string
$params: any params to append?
-
boolean
$full: if 'true', returns an absolute uri otherwise relative
-
boolean
$encode_amp: if 'true', ampersands are encoded to '&'
forward an entry to log system deliver input as args: first is level '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
()
output maintenance message and end execution
static
void
maintenance_mode
()
reset all template vars except common one
static
boolean
reset_tpl
()
sanitize user inputs - very(!) important
available flags: okifempty,forcestr,enforce,stripspaces,restrict,nosymlink,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 blowfish algorithm
static
string
scramble
(string $a, [string $b = 'auto'])
-
string
$a: input stream
-
string
$b: use 'auto' mode or 'encrypt' respectively 'decrypt'
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
static
string
token
(integer $a, [string $b = 'int'], [string $c = 'weak'])
-
integer
$a: length of token
-
string
$b: choose token type: 'int', '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_directory()'
-
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'
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: public,protected,ro,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
()