Browse Source

code factorize

master
Robin Thoni 9 years ago
parent
commit
b9e0adcc7e
1 changed files with 4 additions and 5 deletions
  1. 4
    5
      index.php

+ 4
- 5
index.php View File

@@ -9,11 +9,9 @@ function check_api_key_()
9 9
   $headers = apache_request_headers();
10 10
   if (!isset($headers["Api-Key"]))
11 11
     return false;
12
-  $q = database_exec("SELECT id FROM api_keys WHERE `key` = :key",
13
-                     array(":key" => $headers["Api-Key"]));
14
-  if ($q->fetch() !== false)
15
-    return true;
16
-  return false;
12
+  return database_exec("SELECT id FROM api_keys WHERE `key` = :key",
13
+                       array(":key" => $headers["Api-Key"]))-> fetch()
14
+                       !== false;
17 15
 }
18 16
 
19 17
 function check_api_key()
@@ -31,6 +29,7 @@ function main()
31 29
   $path = rtrim($_GET['_url'], "/");
32 30
   if ($path === "")
33 31
     $path = "/";
32
+
34 33
   if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
35 34
     status_confirm($matches[1]);
36 35
   else if ($path === "/status" && $m_post)

Loading…
Cancel
Save