Class XF

Description

XF handles all low-level including initialization, database connection and basic abstraction layers

Located in /class.root.php (line 41)


	
			
Class Constant Summary
 ANNOY_TIMESPAN = '10,20'
 DATE_RFC822 = 'D, d M Y H:i:s T'
 DEBUG = false
 POST_MAXLEN = 20000
 RSS_LAST = 2147483638
 RSS_MOD_UNAPPROVE = 2147483639
 TASK_RUN = ''
 VAULT_PUBLIC = 0x01
 VAULT_RO = 0x08
 VAULT_RW = 0x04
 VERSION = '0.8.36'
Variable Summary
static array $annoyances
static array $checksum
static array $config
static array $config_data
static array $group
static array $lang
static resource $sql
static mixed $sqllog
static boolean $sql_simulate
static mixed $tables_complete
static array $tags
static array $tbl
static resource $tpl
static array $user
static array $vault
static integer $vtoken
Method Summary
static boolean access_control (string $action, [integer $uid = 0], [integer $gid = 0])
static string arr2str (array $a)
static string bool2yn (boolean $a)
static mixed chksum_query (string $class, string $name, [string $data = ''])
static boolean cookie (string $a, mixed $b, [mixed $c = 0])
static string date ([integer $a = 0], [string $b = ''], [boolean $c = false])
static mixed file_handler (string $fd, [string $data = ''], [string $flags = ''])
static mixed get_cfg (string $a)
static array get_cfg_data ()
static array get_env ()
static mixed get_group ([integer $a = 0])
static string get_masqueraded_directory (integer $a)
static array get_table_list ()
static array get_user ([array $uid = 0])
static true get_user_group_data ()
static string hash (string $input, [boolean $salt = true], [boolean $ext = true])
static string hash_cache_keys (mixed $a, [boolean $b = true])
static mixed ifset (string $class, string $name, string $default)
static true init_annoyances ()
static true init_begin ()
static true init_cache ()
static true init_cfg ()
static true init_db ()
static true init_end ()
static true init_env ()
static true init_i18n ()
static boolean init_task ()
static true init_tpl ()
static true init_user ()
static string link (string $action, [string $params = ''], [boolean $full = false], [boolean $encode_amp = true])
static boolean logger ()
static void maintenance_mode ()
static boolean reset_tpl ()
static mixed sanitize_var (string $input, string $class, [string $flags = ''])
static string scramble (string $a, [string $b = 'auto'])
static mixed sql_lastId (string $a)
static mixed sql_query (string $query, [array $params = array()], [string $method = ''], [integer $line = 0])
static boolean sql_transaction (string $class, [array $params = array()])
static boolean statistic (string $a)
static string strip_trailing_slash (string $a)
static boolean tan (string $a, [ $b = '+'])
static string tbl (string $a, [boolean $b = false])
static void terminate (string $msg, [boolean $beautify = false])
static string token (integer $a, [string $b = 'int'], [string $c = 'weak'])
static true tpl_use_cache_pool (integer $a, string $b)
static boolean update_local_cache (string $a, integer $b, string $c, mixed $d)
static string uuid ()
static boolean validate_gpc_data (array $a)
static mixed vault_query (string $name, [string $value = ''], [string $flags = ''])
boolean __construct ([string $mode = 'regular'], [array $options = array()])
void __destruct ()
Variables
static array $annoyances = array(
'SHOW_BLANK_PAGE','PUT_IN_ANTEROOM','MAINTENANCE_MESSAGE','RANDOM_HTTP_ERROR','LOGOUT_THIS_TIME',
'REDIRECT_TO_INDEX','SCHABERNACK_MACHEN','KILL_AUTHENTICATION'
)
(line 236)
  • var: some annoyances for inconvenient users
  • access: protected
static array $checksum = array() (line 129)
  • var: simple checksum storage
  • access: protected
static array $config = array() (line 117)
  • var: parsed configuration vars
  • access: protected
static array $config_data = array( // root_* should always be first!
'root_uri'=>array('uri'),'root_path'=>array('path'),'auth_activate_limit'=>array('utime'),'auth_use_reauth'=>array('bool'),'auth_bind_ip'=>array('bool'),'auth_bind_agent'=>array('bool'),'auth_max_lifetime'=>array('utime'),'auth_max_faillogin'=>array('int'),'cache_acl'=>array('bool'),'cache_config'=>array('bool'),'cache_main'=>array('bool'),'cache_rss'=>array('bool'),'cache_topic'=>array('bool'),'cache_tpl'=>array('bool'),'cache_user'=>array('bool'),'cookie_domain'=>array('hostname','okifempty'),'cookie_path'=>array('path','okifempty'),'cookie_read_tracker'=>array('str'),'cookie_session'=>array('str'),'cookie_ssl_only'=>array('bool'),'help_class'=>array('enum','o=mail,o=direct'),'help_mail_address'=>array('mail','okifempty'),'http_output_zlib'=>array('bool'),'http_detect_language'=>array('bool'),'log_enable'=>array('bool'),'log_engine'=>array('enum','o=local'),'log_ip'=>array('bool'),'log_statistic'=>array('bool'),'mail_from_name'=>array('str'),'mail_from_mail'=>array('mail'),'main_debug_verbose'=>array('bool'),'main_default_group'=>array('int'),'main_enable'=>array('bool'),'main_guest_uid'=>array('int'),'main_language'=>array('lang'),'main_post_edit_limit'=>array('utime'),'main_post_per_page'=>array('int'),'main_style'=>array('style'),'main_tags_on_index'=>array('int'),'main_title'=>array('str'),'main_topic_per_page'=>array('int'),'main_uuid'=>array('str'),'main_version'=>array('int'),'param_action'=>array('str'),'param_ajax'=>array('file'),'param_file'=>array('file'),'rss_limit'=>array('int'),'rss_payload'=>array('bool'),'task_enable'=>array('bool'),'uri_css'=>array('uri'),'uri_gfx'=>array('uri'),'uri_js'=>array('uri'))
(line 179)
  • var: required configuration variables and their allowed content
  • access: protected
static array $group = array() (line 125)
  • var: cached group data
  • access: protected
static array $lang = array() (line 148)
  • var: language strings
  • access: public
static resource $sql = null (line 133)
  • var: sql resource handler
  • access: public
static mixed $sqllog = array() (line 133)
  • access: public
static boolean $sql_simulate = false (line 137)
  • var: only simulate query execution
  • access: public
static mixed $tables_complete = false (line 139)
  • access: protected
static array $tags = array() (line 152)
  • var: cached posting tags
  • access: public
static array $tbl = array(
'parsed'=>false,
'acl'=>'$P acl',
'config'=>'$P config',
'config_task'=>'$P config_task',
'group'=>'$P group',
'log'=>'$P log',
'post_data'=>'$P post_data',
'post_meta'=>'$P post_meta',
'post_prefix'=>'$P post_prefix',
'post_rating'=>'$P post_rating',
'search_result'=>'$P search_result',
'statistic'=>'$P statistic',
'tag_data'=>'$P tag_data',
'tag_meta'=>'$P tag_meta',
'user'=>'$P user',
'user_blacklist'=>'$P user_blacklist',
'user_bookmark'=>'$P user_bookmark',
'user_request'=>'$P user_request'
)
(line 156)
  • var: available tables in database
  • access: protected
static resource $tpl = null (line 144)
  • var: template engine handler
  • access: public
static array $user = array() (line 121)
  • var: cached user data
  • access: protected
static array $vault = array() (line 113)
  • var: our 'vault' - global variables for XF can be stored here
  • access: protected
static integer $vtoken = null (line 109)
  • var: token for accessing protected vars in 'vault'
  • access: protected
Methods
static method access_control (line 1136)

check if selected user can access an 'action'

  • since: 1.0.0
  • access: public
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
static method arr2str (line 1945)

narrows an array to string

  • since: 1.0.0
  • access: public
static string arr2str (array $a)
  • array $a: input stream
static method bool2yn (line 1967)

transforms a bool to 'yes' or 'no'

  • since: 1.0.0
  • access: public
static string bool2yn (boolean $a)
  • boolean $a: input stream
static method chksum_query (line 1529)

store a checksum locally and compare it, if requested

  • since: 1.0.0
  • access: public
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
static method cookie (line 938)

set a cookie

  • since: 1.0.0
  • access: public
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
static method date (line 1891)

format a date output

  • since: 1.0.0
  • access: public
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'
static method file_handler (line 1086)

all-purpose file handler - abstracts common php code snippets

flags: read,write,delete,noroot,local,remote,append,verify,compression=[none|auto|gz|bz2]

  • since: 1.0.0
  • access: public
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
static method get_cfg (line 1355)

get a configuration value

  • since: 1.0.0
  • access: public
static mixed get_cfg (string $a)
  • string $a: key or '*' for all
static method get_cfg_data (line 926)

get current supported configuration values

  • since: 1.0.0
  • access: public
static array get_cfg_data ()
static method get_env (line 917)

get vars from 'vault'

  • since: 1.0.0
  • access: public
static array get_env ()
static method get_group (line 1433)

get group data

  • since: 1.0.0
  • access: public
static mixed get_group ([integer $a = 0])
  • integer $a: group id, current if not given. '*' returns all.
static method get_masqueraded_directory (line 1814)

count set bits in input and returns them as hex

  • since: 1.0.0
  • access: public
static string get_masqueraded_directory (integer $a)
  • integer $a: input stream
static method get_table_list (line 902)

fetch a list of all tables currently stored in database

  • since: 1.0.0
  • access: public
static array get_table_list ()
static method get_user (line 1370)

get user data - return data, if found, and caches it in class vars

  • since: 1.0.0
  • access: public
static array get_user ([array $uid = 0])
  • array $uid: user id, current if not given. if array, the first user is returned.
static method get_user_group_data (line 854)

fetches user group from database and store them in class vars

  • since: 1.0.0
  • access: protected
static true get_user_group_data ()
static method hash (line 1030)

hash a bitstream e.g. plaintext password - 256-bit requires php extension (usually available)

  • since: 1.0.0
  • access: public
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
static method hash_cache_keys (line 1198)

calculate the hash from input - usuable on non-scalar values

  • since: 1.0.0
  • access: public
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
static method ifset (line 1603)

returns value if is set otherwise a default

  • since: 1.0.0
  • access: public
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
static method init_annoyances (line 750)

well, prepare some fun for inconvenient users *haha*

  • since: 1.0.0
  • access: protected
static true init_annoyances ()
static method init_begin (line 340)

initialize basics: check php settings and prepare user input arrays

  • since: 1.0.0
  • access: protected
static true init_begin ()
static method init_cache (line 427)

initialize caching system

  • since: 1.0.0
  • access: protected
static true init_cache ()
static method init_cfg (line 444)

process configuration

  • since: 1.0.0
  • access: protected
static true init_cfg ()
static method init_db (line 1979)

initialize database connection

  • since: 1.0.0
  • access: public
static true init_db ()
static method init_end (line 797)

set 'action' to run, access checks and set basic template vars

  • since: 1.0.0
  • access: protected
static true init_end ()
static method init_env (line 395)

intialize common variables and prepare database table array

  • since: 1.0.0
  • access: protected
static true init_env ()
static method init_i18n (line 711)

fetch core language file and detect preferred language by browser settings

  • since: 1.0.0
  • access: protected
static true init_i18n ()
static method init_task (line 526)

run a scheduled task, if enabled.

  • since: 1.0.0
  • access: protected
static boolean init_task ()
static method init_tpl (line 601)

prepare smarty template engine handing html outputs

  • since: 1.0.0
  • access: protected
static true init_tpl ()
static method init_user (line 632)

initialize user data and cache group data

  • since: 1.0.0
  • access: protected
static true init_user ()
static method link (line 1924)

parse a link

  • since: 1.0.0
  • access: public
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 '&'
static method logger (line 1242)

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'))

  • since: 1.0.0
  • access: public
static boolean logger ()
static method maintenance_mode (line 1588)

output maintenance message and end execution

  • since: 1.0.0
  • access: public
static void maintenance_mode ()
static method reset_tpl (line 1314)

reset all template vars except common one

  • since: 1.0.0
  • access: public
static boolean reset_tpl ()
static method sanitize_var (line 1628)

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='

  • since: 1.0.0
  • access: public
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
static method scramble (line 963)

(de)scramble a string using blowfish algorithm

  • since: 1.0.0
  • access: public
static string scramble (string $a, [string $b = 'auto'])
  • string $a: input stream
  • string $b: use 'auto' mode or 'encrypt' respectively 'decrypt'
static method sql_lastId (line 2195)

return last inserted id after sql query

  • since: 1.0.0
  • access: public
static mixed sql_lastId (string $a)
  • string $a: resource descriptor - currently only for postgres
static method sql_query (line 2049)

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

  • since: 1.0.0
  • access: public
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?
static method sql_transaction (line 2136)

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

  • since: 1.0.0
  • access: public
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
static method statistic (line 1281)

increase statistic counter by one

  • since: 1.0.0
  • access: public
static boolean statistic (string $a)
  • string $a: descriptor - see statistic table for details
static method strip_trailing_slash (line 1785)

strips trailing slashes

  • since: 1.0.0
  • access: public
static string strip_trailing_slash (string $a)
  • string $a: input stream
static method tan (line 1008)

store a transaction number to session for using in forms

  • since: 1.0.0
  • access: public
static boolean tan (string $a, [ $b = '+'])
  • string $a: requested 'action'
  • $b
static method tbl (line 1061)

returns a valid database table name for usage in sql queries

  • since: 1.0.0
  • access: public
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
static method terminate (line 1555)

terminate script execution and output error message

  • since: 1.0.0
  • access: public
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
static method token (line 1828)

create a token - useful on creating passwords or digests

  • since: 1.0.0
  • access: public
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'
static method tpl_use_cache_pool (line 1212)

rewire template engine cache to 'pool' when required

  • since: 1.0.0
  • access: public
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
static method update_local_cache (line 1336)

update the local caches like self::$user with new values

  • since: 1.0.0
  • access: public
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
static method uuid (line 989)

create an 'universal unique identifier'

output example: 550e8400-e29b-11d4-a716-446655440000 (not really strict RFC!)

  • since: 1.0.0
  • access: public
static string uuid ()
static method validate_gpc_data (line 1797)

validates input array for rejected 'false' data

  • since: 1.0.0
  • access: public
static boolean validate_gpc_data (array $a)
  • array $a: input stream
static method vault_query (line 1453)

our 'vault': values can be stored here for class-wide reference

flags: public,protected,ro,rw,required,token=

  • since: 1.0.0
  • access: public
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
Constructor __construct (line 249)

start your engines :)

  • since: 1.0.0
  • access: public
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
Destructor __destruct (line 325)

well, clean up after work and turn off the lights...

  • since: 1.0.0
  • access: public
void __destruct ()
Class Constants
ANNOY_PROBABILITY_ON_AJAX = 75 (line 97)
  • var: probability in percent a user gets annoyed on asynchronous requests, if enabled
ANNOY_TIMESPAN = '10,20' (line 93)
  • var: between x and y seconds we annoy an user on "regular" use, if enabled
DATABASE_VERSION = 1 (line 53)
  • var: demands this database version
DATE_RFC822 = 'D, d M Y H:i:s T' (line 81)
  • var: date formatting of standard timestamps
DEBUG = false (line 45)
  • var: debugging mode for developers - activates lots more verbosity :)
ENABLE_SCRAMBLE = true (line 85)
  • var: if 'true', we use encryption for cookies
POST_MAXLEN = 20000 (line 89)
  • var: maximal length of posting messages
RSS_LAST = 2147483638 (line 101)
  • var: mapped post id for last posts in rss feed (2^31-10)
RSS_MOD_UNAPPROVE = 2147483639 (line 105)
  • var: mapped post id for unapproved posts in rss feed (2^31-9)
TASK_INTERVAL = 3 (line 73)
  • var: run scheduled tasks every x minutes
TASK_RUN = '' (line 77)
  • var: directly set a scheduled task you want to run
VAULT_PROTECTED = 0x02 (line 65)
  • var: bit for 'vault': access requires token
VAULT_PUBLIC = 0x01 (line 69)
  • var: bit for 'vault': public access
VAULT_RO = 0x08 (line 57)
  • var: bit for 'vault': read-only access
VAULT_RW = 0x04 (line 61)
  • var: bit for 'vault': writeable access
VERSION = '0.8.36' (line 49)
  • var: the current software version

Documentation generated on Tue, 21 Oct 2008 20:58:14 +0200 by phpDocumentor 1.4.1