1 | <?php |
||||
2 | |||||
3 | require dirname(__DIR__, 2) . "/vendor/autoload.php"; |
||||
4 | |||||
5 | use CoffeeCode\Router\Router; |
||||
6 | |||||
7 | define("BASE", "https://www.localhost/coffeecode/router/exemple/controller"); |
||||
8 | $router = new Router(BASE); |
||||
9 | |||||
10 | /** |
||||
11 | * GET httpMethod |
||||
12 | */ |
||||
13 | $router->get("/", function ($data) { |
||||
14 | $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data; |
||||
15 | echo "<h1>GET :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>"; |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
16 | }); |
||||
17 | |||||
18 | /** |
||||
19 | * POST httpMethod |
||||
20 | */ |
||||
21 | $router->post("/", function ($data) { |
||||
22 | $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data; |
||||
23 | echo "<h1>POST :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>"; |
||||
0 ignored issues
–
show
Are you sure
print_r($data, true) of type string|true can be used in echo ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
24 | }); |
||||
25 | |||||
26 | /** |
||||
27 | * PUT spoofing and httpMethod |
||||
28 | */ |
||||
29 | $router->put("/", function ($data) { |
||||
30 | $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data; |
||||
31 | echo "<h1>PUT :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>"; |
||||
0 ignored issues
–
show
Are you sure
print_r($data, true) of type string|true can be used in echo ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
32 | }); |
||||
33 | |||||
34 | /** |
||||
35 | * PATCH spoofing and httpMethod |
||||
36 | */ |
||||
37 | $router->patch("/", function ($data) { |
||||
38 | $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data; |
||||
39 | echo "<h1>PATCH :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>"; |
||||
0 ignored issues
–
show
Are you sure
print_r($data, true) of type string|true can be used in echo ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | }); |
||||
41 | |||||
42 | /** |
||||
43 | * DELETE spoofing and httpMethod |
||||
44 | */ |
||||
45 | $router->delete("/", function ($data) { |
||||
46 | $data = ["realHttp" => $_SERVER["REQUEST_METHOD"]] + $data; |
||||
47 | echo "<h1>DELETE :: Spoofing</h1>", "<pre>", print_r($data, true), "</pre>"; |
||||
0 ignored issues
–
show
Are you sure
print_r($data, true) of type string|true can be used in echo ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
48 | }); |
||||
49 | |||||
50 | $router->dispatch(); |
||||
51 | ?> |
||||
52 | |||||
53 | <form action="" method="POST"> |
||||
54 | <select name="_method"> |
||||
55 | <option value="POST">POST</option> |
||||
56 | <option value="PUT">PUT</option> |
||||
57 | <option value="PATCH">PATCH</option> |
||||
58 | <option value="DELETE">DELETE</option> |
||||
59 | </select> |
||||
60 | |||||
61 | <input type="text" name="first_name" value="Robson"/> |
||||
62 | <input type="text" name="last_name" value="Leite"/> |
||||
63 | <input type="text" name="email" value="[email protected]"/> |
||||
64 | |||||
65 | <button>CoffeeCode</button> |
||||
66 | </form> |