Static Public Member Functions | |
| static | get_params ($params) |
| static | end_in_slash ($value) |
| static | redirect ($url= '', $continue=false) |
| static | atomtime ($t) |
| static | nonce () |
| static | WSSE ($nonce= '', $timestamp= '') |
| static | stripslashes ($value) |
| static | addslashes ($value) |
| static | de_amp ($value) |
| static | revert_magic_quotes_gpc () |
| static | quote_spaced ($value) |
| static | implode_quoted ($separator, $values) |
| static | placeholder_string ($count) |
| static | archive_pages ($item_total, $items_per_page=null) |
| static | map_array ($value, $prefix= '{$', $postfix= '}') |
| static | debug_reveal ($show, $hide, $debugid, $close=false) |
| static | debug () |
| static | firedebug () |
| static | firebacktrace ($backtrace) |
| static | crypt ($password, $hash=null) |
| static | sha1 ($password, $hash=null) |
| static | md5 ($password, $hash=null) |
| static | ssha ($password, $hash=null) |
| static | ssha512 ($password, $hash=null) |
| static | getdate ($timestamp) |
| static | locale_date ($format, $timestamp) |
| static | slugify ($string, $separator= '-') |
| static | html_select ($name, $options, $current=null, $properties=array()) |
| static | html_checkboxes ($name, $options) |
| static | truncate ($str, $len=10, $middle=true) |
| static | php_check_syntax ($code, &$error=null) |
| static | php_check_file_syntax ($file, &$error=null) |
| static | glob ($pattern, $flags=0) |
| static | human_size ($bytesize) |
| static | single_array ($element) |
| static | mimetype ($filename) |
| static | trail ($value=false) |
| static | mail ($to, $subject, $message, $headers=array(), $parameters= '') |
| static | random_password ($length=10) |
| static | array_or ($input) |
| static | ror ($v, $w) |
| static | check_request_method ($expected) |
| static | glob_to_regex ($glob) |
| static | scheme_ports ($scheme=null) |
| static | is_traversable ($data) |
| static | get_ip () |
| static | htmlspecialchars ($string, $quote_flag=ENT_COMPAT, $encoding= 'UTF-8') |
| static | regexdelim ($string, $choices=null) |
| static | html_attr ($attrs) |
Static Public Attributes | |
| static | $debug_defined = false |
Habari Utility Class
Definition at line 11 of file utils.php.
| static Utils::addslashes | ( | $ | value | ) | [static] |
function addslashes Adds slashes to escape strings, including strings in arrays
Definition at line 140 of file utils.php.
Referenced by firebacktrace(), and firedebug().
| static Utils::archive_pages | ( | $ | item_total, | |
| $ | items_per_page = null | |||
| ) | [static] |
function archive_pages Returns the number of pages in an archive using the number of items per page set in options
| integer | Number of items in the archive | |
| integer | Number of items per page |
Definition at line 230 of file utils.php.
Referenced by Theme::theme_next_page_link(), and Theme::theme_page_selector().
| static Utils::array_or | ( | $ | input | ) | [static] |
Does a bitwise OR of all the numbers in an array
| array | $input An array of integers |
Definition at line 951 of file utils.php.
Referenced by Post::get_access(), Comment::get_access(), and ACL::grant_group().
| static Utils::atomtime | ( | $ | t | ) | [static] |
| static Utils::check_request_method | ( | $ | expected | ) | [static] |
Checks whether the correct HTTP method was used for the request
| array | $expected Expected HTTP methods for the request |
Definition at line 969 of file utils.php.
Referenced by FeedbackHandler::act_add_comment(), AdminHandler::act_admin(), AtomHandler::act_collection(), AtomHandler::act_comments(), Theme::act_display(), AtomHandler::act_entry(), AtomHandler::act_entry_comments(), AtomHandler::act_introspection(), UserHandler::act_login(), UserHandler::act_logout(), UserHandler::act_password_reset(), CronTab::act_poll_cron(), AtomHandler::act_rsd(), AtomHandler::act_tag_collection(), AdminThemesHandler::ajax_add_block(), AdminCommentsHandler::ajax_comments(), AdminDashboardHandler::ajax_dashboard(), AdminThemesHandler::ajax_delete_block(), AdminLogsHandler::ajax_delete_logs(), AdminGroupsHandler::ajax_groups(), AdminLogsHandler::ajax_logs(), AdminPostsHandler::ajax_media(), AdminPostsHandler::ajax_media_panel(), AdminPostsHandler::ajax_posts(), AdminThemesHandler::ajax_save_areas(), AdminTagsHandler::ajax_tags(), AdminCommentsHandler::ajax_update_comment(), AdminGroupsHandler::ajax_update_groups(), AdminPostsHandler::ajax_update_posts(), and AdminThemesHandler::get_configure_block().
| static Utils::crypt | ( | $ | password, | |
| $ | hash = null | |||
| ) | [static] |
Crypt a given password, or verify a given password against a given hash.
| string | $password the password to crypt or verify | |
| string | $hash (optional) if given, verify $password against $hash |
Definition at line 400 of file utils.php.
Referenced by UserHandler::act_password_reset(), User::authenticate(), AdminUsersHandler::form_user_success(), AdminUsersHandler::post_users(), CronTab::run_cron(), and WSSE().
| static Utils::de_amp | ( | $ | value | ) | [static] |
| static Utils::debug | ( | ) | [static] |
Outputs a call stack with parameters, and a dump of the parameters passed. mixed Any number of parameters to output in the debug box.
Definition at line 272 of file utils.php.
Referenced by UserThemeHandler::act(), and Term::setslug().
| static Utils::debug_reveal | ( | $ | show, | |
| $ | hide, | |||
| $ | debugid, | |||
| $ | close = false | |||
| ) | [static] |
| static Utils::end_in_slash | ( | $ | value | ) | [static] |
function end_in_slash Forces a string to end in a single slash
| string | A string, usually a path |
Definition at line 46 of file utils.php.
Referenced by Themes::get_active().
| static Utils::firebacktrace | ( | $ | backtrace | ) | [static] |
| array | $backtrace An array of backtrace details from debug_backtrace() |
Definition at line 359 of file utils.php.
Referenced by firedebug().
| static Utils::firedebug | ( | ) | [static] |
| static Utils::get_ip | ( | ) | [static] |
Get the remote IP address, but try and take into account users who are behind proxies, whether they know it or not.
Definition at line 1050 of file utils.php.
Referenced by FeedbackHandler::add_comment(), SpamChecker::get_code(), EventLog::log(), Session::read(), Session::write(), and Pingback::xmlrpc_pingback__ping().
| static Utils::get_params | ( | $ | params | ) | [static] |
function get_params Returns an associative array of parameters, whether the input value is a querystring or an associative array.
| mixed | An associative array or querystring parameter list |
Definition at line 30 of file utils.php.
Referenced by QueryRecord::__construct(), CronJob::__construct(), ActionHandler::act_redirect(), URL::extract_args(), UserGroups::get(), Post::get(), LogEntry::get(), EventLog::get(), Users::get(), Posts::get(), Comments::get(), and Format::more().
| static Utils::getdate | ( | $ | timestamp | ) | [static] |
| static Utils::glob | ( | $ | pattern, | |
| $ | flags = 0 | |||
| ) | [static] |
Replacement for system glob that returns an empty array if there are no results
Definition at line 749 of file utils.php.
Referenced by FileCache::_purge(), Themes::get_all(), Themes::get_all_data(), Site::get_dir(), AdminHandler::get_sysinfo(), HabariLocale::list_all(), Plugins::list_all(), HabariSilo::silo_dir(), HabariSilo::silo_get(), RawPHPEngine::template_exists(), and DatabaseConnection::upgrade().
| static Utils::glob_to_regex | ( | $ | glob | ) | [static] |
Returns a regex pattern equivalent to the given glob pattern
Definition at line 988 of file utils.php.
Referenced by FileCache::_expire(), and APCCache::_expire().
| static Utils::html_attr | ( | $ | attrs | ) | [static] |
Create a list of html element attributes from an associative array
| array | $attrs An associative array of parameters |
Definition at line 1144 of file utils.php.
Referenced by Format::term_tree().
| static Utils::html_checkboxes | ( | $ | name, | |
| $ | options | |||
| ) | [static] |
Creates one or more HTML checkboxes
| string | The name of the checkbox element. If there are multiple checkboxes for the same name, this method will automatically apply "[]" at the end of the name | |
| array | An array of checkbox options. Each element should be an array containing "name" and "value". If the checkbox should be checked, it should have a "checked" element. |
| static Utils::html_select | ( | $ | name, | |
| $ | options, | |||
| $ | current = null, |
|||
| $ | properties = array() | |||
| ) | [static] |
Create an HTML select tag with options and a current value
| string | $name The name and id of the select control | |
| array | $options An associative array of values to use as the select options | |
| string | $current The value of the currently selected option | |
| array | $properties An associative array of additional properties to assign to the select control |
Definition at line 602 of file utils.php.
Referenced by AdminUsersHandler::get_user().
| static Utils::htmlspecialchars | ( | $ | string, | |
| $ | quote_flag = ENT_COMPAT, |
|||
| $ | encoding = 'UTF-8' | |||
| ) | [static] |
Call htmlspecialchars() with the correct flags and encoding, without double escaping strings. See http://php.net/manual/en/function.htmlspecialchars.php for details on the parameters and purpose of the function.
| $string. | string. The string to escape | |
| $quote_flag. | integer. Sets what quotes and doublequotes are escaped | |
| $encoding. | string. The encoding of the passed string |
Definition at line 1086 of file utils.php.
Referenced by AtomHandler::act_introspection(), FlickrSilo::action_plugin_ui_confirm(), AtomHandler::add_comments(), AtomHandler::add_posts(), AtomHandler::create_atom_wrapper(), AtomHandler::get_entry(), HiEngineParser::hi_command(), html_attr(), and AdminPostsHandler::post_delete_post().
| static Utils::human_size | ( | $ | bytesize | ) | [static] |
Produces a human-readable size string. For example, converts 12345 into 12.34KB
| integer | $bytesize Number of bytes |
Definition at line 784 of file utils.php.
Referenced by ViddlerSilo::filter_media_panels().
| static Utils::implode_quoted | ( | $ | separator, | |
| $ | values | |||
| ) | [static] |
| static Utils::is_traversable | ( | $ | data | ) | [static] |
determines if the given that is travesable in foreach
| mixed | $data |
Definition at line 1040 of file utils.php.
Referenced by Posts::get(), and placeholder_string().
| static Utils::locale_date | ( | $ | format, | |
| $ | timestamp | |||
| ) | [static] |
Return a formatted date/time trying to use strftime() AND date()
| string | $format The format for the date. If it contains non-escaped percent signs, it uses strftime(), otherwise date() | |
| integer | $timestamp The unix timestamp of the time to format |
| static Utils::mail | ( | $ | to, | |
| $ | subject, | |||
| $ | message, | |||
| $ | headers = array(), |
|||
| $ | parameters = '' | |||
| ) | [static] |
Send email
| string | $to The destination address | |
| string | $subject The subject of the message | |
| string | $message The message itself | |
| array | $headers An array of key=>value pairs for additional email headers | |
| string | $parameters Additional parameters to mail() |
Definition at line 899 of file utils.php.
Referenced by UserHandler::act_login(), and UserHandler::act_password_reset().
| static Utils::map_array | ( | $ | value | ) | [static] |
Used with array_map to create an array of PHP stringvar-style search/replace strings using optional pre/postfixes $mapped_values= array_map(array('Utils', 'map_array'), $values);
| string | $value The value to wrap | |
| string | $prefix The prefix for the returned value | |
| string | $postfix The postfix for the returned value |
| static Utils::md5 | ( | $ | password, | |
| $ | hash = null | |||
| ) | [static] |
| static Utils::mimetype | ( | $ | filename | ) | [static] |
Return the mimetype of a file
| string | $filename the path of a file |
Definition at line 824 of file utils.php.
Referenced by HabariSilo::silo_get().
| static Utils::nonce | ( | ) | [static] |
| static Utils::php_check_file_syntax | ( | $ | file, | |
| &$ | error = null | |||
| ) | [static] |
Check the PHP syntax of (and execute) the specified file.
Definition at line 734 of file utils.php.
Referenced by Plugins::check_every_plugin_syntax(), and AdminPluginsHandler::get_plugins().
| static Utils::php_check_syntax | ( | $ | code, | |
| &$ | error = null | |||
| ) | [static] |
Check the PHP syntax of the specified code. Performs a syntax (lint) check on the specified code testing for scripting errors.
| string | $code The code string to be evaluated. It does not have to contain PHP opening tags. |
Definition at line 691 of file utils.php.
Referenced by php_check_file_syntax().
| static Utils::placeholder_string | ( | $ | count | ) | [static] |
Returns a string of question mark parameter placeholders.
Useful when building, for instance, an IN() list for SQL
| count | Number of placeholders to put in the string |
Definition at line 215 of file utils.php.
Referenced by Vocabulary::delete(), Posts::get(), and Comments::get().
| static Utils::quote_spaced | ( | $ | value | ) | [static] |
| static Utils::random_password | ( | $ | length = 10 |
) | [static] |
Create a random password of a specific length
| integer | $length Length of the password, if not provded, 10 |
Definition at line 935 of file utils.php.
Referenced by UserHandler::act_login(), and UserHandler::act_password_reset().
| static Utils::redirect | ( | $ | url = '', |
|
| $ | continue = false | |||
| ) | [static] |
function redirect Redirects the request to a new URL
| string | $url The URL to redirect to, or omit to redirect to the current url | |
| boolean | $continue Whether to continue processing the script (default false for security reasons, cf. #749) |
Definition at line 57 of file utils.php.
Referenced by AdminHandler::__construct(), InstallHandler::act_begin_install(), UserHandler::act_login(), UserHandler::act_logout(), ActionHandler::act_redirect(), FeedbackHandler::add_comment(), User::forget(), AdminOptionsHandler::form_options_success(), AdminUsersHandler::form_user_success(), AdminThemesHandler::get_activate_theme(), AdminCommentsHandler::get_comment(), AdminGroupsHandler::get_group(), AdminPluginsHandler::get_plugin_toggle(), AdminThemesHandler::get_preview_theme(), AdminUsersHandler::get_user(), AdminPostsHandler::post_delete_post(), AdminGroupsHandler::post_group(), AdminImportHandler::post_import(), and AdminGroupsHandler::update_groups().
| static Utils::regexdelim | ( | $ | string, | |
| $ | choices = null | |||
| ) | [static] |
Convenience function to find a usable PCRE regular expression delimiter for a particular string. (I.e., some character that *isn't* found in the string.)
| $string. | string. The string for which to find a delimiter. | |
| $choices. | string. Delimiters from which to choose one. | |
| $encoding. | string. The encoding of the passed string |
| static Utils::revert_magic_quotes_gpc | ( | ) | [static] |
| static Utils::ror | ( | $ | v, | |
| $ | w | |||
| ) | [static] |
| static Utils::scheme_ports | ( | $ | scheme = null |
) | [static] |
Return the port used for a specific URL scheme
| string | $scheme The scheme in question |
Definition at line 1011 of file utils.php.
Referenced by InputFilter::glue_url().
| static Utils::sha1 | ( | $ | password, | |
| $ | hash = null | |||
| ) | [static] |
| static Utils::single_array | ( | $ | element | ) | [static] |
Convert a single non-array variable into an array with that one element
| mixed | $element Some value, either an array or not |
Definition at line 810 of file utils.php.
Referenced by UserGroup::add(), Post::add_tokens(), User::can_any(), AdminHandler::filter_menus_by_permission(), Posts::get(), UserGroup::grant(), User::grant(), Post::has_tokens(), UserGroup::remove(), Post::remove_tokens(), UserGroup::revoke(), User::revoke(), Post::set_tokens(), Theme::theme_body_class(), and Theme::theme_content().
| static Utils::slugify | ( | $ | string, | |
| $ | separator = '-' | |||
| ) | [static] |
Return a sanitized slug, replacing non-alphanumeric characters to dashes
| string | $string The string to sanitize. Non-alphanumeric characters will be replaced by dashes | |
| string | $separator The slug separator, '-' by default |
Definition at line 579 of file utils.php.
Referenced by Term::__construct(), Block::__get(), Theme::act_display(), Post::add_new_type(), Block::content_type(), ACL::create_default_tokens(), Post::delete_post_type(), AdminDashboardHandler::fetch_dashboard_modules(), CoreBlocks::filter_block_content_type_monthly_archives(), CoreBlocks::filter_block_content_type_tag_archives(), FormUI::get(), Posts::get(), Comments::get(), AtomHandler::get_collection(), Tags::parse_url_tags(), AdminOptionsHandler::post_options(), Term::setslug(), FlickrSilo::silo_dir(), Modules::storage_name(), and Format::term_tree().
| static Utils::ssha | ( | $ | password, | |
| $ | hash = null | |||
| ) | [static] |
Crypt or verify a given password using SSHA. Implements the {Seeded,Salted}-SHA algorithm as per RfC 2307.
| string | $password the password to crypt or verify | |
| string | $hash (optional) if given, verify $password against $hash |
| static Utils::ssha512 | ( | $ | password, | |
| $ | hash = null | |||
| ) | [static] |
Crypt or verify a given password using SSHA512. Implements a modified version of the {Seeded,Salted}-SHA algorithm from RfC 2307, using SHA-512 instead of SHA-1.
Requires the new hash*() functions.
| string | $password the password to crypt or verify | |
| string | $hash (optional) if given, verify $password against $hash |
Definition at line 514 of file utils.php.
Referenced by crypt().
| static Utils::stripslashes | ( | $ | value | ) | [static] |
function stripslashes Removes slashes from escaped strings, including strings in arrays
Definition at line 125 of file utils.php.
Referenced by SuperGlobal::process_c(), SuperGlobal::process_gps(), and revert_magic_quotes_gpc().
| static Utils::trail | ( | $ | value = false |
) | [static] |
Returns a trailing slash or a string, depending on the value passed in
| mixed | $value A trailing string value |
Definition at line 878 of file utils.php.
Referenced by Site::get_dir(), Site::get_path(), and Site::get_url().
| static Utils::truncate | ( | $ | str, | |
| $ | len = 10, |
|||
| $ | middle = true | |||
| ) | [static] |
Trims longer phrases to shorter ones with elipsis in the middle
| string | The string to truncate | |
| integer | The length of the returned string | |
| bool | Whether to place the ellipsis in the middle (true) or at the end (false) |
| static Utils::WSSE | ( | $ | nonce = '', |
|
| $ | timestamp = '' | |||
| ) | [static] |
function WSSE returns an array of tokens used for WSSE authentication http://www.xml.com/pub/a/2003/12/17/dive.html http://www.sixapart.com/developers/atom/protocol/atom_authentication.html
| String | a nonce | |
| String | a timestamp |
Definition at line 104 of file utils.php.
Referenced by AdminLogsHandler::ajax_delete_logs(), AdminTagsHandler::ajax_tags(), AdminCommentsHandler::ajax_update_comment(), AdminPostsHandler::ajax_update_posts(), AdminGroupsHandler::get_group(), AdminGroupsHandler::get_groups(), AdminPostsHandler::get_publish(), AdminTagsHandler::get_tags(), AdminPostsHandler::post_delete_post(), AdminGroupsHandler::post_group(), AdminGroupsHandler::post_groups(), AdminGroupsHandler::update_groups(), and AdminUsersHandler::update_users().
1.7.1