Browse Source

begin status confirm count

master
Robin Thoni 10 years ago
parent
commit
887bdb3079
1 changed files with 8 additions and 3 deletions
  1. 8
    3
      status.php

+ 8
- 3
status.php View File

9
   $date->add(new DateInterval("P1D"));
9
   $date->add(new DateInterval("P1D"));
10
   if ($token === false || $date < new DateTime())
10
   if ($token === false || $date < new DateTime())
11
     error(401, "Invalid token");
11
     error(401, "Invalid token");
12
-  return $token['token'];
12
+  return $token["token"];
13
 }
13
 }
14
 
14
 
15
 function status_confirm($id)
15
 function status_confirm($id)
16
 {
16
 {
17
-  check_token();
17
+  $token = check_token();
18
 }
18
 }
19
 
19
 
20
 function status_create()
20
 function status_create()
67
   if ($limit < 1)
67
   if ($limit < 1)
68
     $limit = 15;
68
     $limit = 15;
69
   $page = max((check_int(get_get("page", false), 1) - 1), 0) * $limit;
69
   $page = max((check_int(get_get("page", false), 1) - 1), 0) * $limit;
70
-  $s = database_query("SELECT * FROM status ORDER BY `id` DESC ".
70
+  $s = database_query("SELECT *, ".
71
+    "(SELECT COUNT(*) FROM confirms WHERE ".
72
+    "`status` = `status`.id and `confirmation` = 1) as 'up', ".
73
+    "(SELECT COUNT(*) FROM confirms WHERE ".
74
+    "`status` = `status`.id and `confirmation` = 0) as 'down' ".
75
+    "FROM status ORDER BY `id` DESC ".
71
     "LIMIT $page, $limit");
76
     "LIMIT $page, $limit");
72
   $data = array();
77
   $data = array();
73
   global $media_url;
78
   global $media_url;

Loading…
Cancel
Save