forked from teleyinex/jarifa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpc.php
71 lines (59 loc) · 1.96 KB
/
rpc.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
<?php
/*
Copyright 2008 Daniel Lombraña González, David P. Anderson, Francisco Fernández de Vega
This file is part of Jarifa.
Jarifa is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Jarifa is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Jarifa. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("inc/rpc.inc");
$rpc = new rpc;
$host = simplexml_load_file("php://input",'SimpleXMLElement',LIBXML_NOCDATA);
// Update <opaque><id></id></opaque> content as it is surrounded by CDATA:
$host->opaque->addChild('id','');
$host->opaque->id = simplexml_load_string($host->opaque, 'SimpleXMLElement',LIBXML_NOCDATA);
if ($rpc->auth($host))
{
//fill reply with name and public key
$rpc->xmlSigningKey();
//check, if host already exists
if (!$rpc->exist_host())
{
//host is unknown, add it
$id = $rpc->add_host();
if ($id == False)
{
$rpc->error('database operation (add host) failed');
echo $rpc->dom->saveXML();
return;
}
}
//
$rpc->xmlRepeat_sec();
//fill reply withh preferences from pool
$rpc->xmlPreferences();
//
$rpc->xmlOpaqueID();
//fill reply with project infos
$projects = $rpc->projects();
foreach ($projects as $project)
{
$rpc->xmlProject($project);
}
$rpc->xmlRssFeed();
//return the reply as xml string
echo $rpc->dom->saveXML();
}
else {
$rpc->xmlSigningKey();
$rpc->error('host authentication failed');
echo $rpc->dom->saveXML();
}
?>