Exemplo n.º 1
0
        $ar = @$payload['clearCookies'];
        if ($ar) {
            ++$got;
            $sessname = session_name();
            foreach ($_COOKIE as $k => $v) {
                if ($sessname === $k) {
                    continue;
                }
                $this->setCookie($k, false);
                //$this->log[] = "Unset cookie [$k].";
            }
            $ans['cleared'] = true;
            // we do this to force the payload to be-a {object} instead of [array]
            $this->setResult(0, $this->log[] = "Cookies cleared.");
        }
        $ar = @$payload['set'];
        if ($ar) {
            ++$got;
            $ans['set'] = $this->setEnv($ar);
        }
        if (!$got) {
            $this->setResult(1, "Usage error: no action specified.");
        }
        if (count($this->log)) {
            $ans['log'] = $this->log;
        }
        $this->setPayload($ans);
    }
}
JSONMessageDispatcher::mapResponderFile(__FILE__, 'JSONResponse_Cookie');
Exemplo n.º 2
0
        $pay = $req->getPayload();
        if (!@is_array($pay)) {
            throw new Exception($this->getType() . " requires a payload object!", 1);
        }
        $proj = @$pay['project'];
        if (!$proj) {
            throw new Exception($this->getType() . " requires a 'project' property in the payload!", 2);
        }
        $page = @$pay['page'];
        if (!$page) {
            throw new Exception($this->getType() . " requires a 'page' property in the payload!", 2);
        }
        $rev = (int) @$pay['r'];
        $url = 'http://' . $proj . '.googlecode.com/svn/wiki/' . $page . '.wiki' . ($rev ? '?r=' . $rev : '');
        $fh = @file_get_contents($url, 'r');
        if (false === $fh) {
            throw new Exception($this->getType() . " could not open URL [{$url}]!", 3);
        }
        $opay = array();
        $opay['url'] = $url;
        $opay['project'] = $proj;
        $opay['page'] = $page;
        if ($rev) {
            $opay['r'] = $rev;
        }
        $opay['content'] = $fh;
        $this->setPayload($opay);
    }
}
JSONMessageDispatcher::mapResponderFile(__FILE__, JSONResponse_GoCo_GetWikiPage);
Exemplo n.º 3
0
            $ar[] = "The Big Bang happened when Chuck Norris went back in time to just before the Universe began and every atom in the Universe immediately decided it should get the hell away from there and fast. ";
            $ar[] = "Chuck Norris has no home security system. Chuck Norris welcomes intruders.  ";
            $ar[] = "Chuck Norris has the eyes of an angel and the soul of a saint.  He keeps them in a footlocker under his bed. ";
            self::$_quotes = $ar;
        }
        return self::$_quotes;
    }
    /**
        See JSONMessage constructor.
    */
    public function __construct(JSONRequest $req)
    {
        parent::__construct($req);
        $a = array();
        $q = self::quotes();
        $respay = $req->getPayload();
        if ($respay && @is_array($respay) && @$respay['fetchAll']) {
            $a['credits'] = array('originalListAuthor' => 'Brandon Checketts', 'originalURL' => 'http://www.apeleon.net/~microbit/brandon.html');
            $a['quotes'] = $q;
        } else {
            $c = count($q);
            $n = $c ? rand(0, $c - 1) : 0;
            $a['quote'] = $q[$n];
            $a['number'] = $n;
            $a['of'] = $c;
        }
        $this->setPayload($a);
    }
}
JSONMessageDispatcher::mapResponderFile(__FILE__, JSONResponse_ChuckNorris::ClassName);