Standalone Hypergrid Open Simulator BRIGADOON-0008
Configuration of Little-Sense OPen Simulator instance
Loading...
Searching...
No Matches
profile.php
Go to the documentation of this file.
2include '/usr/local/share/brigadoon/apache/os_passwords.php';
3
4mysql_connect ($dbHost,$dbUser,$dbPassword);
5mysql_select_db ($dbName);
6
7$zeroUUID = "00000000-0000-0000-0000-000000000000";
8$xmlrpc_server = xmlrpc_server_create();
9
10xmlrpc_server_register_method($xmlrpc_server, "avatarclassifiedsrequest",
11 "avatarclassifiedsrequest");
12
13function avatarclassifiedsrequest($method_name, $params, $app_data)
14{
15 $req = $params[0];
16
17 $uuid = $req['uuid'];
18
19
20 $result = mysql_query("SELECT * FROM profile_classifieds WHERE ".
21 "creatoruuid = '". mysql_escape_string($uuid) ."'");
22
23 $data = array();
24
25 while (($row = mysql_fetch_assoc($result)))
26 {
27 $data[] = array(
28 "classifiedid" => $row["classifieduuid"],
29 "name" => $row["name"]);
30 }
31
32 $response_xml = xmlrpc_encode(array(
33 'success' => True,
34 'data' => $data
35 ));
36
37 print $response_xml;
38}
39
40
41# Classifieds Update
42
43xmlrpc_server_register_method($xmlrpc_server, "classified_update",
44 "classified_update");
45
46function classified_update($method_name, $params, $app_data)
47{
48 global $zeroUUID;
49
50 $req = $params[0];
51
52 $classifieduuid = $req['classifiedUUID'];
53 $creator = $req['creatorUUID'];
54 $category = $req['category'];
55 $name = $req['name'];
56 $description = $req['description'];
57 $parceluuid = $req['parcelUUID'];
58 $parentestate = $req['parentestate'];
59 $snapshotuuid = $req['snapshotUUID'];
60 $simname = $req['sim_name'];
61 $globalpos = $req['globalpos'];
62 $parcelname = $req['parcelname'];
63 $classifiedflag = $req['classifiedFlags'];
64 $priceforlist = $req['classifiedPrice'];
65
66 // Check if we already have this one in the database
67 $check = mysql_query("SELECT COUNT(*) FROM profile_classifieds WHERE ".
68 "classifieduuid = '". mysql_escape_string($classifieduuid) ."'");
69
70 while ($row = mysql_fetch_row($check))
71 {
72 $ready = $row[0];
73 }
74
75 if ($ready == 0)
76 {
77 // Doing some late checking
78 // Should be done by the module but let's see what happens when
79 // I do it here
80
81 if($parcelname == "")
82 $parcelname = "Unknown";
83
84 if($parceluuid == "")
85 $parceluuid = $zeroUUID;
86
87 if($description == "")
88 $description = "No Description";
89
90 if($classifiedflag == 2)
91 {
92 $creationdate = time();
93 $expirationdate = time() + (7 * 24 * 60 * 60);
94 }
95 else
96 {
97 $creationdate = time();
98 $expirationdate = time() + (365 * 24 * 60 * 60);
99 }
100
101 $insertquery = "INSERT INTO profile_classifieds VALUES ".
102 "('". mysql_escape_string($classifieduuid) ."',".
103 "'". mysql_escape_string($creator) ."',".
104 "". mysql_escape_string($creationdate) .",".
105 "". mysql_escape_string($expirationdate) .",".
106 "'". mysql_escape_string($category) ."',".
107 "'". mysql_escape_string($name) ."',".
108 "'". mysql_escape_string($description) ."',".
109 "'". mysql_escape_string($parceluuid) ."',".
110 "". mysql_escape_string($parentestate) .",".
111 "'". mysql_escape_string($snapshotuuid) ."',".
112 "'". mysql_escape_string($simname) ."',".
113 "'". mysql_escape_string($globalpos) ."',".
114 "'". mysql_escape_string($parcelname) ."',".
115 "". mysql_escape_string($classifiedflag) .",".
116 "". mysql_escape_string($priceforlist) .")";
117
118 // Create a new record for this classified
119 $result = mysql_query($insertquery);
120 }
121 else
122 {
123
124 }
125
126 $response_xml = xmlrpc_encode(array(
127 'success' => True,
128 'data' => $data
129 ));
130
131 print $response_xml;
132}
133
134
135
136
137
138
139# Classifieds Delete
140
141xmlrpc_server_register_method($xmlrpc_server, "classified_delete",
142 "classified_delete");
143
144function classified_delete($method_name, $params, $app_data)
145{
146 $req = $params[0];
147
148 $classifieduuid = $req['classifiedID'];
149
150 $result = mysql_query("DELETE FROM profile_classifieds WHERE ".
151 "classifieduuid = '".mysql_escape_string($classifieduuid) ."'");
152
153 $response_xml = xmlrpc_encode(array(
154 'success' => True,
155 'data' => $data
156 ));
157
158 print $response_xml;
159}
160
161#
162# Picks
163#
164
165# Avatar Picks Request
166
167xmlrpc_server_register_method($xmlrpc_server, "avatarpicksrequest", "avatarpicksrequest");
168
169function avatarpicksrequest($method_name, $params, $app_data)
170{
171 $req = $params[0];
172 $uuid = $req['uuid'];
173 $data = array();
174 $result = mysql_query("SELECT `pickuuid`,`name` FROM profile_picks WHERE ". "creatoruuid = '". mysql_escape_string($uuid) ."'");
175
176 while (($row = mysql_fetch_assoc($result)))
177 {
178 $data[] = array(
179 "pickid" => $row["pickuuid"],
180 "name" => $row["name"]);
181 }
182
183 $response_xml = xmlrpc_encode(array(
184 'success' => True,
185 'data' => $data
186 ));
187
188 print $response_xml;
189}
190
191# Request Picks for User
192
193xmlrpc_server_register_method($xmlrpc_server, "pickinforequest",
194 "pickinforequest");
195
196function pickinforequest($method_name, $params, $app_data)
197{
198 $req = $params[0];
199
200 $uuid = $req['avatar_id'];
201 $pick = $req['pick_id'];
202
203 $data = array();
204
205
206
207
208 $result = mysql_query("SELECT * FROM profile_picks WHERE ".
209 "creatoruuid = '". mysql_escape_string($uuid) ."' AND ".
210 "pickuuid = '". mysql_escape_string($pick) ."'");
211
212 $row = mysql_fetch_assoc($result);
213 if ($row != False)
214 {
215 if ($row["description"] == null || $row["description"] == "")
216 $row["description"] = "No description given";
217
218 $data[] = array(
219 "pickuuid" => $row["pickuuid"],
220 "creatoruuid" => $row["creatoruuid"],
221 "toppick" => $row["toppick"],
222 "parceluuid" => $row["parceluuid"],
223 "name" => $row["name"],
224 "description" => $row["description"],
225 "snapshotuuid" => $row["snapshotuuid"],
226 "user" => $row["user"],
227 "originalname" => $row["originalname"],
228 "simname" => $row["simname"],
229 "posglobal" => $row["posglobal"],
230 "sortorder"=> $row["sortorder"],
231 "enabled" => $row["enabled"]);
232 }
233
234 $response_xml = xmlrpc_encode(array(
235 'success' => True,
236 'data' => $data
237 ));
238
239 print $response_xml;
240}
241
242# Picks Update
243
244xmlrpc_server_register_method($xmlrpc_server, "picks_update",
245 "picks_update");
246
247function picks_update($method_name, $params, $app_data)
248{
249 global $zeroUUID;
250
251 $req = $params[0];
252
253 $pickuuid = $req['pick_id'];
254 $creator = $req['creator_id'];
255 $toppick = $req['top_pick'];
256 $name = $req['name'];
257 $description = $req['desc'];
258 $parceluuid = $req['parcel_uuid'];
259 $snapshotuuid = $req['snapshot_id'];
260 $user = $req['user'];
261 $simname = $req['sim_name'];
262 $posglobal = $req['pos_global'];
263 $sortorder = $req['sort_order'];
264 $enabled = $req['enabled'];
265
266 if($parceluuid == "")
267 $parceluuid = $zeroUUID;
268
269 if($description == "")
270 $description = "No Description";
271
272 // Check if we already have this one in the database
273 $check = mysql_query("SELECT COUNT(*) FROM profile_picks WHERE ".
274 "pickuuid = '". mysql_escape_string($pickuuid) ."'");
275
276 $row = mysql_fetch_row($check);
277
278 if ($row[0] == 0)
279 {
280 if($user == null || $user == "")
281 $user = "Unknown";
282
283 //The original parcel name is the same as the name of the
284 //profile pick when a new profile pick is being created.
285 $original = $name;
286
287 $query = "INSERT INTO profile_picks VALUES ".
288 "('". mysql_escape_string($pickuuid) ."',".
289 "'". mysql_escape_string($creator) ."',".
290 "'". mysql_escape_string($toppick) ."',".
291 "'". mysql_escape_string($parceluuid) ."',".
292 "'". mysql_escape_string($name) ."',".
293 "'". mysql_escape_string($description) ."',".
294 "'". mysql_escape_string($snapshotuuid) ."',".
295 "'". mysql_escape_string($user) ."',".
296 "'". mysql_escape_string($original) ."',".
297 "'". mysql_escape_string($simname) ."',".
298 "'". mysql_escape_string($posglobal) ."',".
299 "'". mysql_escape_string($sortorder) ."',".
300 "'". mysql_escape_string($enabled) ."')";
301 }
302 else
303 {
304 $query = "UPDATE profile_picks SET " .
305 "parceluuid = '". mysql_escape_string($parceluuid) . "', " .
306 "name = '". mysql_escape_string($name) . "', " .
307 "description = '". mysql_escape_string($description) . "', " .
308 "snapshotuuid = '". mysql_escape_string($snapshotuuid) . "' WHERE ".
309 "pickuuid = '". mysql_escape_string($pickuuid) ."'";
310 }
311
312 $result = mysql_query($query);
313 if ($result != False)
314 $result = True;
315
316 $response_xml = xmlrpc_encode(array(
317 'success' => $result,
318 'errorMessage' => mysql_error()
319 ));
320
321 print $response_xml;
322}
323
324# Picks Delete
325
326xmlrpc_server_register_method($xmlrpc_server, "picks_delete",
327 "picks_delete");
328
329function picks_delete($method_name, $params, $app_data)
330{
331 $req = $params[0];
332
333 $pickuuid = $req['pick_id'];
334
335 $result = mysql_query("DELETE FROM profile_picks WHERE ".
336 "pickuuid = '".mysql_escape_string($pickuuid) ."'");
337
338 if ($result != False)
339 $result = True;
340
341 $response_xml = xmlrpc_encode(array(
342 'success' => $result,
343 'errorMessage' => mysql_error()
344 ));
345
346 print $response_xml;
347}
348
349#
350# Notes
351#
352
353# Avatar Notes Request
354
355
356xmlrpc_server_register_method($xmlrpc_server, "avatarnotesrequest",
357 "avatarnotesrequest");
358
359function avatarnotesrequest($method_name, $params, $app_data)
360{
361 $req = $params[0];
362
363 $uuid = $req['avatar_id'];
364 $targetuuid = $req['uuid'];
365
366 $result = mysql_query("SELECT notes FROM profile_notes WHERE ".
367 "useruuid = '". mysql_escape_string($uuid) ."' AND ".
368 "targetuuid = '". mysql_escape_string($targetuuid) ."'");
369
370 $row = mysql_fetch_row($result);
371 if ($row == False)
372 $notes = "";
373 else
374 $notes = $row[0];
375
376 $data[] = array(
377 "targetid" => $targetuuid,
378 "notes" => $notes);
379
380 $response_xml = xmlrpc_encode(array(
381 'success' => True,
382 'data' => $data
383 ));
384
385 print $response_xml;
386}
387
388# Avatar Notes Update
389
390xmlrpc_server_register_method($xmlrpc_server, "avatar_notes_update",
391 "avatar_notes_update");
392
393function avatar_notes_update($method_name, $params, $app_data)
394{
395 $req = $params[0];
396
397 $uuid = $req['avatar_id'];
398 $targetuuid = $req['target_id'];
399 $notes = $req['notes'];
400
401 // Check if we already have this one in the database
402
403 $check = mysql_query("SELECT COUNT(*) FROM profile_notes WHERE ".
404 "useruuid = '". mysql_escape_string($uuid) ."' AND ".
405 "targetuuid = '". mysql_escape_string($targetuuid) ."'");
406
407 $row = mysql_fetch_row($check);
408
409 if ($row[0] == 0)
410 {
411 // Create a new record for this avatar note
412 $result = mysql_query("INSERT INTO profile_notes VALUES ".
413 "('". mysql_escape_string($uuid) ."',".
414 "'". mysql_escape_string($targetuuid) ."',".
415 "'". mysql_escape_string($notes) ."')");
416 }
417 else if ($notes == "")
418 {
419 // Delete the record for this avatar note
420 $result = mysql_query("DELETE FROM profile_notes WHERE ".
421 "useruuid = '". mysql_escape_string($uuid) ."' AND ".
422 "targetuuid = '". mysql_escape_string($targetuuid) ."'");
423 }
424 else
425 {
426 // Update the existing record
427 $result = mysql_query("UPDATE profile_notes SET ".
428 "notes = '". mysql_escape_string($notes) ."' WHERE ".
429 "useruuid = '". mysql_escape_string($uuid) ."' AND ".
430 "targetuuid = '". mysql_escape_string($targetuuid) ."'");
431 }
432
433 $response_xml = xmlrpc_encode(array(
434 'success' => $result,
435 'errorMessage' => mysql_error()
436 ));
437
438 print $response_xml;
439}
440
441# Profile bits
442
443xmlrpc_server_register_method($xmlrpc_server, "avatar_properties_request",
444 "avatar_properties_request");
445
446function avatar_properties_request($method_name, $params, $app_data)
447{
448 global $zeroUUID;
449
450 $req = $params[0];
451
452 $uuid = $req['avatar_id'];
453
454 $result = mysql_query("SELECT * FROM profile WHERE ".
455 "useruuid = '". mysql_escape_string($uuid) ."'");
456 $row = mysql_fetch_assoc($result);
457
458 if ($row != False)
459 {
460 $data[] = array(
461 "ProfileUrl" => $row["profileURL"],
462 "Image" => $row["profileImage"],
463 "AboutText" => $row["profileAboutText"],
464 "FirstLifeImage" => $row["profileFirstImage"],
465 "FirstLifeAboutText" => $row["profileFirstText"],
466 "Partner" => $row["profilePartner"],
467
468 //Return interest data along with avatar properties
469 "wantmask" => $row["profileWantToMask"],
470 "wanttext" => $row["profileWantToText"],
471 "skillsmask" => $row["profileSkillsMask"],
472 "skillstext" => $row["profileSkillsText"],
473 "languages" => $row["profileLanguages"]);
474 }
475 else
476 {
477 //Insert empty record for avatar.
478 //FIXME: Should this only be done when asking for ones own profile?
479 $sql = "INSERT INTO profile VALUES ( ".
480 "'". mysql_escape_string($uuid) ."', ".
481 "'$zeroUUID', 0, 0, '', 0, '', 0, '', '', ".
482 "'$zeroUUID', '', '$zeroUUID', '')";
483 $result = mysql_query($sql);
484
485 $data[] = array(
486 "ProfileUrl" => "",
487 "Image" => $zeroUUID,
488 "AboutText" => "",
489 "FirstLifeImage" => $zeroUUID,
490 "FirstLifeAboutText" => "",
491 "Partner" => $zeroUUID,
492
493 "wantmask" => 0,
494 "wanttext" => "",
495 "skillsmask" => 0,
496 "skillstext" => "",
497 "languages" => "");
498 }
499
500 $response_xml = xmlrpc_encode(array(
501 'success' => True,
502 'data' => $data
503 ));
504
505 print $response_xml;
506}
507
508xmlrpc_server_register_method($xmlrpc_server, "avatar_properties_update",
509 "avatar_properties_update");
510
511function avatar_properties_update($method_name, $params, $app_data)
512{
513 $req = $params[0];
514
515 $uuid = $req['avatar_id'];
516 $profileURL = $req['ProfileUrl'];
517 $image = $req['Image'];
518 $abouttext = $req['AboutText'];
519 $firstlifeimage = $req['FirstLifeImage'];
520 $firstlifetext = $req['FirstLifeAboutText'];
521
522 $result=mysql_query("UPDATE profile SET ".
523 "profileURL='". mysql_escape_string($profileURL) ."', ".
524 "profileImage='". mysql_escape_string($image) ."', ".
525 "profileAboutText='". mysql_escape_string($abouttext) ."', ".
526 "profileFirstImage='". mysql_escape_string($firstlifeimage) ."', ".
527 "profileFirstText='". mysql_escape_string($firstlifetext) ."' ".
528 "WHERE useruuid='". mysql_escape_string($uuid) ."'"
529 );
530
531 $response_xml = xmlrpc_encode(array(
532 'success' => $result,
533 'errorMessage' => mysql_error()
534 ));
535
536 print $response_xml;
537}
538
539
540// Profile Interests
541
542xmlrpc_server_register_method($xmlrpc_server, "avatar_interests_update",
543 "avatar_interests_update");
544
545function avatar_interests_update($method_name, $params, $app_data)
546{
547 $req = $params[0];
548
549 $uuid = $req['avatar_id'];
550 $wanttext = $req['wanttext'];
551 $wantmask = $req['wantmask'];
552 $skillstext = $req['skillstext'];
553 $skillsmask = $req['skillsmask'];
554 $languages = $req['languages'];
555
556 $result = mysql_query("UPDATE profile SET ".
557 "profileWantToMask = ". mysql_escape_string($wantmask) .",".
558 "profileWantToText = '". mysql_escape_string($wanttext) ."',".
559 "profileSkillsMask = ". mysql_escape_string($skillsmask) .",".
560 "profileSkillsText = '". mysql_escape_string($skillstext) ."',".
561 "profileLanguages = '". mysql_escape_string($languages) ."' ".
562 "WHERE useruuid = '". mysql_escape_string($uuid) ."'"
563 );
564
565 $response_xml = xmlrpc_encode(array(
566 'success' => True
567 ));
568
569 print $response_xml;
570}
571
572// User Preferences
573
574xmlrpc_server_register_method($xmlrpc_server, "user_preferences_request",
575 "user_preferences_request");
576
577function user_preferences_request($method_name, $params, $app_data)
578{
579 $req = $params[0];
580
581 $uuid = $req['avatar_id'];
582
583 $result = mysql_query("SELECT imviaemail,visible,email FROM profile_settings WHERE ".
584 "useruuid = '". mysql_escape_string($uuid) ."'");
585
586 $row = mysql_fetch_assoc($result);
587
588 if ($row != False)
589 {
590 $data[] = array(
591 "imviaemail" => $row["imviaemail"],
592 "visible" => $row["visible"],
593 "email" => $row["email"]);
594 }
595 else
596 {
597 //Insert empty record for avatar.
598 //NOTE: The 'false' values here are enums defined in database
599 $sql = "INSERT INTO profile_settings VALUES ".
600 "('". mysql_escape_string($uuid) ."', ".
601 "'false', 'false', '')";
602 $result = mysql_query($sql);
603
604 $data[] = array(
605 "imviaemail" => False,
606 "visible" => False,
607 "email" => "");
608 }
609
610 $response_xml = xmlrpc_encode(array(
611 'success' => True,
612 'data' => $data
613 ));
614
615 print $response_xml;
616}
617
618xmlrpc_server_register_method($xmlrpc_server, "user_preferences_update",
619 "user_preferences_update");
620
621function user_preferences_update($method_name, $params, $app_data)
622{
623
624 $req = $params[0];
625
626 $uuid = $req['avatar_id'];
627 $wantim = $req['imViaEmail'];
628 $directory = $req['visible'];
629
630 $result = mysql_query("UPDATE profile_settings SET ".
631 "imviaemail = '".mysql_escape_string($wantim) ."', ".
632 "visible = '".mysql_escape_string($directory) ."' WHERE ".
633 "useruuid = '". mysql_escape_string($uuid) ."'");
634
635 $response_xml = xmlrpc_encode(array(
636 'success' => True,
637 'data' => $data
638 ));
639
640 print $response_xml;
641}
642
643#
644# Process the request
645#
646
647$request_xml = $HTTP_RAW_POST_DATA;
648xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
649xmlrpc_server_destroy($xmlrpc_server);
650?>
651
avatarpicksrequest($method_name, $params, $app_data)
Definition profile.php:169
avatar_properties_update($method_name, $params, $app_data)
Definition profile.php:511
avatar_interests_update($method_name, $params, $app_data)
Definition profile.php:545
pickinforequest($method_name, $params, $app_data)
Definition profile.php:196
picks_update($method_name, $params, $app_data)
Definition profile.php:247
avatarnotesrequest($method_name, $params, $app_data)
Definition profile.php:359
avatar_properties_request($method_name, $params, $app_data)
Definition profile.php:446
$xmlrpc_server
Definition profile.php:8
$request_xml
Definition profile.php:647
user_preferences_update($method_name, $params, $app_data)
Definition profile.php:621
classified_update($method_name, $params, $app_data)
Definition profile.php:46
$zeroUUID
Definition profile.php:7
picks_delete($method_name, $params, $app_data)
Definition profile.php:329
PHP
Definition profile.php:2
classified_delete($method_name, $params, $app_data)
Definition profile.php:144
user_preferences_request($method_name, $params, $app_data)
Definition profile.php:577
avatarclassifiedsrequest($method_name, $params, $app_data)
Definition profile.php:13
avatar_notes_update($method_name, $params, $app_data)
Definition profile.php:393