Anope IRC Services  Version 2.0
xmlrpc.php
Go to the documentation of this file.
1 <?php
2 /* XMLRPC Functions
3  *
4  * (C) 2003-2014 Anope Team
5  * Contact us at team@anope.org
6  *
7  */
8 
10 {
11  private $Host;
12 
13  function __construct($Host)
14  {
15  $this->Host = $Host;
16  }
17 
25  function RunXMLRPC($name, $params)
26  {
27  $xmlquery = xmlrpc_encode_request($name, $params);
28  $context = stream_context_create(array("http" => array(
29  "method" => "POST",
30  "header" => "Content-Type: text/xml",
31  "content" => $xmlquery)));
32 
33  $inbuf = file_get_contents($this->Host, false, $context);
34  $response = xmlrpc_decode($inbuf);
35 
36  if (isset($response[0]))
37  return $response[0];
38  return NULL;
39  }
40 
47  function DoCommand($Service, $User, $Command)
48  {
49  return $this->RunXMLRPC("command", array($Service, $User, $Command));
50  }
51 
55  function CheckAuthentication($Account, $Pass)
56  {
57  $ret = $this->RunXMLRPC("checkAuthentication", array($Account, $Pass));
58 
59  if ($ret && $ret["result"] == "Success")
60  return $ret["account"];
61  return NULL;
62  }
63 
64  /* Returns an array of misc stats regarding Anope
65  */
66  function DoStats()
67  {
68  return $this->RunXMLRPC("stats", NULL);
69  }
70 
71  /* Look up data for a channel
72  * Returns an array containing channel information, or an array of size one
73  * (just containing the name) if the channel does not exist
74  */
75  function DoChannel($Channel)
76  {
77  return $this->RunXMLRPC("channel", array($Channel));
78  }
79 
80  /* Like DoChannel(), but different.
81  */
82  function DoUser($User)
83  {
84  return $this->RunXMLRPC("user", array($User));
85  }
86 }
87 
88 $anopexmlrpc = new AnopeXMLRPC("http://127.0.0.1:8080/xmlrpc");
89 
90 ?>
DoUser($User)
Definition: xmlrpc.php:82
DoChannel($Channel)
Definition: xmlrpc.php:75
DoCommand($Service, $User, $Command)
Definition: xmlrpc.php:47
__construct($Host)
Definition: xmlrpc.php:13
RunXMLRPC($name, $params)
Definition: xmlrpc.php:25
$anopexmlrpc
Definition: xmlrpc.php:88
CheckAuthentication($Account, $Pass)
Definition: xmlrpc.php:55