@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | $file_name_for_db = uploadFile($max_file_size, $last_msg); |
10 | 10 | } |
11 | 11 | |
12 | - if($file_name_for_db != "not uploaded"){ |
|
12 | + if ($file_name_for_db != "not uploaded") { |
|
13 | 13 | $jsondata = messageToJSON($file_name_for_db, $messages, $last_msg); |
14 | 14 | file_put_contents($file, $jsondata); |
15 | 15 | } |
16 | 16 | |
17 | - if(!isset($_SESSION['response']) || (!$_SESSION['response'] && is_bool($_SESSION['response']))){ |
|
17 | + if (!isset($_SESSION['response']) || (!$_SESSION['response'] && is_bool($_SESSION['response']))) { |
|
18 | 18 | $_SESSION['response'] = true; |
19 | 19 | } |
20 | 20 | |
21 | - } else { |
|
21 | + }else { |
|
22 | 22 | $_SESSION['response'] = "The message field is <b>required</b>."; |
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
26 | - function greenText($msg){ |
|
26 | + function greenText($msg) { |
|
27 | 27 | preg_match_all('/(?<!>)>(?!>).*/', $msg, $matches, PREG_SET_ORDER, 0); |
28 | 28 | |
29 | 29 | foreach ($matches as $m) { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return $msg; |
46 | 46 | } |
47 | 47 | |
48 | - function uploadFile($max_file_size, $last_msg){ |
|
48 | + function uploadFile($max_file_size, $last_msg) { |
|
49 | 49 | $target_dir = "images/"; |
50 | 50 | $target_file_for_base_name = explode(".", $_FILES["file"]["name"]); //sorry, this is horrid, I know. |
51 | 51 | $target_file_for_base_name = $last_msg + 1 . "." . $target_file_for_base_name[1]; |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | $uploadOk = true; |
54 | 54 | $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); |
55 | 55 | $check = getimagesize($_FILES["file"]["tmp_name"]); |
56 | - if($imageFileType != "webm" && $imageFileType != "mp4"){ |
|
56 | + if ($imageFileType != "webm" && $imageFileType != "mp4") { |
|
57 | 57 | if ($check !== false) { |
58 | 58 | $uploadOk = true; |
59 | - } else { |
|
59 | + }else { |
|
60 | 60 | $_SESSION['response'] = "what are you doing anon? that file was not an image or a webm..."; |
61 | 61 | $uploadOk = false; |
62 | 62 | } |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); |
80 | 80 | } |
81 | 81 | |
82 | - if($uploadOk)return $target_file_for_base_name;else return 'not uploaded'; |
|
82 | + if ($uploadOk)return $target_file_for_base_name; else return 'not uploaded'; |
|
83 | 83 | } |
84 | 84 | |
85 | - function messageToJSON($file_name_for_db, $messages, $last_msg){ |
|
85 | + function messageToJSON($file_name_for_db, $messages, $last_msg) { |
|
86 | 86 | $new_message = array( |
87 | 87 | 'id' => $last_msg + 1, |
88 | 88 | 'message' => nl2br(greenText(postLink(str_replace(">", ">", str_replace("<", "<", $_POST['message'])))), false), |
@@ -79,7 +79,11 @@ |
||
79 | 79 | move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); |
80 | 80 | } |
81 | 81 | |
82 | - if($uploadOk)return $target_file_for_base_name;else return 'not uploaded'; |
|
82 | + if($uploadOk) { |
|
83 | + return $target_file_for_base_name; |
|
84 | + } else { |
|
85 | + return 'not uploaded'; |
|
86 | + } |
|
83 | 87 | } |
84 | 88 | |
85 | 89 | function messageToJSON($file_name_for_db, $messages, $last_msg){ |
@@ -44,7 +44,7 @@ |
||
44 | 44 | } |
45 | 45 | // post messages |
46 | 46 | require_once("functions/post_messages.php"); |
47 | - if($_SESSION['response'] && is_bool($_SESSION['response'])){ |
|
47 | + if ($_SESSION['response'] && is_bool($_SESSION['response'])) { |
|
48 | 48 | $_SESSION['response'] = false; |
49 | 49 | echo '<meta http-equiv="refresh" content="1">'; |
50 | 50 | }elseif (isset($_SESSION['response'])) { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | if (!$_SESSION['logged_in'] && $password != "") { |
30 | 30 | require_once("functions/login.php"); |
31 | - }else if ($_SESSION['logged_in'] || $password == "") { |
|
31 | + } else if ($_SESSION['logged_in'] || $password == "") { |
|
32 | 32 | // display messages |
33 | 33 | require_once("functions/display_messages.php"); |
34 | 34 | $messages = get_messages($file); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | if($_SESSION['response'] && is_bool($_SESSION['response'])){ |
48 | 48 | $_SESSION['response'] = false; |
49 | 49 | echo '<meta http-equiv="refresh" content="1">'; |
50 | - }elseif (isset($_SESSION['response'])) { |
|
50 | + } elseif (isset($_SESSION['response'])) { |
|
51 | 51 | echo $_SESSION['response']; |
52 | 52 | $_SESSION['response'] = false; |
53 | 53 | } |