Implement API endpoints as RequestHandlers
parent
6b96f8281c
commit
b68884f33c
|
@ -1 +0,0 @@
|
|||
Deny from all
|
110
api/economy.php
110
api/economy.php
|
@ -1,110 +0,0 @@
|
|||
<?php
|
||||
|
||||
# Copyright (c)Melanie Thielker and Teravus Ovares (http://opensimulator.org/)
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the OpenSim Project nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# updated for Robust installations: BlueWall 2011
|
||||
# further minor changes by justincc (http://justincc.org)
|
||||
|
||||
# Tables
|
||||
$presence = "Presence";
|
||||
|
||||
# XMLRPC
|
||||
$xmlrpc_server = xmlrpc_server_create();
|
||||
xmlrpc_server_register_method($xmlrpc_server, "preflightBuyLandPrep", "buy_land_prep");
|
||||
|
||||
function validate_user($agent_id, $s_session_id)
|
||||
{
|
||||
$stmt = $RUNTIME['PDO']->prepare("SELECT UserID FROM Presence WHERE UserID=? AND SecureSessionID = ?");
|
||||
$stmt->execute(array($agent_id, $s_session_id));
|
||||
|
||||
if($stmt->rowCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $stmt->fetch();
|
||||
return $res['UserID'];
|
||||
}
|
||||
|
||||
function buy_land_prep($method_name, $params, $app_data)
|
||||
{
|
||||
$confirmvalue = "";
|
||||
$req = $params[0];
|
||||
$agentid = $req['agentId'];
|
||||
$sessionid = $req['secureSessionId'];
|
||||
$amount = $req['currencyBuy'];
|
||||
$billableArea = $req['billableArea'];
|
||||
|
||||
$ID = validate_user($agentid, $sessionid);
|
||||
|
||||
if($ID)
|
||||
{
|
||||
$membership_levels = array(
|
||||
'levels' => array(
|
||||
'id' => "00000000-0000-0000-0000-000000000000",
|
||||
'description' => "some level"));
|
||||
|
||||
$landUse = array(
|
||||
'upgrade' => False,
|
||||
'action' => "".SYSURL."");
|
||||
|
||||
$currency = array(
|
||||
'estimatedCost' => "200.00"); // convert_to_real($amount));
|
||||
|
||||
$membership = array(
|
||||
'upgrade' => False,
|
||||
'action' => "".SYSURL."",
|
||||
'levels' => $membership_levels);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'currency' => $currency,
|
||||
'membership' => $membership,
|
||||
'landUse' => $landUse,
|
||||
'currency' => $currency,
|
||||
'confirm' => $confirmvalue));
|
||||
|
||||
header("Content-type: text/xml");
|
||||
print $response_xml;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Content-type: text/xml");
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => False,
|
||||
'errorMessage' => "\n\nUnable to Authenticate\n\nClick URL for more info.",
|
||||
'errorURI' => "".SYSURL.""));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
$request_xml = file_get_contents('php://input');
|
||||
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
|
||||
xmlrpc_server_destroy($xmlrpc_server);
|
||||
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
$membership_levels = array(
|
||||
'levels' => array(
|
||||
'id' => "00000000-0000-0000-0000-000000000000",
|
||||
'description' => "some level"));
|
||||
|
||||
$landUse = array(
|
||||
'upgrade' => False,
|
||||
'action' => "");
|
||||
|
||||
$currency = array(
|
||||
'estimatedCost' => "200.00"); // convert_to_real($amount));
|
||||
|
||||
$membership = array(
|
||||
'upgrade' => False,
|
||||
'action' => "",
|
||||
'levels' => $membership_levels);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => True,
|
||||
'currency' => $currency,
|
||||
'membership' => $membership,
|
||||
'landUse' => $landUse,
|
||||
'currency' => $currency,
|
||||
'confirm' => "200.00"));
|
||||
|
||||
header("Content-type: text/xml");
|
||||
print $response_xml;
|
||||
?>
|
|
@ -1,5 +0,0 @@
|
|||
1148b04d-7a93-19e9-b3c9-ea1cdeec38f7
|
||||
1148b04d-7a93-29e9-b3c9-ea1cdeec38f7
|
||||
1148b04d-7a93-39e9-b3c9-ea1cdeec38f7
|
||||
1148b04d-7a93-49e9-b3c9-ea1cdeec38f7
|
||||
1148b04d-7a93-59e9-b3c9-ea1cdeec38f7
|
|
@ -1,32 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="15">
|
||||
</head>
|
||||
<body style="background-image: url('./style/images/fabric-pattern.png')">
|
||||
<?php
|
||||
$statement = $RUNTIME['PDO']->prepare("SELECT UserID,RegionID FROM Presence WHERE RegionID != '00000000-0000-0000-0000-000000000000' ORDER BY RegionID ASC");
|
||||
$statement->execute();
|
||||
|
||||
if ($statement->rowCount() == 0) {
|
||||
echo "<h1>Es ist niemand online!</h1>";
|
||||
} else {
|
||||
echo '<table style="width:350px;margin-left:auto;margin-right:auto;margin-top:25px"><tr><th align="left" style="background-color: #FF8000;">Name</th><th align="left" style="background-color: #FF8000;">Region</th></tr>';
|
||||
$entryColor = true;
|
||||
include_once 'app/OpenSim.php';
|
||||
$opensim = new OpenSim();
|
||||
while ($row = $statement->fetch()) {
|
||||
if ($entryColor) {
|
||||
$entry = '<tr style="background-color: #F2F2F2;"><td>'.trim($opensim->getUserName($row['UserID'])).'</td><td>'.$opensim->getRegionName($row['RegionID']).'</td></tr>';
|
||||
} else {
|
||||
$entry = '<tr style="background-color: #E6E6E6;"><td>'.trim($opensim->getUserName($row['UserID'])).'</td><td>'.$opensim->getRegionName($row['RegionID']).'</td></tr>';
|
||||
}
|
||||
|
||||
echo $entry;
|
||||
$entryColor = !$entryColor;
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
include_once 'app/OpenSim.php';
|
||||
$opensim = new OpenSim();
|
||||
|
||||
$HTML = new HTML();
|
||||
$HTML->setHTMLTitle("Spalsh");
|
||||
$HTML->importHTML("viewerWelcomeImages.html");
|
||||
|
||||
$IMAGES = array();
|
||||
if ($handle = opendir('./data/viewerWelcomeImages')) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != "..") {
|
||||
$IMAGES = array_merge($IMAGES, array("./data/viewerWelcomeImages/".$entry));
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
shuffle($IMAGES);
|
||||
|
||||
$HTML->ReplaceLayoutInhalt("%%JSONIMAGEARRAY%%", json_encode($IMAGES));
|
||||
$HTML->ReplaceLayoutInhalt("%%GRIDNAME%%", $RUNTIME['GRID']['NAME']);
|
||||
$HTML->ReplaceLayoutInhalt("%%SHOWNEWS%%", $RUNTIME['GRID']['MAIN_NEWS']);
|
||||
|
||||
|
||||
$HTML->ReplaceLayoutInhalt("%%SHOWSTATS%%", "Registrierte User: ".$opensim->getUserCount()."<br>Regionen: ".$opensim->getRegionCount()."<br>Aktuell Online: ".($opensim->getOnlineCount()-1));
|
||||
|
||||
|
||||
$HTML->build();
|
||||
echo $HTML->ausgabe();
|
|
@ -0,0 +1,119 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mcp\Api;
|
||||
|
||||
class Economy extends \Mcp\RequestHandler
|
||||
{
|
||||
|
||||
private const SYSURL = ""; // ???
|
||||
|
||||
# Copyright (c)Melanie Thielker and Teravus Ovares (http://opensimulator.org/)
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the OpenSim Project nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# updated for Robust installations: BlueWall 2011
|
||||
# further minor changes by justincc (http://justincc.org)
|
||||
# Adapted to use PDO and the MCP API by a 4Creative contributor
|
||||
public function handleRequest(): void
|
||||
{
|
||||
# XMLRPC
|
||||
$xmlrpc_server = xmlrpc_server_create();
|
||||
xmlrpc_server_register_method($xmlrpc_server, "preflightBuyLandPrep", function($method_name, $params, $app_data) {
|
||||
$confirmvalue = "";
|
||||
$req = $params[0];
|
||||
$agentid = $req['agentId'];
|
||||
$sessionid = $req['secureSessionId'];
|
||||
$amount = $req['currencyBuy'];
|
||||
$billableArea = $req['billableArea'];
|
||||
|
||||
$id = $this->validateUser($agentid, $sessionid);
|
||||
|
||||
if ($id) {
|
||||
$membership_levels = array(
|
||||
'levels' => array(
|
||||
'id' => "00000000-0000-0000-0000-000000000000",
|
||||
'description' => "some level"
|
||||
)
|
||||
);
|
||||
|
||||
$landUse = array(
|
||||
'upgrade' => false,
|
||||
'action' => "" . $this::SYSURL . ""
|
||||
);
|
||||
|
||||
$currency = array(
|
||||
'estimatedCost' => "200.00"
|
||||
); // convert_to_real($amount));
|
||||
|
||||
$membership = array(
|
||||
'upgrade' => false,
|
||||
'action' => "" . $this::SYSURL . "",
|
||||
'levels' => $membership_levels
|
||||
);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => true,
|
||||
'currency' => $currency,
|
||||
'membership' => $membership,
|
||||
'landUse' => $landUse,
|
||||
'currency' => $currency,
|
||||
'confirm' => $confirmvalue
|
||||
));
|
||||
|
||||
header("Content-type: text/xml");
|
||||
print $response_xml;
|
||||
} else {
|
||||
header("Content-type: text/xml");
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => false,
|
||||
'errorMessage' => "\n\nUnable to Authenticate\n\nClick URL for more info.",
|
||||
'errorURI' => "" . $this::SYSURL . ""
|
||||
));
|
||||
|
||||
print $response_xml;
|
||||
}
|
||||
|
||||
return "";
|
||||
});
|
||||
|
||||
$request_xml = file_get_contents('php://input');
|
||||
xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
|
||||
xmlrpc_server_destroy($xmlrpc_server);
|
||||
}
|
||||
|
||||
private function validateUser($agent_id, $s_session_id)
|
||||
{
|
||||
$stmt = $this->app->db()->prepare("SELECT UserID FROM Presence WHERE UserID=? AND SecureSessionID = ?");
|
||||
$stmt->execute(array($agent_id, $s_session_id));
|
||||
|
||||
if ($stmt->rowCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $stmt->fetch();
|
||||
return $res['UserID'];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mcp\Api;
|
||||
|
||||
class EconomyLandTool extends \Mcp\RequestHandler
|
||||
{
|
||||
public function handleRequest(): void
|
||||
{
|
||||
$membership_levels = array(
|
||||
'levels' => array(
|
||||
'id' => "00000000-0000-0000-0000-000000000000",
|
||||
'description' => "some level"));
|
||||
|
||||
$landUse = array(
|
||||
'upgrade' => false,
|
||||
'action' => "");
|
||||
|
||||
$currency = array(
|
||||
'estimatedCost' => "200.00"); // convert_to_real($amount));
|
||||
|
||||
$membership = array(
|
||||
'upgrade' => false,
|
||||
'action' => "",
|
||||
'levels' => $membership_levels);
|
||||
|
||||
$response_xml = xmlrpc_encode(array(
|
||||
'success' => true,
|
||||
'currency' => $currency,
|
||||
'membership' => $membership,
|
||||
'landUse' => $landUse,
|
||||
'currency' => $currency,
|
||||
'confirm' => "200.00"));
|
||||
|
||||
header("Content-type: text/xml");
|
||||
print $response_xml;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mcp\Api;
|
||||
|
||||
class GetAccessList extends \Mcp\RequestHandler
|
||||
{
|
||||
public function handleRequest(): void
|
||||
{
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
echo "1148b04d-7a93-29e9-b3c9-ea1cdeec38f7\n";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mcp\Api;
|
||||
|
||||
use \Mcp\OpenSim;
|
||||
|
||||
class OnlineDisplay extends \Mcp\RequestHandler
|
||||
{
|
||||
|
||||
public function get(): void
|
||||
{
|
||||
$statement = $this->app->db()->prepare("SELECT UserID,RegionID FROM Presence WHERE RegionID != '00000000-0000-0000-0000-000000000000' ORDER BY RegionID ASC");
|
||||
$statement->execute();
|
||||
|
||||
$tpl = $this->app->template('online-display.php');
|
||||
if ($statement->rowCount() == 0) {
|
||||
$tpl->unsafeVar('online-users', '<h1 style="text-align: center; margin-top: 60px">Es ist niemand online!</h1>');
|
||||
} else {
|
||||
$table = '<table style="width:350px;margin-left:auto;margin-right:auto;margin-top:25px"><tr><th align="left" style="background-color: #FF8000;">Name</th><th align="left" style="background-color: #FF8000;">Region</th></tr>';
|
||||
$entryColor = true;
|
||||
$opensim = new OpenSim($this->app->db());
|
||||
while ($row = $statement->fetch()) {
|
||||
$table = $table.'<tr style="background-color: '.($entryColor ? '#F2F2F2' : '#E6E6E6').';"><td>'.trim($opensim->getUserName($row['UserID'])).'</td><td>'.$opensim->getRegionName($row['RegionID']).'</td></tr>';
|
||||
$entryColor = !$entryColor;
|
||||
}
|
||||
|
||||
$tpl->unsafeVar('online-users', $table.'</table>');
|
||||
}
|
||||
|
||||
$tpl->render();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mcp\Api;
|
||||
|
||||
use Mcp\OpenSim;
|
||||
|
||||
class ViewerWelcomePage extends \Mcp\RequestHandler
|
||||
{
|
||||
public function get(): void
|
||||
{
|
||||
$images = array();
|
||||
if ($handle = opendir('./data/viewerWelcomeImages')) {
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != "..") {
|
||||
$images[] = "./data/viewerWelcomeImages/".$entry;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
shuffle($images);
|
||||
|
||||
$opensim = new OpenSim($this->app->db());
|
||||
|
||||
$this->app->template('viewerWelcomeImages.php')->vars([
|
||||
'title' => 'Splash',
|
||||
'grid-name' => $this->app->config('grid')['name'],
|
||||
'news' => $this->app->config('grid')['main-news']
|
||||
])->unsafeVar('json-image-array', json_encode($images))
|
||||
->unsafeVar('stats', "Registrierte User: ".$opensim->getUserCount()."<br>Regionen: ".$opensim->getRegionCount()."<br>Aktuell Online: ".($opensim->getOnlineCount()-1))
|
||||
->render();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue