-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathatheme.php
84 lines (73 loc) · 2.84 KB
/
atheme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once "lib/xmlrpc.inc";
function atheme_register($hostname, $port, $path, $sourceip, $username, $password, $email)
{
$client = new xmlrpc_client($path, $hostname, $port);
$message = new xmlrpcmsg("atheme.register");
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($password, "string"));
$message->addParam(new xmlrpcval($email, "string"));
$response = $client->send($message);
if (!$response->faultCode()) {
return $response->serialize();
} else {
return "Command failed: " . $response->faultString();
}
}
function atheme_verify($hostname, $port, $path, $sourceip, $username, $code)
{
$client = new xmlrpc_client($path, $hostname, $port);
$message = new xmlrpcmsg("atheme.verify");
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($code, "string"));
$message->addParam(new xmlrpcval($sourceip, "string"));
$response = $client->send($message);
if (!$response->faultCode()) {
return $response->serialize();
} else {
return "Command failed: " . $response->faultString();
}
}
function atheme($hostname, $port, $path, $sourceip, $username, $password, $service, $command, $params)
{
$message = new xmlrpcmsg("atheme.login");
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($password, "string"));
$client = new xmlrpc_client($path, $hostname, $port);
$response = $client->send($message);
$session = NULL;
if (!$response->faultCode()) {
$session = explode("<string>", $response->serialize());
$session = explode("</string", $session[1]);
$session = $session[0];
} else {
return "Authorisation failed";
}
$message = new xmlrpcmsg("atheme.command");
$message->addParam(new xmlrpcval($session, "string"));
$message->addParam(new xmlrpcval($username, "string"));
$message->addParam(new xmlrpcval($sourceip, "string"));
$message->addParam(new xmlrpcval($service, "string"));
$message->addParam(new xmlrpcval($command, "string"));
if ($params != NULL) {
if (sizeof($params) < 2) {
foreach ($params as $param) {
$message->addParam(new xmlrpcval($param, "string"));
}
} else {
$firstparam = $params[0];
$secondparam = "";
for ($i = 1; $i < sizeof($params); $i++) {
$secondparam .= $params[$i] . " ";
}
$message->addParam(new xmlrpcval($firstparam, "string"));
$message->addParam(new xmlrpcval($secondparam, "string"));
}
$response = $client->send($message);
}
if (!$response->faultCode()) {
return $response->serialize();
} else {
return "Command failed: " . $response->faultString();
}
}