X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=67eaf9ed7a65fbaad400a16794687a600fb37215;hb=0eaeff2cbf486e1634a98740554c974153a65aeb;hp=f8442a1f02b81c6388b753cf685e15acc56a7fb6;hpb=3b14b7901c65144835d74b712279d0492c267c0c;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index f8442a1f02..67eaf9ed7a 100644 --- a/lib/action.php +++ b/lib/action.php @@ -1,18 +1,18 @@ . */ @@ -22,19 +22,40 @@ if (!defined('LACONICA')) { exit(1); } class Action { // lawsuit var $args; - + function Action() { } - + function arg($key) { - if (array_has_key($this->args, $key)) { + if (array_key_exists($key, $this->args)) { return $this->args[$key]; } else { return NULL; } } + + function trimmed($key) { + $arg = $this->arg($key); + return (is_string($arg)) ? trim($arg) : $arg; + } + + function handle($argarray) { + $strip = get_magic_quotes_gpc(); + $this->args = array(); + foreach ($argarray as $k => $v) { + $this->args[$k] = ($strip) ? stripslashes($v) : $v; + } + } - function handle($args) { - $this->args = copy($argarray); + function boolean($key, $def=false) { + $arg = $this->arg($key); + return (is_null($arg)) ? $def : + (strcasecmp($arg, 'true')) ? true : + (strcasecmp($arg, 'yes')) ? true : + (strcasecmp($arg, '1')) ? true : + (strcasecmp($arg, 'false')) ? false : + (strcasecmp($arg, 'no')) ? false : + (strcasecmp($arg, '0')) ? false : + $def; } }