[ Index ]
 

Code source de phpMyAdmin 2.10.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/libraries/ -> common.lib.php (sommaire)

Misc stuff and functions used by almost all the scripts. Among other things, it contains the advanced authentication work.

Poids: 3301 lignes (116 kb)
Inclus ou requis: 70 fois
Référencé: 0 fois
Nécessite: 22 fichiers
 libraries/url_generating.lib.php
 libraries/footer.inc.php
 libraries/Config.class.php
 libraries/sqlvalidator.lib.php
 libraries/js_escape.lib.php
 libraries/sanitizing.lib.php
 libraries/PMA_List_Database.class.php
 libraries/language.lib.php
 libraries/ip_allow_deny.lib.php
 libraries/Theme_Manager.class.php
 libraries/kanji-encoding.lib.php
 libraries/Table.class.php
 libraries/cleanup.lib.php
 libraries/sqlparser.lib.php
 libraries/session.inc.php
 libraries/header_meta_style.inc.php
 libraries/database_interface.lib.php
 libraries/header.inc.php
 libraries/Theme.class.php
 libraries/charset_conversion.lib.php
 libraries/grab_globals.lib.php
 libraries/string.lib.php

Définit 45 fonctions

  PMA_securePath()
  PMA_getTableCount()
  PMA_get_real_size()
  PMA_dl()
  PMA_array_merge_recursive()
  PMA_arrayWalkRecursive()
  PMA_checkPageValidity()
  PMA_getenv()
  PMA_removeCookie()
  PMA_setCookie()
  PMA_pow()
  PMA_getIcon()
  PMA_displayMaximumUploadSize()
  PMA_generateHiddenMaxFileSize()
  PMA_sqlAddslashes()
  PMA_escape_mysql_wildcards()
  PMA_unescape_mysql_wildcards()
  PMA_unQuote()
  PMA_formatSql()
  PMA_showMySQLDocu()
  PMA_showHint()
  PMA_mysqlDie()
  PMA_convert_using()
  PMA_sendHeaderLocation()
  PMA_getTableList()
  PMA_backquote()
  PMA_whichCrlf()
  PMA_reloadNavigation()
  PMA_showMessage()
  PMA_formatByteDown()
  PMA_formatNumber()
  PMA_getEnumSetOptions()
  PMA_localisedDate()
  PMA_getTab()
  PMA_getTabs()
  PMA_linkOrButton()
  PMA_timespanFormat()
  PMA_flipstring()
  PMA_checkParameters()
  PMA_getUniqueCondition()
  PMA_buttonOrImage()
  PMA_pageselector()
  PMA_userDir()
  PMA_getDbLink()
  PMA_externalBug()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

PMA_securePath($path)   X-Ref
Removes insecure parts in a path; used before include() or
require() when a part of the path comes from an insecure source
like a cookie or form.

author: Marc Delisle (lem9@users.sourceforge.net)
param: string  The path to check
return: string  The secured path

PMA_getTableCount($db)   X-Ref
returns count of tables in given db

param: string  $db database to count tables for
return: integer count of tables in $db

PMA_get_real_size($size = 0)   X-Ref
Converts numbers like 10M into bytes
Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
(renamed with PMA prefix to avoid double definition when embedded
in Moodle)

param: string  $size
return: integer $size

PMA_dl($module)   X-Ref
loads php module

param: string  $module name if module to load
return: boolean success loading module

PMA_array_merge_recursive()   X-Ref
merges array recursive like array_merge_recursive() but keyed-values are
always overwritten.

array PMA_array_merge_recursive(array $array1[, array $array2[, array ...]])

param: array   array to merge
param: array   array to merge
param: array   ...
return: array   merged array

PMA_arrayWalkRecursive(&$array, $function, $apply_to_keys_also = false)   X-Ref
calls $function vor every element in $array recursively

param: array   $array      array to walk
param: string  $function   function to call for every array element

PMA_checkPageValidity(&$page, $whitelist)   X-Ref
boolean phpMyAdmin.PMA_checkPageValidity(string &$page, array $whitelist)

checks given given $page against given $whitelist and returns true if valid
it ignores optionaly query paramters in $page (script.php?ignored)

param: string  &$page      page to check
param: array   $whitelist  whitelist to check page against
return: boolean whether $page is valid or not (in $whitelist or not)

PMA_getenv($var_name)   X-Ref
trys to find the value for the given environment vriable name

searchs in $_SERVER, $_ENV than trys getenv() and apache_getenv()
in this order

param: string  $var_name   variable name
return: string  value of $var or empty string

PMA_removeCookie($cookie)   X-Ref
removes cookie

param: string  $cookie     name of cookie to remove
return: boolean result of setcookie()

PMA_setCookie($cookie, $value, $default = null, $validity = null, $httponly = true)   X-Ref
sets cookie if value is different from current cokkie value,
or removes if value is equal to default

param: string  $cookie     name of cookie to remove
param: mixed   $value      new cookie value
param: string  $default    default value
param: int     $validity   validity of cookie in seconds (default is one month)
param: bool    $httponlt   whether cookie is only for HTTP (and not for scripts)
return: boolean result of setcookie()

PMA_pow($base, $exp, $use_function = false)   X-Ref
Exponential expression / raise number into power

param: number  $base
param: number  $exp
param: string  pow function use, or false for auto-detect
return: mixed  string or float

PMA_getIcon($icon, $alternate = '')   X-Ref
string PMA_getIcon(string $icon)

param: $icon   name of icon
return: html img tag

PMA_displayMaximumUploadSize($max_upload_size)   X-Ref
Displays the maximum size for an upload

param: integer  the size
return: string   the message

PMA_generateHiddenMaxFileSize($max_size)   X-Ref
Generates a hidden field which should indicate to the browser
the maximum size for upload

param: integer  the size
return: string   the INPUT field

PMA_sqlAddslashes($a_string = '', $is_like = false, $crlf = false, $php_code = false)   X-Ref
Add slashes before "'" and "\" characters so a value containing them can
be used in a sql comparison.

param: string   the string to slash
param: boolean  whether the string will be used in a 'LIKE' clause
param: boolean  whether to treat cr/lfs as escape-worthy entities
param: boolean  whether this function is used as part of the
return: string   the slashed string

PMA_escape_mysql_wildcards($name)   X-Ref
Add slashes before "_" and "%" characters for using them in MySQL
database, table and field names.
Note: This function does not escape backslashes!

param: string   the string to escape
return: string   the escaped string

PMA_unescape_mysql_wildcards($name)   X-Ref
removes slashes before "_" and "%" characters
Note: This function does not unescape backslashes!

param: string   $name  the string to escape
return: string   the escaped string

PMA_unQuote($quoted_string, $quote = null)   X-Ref
removes quotes (',",`) from a quoted string

checks if the sting is quoted and removes this quotes

param: string  $quoted_string  string to remove quotes from
param: string  $quote          type of quote to remove
return: string  unqoted string

PMA_formatSql($parsed_sql, $unparsed_sql = '')   X-Ref
format sql strings

author: Robin Johnson <robbat2@users.sourceforge.net>
param: mixed    pre-parsed SQL structure
return: string   the formatted sql

PMA_showMySQLDocu($chapter, $link, $big_icon = false)   X-Ref
Displays a link to the official MySQL documentation

param: string  chapter of "HTML, one page per chapter" documentation
param: string  contains name of page/anchor that is being linked
param: bool    whether to use big icon (like in left frame)
return: string  the html link

PMA_showHint($hint_message)   X-Ref
Displays a hint icon, on mouse over show the hint

param: string   the error message

PMA_mysqlDie($error_message = '', $the_query = '',$is_modify_link = true, $back_url = '',$exit = true)   X-Ref
Displays a MySQL error message in the right frame.

param: string   the error message
param: string   the sql query that failed
param: boolean  whether to show a "modify" link or not
param: string   the "back" link url (full path is not required)
param: boolean  EXIT the page?

PMA_convert_using($string, $mode='unquoted')   X-Ref
Returns a string formatted with CONVERT ... USING
if MySQL supports it

param: string  the string itself
param: string  the mode: quoted or unquoted (this one by default)
return: the formatted string

PMA_sendHeaderLocation($uri)   X-Ref
Send HTTP header, taking IIS limits into account (600 seems ok)

param: string   $uri the header to send
return: boolean  always true

PMA_getTableList($db, $tables = null)   X-Ref
returns array with tables of given db with extended infomation and grouped

param: string  $db     name of db

PMA_backquote($a_name, $do_it = true)   X-Ref
Adds backquotes on both sides of a database, table or field name.
and escapes backquotes inside the name with another backquote

<code>
echo PMA_backquote('owner`s db'); // `owner``s db`
</code>

param: mixed    $a_name    the database, table or field name to "backquote"
param: boolean  $do_it     a flag to bypass this function (used by dump
return: mixed    the "backquoted" database, table or field name if the

PMA_whichCrlf()   X-Ref
Defines the <CR><LF> value depending on the user OS.

return: string   the <CR><LF> value to use

PMA_reloadNavigation()   X-Ref
Reloads navigation if needed.


PMA_showMessage($message, $sql_query = null)   X-Ref
displays the message and the query
usually the message is the result of the query executed

param: string  $message    the message to display
param: string  $sql_query  the query to display

PMA_formatByteDown($value, $limes = 6, $comma = 0)   X-Ref
Formats $value to byte view

author: staybyte
param: double   the value to format
param: integer  the sensitiveness
param: integer  the number of decimals to retain
return: array    the formatted value and its unit

PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false)   X-Ref
Formats $value to the given length and appends SI prefixes
$comma is not substracted from the length
with a $length of 0 no truncation occurs, number is only formated
to the current locale
<code>
echo PMA_formatNumber(123456789, 6);     // 123,457 k
echo PMA_formatNumber(-123456789, 4, 2); //    -123.46 M
echo PMA_formatNumber(-0.003, 6);        //      -3 m
echo PMA_formatNumber(0.003, 3, 3);      //       0.003
echo PMA_formatNumber(0.00003, 3, 2);    //       0.03 m
echo PMA_formatNumber(0, 6);             //       0
</code>

author: staybyte, sebastian mendel
param: double   $value     the value to format
param: integer  $length    the max length
param: integer  $comma     the number of decimals to retain
param: boolean  $only_down do not reformat numbers below 1
return: string   the formatted value and its unit

PMA_getEnumSetOptions($type_def)   X-Ref
Extracts ENUM / SET options from a type definition string

author: rabus
param: string   The column type definition
return: array    The options or

PMA_localisedDate($timestamp = -1, $format = '')   X-Ref
Writes localised date

param: string   the current timestamp
return: string   the formatted date

PMA_getTab($tab)   X-Ref
returns a tab for tabbed navigation.
If the variables $link and $args ar left empty, an inactive tab is created

param: array   $tab    array with all options
return: string  html code for one tab, a link if valid otherwise a span

PMA_getTabs($tabs, $tag_id = 'topmenu')   X-Ref
returns html-code for a tab navigation

param: array   $tabs   one element per tab
param: string  $tag_id id used for the html-tag
return: string  html-code for tab-navigation

PMA_linkOrButton($url, $message, $tag_params = array()   X-Ref
Displays a link, or a button if the link's URL is too large, to
accommodate some browsers' limitations

param: string  the URL
param: string  the link message
param: mixed   $tag_params  string: js confirmation
param: boolean $new_form    we set this to false when we are already in
return: string  the results to be echoed or saved in an array

PMA_timespanFormat($seconds)   X-Ref
Returns a given timespan value in a readable format.

param: int     the timespan
return: string  the formatted value

PMA_flipstring($string, $Separator = "<br />\n")   X-Ref
Takes a string and outputs each character on a line for itself. Used
mainly for horizontalflipped display mode.
Takes care of special html-characters.
Fulfills todo-item
http://sf.net/tracker/?func=detail&aid=544361&group_id=23067&atid=377411

author: Garvin Hicking <me@supergarv.de>
param: string   The string
param: string   The Separator (defaults to "<br />\n")
return: string      The flipped string

PMA_checkParameters($params, $die = true, $request = true)   X-Ref
Function added to avoid path disclosures.
Called by each script that needs parameters, it displays
an error message and, by default, stops the execution.

Not sure we could use a strMissingParameter message here,
would have to check if the error message file is always available

author: Marc Delisle (lem9@users.sourceforge.net)
param: array   The names of the parameters needed by the calling
param: boolean Stop the execution?
param: boolean Whether to include this list in checking for special params.

PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row)   X-Ref
Function to generate unique condition for specified row.

author: Michal Cihar (michal@cihar.com) and others...
param: resource    $handle         current query result
param: integer     $fields_cnt     number of fields
param: array       $fields_meta    meta information about fields
param: array       $row            current row
return: string      calculated condition

PMA_buttonOrImage($button_name, $button_class, $image_name, $text,$image)   X-Ref
Generate a button or image tag

author: Michal Cihar (michal@cihar.com)
param: string      name of button element
param: string      class of button element
param: string      name of image element
param: string      text to display
param: string      image to display

PMA_pageselector($url, $rows, $pageNow = 1, $nbTotalPage = 1,$showAll = 200, $sliceStart = 5, $sliceEnd = 5, $percent = 20,$range = 10)   X-Ref
Generate a pagination selector for browsing resultsets

author: Garvin Hicking (pma@supergarv.de)
param: string      URL for the JavaScript
param: string      Number of rows in the pagination set
param: string      current page number
param: string      number of total pages
param: string      If the number of pages is lower than this
param: string      How many rows at the beginning should always
param: string      How many rows at the end should always
param: string      Percentage of calculation page offsets to
param: string      Near the current page, how many pages should

PMA_userDir($dir)   X-Ref


PMA_getDbLink($database = null)   X-Ref
returns html code for db link to default db page

param: string  $database
return: string  html link to default db page

PMA_externalBug($functionality, $component, $minimum_version, $bugref)   X-Ref
Displays a lightbulb hint explaining a known external bug
that affects a functionality

param: string  $functionality localized message explaining the func.
param: string  $component  'mysql' (eventually, 'php')
param: string  $minimum_version of this component
param: string  $bugref  bug reference for this component



Généré le : Mon Nov 26 15:18:20 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics