From b68884f33c0fc4c498a01143e4b5edb597237d34 Mon Sep 17 00:00:00 2001 From: Anonymous Contributor Date: Tue, 5 Sep 2023 01:27:06 +0200 Subject: [PATCH] Implement API endpoints as RequestHandlers --- api/.htaccess | 1 - api/economy.php | 110 ------------------------------- api/economylandtool.php.php | 29 --------- api/getAccessList.php | 5 -- api/onlineDisplay.php | 32 --------- api/viewerWelcomeSite.php | 31 --------- app/api/Economy.php | 119 ++++++++++++++++++++++++++++++++++ app/api/EconomyLandTool.php | 38 +++++++++++ app/api/GetAccessList.php | 14 ++++ app/api/OnlineDisplay.php | 33 ++++++++++ app/api/ViewerWelcomePage.php | 35 ++++++++++ 11 files changed, 239 insertions(+), 208 deletions(-) delete mode 100644 api/.htaccess delete mode 100644 api/economy.php delete mode 100644 api/economylandtool.php.php delete mode 100644 api/getAccessList.php delete mode 100644 api/onlineDisplay.php delete mode 100644 api/viewerWelcomeSite.php create mode 100644 app/api/Economy.php create mode 100644 app/api/EconomyLandTool.php create mode 100644 app/api/GetAccessList.php create mode 100644 app/api/OnlineDisplay.php create mode 100644 app/api/ViewerWelcomePage.php diff --git a/api/.htaccess b/api/.htaccess deleted file mode 100644 index 14249c5..0000000 --- a/api/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all \ No newline at end of file diff --git a/api/economy.php b/api/economy.php deleted file mode 100644 index 1ae4f6a..0000000 --- a/api/economy.php +++ /dev/null @@ -1,110 +0,0 @@ -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); - -?> diff --git a/api/economylandtool.php.php b/api/economylandtool.php.php deleted file mode 100644 index 509ba0e..0000000 --- a/api/economylandtool.php.php +++ /dev/null @@ -1,29 +0,0 @@ - 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; -?> diff --git a/api/getAccessList.php b/api/getAccessList.php deleted file mode 100644 index 126712f..0000000 --- a/api/getAccessList.php +++ /dev/null @@ -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 \ No newline at end of file diff --git a/api/onlineDisplay.php b/api/onlineDisplay.php deleted file mode 100644 index c457356..0000000 --- a/api/onlineDisplay.php +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - prepare("SELECT UserID,RegionID FROM Presence WHERE RegionID != '00000000-0000-0000-0000-000000000000' ORDER BY RegionID ASC"); - $statement->execute(); - - if ($statement->rowCount() == 0) { - echo "

Es ist niemand online!

"; - } else { - echo ''; - $entryColor = true; - include_once 'app/OpenSim.php'; - $opensim = new OpenSim(); - while ($row = $statement->fetch()) { - if ($entryColor) { - $entry = ''; - } else { - $entry = ''; - } - - echo $entry; - $entryColor = !$entryColor; - } - - echo '
NameRegion
'.trim($opensim->getUserName($row['UserID'])).''.$opensim->getRegionName($row['RegionID']).'
'.trim($opensim->getUserName($row['UserID'])).''.$opensim->getRegionName($row['RegionID']).'
'; - } - ?> - - \ No newline at end of file diff --git a/api/viewerWelcomeSite.php b/api/viewerWelcomeSite.php deleted file mode 100644 index fbc5a09..0000000 --- a/api/viewerWelcomeSite.php +++ /dev/null @@ -1,31 +0,0 @@ -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()."
Regionen: ".$opensim->getRegionCount()."
Aktuell Online: ".($opensim->getOnlineCount()-1)); - - - $HTML->build(); - echo $HTML->ausgabe(); diff --git a/app/api/Economy.php b/app/api/Economy.php new file mode 100644 index 0000000..c656901 --- /dev/null +++ b/app/api/Economy.php @@ -0,0 +1,119 @@ +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']; + } +} diff --git a/app/api/EconomyLandTool.php b/app/api/EconomyLandTool.php new file mode 100644 index 0000000..62dafa2 --- /dev/null +++ b/app/api/EconomyLandTool.php @@ -0,0 +1,38 @@ + 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; + } +} diff --git a/app/api/GetAccessList.php b/app/api/GetAccessList.php new file mode 100644 index 0000000..8f4a84f --- /dev/null +++ b/app/api/GetAccessList.php @@ -0,0 +1,14 @@ +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', '

Es ist niemand online!

'); + } else { + $table = ''; + $entryColor = true; + $opensim = new OpenSim($this->app->db()); + while ($row = $statement->fetch()) { + $table = $table.''; + $entryColor = !$entryColor; + } + + $tpl->unsafeVar('online-users', $table.'
NameRegion
'.trim($opensim->getUserName($row['UserID'])).''.$opensim->getRegionName($row['RegionID']).'
'); + } + + $tpl->render(); + } +} diff --git a/app/api/ViewerWelcomePage.php b/app/api/ViewerWelcomePage.php new file mode 100644 index 0000000..49b9001 --- /dev/null +++ b/app/api/ViewerWelcomePage.php @@ -0,0 +1,35 @@ +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()."
Regionen: ".$opensim->getRegionCount()."
Aktuell Online: ".($opensim->getOnlineCount()-1)) + ->render(); + } +}