corrade-http-templates

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 6  →  ?path2? @ 7
/plotMapAvatars/config.php
@@ -0,0 +1,9 @@
<?php
 
# Set this to the name of the group.
$GROUP = 'My Group';
# Set this to the group password.
$PASSWORD = 'mypassword';
# Set this to Corrade's HTTP Server URL.
$URL = 'http://corrade.internal.site:8080';
 
/plotMapAvatars/functions.php
@@ -0,0 +1,88 @@
<?php
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function wasKeyValueGet($key, $data) {
return array_reduce(
explode(
"&",
$data
),
function($o, $p) {
$x = explode("=", $p);
return array_shift($x) != $o ? $o : array_shift($x);
},
$key
);
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
function wasCSVToArray($csv) {
$l = array();
$s = array();
$m = "";
for ($i = 0; $i < strlen($csv); ++$i) {
switch ($csv{$i}) {
case ',':
if (sizeof($s) == 0 || !current($s) == '"') {
array_push($l, $m);
$m = "";
break;
}
$m .= $csv{$i};
continue;
case '"':
if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) {
$m .= $csv{$i};
++$i;
break;
}
if (sizeof($s) == 0|| !current($s) == $csv[$i]) {
array_push($s, $csv{$i});
continue;
}
array_pop($s);
break;
default:
$m .= $csv{$i};
break;
}
}
array_push($l, $m);
return $l;
}
 
##########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) {
return $yMin + (
(
$yMax - $yMin
)
*
(
$value - $xMin
)
/
(
$xMax - $xMin
)
);
}
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function wasLSLVectorToArray($vector) {
$components = array();
if(!preg_match(
"/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/",
$vector,
$components
)) return;
array_shift($components);
return $components;
}
/plotMapAvatars/plotMapAvatars.html
@@ -12,16 +12,7 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'post',
url: "plotMapAvatars.php?t=" + Math.random(),
data: {
uuid: $("#uuid").val()
}
}).done(function(data) {
$('#texture').attr('src', "data:image/png;base64," + data);
});
setInterval(function () {
function requestAvatarPositions() {
$.ajax({
type: 'post',
url: "plotMapAvatars.php?t=" + Math.random(),
@@ -30,8 +21,10 @@
}
}).done(function(data) {
$('#texture').attr('src', "data:image/png;base64," + data);
setTimeout(requestAvatarPositions, 1000);
});
}, 1000);
}
setTimeout(requestAvatarPositions, 1000);
});
</script>
</head>
/plotMapAvatars/plotMapAvatars.php
@@ -14,104 +14,13 @@
## CONFIGURATION ##
###########################################################################
 
# Set this to the name of the group.
$GROUP = 'My Group';
# Set this to the group password.
$PASSWORD = 'mypassword';
# Set this to Corrade's HTTP Server URL.
$URL = 'http://corrade.internal.site:8080';
require_once('config.php');
require_once('functions.php');
 
###########################################################################
## INTERNALS ##
###########################################################################
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function wasKeyValueGet($key, $data) {
return array_reduce(
explode(
"&",
$data
),
function($o, $p) {
$x = explode("=", $p);
return array_shift($x) != $o ? $o : array_shift($x);
},
$key
);
}
///////////////////////////////////////////////////////////////////////////
// Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 //
///////////////////////////////////////////////////////////////////////////
function wasCSVToArray($csv) {
$l = array();
$s = array();
$m = "";
for ($i = 0; $i < strlen($csv); ++$i) {
switch ($csv{$i}) {
case ',':
if (sizeof($s) == 0 || !current($s) == '"') {
array_push($l, $m);
$m = "";
break;
}
$m .= $csv{$i};
continue;
case '"':
if ($i + 1 < strlen($csv) && $csv{$i} == $csv{$i + 1}) {
$m .= $csv{$i};
++$i;
break;
}
if (sizeof($s) == 0|| !current($s) == $csv[$i]) {
array_push($s, $csv{$i});
continue;
}
array_pop($s);
break;
default:
$m .= $csv{$i};
break;
}
}
array_push($l, $m);
return $l;
}
 
##########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function mapValueToRange($value, $xMin, $xMax, $yMin, $yMax) {
return $yMin + (
(
$yMax - $yMin
)
*
(
$value - $xMin
)
/
(
$xMax - $xMin
)
);
}
 
###########################################################################
## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
###########################################################################
function wasLSLVectorToArray($vector) {
$components = array();
if(!preg_match(
"/^<\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*,\s*([0-9\.]+?)\s*>$/",
$vector,
$components
)) return;
array_shift($components);
return $components;
}
 
####
# I. Get the UUID of the map image for the current region
$params = array(
@@ -135,6 +44,7 @@
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($curl, CURLOPT_ENCODING, true);
$return = curl_exec($curl);
curl_close($curl);
 
@@ -183,6 +93,7 @@
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($curl, CURLOPT_ENCODING, true);
$return = curl_exec($curl);
curl_close($curl);
 
@@ -231,6 +142,7 @@
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postvars);
curl_setopt($curl, CURLOPT_ENCODING, true);
$return = curl_exec($curl);
curl_close($curl);