summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSebastian <github@afreshmelon.com>2015-04-04 09:43:51 +0200
committerSebastian <github@afreshmelon.com>2015-04-04 09:43:51 +0200
commit41f4c7dab66765e4e759559b97b4a37317a32090 (patch)
treec64c3280e7602ed746b2e7375556c4eecefad477 /docs
parentdd8dd3b4a09543bd0ab8496580c971d6e614a926 (diff)
A variety of small improvements to xmlrpc.php
Pretty simple stuff. * Better method names * Better DocBlocks * Lowercase variables
Diffstat (limited to 'docs')
-rw-r--r--docs/XMLRPC/xmlrpc.php99
1 files changed, 68 insertions, 31 deletions
diff --git a/docs/XMLRPC/xmlrpc.php b/docs/XMLRPC/xmlrpc.php
index 90e7a09c3..2b5645ca7 100644
--- a/docs/XMLRPC/xmlrpc.php
+++ b/docs/XMLRPC/xmlrpc.php
@@ -1,62 +1,88 @@
<?php
-/* XMLRPC Functions
+
+/**
+ * XMLRPC Functions
*
- * (C) 2003-2014 Anope Team
+ * (C) 2003-2015 Anope Team
* Contact us at team@anope.org
- *
*/
-
class AnopeXMLRPC
{
- private $Host;
+ /**
+ * The XMLRPC host
+ *
+ * @var string
+ */
+ private $host;
- public function __construct($Host)
+ /**
+ * Initiate a new AnopeXMLRPC instance
+ *
+ * @param $host
+ */
+ public function __construct($host)
{
- $this->Host = $Host;
+ $this->host = $host;
}
- /** Run an XMLRPC command. Name should be a query name and params an array of parameters, eg:
- * $this->RunXMLRPC("checkAuthentication", array("adam", "qwerty"));
+ /**
+ * Run an XMLRPC command. Name should be a query name and params an array of parameters, eg:
+ * $this->raw("checkAuthentication", ["adam", "qwerty"]);
* If successful returns back an array of useful information.
*
* Note that $params["id"] is reserved for query ID, you may set it to something if you wish.
* If you do, the same ID will be passed back with the reply from Anope.
+ *
+ * @param $name
+ * @param $params
+ * @return array|null
*/
- public function RunXMLRPC($name, $params)
+ public function run($name, $params)
{
$xmlquery = xmlrpc_encode_request($name, $params);
- $context = stream_context_create(array("http" => array(
+ $context = stream_context_create(["http" => [
"method" => "POST",
"header" => "Content-Type: text/xml",
- "content" => $xmlquery)));
+ "content" => $xmlquery]]);
- $inbuf = file_get_contents($this->Host, false, $context);
+ $inbuf = file_get_contents($this->host, false, $context);
$response = xmlrpc_decode($inbuf);
- if (isset($response)) {
+ if ($response) {
return $response;
}
return null;
}
- /** Do Command on Service as User, eg:
- * $anope->DoCommand("ChanServ", "Adam", "REGISTER #adam");
+ /**
+ * Do Command on Service as User, eg:
+ * $anope->command("ChanServ", "Adam", "REGISTER #adam");
* Returns an array of information regarding the command execution, if
* If 'online' is set to yes, then the reply to the command was sent to the user on IRC.
* If 'online' is set to no, then the reply to the command is in the array member 'return'
+ *
+ * @param $service
+ * @param $user
+ * @param $command
+ * @return array|null
*/
- public function DoCommand($Service, $User, $Command)
+ public function command($service, $user, $command)
{
- return $this->RunXMLRPC("command", array($Service, $User, $Command));
+ return $this->run("command", [$service, $user, $command]);
}
- /** Check an account/nick name and password to see if they are valid
+ /**
+ * Check an account/nick name and password to see if they are valid
* Returns the account display name if valid
+ *
+ * @param $account
+ * @param $pass
+ * @return string|null
*/
- public function CheckAuthentication($Account, $Pass)
+ public function auth($account, $pass)
{
- $ret = $this->RunXMLRPC("checkAuthentication", array($Account, $Pass));
+ $ret = $this->run("checkAuthentication", [$account, $pass]);
if ($ret && $ret["result"] == "Success") {
return $ret["account"];
@@ -65,28 +91,39 @@ class AnopeXMLRPC
return null;
}
- /* Returns an array of misc stats regarding Anope
+ /**
+ * Returns an array of misc stats regarding Anope
+ *
+ * @return array|null
*/
- public function DoStats()
+ public function stats()
{
- return $this->RunXMLRPC("stats", null);
+ return $this->run("stats", null);
}
- /* Look up data for a channel
+ /**
+ * Look up data for a channel
* Returns an array containing channel information, or an array of size one
* (just containing the name) if the channel does not exist
+ *
+ * @param $channel
+ * @return array|null
*/
- public function DoChannel($Channel)
+ public function channel($channel)
{
- return $this->RunXMLRPC("channel", array($Channel));
+ return $this->run("channel", [$channel]);
}
- /* Like DoChannel(), but different.
+ /**
+ * Like channel(), but different.
+ *
+ * @param $user
+ * @return array|null
*/
- public function DoUser($User)
+ public function user($user)
{
- return $this->RunXMLRPC("user", array($User));
+ return $this->run("user", [$user]);
}
}
-$anopexmlrpc = new AnopeXMLRPC("http://127.0.0.1:8080/xmlrpc");
+$anope = new AnopeXMLRPC("http://127.0.0.1:8080/xmlrpc");