#72 Implement fetching OppaiCoin price data without login

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

+ 94
- 71
sections/store/index.php View File

@@ -1,78 +1,101 @@
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);
3 22
 
4
-if ($LoggedUser['DisablePoints']) {
5
-  View::show_header('Store'); ?>
6
-  <div class='thin'>
7
-    <h2 id='general'>Denied</h2>
8
-    <div class='box pad' style='padding: 10px 10px 10px 20px;'>
9
-    <p>You are not allowed to spend <?=BONUS_POINTS?>.</p>
10
-    </div>
11
-  </div>
12
-  <? View::show_footer();
13 23
 } else {
14
-  if (isset($_REQUEST['item'])) {
15
-    switch ($_REQUEST['item']) {
16
-      case 'upload_1GB':
17
-        include(SERVER_ROOT.'/sections/store/upload_1GB.php');
18
-        break;
19
-      case 'upload_10GB':
20
-        include(SERVER_ROOT.'/sections/store/upload_10GB.php');
21
-        break;
22
-      case 'upload_100GB':
23
-        include(SERVER_ROOT.'/sections/store/upload_100GB.php');
24
-        break;
25
-      case 'upload_1000GB':
26
-        include(SERVER_ROOT.'/sections/store/upload_1000GB.php');
27
-        break;
28
-      case '1k_points':
29
-        include(SERVER_ROOT.'/sections/store/1k_points.php');
30
-        break;
31
-      case '10k_points':
32
-        include(SERVER_ROOT.'/sections/store/10k_points.php');
33
-        break;
34
-      case '100k_points':
35
-        include(SERVER_ROOT.'/sections/store/100k_points.php');
36
-        break;
37
-      case '1m_points':
38
-        include(SERVER_ROOT.'/sections/store/1m_points.php');
39
-        break;
40
-      case 'token':
41
-        include(SERVER_ROOT.'/sections/store/token.php');
42
-        break;
43
-      case 'freeleechize':
44
-        include(SERVER_ROOT.'/sections/store/freeleechize.php');
45
-        break;
46
-      case 'freeleechpool':
47
-        include(SERVER_ROOT.'/sections/store/freeleechpool.php');
48
-        break;
49
-      case 'invite':
50
-        include(SERVER_ROOT.'/sections/store/invite.php');
51
-        break;
52
-      case 'title':
53
-        include(SERVER_ROOT.'/sections/store/title.php');
54
-        break;
55
-      case 'promotion':
56
-        include(SERVER_ROOT.'/sections/store/promotion.php');
57
-        break;
58
-      case 'become_admin':
59
-        include(SERVER_ROOT.'/sections/store/become_admin.php');
60
-        break;
61
-      case 'badge':
62
-        include(SERVER_ROOT.'/sections/store/badge.php');
63
-        break;
64
-      case 'coinbadge':
65
-        include(SERVER_ROOT.'/sections/store/coinbadge.php');
66
-        break;
67
-      case 'capture_user':
68
-        include(SERVER_ROOT.'/sections/store/capture_user.php');
69
-        break;
70
-      default:
71
-        error(404);
72
-        break;
73
-    }
24
+  enforce_login();
25
+
26
+  if ($LoggedUser['DisablePoints']) {
27
+    View::show_header('Store'); ?>
28
+    <div class='thin'>
29
+      <h2 id='general'>Denied</h2>
30
+      <div class='box pad' style='padding: 10px 10px 10px 20px;'>
31
+      <p>You are not allowed to spend <?=BONUS_POINTS?>.</p>
32
+      </div>
33
+    </div>
34
+    <? View::show_footer();
74 35
   } else {
75
-    include(SERVER_ROOT.'/sections/store/store.php');
36
+    if (isset($_REQUEST['item'])) {
37
+      switch ($_REQUEST['item']) {
38
+        case 'upload_1GB':
39
+          include(SERVER_ROOT.'/sections/store/upload_1GB.php');
40
+          break;
41
+        case 'upload_10GB':
42
+          include(SERVER_ROOT.'/sections/store/upload_10GB.php');
43
+          break;
44
+        case 'upload_100GB':
45
+          include(SERVER_ROOT.'/sections/store/upload_100GB.php');
46
+          break;
47
+        case 'upload_1000GB':
48
+          include(SERVER_ROOT.'/sections/store/upload_1000GB.php');
49
+          break;
50
+        case '1k_points':
51
+          include(SERVER_ROOT.'/sections/store/1k_points.php');
52
+          break;
53
+        case '10k_points':
54
+          include(SERVER_ROOT.'/sections/store/10k_points.php');
55
+          break;
56
+        case '100k_points':
57
+          include(SERVER_ROOT.'/sections/store/100k_points.php');
58
+          break;
59
+        case '1m_points':
60
+          include(SERVER_ROOT.'/sections/store/1m_points.php');
61
+          break;
62
+        case 'token':
63
+          include(SERVER_ROOT.'/sections/store/token.php');
64
+          break;
65
+        case 'freeleechize':
66
+          include(SERVER_ROOT.'/sections/store/freeleechize.php');
67
+          break;
68
+        case 'freeleechpool':
69
+          include(SERVER_ROOT.'/sections/store/freeleechpool.php');
70
+          break;
71
+        case 'invite':
72
+          include(SERVER_ROOT.'/sections/store/invite.php');
73
+          break;
74
+        case 'title':
75
+          include(SERVER_ROOT.'/sections/store/title.php');
76
+          break;
77
+        case 'promotion':
78
+          include(SERVER_ROOT.'/sections/store/promotion.php');
79
+          break;
80
+        case 'become_admin':
81
+          include(SERVER_ROOT.'/sections/store/become_admin.php');
82
+          break;
83
+        case 'badge':
84
+          include(SERVER_ROOT.'/sections/store/badge.php');
85
+          break;
86
+        case 'coinbadge':
87
+          include(SERVER_ROOT.'/sections/store/coinbadge.php');
88
+          break;
89
+        case 'capture_user':
90
+          include(SERVER_ROOT.'/sections/store/capture_user.php');
91
+          break;
92
+        default:
93
+          error(404);
94
+          break;
95
+      }
96
+    } else {
97
+      include(SERVER_ROOT.'/sections/store/store.php');
98
+    }
76 99
   }
77 100
 }
78 101
 ?>

Loading…
Cancel
Save