@@ -1,10 +1,10 @@ |
||
| 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;"); |
@@ -16,14 +16,14 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -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), |
@@ -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'])) { |