2008-05-09 03:16:04 +01:00
|
|
|
<?php
|
2008-05-20 20:14:12 +01:00
|
|
|
/*
|
2008-05-14 20:26:48 +01:00
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2008-05-14 20:26:48 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2008-05-14 20:26:48 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2008-05-20 20:14:12 +01:00
|
|
|
*
|
2008-05-14 20:26:48 +01:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2008-05-09 03:16:04 +01:00
|
|
|
|
2008-05-17 16:47:01 +01:00
|
|
|
if (!defined('LACONICA')) { exit(1); }
|
2008-05-14 20:00:09 +01:00
|
|
|
|
2008-05-09 03:16:04 +01:00
|
|
|
class Action { // lawsuit
|
|
|
|
|
|
|
|
var $args;
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2008-05-09 03:16:04 +01:00
|
|
|
function Action() {
|
|
|
|
}
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2008-05-09 03:16:04 +01:00
|
|
|
function arg($key) {
|
2008-05-17 17:42:18 +01:00
|
|
|
if (array_key_exists($key, $this->args)) {
|
2008-05-09 03:16:04 +01:00
|
|
|
return $this->args[$key];
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-05-20 20:14:12 +01:00
|
|
|
|
2008-05-21 12:27:07 +01:00
|
|
|
function trimmed($key) {
|
|
|
|
$arg = $this->arg($key);
|
|
|
|
return (is_string($arg)) ? trim($arg) : $arg;
|
|
|
|
}
|
|
|
|
|
2008-05-17 17:37:49 +01:00
|
|
|
function handle($argarray) {
|
2008-05-22 11:36:30 +01:00
|
|
|
$strip = get_magic_quotes_gpc();
|
2008-05-17 17:23:05 +01:00
|
|
|
$this->args = array();
|
2008-05-17 17:37:49 +01:00
|
|
|
foreach ($argarray as $k => $v) {
|
2008-05-22 11:36:30 +01:00
|
|
|
$this->args[$k] = ($strip) ? stripslashes($v) : $v;
|
2008-05-17 17:23:05 +01:00
|
|
|
}
|
2008-05-09 03:16:04 +01:00
|
|
|
}
|
2008-05-22 12:29:54 +01:00
|
|
|
|
|
|
|
function boolean($key, $def=false) {
|
|
|
|
$arg = $this->arg($key);
|
|
|
|
return (is_null($arg)) ? $def :
|
2008-05-29 16:16:02 +01:00
|
|
|
(strcasecmp($arg, 'true') == 0) ? true :
|
|
|
|
(strcasecmp($arg, 'yes') == 0) ? true :
|
|
|
|
(strcasecmp($arg, '1') == 0) ? true :
|
|
|
|
(strcasecmp($arg, 'false') == 0) ? false :
|
|
|
|
(strcasecmp($arg, 'no') == 0) ? false :
|
|
|
|
(strcasecmp($arg, '0') == 0) ? false :
|
2008-05-22 12:29:54 +01:00
|
|
|
$def;
|
|
|
|
}
|
2008-05-09 03:16:04 +01:00
|
|
|
}
|