The public function that does all the work.
214 {
216
217
218
219
220
221
222 $NULL_KEY = (string)'00000000-0000-0000-0000-000000000000';
223
224
225 $teleporter = [];
226
227 $allow_outsiders = FALSE;
228
229 $LOCAL_LOCATION = "GROUP";
230 $REGION_LOCATION = "REGION";
231 $WORLD_LOCATION = "WORLD";
232 $METAVERSE_LOCATION = "METAVERSE";
233
234 $GROUP_FLAG = 1;
235 $REGION_FLAG = 2;
236 $WORLD_FLAG = 4;
237 $METAVERSE_FLAG = 8;
238
239 $LOCATION_MASK = $GROUP_FLAG | $REGION_FLAG | $WORLD_FLAG | $METAVERSE_FLAG;
240
241 $ANONYMOUS_FLAG = 16;
242
243 $pdo; $pdo1;
244 $remote_world = "";
245 $teleport_allowed = FALSE;
246
247
248
249
250 $use_sim_db = TRUE;
251
252
253
254
255
256
257
258 $allow_outsiders = FALSE;
259
260
261
262
263
264 global $db; global $host; global $db_username; global $db_password;
265 global $db1; global $host1; global $db1_username; global $db1_password;
266 global $pdo; global $pdo1; global $remote_world; global
$readings;
267
268
269 $pdo = $this->
rdOpenDatabase($db, $host, $db_username, $db_password);
270
271
272
273 if ($use_sim_db) $pdo1 = $this->
rdOpenDatabase($db1, $host1, $db1_username, $db1_password);
274
275
276
277
278
279
281
282
283
284
285
286
288 {
289
290
291
292 if ($remote_world != "" && (!is_allowed || !$allow_outsiders))
293 {
294 die(
"FAILURE=BANNED|Teleporter Owner ".
$readings[
'owner'].
"@".
$readings[
'world'].
" is not authorised\n");
295 }
296
297
298
299
300
301
302 $position_string = substr(
$readings[
'position'], 1, -1);
303 $pos = explode(",", $position_string);
304 $position = array_slice($pos, 0, 3);
305
306
307 $rotation_string = substr(
$readings[
'rotation'], 1, -1);
308 $rot = explode(",", $rotation_string);
309 $rotation = array_slice($rot, 0, 4);
310
311
312
313
314
315
316 $sql_query = "select * from ls_os_teleport where teleport_key = :key";
317 try
318 {
319 $stmt = $pdo->prepare($sql_query);
320 $stmt->execute([
'key' =>
$readings[
'key']]);
321 $exists = $stmt->fetch(PDO::FETCH_ASSOC);
322 }
323 catch (Exception $e)
324 {
325 echo "FAILURE=IDENTIFY:".$e->getMessage()."\n";
326 }
327
328
329
330
331 if ($exists)
332 {
333
334 $data =
335 [
337 $position[0], $position[1], $position[2],
338 $rotation[0], $rotation[1], $rotation[2], $rotation[3],
342 ];
343
344
345 $sql_query = "update ls_os_teleport set ";
346 $sql_query .= "teleport_name = ?, teleport_owner_key = ?, teleport_world = ?, teleport_region = ?, ";
347 $sql_query .= "teleport_region_x = ?, teleport_region_y = ?, teleport_region_z = ?, ";
348 $sql_query .= "teleport_rotation_x = ?, teleport_rotation_y = ?, teleport_rotation_z = ?, teleport_rotation_s = ?, ";
349 $sql_query .= "teleport_offset = ?, teleport_group_key = ?, teleport_front_offset_angle = ?, ";
350 $sql_query .= "teleport_location_info = ?, teleport_version_number = ?, teleport_locality_group = ?, ";
351 $sql_query .= "teleport_heartbeat = CURRENT_TIMESTAMP()";
352 $sql_query .= "where teleport_key = ?";
353
354
355 try
356 {
357 $stmt = $pdo->prepare($sql_query);
358 $stmt->execute($data);
359 }
360 catch (Exception $e)
361 {
362 echo "FAILURE=UPDATE:".$e->getMessage()."\n";
363 }
364 }
365
366
367
368
369 else
370 {
371
372
373
374
375
376 $sql_query = "select * from ls_os_teleport where teleport_name = :name";
377 try
378 {
379 $stmt = $pdo->prepare($sql_query);
380 $stmt->execute([
'name' =>
$readings[
'name']]);
381 $same_name = $stmt->fetch(PDO::FETCH_ASSOC);
382 }
383 catch (Exception $e)
384 {
385 echo "FAILURE=NAME_MATCH: ".$readings['name'].":Failed with".$e->getMessage()."\n";
386 }
387 if ($same_name)
388 {
389 echo "FAILURE=NAME_MATCH: Existing teleporter data - ";
390 echo $row['teleport_world']."/".$row['teleport_region']."/";
391 echo "<".$row['teleport_region_x'].",".$row['teleport_region_y'].",".$row['teleport_region_z'].">\n";
392 }
393 else
394 {
395
396 $data =
397 [
399 $position[0], $position[1], $position[2],
400 $rotation[0], $rotation[1], $rotation[2], $rotation[3],
403 ];
404
405
406 $sql_query = "insert into ls_os_teleport(";
407 $sql_query .= "teleport_key, teleport_name, teleport_owner_key, teleport_world, teleport_region, ";
408 $sql_query .= "teleport_region_x, teleport_region_y, teleport_region_z, ";
409 $sql_query .= "teleport_rotation_x, teleport_rotation_y, teleport_rotation_z, teleport_rotation_s, ";
410 $sql_query .= "teleport_offset, teleport_group_key, teleport_front_offset_angle,";
411 $sql_query .= "teleport_location_info, teleport_version_number, teleport_locality_group";
412 $sql_query .= ")VALUES(";
413 $sql_query .= "?, ?, ?, ?, ?, ";
414 $sql_query .= "?, ?, ?, ";
415 $sql_query .= "?, ?, ?, ?, ";
416 $sql_query .= "?, ?, ?, ";
417 $sql_query .= "?, ?, ?";
418 $sql_query .= ")";
419
420
421 try
422 {
423 $stmt = $pdo->prepare($sql_query);
424 $stmt->execute($data);
425 }
426 catch (Exception $e)
427 {
428 echo "FAILURE=INSERT:".$e->getMessage()."\n";
429 }
430 }
431 }
432
433
434 echo "EXTRACT_LIST=START\n";
435
436
437 $this_group_flag =
$readings[
'locationinfo'] & $GROUP_FLAG;
438 $this_region_flag =
$readings[
'locationinfo'] & $REGION_FLAG;
439 $this_world_flag =
$readings[
'locationinfo'] & $WORLD_FLAG;
440 $this_metaverse_flag =
$readings[
'locationinfo'] & $METAVERSE_FLAG;
441
442 $sql_query = "";
443
444
445
446
447 $sql_query .= "select * from ls_os_teleport";
448 $sql_query .= " where teleport_key != :key";
449 $sql_query .= " and ((teleport_location_info & :group_flag = :this_group_flag and teleport_locality_group = :group) or teleport_location_info & :region_flag = :this_region_flag)";
450 $sql_query .= " and teleport_location_info & :anon_flag = 0";
451 $sql_query .= " and teleport_region = :region";
452 $sql_query .= " and teleport_world = :world";
453 $sql_query .= " and teleport_version_number != 0";
454
455 $sql_query .= " UNION ";
456
457
458 $sql_query .= "select * from ls_os_teleport ";
459 $sql_query .= " where teleport_key != :key";
460 $sql_query .= " and ((teleport_location_info & :world_flag = :this_world_flag and teleport_world = :world)";
461 $sql_query .= " and teleport_location_info & :anon_flag = 0";
462 $sql_query .= " or (teleport_location_info & :metaverse_flag = :this_metaverse_flag and teleport_world != :world))";
463 $sql_query .= " and teleport_version_number != 0";
464
465
466 $sql_query .= " order by teleport_name";
467
470 'group_flag' => $GROUP_FLAG,
471 'region_flag' => $REGION_FLAG,
472 'world_flag' => $WORLD_FLAG,
473 'metaverse_flag' => $METAVERSE_FLAG,
474 'anon_flag' => $ANONYMOUS_FLAG,
475 'this_group_flag' => $this_group_flag,
476 'this_region_flag' => $this_region_flag,
477 'this_world_flag' => $this_world_flag,
478 'this_metaverse_flag' => $this_metaverse_flag,
482 ];
483
485
486
487 sleep(1);
488 echo "EXTRACT_LIST=END\n";
489 }
490
491
493 {
494
495
496
497
498
499
500
501
502
504
505 $SqlQuery = "select * from ls_os_teleport";
506 $SqlQuery .= "where DATE_ADD(teleport_heartbeat, INTERVAL :lifetime HOUR) < CURRENT_TIMESTAMP()";
507 $SqlQuery .= " and teleport_version_number != 0 ";
508 if ($world != '###') $SqlQuery .= " and teleport_world = :world";
509 $SqlQuery .= " order by teleport_name;";
510
511 $Parameters = [
'lifetime' =>
$readings[
'lifetime'] ];
512 if ($world != '###') $Parameters['world'] = $world;
513
514 try
515 {
516 $stmt = $pdo->prepare($SqlQuery);
517 $stmt->execute($Parameters);
518 $results = $stmt->fetchAll(PDO::FETCH_DEFAULT);
519 }
520 catch (Exception $e)
521 {
522 echo "FAILURE=SCAN:".$e->getMessage()."\n";
523 }
524
525
526
527
528
529 echo "SCAN_LIST=START\n";
530 echo "//=========================== Date: ".date("Y-m-d H:i:s")."==================\n";
531
532 foreach ($results as $row)
533 {
534 $action_string = "SCANNED";
535 $teleport_name = $row['teleport_name'];
536 $teleport_version = $row['teleport_version_number'];
537
538
540 {
541 $sql_query1 = "delete from ls_os_teleport where teleport_key = :key";
542 $parameters1 = ['key' => $row['teleport_key'] ];
543 $stmt1 = $pdo->prepare($sql_query1);
544 $stmt1->execute($parameters1);
545 $results1 = $stmt1->fetchAll(PDO::FETCH_DEFAULT);
546 $action_string = "DELETED";
547 }
548 echo $row['teleport_name']."|".$action_string."|";
549 echo "hop://".$row['teleport_world']."/".$row['teleport_region']."/".$row['teleport_region_x']."/".$row['teleport_region_y']."/".$row['teleport_region_z']."\n";
550 }
551 echo "SCAN_LIST=END\n";
552 }
553 }
rdSelectDestinations($SqlQuery, $Parameters, $Pdo, $ThisWorld, $ThisRegion)
Print out the selected teleporters for the Destination Notecard.
rdConfirmUser($UseSimDb, $PDO, $PDO1)
Fucntion to confirm that the object's owner is authorise to run script.
rdOpenDatabase($Database, $Host, $Username, $Password)
Open the Support Database for Use.