1
|
|
|
<?php |
2
|
|
|
/****************************************************************** |
3
|
|
|
loader.soap.php Muze Ariadne |
4
|
|
|
------------------------------------------------------------------ |
5
|
|
|
Author: Muze ([email protected]) |
6
|
|
|
Date: 11 december 2002 |
7
|
|
|
|
8
|
|
|
Copyright 2002 Muze |
9
|
|
|
|
10
|
|
|
This file is part of Ariadne. |
11
|
|
|
|
12
|
|
|
Ariadne is free software; you can redistribute it and/or modify |
13
|
|
|
it under the terms of the GNU General Public License as published |
14
|
|
|
by the Free Software Foundation; either version 2 of the License, |
15
|
|
|
or (at your option) any later version. |
16
|
|
|
|
17
|
|
|
Ariadne is distributed in the hope that it will be useful, |
18
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
GNU General Public License for more details. |
21
|
|
|
|
22
|
|
|
You should have received a copy of the GNU General Public License |
23
|
|
|
along with Ariadne; if not, write to the Free Software |
24
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
25
|
|
|
02111-1307 USA |
26
|
|
|
|
27
|
|
|
------------------------------------------------------------------- |
28
|
|
|
|
29
|
|
|
Description: |
30
|
|
|
|
31
|
|
|
Contains all loader functions for the Ariadne Soap interface. |
32
|
|
|
|
33
|
|
|
******************************************************************/ |
34
|
|
|
|
35
|
|
|
$ERRMODE="htmljs"; // alternative: "text"/"html"/"js" |
36
|
|
|
|
37
|
|
|
require_once($store_config['code']."include/loader.soap.server.php"); |
38
|
|
|
|
39
|
|
|
$DB["method"]["loader"] = false; |
40
|
|
|
$DB["method"]["file"] = true; |
41
|
|
|
$DB["file"] = "/tmp/soap.log"; |
42
|
|
|
|
43
|
|
|
function error($text, $code="Client.Unkown") { |
|
|
|
|
44
|
|
|
global $SOAP_Fault; |
45
|
|
|
debug("soap::ldObjectNotFound($requestedpath, $requestedtemplate)", "loader"); |
|
|
|
|
46
|
|
|
$SOAP_Fault = new soap_fault( |
47
|
|
|
$code, |
48
|
|
|
$text, |
49
|
|
|
"Server could not find $requestedpath::$requestedtemplate"); |
50
|
|
|
|
51
|
|
|
debug("error: '$text'"); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
function ldCheckLogin($login, $password) { |
56
|
|
|
global $ARLogin, $ARPassword, $store, $AR; |
57
|
|
|
debug("soap::ldCheckLogin($login, [password])"); |
58
|
|
|
$criteria = array(); |
59
|
|
|
$criteria["object"]["implements"]["="]="puser"; |
60
|
|
|
$criteria["login"]["value"]["="]=$login; |
61
|
|
|
$result = $store->call( |
62
|
|
|
"system.authenticate.phtml", |
63
|
|
|
Array( |
64
|
|
|
"ARPassword" => $password |
65
|
|
|
), |
66
|
|
|
$store->find("/system/users/", $criteria) |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
if (!count($result)) { |
70
|
|
|
//echo "<script> alert('1'); </script>\n"; |
71
|
|
|
$user = current( |
72
|
|
|
$store->call( |
73
|
|
|
"system.authenticate.phtml", |
74
|
|
|
Array( |
75
|
|
|
"ARLogin" => $login, |
76
|
|
|
"ARPassword" => $password |
77
|
|
|
), |
78
|
|
|
$store->get("/system/users/extern/") |
79
|
|
|
)); |
80
|
|
|
} else { |
81
|
|
|
$user = current($result); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if ($user) { |
85
|
|
|
// if ($login !== "public") { |
86
|
|
|
// /* welcome to Ariadne :) */ |
87
|
|
|
// ldSetCredentials($login, $password); |
88
|
|
|
// } |
89
|
|
|
$ARLogin = $login; |
90
|
|
|
$ARPassword = 0; |
91
|
|
|
$AR->user = $user; |
92
|
|
|
$result = true; |
93
|
|
|
} else { |
94
|
|
|
debug("ldAuthUser: user('$user') could not authenticate", "all"); |
95
|
|
|
} |
96
|
|
|
return $result; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
function ldRegisterFile($field = "file", &$error) { |
|
|
|
|
101
|
|
|
global $ARnls, $store, $arguments; |
102
|
|
|
debug("ldRegisterFile([$field], [error])"); |
103
|
|
|
|
104
|
|
|
require_once($store->code."modules/mod_mimemagic.php"); |
105
|
|
|
|
106
|
|
|
$result = Array(); |
107
|
|
|
$file_data = $arguments[$field]; |
108
|
|
|
if ($file_data) { |
109
|
|
|
$file_data = base64_decode($file_data); |
110
|
|
|
if (!$file_data) { |
111
|
|
|
$error = "could not base64_decode file '$field'"; |
112
|
|
|
} else { |
113
|
|
|
$file_temp = tempnam($store->get_config("files")."temp", "upload"); |
114
|
|
|
$fp = fopen($file_temp, "wb+"); |
115
|
|
View Code Duplication |
if (!$fp) { |
116
|
|
|
$error = "could not write file '$field'"; |
117
|
|
|
} else { |
118
|
|
|
debug(" file_data (".$file_data.")"); |
119
|
|
|
fwrite($fp, $file_data, strlen($file_data)); |
120
|
|
|
fclose($fp); |
121
|
|
|
|
122
|
|
|
$file_type = get_mime_type($file_temp); |
123
|
|
|
|
124
|
|
|
$result[$field] = $field; |
125
|
|
|
$result[$field."_temp"] = substr($file_temp, strlen($store->get_config("files")."temp/")); |
126
|
|
|
$result[$field."_size"] = filesize($file_temp); |
127
|
|
|
$result[$field."_type"] = $file_type; |
128
|
|
|
debug(" http_post_vars (".serialize($result).")"); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
debug("ldRegisterFile[end] ($result)"); |
133
|
|
|
return $result; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
|
138
|
|
|
function ldObjectNotFound($requestedpath, $requestedtemplate) { |
|
|
|
|
139
|
|
|
global $SOAP_Fault; |
140
|
|
|
debug("soap::ldObjectNotFound($requestedpath, $requestedtemplate)", "loader"); |
141
|
|
|
$SOAP_Fault = new soap_fault( |
142
|
|
|
"Client.ObjectNotFound", |
143
|
|
|
"", |
144
|
|
|
"Server could not find $requestedpath::$requestedtemplate"); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
function ldAccessDenied($path, $message) { |
|
|
|
|
148
|
|
|
global $SOAP_Fault, $store; |
149
|
|
|
|
150
|
|
|
$SOAP_Fault = new soap_fault( |
151
|
|
|
"Client.AccessDenied", |
152
|
|
|
"", |
153
|
|
|
$message); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
View Code Duplication |
function ldSetRoot($session='', $nls='') { |
|
|
|
|
157
|
|
|
global $store, $AR, $ARCurrent, $root, $rootoptions; |
158
|
|
|
|
159
|
|
|
$root=$AR->root; |
160
|
|
|
$rootoptions=""; |
161
|
|
|
if ($session) { |
162
|
|
|
$rootoptions.="/-".$session."-"; |
163
|
|
|
$ARCurrent->session->id=$session; |
164
|
|
|
} |
165
|
|
|
if ($nls) { |
166
|
|
|
$rootoptions.="/$nls"; |
167
|
|
|
$ARCurrent->nls=$nls; |
168
|
|
|
} |
169
|
|
|
$root.=$rootoptions; |
170
|
|
|
if ($store) { // loader.php uses this function before the store is initialized. |
171
|
|
|
$store->root=$root; |
172
|
|
|
$store->rootoptions=$rootoptions; |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
function ldSetNls($nls) { |
|
|
|
|
177
|
|
|
global $ARCurrent; |
178
|
|
|
|
179
|
|
|
$session=$ARCurrent->session->id; |
180
|
|
|
ldSetRoot($session, $nls); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
function ldSetSession($session='') { |
|
|
|
|
184
|
|
|
global $ARCurrent, $ARLogin, $ARPassword; |
185
|
|
|
|
186
|
|
|
$nls=$ARCurrent->nls; |
187
|
|
|
ldSetRoot($session, $nls); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
View Code Duplication |
function ldStartSession($sessionid='') { |
|
|
|
|
191
|
|
|
global $ARCurrent, $AR, $ariadne; |
192
|
|
|
|
193
|
|
|
require($ariadne."/configs/sessions.phtml"); |
194
|
|
|
$ARCurrent->session=new session($session_config,$sessionid); |
|
|
|
|
195
|
|
|
ldSetSession($ARCurrent->session->id); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
function ldSetCache($file, $time, $image, $headers) { |
|
|
|
|
199
|
|
|
global $store; |
200
|
|
|
|
201
|
|
|
debug("ldSetCache($file, $time, [image], [headers])","object"); |
202
|
|
|
debug("ldSetCache::not implemented\n"); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
View Code Duplication |
function ldMkDir($dir) { |
|
|
|
|
206
|
|
|
global $store; |
207
|
|
|
|
208
|
|
|
debug("ldMkDir($dir)","object"); |
209
|
|
|
$dir=strtok($dir, "/"); |
210
|
|
|
$curr=$store->get_config("files"); |
211
|
|
|
while ($dir) { |
212
|
|
|
$curr.=$dir."/"; |
213
|
|
|
debug("ldMkDir: $curr","all"); |
214
|
|
|
@mkdir($curr, 0755); |
215
|
|
|
$dir=strtok("/"); |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
function ldGetCredentials() { |
|
|
|
|
220
|
|
|
return false; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
function ldSetCredentials($login, $password) { |
|
|
|
|
224
|
|
|
global $ARCurrent, $SOAP_SessionID; |
225
|
|
|
|
226
|
|
|
// Make sure the login is lower case. Because of the |
227
|
|
|
// numerous checks on "admin". |
228
|
|
|
$login = strtolower( $login ); |
229
|
|
|
|
230
|
|
|
debug("ldSetCredentials($login, [password])","object"); |
231
|
|
|
$ARCurrent->session->put("ARLogin", $login); |
232
|
|
|
$ARCurrent->session->put("ARPassword", $password, 1); |
233
|
|
|
$SOAP_SessionID = $ARCurrent->session->id. |
234
|
|
|
md5($ARCurrent->session->id. |
235
|
|
|
$login.$password); |
236
|
|
|
|
237
|
|
|
return $SOAP_SessionID; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
function ldCheckCredentials($login, $password) { |
|
|
|
|
241
|
|
|
global $ARCurrent, $SOAP_SessionID; |
242
|
|
|
debug("ldCheckCredentials()","object"); |
243
|
|
|
$result = false; |
244
|
|
|
if ($ARCurrent->session && $SOAP_SessionID) { |
245
|
|
|
$sessionid = $ARCurrent->session->id; |
246
|
|
|
$md5_hash = $sessionid.md5($sessionid. |
247
|
|
|
$ARCurrent->session->get("ARLogin"). |
248
|
|
|
$ARCurrent->session->get("ARPassword",1)); |
249
|
|
|
debug("soap:: checking ($md5_hash) against $SOAP_SessionID", "loader"); |
250
|
|
|
if ($md5_hash == $SOAP_SessionID) { |
251
|
|
|
$result = true; |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
return $result; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
function ldRedirect($uri) { |
|
|
|
|
258
|
|
|
return ldHeader("Location: $uri"); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
function ldHeader($header) { |
|
|
|
|
262
|
|
|
global $ARCurrent; |
263
|
|
|
|
264
|
|
|
$result=false; |
265
|
|
|
if (!Headers_sent()) { |
266
|
|
|
$result=true; |
267
|
|
|
Header($header); |
268
|
|
|
$ARCurrent->ldHeaders[strtolower($header)]=$header; |
269
|
|
|
} else { |
270
|
|
|
debug("Headers already sent, couldn't send $header","all"); |
271
|
|
|
} |
272
|
|
|
return $result; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
function ldSetClientCache($cache_on, $expires=0, $modified=0) { |
|
|
|
|
276
|
|
|
global $ARCurrent; |
277
|
|
|
$now=time(); |
|
|
|
|
278
|
|
|
$result = true; |
279
|
|
|
return $result; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
View Code Duplication |
function ldSetContent($mimetype, $size=0) { |
|
|
|
|
283
|
|
|
$result=ldHeader("Content-type: ".$mimetype); |
284
|
|
|
if ($size) { |
285
|
|
|
$result=ldHeader("Content-Length: ".$size); |
286
|
|
|
} |
287
|
|
|
return $result; |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
function ldGetServerVar($server_var) { |
|
|
|
|
291
|
|
|
return $_SERVER[$server_var]; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
function ldGetClientVar($client_var) { |
|
|
|
|
295
|
|
|
// dummy function |
296
|
|
|
return false; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
function ldDisablePostProcessing() { |
|
|
|
|
300
|
|
|
// dummy function |
301
|
|
|
return false; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
function ldGetRequestedHost() { |
|
|
|
|
305
|
|
|
// dummy function |
306
|
|
|
} |
307
|
|
|
|
This check looks for functions that have already been defined in other files.
Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the
@ignore
annotation.See also the PhpDoc documentation for @ignore.