Passed
Pull Request — master (#20)
by
unknown
01:53
created
register.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,32 +18,32 @@  discard block
 block discarded – undo
18 18
          ?>
19 19
         <center><h1 style="display: inline-block;">4Grounds - Register</h1><br>
20 20
             <?php
21
-                if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) 
21
+                if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) 
22 22
                 {
23 23
                     $email = htmlspecialchars(@$_POST['email']);
24 24
                     $username = htmlspecialchars(@$_POST['username']);
25 25
                     $password = @$_POST['password'];
26 26
                     $passwordhash = password_hash(@$password, PASSWORD_DEFAULT);
27 27
                     
28
-                    if($_POST['password'] !== $_POST['confirm']){ $error = "password and confirmation password do not match"; goto skip; }
28
+                    if ($_POST['password'] !== $_POST['confirm']) { $error = "password and confirmation password do not match"; goto skip; }
29 29
 
30
-                    if(strlen($username) > 21) { $error = "your username must be shorter than 21 characters"; goto skip; }
31
-                    if(strlen($password) < 8) { $error = "your password must be at least 8 characters long"; goto skip; }
32
-                    if(!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $password)) { $error = "please include both letters and numbers in your password"; goto skip; }
33
-                    if(!isset($_POST['g-recaptcha-response'])){ $error = "captcha validation failed"; goto skip; }
34
-                    if($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; }
30
+                    if (strlen($username) > 21) { $error = "your username must be shorter than 21 characters"; goto skip; }
31
+                    if (strlen($password) < 8) { $error = "your password must be at least 8 characters long"; goto skip; }
32
+                    if (!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $password)) { $error = "please include both letters and numbers in your password"; goto skip; }
33
+                    if (!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; }
34
+                    if ($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; }
35 35
     
36 36
                     $stmt = $conn->prepare("SELECT username FROM users WHERE username = ?");
37 37
                     $stmt->bind_param("s", $username);
38 38
                     $stmt->execute();
39 39
                     $result = $stmt->get_result();
40
-                    if($result->num_rows) { $error = "there's already a user with that same name!"; goto skip; }
40
+                    if ($result->num_rows) { $error = "there's already a user with that same name!"; goto skip; }
41 41
 
42 42
                     $stmt = $conn->prepare("SELECT email FROM users WHERE email = ?");
43 43
                     $stmt->bind_param("s", $email);
44 44
                     $stmt->execute();
45 45
                     $result = $stmt->get_result();
46
-                    if($result->num_rows) { $error = "there's already a user with that same email!"; goto skip; }
46
+                    if ($result->num_rows) { $error = "there's already a user with that same email!"; goto skip; }
47 47
                             
48 48
                     //TODO: add cloudflare ip thing 
49 49
                     $stmt = $conn->prepare("INSERT INTO `users` (`username`, `email`, `password`) VALUES (?, ?, ?)");
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                 }
64 64
                 skip:
65 65
             
66
-            if(isset($error)) { echo "<small style='color:red'>".$error."</small>"; } ?>
66
+            if (isset($error)) { echo "<small style='color:red'>" . $error . "</small>"; } ?>
67 67
             <form method="post">
68 68
                 <input required placeholder="Username" type="text" name="username"><br>
69 69
                 <input required placeholder="E-Mail" type="email" name="email"><br><br>
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     <body> 
15 15
         <?php 
16 16
             require(__DIR__ . "/important/header.php"); 
17
-         ?>
17
+            ?>
18 18
         <center><h1 style="display: inline-block;">4Grounds - Register</h1><br>
19 19
             <?php
20 20
                 if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) 
Please login to merge, or discard this patch.
view/groups.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
                 $stmt = $conn->prepare("SELECT * FROM `groups` ORDER BY id DESC");
19 19
                 $stmt->execute();
20 20
                 $result = $stmt->get_result();
21
-                if($result->num_rows === 0) echo('There are no users.');
22
-                while($row = $result->fetch_assoc()) {
21
+                if ($result->num_rows === 0) echo('There are no users.');
22
+                while ($row = $result->fetch_assoc()) {
23 23
                     echo "<img style='position: absolute;border: 1px solid white; width: 5em;' src='/pfp/" . getPFP($row['author'], $conn) . "'>
24 24
                     <small>
25 25
                     <a href='/view/group?id=" . $row['id'] . "'><span style='float:right;color: gold;'><i>" . $row['title'] . "</a></i></span><br>
Please login to merge, or discard this patch.
view/index.php 3 patches
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
                 $stmt->bind_param("i", $_GET['id']);
13 13
                 $stmt->execute();
14 14
                 $result = $stmt->get_result();
15
-                if($result->num_rows === 0) echo('There are no users.');
15
+                if($result->num_rows === 0) {
16
+                    echo('There are no users.');
17
+                }
16 18
                 while($row = $result->fetch_assoc()) {
17 19
                     $author = $row['author'];
18 20
                     $id = $row['id'];
@@ -215,12 +217,13 @@  discard block
 block discarded – undo
215 217
             <form method="post" enctype="multipart/form-data" id="submitform">
216 218
                 <textarea required cols="77" placeholder="Comment" name="comment"></textarea><br>
217 219
                 <input type="submit" value="Post" <?php 
218
-                  if ($config['use_recaptcha']) 
219
-                    echo 'class="g-recaptcha" data-sitekey="' . $config['recaptcha_sitekey'] . '" data-callback="onSubmit"'
220
+                  if ($config['use_recaptcha']) {
221
+                                      echo 'class="g-recaptcha" data-sitekey="' . $config['recaptcha_sitekey'] . '" data-callback="onSubmit"'
220 222
                 ?>> <small>max limit: 500 characters | supports <a href="https://www.markdownguide.org/basic-syntax">Markdown</a></small>
221 223
             </form>
222 224
             <?php
223 225
                 $stmt = $conn->prepare("SELECT * FROM `gamecomments` WHERE toid = ? ORDER BY id DESC");
226
+                  }
224 227
                 $stmt->bind_param("s", $_GET['id']);
225 228
                 $stmt->execute();
226 229
                 $result = $stmt->get_result();
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 va                <source src="/dynamic/song/' . $filename . '">
70 70
                 </audio>';
71 71
             } else if($type == "image") {
72
-              echo "<img style='max-width: 100%;' src='/dynamic/image/" . $filename . "'>";
72
+                echo "<img style='max-width: 100%;' src='/dynamic/image/" . $filename . "'>";
73 73
             } else if($type == "midi") {
74 74
                 echo "Note: It may take a few seconds for the MIDI to load.<br>";
75 75
                 echo "<a href='#' onClick=\"MIDIjs.play('/dynamic/midi/" . $filename . "');\">Play " . $title . "</a>";
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
             <script type="text/javascript" src="//cdn.jsdelivr.net/gh/deskjet/chiptune2.js@master/chiptune2.js"></script>';
203 203
             echo '<a class="song" data-modurl="/dynamic/chiptune/' . $filename . '" href="#">Play ' . $title . '</a>';
204 204
             } else if($type == "news" || $type == "review") {
205
-              //do nothing
205
+                //do nothing
206 206
             } else if($type == "video") {
207
-              echo ' <video width="640" height="400" controls>
207
+                echo ' <video width="640" height="400" controls>
208 208
                   <source src="/dynamic/video/' . $filename . '" type="video/mp4">
209 209
                 </video> ';
210 210
             } else {
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
             <form method="post" enctype="multipart/form-data" id="submitform">
216 216
                 <textarea required cols="77" placeholder="Comment" name="comment"></textarea><br>
217 217
                 <input type="submit" value="Post" <?php 
218
-                  if ($config['use_recaptcha']) 
218
+                    if ($config['use_recaptcha']) 
219 219
                     echo 'class="g-recaptcha" data-sitekey="' . $config['recaptcha_sitekey'] . '" data-callback="onSubmit"'
220 220
                 ?>> <small>max limit: 500 characters | supports <a href="https://www.markdownguide.org/basic-syntax">Markdown</a></small>
221 221
             </form>
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
             require(__DIR__ . "/../func/func.php");
8 8
             require(__DIR__ . "/../func/conn.php"); 
9 9
 
10
-            if(isset($_GET['id'])) {
10
+            if (isset($_GET['id'])) {
11 11
                 $stmt = $conn->prepare("SELECT * FROM files WHERE id = ?");
12 12
                 $stmt->bind_param("i", $_GET['id']);
13 13
                 $stmt->execute();
14 14
                 $result = $stmt->get_result();
15
-                if($result->num_rows === 0) echo('There are no users.');
16
-                while($row = $result->fetch_assoc()) {
15
+                if ($result->num_rows === 0) echo('There are no users.');
16
+                while ($row = $result->fetch_assoc()) {
17 17
                     $author = $row['author'];
18 18
                     $id = $row['id'];
19 19
                     $date = $row['date'];
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
                     $status = $row['status'];
24 24
                     $filename = $row['filename'];
25 25
 
26
-                    if($status != "y") {
26
+                    if ($status != "y") {
27 27
                         die("Item is not approved yet.");
28 28
                     }
29 29
                 }
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
         
38 38
         <div class="container">
39 39
             <?php
40
-                if($_SERVER['REQUEST_METHOD'] == 'POST') 
40
+                if ($_SERVER['REQUEST_METHOD'] == 'POST') 
41 41
                 {
42
-                    if(!isset($_SESSION['user'])){ $error = "you are not logged in"; goto skipcomment; }
43
-                    if(!$_POST['comment']){ $error = "your comment cannot be blank"; goto skipcomment; }
44
-                    if(strlen($_POST['comment']) > 500){ $error = "your comment must be shorter than 500 characters"; goto skipcomment; }
45
-                    if(!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; }
46
-                    if($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; }
42
+                    if (!isset($_SESSION['user'])) { $error = "you are not logged in"; goto skipcomment; }
43
+                    if (!$_POST['comment']) { $error = "your comment cannot be blank"; goto skipcomment; }
44
+                    if (strlen($_POST['comment']) > 500) { $error = "your comment must be shorter than 500 characters"; goto skipcomment; }
45
+                    if (!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; }
46
+                    if ($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; }
47 47
 
48 48
                     $stmt = $conn->prepare("INSERT INTO `gamecomments` (toid, author, text, date) VALUES (?, ?, ?, now())");
49 49
                     $stmt->bind_param("sss", $_GET['id'], $_SESSION['user'], $text);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                     $stmt->close();
53 53
                 }
54 54
                 skipcomment:
55
-                if(isset($error)) {
55
+                if (isset($error)) {
56 56
                     echo "<span style='color: red;'><small>" . $error . "</small></span><br>";
57 57
                 }
58 58
 
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
                 <br><br>" . $extrainfo . "</small><hr>";
65 65
             ?>
66 66
             <?php 
67
-            if($type == "song") {
67
+            if ($type == "song") {
68 68
                 echo '<audio controls>
69 69
 va                <source src="/dynamic/song/' . $filename . '">
70 70
                 </audio>';
71
-            } else if($type == "image") {
71
+            } else if ($type == "image") {
72 72
               echo "<img style='max-width: 100%;' src='/dynamic/image/" . $filename . "'>";
73
-            } else if($type == "midi") {
73
+            } else if ($type == "midi") {
74 74
                 echo "Note: It may take a few seconds for the MIDI to load.<br>";
75 75
                 echo "<a href='#' onClick=\"MIDIjs.play('/dynamic/midi/" . $filename . "');\">Play " . $title . "</a>";
76 76
                 echo "<br><a href='#' onClick='MIDIjs.stop();'>Stop MIDI Playback</a>";
77
-            } else if($type == "chiptune") {
77
+            } else if ($type == "chiptune") {
78 78
                 //the way i did this absolutely sucks and im
79 79
                 echo '<script type="text/javascript">
80 80
                 window["libopenmpt"] = {};
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
             <script type="text/javascript" src="//cdn.jsdelivr.net/gh/deskjet/chiptune2.js@master/libopenmpt.js"></script>
202 202
             <script type="text/javascript" src="//cdn.jsdelivr.net/gh/deskjet/chiptune2.js@master/chiptune2.js"></script>';
203 203
             echo '<a class="song" data-modurl="/dynamic/chiptune/' . $filename . '" href="#">Play ' . $title . '</a>';
204
-            } else if($type == "news" || $type == "review") {
204
+            } else if ($type == "news" || $type == "review") {
205 205
               //do nothing
206
-            } else if($type == "video") {
206
+            } else if ($type == "video") {
207 207
               echo ' <video width="640" height="400" controls>
208 208
                   <source src="/dynamic/video/' . $filename . '" type="video/mp4">
209 209
                 </video> ';
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                 $result = $stmt->get_result();
227 227
             ?>
228 228
             <div class="commentsList">
229
-                <?php while($row = $result->fetch_assoc()) { ?>
229
+                <?php while ($row = $result->fetch_assoc()) { ?>
230 230
                 <div class='commentRight' style='display: grid; grid-template-columns: auto 85%; padding:5px;'>
231 231
                     <div>
232 232
                         <a style='float: left;' href='/view/profile?id=<?php echo getID($row['author'], $conn); ?>'><?php echo $row['author']; ?></a>
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
                     </div>
236 236
                     <div style="word-wrap: break-word;">
237 237
                         <small><?php echo $row['date']; ?></small>
238
-                        <?php echo validateMarkdown($row['text']);?>
238
+                        <?php echo validateMarkdown($row['text']); ?>
239 239
                     </div>
240 240
                 </div>
241 241
                 <?php } ?>
Please login to merge, or discard this patch.
view/items.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
             require(__DIR__ . "/../func/func.php");
9 9
             require(__DIR__ . "/../func/conn.php"); 
10 10
             $featured = array(1, 3, 12);
11
-            $newlines = array("<br>", " <br>", "<br>" , " <br> ");
11
+            $newlines = array("<br>", " <br>", "<br>", " <br> ");
12 12
         ?>
13 13
         <title>4Grounds - Hub</title>
14 14
     </head>
@@ -17,27 +17,27 @@  discard block
 block discarded – undo
17 17
         <div class="container"><br>
18 18
             <h1>Search results for type '<?php echo htmlspecialchars($_GET['type']); ?>'</h1>
19 19
             <?php
20
-            if(isset($_GET['type'])) {
20
+            if (isset($_GET['type'])) {
21 21
                 $stmt = $conn->prepare("SELECT * FROM `files` WHERE type = ? AND status = 'y' ORDER BY id DESC");
22 22
                 $stmt->bind_param("s", $_GET['type']);
23 23
                 $stmt->execute();
24 24
                 $result = $stmt->get_result();
25 25
 
26
-                while($row = $result->fetch_assoc()) { 
27
-                    if($row['type'] == "song") {
26
+                while ($row = $result->fetch_assoc()) { 
27
+                    if ($row['type'] == "song") {
28 28
                         echo '<b><a href="/view?id=' . $row['id'] . '">' . htmlspecialchars($row['title']) . '</b></a> <span style="float:right;"><small>Uploader: <b>' . $row['author'] . '</b></small></span><br>
29 29
                         ' . $row['extrainfo'] . '<br>
30 30
                         <audio controls>
31 31
                         <source src="/dynamic/song/' . $row['filename'] . '">
32 32
                         </audio><hr>';
33
-                    } else if($row['type'] == "image") {
33
+                    } else if ($row['type'] == "image") {
34 34
                         //im sorry for this abomination
35 35
                         echo "<div style='display: inline-block;' class='notegray'>
36 36
                             <a href='/view?id=" . $row['id'] . "'><img style='width: 10em;height: 10em;' src='images/" . $row['filename'] . "'>
37 37
                             <br><center><b>" . htmlspecialchars($row['title']) . "</b><br><span style='color: gray;'>By " . $row['author'] . "</span></center>
38 38
                             </a>
39 39
                         </div> ";  
40
-                    } else if($row['type'] == "news" || $row['type'] == "review") {
40
+                    } else if ($row['type'] == "news" || $row['type'] == "review") {
41 41
                         echo "<small>
42 42
                         <img style='position: absolute;border: 1px solid white; width: 5em;' src='/pfp/" . getPFP($row['author'], $conn) . "'>
43 43
                         <a href='/view?id=" . $row['id'] . "'><span style='float:right;color: gold;'>[" . $row['agerating'] . "] <i>" . $row['title'] . "</a></i></span><br>
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                     } else {
48 48
                         echo "<b><a href='/view?id=" . $row['id'] . "'>" . htmlspecialchars($row['title']) . " by " . $row['author'] . "
49 49
                         </a><small><span style='float:right;'>[" . $row['date'] . "]</small></span>";
50
-                        if(in_array($row['id'], $featured)) {
50
+                        if (in_array($row['id'], $featured)) {
51 51
                             echo "<span style='float:right; color: gold;margin-right: 10px;'>Featured!</span> &nbsp;";
52 52
                         }
53 53
                         echo "</b><br>" . $row['extrainfo'] . "<br><hr>";
Please login to merge, or discard this patch.
func/upload.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 return function($type, $allowedFileTypes, $conn) {
3
-    if(isset($_SESSION['user'])) {
3
+    if (isset($_SESSION['user'])) {
4 4
         $fileType = strtolower(pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_EXTENSION));
5 5
         $target_dir = __DIR__ . "/../dynamic/" . $type . "/";
6 6
         $target_name = md5_file($_FILES["fileToUpload"]["tmp_name"]) . "." . $fileType;
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             $movedFile = move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
16 16
         }
17 17
 
18
-        if(!in_array($fileType, $allowedFileTypes)) {
18
+        if (!in_array($fileType, $allowedFileTypes)) {
19 19
             echo 'unsupported file type. must be one of ' . join(", ", $allowedFileTypes) . '<hr>';
20 20
             $uploadOk = 0;
21 21
         }
Please login to merge, or discard this patch.
upload/game.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     <body> 
13 13
         <?php require(__DIR__ . "/../important/header.php"); 
14 14
         
15
-        if(@$_POST['submit']) {
15
+        if (@$_POST['submit']) {
16 16
             $register = require(__DIR__ . "/../func/upload.php");
17 17
             $register("game", ["swf"], $conn);
18 18
         }
Please login to merge, or discard this patch.
upload/midi.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     <body> 
13 13
         <?php require(__DIR__ . "/../important/header.php"); 
14 14
         
15
-        if(@$_POST['submit']) {
15
+        if (@$_POST['submit']) {
16 16
             $register = require(__DIR__ . "/../func/upload.php");
17 17
             $register("midi", ["mid"], $conn);
18 18
         }
Please login to merge, or discard this patch.
upload/video.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     <body> 
13 13
         <?php require(__DIR__ . "/../important/header.php"); 
14 14
         
15
-        if(@$_POST['submit']) {
15
+        if (@$_POST['submit']) {
16 16
             $register = require(__DIR__ . "/../func/upload.php");
17 17
             $register("video", ["mp4"], $conn);
18 18
         }
Please login to merge, or discard this patch.
upload/chiptune.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     <body> 
13 13
         <?php require(__DIR__ . "/../important/header.php"); 
14 14
         
15
-        if(@$_POST['submit']) {
15
+        if (@$_POST['submit']) {
16 16
             $register = require(__DIR__ . "/../func/upload.php");
17 17
             $register("chiptune", ["xm", "mod", "s3m", "it"], $conn);
18 18
         }
Please login to merge, or discard this patch.