@@ -11,143 +11,143 @@ |
||
| 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) { |
| 20 | - $comment = htmlspecialchars($comment); |
|
| 21 | - $Parsedown = new Parsedown(); |
|
| 22 | - $Parsedown->setSafeMode(true); |
|
| 20 | + $comment = htmlspecialchars($comment); |
|
| 21 | + $Parsedown = new Parsedown(); |
|
| 22 | + $Parsedown->setSafeMode(true); |
|
| 23 | 23 | |
| 24 | - $filtered = $Parsedown->line($comment); |
|
| 25 | - return str_replace(PHP_EOL, "<br>", $filtered); |
|
| 24 | + $filtered = $Parsedown->line($comment); |
|
| 25 | + return str_replace(PHP_EOL, "<br>", $filtered); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | function validateCaptcha($privatekey, $response) { |
| 30 | - $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 31 | - return $responseData->success; |
|
| 30 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 31 | + return $responseData->success; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function requireLogin() { |
| 35 | - if (!isset($_SESSION['user'])) { |
|
| 36 | - header("Location: /login.php?r_login"); die(); |
|
| 37 | - } |
|
| 35 | + if (!isset($_SESSION['user'])) { |
|
| 36 | + header("Location: /login.php?r_login"); die(); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | function getGroup($id, $conn) { |
| 41 | - $stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?"); |
|
| 42 | - $stmt->bind_param("i", $id); |
|
| 43 | - $stmt->execute(); |
|
| 44 | - $result = $stmt->get_result(); |
|
| 45 | - if ($result->num_rows === 0) return 'error'; |
|
| 46 | - return $result->fetch_assoc(); |
|
| 41 | + $stmt = $conn->prepare("SELECT * FROM `groups` WHERE `id` = ?"); |
|
| 42 | + $stmt->bind_param("i", $id); |
|
| 43 | + $stmt->execute(); |
|
| 44 | + $result = $stmt->get_result(); |
|
| 45 | + if ($result->num_rows === 0) return 'error'; |
|
| 46 | + return $result->fetch_assoc(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function getID($user, $connection) { |
| 50 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 51 | - $stmt->bind_param("s", $user); |
|
| 52 | - $stmt->execute(); |
|
| 53 | - $result = $stmt->get_result(); |
|
| 54 | - if($result->num_rows === 0) return 'error'; |
|
| 55 | - while($row = $result->fetch_assoc()) { |
|
| 56 | - $id = $row['id']; |
|
| 57 | - } |
|
| 58 | - $stmt->close(); |
|
| 59 | - return $id; |
|
| 50 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 51 | + $stmt->bind_param("s", $user); |
|
| 52 | + $stmt->execute(); |
|
| 53 | + $result = $stmt->get_result(); |
|
| 54 | + if($result->num_rows === 0) return 'error'; |
|
| 55 | + while($row = $result->fetch_assoc()) { |
|
| 56 | + $id = $row['id']; |
|
| 57 | + } |
|
| 58 | + $stmt->close(); |
|
| 59 | + return $id; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function getName($id, $connection) { |
| 63 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 64 | - $stmt->bind_param("s", $id); |
|
| 65 | - $stmt->execute(); |
|
| 66 | - $result = $stmt->get_result(); |
|
| 67 | - if($result->num_rows === 0) return('error'); |
|
| 68 | - while($row = $result->fetch_assoc()) { |
|
| 69 | - $name = htmlspecialchars($row['username']); |
|
| 70 | - } |
|
| 71 | - $stmt->close(); |
|
| 72 | - return $name; |
|
| 63 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 64 | + $stmt->bind_param("s", $id); |
|
| 65 | + $stmt->execute(); |
|
| 66 | + $result = $stmt->get_result(); |
|
| 67 | + if($result->num_rows === 0) return('error'); |
|
| 68 | + while($row = $result->fetch_assoc()) { |
|
| 69 | + $name = htmlspecialchars($row['username']); |
|
| 70 | + } |
|
| 71 | + $stmt->close(); |
|
| 72 | + return $name; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function getPFP($user, $connection) { |
| 76 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 77 | - $stmt->bind_param("s", $user); |
|
| 78 | - $stmt->execute(); |
|
| 79 | - $result = $stmt->get_result(); |
|
| 80 | - if($result->num_rows === 0) return('error'); |
|
| 81 | - while($row = $result->fetch_assoc()) { |
|
| 82 | - $pfp = htmlspecialchars($row['pfp']); |
|
| 83 | - } |
|
| 84 | - $stmt->close(); |
|
| 85 | - return $pfp; |
|
| 76 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 77 | + $stmt->bind_param("s", $user); |
|
| 78 | + $stmt->execute(); |
|
| 79 | + $result = $stmt->get_result(); |
|
| 80 | + if($result->num_rows === 0) return('error'); |
|
| 81 | + while($row = $result->fetch_assoc()) { |
|
| 82 | + $pfp = htmlspecialchars($row['pfp']); |
|
| 83 | + } |
|
| 84 | + $stmt->close(); |
|
| 85 | + return $pfp; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | function checkIfFriended($friend1, $friend2, $connection) |
| 89 | 89 | { |
| 90 | - $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 91 | - $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 92 | - $stmt->execute(); |
|
| 93 | - $result = $stmt->get_result(); |
|
| 94 | - if($result->num_rows === 1){ return true; } |
|
| 95 | - return false; |
|
| 90 | + $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 91 | + $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 92 | + $stmt->execute(); |
|
| 93 | + $result = $stmt->get_result(); |
|
| 94 | + if($result->num_rows === 1){ return true; } |
|
| 95 | + return false; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | function getUser($id, $connection) { |
| 99 | - $userResult = array(); |
|
| 100 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 101 | - $stmt->bind_param("i", $id); |
|
| 102 | - $stmt->execute(); |
|
| 103 | - $result = $stmt->get_result(); |
|
| 104 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 105 | - while($row = $result->fetch_assoc()) { |
|
| 106 | - $userResult['username'] = $row['username']; |
|
| 107 | - $userResult['id'] = $row['id']; |
|
| 108 | - $userResult['date'] = $row['date']; |
|
| 109 | - $userResult['bio'] = $row['bio']; |
|
| 110 | - $userResult['css'] = $row['css']; |
|
| 111 | - $userResult['pfp'] = $row['pfp']; |
|
| 112 | - $userResult['badges'] = explode(';', $row['badges']); |
|
| 113 | - $userResult['music'] = $row['music']; |
|
| 114 | - $userResult['rank'] = $row['rank']; |
|
| 115 | - $userResult['currentgroup'] = $row['currentgroup']; |
|
| 116 | - } |
|
| 117 | - $stmt->close(); |
|
| 118 | - |
|
| 119 | - $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 120 | - $stmt->bind_param("s", $userResult['username']); |
|
| 121 | - $stmt->execute(); |
|
| 122 | - $result = $stmt->get_result(); |
|
| 123 | - |
|
| 124 | - $userResult['comments'] = 0; |
|
| 125 | - while($row = $result->fetch_assoc()) { |
|
| 126 | - $userResult['comments']++; |
|
| 127 | - } |
|
| 128 | - $stmt->close(); |
|
| 129 | - |
|
| 130 | - $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 131 | - $stmt->bind_param("s", $userResult['username']); |
|
| 132 | - $stmt->execute(); |
|
| 133 | - $result = $stmt->get_result(); |
|
| 134 | - |
|
| 135 | - $userResult['profilecomments'] = 0; |
|
| 136 | - while($row = $result->fetch_assoc()) { |
|
| 137 | - $userResult['profilecomments']++; |
|
| 138 | - } |
|
| 139 | - $stmt->close(); |
|
| 140 | - |
|
| 141 | - $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 142 | - $stmt->bind_param("s", $userResult['username']); |
|
| 143 | - $stmt->execute(); |
|
| 144 | - $result = $stmt->get_result(); |
|
| 145 | - |
|
| 146 | - $userResult['filesuploaded'] = 0; |
|
| 147 | - while($row = $result->fetch_assoc()) { |
|
| 148 | - $userResult['filesuploaded']++; |
|
| 149 | - } |
|
| 150 | - $stmt->close(); |
|
| 151 | - return $userResult; |
|
| 99 | + $userResult = array(); |
|
| 100 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 101 | + $stmt->bind_param("i", $id); |
|
| 102 | + $stmt->execute(); |
|
| 103 | + $result = $stmt->get_result(); |
|
| 104 | + if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 105 | + while($row = $result->fetch_assoc()) { |
|
| 106 | + $userResult['username'] = $row['username']; |
|
| 107 | + $userResult['id'] = $row['id']; |
|
| 108 | + $userResult['date'] = $row['date']; |
|
| 109 | + $userResult['bio'] = $row['bio']; |
|
| 110 | + $userResult['css'] = $row['css']; |
|
| 111 | + $userResult['pfp'] = $row['pfp']; |
|
| 112 | + $userResult['badges'] = explode(';', $row['badges']); |
|
| 113 | + $userResult['music'] = $row['music']; |
|
| 114 | + $userResult['rank'] = $row['rank']; |
|
| 115 | + $userResult['currentgroup'] = $row['currentgroup']; |
|
| 116 | + } |
|
| 117 | + $stmt->close(); |
|
| 118 | + |
|
| 119 | + $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 120 | + $stmt->bind_param("s", $userResult['username']); |
|
| 121 | + $stmt->execute(); |
|
| 122 | + $result = $stmt->get_result(); |
|
| 123 | + |
|
| 124 | + $userResult['comments'] = 0; |
|
| 125 | + while($row = $result->fetch_assoc()) { |
|
| 126 | + $userResult['comments']++; |
|
| 127 | + } |
|
| 128 | + $stmt->close(); |
|
| 129 | + |
|
| 130 | + $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 131 | + $stmt->bind_param("s", $userResult['username']); |
|
| 132 | + $stmt->execute(); |
|
| 133 | + $result = $stmt->get_result(); |
|
| 134 | + |
|
| 135 | + $userResult['profilecomments'] = 0; |
|
| 136 | + while($row = $result->fetch_assoc()) { |
|
| 137 | + $userResult['profilecomments']++; |
|
| 138 | + } |
|
| 139 | + $stmt->close(); |
|
| 140 | + |
|
| 141 | + $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 142 | + $stmt->bind_param("s", $userResult['username']); |
|
| 143 | + $stmt->execute(); |
|
| 144 | + $result = $stmt->get_result(); |
|
| 145 | + |
|
| 146 | + $userResult['filesuploaded'] = 0; |
|
| 147 | + while($row = $result->fetch_assoc()) { |
|
| 148 | + $userResult['filesuploaded']++; |
|
| 149 | + } |
|
| 150 | + $stmt->close(); |
|
| 151 | + return $userResult; |
|
| 152 | 152 | } |
| 153 | 153 | ?> |
| 154 | 154 | \ 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); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | function validateCaptcha($privatekey, $response) { |
| 30 | - $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 30 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $privatekey . '&response=' . $response)); |
|
| 31 | 31 | return $responseData->success; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | $stmt->bind_param("s", $user); |
| 52 | 52 | $stmt->execute(); |
| 53 | 53 | $result = $stmt->get_result(); |
| 54 | - if($result->num_rows === 0) return 'error'; |
|
| 55 | - while($row = $result->fetch_assoc()) { |
|
| 54 | + if ($result->num_rows === 0) return 'error'; |
|
| 55 | + while ($row = $result->fetch_assoc()) { |
|
| 56 | 56 | $id = $row['id']; |
| 57 | 57 | } |
| 58 | 58 | $stmt->close(); |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | $stmt->bind_param("s", $id); |
| 65 | 65 | $stmt->execute(); |
| 66 | 66 | $result = $stmt->get_result(); |
| 67 | - if($result->num_rows === 0) return('error'); |
|
| 68 | - while($row = $result->fetch_assoc()) { |
|
| 67 | + if ($result->num_rows === 0) return('error'); |
|
| 68 | + while ($row = $result->fetch_assoc()) { |
|
| 69 | 69 | $name = htmlspecialchars($row['username']); |
| 70 | 70 | } |
| 71 | 71 | $stmt->close(); |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | $stmt->bind_param("s", $user); |
| 78 | 78 | $stmt->execute(); |
| 79 | 79 | $result = $stmt->get_result(); |
| 80 | - if($result->num_rows === 0) return('error'); |
|
| 81 | - while($row = $result->fetch_assoc()) { |
|
| 80 | + if ($result->num_rows === 0) return('error'); |
|
| 81 | + while ($row = $result->fetch_assoc()) { |
|
| 82 | 82 | $pfp = htmlspecialchars($row['pfp']); |
| 83 | 83 | } |
| 84 | 84 | $stmt->close(); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
| 92 | 92 | $stmt->execute(); |
| 93 | 93 | $result = $stmt->get_result(); |
| 94 | - if($result->num_rows === 1){ return true; } |
|
| 94 | + if ($result->num_rows === 1) { return true; } |
|
| 95 | 95 | return false; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | $stmt->bind_param("i", $id); |
| 102 | 102 | $stmt->execute(); |
| 103 | 103 | $result = $stmt->get_result(); |
| 104 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 105 | - while($row = $result->fetch_assoc()) { |
|
| 104 | + if ($result->num_rows === 0) echo('That user does not exist.'); |
|
| 105 | + while ($row = $result->fetch_assoc()) { |
|
| 106 | 106 | $userResult['username'] = $row['username']; |
| 107 | 107 | $userResult['id'] = $row['id']; |
| 108 | 108 | $userResult['date'] = $row['date']; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $result = $stmt->get_result(); |
| 123 | 123 | |
| 124 | 124 | $userResult['comments'] = 0; |
| 125 | - while($row = $result->fetch_assoc()) { |
|
| 125 | + while ($row = $result->fetch_assoc()) { |
|
| 126 | 126 | $userResult['comments']++; |
| 127 | 127 | } |
| 128 | 128 | $stmt->close(); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $result = $stmt->get_result(); |
| 134 | 134 | |
| 135 | 135 | $userResult['profilecomments'] = 0; |
| 136 | - while($row = $result->fetch_assoc()) { |
|
| 136 | + while ($row = $result->fetch_assoc()) { |
|
| 137 | 137 | $userResult['profilecomments']++; |
| 138 | 138 | } |
| 139 | 139 | $stmt->close(); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $result = $stmt->get_result(); |
| 145 | 145 | |
| 146 | 146 | $userResult['filesuploaded'] = 0; |
| 147 | - while($row = $result->fetch_assoc()) { |
|
| 147 | + while ($row = $result->fetch_assoc()) { |
|
| 148 | 148 | $userResult['filesuploaded']++; |
| 149 | 149 | } |
| 150 | 150 | $stmt->close(); |