Passed
Pull Request — master (#13)
by
unknown
02:13
created
functions/login.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2
-if($password != "" && isset($_POST['auth_submit'])){
3
-  if($password != $_POST['password']){
2
+if ($password != "" && isset($_POST['auth_submit'])) {
3
+  if ($password != $_POST['password']) {
4 4
     ?>
5 5
       <b>wrong password</b>, try again.
6 6
     <?php
7
-  } else{
7
+  }else {
8 8
     $_SESSION['logged_in'] = true;
9 9
     echo 'logged in!';
10 10
     header("refresh:0;");
Please login to merge, or discard this patch.
functions/display_messages.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
     return $result;
17 17
   }
18 18
 
19
-  function build_message($message){
19
+  function build_message($message) {
20 20
     $result = "";
21 21
     $result = $result . "<div class='message'>";
22 22
     $result = $result . "<div class='title' id='" . $message['id'] . "'><span class='name'>Anonymous</span> " . $message['date'] . " id. <a href='#" . $message['id'] . "'>" . $message['id'] . "</a></div><div class = 'message-inside'>";
23 23
     if ($message['file'] != "") {
24
-      if(substr($message['file'], -4) == "webm" || substr($message['file'], -3) == "mp4"){
24
+      if (substr($message['file'], -4) == "webm" || substr($message['file'], -3) == "mp4") {
25 25
         $result = $result . '<div><video width="600" controls loop><source src="images/' . $message['file'] . '" type="video/mp4"></video></div><br />';
26
-      }else{
26
+      }else {
27 27
         $result = $result . "<div><a href='images/" . $message['file'] . "'><img src = 'images/" . $message['file'] . "' class='message-image'/></a></div>";
28 28
       }
29 29
     }
@@ -31,21 +31,21 @@  discard block
 block discarded – undo
31 31
     return $result;
32 32
   }
33 33
 
34
-  function check_empty($msgs){
34
+  function check_empty($msgs) {
35 35
     if (isset($msgs) && $msgs != "") {
36 36
       $msg = $msgs;
37
-    } else {
37
+    }else {
38 38
       $msg = "something's wrong, this nerve is either empty or our brain doesn't have access to this nerve's messages...";
39 39
     }
40 40
     return $msg;
41 41
   }
42 42
 
43
-  function build_result($msg, $last_msg, $action){
43
+  function build_result($msg, $last_msg, $action) {
44 44
     if ($action == "messages") {
45 45
       $result = $msg;
46
-    } else if ($action == "last_msg") {
46
+    }else if ($action == "last_msg") {
47 47
       $result = $last_msg;
48
-    } else {
48
+    }else {
49 49
       $result = "show_messages: parameters <b>must</b> be \$messages and either 'messages' or 'last_msg'";
50 50
     }
51 51
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
     if ($message['file'] != "") {
24 24
       if(substr($message['file'], -4) == "webm" || substr($message['file'], -3) == "mp4"){
25 25
         $result = $result . '<div><video width="600" controls loop><source src="images/' . $message['file'] . '" type="video/mp4"></video></div><br />';
26
-      }else{
26
+      } else{
27 27
         $result = $result . "<div><a href='images/" . $message['file'] . "'><img src = 'images/" . $message['file'] . "' class='message-image'/></a></div>";
28 28
       }
29 29
     }
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
     }
45 45
     // post messages
46 46
     require_once("functions/post_messages.php");
47
-    if(isset($_SESSION['response']) && $_SESSION['response'] && is_bool($_SESSION['response'])){
47
+    if (isset($_SESSION['response']) && $_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'])) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
47 47
     if(isset($_SESSION['response']) && $_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
     }
Please login to merge, or discard this patch.
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.