Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobocoder <anthon.pang@gmail.com>2011-09-05 07:08:31 +0400
committerrobocoder <anthon.pang@gmail.com>2011-09-05 07:08:31 +0400
commit39a64fd5f2d5c3fe9929e6c519618c840d5b9e03 (patch)
tree3c3059e7e3c4ded940c8779dd044e6bd475c615e
parentad26b46cf513ef2c26248df713c1f2d31a95fdbe (diff)
remove Inspekt; sorry...last commit was not from my usual workspace
git-svn-id: http://dev.piwik.org/svn/trunk@5127 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r--LEGALNOTICE4
-rw-r--r--libs/Inspekt.php1244
-rw-r--r--libs/Inspekt/AccessorAbstract.php104
-rw-r--r--libs/Inspekt/Cage.php1086
-rw-r--r--libs/Inspekt/Cage/Session.php66
-rw-r--r--libs/Inspekt/CageTest.php742
-rw-r--r--libs/Inspekt/Error.php38
-rw-r--r--libs/Inspekt/Supercage.php130
8 files changed, 0 insertions, 3414 deletions
diff --git a/LEGALNOTICE b/LEGALNOTICE
index 2173121f04..a0f275b753 100644
--- a/LEGALNOTICE
+++ b/LEGALNOTICE
@@ -186,10 +186,6 @@ THIRD-PARTY COMPONENTS AND LIBRARIES
Link: http://www.phcomp.co.uk/tmp/Smarty.phps
License: New BSD
- Name: Inspekt
- Link: http://inspekt.org/
- License: New BSD
-
Name: PclZip
Link: http://www.phpconcept.net/pclzip/
License: LGPL
diff --git a/libs/Inspekt.php b/libs/Inspekt.php
deleted file mode 100644
index d76ef9d85b..0000000000
--- a/libs/Inspekt.php
+++ /dev/null
@@ -1,1244 +0,0 @@
-<?php
-/**
- * Inspekt - main source file
- *
- * @author Chris Shiflett <chris@shiflett.org>
- * @author Ed Finkler <coj@funkatron.com>
- *
- * @package Inspekt
- */
-
-/**
- * Inspekt_Error
- */
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Inspekt/Error.php');
-
-/**
- * Inspekt_Cage
- */
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Inspekt/Cage.php');
-
-/**
- * Inspekt_Cage_Session
- */
-//require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Inspekt/Cage/Session.php');
-
-/**
- * Inspekt_Supercage
- */
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Inspekt/Supercage.php');
-
-
-/**
- * Options for isHostname() that specify which types of hostnames
- * to allow.
- *
- * HOST_ALLOW_DNS: Allows Internet domain names (e.g.,
- * example.com).
- */
-define('ISPK_HOST_ALLOW_DNS', 1);
-
-/**
- * Options for isHostname() that specify which types of hostnames
- * to allow.
- *
- * HOST_ALLOW_IP: Allows IP addresses.
- */
-define('ISPK_HOST_ALLOW_IP', 2);
-
-/**
- * Options for isHostname() that specify which types of hostnames
- * to allow.
- *
- * HOST_ALLOW_LOCAL: Allows local network names (e.g., localhost,
- * www.localdomain) and Internet domain names.
- */
-define('ISPK_HOST_ALLOW_LOCAL', 4);
-
-/**
- * Options for isHostname() that specify which types of hostnames
- * to allow.
- *
- * HOST_ALLOW_ALL: Allows all of the above types of hostnames.
- */
-define('ISPK_HOST_ALLOW_ALL', 7);
-
-/**
- * Options for isUri that specify which types of URIs to allow.
- *
- * URI_ALLOW_COMMON: Allow only "common" hostnames: http, https, ftp
- */
-define('ISPK_URI_ALLOW_COMMON', 1);
-
-/**
- * @package Inspekt
- */
-class Inspekt
-{
- protected static $useFilterExtension = true;
-
- /**
- * regex used to define what we're calling a valid domain name
- */
- const VALID_DNS_REGEX = '/^(?:[^\W_]((?:[^\W_]|-){0,61}[^\W_])?\.)+[a-zA-Z]{2,6}\.?$/';
- /**
- * regex used to define what we're calling a valid email
- *
- * we're taking a "match 99%" approach here, rather than a strict
- * interpretation of the RFC.
- *
- * @see http://www.regular-expressions.info/email.html
- */
- const VALID_EMAIL_REGEX = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/';
- /**
- * regex used to validate a US postal (zip) code, ZIP or ZIP+4 allowed
- */
- const VALID_POSTAL_CODE_REGEX = '/(^\d{5}$)|(^\d{5}-\d{4}$)/';
- /**
- * Returns the $_SERVER data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- *
- * @assert()
- */
- static public function makeServerCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_SERVER, $config_file, '_SERVER', $strict);
- }
- $GLOBALS['HTTP_SERVER_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_GET data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- */
- static public function makeGetCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_GET, $config_file, '_GET', $strict);
- }
- $GLOBALS['HTTP_GET_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_POST data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- */
- static public function makePostCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_POST, $config_file, '_POST', $strict);
- }
- $GLOBALS['HTTP_POST_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_COOKIE data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- */
- static public function makeCookieCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_COOKIE, $config_file, '_COOKIE', $strict);
- }
- $GLOBALS['HTTP_COOKIE_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_ENV data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- */
- static public function makeEnvCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_ENV, $config_file, '_ENV', $strict);
- }
- $GLOBALS['HTTP_ENV_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_FILES data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- */
- static public function makeFilesCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage::Factory($_FILES, $config_file, '_FILES', $strict);
- }
- $GLOBALS['HTTP_POST_FILES'] = null;
- return $_instance;
- }
-
- /**
- * Returns the $_SESSION data wrapped in an Inspekt_Cage object
- *
- * This utilizes a singleton pattern to get around scoping issues
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal array
- * @return Inspekt_Cage
- * @deprecated
- */
- static public function makeSessionCage($config_file = null, $strict = true)
- {
- Inspekt_Error::raiseError('makeSessionCage is disabled in this version', E_USER_ERROR);
-
- /**
- * @staticvar $_instance
- */
- static $_instance;
-
- if (!isset($_SESSION)) {
- return null;
- }
-
- if (!isset($_instance)) {
- $_instance = Inspekt_Cage_Session::Factory($_SESSION, $config_file, '_SESSION', $strict);
- }
- $GLOBALS['HTTP_SESSION_VARS'] = null;
- return $_instance;
- }
-
- /**
- * Returns a Supercage object, which wraps ALL input superglobals
- *
- * @param string $config_file
- * @param boolean $strict whether or not to nullify the superglobal
- * @return Inspekt_Supercage
- */
- static public function makeSuperCage($config_file = null, $strict = true)
- {
- /**
- * @staticvar $_instance
- */
- static $_scinstance;
-
- if (!isset($_scinstance)) {
- $_scinstance = Inspekt_Supercage::Factory($config_file, $strict);
- }
- return $_scinstance;
- }
-
- /**
- * Sets and/or retrieves whether we should use the PHP filter extensions where possible
- * If a param is passed, it will set the state in addition to returning it
- *
- * We use this method of storing in a static class property so that we can access the value outside of class instances
- *
- * @param boolean $state optional
- * @return boolean
- */
- static public function useFilterExt($state = null)
- {
- if (isset($state)) {
- Inspekt::$useFilterExtension = (bool) $state;
- }
- return Inspekt::$useFilterExtension;
- }
-
- /**
- * Recursively walks an array and applies a given filter method to
- * every value in the array.
- *
- * This should be considered a "protected" method, and not be called
- * outside of the class
- *
- * @param array|ArrayObject $input
- * @param string $inspektor The name of a static filtering method, like get* or no*
- * @return array
- */
- static protected function _walkArray($input, $method, $classname = null)
- {
- if (!isset($classname)) {
- $classname = __CLASS__;
- }
-
- if (!self::isArrayOrArrayObject($input) ) {
- Inspekt_Error::raiseError('$input must be an array or ArrayObject', E_USER_ERROR);
- return false;
- }
-
- if (!is_callable(array($classname, $method))) {
- Inspekt_Error::raiseError('Inspektor ' . $classname . '::' . $method . ' is invalid', E_USER_ERROR);
- return false;
- }
-
- foreach ($input as $key => $val) {
- if (is_array($val)) {
- $input[$key]=self::_walkArray($val, $method, $classname);
- } else {
- $val = call_user_func(array($classname, $method), $val);
- $input[$key] = $val;
- }
- }
- return $input;
- }
-
- /**
- * Checks to see if this is an ArrayObject
- * @param mixed
- * @return boolean
- * @deprecated
- * @link http://php.net/arrayobject
- */
- static public function isArrayObject($obj)
- {
- $is = false;
- //$is = (is_object($obj) && get_class($obj) === 'ArrayObject');
- $is = $obj instanceof ArrayObject;
- return $is;
- }
-
- /**
- * Checks to see if this is an array or an ArrayObject
- * @param mixed
- * @return boolean
- * @link http://php.net/arrayobject
- * @link http://php.net/array
- */
- static public function isArrayOrArrayObject($arr)
- {
- $is = false;
- $is = $arr instanceof ArrayObject || is_array($arr);
- return $is;
- }
-
- /**
- * Converts an array into an ArrayObject. We use ArrayObjects when walking arrays in Inspekt
- * @param array
- * @return ArrayObject
- */
- static public function convertArrayToArrayObject(&$arr)
- {
- foreach ($arr as $key => $value) {
- if (is_array($value)) {
- $value = new ArrayObject($value);
- $arr[$key] = $value;
- //echo $key." is an array\n";
- Inspekt::convertArrayToArrayObject($arr[$key]);
- }
- }
-
- return new ArrayObject($arr);
- }
-
- /**
- * Returns only the alphabetic characters in value.
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- */
- static public function getAlpha($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getAlpha');
- } else {
- return preg_replace('/[^[:alpha:]]/', '', $value);
- }
- }
-
- /**
- * Returns only the alphabetic characters and digits in value.
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- *
- * @assert('1)@*(&UR)HQ)W(*(HG))') === '1URHQWHG'
- */
- static public function getAlnum($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getAlnum');
- } else {
- return preg_replace('/[^[:alnum:]]/', '', $value);
- }
- }
-
- /**
- * Returns only the digits in value.
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- *
- * @assert('1)@*(&UR)HQ)56W(*(HG))') === '156'
- */
- static public function getDigits($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getDigits');
- } else {
- return preg_replace('/[^[:digit:]]/', '', $value);
- }
- }
-
- /**
- * Returns dirname(value).
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- *
- * @assert('/usr/lib/php/Pear.php') === '/usr/lib/php'
- */
- static public function getDir($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getDir');
- } else {
- return dirname($value);
- }
- }
-
- /**
- * Returns (int) value.
- *
- * @param mixed $value
- * @return int
- *
- * @tag filter
- *
- * @assert('1)45@*(&UR)HQ)W.0000(*(HG))') === 1
- * @assert('A1)45@*(&UR)HQ)W.0000(*(HG))') === 0
- */
- static public function getInt($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getInt');
- } else {
- return (int) $value;
- }
- }
-
- /**
- * Returns realpath(value).
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- */
- static public function getPath($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getPath');
- } else {
- return realpath($value);
- }
- }
-
- /**
- * Returns the value encoded as ROT13 (or decoded, if already was ROT13)
- *
- * @param mixed $value
- * @return mixed
- *
- * @link http://php.net/manual/en/function.str-rot13.php
- */
- static public function getROT13($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'getROT13');
- } else {
- return str_rot13($value);
- }
- }
-
- /**
- * Returns true if every character is alphabetic or a digit,
- * false otherwise.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- *
- * @assert('NCOFWIERNVOWIEBHV12047057y0650ytg0314') === true
- * @assert('NCOFWIERNVOWIEBHV2@12047057y0650ytg0314') === false
- * @assert('funkatron') === true
- * @assert('funkatron_user') === false
- * @assert('funkatron-user') === false
- * @assert('_funkatronuser') === false
- */
- static public function isAlnum($value)
- {
- return ctype_alnum($value);
- }
-
- /**
- * Returns true if every character is alphabetic, false
- * otherwise.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- *
- * @assert('NCOFWIERNVOWIEBHV12047057y0650ytg0314') === false
- * @assert('NCOFWIERNVOWIEBHV2@12047057y0650ytg0314') === false
- * @assert('funkatron') === true
- * @assert('funkatron_user') === false
- * @assert('funkatron-user') === false
- * @assert('_funkatronuser') === false
- */
- static public function isAlpha($value)
- {
- return ctype_alpha($value);
- }
-
- /**
- * Returns true if value is greater than or equal to $min and less
- * than or equal to $max, false otherwise. If $inc is set to
- * false, then the value must be strictly greater than $min and
- * strictly less than $max.
- *
- * @param mixed $value
- * @param mixed $min
- * @param mixed $max
- * @return boolean
- *
- * @tag validator
- *
- * @assert(12, 0, 12) === true
- * @assert(12, 0, 12, false) === false
- * @assert('f', 'a', 'm', false) === true
- * @assert('p', 'a', 'm', false) === false
- */
- static public function isBetween($value, $min, $max, $inc = true)
- {
- if ($value > $min &&
- $value < $max) {
- return true;
- }
-
- if ($inc &&
- $value >= $min &&
- $value <= $max) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns true if it is a valid credit card number format. The
- * optional second argument allows developers to indicate the
- * type.
- *
- * @param mixed $value
- * @param mixed $type
- * @return boolean
- *
- * @tag validator
- */
- static public function isCcnum($value, $type = null)
- {
- /**
- * @todo Type-specific checks
- */
- if (isset($type)) {
- Inspekt_Error::raiseError('Type-specific cc checks are not yet supported');
- }
-
- $value = self::getDigits($value);
- $length = strlen($value);
-
- if ($length < 13 || $length > 19) {
- return false;
- }
-
- $sum = 0;
- $weight = 2;
-
- for ($i = $length - 2; $i >= 0; $i--) {
- $digit = $weight * $value[$i];
- $sum += floor($digit / 10) + $digit % 10;
- $weight = $weight % 2 + 1;
- }
-
- $mod = (10 - $sum % 10) % 10;
-
- return ($mod == $value[$length - 1]);
- }
-
- /**
- * Returns true if value is a valid date, false otherwise. The
- * date is required to be in ISO 8601 format.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- *
- * @assert('2009-06-30') === true
- * @assert('2009-06-31') === false
- * @assert('2009-6-30') === true
- * @assert('2-6-30') === true
- */
- static public function isDate($value)
- {
- list($year, $month, $day) = sscanf($value, '%d-%d-%d');
-
- return checkdate($month, $day, $year);
- }
-
- /**
- * Returns true if every character is a digit, false otherwise.
- * This is just like isInt(), except there is no upper limit.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- *
- * @assert('1029438750192730t91740987023948') === false
- * @assert('102943875019273091740987023948') === true
- * @assert(102943875019273091740987023948) === false
- */
- static public function isDigits($value)
- {
- return ctype_digit((string) $value);
- }
-
- /**
- * Returns true if value is a valid email format, false otherwise.
- *
- * @param string $value
- * @return boolean
- * @see http://www.regular-expressions.info/email.html
- * @see Inspekt::VALID_EMAIL_REGEX
- *
- * @tag validator
- *
- * @assert('coj@poop.com') === true
- * @assert('coj+booboo@poop.com') === true
- * @assert('coj!booboo@poop.com') === false
- * @assert('@poop.com') === false
- * @assert('a@b') === false
- * @assert('webmaster') === false
- */
- static public function isEmail($value)
- {
- return (bool) preg_match(self::VALID_EMAIL_REGEX, $value);
- }
-
- /**
- * Returns true if value is a valid float value, false otherwise.
- *
- * @param string $value
- * @return boolean
- *
- * @assert(10244578109.234451) === true
- * @assert('10244578109.234451') === false
- * @assert('10,244,578,109.234451') === false
- *
- * @tag validator
- */
- static public function isFloat($value)
- {
- $locale = localeconv();
- $value = str_replace($locale['decimal_point'], '.', $value);
- $value = str_replace($locale['thousands_sep'], '', $value);
-
- return (strval(floatval($value)) == $value);
- }
-
- /**
- * Returns true if value is greater than $min, false otherwise. Note that
- * comparisons with NULL do not work the same way as SQL, ex. "1 > null" is
- * true
- *
- * @param mixed $value
- * @param mixed $min
- * @return boolean
- *
- * @tag validator
- *
- * @assert(5, 0) === true
- * @assert(2, 10) === false
- * @assert('b', 'a') === true
- * @assert('a', 'b') === false
- *
- * @todo missing $min is a really bad idea considering the odd null behavior. should that throw an error?
- */
- static public function isGreaterThan($value, $min)
- {
- return ($value > $min);
- }
-
- /**
- * Returns true if value is a valid hexadecimal format, false
- * otherwise.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- *
- * @assert('6F') === true
- * @assert('F6') === true
- *
- */
- static public function isHex($value)
- {
- return ctype_xdigit($value);
- }
-
- /**
- * Returns true if value is a valid hostname, false otherwise.
- * Depending upon the value of $allow, Internet domain names, IP
- * addresses, and/or local network names are considered valid.
- * The default is HOST_ALLOW_ALL, which considers all of the
- * above to be valid.
- *
- * @param mixed $value
- * @param integer $allow bitfield for ISPK_HOST_ALLOW_DNS, ISPK_HOST_ALLOW_IP, ISPK_HOST_ALLOW_LOCAL
- * @return boolean
- *
- * @tag validator
- */
- static public function isHostname($value, $allow = ISPK_HOST_ALLOW_ALL)
- {
- if (!is_numeric($allow) || !is_int($allow)) {
- Inspekt_Error::raiseError('Illegal value for $allow; expected an integer', E_USER_WARNING);
- }
-
- if ($allow < ISPK_HOST_ALLOW_DNS || ISPK_HOST_ALLOW_ALL < $allow) {
- Inspekt_Error::raiseError('Illegal value for $allow; expected integer between ' . ISPK_HOST_ALLOW_DNS . ' and ' . ISPK_HOST_ALLOW_ALL, E_USER_WARNING);
- }
-
- // determine whether the input is formed as an IP address
- $status = self::isIp($value);
-
- // if the input looks like an IP address
- if ($status) {
- // if IP addresses are not allowed, then fail validation
- if (($allow & ISPK_HOST_ALLOW_IP) == 0) {
- return false;
- }
-
- // IP passed validation
- return true;
- }
-
- // check input against domain name schema
- $status = @preg_match(ISPK_DNS_VALID, $value);
- if ($status === false) {
- Inspekt_Error::raiseError('Internal error: DNS validation failed', E_USER_WARNING);
- }
-
- // if the input passes as an Internet domain name, and domain names are allowed, then the hostname
- // passes validation
- if ($status == 1 && ($allow & ISPK_HOST_ALLOW_DNS) != 0) {
- return true;
- }
-
- // if local network names are not allowed, then fail validation
- if (($allow & ISPK_HOST_ALLOW_LOCAL) == 0) {
- return false;
- }
-
- // check input against local network name schema; last chance to pass validation
- $status = @preg_match('/^(?:[^\W_](?:[^\W_]|-){0,61}[^\W_]\.)*(?:[^\W_](?:[^\W_]|-){0,61}[^\W_])\.?$/',
- $value);
- if ($status === false) {
- Inspekt_Error::raiseError('Internal error: local network name validation failed', E_USER_WARNING);
- }
-
- if ($status == 0) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Returns true if value is a valid integer value, false otherwise.
- *
- * @param string|array $value
- * @return boolean
- *
- * @tag validator
- *
- * @todo better handling of diffs b/t 32-bit and 64-bit
- */
- static public function isInt($value)
- {
- $locale = localeconv();
-
- $value = str_replace($locale['decimal_point'], '.', $value);
- $value = str_replace($locale['thousands_sep'], '', $value);
-
- $is_valid = (
- is_numeric($value) // Must be able to be converted to a number
- && preg_replace("/^-?([0-9]+)$/", "", $value) == "" // Must be an integer (no floats or e-powers)
- && bccomp($value, "-9223372036854775807") >= 0 // Must be greater than than min of 64-bit
- && bccomp($value, "9223372036854775807") <= 0 // Must be less than max of 64-bit
- );
- if (!$is_valid) {
- return false;
- } else {
- return true;
- }
- // return (strval(intval($value)) === $value);
- }
-
- /**
- * Returns true if value is a valid IP format, false otherwise.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- */
- static public function isIp($value)
- {
- return (bool) ip2long($value);
- }
-
- /**
- * Returns true if value is less than $max, false otherwise.
- *
- * @param mixed $value
- * @param mixed $max
- * @return boolean
- *
- * @tag validator
- */
- static public function isLessThan($value, $max)
- {
- return ($value < $max);
- }
-
- /**
- * Returns true if value is one of $allowed, false otherwise.
- *
- * @param mixed $value
- * @param array|string $allowed
- * @return boolean
- *
- * @tag validator
- */
- static public function isOneOf($value, $allowed)
- {
- /**
- * @todo: Consider allowing a string for $allowed, where each
- * character in the string is an allowed character in the
- * value.
- */
-
- if (is_string($allowed)) {
- $allowed = str_split($allowed);
- }
-
- return in_array($value, $allowed);
- }
-
- /**
- * Returns true if value is a valid phone number format, false
- * otherwise. The optional second argument indicates the country.
- * This method requires that the value consist of only digits.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- */
- static public function isPhone($value, $country = 'US')
- {
- if (!ctype_digit($value)) {
- return false;
- }
-
- switch ($country) {
- case 'US':
- if (strlen($value) != 10) {
- return false;
- }
-
- $areaCode = substr($value, 0, 3);
-
- $areaCodes = array(201, 202, 203, 204, 205, 206, 207, 208,
- 209, 210, 212, 213, 214, 215, 216, 217,
- 218, 219, 224, 225, 226, 228, 229, 231,
- 234, 239, 240, 242, 246, 248, 250, 251,
- 252, 253, 254, 256, 260, 262, 264, 267,
- 268, 269, 270, 276, 281, 284, 289, 301,
- 302, 303, 304, 305, 306, 307, 308, 309,
- 310, 312, 313, 314, 315, 316, 317, 318,
- 319, 320, 321, 323, 325, 330, 334, 336,
- 337, 339, 340, 345, 347, 351, 352, 360,
- 361, 386, 401, 402, 403, 404, 405, 406,
- 407, 408, 409, 410, 412, 413, 414, 415,
- 416, 417, 418, 419, 423, 424, 425, 430,
- 432, 434, 435, 438, 440, 441, 443, 445,
- 450, 469, 470, 473, 475, 478, 479, 480,
- 484, 501, 502, 503, 504, 505, 506, 507,
- 508, 509, 510, 512, 513, 514, 515, 516,
- 517, 518, 519, 520, 530, 540, 541, 555,
- 559, 561, 562, 563, 564, 567, 570, 571,
- 573, 574, 580, 585, 586, 600, 601, 602,
- 603, 604, 605, 606, 607, 608, 609, 610,
- 612, 613, 614, 615, 616, 617, 618, 619,
- 620, 623, 626, 630, 631, 636, 641, 646,
- 647, 649, 650, 651, 660, 661, 662, 664,
- 670, 671, 678, 682, 684, 700, 701, 702,
- 703, 704, 705, 706, 707, 708, 709, 710,
- 712, 713, 714, 715, 716, 717, 718, 719,
- 720, 724, 727, 731, 732, 734, 740, 754,
- 757, 758, 760, 763, 765, 767, 769, 770,
- 772, 773, 774, 775, 778, 780, 781, 784,
- 785, 786, 787, 800, 801, 802, 803, 804,
- 805, 806, 807, 808, 809, 810, 812, 813,
- 814, 815, 816, 817, 818, 819, 822, 828,
- 829, 830, 831, 832, 833, 835, 843, 844,
- 845, 847, 848, 850, 855, 856, 857, 858,
- 859, 860, 863, 864, 865, 866, 867, 868,
- 869, 870, 876, 877, 878, 888, 900, 901,
- 902, 903, 904, 905, 906, 907, 908, 909,
- 910, 912, 913, 914, 915, 916, 917, 918,
- 919, 920, 925, 928, 931, 936, 937, 939,
- 940, 941, 947, 949, 951, 952, 954, 956,
- 959, 970, 971, 972, 973, 978, 979, 980,
- 985, 989);
-
- return in_array($areaCode, $areaCodes);
- break;
- default:
- Inspekt_Error::raiseError('isPhone() does not yet support this country.', E_USER_WARNING);
- return false;
- break;
- }
- }
-
- /**
- * Returns true if value matches $pattern, false otherwise. Uses
- * preg_match() for the matching.
- *
- * @param mixed $value
- * @param mixed $pattern
- * @return mixed
- *
- * @tag validator
- */
- static public function isRegex($value, $pattern)
- {
- return (bool) preg_match($pattern, $value);
- }
-
- /**
- * Enter description here...
- *
- * @param string $value
- * @param integer $mode
- * @return boolean
- *
- * @link http://www.ietf.org/rfc/rfc2396.txt
- *
- * @tag validator
- */
- static public function isUri($value, $mode = ISPK_URI_ALLOW_COMMON)
- {
- /**
- * @todo
- */
- $regex = '';
- switch ($mode) {
-
- // a common absolute URI: ftp, http or https
- case ISPK_URI_ALLOW_COMMON:
-
- $regex .= '&';
- $regex .= '^(ftp|http|https):'; // protocol
- $regex .= '(//)'; // authority-start
- $regex .= '([-a-z0-9/~;:@=+$,.!*()\']+@)?'; // userinfo
- $regex .= '(';
- $regex .= '((?:[^\W_]((?:[^\W_]|-){0,61}[^\W_])?\.)+[a-zA-Z]{2,6}\.?)'; // domain name
- $regex .= '|';
- $regex .= '([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?(\.[0-9]{1,3})?)'; // OR ipv4
- $regex .= ')';
- $regex .= '(:([0-9]*))?'; // port
- $regex .= '(/((%[0-9a-f]{2}|[-_a-z0-9/~;:@=+$,.!*()\'\&]*)*)/?)?'; // path
- $regex .= '(\?[^#]*)?'; // query
- $regex .= '(#([-a-z0-9_]*))?'; // anchor (fragment)
- $regex .= '$&i';
- //echo "<pre>"; echo print_r($regex, true); echo "</pre>\n";
-
- break;
-
- case ISPK_URI_ALLOW_ABSOLUTE:
-
- Inspekt_Error::raiseError('isUri() for ISPK_URI_ALLOW_ABSOLUTE has not been implemented.', E_USER_WARNING);
- return false;
-
-// $regex .= '&';
-// $regex .= '^(ftp|http|https):'; // protocol
-// $regex .= '(//)'; // authority-start
-// $regex .= '([-a-z0-9/~;:@=+$,.!*()\']+@)?'; // userinfo
-// $regex .= '(';
-// $regex .= '((?:[^\W_]((?:[^\W_]|-){0,61}[^\W_])?\.)+[a-zA-Z]{2,6}\.?)'; // domain name
-// $regex .= '|';
-// $regex .= '([0-9]{1,3}(\.[0-9]{1,3})?(\.[0-9]{1,3})?(\.[0-9]{1,3})?)'; // OR ipv4
-// $regex .= ')';
-// $regex .= '(:([0-9]*))?'; // port
-// $regex .= '(/((%[0-9a-f]{2}|[-a-z0-9/~;:@=+$,.!*()\'\&]*)*)/?)?'; // path
-// $regex .= '(\?[^#]*)?'; // query
-// $regex .= '(#([-a-z0-9_]*))?'; // anchor (fragment)
-// $regex .= '$&i';
- //echo "<pre>"; echo print_r($regex, true); echo "</pre>\n";
-
- break;
-
- }
- $result = preg_match($regex, $value);
-
- if ($result === 1) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Returns true if value is a valid US postal (zip) code, false otherwise.
- *
- * @param mixed $value
- * @return boolean
- *
- * @tag validator
- */
- static public function isZip($value)
- {
- return (bool) preg_match(self::VALID_POSTAL_CODE_REGEX, $value);
- }
-
- /**
- * Returns value with all tags removed.
- *
- * This will utilize the PHP Filter extension if available
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- */
- static public function noTags($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'noTags');
- } else {
- if (Inspekt::useFilterExt()) {
- return filter_var($value, FILTER_SANITIZE_STRING);
- } else {
- return strip_tags($value);
- }
- }
- }
-
- /**
- * returns value with tags stripped and the chars '"&<> and all ascii chars
- * under 32 encoded as html entities
- *
- * This will utilize the PHP Filter extension if available
- *
- * @param mixed $value
- * @return @mixed
- *
- * @tag filter
- *
- */
- static public function noTagsOrSpecial($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'noTagsOrSpecial');
- } else {
- if (Inspekt::useFilterExt()) {
- $newval = filter_var($value, FILTER_SANITIZE_STRING);
- $newval = filter_var($newval, FILTER_SANITIZE_SPECIAL_CHARS);
- return $newval;
- } else {
- $newval = strip_tags($value);
- //for sake of simplicity and safety we assume UTF-8
- $newval = htmlspecialchars($newval, ENT_QUOTES, 'UTF-8');
-
- /*
- * convert low ascii chars to entities
- */
- $newval = str_split($newval);
- for ($i=0; $i < count($newval); $i++) {
- $ascii_code = ord($newval[$i]);
- if ($ascii_code < 32) {
- $newval[$i] = "&#{$ascii_code};";
- }
- }
- $newval = implode($newval);
-
- return $newval;
- }
- }
- }
-
- /**
- * Returns basename(value).
- *
- * @param mixed $value
- * @return mixed
- *
- * @tag filter
- */
- static public function noPath($value)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'noPath');
- } else {
- return basename($value);
- }
- }
-
- /**
- * Escapes the value given with mysql_real_escape_string
- *
- * @param mixed $value
- * @param resource $conn the mysql connection. If none is given, it will use
- * the last link opened, per behavior of mysql_real_escape_string
- * @return mixed
- *
- * @link http://php.net/manual/en/function.mysql-real-escape-string.php
- *
- * @tag filter
- */
- static public function escMySQL($value, $conn = null)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'escMySQL');
- } else {
- //no explicit func to check if the connection is live, but if it's not $conn would be false
- if (isset($conn) && is_resource($conn)) {
- return mysql_real_escape_string($value, $conn);
- } else {
- return mysql_real_escape_string($value);
- }
- }
- }
-
- /**
- * Escapes the value given with pg_escape_string
- *
- * If the data is for a column of the type bytea, use Inspekt::escPgSQLBytea()
- *
- * @param mixed $value
- * @param resource $conn the postgresql connection. If none is given, it
- * will use the last link opened, per behavior of pg_escape_string
- * @return mixed
- *
- * @link http://php.net/manual/en/function.pg-escape-string.php
- */
- static public function escPgSQL($value, $conn = null)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'escPgSQL');
- } else {
- //might also check is_resource if pg_connection_status is too much
- if (isset($conn) && pg_connection_status($conn) === PGSQL_CONNECTION_OK) {
- return pg_escape_string($conn, $value);
- } else {
- return pg_escape_string($value);
- }
- }
- }
-
- /**
- * Escapes the value given with pg_escape_bytea
- *
- * @param mixed $value
- * @param resource $conn the postgresql connection. If none is given, it
- * will use the last link opened, per behavior of pg_escape_bytea
- * @return mixed
- *
- * @link http://php.net/manual/en/function.pg-escape-bytea.php
- */
- static public function escPgSQLBytea($value, $conn = null)
- {
- if (Inspekt::isArrayOrArrayObject($value)) {
- return Inspekt::_walkArray($value, 'escPgSQL');
- } else {
- //might also check is_resource if pg_connection_status is too much
- if (isset($conn) && pg_connection_status($conn) === PGSQL_CONNECTION_OK) {
- return pg_escape_bytea($conn, $value);
- } else {
- return pg_escape_bytea($value);
- }
- }
- }
-}
diff --git a/libs/Inspekt/AccessorAbstract.php b/libs/Inspekt/AccessorAbstract.php
deleted file mode 100644
index 25391081eb..0000000000
--- a/libs/Inspekt/AccessorAbstract.php
+++ /dev/null
@@ -1,104 +0,0 @@
-<?php
-/**
- * This is the abstract for user-defined Accessor methods. Accessors are used to
- * retrieve values from a cage object. By extending this abstract, developers
- * can add their own accessor methods. Typically the only method they will need
- * to define is AccessorAbstract::inspekt(), which takes a value, examines it,
- * and returns a result. Array walking is automatically handled
- *
- * @package Inspekt
- * @author Ed Finkler
- */
-abstract class AccessorAbstract {
-
- /**
- * the cage object this is attached to, provided in the constructor
- *
- * @var string
- */
- protected $cage;
-
- /**
- * constructor
- *
- * @param Inspekt_Cage $cage
- * @param array $args optional
- * @author Ed Finkler
- */
- public function __construct(Inspekt_Cage $cage, $args=NULL) {
- $this->cage = $cage;
- $this->args = $args;
- }
-
- /**
- * This executes the accessor on the key, either passed as the only argument,
- * or the first value in $this->args;
- *
- * @param string $key
- * @return mixed
- * @author Ed Finkler
- */
- public function run($key = null) {
- if (!isset($key)) {
- $key = $this->args[0];
- }
-
- if (!$this->cage->keyExists($key)) {
- return false;
- }
- $val = $this->getValue($key);
- if (Inspekt::isArrayOrArrayObject($val)) {
- return $this->walkArray($val);
- } else {
- return $this->inspekt($val);
- }
- }
-
- /**
- * Retrieves a value from the cage
- *
- * @param string $key
- * @return mixed
- * @author Ed Finkler
- */
- protected function getValue($key) {
- return $this->cage->_getValue($key);
- }
-
- /**
- * If an array is the value of the given key, this method walks the array
- * recursively, applying $this->inspekt on any non-array values
- *
- * @param mixed $input
- * @param
- * @author Ed Finkler
- */
- protected function walkArray($input) {
- if (!isset($classname)) {
- $classname = __CLASS__;
- }
-
- if (!Inspekt::isArrayOrArrayObject($input)) {
- Inspekt_Error::raiseError('$input must be an array or ArrayObject', E_USER_ERROR);
- return FALSE;
- }
-
- foreach($input as $key=>$val) {
- if (Inspekt::isArrayOrArrayObject($val)) {
- $input[$key]=$this->walkArray($val);
- } else {
- $val = $this->inspekt($val);
- $input[$key]=$val;
- }
- }
- return $input;
- }
-
- abstract protected function inspekt($val);
-
-}
-
-
-
-
-?> \ No newline at end of file
diff --git a/libs/Inspekt/Cage.php b/libs/Inspekt/Cage.php
deleted file mode 100644
index a3d86b3df3..0000000000
--- a/libs/Inspekt/Cage.php
+++ /dev/null
@@ -1,1086 +0,0 @@
-<?php
-/**
- * Inspekt Cage - main source file
- *
- * @author Chris Shiflett <chris@shiflett.org>
- * @author Ed Finkler <coj@funkatron.com>
- *
- * @package Inspekt
- */
-
-/**
- * require main Inspekt file
- */
-require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Inspekt.php';
-
-define('ISPK_ARRAY_PATH_SEPARATOR', '/');
-
-define('ISPK_RECURSION_MAX', 15);
-
-/**
- * @package Inspekt
- */
-class Inspekt_Cage implements IteratorAggregate, ArrayAccess, Countable
-{
- /**
- * {@internal The raw source data. Although tempting, NEVER EVER
- * EVER access the data directly using this property!}}
- *
- * Don't try to access this. ever. Now that we're safely on PHP5, we'll
- * enforce this with the "protected" keyword.
- *
- * @var array
- */
- protected $_source = null;
-
- /**
- * where we store user-defined methods
- *
- * @var array
- */
- public $_user_accessors = array();
-
- /**
- * the holding property for autofilter config
- *
- * @var array
- */
- public $_autofilter_conf = null;
-
- /**
- *
- * @var HTMLPurifer
- */
- protected $_purifier = null;
-
- /**
- * Takes an array and wraps it inside an object. If $strict is not set to
- * false, the original array will be destroyed, and the data can only be
- * accessed via the object's accessor methods
- *
- * @param array $source
- * @param string $conf_file
- * @param string $conf_section
- * @param boolean $strict
- * @return Inspekt_Cage
- */
- static public function Factory(&$source, $conf_file = null, $conf_section = null, $strict = true)
- {
- if (!is_array($source)) {
- Inspekt_Error::raiseError('$source '.$source.' is not an array', E_USER_WARNING);
- }
-
- $cage = new Inspekt_Cage();
- $cage->_setSource($source);
- $cage->_parseAndApplyAutoFilters($conf_file, $conf_section);
-
- if ($strict) {
- $source = null;
- }
-
- return $cage;
- }
-
- /**
- * {@internal we use this to set the data array in Factory()}}
- *
- * @see Factory()
- * @param array $newsource
- */
- private function _setSource(&$newsource)
- {
- $this->_source = Inspekt::convertArrayToArrayObject($newsource);
- }
-
- /**
- * Returns an iterator for looping through an ArrayObject.
- *
- * @return ArrayIterator
- */
- public function getIterator()
- {
- return $this->_source->getIterator();
- }
-
-
- /**
- * Sets the value at the specified $offset to value$ in $this->_source.
- *
- * @param mixed $offset
- * @param mixed $value
- * @return void
- */
- public function offsetSet($offset, $value)
- {
- $this->_source->offsetSet($offset, $value);
- }
-
- /**
- * Returns whether the $offset exists in $this->_source.
- *
- * @param mixed $offset
- * @return boolean
- */
- public function offsetExists($offset)
- {
- return $this->_source->offsetExists($offset);
- }
-
- /**
- * Unsets the value in $this->_source at $offset.
- *
- * @param mixed $offset
- * @access public
- * @return void
- */
- public function offsetUnset($offset)
- {
- $this->_source->offsetUnset($offset);
- }
-
- /**
- * Returns the value at $offset from $this->_source.
- *
- * @param mixed $offset
- * @access public
- * @return void
- */
- public function offsetGet($offset)
- {
- return $this->_source->offsetGet($offset);
- }
-
- /**
- * Returns the number of elements in $this->_source.
- *
- * @access public
- * @return int
- */
- public function count()
- {
- return $this->_source->count();
- }
-
- /**
- * Load the HTMLPurifier library and instantiate the object
- * @param string $path the full path to the HTMLPurifier.auto.php base file.
- * Optional if HTMLPurifier is already in your include_path
- */
- public function loadHTMLPurifier($path = null, $opts = null)
- {
- if (!class_exists('HTMLPurifier')) {
- if (isset($path)) {
- include_once $path;
- } else {
- include_once 'HTMLPurifier.auto.php';
- }
- }
-
- $config = null;
- if (isset($opts) && is_array($opts)) {
- $config = $this->_buildHTMLPurifierConfig($opts);
- }
-
- $this->_purifier = new HTMLPurifier($config);
- }
-
- /**
- *
- * @param HTMLPurifier $pobj an HTMLPurifier Object
- */
- public function setHTMLPurifier(HTMLPurifier $pobj)
- {
- $this->_purifier = $pobj;
- }
-
- /**
- * @return HTMLPurifier
- */
- public function getHTMLPurifier()
- {
- return $this->_purifier;
- }
-
- protected function _buildHTMLPurifierConfig($opts)
- {
- $config = HTMLPurifier_Config::createDefault();
- foreach ($opts as $key => $val) {
- $config->set($key, $val);
- }
- return $config;
- }
-
- protected function _parseAndApplyAutoFilters($conf_file, $conf_section)
- {
- if (isset($conf_file)) {
- $conf = parse_ini_file($conf_file, true);
- if ($conf_section) {
- if (isset($conf[$conf_section])) {
- $this->_autofilter_conf = $conf[$conf_section];
- }
- } else {
- $this->_autofilter_conf = $conf;
- }
- $this->_applyAutoFilters();
- }
- }
-
- protected function _applyAutoFilters()
- {
- if (isset($this->_autofilter_conf) && is_array($this->_autofilter_conf)) {
- foreach ($this->_autofilter_conf as $key => $filters) {
- // get universal filter key
- if ($key == '*') {
- // get filters for this key
- $uni_filters = explode(',', $this->_autofilter_conf[$key]);
- array_walk($uni_filters, 'trim');
-
- // apply uni filters
- foreach($uni_filters as $this_filter) {
- foreach ($this->_source as $key => $val) {
- $this->_source[$key] = $this->$this_filter($key);
- }
- }
- //echo "<pre>UNI FILTERS"; echo var_dump($this->_source); echo "</pre>\n";
- } else if ($val == $this->keyExists($key)) {
- // get filters for this key
- $filters = explode(',', $this->_autofilter_conf[$key]);
- array_walk($filters, 'trim');
-
- // apply filters
- foreach ($filters as $this_filter) {
- $this->_setValue($key, $this->$this_filter($key));
- }
- //echo "<pre> Filter $this_filter/$key: "; echo var_dump($this->_source); echo "</pre>\n";
- }
- }
- }
- }
-
- public function __call($name, $args)
- {
- if (in_array($name, $this->_user_accessors) ) {
- $acc = new $name($this, $args);
- /*
- this first argument should always be the key we're accessing
- */
- return $acc->run($args[0]);
- } else {
- Inspekt_Error::raiseError("The accessor $name does not exist and is not registered", E_USER_ERROR);
- return false;
- }
- }
-
- /**
- * This method lets the developer add new accessor methods to a cage object
- * Note that calling these will be quite a bit slower, because we have to
- * use call_user_func()
- *
- * The dev needs to define a procedural function like so:
- *
- * <code>
- * function foo_bar($cage_object, $arg2, $arg3, $arg4, $arg5...) {
- * ...
- * }
- * </code>
- *
- * @param string $method_name
- * @return void
- * @author Ed Finkler
- */
- public function addAccessor($accessor_name)
- {
- $this->_user_accessors[] = $accessor_name;
- }
-
- /**
- * Returns only the alphabetic characters in value.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function getAlpha($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getAlpha($this->_getValue($key));
- }
-
- /**
- * Returns only the alphabetic characters and digits in value.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function getAlnum($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getAlnum($this->_getValue($key));
- }
-
- /**
- * Returns only the digits in value. This differs from getInt().
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function getDigits($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getDigits($this->_getValue($key));
- }
-
- /**
- * Returns dirname(value).
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function getDir($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getDir($this->_getValue($key));
- }
-
- /**
- * Returns (int) value.
- *
- * @param mixed $key
- * @return int
- *
- * @tag filter
- */
- public function getInt($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getInt($this->_getValue($key));
- }
-
- /**
- * Returns realpath(value).
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function getPath($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getPath($this->_getValue($key));
- }
-
- /**
- * Returns ROT13-encoded version
- *
- * @param string $key
- * @return mixed
- * @tag hash
- */
- public function getROT13($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::getROT13($this->_getValue($key));
- }
-
- /**
- * This returns the value of the given key passed through the HTMLPurifer
- * object, if it is instantiated with Inspekt_Cage::loadHTMLPurifer
- *
- * @param string $key
- * @return mixed purified HTML version of input
- * @tag filter
- */
- public function getPurifiedHTML($key)
- {
- if (!isset($this->_purifier)) {
- Inspekt_Error::raiseError("HTMLPurifier was not loaded", E_USER_WARNING);
- return false;
- }
-
- if (!$this->keyExists($key)) {
- return false;
- }
- $val = $this->_getValue($key);
- if (Inspekt::isArrayOrArrayObject($val)) {
- return $this->_purifier->purifyArray($val);
- } else {
- return $this->_purifier->purify($val);
- }
- }
-
- /**
- * Returns value.
- *
- * @param string $key
- * @return mixed
- *
- * @tag filter
- */
- public function getRaw($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return $this->_getValue($key);
- }
-
- /**
- * Returns value if every character is alphabetic or a digit,
- * false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testAlnum($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isAlnum($this->_getValue($key))) {
- return $this->_getValue($key);
- }
- return false;
- }
-
- /**
- * Returns value if every character is alphabetic, false
- * otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testAlpha($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isAlpha($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is greater than or equal to $min and less
- * than or equal to $max, false otherwise. If $inc is set to
- * false, then the value must be strictly greater than $min and
- * strictly less than $max.
- *
- * @param mixed $key
- * @param mixed $min
- * @param mixed $max
- * @param boolean $inc
- * @return mixed
- *
- * @tag validator
- */
- public function testBetween($key, $min, $max, $inc = true)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isBetween($this->_getValue($key), $min, $max, $inc)) {
- return $this->_getValue($key);
- }
- return false;
- }
-
- /**
- * Returns value if it is a valid credit card number format. The
- * optional second argument allows developers to indicate the
- * type.
- *
- * @param mixed $key
- * @param mixed $type
- * @return mixed
- *
- * @tag validator
- */
- public function testCcnum($key, $type = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isCcnum($this->_getValue($key), $type)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns $value if it is a valid date, false otherwise. The
- * date is required to be in ISO 8601 format.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testDate($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isDate($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if every character is a digit, false otherwise.
- * This is just like isInt(), except there is no upper limit.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testDigits($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isDigits($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid email format, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testEmail($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isEmail($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid float value, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testFloat($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isFloat($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is greater than $min, false otherwise.
- *
- * @param mixed $key
- * @param mixed $min
- * @return mixed
- *
- * @tag validator
- */
- public function testGreaterThan($key, $min = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isGreaterThan($this->_getValue($key), $min)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid hexadecimal format, false
- * otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testHex($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isHex($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid hostname, false otherwise.
- * Depending upon the value of $allow, Internet domain names, IP
- * addresses, and/or local network names are considered valid.
- * The default is HOST_ALLOW_ALL, which considers all of the
- * above to be valid.
- *
- * @param mixed $key
- * @param integer $allow bitfield for HOST_ALLOW_DNS, HOST_ALLOW_IP, HOST_ALLOW_LOCAL
- * @return mixed
- *
- * @tag validator
- */
- public function testHostname($key, $allow = ISPK_HOST_ALLOW_ALL)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isHostname($this->_getValue($key), $allow)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid integer value, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testInt($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isInt($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid IP format, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testIp($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isIp($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is less than $max, false otherwise.
- *
- * @param mixed $key
- * @param mixed $max
- * @return mixed
- *
- * @tag validator
- */
- public function testLessThan($key, $max = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isLessThan($this->_getValue($key), $max)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is one of $allowed, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testOneOf($key, $allowed = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isOneOf($this->_getValue($key), $allowed)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid phone number format, false
- * otherwise. The optional second argument indicates the country.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testPhone($key, $country = 'US')
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isPhone($this->_getValue($key), $country)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it matches $pattern, false otherwise. Uses
- * preg_match() for the matching.
- *
- * @param mixed $key
- * @param mixed $pattern
- * @return mixed
- *
- * @tag validator
- */
- public function testRegex($key, $pattern = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isRegex($this->_getValue($key), $pattern)) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
-
- /**
- * Checks to see if the passed $key references a properly-formed URI
- *
- * @param string $key
- * @return string|false
- *
- * @tag validator
- */
- public function testUri($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isUri($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value if it is a valid US ZIP, false otherwise.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag validator
- */
- public function testZip($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (Inspekt::isZip($this->_getValue($key))) {
- return $this->_getValue($key);
- }
-
- return false;
- }
-
- /**
- * Returns value with all tags removed.
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function noTags($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::noTags($this->_getValue($key));
- }
-
- /**
- * Returns basename(value).
- *
- * @param mixed $key
- * @return mixed
- *
- * @tag filter
- */
- public function noPath($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::noPath($this->_getValue($key));
- }
-
-
- public function noTagsOrSpecial($key)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- return Inspekt::noTagsOrSpecial($this->_getValue($key));
- }
-
- /**
- *
- * @param string $key
- * @param resource $conn
- * @return string|false
- *
- * @todo remove $conn check, redundant with Inspekt::escMySQL
- */
- public function escMySQL($key, $conn = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (isset($conn)) {
- return Inspekt::escMySQL($this->_getValue($key), $conn);
- } else {
- return Inspekt::escMySQL($this->_getValue($key));
- }
- }
-
- /**
- *
- * @param string $key
- * @param resource $conn
- * @return string|false
- *
- * @todo remove $conn check, redundant with Inspekt::escPgSQL
- */
- public function escPgSQL($key, $conn = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (isset($conn)) {
- return Inspekt::escPgSQL($this->_getValue($key), $conn);
- } else {
- return Inspekt::escPgSQL($this->_getValue($key));
- }
-
- }
-
- /**
- *
- * @param string $key
- * @param resource $conn
- * @return string|false
- *
- * @todo remove $conn check, redundant with Inspekt::escPgSQLBytea
- */
- public function escPgSQLBytea($key, $conn = null)
- {
- if (!$this->keyExists($key)) {
- return false;
- }
- if (isset($conn)) {
- return Inspekt::escPgSQLBytea($this->_getValue($key), $conn);
- } else {
- return Inspekt::escPgSQLBytea($this->_getValue($key));
- }
-
- }
-
- /**
- * Checks if a key exists
- *
- * @param mixed $key
- * @param boolean $return_value whether or not to return the value if key exists. defaults to false.
- * @return mixed
- */
- public function keyExists($key, $return_value = false)
- {
- if (strpos($key, ISPK_ARRAY_PATH_SEPARATOR) !== false) {
- $key = trim($key, ISPK_ARRAY_PATH_SEPARATOR);
- $keys = explode(ISPK_ARRAY_PATH_SEPARATOR, $key);
- return $this->_keyExistsRecursive($keys, $this->_source);
- } else {
- if (array_key_exists($key, $this->_source)) {
- return ($return_value) ? $this->_source[$key] : true;
- } else {
- return false;
- }
- }
- }
-
- protected function _keyExistsRecursive($keys, $data_array)
- {
- $thiskey = current($keys);
-
- if (is_numeric($thiskey)) { // force numeric strings to be integers
- $thiskey = (int)$thiskey;
- }
-
- if (array_key_exists($thiskey, $data_array)) {
- if (sizeof($keys) == 1) {
- return true;
- } else if ($data_array[$thiskey] instanceof ArrayObject) {
- unset($keys[key($keys)]);
- return $this->_keyExistsRecursive($keys, $data_array[$thiskey]);
- }
- } else { // if any key DNE, return false
- return false;
- }
- }
-
- /**
- * Retrieves a value from the _source array. This should NOT be called
- * directly, but needs to be public for use by AccessorAbstract. Maybe a
- * different approach should be considered (adapt getRaw()?)
- *
- * @param string $key
- * @return mixed
- * @private
- */
- public function _getValue($key)
- {
- if (strpos($key, ISPK_ARRAY_PATH_SEPARATOR) !== false) {
- $key = trim($key, ISPK_ARRAY_PATH_SEPARATOR);
- $keys = explode(ISPK_ARRAY_PATH_SEPARATOR, $key);
- return $this->_getValueRecursive($keys, $this->_source);
- } else {
- return $this->_source[$key];
- }
- }
-
- protected function _getValueRecursive($keys, $data_array, $level = 0)
- {
- $thiskey = current($keys);
-
- if (is_numeric($thiskey)) { // force numeric strings to be integers
- $thiskey = (int) $thiskey;
- }
-
- if (array_key_exists($thiskey, $data_array)) {
- if (sizeof($keys) == 1) {
- return $data_array[$thiskey];
- } else if ($data_array[$thiskey] instanceof ArrayObject) {
- if ($level < ISPK_RECURSION_MAX) {
- unset($keys[key($keys)]);
- return $this->_getValueRecursive($keys, $data_array[$thiskey], $level + 1);
- } else {
- Inspekt_Error::raiseError('Inspekt recursion limit met', E_USER_WARNING);
- return false;
- }
- }
- } else { // if any key DNE, return false
- return false;
- }
- }
-
- /**
- * Sets a value in the _source array
- *
- * @param mixed $key
- * @param mixed $val
- * @return mixed
- */
- protected function _setValue($key, $val)
- {
- if (strpos($key, ISPK_ARRAY_PATH_SEPARATOR) !== false) {
- $key = trim($key, ISPK_ARRAY_PATH_SEPARATOR);
- $keys = explode(ISPK_ARRAY_PATH_SEPARATOR, $key);
- return $this->_setValueRecursive($keys, $this->_source);
- } else {
- $this->_source[$key] = $val;
- return $this->_source[$key];
- }
- }
-
- protected function _setValueRecursive($keys, $val, $data_array, $level = 0)
- {
- $thiskey = current($keys);
-
- if (is_numeric($thiskey)) { // force numeric strings to be integers
- $thiskey = (int)$thiskey;
- }
-
- if (array_key_exists($thiskey, $data_array)) {
- if (sizeof($keys) == 1) {
- $data_array[$thiskey] = $val;
- return $data_array[$thiskey];
- } elseif ($data_array[$thiskey] instanceof ArrayObject) {
- if ($level < ISPK_RECURSION_MAX) {
- unset($keys[key($keys)]);
- return $this->_setValueRecursive($keys, $val, $data_array[$thiskey], $level + 1);
- } else {
- Inspekt_Error::raiseError('Inspekt recursion limit met', E_USER_WARNING);
- return false;
- }
- }
- } else { // if any key DNE, return false
- return false;
- }
- }
-}
diff --git a/libs/Inspekt/Cage/Session.php b/libs/Inspekt/Cage/Session.php
deleted file mode 100644
index 44bdabde04..0000000000
--- a/libs/Inspekt/Cage/Session.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * Inspekt Session Cage - main source file
- *
- * @author Chris Shiflett <chris@shiflett.org>
- * @author Ed Finkler <coj@funkatron.com>
- *
- * @package Inspekt
- *
- * @deprecated
- */
-
-require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'Cage.php';
-
-/**
- * @package Inspekt
- */
-class Inspekt_Cage_Session extends Inspekt_Cage {
-
- static public function Factory(&$source, $conf_file = NULL, $conf_section = NULL, $strict = TRUE) {
-
- if (!is_array($source)) {
- Inspekt_Error::raiseError('$source '.$source.' is not an array', E_USER_NOTICE);
- }
-
- $cage = new Inspekt_Cage_Session();
- $cage->_setSource($source);
- $cage->_parseAndApplyAutoFilters($conf_file);
-
- if (ini_get('session.use_cookies') || ini_get('session.use_only_cookies') ) {
- if (isset($_COOKIE) && isset($_COOKIE[session_name()])) {
- session_id($_COOKIE[session_name()]);
- } elseif ($cookie = Inspekt::makeSessionCage()) {
- session_id($cookie->getAlnum(session_name()));
- }
- } else { // we're using session ids passed via GET
- if (isset($_GET) && isset($_GET[session_name()])) {
- session_id($_GET[session_name()]);
- } elseif ($cookie = Inspekt::makeSessionCage()) {
- session_id($cookie->getAlnum(session_name()));
- }
- }
-
-
- if ($strict) {
- $source = NULL;
- }
-
- return $cage;
-
- register_shutdown_function();
-
- register_shutdown_function( array($this, '_repopulateSession') );
-
- }
-
-
-
- protected function _repopulateSession() {
- $_SESSION = array();
- $_SESSION = $this->_source;
- }
-
-
-
-} \ No newline at end of file
diff --git a/libs/Inspekt/CageTest.php b/libs/Inspekt/CageTest.php
deleted file mode 100644
index 9720287f18..0000000000
--- a/libs/Inspekt/CageTest.php
+++ /dev/null
@@ -1,742 +0,0 @@
-<?php
-require_once 'PHPUnit/Framework.php';
-
-require_once 'Cage.php';
-
-/**
- * Test class for Inspekt_Cage.
- * Generated by PHPUnit on 2009-08-10 at 16:30:49.
- */
-class Inspekt_CageTest extends PHPUnit_Framework_TestCase
-{
- /**
- * @var Inspekt_Cage
- * @access protected
- */
- protected $cage;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- *
- * @access protected
- */
- protected function setUp()
- {
- $inputarray['html'] = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
- $inputarray['int'] = 7;
- $inputarray['date'] = '2009-12-25';
- $inputarray['alnum'] = '3a4b5c';
- $inputarray['alpha'] = 'abcdefg';
- $inputarray['zip'] = 55555;
- $inputarray['zip+4'] = '55555-4444';
-
- $this->cage = Inspekt_Cage::Factory($inputarray);
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @access protected
- */
- protected function tearDown()
- {
- }
-
- /**
- * @todo Implement testFactory().
- */
- public function testFactory()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- *
- */
- public function testGetIterator()
- {
- $this->assertTrue($this->cage->getIterator() instanceof ArrayIterator);
- }
-
- /**
- * @todo Implement testOffsetSet().
- */
- public function testOffsetSet()
- {
- $this->assertFalse($this->cage->getRaw('try_later'));
- $this->cage->offsetSet('try_later', 'it is later');
- $this->assertEquals($this->cage['try_later'], 'it is later');
- }
-
- /**
- * exists
- */
- public function testOffsetExists()
- {
- $this->assertTrue($this->cage->offsetExists('html'));
- }
-
- /**
- * doesn't exist
- */
- public function testOffsetExists2()
- {
- $this->assertFalse($this->cage->offsetExists('non-existant'));
- }
-
- /**
- * @todo Implement testOffsetUnset().
- */
- public function testOffsetUnset()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testOffsetGet().
- */
- public function testOffsetGet()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testCount().
- */
- public function testCount()
- {
- $this->assertSame(7, $this->cage->count());
- }
-
- /**
- * @todo Implement testLoadHTMLPurifier().
- */
- public function testLoadHTMLPurifier()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testGetHTMLPurifier().
- */
- public function testGetHTMLPurifier()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testSetHTMLPurifier().
- */
- public function testSetHTMLPurifier()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * Implement test_parseAndApplyAutoFilters().
-
- public function test_parseAndApplyAutoFilters()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }*/
-
- /**
- * Implement test_applyAutoFilters().
-
- public function test_applyAutoFilters()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }*/
-
- /**
- * @todo Implement test__call().
- */
- public function test__call()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- *
- */
- public function testAddAccessor()
- {
- //pre-condition, clean start
- $this->assertSame($this->cage->_user_accessors, array());
- $this->cage->addAccessor('method_name');
- $this->assertSame($this->cage->_user_accessors, array('method_name'));
- }
-
- /**
- * valid, filtered
- */
- public function testGetAlpha()
- {
- $this->assertSame('abc', $this->cage->getAlpha('alnum'));
- }
-
- /**
- * missing
- */
- public function testGetAlpha2()
- {
- $this->assertFalse($this->cage->getAlpha('non-existant'));
- }
-
- /**
- * invalid, filtered
- */
- public function testGetAlpha3()
- {
- $this->assertSame('', $this->cage->getAlpha('int'));
- }
-
- /**
- * valid, unfiltered
- */
- public function testGetAlpha4()
- {
- $this->assertSame('abcdefg', $this->cage->getAlpha('alpha'));
- }
-
- /**
- * @todo Implement testGetAlnum().
- */
- public function testGetAlnum()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testGetDigits().
- */
- public function testGetDigits()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testGetDir().
- */
- public function testGetDir()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * test missing
- */
- public function testGetInt()
- {
- //non-existent key should return false
- $this->assertFalse($this->cage->getInt('non-existant'));
- }
-
- /**
- * test valid
- */
- public function testGetInt2()
- {
- $this->assertSame($this->cage->getInt('int'), 7);
- }
-
- /**
- * test filter
- */
- public function testGetInt3()
- {
- $this->assertSame(2009, $this->cage->getInt('date'));
- }
-
- /**
- * @todo Implement testGetPath().
- */
- public function testGetPath()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testGetROT13().
- */
- public function testGetROT13()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testGetPurifiedHTML().
- */
- public function testGetPurifiedHTML()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- *
- */
- public function testGetRaw()
- {
- $this->assertFalse($this->cage->getRaw('non-existant'));
- }
-
- /**
- *
- */
- public function testGetRaw2()
- {
- //test that found key returns matching value
- $this->assertEquals($this->cage->getRaw('html'),
- '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">');
- }
-
- /**
- * test invalid
- */
- public function testTestAlnum()
- {
- $this->assertFalse($this->cage->testAlnum('html'));
- }
-
- /**
- * test valid
- */
- public function testTestAlnum2()
- {
- $this->assertSame('3a4b5c', $this->cage->testAlnum('alnum'));
- }
-
- /**
- * test missing
- */
- public function testTestAlnum3()
- {
- $this->assertFalse($this->cage->testAlnum('non-existant'));
- }
-
- /**
- * test valid
- */
- public function testTestAlpha()
- {
- $this->assertSame('abcdefg', $this->cage->testAlpha('alpha'));
- }
-
- /**
- * test missing
- */
- public function testTestAlpha2()
- {
- $this->assertFalse($this->cage->testAlpha('non-existant'));
- }
-
- /**
- * test invalid
- */
- public function testTestAlpha3()
- {
- $this->assertFalse($this->cage->testAlpha('alnum'));
- }
-
- /**
- * @todo Implement testTestBetween().
- */
- public function testTestBetween()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestCcnum().
- */
- public function testTestCcnum()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestDate().
- */
- public function testTestDate()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestDigits().
- */
- public function testTestDigits()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestEmail().
- */
- public function testTestEmail()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestFloat().
- */
- public function testTestFloat()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * integer, true
- */
- public function testTestGreaterThan()
- {
- $this->assertSame(7, $this->cage->testGreaterThan('int', 5));
- }
-
- /**
- * non-integer, true
- * @depends testOffsetSet
- */
- public function testTestGreaterThan2()
- {
- $this->cage['highAlpha'] = 'z';
- $this->assertSame('z', $this->cage->testGreaterThan('highAlpha', 'a'));
- }
-
- /**
- * integer, false
- */
- public function testTestGreaterThan3()
- {
- $this->assertFalse($this->cage->testGreaterThan('int', 9));
- }
-
- /**
- * non-integer, false
- */
- public function testTestGreaterThan4()
- {
- $this->assertFalse($this->cage->testGreaterThan('alpha', 'z'));
- }
-
- /**
- * missing
- */
- public function testTestGreaterThan5()
- {
- $this->assertFalse($this->cage->testGreaterThan('non-existant', 5));
- }
-
- /**
- * missing min (bad idea)
- */
- public function testTestGreaterThan6()
- {
- $this->assertSame(7, $this->cage->testGreaterThan('int'));
- }
-
- /**
- * @todo Implement testTestHex().
- */
- public function testTestHex()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestHostname().
- * @TODO add more tests for hosttype params
- */
- public function testTestHostname()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestInt() for too high
- * @todo Implement testTestInt() for too low
- * valid
- */
- public function testTestInt()
- {
- $this->assertSame(7, $this->cage->testInt('int'));
- }
-
- /**
- * invalid
- */
- public function testTestInt2()
- {
- $this->assertFalse($this->cage->testInt('date'));
- }
-
- /**
- * missing
- */
- public function testTestInt3()
- {
- $this->assertFalse($this->cage->testInt('non-existant'));
- }
-
- /**
- * @todo Implement testTestIp().
- */
- public function testTestIp()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * integer, true
- */
- public function testTestLessThan()
- {
- $this->assertSame(7, $this->cage->testLessThan('int', 10));
- }
-
- /**
- * non-integer, true
- */
- public function testTestLessThan2()
- {
- $this->assertSame('abcdefg', $this->cage->testLessThan('alpha', 'z'));
- }
-
- /**
- * integer, false
- */
- public function testTestLessThan3()
- {
- $this->assertFalse($this->cage->testLessThan('int', 2));
- }
-
- /**
- * non-integer, false
- * @depends testOffsetSet
- */
- public function testTestLessThan4()
- {
- $this->cage['highAlpha'] = 'z';
- $this->assertFalse($this->cage->testLessThan('highAlpha', 'a'));
- }
-
- /**
- * missing
- */
- public function testTestLessThan5()
- {
- $this->assertFalse($this->cage->testLessThan('non-existant', 5));
- }
-
- /**
- * missing max (bad idea, should alwasy return false?)
- */
- public function testTestLessThan6()
- {
- $this->assertFalse($this->cage->testLessThan('int'));
- }
-
- /**
- * @todo Implement testTestOneOf().
- */
- public function testTestOneOf()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestPhone().
- */
- public function testTestPhone()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestRegex().
- */
- public function testTestRegex()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testTestUri().
- */
- public function testTestUri()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * valid zip
- */
- public function testTestZip()
- {
- $this->assertSame(55555, $this->cage->testZip('zip'));
- }
-
- /**
- * valid zip+4
- */
- public function testTestZip2()
- {
- $this->assertSame('55555-4444', $this->cage->testZip('zip+4'));
- }
-
- /**
- * invalid zip
- */
- public function testTestZip3()
- {
- $this->assertFalse($this->cage->testZip('date'));
- }
-
- /**
- * missing
- */
- public function testTestZip4()
- {
- $this->assertFalse($this->cage->testZip('non-existant'));
- }
-
- /**
- * @todo Implement testNoTags().
- */
- public function testNoTags()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testNoPath().
- */
- public function testNoPath()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testNoTagsOrSpecial().
- */
- public function testNoTagsOrSpecial()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testEscMySQL().
- */
- public function testEscMySQL()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testEscPgSQL().
- */
- public function testEscPgSQL()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testEscPgSQLBytea().
- */
- public function testEscPgSQLBytea()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement testKeyExists().
- */
- public function testKeyExists()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement test_keyExistsRecursive().
- */
- public function test_keyExistsRecursive()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement test_getValue().
- */
- public function test_getValue()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement test_getValueRecursive().
- */
- public function test_getValueRecursive()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement test_setValue().
- */
- public function test_setValue()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-
- /**
- * @todo Implement test_setValueRecursive().
- */
- public function test_setValueRecursive()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
- }
-}
-?> \ No newline at end of file
diff --git a/libs/Inspekt/Error.php b/libs/Inspekt/Error.php
deleted file mode 100644
index 0c924dfacb..0000000000
--- a/libs/Inspekt/Error.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-/**
- * Source file for Inspekt_Error
- *
- * @author Ed Finkler <coj@funkatron.com>
- * @package Inspekt
- */
-
-/**
- * Error handling for Inspekt
- *
- * @package Inspekt
- *
- */
-class Inspekt_Error {
-
- /**
- * Constructor
- *
- * @return Inspekt_Error
- */
- public function __construct() {
-
- }
-
- /**
- * Raises an error. In >= PHP5, this will throw an exception.
- *
- * @param string $msg
- * @param integer $type One of the PHP Error Constants (E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE)
- *
- * @link http://www.php.net/manual/en/ref.errorfunc.php#errorfunc.constants
- */
- public static function raiseError($msg, $type = E_USER_WARNING)
- {
- throw new Exception($msg, $type);
- }
-} \ No newline at end of file
diff --git a/libs/Inspekt/Supercage.php b/libs/Inspekt/Supercage.php
deleted file mode 100644
index 13d830203a..0000000000
--- a/libs/Inspekt/Supercage.php
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-/**
- * Inspekt Supercage
- *
- * @author Ed Finkler <coj@funkatron.com>
- *
- * @package Inspekt
- */
-
-/**
- * require main Inspekt class
- */
-require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'Inspekt.php';
-
-/**
- * require the Cage class
- */
-require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'Inspekt/Cage.php';
-
-/**
- * The Supercage object wraps ALL of the superglobals
- *
- * @package Inspekt
- *
- */
-Class Inspekt_Supercage {
-
- /**
- * The get cage
- *
- * @var Inspekt_Cage
- */
- var $get;
-
- /**
- * The post cage
- *
- * @var Inspekt_Cage
- */
- var $post;
-
- /**
- * The cookie cage
- *
- * @var Inspekt_Cage
- */
- var $cookie;
-
- /**
- * The env cage
- *
- * @var Inspekt_Cage
- */
- var $env;
-
- /**
- * The files cage
- *
- * @var Inspekt_Cage
- */
- var $files;
-
- /**
- * The session cage
- *
- * @var Inspekt_Cage
- */
- var $session;
-
- var $server;
-
- /**
- * Enter description here...
- *
- * @return Inspekt_Supercage
- */
- public function Inspekt_Supercage() {
- // placeholder
- }
-
- /**
- * Enter description here...
- *
- * @param string $config_file
- * @param boolean $strict
- * @return Inspekt_Supercage
- */
- static public function Factory($config_file = NULL, $strict = TRUE) {
-
- $sc = new Inspekt_Supercage();
- $sc->_makeCages($config_file, $strict);
-
- // eliminate the $_REQUEST superglobal
- if ($strict) {
- $_REQUEST = null;
- }
-
- return $sc;
-
- }
-
- /**
- * Enter description here...
- *
- * @see Inspekt_Supercage::Factory()
- * @param string $config_file
- * @param boolean $strict
- */
- protected function _makeCages($config_file=NULL, $strict=TRUE) {
- $this->get = Inspekt::makeGetCage($config_file, $strict);
- $this->post = Inspekt::makePostCage($config_file, $strict);
- $this->cookie = Inspekt::makeCookieCage($config_file, $strict);
- $this->env = Inspekt::makeEnvCage($config_file, $strict);
- $this->files = Inspekt::makeFilesCage($config_file, $strict);
- // $this->session = Inspekt::makeSessionCage($config_file, $strict);
- $this->server = Inspekt::makeServerCage($config_file, $strict);
- }
-
-
- public function addAccessor($name) {
- $this->get->addAccessor($name);
- $this->post->addAccessor($name);
- $this->cookie->addAccessor($name);
- $this->env->addAccessor($name);
- $this->files->addAccessor($name);
- // $this->session->addAccessor($name);
- $this->server->addAccessor($name);
- }
-
-} \ No newline at end of file