Passed
Pull Request — master (#13)
by
unknown
02:13
created
functions/post_messages.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@  discard block
 block discarded – undo
9 9
         $file_name_for_db = uploadFile($max_file_size, $last_msg);
10 10
       }
11 11
 
12
-      if(is_null($file_name_for_db)){
12
+      if (is_null($file_name_for_db)) {
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('/(?<!&gt;)&gt;(?!&gt;).*/', $msg, $matches, PREG_SET_ORDER, 0);
28 28
 
29 29
     foreach ($matches as $m) {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     $ext = "";
58 58
     
59 59
     $file_mime = mime_content_type($_FILES["file"]);
60
-    switch($file_mime) {
60
+    switch ($file_mime) {
61 61
       case "video/webm":
62 62
         $ext = "webm";
63 63
         break;
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
     return $ext;
81 81
   }
82 82
 
83
-  function uploadFile($max_file_size, $last_msg){
83
+  function uploadFile($max_file_size, $last_msg) {
84 84
     $target_dir = "images/";
85 85
     $target_file_for_base_name = explode(".", $_FILES["file"]["name"]); //sorry, this is horrid, I know.
86 86
     $target_file_for_base_name = $last_msg + 1 . "." . $target_file_for_base_name[get_ext()];
87 87
     $target_file = $target_dir . basename($target_file_for_base_name);
88 88
 
89
-    if(is_file_okay($max_file_size)) {
89
+    if (is_file_okay($max_file_size)) {
90 90
       move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
91 91
       return $target_file_for_base_name;
92
-    } else {
92
+    }else {
93 93
       $_SESSION['response'] = "what are you doing anon? that file was not an image or a webm...";
94 94
       return null;
95 95
     }
96 96
   }
97 97
 
98
-  function messageToJSON($file_name_for_db, $messages, $last_msg){
98
+  function messageToJSON($file_name_for_db, $messages, $last_msg) {
99 99
     $new_message = array(
100 100
       'id' => $last_msg + 1,
101 101
       'message' => nl2br(greenText(postLink(str_replace(">", "&gt;", str_replace("<", "&lt;", $_POST['message'])))), false),
Please login to merge, or discard this patch.