Textpattern PHP Cross Reference Content Management Systems

Summary: /textpattern/lib/txplib_admin.php - 2052 lines - 56941 bytes - Source - Print

Description: Collection of password handling functions.

Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 50 functions

send_account_activation()
send_reset_confirmation_request()
send_password()
send_new_password()
generate_password()
reset_author_pass()
gTxtScript()
updatePartials()
updateVolatilePartials()
get_safe_image_types()
check_gd()
image_data()
adminErrorHandler()
updateErrorHandler()
register_page_extension()
register_tab()
pluggable_ui()
get_form_types()
get_essential_forms()
permlinkmodes()
getDefaultSection()
event_change_pageby()
event_multi_edit()
find_temp_dir()
get_uploaded_file()
get_filenames()
shift_uploaded_file()
assign_user_assets()
is_valid_username()
create_user()
update_user()
change_user_password()
remove_user()
rename_user()
user_exists()
change_user_group()
txp_validate()
txp_hash_password()
generate_user_token()
modal_halt()
announce()
load_lang_dates()
load_lang_event()
install_textpack()
form_token()
bouncer()
check_file_integrity()
assert_system_requirements()
get_prefs_theme()
txp_dateformats()

Functions

Functions that are not part of a class:

send_account_activation($name line: 30
Emails a new user with account details and requests they set a password.

return: bool FALSE on error.
param: string $name     The login name
send_reset_confirmation_request($name line: 88
Sends a password reset link to a user's email address.

This function will return a success message even when the specified user
doesn't exist. Though an error message could be thrown when a user isn't
found, security best practice prevents leaking existing account names.

return: string A localized message string
param: string $name The login name
send_password($RealName, $name, $email, $password line: 176
Emails a new user with login details.

This function can be only executed when the currently authenticated user
trying to send the email was granted 'admin.edit' privileges.

Should NEVER be used as sending plaintext passwords is wrong.
Will be removed in future, in lieu of sending reset request tokens.

return: bool FALSE on error.
param: string $RealName The real name
param: string $name     The login name
param: string $email    The email address
param: string $password The password
send_new_password($password, $email, $name line: 217
Sends a new password to an existing user.

If the $name is FALSE, the password is sent to the currently
authenticated user.

Should NEVER be used as sending plaintext passwords is wrong.
Will be removed in future, in lieu of sending reset request tokens.

return: bool FALSE on error.
param: string $password The new password
param: string $email    The email address
param: string $name     The login name
generate_password($length = 10)  line: 258
Generates a password.

Generates a random password of given length using the symbols set in
PASSWORD_SYMBOLS constant.

Should NEVER be used as it is not cryptographically secure.
Will be removed in future, in lieu of sending reset request tokens.

return: string Random plain-text password
param: int $length The length of the password
reset_author_pass($name line: 301
Resets the given user's password and emails it.

The old password is replaced with a new random-generated one.

Should NEVER be used as sending plaintext passwords is wrong.
Will be removed in future, in lieu of sending reset request tokens.

return: string A localized message string
param: string $name The login name
gTxtScript($var, $atts = array()  line: 337
Loads client-side localisation scripts.

Passes localisation strings from the database to JavaScript.

Only works on the admin-side pages.

param: string|array $var   Scalar or array of string keys
param: array        $atts  Array or array of arrays of variable substitution pairs
param: array        $route Optional events/steps upon which to add the strings
updatePartials($partials, $rs, $types line: 370
Handle refreshing the passed AJAX content to the UI.

param: array $partials Partials array
param: array $rs       Record set of the edited content
updateVolatilePartials($partials line: 393
Handle refreshing the passed AJAX content to the UI.

return: array           Response to send back to the browser
param: array $partials Partials array
get_safe_image_types($type = null)  line: 434
Lists image types that can be safely uploaded.

Returns different results based on the logged in user's privileges.

return: mixed
param: int         $type If set, validates the given value
check_gd($image_type line: 466
Checks if GD supports the given image type.

return: bool TRUE if the type is supported
param: string $image_type Either '.gif', '.jpg', '.png'
image_data($file, $meta = array()  line: 497
Uploads an image.

Can be used to upload a new image or replace an existing one.
If $id is specified, the image will be replaced. If $uploaded is set FALSE,
$file can take a local file instead of HTTP file upload variable.

All uploaded files will included on the Images panel.

return: array|string An array of array(message, id) on success, localized error string on error
param: array        $file     HTTP file upload variables
param: array        $meta     Image meta data, allowed keys 'caption', 'alt', 'category'
param: int          $id       Existing image's ID
param: bool         $uploaded If FALSE, $file takes a filename instead of upload vars
adminErrorHandler($errno, $errstr, $errfile, $errline line: 631
Error handler for admin-side pages.

param: int    $errno
param: string $errstr
param: string $errfile
param: int    $errline
updateErrorHandler($errno, $errstr, $errfile, $errline line: 728
Error handler for update scripts.

param: int    $errno
param: string $errstr
param: string $errfile
param: int    $errline
register_page_extension($func, $event, $step = '', $top = 0)  line: 753
Registers an admin-side extension page.

For now this just does the same as register_callback().

param: callback $func  The callback function
param: string   $event The callback event
param: string   $step  The callback step
param: bool     $top   The top or the bottom of the page
register_tab($area, $panel, $title line: 772
Registers a new admin-side panel and adds a navigation link to the menu.

param: string $area  The menu the panel appears in, e.g. "home", "content", "presentation", "admin", "extensions"
param: string $panel The panel's event
param: string $title The menu item's label
pluggable_ui($event, $element, $default = '')  line: 794
Call an event's pluggable UI function.

return: mixed  Returned value from a callback handler, or $default if no custom UI was provided
param: string $event   The event
param: string $element The element selector
param: string $default The default interface markup
get_form_types()  line: 821
Gets a list of form types.

The list form types can be extended with a 'form.types > types'
callback event. Callback functions get passed three arguments: '$event',
'$step' and '$types'. The third parameter contains a reference to an
array of 'type => label' pairs.

return: array An array of form types
get_essential_forms()  line: 849
Gets a list of essential form templates.

These forms can not be deleted or renamed. The array keys hold
the form names, the array values their group.

The list forms can be extended with a 'form.essential > forms'
callback event. Callback functions get passed three arguments: '$event',
'$step' and '$essential'. The third parameter contains a reference to an
array of forms.

return: array An array of form names
permlinkmodes($name, $val, $blank = false)  line: 885
Renders a HTML <select> list of supported permanent link URL formats.

return: string HTML
param: string $name HTML name and id of the list
param: string $val  Initial (or current) selected item
getDefaultSection()  line: 909
Gets the name of the default publishing section.

return: string The section
event_change_pageby($name = null)  line: 934
Updates a list's per page number.

Gets the per page number from a "qty" HTTP POST/GET parameter and
creates a user-specific preference value "$name_list_pageby".

param: string|null $name The name of the list
event_multi_edit($table, $id_key line: 951
Generic multi-edit form's edit handler shared across panels.

Receives an action from a multi-edit form and runs it in the given
database table.

return: string Comma-separated list of affected items
param: string $table  The database table
param: string $id_key The database column selected items match to. Column should be integer type
find_temp_dir()  line: 985
Verifies temporary directory.

Verifies that the temporary directory is writeable.

return: bool|null NULL on error, TRUE on success
param: string $dir The directory to check
get_uploaded_file($f, $dest = '')  line: 1040
Moves an uploaded file and returns its new location.

return: string|bool The new path or FALSE on error
param: string $f    The filename of the uploaded file
param: string $dest The destination of the moved file. If omitted, the file is moved to the temp directory
get_filenames($path = null, $options = GLOB_NOSORT)  line: 1072
Gets an array of files in the Files directory that weren't uploaded
from Textpattern.

Used for importing existing files on the server to Textpattern's files panel.

return: array An array of file paths
param: string $path    The directory to scan
param: int    $options glob() options
shift_uploaded_file($f, $dest line: 1131
Moves a file.

return: bool TRUE on success, or FALSE on error
param: string $f    The file to move
param: string $dest The destination
assign_user_assets($owner, $new_owner line: 1155
Assigns assets to a different user.

Changes the owner of user's assets. It will move articles, files, images
and links from one user to another.

Should be run when a user's permissions are taken away, a username is
renamed or the user is removed from the site.

Affected database tables can be extended with a 'user.assign_assets > columns'
callback event. Callback functions get passed three arguments: '$event',
'$step' and '$columns'. The third parameter contains a reference to an
array of 'table => column' pairs.

On a successful run, will trigger a 'user.assign_assets > done' callback event.

return: bool FALSE on error
param: string|array $owner     List of current owners
param: string       $new_owner The new owner
is_valid_username($name line: 1216
Validates a string as a username.

return: bool TRUE if the string valid
param: string $name The username
create_user($name, $email, $password, $realname = '', $group = 0)  line: 1241
Creates a user account.

On a successful run, will trigger a 'user.create > done' callback event.

return: bool FALSE on error
param: string $name     The login name
param: string $email    The email address
param: string $password The password
param: string $realname The real name
param: int    $group    The user group
update_user($user, $email = null, $realname = null, $meta = array()  line: 1291
Updates a user.

Updates a user account's properties. The $user argument is used for
selecting the updated user, and rest of the arguments new values.
Use NULL to omit an argument.

On a successful run, will trigger a 'user.update > done' callback event.

return: bool FALSE on error
param: string      $user     The updated user
param: string|null $email    The email address
param: string|null $realname The real name
param: array|null  $meta     Additional meta fields
change_user_password($user, $password line: 1346
Changes a user's password.

On a successful run, will trigger a 'user.password_change > done' callback event.

return: bool FALSE on error
param: string $user     The updated user
param: string $password The new password
remove_user($user, $new_owner line: 1386
Removes a user.

The user's assets are assigned to the given new owner.

On a successful run, will trigger a 'user.remove > done' callback event.

return: bool FALSE on error
param: string|array $user      List of removed users
param: string       $new_owner Assign assets to
rename_user($user, $newname line: 1430
Renames a user.

On a successful run, will trigger a 'user.rename > done' callback event.

return: bool FALSE on error
param: string $user    Updated user
param: string $newname The new name
user_exists($user line: 1472
Checks if a user exists.

return: bool TRUE if the user exists
param: string $user The user
change_user_group($user, $group line: 1491
Changes a user's group.

On a successful run, will trigger a 'user.change_group > done' callback event.

return: bool FALSE on error
param: string|array $user  Updated users
param: int          $group The new group
txp_validate($user, $password, $log = true)  line: 1533
Validates the given user credentials.

Validates a given login and a password combination. If the combination is
correct, the user's login name is returned, FALSE otherwise.

If $log is TRUE, also checks that the user has permissions to access the
admin side interface. On success, updates the user's last access timestamp.

return: string|bool The user's login name or FALSE on error
param: string $user     The login
param: string $password The password
param: bool   $log      If TRUE, requires privilege level greater than 'none'
txp_hash_password($password line: 1590
Calculates a password hash.

return: string A hash
param: string $password The password
generate_user_token($ref, $type, $expiryTimestamp, $pass, $nonce line: 1612
Create a secure token hash in the database from the passed information.

return: string                  Secure token suitable for emailing as part of a link
param: int    $ref             Reference to the user's account (user_id)
param: string $type            Flavour of token to create
param: int    $expiryTimestamp UNIX timestamp of when the token will expire
param: string $pass            Password, used as part of the token generation
param: string $nonce           Random nonce associated with the user's account
modal_halt($thing line: 1657
Display a modal client message in response to an AJAX request and
halt execution.

param: string|array $thing The $thing[0] is the message's text; $thing[1] is the message's type (one of E_ERROR or E_WARNING, anything else meaning "success"; not used)
announce($message, $type = 0, $flags = TEXTPATTERN_ANNOUNCE_ADAPTIVE)  line: 1676
Sends an activity message to the client.

param: string|array $message The message
param: int          $type    The type, either 0, E_ERROR, E_WARNING
param: int          $flags   Flags, consisting of TEXTPATTERN_ANNOUNCE_ADAPTIVE | TEXTPATTERN_ANNOUNCE_ASYNC | TEXTPATTERN_ANNOUNCE_MODAL | TEXTPATTERN_ANNOUNCE_REGULAR
load_lang_dates($lang line: 1707
Loads date definitions from a localisation file.

param: string $lang The language
load_lang_event($event, $lang = LANG)  line: 1738
Gets language strings for the given event.

If no $lang is specified, the strings are loaded from the currently
active language.

return: array|string Array of string on success, or an empty string when no strings were found
param: string $event The event to get, e.g. "common", "admin", "public"
param: string $lang  The language code
install_textpack($textpack, $add_new_langs = false)  line: 1774
Installs localisation strings from a Textpack.

return: int Number of installed strings
param: string $textpack      The Textpack to install
param: bool   $add_new_langs If TRUE, installs strings for any included language
form_token()  line: 1789
Generate a ciphered token.

The token is reproducible, unique among sites and users, expires later.

return: string The token
bouncer($step, $steps line: 1814
Validates admin steps and protects against CSRF attempts using tokens.

Takes an admin step and validates it against an array of valid steps.
The valid steps array indicates the step's token based session riding
protection needs.

If the step requires CSRF token protection, and the request doesn't come with
a valid token, the request is terminated, defeating any CSRF attempts.

If the $step isn't in valid steps, it returns FALSE, but the request
isn't terminated. If the $step is valid and passes CSRF validation,
returns TRUE.

return: bool If the $step is valid, proceeds and returns TRUE. Dies on CSRF attempt.
param: string $step  Requested admin step
param: array  $steps An array of valid steps with flag indicating CSRF needs, e.g. array('savething' => true, 'listthings' => false)
check_file_integrity($flags = INTEGRITY_STATUS)  line: 1875
Checks install's file integrity and returns results.

Depending on the given $flags this function will either return an array of
file statuses, checksums or the digest of the install. It can also return the
parsed contents of the checksum file.

return: array|bool Array of files and status, or FALSE on error
param: int $flags Options are INTEGRITY_MD5 | INTEGRITY_STATUS | INTEGRITY_REALPATH | INTEGRITY_DIGEST
assert_system_requirements()  line: 1975
Assert system requirements.

get_prefs_theme()  line: 1992
Get Theme prefs
Now Textpattern does not support themes. If the setup folder is deleted, it will return an empty array.

txp_dateformats()  line: 2008
Renders an array of available ways to display the date.

return: array

title

Body