X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Faction.php;h=67eaf9ed7a65fbaad400a16794687a600fb37215;hb=de56ccca07e19c5163792c210ff5f6130e91d892;hp=049885acd0450589b3d663fa69172ed15bc92ef1;hpb=b6cfd2dffeeb733f07818db5f4ce11d4b3d51771;p=quix0rs-gnu-social.git diff --git a/lib/action.php b/lib/action.php index 049885acd0..67eaf9ed7a 100644 --- a/lib/action.php +++ b/lib/action.php @@ -1,40 +1,61 @@ . */ -if (!defined('LACONICA')) { exit(1) } +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; } }