corrade-http-templates – Diff between revs 1 and 51
?pathlinks?
Rev 1 | Rev 51 | |||
---|---|---|---|---|
1 | <?php |
1 | <?php |
|
2 | |
2 | |
|
3 | ########################################################################### |
3 | ########################################################################### |
|
4 | ## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ## |
4 | ## Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 ## |
|
5 | ########################################################################### |
5 | ########################################################################### |
|
6 | ## A small script that will delete a conversation from the configured ## |
6 | ## A small script that will delete a conversation from the configured ## |
|
7 | ## conversation directory. ## |
7 | ## conversation directory. ## |
|
8 | ########################################################################### |
8 | ########################################################################### |
|
9 | |
9 | |
|
10 | ########################################################################### |
10 | ########################################################################### |
|
11 | ## CONFIGURATION ## |
11 | ## CONFIGURATION ## |
|
12 | ########################################################################### |
12 | ########################################################################### |
|
13 | |
13 | |
|
14 | require_once('config.php'); |
14 | require_once('config.php'); |
|
15 | require_once('functions.php'); |
15 | require_once('functions.php'); |
|
16 | |
16 | |
|
17 | ########################################################################### |
17 | ########################################################################### |
|
18 | ## INTERNALS ## |
18 | ## INTERNALS ## |
|
19 | ########################################################################### |
19 | ########################################################################### |
|
- | 20 | |
||
- | 21 | # CRSF. |
||
- | 22 | session_start(); |
||
- | 23 | if (empty($_POST['token']) || !hash_equals($_SESSION['token'], $_POST['token'])) { |
||
- | 24 | http_response_code(403); |
||
- | 25 | die('Forbidden.'); |
||
- | 26 | } |
||
- | 27 | |
||
20 | # Bail if "firstname" or "lastname" are blank. |
28 | # Bail if "firstname" or "lastname" are blank. |
|
21 | if(!isset($_POST['firstname']) || |
29 | if(!isset($_POST['firstname']) || |
|
22 | !isset($_POST['lastname'])) return; |
30 | !isset($_POST['lastname'])) return; |
|
23 | |
31 | |
|
24 | #### |
32 | #### |
|
25 | # I. Get the path to the configured chat directory. |
33 | # I. Get the path to the configured chat directory. |
|
26 | $chatPath = realpath($CHAT_DIRECTORY); |
34 | $chatPath = realpath($CHAT_DIRECTORY); |
|
27 | |
35 | |
|
28 | #### |
36 | #### |
|
29 | # II. Get the user path. |
37 | # II. Get the user path. |
|
30 | $userPath = join( |
38 | $userPath = join( |
|
31 | DIRECTORY_SEPARATOR, |
39 | DIRECTORY_SEPARATOR, |
|
32 | array( |
40 | array( |
|
33 | $CHAT_DIRECTORY, |
41 | $CHAT_DIRECTORY, |
|
34 | ucfirst( |
42 | ucfirst( |
|
35 | strtolower( |
43 | strtolower( |
|
36 | $_POST['firstname'] |
44 | $_POST['firstname'] |
|
37 | ) |
45 | ) |
|
38 | ) .' '. |
46 | ) .' '. |
|
39 | ucfirst( |
47 | ucfirst( |
|
40 | strtolower( |
48 | strtolower( |
|
41 | $_POST['lastname'] |
49 | $_POST['lastname'] |
|
42 | ) |
50 | ) |
|
43 | ).'.log' |
51 | ).'.log' |
|
44 | ) |
52 | ) |
|
45 | ); |
53 | ); |
|
46 | |
54 | |
|
47 | #### |
55 | #### |
|
48 | # III. Check that the file will be placed within the chat directory. |
56 | # III. Check that the file will be placed within the chat directory. |
|
49 | $pathPart = pathinfo($userPath); |
57 | $pathPart = pathinfo($userPath); |
|
50 | if(realpath($pathPart['dirname']) != $chatPath) |
58 | if(realpath($pathPart['dirname']) != $chatPath) |
|
51 | die; |
59 | die; |
|
52 | |
60 | |
|
53 | #### |
61 | #### |
|
54 | # IV. Remove the conversation. |
62 | # IV. Remove the conversation. |
|
55 | unlink($userPath); |
63 | unlink($userPath); |
|
56 | |
64 | |
|
57 | ?> |
65 | ?> |
|
58 | |
66 | |
|
59 |
|
67 |
|
|
60 | |
68 | |
|
61 | |
69 | |
|
62 | |
70 | |