@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | <source src="/musicfiles/' . $filename . '"> |
| 70 | 70 | </audio>'; |
| 71 | 71 | } else if($type == "image") { |
| 72 | - echo "<img style='max-width: 100%;' src='/images/" . $filename . "'>"; |
|
| 72 | + echo "<img style='max-width: 100%;' src='/images/" . $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('/midis/" . $filename . "');\">Play " . $title . "</a>"; |
@@ -202,9 +202,9 @@ discard block |
||
| 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="/midis/' . $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="/videos/' . $filename . '" type="video/mp4"> |
| 209 | 209 | </video> '; |
| 210 | 210 | } else { |
@@ -12,131 +12,131 @@ |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | function validateCSS($validate) { |
| 15 | - $DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); |
|
| 15 | + $DISALLOWED = array("<?php", "?>", "behavior: url", ".php", "@import", "@\import", "@/import"); |
|
| 16 | 16 | |
| 17 | - $validated = str_replace($DISALLOWED, "", $validate); |
|
| 17 | + $validated = str_replace($DISALLOWED, "", $validate); |
|
| 18 | 18 | return $validated; |
| 19 | 19 | } |
| 20 | 20 | function validateMarkdown($comment) { |
| 21 | - $markdown = new Michelf\Markdown; |
|
| 22 | - $markdown->no_markup = true; |
|
| 23 | - $transformed = $markdown->transform($comment); |
|
| 24 | - return preg_replace( |
|
| 25 | - "/<a href=(?:'|\")javascript:(.*?)(?:'|\")>(.*?)<\/a>/i", |
|
| 26 | - "Attempted XSS: $2 ($1)", |
|
| 27 | - $transformed |
|
| 28 | - ); |
|
| 21 | + $markdown = new Michelf\Markdown; |
|
| 22 | + $markdown->no_markup = true; |
|
| 23 | + $transformed = $markdown->transform($comment); |
|
| 24 | + return preg_replace( |
|
| 25 | + "/<a href=(?:'|\")javascript:(.*?)(?:'|\")>(.*?)<\/a>/i", |
|
| 26 | + "Attempted XSS: $2 ($1)", |
|
| 27 | + $transformed |
|
| 28 | + ); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | function validateCaptcha($privatekey, $response) { |
| 32 | - $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 33 | - return $responseData->success; |
|
| 32 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$privatekey.'&response='.$response)); |
|
| 33 | + return $responseData->success; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | function requireLogin() { |
| 37 | - if (!isset($_SESSION['user'])) { |
|
| 38 | - header("Location: /login.php?r_login"); die(); |
|
| 39 | - } |
|
| 37 | + if (!isset($_SESSION['user'])) { |
|
| 38 | + header("Location: /login.php?r_login"); die(); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function getID($user, $connection) { |
| 43 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 44 | - $stmt->bind_param("s", $user); |
|
| 45 | - $stmt->execute(); |
|
| 46 | - $result = $stmt->get_result(); |
|
| 47 | - if($result->num_rows === 0) return 'error'; |
|
| 48 | - while($row = $result->fetch_assoc()) { |
|
| 49 | - $id = $row['id']; |
|
| 50 | - } |
|
| 51 | - $stmt->close(); |
|
| 52 | - return $id; |
|
| 43 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 44 | + $stmt->bind_param("s", $user); |
|
| 45 | + $stmt->execute(); |
|
| 46 | + $result = $stmt->get_result(); |
|
| 47 | + if($result->num_rows === 0) return 'error'; |
|
| 48 | + while($row = $result->fetch_assoc()) { |
|
| 49 | + $id = $row['id']; |
|
| 50 | + } |
|
| 51 | + $stmt->close(); |
|
| 52 | + return $id; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | function getName($id, $connection) { |
| 56 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 57 | - $stmt->bind_param("s", $id); |
|
| 58 | - $stmt->execute(); |
|
| 59 | - $result = $stmt->get_result(); |
|
| 60 | - if($result->num_rows === 0) return('error'); |
|
| 61 | - while($row = $result->fetch_assoc()) { |
|
| 62 | - $name = htmlspecialchars($row['username']); |
|
| 63 | - } |
|
| 64 | - $stmt->close(); |
|
| 65 | - return $name; |
|
| 56 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 57 | + $stmt->bind_param("s", $id); |
|
| 58 | + $stmt->execute(); |
|
| 59 | + $result = $stmt->get_result(); |
|
| 60 | + if($result->num_rows === 0) return('error'); |
|
| 61 | + while($row = $result->fetch_assoc()) { |
|
| 62 | + $name = htmlspecialchars($row['username']); |
|
| 63 | + } |
|
| 64 | + $stmt->close(); |
|
| 65 | + return $name; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | function getPFP($user, $connection) { |
| 69 | - $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 70 | - $stmt->bind_param("s", $user); |
|
| 71 | - $stmt->execute(); |
|
| 72 | - $result = $stmt->get_result(); |
|
| 73 | - if($result->num_rows === 0) return('error'); |
|
| 74 | - while($row = $result->fetch_assoc()) { |
|
| 75 | - $pfp = htmlspecialchars($row['pfp']); |
|
| 76 | - } |
|
| 77 | - $stmt->close(); |
|
| 78 | - return $pfp; |
|
| 69 | + $stmt = $connection->prepare("SELECT * FROM users WHERE username = ?"); |
|
| 70 | + $stmt->bind_param("s", $user); |
|
| 71 | + $stmt->execute(); |
|
| 72 | + $result = $stmt->get_result(); |
|
| 73 | + if($result->num_rows === 0) return('error'); |
|
| 74 | + while($row = $result->fetch_assoc()) { |
|
| 75 | + $pfp = htmlspecialchars($row['pfp']); |
|
| 76 | + } |
|
| 77 | + $stmt->close(); |
|
| 78 | + return $pfp; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | function checkIfFriended($friend1, $friend2, $connection) |
| 82 | 82 | { |
| 83 | - $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 84 | - $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 85 | - $stmt->execute(); |
|
| 86 | - $result = $stmt->get_result(); |
|
| 87 | - if($result->num_rows === 1){ return true; } |
|
| 88 | - return false; |
|
| 83 | + $stmt = $connection->prepare("SELECT * FROM `friends` WHERE reciever = ? AND sender = ? OR reciever = ? AND sender = ?"); |
|
| 84 | + $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
|
| 85 | + $stmt->execute(); |
|
| 86 | + $result = $stmt->get_result(); |
|
| 87 | + if($result->num_rows === 1){ return true; } |
|
| 88 | + return false; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | function getUser($id, $connection) { |
| 92 | - $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 93 | - $stmt->bind_param("i", $id); |
|
| 94 | - $stmt->execute(); |
|
| 95 | - $result = $stmt->get_result(); |
|
| 96 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 97 | - while($row = $result->fetch_assoc()) { |
|
| 98 | - $username = $row['username']; |
|
| 99 | - $id = $row['id']; |
|
| 100 | - $date = $row['date']; |
|
| 101 | - $bio = $row['bio']; |
|
| 102 | - $css = $row['css']; |
|
| 103 | - $pfp = $row['pfp']; |
|
| 104 | - $badges = explode(';', $row['badges']); |
|
| 105 | - $music = $row['music']; |
|
| 106 | - } |
|
| 107 | - $stmt->close(); |
|
| 108 | - |
|
| 109 | - $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 110 | - $stmt->bind_param("s", $username); |
|
| 111 | - $stmt->execute(); |
|
| 112 | - $result = $stmt->get_result(); |
|
| 113 | - |
|
| 114 | - $comments = 0; |
|
| 115 | - while($row = $result->fetch_assoc()) { |
|
| 116 | - $comments++; |
|
| 117 | - } |
|
| 118 | - $stmt->close(); |
|
| 119 | - |
|
| 120 | - $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 121 | - $stmt->bind_param("s", $username); |
|
| 122 | - $stmt->execute(); |
|
| 123 | - $result = $stmt->get_result(); |
|
| 124 | - |
|
| 125 | - $profilecomments = 0; |
|
| 126 | - while($row = $result->fetch_assoc()) { |
|
| 127 | - $profilecomments++; |
|
| 128 | - } |
|
| 129 | - $stmt->close(); |
|
| 130 | - |
|
| 131 | - $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 132 | - $stmt->bind_param("s", $username); |
|
| 133 | - $stmt->execute(); |
|
| 134 | - $result = $stmt->get_result(); |
|
| 135 | - |
|
| 136 | - $filesuploaded = 0; |
|
| 137 | - while($row = $result->fetch_assoc()) { |
|
| 138 | - $filesuploaded++; |
|
| 139 | - } |
|
| 140 | - $stmt->close(); |
|
| 92 | + $stmt = $connection->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 93 | + $stmt->bind_param("i", $id); |
|
| 94 | + $stmt->execute(); |
|
| 95 | + $result = $stmt->get_result(); |
|
| 96 | + if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 97 | + while($row = $result->fetch_assoc()) { |
|
| 98 | + $username = $row['username']; |
|
| 99 | + $id = $row['id']; |
|
| 100 | + $date = $row['date']; |
|
| 101 | + $bio = $row['bio']; |
|
| 102 | + $css = $row['css']; |
|
| 103 | + $pfp = $row['pfp']; |
|
| 104 | + $badges = explode(';', $row['badges']); |
|
| 105 | + $music = $row['music']; |
|
| 106 | + } |
|
| 107 | + $stmt->close(); |
|
| 108 | + |
|
| 109 | + $stmt = $connection->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 110 | + $stmt->bind_param("s", $username); |
|
| 111 | + $stmt->execute(); |
|
| 112 | + $result = $stmt->get_result(); |
|
| 113 | + |
|
| 114 | + $comments = 0; |
|
| 115 | + while($row = $result->fetch_assoc()) { |
|
| 116 | + $comments++; |
|
| 117 | + } |
|
| 118 | + $stmt->close(); |
|
| 119 | + |
|
| 120 | + $stmt = $connection->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 121 | + $stmt->bind_param("s", $username); |
|
| 122 | + $stmt->execute(); |
|
| 123 | + $result = $stmt->get_result(); |
|
| 124 | + |
|
| 125 | + $profilecomments = 0; |
|
| 126 | + while($row = $result->fetch_assoc()) { |
|
| 127 | + $profilecomments++; |
|
| 128 | + } |
|
| 129 | + $stmt->close(); |
|
| 130 | + |
|
| 131 | + $stmt = $connection->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 132 | + $stmt->bind_param("s", $username); |
|
| 133 | + $stmt->execute(); |
|
| 134 | + $result = $stmt->get_result(); |
|
| 135 | + |
|
| 136 | + $filesuploaded = 0; |
|
| 137 | + while($row = $result->fetch_assoc()) { |
|
| 138 | + $filesuploaded++; |
|
| 139 | + } |
|
| 140 | + $stmt->close(); |
|
| 141 | 141 | } |
| 142 | 142 | ?> |
| 143 | 143 | \ No newline at end of file |