@@ -11,146 +11,146 @@ |
||
| 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 getUser($id, $connection) { |
| 102 | - $userResult = array(); |
|
| 103 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 104 | - $stmt->bind_param("i", $id); |
|
| 105 | - $stmt->execute(); |
|
| 106 | - $result = $stmt->get_result(); |
|
| 107 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 108 | - while($row = $result->fetch_assoc()) { |
|
| 109 | - $userResult['username'] = $row['username']; |
|
| 110 | - $userResult['id'] = $row['id']; |
|
| 111 | - $userResult['date'] = $row['date']; |
|
| 112 | - $userResult['bio'] = $row['bio']; |
|
| 113 | - $userResult['css'] = $row['css']; |
|
| 114 | - $userResult['pfp'] = $row['pfp']; |
|
| 115 | - $userResult['badges'] = explode(';', $row['badges']); |
|
| 116 | - $userResult['music'] = $row['music']; |
|
| 117 | - $userResult['rank'] = $row['rank']; |
|
| 118 | - $userResult['currentgroup'] = $row['currentgroup']; |
|
| 119 | - } |
|
| 120 | - $stmt->close(); |
|
| 121 | - |
|
| 122 | - $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 123 | - $stmt->bind_param("s", $userResult['username']); |
|
| 124 | - $stmt->execute(); |
|
| 125 | - $result = $stmt->get_result(); |
|
| 126 | - |
|
| 127 | - $userResult['comments'] = 0; |
|
| 128 | - while($row = $result->fetch_assoc()) { |
|
| 129 | - $userResult['comments']++; |
|
| 130 | - } |
|
| 131 | - $stmt->close(); |
|
| 132 | - |
|
| 133 | - $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 134 | - $stmt->bind_param("s", $userResult['username']); |
|
| 135 | - $stmt->execute(); |
|
| 136 | - $result = $stmt->get_result(); |
|
| 137 | - |
|
| 138 | - $userResult['profilecomments'] = 0; |
|
| 139 | - while($row = $result->fetch_assoc()) { |
|
| 140 | - $userResult['profilecomments']++; |
|
| 141 | - } |
|
| 142 | - $stmt->close(); |
|
| 143 | - |
|
| 144 | - $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 145 | - $stmt->bind_param("s", $userResult['username']); |
|
| 146 | - $stmt->execute(); |
|
| 147 | - $result = $stmt->get_result(); |
|
| 148 | - |
|
| 149 | - $userResult['filesuploaded'] = 0; |
|
| 150 | - while($row = $result->fetch_assoc()) { |
|
| 151 | - $userResult['filesuploaded']++; |
|
| 152 | - } |
|
| 153 | - $stmt->close(); |
|
| 154 | - return $userResult; |
|
| 102 | + $userResult = array(); |
|
| 103 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 104 | + $stmt->bind_param("i", $id); |
|
| 105 | + $stmt->execute(); |
|
| 106 | + $result = $stmt->get_result(); |
|
| 107 | + if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 108 | + while($row = $result->fetch_assoc()) { |
|
| 109 | + $userResult['username'] = $row['username']; |
|
| 110 | + $userResult['id'] = $row['id']; |
|
| 111 | + $userResult['date'] = $row['date']; |
|
| 112 | + $userResult['bio'] = $row['bio']; |
|
| 113 | + $userResult['css'] = $row['css']; |
|
| 114 | + $userResult['pfp'] = $row['pfp']; |
|
| 115 | + $userResult['badges'] = explode(';', $row['badges']); |
|
| 116 | + $userResult['music'] = $row['music']; |
|
| 117 | + $userResult['rank'] = $row['rank']; |
|
| 118 | + $userResult['currentgroup'] = $row['currentgroup']; |
|
| 119 | + } |
|
| 120 | + $stmt->close(); |
|
| 121 | + |
|
| 122 | + $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 123 | + $stmt->bind_param("s", $userResult['username']); |
|
| 124 | + $stmt->execute(); |
|
| 125 | + $result = $stmt->get_result(); |
|
| 126 | + |
|
| 127 | + $userResult['comments'] = 0; |
|
| 128 | + while($row = $result->fetch_assoc()) { |
|
| 129 | + $userResult['comments']++; |
|
| 130 | + } |
|
| 131 | + $stmt->close(); |
|
| 132 | + |
|
| 133 | + $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 134 | + $stmt->bind_param("s", $userResult['username']); |
|
| 135 | + $stmt->execute(); |
|
| 136 | + $result = $stmt->get_result(); |
|
| 137 | + |
|
| 138 | + $userResult['profilecomments'] = 0; |
|
| 139 | + while($row = $result->fetch_assoc()) { |
|
| 140 | + $userResult['profilecomments']++; |
|
| 141 | + } |
|
| 142 | + $stmt->close(); |
|
| 143 | + |
|
| 144 | + $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 145 | + $stmt->bind_param("s", $userResult['username']); |
|
| 146 | + $stmt->execute(); |
|
| 147 | + $result = $stmt->get_result(); |
|
| 148 | + |
|
| 149 | + $userResult['filesuploaded'] = 0; |
|
| 150 | + while($row = $result->fetch_assoc()) { |
|
| 151 | + $userResult['filesuploaded']++; |
|
| 152 | + } |
|
| 153 | + $stmt->close(); |
|
| 154 | + return $userResult; |
|
| 155 | 155 | } |
| 156 | 156 | ?> |
| 157 | 157 | \ No newline at end of file |