@@ -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]; |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); |
88 | 88 | } |
89 | 89 | |
90 | - if($uploadOk)return $target_file_for_base_name; else return 'not uploaded'; |
|
90 | + if ($uploadOk)return $target_file_for_base_name; else return 'not uploaded'; |
|
91 | 91 | } |
92 | 92 | |
93 | - function messageToJSON($file_name_for_db, $messages, $last_msg){ |
|
93 | + function messageToJSON($file_name_for_db, $messages, $last_msg) { |
|
94 | 94 | $new_message = array( |
95 | 95 | 'id' => $last_msg + 1, |
96 | 96 | 'message' => nl2br(greenText(postLink(str_replace(">", ">", str_replace("<", "<", $_POST['message'])))), false), |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | return $jsondata; |
104 | 104 | } |
105 | 105 | |
106 | - function get_mime(){ |
|
106 | + function get_mime() { |
|
107 | 107 | $mime = $_FILES["file"]["type"]; |
108 | 108 | $mime = explode("/", $mime)[1]; |
109 | 109 | return $mime; |
@@ -87,7 +87,11 @@ |
||
87 | 87 | move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); |
88 | 88 | } |
89 | 89 | |
90 | - if($uploadOk)return $target_file_for_base_name; else return 'not uploaded'; |
|
90 | + if($uploadOk) { |
|
91 | + return $target_file_for_base_name; |
|
92 | + } else { |
|
93 | + return 'not uploaded'; |
|
94 | + } |
|
91 | 95 | } |
92 | 96 | |
93 | 97 | function messageToJSON($file_name_for_db, $messages, $last_msg){ |