@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require("dependencies.php"); |
| 3 | 3 | |
| 4 | -if(isset($_SESSION['user'])) { |
|
| 5 | - if(isset($_GET['id'])) { |
|
| 6 | - if(isAdmin($_SESSION['user'], $conn)) { |
|
| 4 | +if (isset($_SESSION['user'])) { |
|
| 5 | + if (isset($_GET['id'])) { |
|
| 6 | + if (isAdmin($_SESSION['user'], $conn)) { |
|
| 7 | 7 | $stmt = $conn->prepare("DELETE FROM users WHERE id = ?"); |
| 8 | 8 | $stmt->bind_param("i", $_GET['id']); |
| 9 | 9 | $stmt->execute(); |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require("dependencies.php"); |
| 3 | 3 | |
| 4 | -if(isset($_SESSION['user'])) { |
|
| 5 | - if(isAdmin($_SESSION['user'], $conn)) { |
|
| 4 | +if (isset($_SESSION['user'])) { |
|
| 5 | + if (isAdmin($_SESSION['user'], $conn)) { |
|
| 6 | 6 | echo "<h1>Welcome</h1>"; |
| 7 | 7 | } else { |
| 8 | 8 | die("not a admin"); |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | $stmt = $conn->prepare("SELECT * FROM files WHERE status = 'n'"); |
| 34 | 34 | $stmt->execute(); |
| 35 | 35 | $result = $stmt->get_result(); |
| 36 | - if($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 37 | - while($row = $result->fetch_assoc()) { |
|
| 36 | + if ($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 37 | + while ($row = $result->fetch_assoc()) { |
|
| 38 | 38 | echo "<a href='/view/?id=" . $row['id'] . "'>" . $row['title'] . "</a> by <a href='/view/profile?id=" . getID($row['author'], $conn) . "'>" . $row['author'] . "</a> @ " . $row['date'] . " | <a href='approve.php?id=" . $row['id'] . "'>Approve</a> | <a href='deny.php?id=" . $row['id'] . "'>Deny</a><br>"; |
| 39 | 39 | } |
| 40 | 40 | ?> |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | $stmt = $conn->prepare("SELECT * FROM users ORDER BY id DESC"); |
| 46 | 46 | $stmt->execute(); |
| 47 | 47 | $result = $stmt->get_result(); |
| 48 | - if($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 49 | - while($row = $result->fetch_assoc()) { |
|
| 48 | + if ($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 49 | + while ($row = $result->fetch_assoc()) { |
|
| 50 | 50 | echo "<a href='/index.php?id=" . $row['id'] . "'>" . $row['username'] . "</a> | <a href='ban.php?id=" . $row['id'] . "'>Ban</a><br>"; |
| 51 | 51 | } |
| 52 | 52 | ?> |
| 53 | 53 | \ No newline at end of file |
@@ -33,7 +33,9 @@ discard block |
||
| 33 | 33 | $stmt = $conn->prepare("SELECT * FROM files WHERE status = 'n'"); |
| 34 | 34 | $stmt->execute(); |
| 35 | 35 | $result = $stmt->get_result(); |
| 36 | - if($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 36 | + if($result->num_rows === 0) { |
|
| 37 | + echo('There are no items waiting for approval.'); |
|
| 38 | + } |
|
| 37 | 39 | while($row = $result->fetch_assoc()) { |
| 38 | 40 | echo "<a href='/view/?id=" . $row['id'] . "'>" . $row['title'] . "</a> by <a href='/view/profile?id=" . getID($row['author'], $conn) . "'>" . $row['author'] . "</a> @ " . $row['date'] . " | <a href='approve.php?id=" . $row['id'] . "'>Approve</a> | <a href='deny.php?id=" . $row['id'] . "'>Deny</a><br>"; |
| 39 | 41 | } |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | $stmt = $conn->prepare("SELECT * FROM users ORDER BY id DESC"); |
| 46 | 48 | $stmt->execute(); |
| 47 | 49 | $result = $stmt->get_result(); |
| 48 | - if($result->num_rows === 0) echo('There are no items waiting for approval.'); |
|
| 50 | + if($result->num_rows === 0) { |
|
| 51 | + echo('There are no items waiting for approval.'); |
|
| 52 | + } |
|
| 49 | 53 | while($row = $result->fetch_assoc()) { |
| 50 | 54 | echo "<a href='/index.php?id=" . $row['id'] . "'>" . $row['username'] . "</a> | <a href='ban.php?id=" . $row['id'] . "'>Ban</a><br>"; |
| 51 | 55 | } |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require("dependencies.php"); |
| 3 | 3 | |
| 4 | -if(isset($_SESSION['user'])) { |
|
| 5 | - if(isset($_GET['id'])) { |
|
| 6 | - if(isAdmin($_SESSION['user'], $conn)) { |
|
| 4 | +if (isset($_SESSION['user'])) { |
|
| 5 | + if (isset($_GET['id'])) { |
|
| 6 | + if (isAdmin($_SESSION['user'], $conn)) { |
|
| 7 | 7 | $stmt = $conn->prepare("UPDATE files SET status = 'd' WHERE id = ?"); |
| 8 | 8 | $stmt->bind_param("i", $_GET['id']); |
| 9 | 9 | $stmt->execute(); |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | require("dependencies.php"); |
| 3 | 3 | |
| 4 | -if(isset($_SESSION['user'])) { |
|
| 5 | - if(isset($_GET['id'])) { |
|
| 6 | - if(isAdmin($_SESSION['user'], $conn)) { |
|
| 4 | +if (isset($_SESSION['user'])) { |
|
| 5 | + if (isset($_GET['id'])) { |
|
| 6 | + if (isAdmin($_SESSION['user'], $conn)) { |
|
| 7 | 7 | $stmt = $conn->prepare("UPDATE files SET status = 'y' WHERE id = ?"); |
| 8 | 8 | $stmt->bind_param("i", $_GET['id']); |
| 9 | 9 | $stmt->execute(); |
@@ -11,91 +11,91 @@ discard block |
||
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | function validateCSS($validate) { |
| 14 | - $DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); |
|
| 14 | + $DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); |
|
| 15 | 15 | |
| 16 | - $validated = str_replace($DISALLOWED, "", $validate); |
|
| 16 | + $validated = str_replace($DISALLOWED, "", $validate); |
|
| 17 | 17 | return $validated; |
| 18 | 18 | } |
| 19 | 19 | function validateMarkdown($comment, $type = "comment") { |
| 20 | - $comment = htmlspecialchars($comment); |
|
| 21 | - $Parsedown = new Parsedown(); |
|
| 22 | - $Parsedown->setSafeMode(true); |
|
| 23 | - |
|
| 24 | - if ($type === "profile") { |
|
| 25 | - return $Parsedown->parse($comment); |
|
| 26 | - } else { |
|
| 27 | - return $Parsedown->line($comment); |
|
| 28 | - } |
|
| 20 | + $comment = htmlspecialchars($comment); |
|
| 21 | + $Parsedown = new Parsedown(); |
|
| 22 | + $Parsedown->setSafeMode(true); |
|
| 23 | + |
|
| 24 | + if ($type === "profile") { |
|
| 25 | + return $Parsedown->parse($comment); |
|
| 26 | + } else { |
|
| 27 | + return $Parsedown->line($comment); |
|
| 28 | + } |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | function validateCaptcha($privatekey, $response) { |
| 33 | - $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 34 | - return $responseData->success; |
|
| 33 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 34 | + return $responseData->success; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | function requireLogin() { |
| 38 | - if (!isset($_SESSION['user'])) { |
|
| 39 | - header("Location: /login.php?r_login"); die(); |
|
| 40 | - } |
|
| 38 | + if (!isset($_SESSION['user'])) { |
|
| 39 | + header("Location: /login.php?r_login"); die(); |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function getGroup($id, $conn) { |
| 44 | - $stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?"); |
|
| 45 | - $stmt->bind_param("i", $id); |
|
| 46 | - $stmt->execute(); |
|
| 47 | - $result = $stmt->get_result(); |
|
| 48 | - if ($result->num_rows === 0) return 'error'; |
|
| 49 | - return $result->fetch_assoc(); |
|
| 44 | + $stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?"); |
|
| 45 | + $stmt->bind_param("i", $id); |
|
| 46 | + $stmt->execute(); |
|
| 47 | + $result = $stmt->get_result(); |
|
| 48 | + if ($result->num_rows === 0) return 'error'; |
|
| 49 | + return $result->fetch_assoc(); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function getID($user, $connection) { |
| 53 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 54 | - $stmt->bind_param("s", $user); |
|
| 55 | - $stmt->execute(); |
|
| 56 | - $result = $stmt->get_result(); |
|
| 57 | - if($result->num_rows === 0) return 'error'; |
|
| 58 | - while($row = $result->fetch_assoc()) { |
|
| 59 | - $id = $row['id']; |
|
| 60 | - } |
|
| 61 | - $stmt->close(); |
|
| 62 | - return $id; |
|
| 53 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 54 | + $stmt->bind_param("s", $user); |
|
| 55 | + $stmt->execute(); |
|
| 56 | + $result = $stmt->get_result(); |
|
| 57 | + if($result->num_rows === 0) return 'error'; |
|
| 58 | + while($row = $result->fetch_assoc()) { |
|
| 59 | + $id = $row['id']; |
|
| 60 | + } |
|
| 61 | + $stmt->close(); |
|
| 62 | + return $id; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function getName($id, $connection) { |
| 66 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 67 | - $stmt->bind_param("s", $id); |
|
| 68 | - $stmt->execute(); |
|
| 69 | - $result = $stmt->get_result(); |
|
| 70 | - if($result->num_rows === 0) return('error'); |
|
| 71 | - while($row = $result->fetch_assoc()) { |
|
| 72 | - $name = htmlspecialchars($row['username']); |
|
| 73 | - } |
|
| 74 | - $stmt->close(); |
|
| 75 | - return $name; |
|
| 66 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 67 | + $stmt->bind_param("s", $id); |
|
| 68 | + $stmt->execute(); |
|
| 69 | + $result = $stmt->get_result(); |
|
| 70 | + if($result->num_rows === 0) return('error'); |
|
| 71 | + while($row = $result->fetch_assoc()) { |
|
| 72 | + $name = htmlspecialchars($row['username']); |
|
| 73 | + } |
|
| 74 | + $stmt->close(); |
|
| 75 | + return $name; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function getPFP($user, $connection) { |
| 79 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 80 | - $stmt->bind_param("s", $user); |
|
| 81 | - $stmt->execute(); |
|
| 82 | - $result = $stmt->get_result(); |
|
| 83 | - if($result->num_rows === 0) return('error'); |
|
| 84 | - while($row = $result->fetch_assoc()) { |
|
| 85 | - $pfp = htmlspecialchars($row['pfp']); |
|
| 86 | - } |
|
| 87 | - $stmt->close(); |
|
| 88 | - return $pfp; |
|
| 79 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 80 | + $stmt->bind_param("s", $user); |
|
| 81 | + $stmt->execute(); |
|
| 82 | + $result = $stmt->get_result(); |
|
| 83 | + if($result->num_rows === 0) return('error'); |
|
| 84 | + while($row = $result->fetch_assoc()) { |
|
| 85 | + $pfp = htmlspecialchars($row['pfp']); |
|
| 86 | + } |
|
| 87 | + $stmt->close(); |
|
| 88 | + return $pfp; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function checkIfFriended($friend1, $friend2, $connection) |
| 92 | 92 | { |
| 93 | - $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 94 | - $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 95 | - $stmt->execute(); |
|
| 96 | - $result = $stmt->get_result(); |
|
| 97 | - if($result->num_rows === 1){ return true; } |
|
| 98 | - return false; |
|
| 93 | + $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 94 | + $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 95 | + $stmt->execute(); |
|
| 96 | + $result = $stmt->get_result(); |
|
| 97 | + if($result->num_rows === 1){ return true; } |
|
| 98 | + return false; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | function isAdmin($user, $conn) { |
@@ -115,58 +115,58 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function getUser($id, $connection) { |
| 118 | - $userResult = array(); |
|
| 119 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 120 | - $stmt->bind_param("i", $id); |
|
| 121 | - $stmt->execute(); |
|
| 122 | - $result = $stmt->get_result(); |
|
| 123 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 124 | - while($row = $result->fetch_assoc()) { |
|
| 125 | - $userResult['username'] = $row['username']; |
|
| 126 | - $userResult['id'] = $row['id']; |
|
| 127 | - $userResult['date'] = $row['date']; |
|
| 128 | - $userResult['bio'] = $row['bio']; |
|
| 129 | - $userResult['css'] = $row['css']; |
|
| 130 | - $userResult['pfp'] = $row['pfp']; |
|
| 131 | - $userResult['badges'] = explode(';', $row['badges']); |
|
| 132 | - $userResult['music'] = $row['music']; |
|
| 133 | - $userResult['rank'] = $row['rank']; |
|
| 134 | - $userResult['currentgroup'] = $row['currentgroup']; |
|
| 135 | - } |
|
| 136 | - $stmt->close(); |
|
| 137 | - |
|
| 138 | - $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 139 | - $stmt->bind_param("s", $userResult['username']); |
|
| 140 | - $stmt->execute(); |
|
| 141 | - $result = $stmt->get_result(); |
|
| 142 | - |
|
| 143 | - $userResult['comments'] = 0; |
|
| 144 | - while($row = $result->fetch_assoc()) { |
|
| 145 | - $userResult['comments']++; |
|
| 146 | - } |
|
| 147 | - $stmt->close(); |
|
| 148 | - |
|
| 149 | - $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 150 | - $stmt->bind_param("s", $userResult['username']); |
|
| 151 | - $stmt->execute(); |
|
| 152 | - $result = $stmt->get_result(); |
|
| 153 | - |
|
| 154 | - $userResult['profilecomments'] = 0; |
|
| 155 | - while($row = $result->fetch_assoc()) { |
|
| 156 | - $userResult['profilecomments']++; |
|
| 157 | - } |
|
| 158 | - $stmt->close(); |
|
| 159 | - |
|
| 160 | - $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 161 | - $stmt->bind_param("s", $userResult['username']); |
|
| 162 | - $stmt->execute(); |
|
| 163 | - $result = $stmt->get_result(); |
|
| 164 | - |
|
| 165 | - $userResult['filesuploaded'] = 0; |
|
| 166 | - while($row = $result->fetch_assoc()) { |
|
| 167 | - $userResult['filesuploaded']++; |
|
| 168 | - } |
|
| 169 | - $stmt->close(); |
|
| 170 | - return $userResult; |
|
| 118 | + $userResult = array(); |
|
| 119 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 120 | + $stmt->bind_param("i", $id); |
|
| 121 | + $stmt->execute(); |
|
| 122 | + $result = $stmt->get_result(); |
|
| 123 | + if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 124 | + while($row = $result->fetch_assoc()) { |
|
| 125 | + $userResult['username'] = $row['username']; |
|
| 126 | + $userResult['id'] = $row['id']; |
|
| 127 | + $userResult['date'] = $row['date']; |
|
| 128 | + $userResult['bio'] = $row['bio']; |
|
| 129 | + $userResult['css'] = $row['css']; |
|
| 130 | + $userResult['pfp'] = $row['pfp']; |
|
| 131 | + $userResult['badges'] = explode(';', $row['badges']); |
|
| 132 | + $userResult['music'] = $row['music']; |
|
| 133 | + $userResult['rank'] = $row['rank']; |
|
| 134 | + $userResult['currentgroup'] = $row['currentgroup']; |
|
| 135 | + } |
|
| 136 | + $stmt->close(); |
|
| 137 | + |
|
| 138 | + $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 139 | + $stmt->bind_param("s", $userResult['username']); |
|
| 140 | + $stmt->execute(); |
|
| 141 | + $result = $stmt->get_result(); |
|
| 142 | + |
|
| 143 | + $userResult['comments'] = 0; |
|
| 144 | + while($row = $result->fetch_assoc()) { |
|
| 145 | + $userResult['comments']++; |
|
| 146 | + } |
|
| 147 | + $stmt->close(); |
|
| 148 | + |
|
| 149 | + $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 150 | + $stmt->bind_param("s", $userResult['username']); |
|
| 151 | + $stmt->execute(); |
|
| 152 | + $result = $stmt->get_result(); |
|
| 153 | + |
|
| 154 | + $userResult['profilecomments'] = 0; |
|
| 155 | + while($row = $result->fetch_assoc()) { |
|
| 156 | + $userResult['profilecomments']++; |
|
| 157 | + } |
|
| 158 | + $stmt->close(); |
|
| 159 | + |
|
| 160 | + $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 161 | + $stmt->bind_param("s", $userResult['username']); |
|
| 162 | + $stmt->execute(); |
|
| 163 | + $result = $stmt->get_result(); |
|
| 164 | + |
|
| 165 | + $userResult['filesuploaded'] = 0; |
|
| 166 | + while($row = $result->fetch_assoc()) { |
|
| 167 | + $userResult['filesuploaded']++; |
|
| 168 | + } |
|
| 169 | + $stmt->close(); |
|
| 170 | + return $userResult; |
|
| 171 | 171 | } |
| 172 | 172 | ?> |
| 173 | 173 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | define("DEBUG_MODE", true); |
| 6 | 6 | session_start(); |
| 7 | -if(defined("DEBUG_MODE") && DEBUG_MODE) { |
|
| 7 | +if (defined("DEBUG_MODE") && DEBUG_MODE) { |
|
| 8 | 8 | ini_set('display_errors', 1); |
| 9 | 9 | ini_set('display_startup_errors', 1); |
| 10 | 10 | error_reporting(E_ALL); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | function validateCaptcha($privatekey, $response) { |
| 33 | - $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 33 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $privatekey . '&response=' . $response)); |
|
| 34 | 34 | return $responseData->success; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | $stmt->bind_param("s", $user); |
| 55 | 55 | $stmt->execute(); |
| 56 | 56 | $result = $stmt->get_result(); |
| 57 | - if($result->num_rows === 0) return 'error'; |
|
| 58 | - while($row = $result->fetch_assoc()) { |
|
| 57 | + if ($result->num_rows === 0) return 'error'; |
|
| 58 | + while ($row = $result->fetch_assoc()) { |
|
| 59 | 59 | $id = $row['id']; |
| 60 | 60 | } |
| 61 | 61 | $stmt->close(); |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | $stmt->bind_param("s", $id); |
| 68 | 68 | $stmt->execute(); |
| 69 | 69 | $result = $stmt->get_result(); |
| 70 | - if($result->num_rows === 0) return('error'); |
|
| 71 | - while($row = $result->fetch_assoc()) { |
|
| 70 | + if ($result->num_rows === 0) return('error'); |
|
| 71 | + while ($row = $result->fetch_assoc()) { |
|
| 72 | 72 | $name = htmlspecialchars($row['username']); |
| 73 | 73 | } |
| 74 | 74 | $stmt->close(); |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | $stmt->bind_param("s", $user); |
| 81 | 81 | $stmt->execute(); |
| 82 | 82 | $result = $stmt->get_result(); |
| 83 | - if($result->num_rows === 0) return('error'); |
|
| 84 | - while($row = $result->fetch_assoc()) { |
|
| 83 | + if ($result->num_rows === 0) return('error'); |
|
| 84 | + while ($row = $result->fetch_assoc()) { |
|
| 85 | 85 | $pfp = htmlspecialchars($row['pfp']); |
| 86 | 86 | } |
| 87 | 87 | $stmt->close(); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
| 95 | 95 | $stmt->execute(); |
| 96 | 96 | $result = $stmt->get_result(); |
| 97 | - if($result->num_rows === 1){ return true; } |
|
| 97 | + if ($result->num_rows === 1) { return true; } |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | $stmt->bind_param("s", $user); |
| 104 | 104 | $stmt->execute(); |
| 105 | 105 | $result = $stmt->get_result(); |
| 106 | - if($result->num_rows === 0) return false; |
|
| 107 | - while($row = $result->fetch_assoc()) { |
|
| 108 | - if($row['rank'] == "Admin" || $row['rank'] == "Owner") { |
|
| 106 | + if ($result->num_rows === 0) return false; |
|
| 107 | + while ($row = $result->fetch_assoc()) { |
|
| 108 | + if ($row['rank'] == "Admin" || $row['rank'] == "Owner") { |
|
| 109 | 109 | return true; |
| 110 | 110 | } else { |
| 111 | 111 | return false; |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | $stmt->bind_param("i", $id); |
| 121 | 121 | $stmt->execute(); |
| 122 | 122 | $result = $stmt->get_result(); |
| 123 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 124 | - while($row = $result->fetch_assoc()) { |
|
| 123 | + if ($result->num_rows === 0) echo('That user does not exist.'); |
|
| 124 | + while ($row = $result->fetch_assoc()) { |
|
| 125 | 125 | $userResult['username'] = $row['username']; |
| 126 | 126 | $userResult['id'] = $row['id']; |
| 127 | 127 | $userResult['date'] = $row['date']; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $result = $stmt->get_result(); |
| 142 | 142 | |
| 143 | 143 | $userResult['comments'] = 0; |
| 144 | - while($row = $result->fetch_assoc()) { |
|
| 144 | + while ($row = $result->fetch_assoc()) { |
|
| 145 | 145 | $userResult['comments']++; |
| 146 | 146 | } |
| 147 | 147 | $stmt->close(); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $result = $stmt->get_result(); |
| 153 | 153 | |
| 154 | 154 | $userResult['profilecomments'] = 0; |
| 155 | - while($row = $result->fetch_assoc()) { |
|
| 155 | + while ($row = $result->fetch_assoc()) { |
|
| 156 | 156 | $userResult['profilecomments']++; |
| 157 | 157 | } |
| 158 | 158 | $stmt->close(); |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $result = $stmt->get_result(); |
| 164 | 164 | |
| 165 | 165 | $userResult['filesuploaded'] = 0; |
| 166 | - while($row = $result->fetch_assoc()) { |
|
| 166 | + while ($row = $result->fetch_assoc()) { |
|
| 167 | 167 | $userResult['filesuploaded']++; |
| 168 | 168 | } |
| 169 | 169 | $stmt->close(); |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | $stmt->bind_param("i", $id); |
| 46 | 46 | $stmt->execute(); |
| 47 | 47 | $result = $stmt->get_result(); |
| 48 | - if ($result->num_rows === 0) return 'error'; |
|
| 48 | + if ($result->num_rows === 0) { |
|
| 49 | + return 'error'; |
|
| 50 | + } |
|
| 49 | 51 | return $result->fetch_assoc(); |
| 50 | 52 | } |
| 51 | 53 | |
@@ -54,7 +56,9 @@ discard block |
||
| 54 | 56 | $stmt->bind_param("s", $user); |
| 55 | 57 | $stmt->execute(); |
| 56 | 58 | $result = $stmt->get_result(); |
| 57 | - if($result->num_rows === 0) return 'error'; |
|
| 59 | + if($result->num_rows === 0) { |
|
| 60 | + return 'error'; |
|
| 61 | + } |
|
| 58 | 62 | while($row = $result->fetch_assoc()) { |
| 59 | 63 | $id = $row['id']; |
| 60 | 64 | } |
@@ -67,7 +71,9 @@ discard block |
||
| 67 | 71 | $stmt->bind_param("s", $id); |
| 68 | 72 | $stmt->execute(); |
| 69 | 73 | $result = $stmt->get_result(); |
| 70 | - if($result->num_rows === 0) return('error'); |
|
| 74 | + if($result->num_rows === 0) { |
|
| 75 | + return('error'); |
|
| 76 | + } |
|
| 71 | 77 | while($row = $result->fetch_assoc()) { |
| 72 | 78 | $name = htmlspecialchars($row['username']); |
| 73 | 79 | } |
@@ -80,7 +86,9 @@ discard block |
||
| 80 | 86 | $stmt->bind_param("s", $user); |
| 81 | 87 | $stmt->execute(); |
| 82 | 88 | $result = $stmt->get_result(); |
| 83 | - if($result->num_rows === 0) return('error'); |
|
| 89 | + if($result->num_rows === 0) { |
|
| 90 | + return('error'); |
|
| 91 | + } |
|
| 84 | 92 | while($row = $result->fetch_assoc()) { |
| 85 | 93 | $pfp = htmlspecialchars($row['pfp']); |
| 86 | 94 | } |
@@ -103,7 +111,9 @@ discard block |
||
| 103 | 111 | $stmt->bind_param("s", $user); |
| 104 | 112 | $stmt->execute(); |
| 105 | 113 | $result = $stmt->get_result(); |
| 106 | - if($result->num_rows === 0) return false; |
|
| 114 | + if($result->num_rows === 0) { |
|
| 115 | + return false; |
|
| 116 | + } |
|
| 107 | 117 | while($row = $result->fetch_assoc()) { |
| 108 | 118 | if($row['rank'] == "Admin" || $row['rank'] == "Owner") { |
| 109 | 119 | return true; |
@@ -120,7 +130,9 @@ discard block |
||
| 120 | 130 | $stmt->bind_param("i", $id); |
| 121 | 131 | $stmt->execute(); |
| 122 | 132 | $result = $stmt->get_result(); |
| 123 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 133 | + if($result->num_rows === 0) { |
|
| 134 | + echo('That user does not exist.'); |
|
| 135 | + } |
|
| 124 | 136 | while($row = $result->fetch_assoc()) { |
| 125 | 137 | $userResult['username'] = $row['username']; |
| 126 | 138 | $userResult['id'] = $row['id']; |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | require(__DIR__ . "/../func/func.php"); |
| 9 | 9 | require(__DIR__ . "/../func/conn.php"); |
| 10 | 10 | |
| 11 | - if(isset($_GET['id'])) { |
|
| 11 | + if (isset($_GET['id'])) { |
|
| 12 | 12 | $stmt = $conn->prepare("SELECT * FROM files WHERE id = ?"); |
| 13 | 13 | $stmt->bind_param("i", $_GET['id']); |
| 14 | 14 | $stmt->execute(); |
| 15 | 15 | $result = $stmt->get_result(); |
| 16 | - if($result->num_rows === 0) echo('There are no users.'); |
|
| 17 | - while($row = $result->fetch_assoc()) { |
|
| 16 | + if ($result->num_rows === 0) echo('There are no users.'); |
|
| 17 | + while ($row = $result->fetch_assoc()) { |
|
| 18 | 18 | $author = $row['author']; |
| 19 | 19 | $id = $row['id']; |
| 20 | 20 | $date = $row['date']; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $status = $row['status']; |
| 25 | 25 | $filename = $row['filename']; |
| 26 | 26 | |
| 27 | - if($status != "y" && !@isAdmin($_SESSION['user'], $conn)) { |
|
| 27 | + if ($status != "y" && !@isAdmin($_SESSION['user'], $conn)) { |
|
| 28 | 28 | die("Item is not approved yet."); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | <div class="container"> |
| 40 | 40 | <?php |
| 41 | - if($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 41 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 42 | 42 | { |
| 43 | - if(!isset($_SESSION['user'])){ $error = "you are not logged in"; goto skipcomment; } |
|
| 44 | - if(!$_POST['comment']){ $error = "your comment cannot be blank"; goto skipcomment; } |
|
| 45 | - if(strlen($_POST['comment']) > 500){ $error = "your comment must be shorter than 500 characters"; goto skipcomment; } |
|
| 46 | - if(!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; } |
|
| 47 | - if($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; } |
|
| 43 | + if (!isset($_SESSION['user'])) { $error = "you are not logged in"; goto skipcomment; } |
|
| 44 | + if (!$_POST['comment']) { $error = "your comment cannot be blank"; goto skipcomment; } |
|
| 45 | + if (strlen($_POST['comment']) > 500) { $error = "your comment must be shorter than 500 characters"; goto skipcomment; } |
|
| 46 | + if (!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; } |
|
| 47 | + if ($config['use_recaptcha'] && !validateCaptcha($config['recaptcha_secret'], $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skipcomment; } |
|
| 48 | 48 | |
| 49 | 49 | $stmt = $conn->prepare("INSERT INTO `gamecomments` (toid, author, text, date) VALUES (?, ?, ?, now())"); |
| 50 | 50 | $stmt->bind_param("sss", $_GET['id'], $_SESSION['user'], $text); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $stmt->close(); |
| 54 | 54 | } |
| 55 | 55 | skipcomment: |
| 56 | - if(isset($error)) { |
|
| 56 | + if (isset($error)) { |
|
| 57 | 57 | echo "<span style='color: red;'><small>" . $error . "</small></span><br>"; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | <br><br>" . $extrainfo . "</small><hr>"; |
| 66 | 66 | ?> |
| 67 | 67 | <?php |
| 68 | - switch($type) { |
|
| 68 | + switch ($type) { |
|
| 69 | 69 | case "song": |
| 70 | 70 | echo '<audio controls> <source src="/dynamic/song/' . $filename . '"> </audio>'; |
| 71 | 71 | break; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $result = $stmt->get_result(); |
| 108 | 108 | ?> |
| 109 | 109 | <div class="commentsList"> |
| 110 | - <?php while($row = $result->fetch_assoc()) { ?> |
|
| 110 | + <?php while ($row = $result->fetch_assoc()) { ?> |
|
| 111 | 111 | <div class='commentRight' style='display: grid; grid-template-columns: auto 85%; padding:5px;'> |
| 112 | 112 | <div> |
| 113 | 113 | <a style='float: left;' href='/view/profile?id=<?php echo getID($row['author'], $conn); ?>'><?php echo $row['author']; ?></a> |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | </div> |
| 117 | 117 | <div style="word-wrap: break-word;"> |
| 118 | 118 | <small><?php echo $row['date']; ?></small><br> |
| 119 | - <?php echo validateMarkdown($row['text']);?> |
|
| 119 | + <?php echo validateMarkdown($row['text']); ?> |
|
| 120 | 120 | </div> |
| 121 | 121 | </div> |
| 122 | 122 | <?php } ?> |