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

Loading…
Cancel
Save