<?
require_once('superglobals.php');
class falseDB
{
public function getCol()
{
return array( 'first','second','third');
}
public function escape($value)
{
return mysql_escape_string($value);
}
}
class falseMemcache
{
function get()
{
return false;
}
function set()
{
return false;
}
}
echo '<a href="/superglobals/superglobals.zip">Download this package</a> <br> --------------------------------------- <br>';
echo '--------------------------------------- <br> Unit tests: <br> --------------------------------------- <br>';
function dooHast()
{
echo '--------------------------------------- <br> Calls from function with modifiers: <br> --------------------------------------- <br>';
echo '<b>$_GET[\'myParam\']:</b> <cite>';
var_dump($_GET['myParam']);
echo '</cite><br><b>$_GET[\'array:myParam\']:</b> <cite>';
var_dump($_GET['array:myParam']);
echo '</cite><br><b>$_GET[\'id\']:</b> <cite>';
var_dump($_GET['id']);
echo '</cite><br><b>$_GET[\'id_as_int\']:</b> <cite>';
var_dump($_GET['id_as_int']);
echo '</cite><br><b>$_GET[\'int:id\']:</b> <cite>';
var_dump($_GET['int:id']);
echo '</cite><br><b>$_GET[\'array:int:id\']:</b> <cite>';
var_dump($_GET['array:int:id']);
echo '</cite><br><b>$_GET[\'array:float:cos:id\']:</b> <cite>';
var_dump($_GET['array:float:cos:id']);
echo '</cite><br><b>$_POST[\'escape:test\']:</b> <cite>';
var_dump($_POST['escape:test']);
echo '</cite><br><b>$_GET</b>: <cite>';
echo $_GET;
echo '</cite><br>';
}
$start = microtime(true);
$_POST['test'] = '<html>test';
superGlobal::db(new falseDB());
superGlobal::memcached(new falseMemcache(),1200);
superGlobal::registerParam('myParam', array('index','about_us','production','events','publications','resources','contacts','login','��'));
superGlobal::registerParam('id', 'is_numeric');
superGlobal::registerParam('int:id_as_int', 'is_numeric');
superGlobal::registerSQLParam('sql', 'falseTable','falseField');
superGlobal::inject('_POST');
echo '--------------------------------------- <br> Array iteration: <br> --------------------------------------- <br>';
foreach($_GET as $k => $v)
echo $k.' => '.$v.";<br>";
dooHast();
echo '<br>--------------------------------------- <br> Time spent: '.(microtime(true) - $start).' seconds <br> --------------------------------------- <br>';
echo '<br>--------------------------------------- <br> Source code of unit test file: <br> --------------------------------------- <br>';
highlight_file(__FILE__);
echo '<br>--------------------------------------- <br> Source code of library: <br> --------------------------------------- <br>';
highlight_file('superglobals.php');
?>