Browse Source

code factorize

master
Robin Thoni 10 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
   $headers = apache_request_headers();
9
   $headers = apache_request_headers();
10
   if (!isset($headers["Api-Key"]))
10
   if (!isset($headers["Api-Key"]))
11
     return false;
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
 function check_api_key()
17
 function check_api_key()
31
   $path = rtrim($_GET['_url'], "/");
29
   $path = rtrim($_GET['_url'], "/");
32
   if ($path === "")
30
   if ($path === "")
33
     $path = "/";
31
     $path = "/";
32
+
34
   if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
33
   if (preg_match($path, "^/status/([0-9]+)/confirm$", $matches) && $m_post)
35
     status_confirm($matches[1]);
34
     status_confirm($matches[1]);
36
   else if ($path === "/status" && $m_post)
35
   else if ($path === "/status" && $m_post)

Loading…
Cancel
Save