forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OP_server.php
138 lines (110 loc) · 4.47 KB
/
OP_server.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?
//************************************************************************
// Leonardo XC Server, http://www.leonardoxc.net
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: OP_server.php,v 1.7 2010/03/14 20:56:11 manolis Exp $
//
//************************************************************************
// this runs on the slave servers so that the master can upload updates
$serverFunctions['server.uploadFileFromUrl']='uploadFileFromUrl';
function uploadFileFromUrl($arg) {
$sitePass=$arg[0];
$remoteFile=$arg[1];
$localFile=$arg[2];
global $CONF_SitePassword;
if ( ! securityCheck($sitePass) ) return new IXR_Error(4000, 'Access Denied');;
if ( ($fileStr=@file_get_contents($remoteFile)) === FALSE)
return new IXR_Error(4001, "Cant access file ($remoteFile) to upload");
if ( ! (strpos($localFile,"..") === FALSE) )
return new IXR_Error(4002, "Invalid local file ($localFile)");
$f1=$fileStr;
$filename=dirname(__FILE__)."/$localFile";
if (!$handle = fopen($filename, 'w'))
return new IXR_Error(4003, "Cannot open file ($filename)");
if (fwrite($handle, $fileStr)===FALSE)
return new IXR_Error(4004, "Cannot write to file ($filename)");
fclose($handle);
return 1;
}
// this runs on the slave servers so that the master can upload updates
$serverFunctions['server.uploadFileInline']='uploadFileInline';
function uploadFileInline($arg) {
$sitePass=$arg[0];
$remoteFile_base64=$arg[1];
$localFile=$arg[2];
global $CONF_SitePassword;
if ( ! securityCheck($sitePass) ) return new IXR_Error(4000, 'Access Denied');;
if ( ! (strpos($localFile,"..") === FALSE) )
return new IXR_Error(4002, "Invalid local file ($localFile)");
$fileStr=base64_decode($remoteFile_base64);
$filename=dirname(__FILE__)."/$localFile";
if (!$handle = fopen($filename, 'w'))
return new IXR_Error(4003, "Cannot open file ($filename)");
if (fwrite($handle, $fileStr)===FALSE)
return new IXR_Error(4004, "Cannot write to file ($filename)");
fclose($handle);
return 1;
}
$serverFunctions['server.info']='server_info';
function server_info($arg) {
$sitePass=$arg;
global $CONF_SitePassword;
global $CONF_version,$CONF_releaseDate, $opMode, $CONF_isMasterServer, $CONF_admin_email;
if ( ! securityCheck($sitePass) ) return new IXR_Error(4000, 'Access Denied');
return array($CONF_version,$CONF_releaseDate, $opMode, $CONF_isMasterServer,
$CONF_admin_email,PHP_VERSION,mysql_get_server_info() ,mysql_get_client_info() );
}
$serverFunctions['server.module_info']='server_module_info';
function server_module_info($arg) {
$sitePass=$arg;
global $CONF_SitePassword;
global $CONF_version,$CONF_releaseDate, $opMode, $CONF_isMasterServer, $CONF_admin_email;
if ( ! securityCheck($sitePass) ) return new IXR_Error(4000, 'Access Denied');
return array($CONF_version,$CONF_releaseDate, $opMode, $CONF_isMasterServer, $CONF_admin_email);
}
// this function runs only on the Master Server to register slave servers
require_once dirname(__FILE__).'/CL_server.php';
$serverFunctions['server.registerSlave']='registerSlave';
function registerSlave($arg) {
$installType=$arg[0];
$leonardo_version=$arg[1];
$url=$arg[2];
$url_base=$arg[3];
$url_op=$arg[4];
$adminEmail=$arg[5];
$sitePass=$arg[6];
global $CONF_isMasterServer;
if (!$CONF_isMasterServer)
return new IXR_Error(5001, "Not a Master server");
if (0){
$newServer=new Server();
$newServer->ID= Server::getNextFreeID();
$newServer->isLeo=1;
$newServer->installation_type =$installType;
$newServer->leonardo_version =$leonardo_version ;
$newServer->url =$url;
$newServer->url_base =$url_base;
$newServer->url_op =$url_op;
$newServer->admin_email =$adminEmail;
$newServer->site_pass =$sitePass;
$newServer->is_active =0;
$newServer->gives_waypoints =1;
$newServer->waypoint_countries ='';
$res=$newServer->putToDB();
}
$fileStr="$installType#$leonardo_version#$url#$url_op#$adminEmail#$sitePass\n";
$filename=dirname(__FILE__)."/DB_of_servers.txt";
if (!$handle = fopen($filename, 'a'))
return new IXR_Error(5002, "Cannot open file ($filename)");
if (fwrite($handle, $fileStr)===FALSE)
return new IXR_Error(5003, "Cannot write to file ($filename)");
fclose($handle);
return 1;
}
?>