/** See JSONMessage constructor. */ public function __construct(JSONRequest $req) { parent::__construct($req); $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); }
/** See JSONMessage constructor. */ public function __construct(JSONRequest $req) { parent::__construct($req); $pay = $req->getPayload(array()); 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); } $url = 'http://' . $proj . '.googlecode.com/svn/wiki/'; $fh = @file_get_contents($url, 'r'); if (false === $fh) { throw new Exception($this->getType() . " could not open URL [{$url}]!", 3); } $opay = array(); $opay['project'] = $proj; $opay['url'] = $url; $m = array(); preg_match_all("/>([a-zA-Z]\\w+)\\.wiki</", $fh, $m); /* $li = array(); if($m) for( $i = 0; $i < count($m[1]); ++$i ) { $x = $m[1]; array_push( $li, $x[$i] ); }*/ //$opay['matches'] = $m; $opay['pages'] = @$m[1] ? $m[1] : null; $this->setPayload($opay); }
/** See JSONMessage constructor. */ public function __construct(JSONRequest $req) { parent::__construct($req); $tr = $req->get('timestamp'); $ts = $this->get('timestamp'); $ar = array('timeDiffSeconds' => ($ts - $tr) / 1000, 'requestTime' => $tr, 'pingPayload' => $req->getPayload()); $this->setResult(0, 'Pong'); $this->setPayload($ar); }
/** See JSONMessage constructor. */ public function __construct(JSONRequest $req) { parent::__construct($req); $ans = array(); $errval = -42; $payload = $req->getPayload(array()); $got = 0; $ar = $req->getOptions(); if ($ar) { $this->opt = array_merge($this->opt, $ar); } $ar = @$payload['get']; if (null !== $ar) { ++$got; $ans['get'] = $this->getEnv($ar); } $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); }
/** 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); }