ACBackend::process PHP Method

process() public method

public process ( $command = '', $logger = null, $endCallback = null )
    public function process($command = '', $logger = null, $endCallback = null)
    {
        $command = explode(',', $command);
        $command = $command[0];
        self::$logger = $logger;
        self::$endCallback = $endCallback;
        if ('' == $command) {
            throw new Exception('No action command specified.');
        }
        if (!method_exists($this, 'on_' . $command)) {
            throw new Exception('Action command `' . $command . '` not found.');
        }
        $command = 'on_' . $command;
        $p = array();
        if (get_magic_quotes_gpc()) {
            $req_vars = array_map('stripslashes', $_REQUEST);
        } else {
            $req_vars = $_REQUEST;
        }
        foreach ($req_vars as $k => $v) {
            if ('(a)' == substr($k, -3)) {
                // array passed
                $v = explode('],[', substr($v, 1, -1));
                $n = sizeof($v);
                for ($i = 0; $i < $n; $i++) {
                    $v[$i] = str_replace('`§~§[]§~§`', '],[', $v[$i]);
                }
                $p[substr($k, 0, -3)] = $v;
            } else {
                if ('(o)' == substr($k, -3)) {
                    // object passed
                    $obj = new stdClass();
                    $v = explode('],[', substr($v, 1, -1));
                    $n = sizeof($v);
                    for ($i = 0; $i < $n; $i++) {
                        $pair = str_replace('`§~§[]§~§`', '],[', $v[$i]);
                        if (false !== ($ix = strpos($pair, '='))) {
                            $prop_name = substr($pair, 0, $ix);
                            $obj->{$prop_name} = substr($pair, $ix + 1);
                        }
                    }
                    $p[substr($k, 0, -3)] = $obj;
                } else {
                    $p[$k] = $v;
                }
            }
        }
        $this->{$command}($p);
    }