#72 Implement fetching OppaiCoin price data without login

Open
Maav wants to merge 2 commits from Maav/Gazelle:master into master

+ 23
- 0
sections/store/index.php View File

@@ -1,4 +1,26 @@
1 1
 <?
2
+if (isset($_GET['api']) && $_GET['api'] == 1) {
3
+  $DB->query("
4
+    SELECT First, Second
5
+    FROM misc
6
+    WHERE Name='CoinBadge'");
7
+  if ($DB->has_results()) {
8
+    list($Purchases, $Price) = $DB->next_record();
9
+  } else {
10
+    $DB->query("
11
+      INSERT INTO misc
12
+             (Name,        First, Second)
13
+      VALUES ('CoinBadge', 0,     1000)");
14
+    list($Purchases, $Price) = [0, 1000];
15
+  }
16
+
17
+  $Response = array(
18
+    "purchases" => $Purchases,
19
+    "price" => $Price,
20
+  );
21
+  echo json_encode($Response);
22
+
23
+} else {
2 24
   enforce_login();
3 25
 
4 26
   if ($LoggedUser['DisablePoints']) {
@@ -75,4 +97,5 @@ if ($LoggedUser['DisablePoints']) {
75 97
       include(SERVER_ROOT.'/sections/store/store.php');
76 98
     }
77 99
   }
100
+}
78 101
 ?>

Loading…
Cancel
Save