瀏覽代碼

fixed confirm regex

master
Robin Thoni 10 年之前
父節點
當前提交
5d74a3cf05
共有 1 個檔案被更改,包括 4 行新增3 行删除
  1. 4
    3
      index.php

+ 4
- 3
index.php 查看文件

12
 
12
 
13
 function main()
13
 function main()
14
 {
14
 {
15
+  header("Content-Type: application/json");
16
+  check_api_key();
15
   $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
17
   $m_get = ($_SERVER['REQUEST_METHOD'] == "GET");
16
   $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
18
   $m_post = ($_SERVER['REQUEST_METHOD'] == "POST");
17
   $matches = array();
19
   $matches = array();
20
   if ($path === "")
22
   if ($path === "")
21
     $path = "/";
23
     $path = "/";
22
 
24
 
23
-  if (preg_match($path, "/^\/status\/([0-9]+)\/confirm$/", $matches) && $m_post)
25
+  if (preg_match('(^\/status\/([0-9]+)\/confirm$)', $path, $matches)
26
+    && $m_post)
24
     status_confirm($matches[1]);
27
     status_confirm($matches[1]);
25
   else if ($path === "/status" && $m_post)
28
   else if ($path === "/status" && $m_post)
26
     status_create();
29
     status_create();
33
   else
36
   else
34
     error(501, "Not implemented");
37
     error(501, "Not implemented");
35
 }
38
 }
36
-header("Content-Type: application/json");
37
-check_api_key();
38
 main();
39
 main();
39
 ?>
40
 ?>

Loading…
取消
儲存