index






















































































<?php

/* GETPOST.PHP - GET/POST data parser/validator

There used to be much experimental stuff here in trying to automate and 
validate data according to defined filters... It was pretty bad...

This is all very trivial stuff now. See RULES.PHP for more data validation.
*/

define('POST_','foreach(explode(",",$post)as$_p){$$_p=($_t=trim(@$_POST[$_p]))?$_t:"";}');

// usage:
// $post = 'name,button';
// eval(POST_);
// echo "name=$name, button=$button";


// first things first!

foreach ($_POST as $name => $value) {
    
$_POST[$name] = preg_replace("/\r/","",$value); // WINDOWS/MAC
    
$_POST[$name] = trim($_POST[$name]);
    if (
get_magic_quotes_gpc())
        
$_POST[$name] = stripslashes($_POST[$name]);
}


/* getvar - read a $_GET variable (reduces redundancy) */

function getvar($var) {
    return (isset(
$_GET[$var])) ? $_GET[$var] : '';
}


/* postvar - read a $_POST variable */

function postvar($var) {
    return (isset(
$_POST[$var])) ? $_POST[$var] : '';
}


/* postvars - read and/or validate $_POST variables */

function postvars($a = array(), $assoc FALSE) {

    
// postvars("one","two","three");

    
if (!is_array(func_get_arg(0)))
        foreach (
func_get_args() as $var)
            if (
$assoc$p[$var] = $_POST[$var];
            else 
$p[] = $_POST[$var];
    else

    
// postvars(array("one","two","three"));

    
if (isset($a[0]))
        foreach (
func_get_arg(0) as $var)
            if (
$assoc$p[$var] = $_POST[$var];
            else 
$p[] = $_POST[$var];
    else

    
// postvars(array(32,array(32,"function"));

// this one is used by the comment form, it truncates and/or filters the data
// it modifies the $_POST array

    
foreach ($a as $var => $val) {
        
$g postvar($var);
        
$n = (is_numeric($val)) ? $val $val[0];

// have to make sure empty is empty and not FALSE:
        
if ($g)
            
$g substr($g,0,$n);

        if (isset(
$val[1]) && function_exists($val[1]))
            
$g $val[1]($g);

        
$p[] = $_POST[$var] = $g;
    }

    return 
$p;
}

?>