#72 Implement fetching OppaiCoin price data without login

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

+ 26
- 3
sections/store/index.php View File

@@ -1,7 +1,29 @@
1 1
 <?
2
-enforce_login();
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 {
24
+  enforce_login();
3 25
 
4
-if ($LoggedUser['DisablePoints']) {
26
+  if ($LoggedUser['DisablePoints']) {
5 27
     View::show_header('Store'); ?>
6 28
     <div class='thin'>
7 29
       <h2 id='general'>Denied</h2>
@@ -10,7 +32,7 @@ if ($LoggedUser['DisablePoints']) {
10 32
       </div>
11 33
     </div>
12 34
     <? View::show_footer();
13
-} else {
35
+  } else {
14 36
     if (isset($_REQUEST['item'])) {
15 37
       switch ($_REQUEST['item']) {
16 38
         case 'upload_1GB':
@@ -74,5 +96,6 @@ if ($LoggedUser['DisablePoints']) {
74 96
     } else {
75 97
       include(SERVER_ROOT.'/sections/store/store.php');
76 98
     }
99
+  }
77 100
 }
78 101
 ?>

Loading…
Cancel
Save