inc/get.php -
index
<?php
/* GET.PHP - THIS CODE WILL CHANGE
This is an experimental GET data parser/validator.
The idea is to see if ALL $_GET data can be read, parsed,
and validated in just one place.
See also RULES.PHP for more data validation code.
*/
/* the GET macro */
$GET = 'foreach(explode(",",$get)as$_g){$$_g=@$_GET[$_g]?:"";}';
// usage:
// $get = 'op,arg';
// eval($GLOBALS['GET']);
// echo "op=$op, arg=$arg";
function getvar($var) {
return ($t = @$_GET[$var]) ? $t : '';
}
/* EXPERIMENTAL */
/* This simulates an INI file */
// (possible to use configfile() here only because it's source is
// 'base.php' and the glob() function sorts! see INDEX.PHP line 17
// for where/what/why I mean)
$getdata = configfile(explode(THIS_EOL,'
[visitors]
n =
e =
x =
c =
[:a]
_pre = $a = ($a!=="") ? $a[0] : "";
ctype_digit = $a = "0-9";
ctype_alpha = $a = strtolower($a).strtoupper($a);
ctype_punct = $a = "^a-zA-Z0-9";
'));
// yes, the above is incomprehensible; but we won't explain as it will
// be changed; this function was created to support the Admin "Visitors"
// code, and that is the sole caller; might be deleted as this may be too
// odd even for us!
// compare this function to postvars() (in POST.PHP); this one is simpler
// (sort of, smaller anyway) and can possible do more! need to add more...
function getvars($vars) {
global $getdata;
if (is_string($vars)) {
if (!isset($getdata[$vars]))
return FALSE;
$vars = $getdata[$vars];
}
foreach ($vars as $n => $v) {
$a = (isset($_GET[$n])) ? $_GET[$n] : "";
if (isset($vars[$n]['_pre'])) {
$p = array_shift($vars[$n]);
eval($p);
}
if (is_array($vars[$n])) {
foreach ($vars[$n] as $f => $p) {
if ($f($a)) {
eval($p);
break;
}
}
}
$gets[] = $a;
}
return $gets;
}
?>