Class SensitiveIO

Description

Class SensitiveIO

Collection of static methods used to validate user input and output

Located in /automne/classes/common/sensitiveio.php (line 27)

CMS_grandFather
   |
   --SensitiveIO
Direct descendents
Class Description
 class io Class io
Method Summary
 static String arraySprintf (String $formatString, [array(String) $formatStringParameters = false])
 static boolean checkXHTMLValue (string $value, string &$errors)
 static string, convertTextToHTML (string $body, [boolean $withNl2Br = true])
 static array cp1252ToUtf8Map ()
 static string decodeEntities (string $text)
 static string decodeWindowsChars (string $input)
 static string ellipsis (string $value, integer $length, [integer $ellipsis = '...'], [boolean $center = false], [boolean $breakWords = true])
 static string evalPHPCode (string $input)
 static void filter ( $value, [ $filter = ''], [ $default = false])
 static string generateKey (int $keyLength)
 static void get ( $name, [ $filter = ''], [ $default = false])
 static string getCallInfos ([ $deep = 1])
 static string htmlspecialchars (mixed $input, [ $quote_style = ENT_QUOTES])
 static boolean isInSet (mixed $input, array(mixed) $set)
 static boolean isPositiveInteger (mixed $input)
 static boolean isUnderRange (mixed $input, mixed $min, mixed $max)
 static boolean isUTF8 ( $string)
 static boolean isValidEmail ( $email, [ $checkDomain = false], String $email.)
 static boolean isValidLogin (string $login)
 static boolean isValidPassword (string $input)
 static string jsonEncode (array $datas)
 static void natcasecmp ( $str1,  $str2)
 static void post ( $name, [ $filter = ''], [ $default = false])
 static void printBackTrace ( $backtrace)
 static string reencodeAmpersand (string $text)
 static mixed request (string $name, [mixed $filter = ''], [mixed $default = false])
 static array sanitizeAsciiMap ()
 static string sanitizeAsciiString (string $input, [string $keep = ''], [string $special = '_.-'])
 static string sanitizeExecCommand (mixed $input)
 static void sanitizeHTMLString ( $input)
 static string sanitizeJSString ( $input, [ $minimize = false], [ $addslashes = true], [ $keepCariageReturn = false], mixed $input:, boolean $minimize:, boolean $addslashes:)
 static string sanitizeSQLString (mixed $input)
 static string sanitizeURLString (mixed $input)
 static string stripPHPTags (mixed $input)
 static void strlen ()
 static void strpos ()
 static void strtolower ()
 static void strtoupper ()
 static mixed substr ()
 static void unsetRequest (string/array $requests)
 static string utf8Decode (string $text)
 static string utf8Encode (string $text)
 static string uuid ()
Methods
static arraySprintf (line 342)

Replaces each succesive %s with succesive array items Note if no %s in string or no $formatStringParameters then returns formatString

  • access: public
static String arraySprintf (String $formatString, [array(String) $formatStringParameters = false])
  • String $formatString: containing %s
  • array(String) $formatStringParameters: The array of parameters to replace the %s with
static checkXHTMLValue (line 636)

Check a value for XHTML errors

  • return: : true on success, false on failure
  • access: public
static boolean checkXHTMLValue (string $value, string &$errors)
  • string $value: The value to check
  • string &$errors: : Errors founded, returned by reference
static convertTextToHTML (line 604)

Convert textBody to HTMLBody, convert all links and \n tags

  • return: the body converted in html
  • access: public
static string, convertTextToHTML (string $body, [boolean $withNl2Br = true])
  • string $body: The body to convert
  • boolean $withNl2Br: : Use nl2br on returned text (default : true)
static cp1252ToUtf8Map (line 728)

Map of CP1252 characters not supported into latin to utf8 encoding

  • return: : the map
  • access: public
static array cp1252ToUtf8Map ()
static decodeEntities (line 694)

Decode HTML entities (charset insensitive)

  • return: : the value decoded
  • access: public
static string decodeEntities (string $text)
  • string $text: The HTML value to decode
static decodeWindowsChars (line 388)

Replace special chars returned by Windows shell or Word copy/paste by standard ISO 8859-1 chars Static method.

  • return: decoded
  • access: public
static string decodeWindowsChars (string $input)
  • string $input: The sensitive input
static ellipsis (line 485)

Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length

  • return: the value troncated
  • access: public
static string ellipsis (string $value, integer $length, [integer $ellipsis = '...'], [boolean $center = false], [boolean $breakWords = true])
  • string $value: The string value to troncate
  • integer $length: The maximum length of the returned string
  • integer $ellipsis: The ellipsis to add at the end of string (default : '...')
  • boolean $center: If true, cut the string in the middle (default : false)
  • boolean $breakWords: If false, do not cut the string in the middle of a word (default : true)
static evalPHPCode (line 437)

Evaluate all php blocks (like <?php ... ? >) founded in input string Static method.

  • return: with code evalued (all PHP code is replaced by his output value)
  • access: public
static string evalPHPCode (string $input)
  • string $input: The input string in which eval the code
static filter (line 61)
static void filter ( $value, [ $filter = ''], [ $default = false])
  • $value
  • $filter
  • $default
static generateKey (line 661)

Generate a random ascii key of determined length

  • return: the generated key
  • access: public
static string generateKey (int $keyLength)
  • int $keyLength: keyLength the desired length of the key
static get (line 49)
static void get ( $name, [ $filter = ''], [ $default = false])
  • $name
  • $filter
  • $default
static getCallInfos (line 508)

Get call infos of the caller function which call this one

  • return: the caller call info
  • access: public
static string getCallInfos ([ $deep = 1])
  • $deep
static htmlspecialchars (line 171)

Cleans a string that has to be echoed to the user.

Static method.

  • return: the sanitized string
  • access: public
static string htmlspecialchars (mixed $input, [ $quote_style = ENT_QUOTES])
  • mixed $input: The sensitive input.
  • $quote_style
static isInSet (line 134)

Tests the input to see if it is part of a given set of values.

Static method.

  • return: true if the input is part of the set, false otherwise
  • access: public
static boolean isInSet (mixed $input, array(mixed) $set)
  • mixed $input: The sensitive input.
  • array(mixed) $set: The set the input should be part of
static isPositiveInteger (line 121)

Tests the input to see if it is a positive integer.

Static method.

  • return: true if the input is a positive integer, false otherwise
  • access: public
static boolean isPositiveInteger (mixed $input)
  • mixed $input: The sensitive input
static isUnderRange (line 376)

Tests the input to see if it is an integer between min and max value.

Static method.

  • return: true if the input is in range, false otherwise
  • access: public
static boolean isUnderRange (mixed $input, mixed $min, mixed $max)
  • mixed $input: The sensitive input
  • mixed $min: The min value
  • mixed $max: The max value
static isUTF8 (line 791)

Try to detect UTF-8 content

  • return: true/false
  • author: chris AT w3style.co DOT uk
  • access: private
static boolean isUTF8 ( $string)
  • $string
static isValidEmail (line 286)

Parses input string for email format correctness Static method.

  • access: public
static boolean isValidEmail ( $email, [ $checkDomain = false], String $email.)
  • String $email.
  • $email
  • $checkDomain
static isValidLogin (line 309)

Check if the login is valid

  • return: true on success, false on failure
  • access: public
static boolean isValidLogin (string $login)
  • string $login
static isValidPassword (line 328)

Parses input string as if it is a password, and return the "well-formed" status : must be at least 5 chars long, ...

Static method.

  • access: public
static boolean isValidPassword (string $input)
  • string $input: the user input to be login
static jsonEncode (line 459)

Encode a multidimentionnal array in json format Convert datas in utf-8 if needed

  • return: json encoded datas
  • access: public
static string jsonEncode (array $datas)
  • array $datas: The datas to convert
static natcasecmp (line 875)

Callback function for natural sorting without care of accentuation

Usage : Sort on array values : uasort( (array) $array, array('io','natcasecmp')); Sort on array keys : uksort( (array) $array, array('io','natcasecmp'));

  • access: public
static void natcasecmp ( $str1,  $str2)
  • $str1
  • $str2
static post (line 55)
static void post ( $name, [ $filter = ''], [ $default = false])
  • $name
  • $filter
  • $default
static printBackTrace (line 537)
static void printBackTrace ( $backtrace)
  • $backtrace
static reencodeAmpersand (line 683)

Check a value and force reencode of ampersand without double encode them :

& => &amp; &amp; => &amp; &eacute; => &eacute; &#123; => &#123;

  • return: : the value reencoded
  • access: public
static string reencodeAmpersand (string $text)
  • string $text: The HTML value to reencode
static request (line 43)

Filter request input Static method.

  • return: : the original value if it pass the filter or boolean false otherwise
  • access: public
static mixed request (string $name, [mixed $filter = ''], [mixed $default = false])
  • string $name: The request name to filter
  • mixed $filter: The filter to use. Can be :
    • a string of a function name or static object method (class::method) to use for the check (must return true / false)
    • a string for a regular expression to validate with preg_match
    • an array of possible values (case sensitive)
    • nothin, in this case, the request value is returned as it (if it exists)
  • mixed $default: The default value to return if request is empty or does not match the filter rule (default : false)
static sanitizeAsciiMap (line 766)

Map of non-ascii characters to convert in ascii equivalent

  • return: : the map
  • access: public
static array sanitizeAsciiMap ()
static sanitizeAsciiString (line 206)

Cleans a string containing other thing than [a..zA..Z0..9_.-] but translates spaces to _ and accentuated chars to their non-accentuated counterpart before.

Static method.

  • return: the sanitized string
  • access: public
static string sanitizeAsciiString (string $input, [string $keep = ''], [string $special = '_.-'])
  • string $input: The sensitive input.
  • string $keep: The meta caracters to keep with _.- (default : none).
  • string $special: The special caracters allowed (default : "_.-").
static sanitizeExecCommand (line 191)

Cleans a string that has to be used in an exec command For now, remove backticks ` in string Static method.

  • return: the sanitized string
  • access: public
static string sanitizeExecCommand (mixed $input)
  • mixed $input: The sensitive input.
static sanitizeHTMLString (line 178)
static void sanitizeHTMLString ( $input)
  • $input
static sanitizeJSString (line 260)

Cleans a string to use it in a JS var Remove line breaks and add slashes to single quotes

  • return: the sanitized string
  • access: public
static string sanitizeJSString ( $input, [ $minimize = false], [ $addslashes = true], [ $keepCariageReturn = false], mixed $input:, boolean $minimize:, boolean $addslashes:)
  • mixed $input:: The sensitive input.
  • boolean $minimize:: Use jsmin to minimise JS, this will also strip comments (default : false)
  • boolean $addslashes:: add slashes around single quotes (default : true);
  • $input
  • $minimize
  • $addslashes
  • $keepCariageReturn
static sanitizeSQLString (line 147)

Cleans a string that is to be put into a SQL query.

Actually, only escapes single quotes that are not already escaped. Static method.

  • return: the sanitized string
  • access: public
static string sanitizeSQLString (mixed $input)
  • mixed $input: The sensitive input.
static sanitizeURLString (line 233)

Cleans a string containing other thing than [a..z0..9-] Translates spaces to - and accentuated chars to their non-accentuated counterpart before.

Then lower the case of the sring Static method.

  • return: the sanitized string
  • access: public
static string sanitizeURLString (mixed $input)
  • mixed $input: The sensitive input.
static stripPHPTags (line 159)

Cleans a string that must not contain php opening and closing tags Static method.

  • return: the sanitized string
  • access: public
static string stripPHPTags (mixed $input)
  • mixed $input: The sensitive input.
static strlen (line 834)
static void strlen ()
static strpos (line 842)
static void strpos ()
static strtolower (line 850)
static void strtolower ()
static strtoupper (line 858)
static void strtoupper ()
static substr (line 826)

Rewrite some PHP functions to be charset insensitive

  • access: public
static mixed substr ()
static unsetRequest (line 96)

Unset request input Static method.

  • access: public
static void unsetRequest (string/array $requests)
  • string/array $requests: The request(s) name to unset
static utf8Decode (line 717)

Decode String from UTF8 to latin1 with support of cp1252 charset

  • return: : the value decoded
  • access: public
static string utf8Decode (string $text)
  • string $text: The to decode
static utf8Encode (line 705)

Encode ISO8859-1 string to UTF8 with support of cp1252 charset

  • return: : the value encoded
  • access: public
static string utf8Encode (string $text)
  • string $text: The to encode
static uuid (line 815)

Generated a Universal Unique Identifier (UUID) generated according to “DCE 1.1: Remote Procedure Call” (Appendix A) CAE (Common Applications Environment) Specifications published by The Open Group in October 1997 (Document Number C706, http://www.opengroup.org/public/pubs/catalog/c706.htm).

  • access: public
static string uuid ()

Inherited Methods

Inherited From CMS_grandFather

 CMS_grandFather::autoload()
 CMS_grandFather::hasError()
 CMS_grandFather::log()
 CMS_grandFather::PHPErrorHandler()
 CMS_grandFather::raiseError()
 CMS_grandFather::setDebug()
 CMS_grandFather::setLog()
 CMS_grandFather::_raiseError()
 CMS_grandFather::__call()
Class Constants

Documentation generated on Wed, 15 Feb 2012 15:39:01 +0100 by phpDocumentor 1.4.3