@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | <body> |
| 13 | 13 | <?php require(__DIR__ . "/important/header.php"); |
| 14 | 14 | |
| 15 | - if(@$_POST['submit']) { |
|
| 16 | - if(isset($_SESSION['user'])) { |
|
| 15 | + if (@$_POST['submit']) { |
|
| 16 | + if (isset($_SESSION['user'])) { |
|
| 17 | 17 | $target_dir = __DIR__ . "/videos/"; |
| 18 | 18 | $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); |
| 19 | 19 | $uploadOk = 1; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | echo 'file with the same name already exists<hr>'; |
| 24 | 24 | $uploadOk = 0; |
| 25 | 25 | } |
| 26 | - if($imageFileType != "mp4") { |
|
| 26 | + if ($imageFileType != "mp4") { |
|
| 27 | 27 | echo 'unsupported file type. must be swf<hr>'; |
| 28 | 28 | $uploadOk = 0; |
| 29 | 29 | } |
@@ -12,35 +12,35 @@ discard block |
||
| 12 | 12 | <link rel="stylesheet" href="/css/header.css"> |
| 13 | 13 | </head> |
| 14 | 14 | <body> |
| 15 | - <?php require(__DIR__ . "/important/header.php"); ?> |
|
| 15 | + <?php require(__DIR__ . "/important/header.php"); ?> |
|
| 16 | 16 | <center><h1 style="display: inline-block;">4Grounds - Register</h1><br> |
| 17 | 17 | <?php |
| 18 | - if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) |
|
| 18 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) |
|
| 19 | 19 | { |
| 20 | 20 | $email = htmlspecialchars(@$_POST['email']); |
| 21 | 21 | $username = htmlspecialchars(@$_POST['username']); |
| 22 | 22 | $password = @$_POST['password']; |
| 23 | 23 | $passwordhash = password_hash(@$password, PASSWORD_DEFAULT); |
| 24 | 24 | |
| 25 | - if($_POST['password'] !== $_POST['confirm']){ $error = "password and confirmation password do not match"; goto skip; } |
|
| 25 | + if ($_POST['password'] !== $_POST['confirm']) { $error = "password and confirmation password do not match"; goto skip; } |
|
| 26 | 26 | |
| 27 | - if(strlen($username) > 21) { $error = "your username must be shorter than 21 characters"; goto skip; } |
|
| 28 | - if(strlen($password) < 8) { $error = "your password must be at least 8 characters long"; goto skip; } |
|
| 29 | - 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; } |
|
| 30 | - if(!isset($_POST['g-recaptcha-response'])){ $error = "captcha validation failed"; goto skip; } |
|
| 31 | - if(!validateCaptcha(CAPTCHA_PRIVATEKEY, $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; } |
|
| 27 | + if (strlen($username) > 21) { $error = "your username must be shorter than 21 characters"; goto skip; } |
|
| 28 | + if (strlen($password) < 8) { $error = "your password must be at least 8 characters long"; goto skip; } |
|
| 29 | + 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; } |
|
| 30 | + if (!isset($_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; } |
|
| 31 | + if (!validateCaptcha(CAPTCHA_PRIVATEKEY, $_POST['g-recaptcha-response'])) { $error = "captcha validation failed"; goto skip; } |
|
| 32 | 32 | |
| 33 | 33 | $stmt = $conn->prepare("SELECT username FROM users WHERE username = ?"); |
| 34 | 34 | $stmt->bind_param("s", $username); |
| 35 | 35 | $stmt->execute(); |
| 36 | 36 | $result = $stmt->get_result(); |
| 37 | - if($result->num_rows) { $error = "there's already a user with that same name!"; goto skip; } |
|
| 37 | + if ($result->num_rows) { $error = "there's already a user with that same name!"; goto skip; } |
|
| 38 | 38 | |
| 39 | 39 | $stmt = $conn->prepare("SELECT email FROM users WHERE email = ?"); |
| 40 | 40 | $stmt->bind_param("s", $email); |
| 41 | 41 | $stmt->execute(); |
| 42 | 42 | $result = $stmt->get_result(); |
| 43 | - if($result->num_rows) { $error = "there's already a user with that same email!"; goto skip; } |
|
| 43 | + if ($result->num_rows) { $error = "there's already a user with that same email!"; goto skip; } |
|
| 44 | 44 | |
| 45 | 45 | //TODO: add cloudflare ip thing |
| 46 | 46 | $stmt = $conn->prepare("INSERT INTO `users` (`username`, `email`, `password`) VALUES (?, ?, ?)"); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | skip: |
| 62 | 62 | |
| 63 | - if(isset($error)) { echo "<small style='color:red'>".$error."</small>"; } ?> |
|
| 63 | + if (isset($error)) { echo "<small style='color:red'>" . $error . "</small>"; } ?> |
|
| 64 | 64 | <form method="post"> |
| 65 | 65 | <input required placeholder="Username" type="text" name="username"><br> |
| 66 | 66 | <input required placeholder="E-Mail" type="email" name="email"><br><br> |
@@ -14,32 +14,32 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class BBCode |
| 16 | 16 | { |
| 17 | - // Tag aliases. Item on left translates to item on right. |
|
| 18 | - const TAG_ALIAS = [ |
|
| 17 | + // Tag aliases. Item on left translates to item on right. |
|
| 18 | + const TAG_ALIAS = [ |
|
| 19 | 19 | 'url' => 'a', |
| 20 | 20 | 'code' => 'pre', |
| 21 | 21 | 'quote' => 'blockquote', |
| 22 | 22 | '*' => 'li' |
| 23 | - ]; |
|
| 23 | + ]; |
|
| 24 | 24 | |
| 25 | - // helper function: normalize a potential "tag" |
|
| 26 | - // convert to lowercase and check against the alias list |
|
| 27 | - // returns a named array with details about the tag |
|
| 28 | - static private function decode_tag($input) : array |
|
| 29 | - { |
|
| 25 | + // helper function: normalize a potential "tag" |
|
| 26 | + // convert to lowercase and check against the alias list |
|
| 27 | + // returns a named array with details about the tag |
|
| 28 | + static private function decode_tag($input) : array |
|
| 29 | + { |
|
| 30 | 30 | // first determine if it's opening on closing tag, then substr out the inner portion |
| 31 | 31 | if ($input[1] === '/') { |
| 32 | - $open = 0; |
|
| 33 | - $inner = substr($input, 2, -1); |
|
| 32 | + $open = 0; |
|
| 33 | + $inner = substr($input, 2, -1); |
|
| 34 | 34 | } else { |
| 35 | - $open = 1; |
|
| 36 | - $inner = substr($input, 1, -1); |
|
| 35 | + $open = 1; |
|
| 36 | + $inner = substr($input, 1, -1); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // oneliner to burst inner by spaces, then burst each of those by equals signs |
| 40 | 40 | $params = array_map( |
| 41 | - function(&$a) { return explode('=', $a, 2); }, |
|
| 42 | - explode(' ', $inner)); |
|
| 41 | + function(&$a) { return explode('=', $a, 2); }, |
|
| 42 | + explode(' ', $inner)); |
|
| 43 | 43 | |
| 44 | 44 | // first "param" is special - it's the tag name and (optionally) the default arg |
| 45 | 45 | $first = array_shift($params); |
@@ -47,29 +47,29 @@ discard block |
||
| 47 | 47 | // tag name |
| 48 | 48 | $name = strtolower($first[0]); |
| 49 | 49 | if (isset(self::TAG_ALIAS[$name])) { |
| 50 | - $name = self::TAG_ALIAS[$name]; |
|
| 50 | + $name = self::TAG_ALIAS[$name]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // "default" (unnamed) argument |
| 54 | 54 | $args = null; |
| 55 | 55 | if (isset ($first[1])) { |
| 56 | - $args['default'] = $first[1]; |
|
| 56 | + $args['default'] = $first[1]; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // finally, put the rest of the args in the list |
| 60 | 60 | //array_walk( $params, function(&$a, $i, &$args) { print_r($args); $args[strtolower($a[1])] = $a[0]; }, $args); |
| 61 | 61 | foreach ($params as &$param) { |
| 62 | - $k = isset($param[0]) ? strtolower($param[0]) : ''; |
|
| 63 | - $v = isset($param[1]) ? $param[1] : ''; |
|
| 64 | - $args[$k] = $v; |
|
| 62 | + $k = isset($param[0]) ? strtolower($param[0]) : ''; |
|
| 63 | + $v = isset($param[1]) ? $param[1] : ''; |
|
| 64 | + $args[$k] = $v; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return [ 'name' => $name, 'open' => $open, 'args' => $args ]; |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - // helper function: normalize HTML entities, with newline handling |
|
| 71 | - static private function encode($input) : string |
|
| 72 | - { |
|
| 70 | + // helper function: normalize HTML entities, with newline handling |
|
| 71 | + static private function encode($input) : string |
|
| 72 | + { |
|
| 73 | 73 | // break substring into individual unicode chars |
| 74 | 74 | $characters = preg_split('//u', $input, null, PREG_SPLIT_NO_EMPTY); |
| 75 | 75 | |
@@ -79,19 +79,19 @@ discard block |
||
| 79 | 79 | foreach ($characters as &$ch) |
| 80 | 80 | { |
| 81 | 81 | if ($ch === '\n') { |
| 82 | - $output .= "\n<br>"; |
|
| 82 | + $output .= "\n<br>"; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | if ($ch === '<') { |
| 86 | - $output .= '<'; |
|
| 86 | + $output .= '<'; |
|
| 87 | 87 | } elseif ($ch === '>') { |
| 88 | - $output .= '>'; |
|
| 88 | + $output .= '>'; |
|
| 89 | 89 | } elseif ($ch === '&') { |
| 90 | - $output .= '&'; |
|
| 90 | + $output .= '&'; |
|
| 91 | 91 | } elseif ($ch === "\u{00A0}") { |
| 92 | - $output .= ' '; |
|
| 92 | + $output .= ' '; |
|
| 93 | 93 | } else { |
| 94 | - $output .= $ch; |
|
| 94 | + $output .= $ch; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | return $output; |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - // Renders a BBCode string to HTML, for inclusion into a document. |
|
| 106 | - static public function bbcode_to_html($input) : string |
|
| 107 | - { |
|
| 105 | + // Renders a BBCode string to HTML, for inclusion into a document. |
|
| 106 | + static public function bbcode_to_html($input) : string |
|
| 107 | + { |
|
| 108 | 108 | // split input string into array using regex, UTF-8 aware |
| 109 | 109 | // this should give us tokens to work with |
| 110 | 110 | |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | // ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 -._~:/?#@!$&'()*+,;=% |
| 114 | 114 | // Square brackets are technically allowed, but excluded here, because they interfere. |
| 115 | 115 | $match_count = preg_match_all("/\[[A-Za-z0-9 \-._~:\/?#@!$&'()*+,;=%]+\]/u", |
| 116 | - $input, $matches, PREG_OFFSET_CAPTURE); |
|
| 116 | + $input, $matches, PREG_OFFSET_CAPTURE); |
|
| 117 | 117 | if ($match_count === FALSE) { |
| 118 | - throw new RuntimeException('Fatal error in preg_match_all for BBCode tags'); |
|
| 118 | + throw new RuntimeException('Fatal error in preg_match_all for BBCode tags'); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | // begin with the empty string |
@@ -125,31 +125,31 @@ discard block |
||
| 125 | 125 | $stack = []; |
| 126 | 126 | for ($match_idx = 0; $match_idx < $match_count; $match_idx ++) |
| 127 | 127 | { |
| 128 | - list($match, $offset) = $matches[0][$match_idx]; |
|
| 128 | + list($match, $offset) = $matches[0][$match_idx]; |
|
| 129 | 129 | |
| 130 | - // pick up chars between tags and HTML-encode them |
|
| 131 | - $output .= self::encode(substr($input, $input_ptr, $offset - $input_ptr)); |
|
| 132 | - // advance input_ptr to just past the current tag |
|
| 133 | - $input_ptr = $offset + strlen($match); |
|
| 130 | + // pick up chars between tags and HTML-encode them |
|
| 131 | + $output .= self::encode(substr($input, $input_ptr, $offset - $input_ptr)); |
|
| 132 | + // advance input_ptr to just past the current tag |
|
| 133 | + $input_ptr = $offset + strlen($match); |
|
| 134 | 134 | |
| 135 | - // decode the tag |
|
| 136 | - list('name' => $name, 'open' => $open, 'args' => $args) = self::decode_tag($match); |
|
| 135 | + // decode the tag |
|
| 136 | + list('name' => $name, 'open' => $open, 'args' => $args) = self::decode_tag($match); |
|
| 137 | 137 | |
| 138 | - if (! $open) { |
|
| 138 | + if (! $open) { |
|
| 139 | 139 | // CLOSING TAG |
| 140 | 140 | |
| 141 | 141 | // Search the tag stack and see if the opening tag was pushed into it |
| 142 | 142 | if (array_search($name, $stack, TRUE) === FALSE) { |
| 143 | - // Attempted to close a tag that was not on the stack! |
|
| 144 | - $output = $output . self::encode($match); |
|
| 143 | + // Attempted to close a tag that was not on the stack! |
|
| 144 | + $output = $output . self::encode($match); |
|
| 145 | 145 | } else { |
| 146 | - //pop repeatedly until we pop the tag, and close everything on the way |
|
| 147 | - do { |
|
| 146 | + //pop repeatedly until we pop the tag, and close everything on the way |
|
| 147 | + do { |
|
| 148 | 148 | $popped_name = array_pop($stack); |
| 149 | 149 | $output = $output . '</' . $popped_name . '>'; |
| 150 | - } while ($name !== $popped_name); |
|
| 150 | + } while ($name !== $popped_name); |
|
| 151 | 151 | } |
| 152 | - } else { |
|
| 152 | + } else { |
|
| 153 | 153 | // OPENING TAG |
| 154 | 154 | |
| 155 | 155 | // Big if / elseif ladder to handle each tag |
@@ -157,77 +157,77 @@ discard block |
||
| 157 | 157 | $name === 'blockquote' || |
| 158 | 158 | $name === 'ol' || $name === 'ul' || |
| 159 | 159 | $name === 'table') { |
| 160 | - // Simple tags (no validation or alternate modes) |
|
| 161 | - $stack[] = $name; |
|
| 162 | - $output = $output . '<' . $name . '>'; |
|
| 160 | + // Simple tags (no validation or alternate modes) |
|
| 161 | + $stack[] = $name; |
|
| 162 | + $output = $output . '<' . $name . '>'; |
|
| 163 | 163 | } elseif ($name === 'li') { |
| 164 | - // Disallow [li] outside of [ol] or [ul] |
|
| 165 | - if (array_search('ol', $stack, TRUE) !== FALSE || |
|
| 164 | + // Disallow [li] outside of [ol] or [ul] |
|
| 165 | + if (array_search('ol', $stack, TRUE) !== FALSE || |
|
| 166 | 166 | array_search('ul', $stack, TRUE) !== FALSE) { |
| 167 | 167 | $stack[] = 'li'; |
| 168 | 168 | $output .= '<li>'; |
| 169 | - } else { |
|
| 169 | + } else { |
|
| 170 | 170 | $output .= self::encode($match); |
| 171 | - } |
|
| 171 | + } |
|
| 172 | 172 | } elseif ($name === 'tr') { |
| 173 | - // Disallow [tr] outside of [table] |
|
| 174 | - if (array_search('table', $stack, TRUE) !== FALSE) { |
|
| 173 | + // Disallow [tr] outside of [table] |
|
| 174 | + if (array_search('table', $stack, TRUE) !== FALSE) { |
|
| 175 | 175 | $stack[] = 'tr'; |
| 176 | 176 | $output .= '<tr>'; |
| 177 | - } else { |
|
| 177 | + } else { |
|
| 178 | 178 | $output .= self::encode($match); |
| 179 | - } |
|
| 179 | + } |
|
| 180 | 180 | } elseif ($name === 'td' || $name === 'th') { |
| 181 | - // Disallow [th] / [td] outside of [tr] outside of [table] |
|
| 182 | - $tr_index = array_search('tr', $stack, TRUE); |
|
| 183 | - $table_index = array_search('table', $stack, TRUE); |
|
| 184 | - if ($tr_index !== FALSE && $table_index !== FALSE && $table_index < $tr_index) { |
|
| 181 | + // Disallow [th] / [td] outside of [tr] outside of [table] |
|
| 182 | + $tr_index = array_search('tr', $stack, TRUE); |
|
| 183 | + $table_index = array_search('table', $stack, TRUE); |
|
| 184 | + if ($tr_index !== FALSE && $table_index !== FALSE && $table_index < $tr_index) { |
|
| 185 | 185 | $stack[] = $name; |
| 186 | 186 | $output = $output . '<' . $name . '>'; |
| 187 | - } else { |
|
| 187 | + } else { |
|
| 188 | 188 | $output .= self::encode($match); |
| 189 | - } |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | } elseif ($name === 'font') { |
| 192 | - // Font size adjustment. This requires an argument, one of "size" or "color" (or both). |
|
| 193 | - $font_param = []; |
|
| 192 | + // Font size adjustment. This requires an argument, one of "size" or "color" (or both). |
|
| 193 | + $font_param = []; |
|
| 194 | 194 | |
| 195 | - if (isset ($args['size'])) { |
|
| 195 | + if (isset ($args['size'])) { |
|
| 196 | 196 | //TODO: size validation |
| 197 | 197 | $font_param['font-size'] = $args['size']; |
| 198 | - } |
|
| 199 | - if (isset ($args['color'])) { |
|
| 198 | + } |
|
| 199 | + if (isset ($args['color'])) { |
|
| 200 | 200 | //TODO: color validation |
| 201 | 201 | $font_param['color'] = $args['color']; |
| 202 | - } |
|
| 202 | + } |
|
| 203 | 203 | //TODO: handle bad settings |
| 204 | 204 | |
| 205 | - if (! empty($font_param)) { |
|
| 205 | + if (! empty($font_param)) { |
|
| 206 | 206 | $stack[] = 'font'; |
| 207 | 207 | |
| 208 | 208 | // append all css_style params |
| 209 | 209 | $css_style = []; |
| 210 | 210 | foreach ($font_param as $name=>$value) { |
| 211 | - $css_style[] = $name . ': ' . $value; |
|
| 211 | + $css_style[] = $name . ': ' . $value; |
|
| 212 | 212 | } |
| 213 | 213 | $output = $output . '<span style="' . implode(';', $css_style) . '">'; |
| 214 | - } else { |
|
| 214 | + } else { |
|
| 215 | 215 | // Font tag without good args is useless. |
| 216 | 216 | $output .= self::encode($match); |
| 217 | - } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | // SPECIAL TAG HANDLING |
| 220 | 220 | } elseif ($name === 'pre') { |
| 221 | - // [pre] / [code] put us into RAW mode, where nothing is parsed except [/code] |
|
| 221 | + // [pre] / [code] put us into RAW mode, where nothing is parsed except [/code] |
|
| 222 | 222 | |
| 223 | - for ($i = $match_idx + 1; $i < $match_count; $i ++) |
|
| 224 | - { |
|
| 223 | + for ($i = $match_idx + 1; $i < $match_count; $i ++) |
|
| 224 | + { |
|
| 225 | 225 | list($search_match, $search_offset) = $matches[0][$i]; |
| 226 | 226 | $search_tag = self::decode_tag($search_match); |
| 227 | 227 | if (! $search_tag['open'] && $search_tag['name'] === 'pre') { break; } |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - if ($i < $match_count) { |
|
| 230 | + if ($i < $match_count) { |
|
| 231 | 231 | // successfully found ending tag |
| 232 | 232 | |
| 233 | 233 | // encode everything contained between here and there |
@@ -236,31 +236,31 @@ discard block |
||
| 236 | 236 | $input_ptr = $search_offset + strlen($search_match); |
| 237 | 237 | // update search position |
| 238 | 238 | $match_idx = $i; |
| 239 | - } else { |
|
| 239 | + } else { |
|
| 240 | 240 | // Unrecognized type! |
| 241 | 241 | $output .= self::encode($match); |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | } elseif ($name === 'a') { |
| 244 | - // URL handling. Two modes: [a=url]title[/a] and [a]url[/a]. |
|
| 245 | - // Verify enclosing value first. |
|
| 246 | - $buffer = null; |
|
| 247 | - $i = $match_idx + 1; |
|
| 248 | - if ($i < $match_count) { |
|
| 244 | + // URL handling. Two modes: [a=url]title[/a] and [a]url[/a]. |
|
| 245 | + // Verify enclosing value first. |
|
| 246 | + $buffer = null; |
|
| 247 | + $i = $match_idx + 1; |
|
| 248 | + if ($i < $match_count) { |
|
| 249 | 249 | list($search_match, $search_offset) = $matches[0][$i]; |
| 250 | 250 | $search_tag = self::decode_tag($search_match); |
| 251 | 251 | if (! $search_tag['open'] && $search_tag['name'] === 'a') { |
| 252 | - $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
|
| 252 | + $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
|
| 253 | + } |
|
| 253 | 254 | } |
| 254 | - } |
|
| 255 | 255 | |
| 256 | - // matched something in the middle |
|
| 257 | - if (isset($buffer)) { |
|
| 256 | + // matched something in the middle |
|
| 257 | + if (isset($buffer)) { |
|
| 258 | 258 | if (isset($args['default'])) { |
| 259 | - // $buffer is the title |
|
| 260 | - $url = $args['default']; |
|
| 259 | + // $buffer is the title |
|
| 260 | + $url = $args['default']; |
|
| 261 | 261 | } else { |
| 262 | - // $buffer is the url |
|
| 263 | - $url = $buffer; |
|
| 262 | + // $buffer is the url |
|
| 263 | + $url = $buffer; |
|
| 264 | 264 | } |
| 265 | 265 | // emit the tag |
| 266 | 266 | $output = $output . '<a href="' . $url . '">' . self::encode($buffer) . '</a>'; |
@@ -268,43 +268,43 @@ discard block |
||
| 268 | 268 | $input_ptr = $search_offset + strlen($search_match); |
| 269 | 269 | // update search position |
| 270 | 270 | $match_idx = $i; |
| 271 | - } else { |
|
| 271 | + } else { |
|
| 272 | 272 | // Unrecognized type! |
| 273 | 273 | $output .= self::encode($match); |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | 276 | } elseif ($name === 'img') { |
| 277 | - // image handling. [img (optional=args go=here)]url[/img]. |
|
| 278 | - // Verify enclosing value first. |
|
| 279 | - $buffer = null; |
|
| 280 | - $i = $match_idx + 1; |
|
| 281 | - if ($i < $match_count) { |
|
| 277 | + // image handling. [img (optional=args go=here)]url[/img]. |
|
| 278 | + // Verify enclosing value first. |
|
| 279 | + $buffer = null; |
|
| 280 | + $i = $match_idx + 1; |
|
| 281 | + if ($i < $match_count) { |
|
| 282 | 282 | list($search_match, $search_offset) = $matches[0][$i]; |
| 283 | 283 | $search_tag = self::decode_tag($search_match); |
| 284 | 284 | if (! $search_tag['open'] && $search_tag['name'] === 'img') { |
| 285 | - $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
|
| 285 | + $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
|
| 286 | + } |
|
| 286 | 287 | } |
| 287 | - } |
|
| 288 | 288 | |
| 289 | - // matched something in the middle |
|
| 290 | - if (isset($buffer)) { |
|
| 289 | + // matched something in the middle |
|
| 290 | + if (isset($buffer)) { |
|
| 291 | 291 | // Image size adjustment - accepts width and height |
| 292 | 292 | $img_param = []; |
| 293 | 293 | |
| 294 | 294 | if (isset ($args['width'])) { |
| 295 | - //TODO: size validation |
|
| 296 | - $img_param['width'] = $args['width']; |
|
| 295 | + //TODO: size validation |
|
| 296 | + $img_param['width'] = $args['width']; |
|
| 297 | 297 | } |
| 298 | 298 | if (isset ($args['height'])) { |
| 299 | - //TODO: size validation |
|
| 300 | - $img_param['height'] = $args['height']; |
|
| 299 | + //TODO: size validation |
|
| 300 | + $img_param['height'] = $args['height']; |
|
| 301 | 301 | } |
| 302 | 302 | //TODO: handle bad settings |
| 303 | 303 | |
| 304 | 304 | // emit the tag |
| 305 | 305 | $output = $output . '<img src="' . $buffer . '"'; |
| 306 | 306 | foreach ($img_param as $name=>$value) { |
| 307 | - $output = $output . ' ' . $name . '="' . $value . '"'; |
|
| 307 | + $output = $output . ' ' . $name . '="' . $value . '"'; |
|
| 308 | 308 | } |
| 309 | 309 | $output .= '>'; |
| 310 | 310 | |
@@ -312,18 +312,18 @@ discard block |
||
| 312 | 312 | $input_ptr = $search_offset + strlen($search_match); |
| 313 | 313 | // update search position |
| 314 | 314 | $match_idx = $i; |
| 315 | - } else { |
|
| 315 | + } else { |
|
| 316 | 316 | // Unrecognized type! |
| 317 | 317 | $output .= self::encode($match); |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | 320 | // ADD CUSTOM TAGS HERE |
| 321 | 321 | |
| 322 | 322 | } else { |
| 323 | - // Unrecognized type! |
|
| 324 | - $output .= self::encode($match); |
|
| 323 | + // Unrecognized type! |
|
| 324 | + $output .= self::encode($match); |
|
| 325 | + } |
|
| 325 | 326 | } |
| 326 | - } |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // pick up any stray chars and HTML-encode them |
@@ -332,16 +332,16 @@ discard block |
||
| 332 | 332 | // Close any remaining stray tags left on the stack |
| 333 | 333 | while ($stack) |
| 334 | 334 | { |
| 335 | - $tag = array_pop($stack); |
|
| 336 | - $output = $output . '</' . $tag . '>'; |
|
| 335 | + $tag = array_pop($stack); |
|
| 336 | + $output = $output . '</' . $tag . '>'; |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | return $output; |
| 340 | - } |
|
| 340 | + } |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | // procedural |
| 344 | 344 | function bbcode_to_html($input) : string |
| 345 | 345 | { |
| 346 | - return BBCode::bbcode_to_html($input); |
|
| 346 | + return BBCode::bbcode_to_html($input); |
|
| 347 | 347 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $args[$k] = $v; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - return [ 'name' => $name, 'open' => $open, 'args' => $args ]; |
|
| 67 | + return ['name' => $name, 'open' => $open, 'args' => $args]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // helper function: normalize HTML entities, with newline handling |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $input_ptr = 0; |
| 124 | 124 | |
| 125 | 125 | $stack = []; |
| 126 | - for ($match_idx = 0; $match_idx < $match_count; $match_idx ++) |
|
| 126 | + for ($match_idx = 0; $match_idx < $match_count; $match_idx++) |
|
| 127 | 127 | { |
| 128 | 128 | list($match, $offset) = $matches[0][$match_idx]; |
| 129 | 129 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | // decode the tag |
| 136 | 136 | list('name' => $name, 'open' => $open, 'args' => $args) = self::decode_tag($match); |
| 137 | 137 | |
| 138 | - if (! $open) { |
|
| 138 | + if (!$open) { |
|
| 139 | 139 | // CLOSING TAG |
| 140 | 140 | |
| 141 | 141 | // Search the tag stack and see if the opening tag was pushed into it |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | //TODO: handle bad settings |
| 204 | 204 | |
| 205 | - if (! empty($font_param)) { |
|
| 205 | + if (!empty($font_param)) { |
|
| 206 | 206 | $stack[] = 'font'; |
| 207 | 207 | |
| 208 | 208 | // append all css_style params |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | } elseif ($name === 'pre') { |
| 221 | 221 | // [pre] / [code] put us into RAW mode, where nothing is parsed except [/code] |
| 222 | 222 | |
| 223 | - for ($i = $match_idx + 1; $i < $match_count; $i ++) |
|
| 223 | + for ($i = $match_idx + 1; $i < $match_count; $i++) |
|
| 224 | 224 | { |
| 225 | 225 | list($search_match, $search_offset) = $matches[0][$i]; |
| 226 | 226 | $search_tag = self::decode_tag($search_match); |
| 227 | - if (! $search_tag['open'] && $search_tag['name'] === 'pre') { break; } |
|
| 227 | + if (!$search_tag['open'] && $search_tag['name'] === 'pre') { break; } |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | if ($i < $match_count) { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | if ($i < $match_count) { |
| 249 | 249 | list($search_match, $search_offset) = $matches[0][$i]; |
| 250 | 250 | $search_tag = self::decode_tag($search_match); |
| 251 | - if (! $search_tag['open'] && $search_tag['name'] === 'a') { |
|
| 251 | + if (!$search_tag['open'] && $search_tag['name'] === 'a') { |
|
| 252 | 252 | $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | $buffer = null; |
| 280 | 280 | $i = $match_idx + 1; |
| 281 | 281 | if ($i < $match_count) { |
| 282 | - list($search_match, $search_offset) = $matches[0][$i]; |
|
| 282 | + list($search_match, $search_offset) = $matches[0][$i]; |
|
| 283 | 283 | $search_tag = self::decode_tag($search_match); |
| 284 | - if (! $search_tag['open'] && $search_tag['name'] === 'img') { |
|
| 284 | + if (!$search_tag['open'] && $search_tag['name'] === 'img') { |
|
| 285 | 285 | $buffer = substr($input, $input_ptr, $search_offset - $input_ptr); |
| 286 | 286 | } |
| 287 | 287 | } |
@@ -12,136 +12,136 @@ |
||
| 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 | //thanks dzhaugasharov https://gist.github.com/afsalrahim/bc8caf497a4b54c5d75d |
| 92 | 92 | function replaceBBcodes($text) { |
| 93 | - return bbcode_to_html($text); |
|
| 93 | + return bbcode_to_html($text); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | function getUser($id) { |
| 97 | - $stmt = $conn->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 98 | - $stmt->bind_param("i", $id); |
|
| 99 | - $stmt->execute(); |
|
| 100 | - $result = $stmt->get_result(); |
|
| 101 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 102 | - while($row = $result->fetch_assoc()) { |
|
| 103 | - $username = $row['username']; |
|
| 104 | - $id = $row['id']; |
|
| 105 | - $date = $row['date']; |
|
| 106 | - $bio = $row['bio']; |
|
| 107 | - $css = $row['css']; |
|
| 108 | - $pfp = $row['pfp']; |
|
| 109 | - $badges = explode(';', $row['badges']); |
|
| 110 | - $music = $row['music']; |
|
| 111 | - } |
|
| 112 | - $stmt->close(); |
|
| 113 | - |
|
| 114 | - $stmt = $conn->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 115 | - $stmt->bind_param("s", $username); |
|
| 116 | - $stmt->execute(); |
|
| 117 | - $result = $stmt->get_result(); |
|
| 118 | - |
|
| 119 | - $comments = 0; |
|
| 120 | - while($row = $result->fetch_assoc()) { |
|
| 121 | - $comments++; |
|
| 122 | - } |
|
| 123 | - $stmt->close(); |
|
| 124 | - |
|
| 125 | - $stmt = $conn->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 126 | - $stmt->bind_param("s", $username); |
|
| 127 | - $stmt->execute(); |
|
| 128 | - $result = $stmt->get_result(); |
|
| 129 | - |
|
| 130 | - $profilecomments = 0; |
|
| 131 | - while($row = $result->fetch_assoc()) { |
|
| 132 | - $profilecomments++; |
|
| 133 | - } |
|
| 134 | - $stmt->close(); |
|
| 135 | - |
|
| 136 | - $stmt = $conn->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 137 | - $stmt->bind_param("s", $username); |
|
| 138 | - $stmt->execute(); |
|
| 139 | - $result = $stmt->get_result(); |
|
| 140 | - |
|
| 141 | - $filesuploaded = 0; |
|
| 142 | - while($row = $result->fetch_assoc()) { |
|
| 143 | - $filesuploaded++; |
|
| 144 | - } |
|
| 145 | - $stmt->close(); |
|
| 97 | + $stmt = $conn->prepare("SELECT * FROM users WHERE id = ?"); |
|
| 98 | + $stmt->bind_param("i", $id); |
|
| 99 | + $stmt->execute(); |
|
| 100 | + $result = $stmt->get_result(); |
|
| 101 | + if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 102 | + while($row = $result->fetch_assoc()) { |
|
| 103 | + $username = $row['username']; |
|
| 104 | + $id = $row['id']; |
|
| 105 | + $date = $row['date']; |
|
| 106 | + $bio = $row['bio']; |
|
| 107 | + $css = $row['css']; |
|
| 108 | + $pfp = $row['pfp']; |
|
| 109 | + $badges = explode(';', $row['badges']); |
|
| 110 | + $music = $row['music']; |
|
| 111 | + } |
|
| 112 | + $stmt->close(); |
|
| 113 | + |
|
| 114 | + $stmt = $conn->prepare("SELECT * FROM gamecomments WHERE author = ?"); |
|
| 115 | + $stmt->bind_param("s", $username); |
|
| 116 | + $stmt->execute(); |
|
| 117 | + $result = $stmt->get_result(); |
|
| 118 | + |
|
| 119 | + $comments = 0; |
|
| 120 | + while($row = $result->fetch_assoc()) { |
|
| 121 | + $comments++; |
|
| 122 | + } |
|
| 123 | + $stmt->close(); |
|
| 124 | + |
|
| 125 | + $stmt = $conn->prepare("SELECT * FROM comments WHERE author = ?"); |
|
| 126 | + $stmt->bind_param("s", $username); |
|
| 127 | + $stmt->execute(); |
|
| 128 | + $result = $stmt->get_result(); |
|
| 129 | + |
|
| 130 | + $profilecomments = 0; |
|
| 131 | + while($row = $result->fetch_assoc()) { |
|
| 132 | + $profilecomments++; |
|
| 133 | + } |
|
| 134 | + $stmt->close(); |
|
| 135 | + |
|
| 136 | + $stmt = $conn->prepare("SELECT * FROM files WHERE author = ? AND status='y'"); |
|
| 137 | + $stmt->bind_param("s", $username); |
|
| 138 | + $stmt->execute(); |
|
| 139 | + $result = $stmt->get_result(); |
|
| 140 | + |
|
| 141 | + $filesuploaded = 0; |
|
| 142 | + while($row = $result->fetch_assoc()) { |
|
| 143 | + $filesuploaded++; |
|
| 144 | + } |
|
| 145 | + $stmt->close(); |
|
| 146 | 146 | } |
| 147 | 147 | ?> |
| 148 | 148 | \ No newline at end of file |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | define("DEBUG_MODE", true); |
| 7 | 7 | session_start(); |
| 8 | -if(DEBUG_MODE == true) { |
|
| 8 | +if (DEBUG_MODE == true) { |
|
| 9 | 9 | ini_set('display_errors', 1); |
| 10 | 10 | ini_set('display_startup_errors', 1); |
| 11 | 11 | error_reporting(E_ALL); |
@@ -29,7 +29,7 @@ discard block |
||
| 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)); |
|
| 32 | + $responseData = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $privatekey . '&response=' . $response)); |
|
| 33 | 33 | return $responseData->success; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | $stmt->bind_param("s", $user); |
| 45 | 45 | $stmt->execute(); |
| 46 | 46 | $result = $stmt->get_result(); |
| 47 | - if($result->num_rows === 0) return 'error'; |
|
| 48 | - while($row = $result->fetch_assoc()) { |
|
| 47 | + if ($result->num_rows === 0) return 'error'; |
|
| 48 | + while ($row = $result->fetch_assoc()) { |
|
| 49 | 49 | $id = $row['id']; |
| 50 | 50 | } |
| 51 | 51 | $stmt->close(); |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | $stmt->bind_param("s", $id); |
| 58 | 58 | $stmt->execute(); |
| 59 | 59 | $result = $stmt->get_result(); |
| 60 | - if($result->num_rows === 0) return('error'); |
|
| 61 | - while($row = $result->fetch_assoc()) { |
|
| 60 | + if ($result->num_rows === 0) return('error'); |
|
| 61 | + while ($row = $result->fetch_assoc()) { |
|
| 62 | 62 | $name = htmlspecialchars($row['username']); |
| 63 | 63 | } |
| 64 | 64 | $stmt->close(); |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | $stmt->bind_param("s", $user); |
| 71 | 71 | $stmt->execute(); |
| 72 | 72 | $result = $stmt->get_result(); |
| 73 | - if($result->num_rows === 0) return('error'); |
|
| 74 | - while($row = $result->fetch_assoc()) { |
|
| 73 | + if ($result->num_rows === 0) return('error'); |
|
| 74 | + while ($row = $result->fetch_assoc()) { |
|
| 75 | 75 | $pfp = htmlspecialchars($row['pfp']); |
| 76 | 76 | } |
| 77 | 77 | $stmt->close(); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $stmt->bind_param("ssss", $friend1, $friend2, $friend2, $friend1); |
| 85 | 85 | $stmt->execute(); |
| 86 | 86 | $result = $stmt->get_result(); |
| 87 | - if($result->num_rows === 1){ return true; } |
|
| 87 | + if ($result->num_rows === 1) { return true; } |
|
| 88 | 88 | return false; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $stmt->bind_param("i", $id); |
| 99 | 99 | $stmt->execute(); |
| 100 | 100 | $result = $stmt->get_result(); |
| 101 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 102 | - while($row = $result->fetch_assoc()) { |
|
| 101 | + if ($result->num_rows === 0) echo('That user does not exist.'); |
|
| 102 | + while ($row = $result->fetch_assoc()) { |
|
| 103 | 103 | $username = $row['username']; |
| 104 | 104 | $id = $row['id']; |
| 105 | 105 | $date = $row['date']; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $result = $stmt->get_result(); |
| 118 | 118 | |
| 119 | 119 | $comments = 0; |
| 120 | - while($row = $result->fetch_assoc()) { |
|
| 120 | + while ($row = $result->fetch_assoc()) { |
|
| 121 | 121 | $comments++; |
| 122 | 122 | } |
| 123 | 123 | $stmt->close(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $result = $stmt->get_result(); |
| 129 | 129 | |
| 130 | 130 | $profilecomments = 0; |
| 131 | - while($row = $result->fetch_assoc()) { |
|
| 131 | + while ($row = $result->fetch_assoc()) { |
|
| 132 | 132 | $profilecomments++; |
| 133 | 133 | } |
| 134 | 134 | $stmt->close(); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $result = $stmt->get_result(); |
| 140 | 140 | |
| 141 | 141 | $filesuploaded = 0; |
| 142 | - while($row = $result->fetch_assoc()) { |
|
| 142 | + while ($row = $result->fetch_assoc()) { |
|
| 143 | 143 | $filesuploaded++; |
| 144 | 144 | } |
| 145 | 145 | $stmt->close(); |
@@ -44,7 +44,9 @@ discard block |
||
| 44 | 44 | $stmt->bind_param("s", $user); |
| 45 | 45 | $stmt->execute(); |
| 46 | 46 | $result = $stmt->get_result(); |
| 47 | - if($result->num_rows === 0) return 'error'; |
|
| 47 | + if($result->num_rows === 0) { |
|
| 48 | + return 'error'; |
|
| 49 | + } |
|
| 48 | 50 | while($row = $result->fetch_assoc()) { |
| 49 | 51 | $id = $row['id']; |
| 50 | 52 | } |
@@ -57,7 +59,9 @@ discard block |
||
| 57 | 59 | $stmt->bind_param("s", $id); |
| 58 | 60 | $stmt->execute(); |
| 59 | 61 | $result = $stmt->get_result(); |
| 60 | - if($result->num_rows === 0) return('error'); |
|
| 62 | + if($result->num_rows === 0) { |
|
| 63 | + return('error'); |
|
| 64 | + } |
|
| 61 | 65 | while($row = $result->fetch_assoc()) { |
| 62 | 66 | $name = htmlspecialchars($row['username']); |
| 63 | 67 | } |
@@ -70,7 +74,9 @@ discard block |
||
| 70 | 74 | $stmt->bind_param("s", $user); |
| 71 | 75 | $stmt->execute(); |
| 72 | 76 | $result = $stmt->get_result(); |
| 73 | - if($result->num_rows === 0) return('error'); |
|
| 77 | + if($result->num_rows === 0) { |
|
| 78 | + return('error'); |
|
| 79 | + } |
|
| 74 | 80 | while($row = $result->fetch_assoc()) { |
| 75 | 81 | $pfp = htmlspecialchars($row['pfp']); |
| 76 | 82 | } |
@@ -98,7 +104,9 @@ discard block |
||
| 98 | 104 | $stmt->bind_param("i", $id); |
| 99 | 105 | $stmt->execute(); |
| 100 | 106 | $result = $stmt->get_result(); |
| 101 | - if($result->num_rows === 0) echo('That user does not exist.'); |
|
| 107 | + if($result->num_rows === 0) { |
|
| 108 | + echo('That user does not exist.'); |
|
| 109 | + } |
|
| 102 | 110 | while($row = $result->fetch_assoc()) { |
| 103 | 111 | $username = $row['username']; |
| 104 | 112 | $id = $row['id']; |
@@ -8,7 +8,7 @@ discard block |
||
| 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 |
||
| 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="/musicfiles/' . $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 |
||
| 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> "; |
| 52 | 52 | } |
| 53 | 53 | echo "</b><br>" . $row['extrainfo'] . "<br><hr>"; |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | <body> |
| 13 | 13 | <?php require("important/header.php"); |
| 14 | 14 | |
| 15 | - if(@$_POST['submit']) { |
|
| 16 | - if(isset($_SESSION['user'])) { |
|
| 15 | + if (@$_POST['submit']) { |
|
| 16 | + if (isset($_SESSION['user'])) { |
|
| 17 | 17 | $stmt = $conn->prepare("INSERT INTO `groups` (title, description, author) VALUES (?, ?, ?)"); |
| 18 | 18 | $stmt->bind_param("sss", $name, $text, $_SESSION['user']); |
| 19 | 19 | $text = htmlspecialchars($_POST['description']); |
@@ -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 users 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.'); // please just refuse to give a user if this is the case |
|
| 17 | - while($row = $result->fetch_assoc()) { // you dont need to use a loop if its only ever gonna return 1 or 0 |
|
| 16 | + if ($result->num_rows !== 0) { // echo('There are no users.'); // please just refuse to give a user if this is the case |
|
| 17 | + while ($row = $result->fetch_assoc()) { // you dont need to use a loop if its only ever gonna return 1 or 0 |
|
| 18 | 18 | $username = $row['username']; // you dont actually need all of these variables oh my god just use an array |
| 19 | 19 | $id = $row['id']; |
| 20 | 20 | $date = $row['date']; |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | $stmt->bind_param("i", $currentgroup); |
| 39 | 39 | $stmt->execute(); |
| 40 | 40 | $result = $stmt->get_result(); |
| 41 | - if($result->num_rows !== 0){ //echo('There are no users.'); // why again |
|
| 42 | - while($row = $result->fetch_assoc()) { |
|
| 41 | + if ($result->num_rows !== 0) { //echo('There are no users.'); // why again |
|
| 42 | + while ($row = $result->fetch_assoc()) { |
|
| 43 | 43 | $grouptitle = $row['title']; |
| 44 | 44 | } |
| 45 | - }else{ |
|
| 45 | + } else { |
|
| 46 | 46 | $grouptitle = "none"; |
| 47 | 47 | } |
| 48 | 48 | $stmt->close(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $result = $stmt->get_result(); |
| 54 | 54 | |
| 55 | 55 | $comments = 0; |
| 56 | - while($row = $result->fetch_assoc()) { |
|
| 56 | + while ($row = $result->fetch_assoc()) { |
|
| 57 | 57 | $comments++; |
| 58 | 58 | } |
| 59 | 59 | $stmt->close(); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $result = $stmt->get_result(); |
| 65 | 65 | |
| 66 | 66 | $profilecomments = 0; |
| 67 | - while($row = $result->fetch_assoc()) { |
|
| 67 | + while ($row = $result->fetch_assoc()) { |
|
| 68 | 68 | $profilecomments++; |
| 69 | 69 | } |
| 70 | 70 | $stmt->close(); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $result = $stmt->get_result(); |
| 76 | 76 | |
| 77 | 77 | $filesuploaded = 0; |
| 78 | - while($row = $result->fetch_assoc()) { |
|
| 78 | + while ($row = $result->fetch_assoc()) { |
|
| 79 | 79 | $filesuploaded++; |
| 80 | 80 | } |
| 81 | 81 | $stmt->close(); |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | <div class="container"> |
| 96 | 96 | <br> |
| 97 | 97 | <?php |
| 98 | - if($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 98 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') |
|
| 99 | 99 | { |
| 100 | - if(!isset($_SESSION['user'])){ $error = "you are not logged in"; goto skipcomment; } |
|
| 101 | - if(!$_POST['comment']){ $error = "your comment cannot be blank"; goto skipcomment; } |
|
| 102 | - if(strlen($_POST['comment']) > 500){ $error = "your comment must be shorter than 500 characters"; goto skipcomment; } |
|
| 100 | + if (!isset($_SESSION['user'])) { $error = "you are not logged in"; goto skipcomment; } |
|
| 101 | + if (!$_POST['comment']) { $error = "your comment cannot be blank"; goto skipcomment; } |
|
| 102 | + if (strlen($_POST['comment']) > 500) { $error = "your comment must be shorter than 500 characters"; goto skipcomment; } |
|
| 103 | 103 | |
| 104 | 104 | $stmt = $conn->prepare("INSERT INTO `comments` (toid, author, text) VALUES (?, ?, ?)"); |
| 105 | 105 | $stmt->bind_param("sss", $_GET['id'], $_SESSION['user'], $text); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | skipcomment: |
| 113 | 113 | |
| 114 | - if(isset($id)) {?> |
|
| 114 | + if (isset($id)) {?> |
|
| 115 | 115 | <div id="groundtext"><center><h1><?php echo $username; ?>'s Ground</h1></center></div> |
| 116 | 116 | <div class="leftHalf"> |
| 117 | 117 | <div class="notegray"> |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | </center> |
| 122 | 122 | <hr style="border-top: 1px dashed gray;"> |
| 123 | 123 | <div id="userinfo" style="padding-left: 20px;"> |
| 124 | - <span style="color: gold;">Rank:</span> <?php echo $rank;?><br> |
|
| 125 | - <span style="color: gold;">ID:</span> <?php echo $id;?><br> |
|
| 126 | - <span style="color: gold;">Other Comments:</span> <?php echo $comments;?><br> |
|
| 127 | - <span style="color: gold;">Profile Comments:</span> <?php echo $profilecomments;?><br> |
|
| 128 | - <span style="color: gold;">Current Group:</span> <?php echo $grouptitle;?><br> |
|
| 129 | - <span style="color: gold;">Files Uploaded:</span> <?php echo $filesuploaded;?> |
|
| 124 | + <span style="color: gold;">Rank:</span> <?php echo $rank; ?><br> |
|
| 125 | + <span style="color: gold;">ID:</span> <?php echo $id; ?><br> |
|
| 126 | + <span style="color: gold;">Other Comments:</span> <?php echo $comments; ?><br> |
|
| 127 | + <span style="color: gold;">Profile Comments:</span> <?php echo $profilecomments; ?><br> |
|
| 128 | + <span style="color: gold;">Current Group:</span> <?php echo $grouptitle; ?><br> |
|
| 129 | + <span style="color: gold;">Files Uploaded:</span> <?php echo $filesuploaded; ?> |
|
| 130 | 130 | </div><br> |
| 131 | 131 | <?php if (!isset($_GET["ed"])) { ?> |
| 132 | 132 | <audio autoplay controls> |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | </div> |
| 137 | 137 | <br> |
| 138 | 138 | <div class="notegray"> |
| 139 | - <?php if(isset($error)) { echo "<small style='color:red'>".$error."</small>"; } ?> |
|
| 139 | + <?php if (isset($error)) { echo "<small style='color:red'>" . $error . "</small>"; } ?> |
|
| 140 | 140 | <h2>Comment</h2> |
| 141 | 141 | <form method="post" enctype="multipart/form-data"> |
| 142 | 142 | <textarea required cols="33" placeholder="Comment" name="comment"></textarea><br> |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | <div id="badges" class="notegray"> |
| 156 | 156 | <h1>Badges</h1> |
| 157 | 157 | <?php |
| 158 | - foreach($badges as $badge) { |
|
| 159 | - if($badge == "good") { |
|
| 158 | + foreach ($badges as $badge) { |
|
| 159 | + if ($badge == "good") { |
|
| 160 | 160 | echo "<img width='70px;' height='70px;' src='https://cdn.discordapp.com/attachments/740680780740821105/740776214523936808/340juojg3h.png'>"; |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | $stmt->bind_param("s", $username); |
| 169 | 169 | $stmt->execute(); |
| 170 | 170 | $result = $stmt->get_result(); |
| 171 | - if($result->num_rows > 0) echo('<h1>Files</h1>'); |
|
| 171 | + if ($result->num_rows > 0) echo('<h1>Files</h1>'); |
|
| 172 | 172 | |
| 173 | - while($row = $result->fetch_assoc()) { |
|
| 174 | - echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [' , $row['type'] . ']</a><br>'; |
|
| 173 | + while ($row = $result->fetch_assoc()) { |
|
| 174 | + echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [', $row['type'] . ']</a><br>'; |
|
| 175 | 175 | }?> |
| 176 | 176 | </div><br> |
| 177 | 177 | <div id="bio" class="notegray"> |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $stmt->execute(); |
| 186 | 186 | $result = $stmt->get_result(); |
| 187 | 187 | |
| 188 | - while($row = $result->fetch_assoc()) { ?> |
|
| 188 | + while ($row = $result->fetch_assoc()) { ?> |
|
| 189 | 189 | <div class='commentRight' style='display: grid; grid-template-columns: 75% auto; padding:5px;'> |
| 190 | 190 | <div style="word-wrap: break-word;"> |
| 191 | 191 | <small><?php echo $row['date']; ?></small> |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | <a href="/media">Featured</a><br> |
| 221 | 221 | <?php |
| 222 | - if(isset($_SESSION['user'])) { echo "<a href='/home'>Manage</a><br><a href='/files'>Files<a>"; } |
|
| 222 | + if (isset($_SESSION['user'])) { echo "<a href='/home'>Manage</a><br><a href='/files'>Files<a>"; } |
|
| 223 | 223 | ?> |
| 224 | 224 | </div> |
| 225 | 225 | <br> |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $stmt = $conn->prepare("SELECT * FROM files WHERE type='review' AND status='y' ORDER BY RAND() LIMIT 1"); |
| 230 | 230 | $stmt->execute(); |
| 231 | 231 | $result = $stmt->get_result(); |
| 232 | - while($row = $result->fetch_assoc()) { |
|
| 232 | + while ($row = $result->fetch_assoc()) { |
|
| 233 | 233 | echo "<br><img style='height: 5em;position: absolute;border: 1px solid white; width: 5em;' src='/pfp/" . getPFP($row['author'], $conn) . "'> |
| 234 | 234 | <small> |
| 235 | 235 | <a href='/view?id=" . $row['id'] . "'><span style='float:right;color: gold;'><i>[" . $row['agerating'] . "] " . $row['title'] . "</a></i></span><br> |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $stmt = $conn->prepare("SELECT * FROM files WHERE type='news' AND status='y' ORDER BY RAND() LIMIT 1"); |
| 246 | 246 | $stmt->execute(); |
| 247 | 247 | $result = $stmt->get_result(); |
| 248 | - while($row = $result->fetch_assoc()) { |
|
| 248 | + while ($row = $result->fetch_assoc()) { |
|
| 249 | 249 | echo "<br><img style='height: 5em;position: absolute;border: 1px solid white; width: 5em;' src='/pfp/" . getPFP($row['author'], $conn) . "'> |
| 250 | 250 | <small> |
| 251 | 251 | <a href='/view?id=" . $row['id'] . "'><span style='float:right;color: gold;'>[" . $row['agerating'] . "] <i>" . $row['title'] . "</a></i></span><br> |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | $stmt = $conn->prepare("SELECT * FROM users ORDER BY id DESC"); |
| 262 | 262 | $stmt->execute(); |
| 263 | 263 | $result = $stmt->get_result(); |
| 264 | - if($result->num_rows === 0) echo('There are no users.'); |
|
| 265 | - while($row = $result->fetch_assoc()) { |
|
| 264 | + if ($result->num_rows === 0) echo('There are no users.'); |
|
| 265 | + while ($row = $result->fetch_assoc()) { |
|
| 266 | 266 | $id = 1; |
| 267 | 267 | echo "<div class='item" . $id . "'><img style='height: 8em;width: 8em;' src='/pfp/" . getPFP($row['username'], $conn) . "'><br><a href='/?id=" . $row['id'] . "'>" . $row['username'] . "</a></div>"; |
| 268 | 268 | $id = $id + 1; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $stmt = $conn->prepare("SELECT * FROM files WHERE type='image' AND status='y' ORDER BY RAND() LIMIT 6"); |
| 280 | 280 | $stmt->execute(); |
| 281 | 281 | $result = $stmt->get_result(); |
| 282 | - while($row = $result->fetch_assoc()) { |
|
| 282 | + while ($row = $result->fetch_assoc()) { |
|
| 283 | 283 | echo "<div style='display: inline-block;' class='notegray'> |
| 284 | 284 | <a href='/view?id=" . $row['id'] . "'><img style='width: 7.5em;height: 7.5em;' src='/images/" . $row['filename'] . "'> |
| 285 | 285 | <br><center><b>" . htmlspecialchars($row['title']) . "</b><br><span style='color: gray;'>By " . $row['author'] . "</span></center> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | while($row = $result->fetch_assoc()) { |
| 43 | 43 | $grouptitle = $row['title']; |
| 44 | 44 | } |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | $grouptitle = "none"; |
| 47 | 47 | } |
| 48 | 48 | $stmt->close(); |
@@ -168,7 +168,9 @@ discard block |
||
| 168 | 168 | $stmt->bind_param("s", $username); |
| 169 | 169 | $stmt->execute(); |
| 170 | 170 | $result = $stmt->get_result(); |
| 171 | - if($result->num_rows > 0) echo('<h1>Files</h1>'); |
|
| 171 | + if($result->num_rows > 0) { |
|
| 172 | + echo('<h1>Files</h1>'); |
|
| 173 | + } |
|
| 172 | 174 | |
| 173 | 175 | while($row = $result->fetch_assoc()) { |
| 174 | 176 | echo '<a href="/view?id=' . $row['id'] . '">' . $row['title'] . ' [' , $row['type'] . ']</a><br>'; |
@@ -261,7 +263,9 @@ discard block |
||
| 261 | 263 | $stmt = $conn->prepare("SELECT * FROM users ORDER BY id DESC"); |
| 262 | 264 | $stmt->execute(); |
| 263 | 265 | $result = $stmt->get_result(); |
| 264 | - if($result->num_rows === 0) echo('There are no users.'); |
|
| 266 | + if($result->num_rows === 0) { |
|
| 267 | + echo('There are no users.'); |
|
| 268 | + } |
|
| 265 | 269 | while($row = $result->fetch_assoc()) { |
| 266 | 270 | $id = 1; |
| 267 | 271 | echo "<div class='item" . $id . "'><img style='height: 8em;width: 8em;' src='/pfp/" . getPFP($row['username'], $conn) . "'><br><a href='/?id=" . $row['id'] . "'>" . $row['username'] . "</a></div>"; |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | $stmt->bind_param("s", $_SESSION['user']); |
| 10 | 10 | $stmt->execute(); |
| 11 | 11 | $result = $stmt->get_result(); |
| 12 | - if($result->num_rows === 0) header('Location: index.php'); |
|
| 13 | - while($row = $result->fetch_assoc()) { |
|
| 12 | + if ($result->num_rows === 0) header('Location: index.php'); |
|
| 13 | + while ($row = $result->fetch_assoc()) { |
|
| 14 | 14 | $username = $row['username']; |
| 15 | 15 | $id = $row['id']; |
| 16 | 16 | $date = $row['date']; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | <body> |
| 29 | 29 | <?php require(__DIR__ . "/important/header.php"); |
| 30 | 30 | |
| 31 | - if(@$_POST['bioset']) { |
|
| 31 | + if (@$_POST['bioset']) { |
|
| 32 | 32 | $stmt = $conn->prepare("UPDATE users SET bio = ? WHERE `users`.`username` = ?;"); |
| 33 | 33 | $stmt->bind_param("ss", $text, $_SESSION['user']); |
| 34 | 34 | $unprocessedText = replaceBBcodes($_POST['bio']); |
@@ -37,22 +37,22 @@ discard block |
||
| 37 | 37 | $stmt->execute(); |
| 38 | 38 | $stmt->close(); |
| 39 | 39 | header("Location: home.php"); |
| 40 | - } else if(@$_POST['css']) { |
|
| 40 | + } else if (@$_POST['css']) { |
|
| 41 | 41 | $stmt = $conn->prepare("UPDATE users SET css = ? WHERE `users`.`username` = ?;"); |
| 42 | 42 | $stmt->bind_param("ss", $validatedcss, $_SESSION['user']); |
| 43 | 43 | $validatedcss = validateCSS($_POST['css']); |
| 44 | 44 | $stmt->execute(); |
| 45 | 45 | $stmt->close(); |
| 46 | 46 | header("Location: home.php"); |
| 47 | - } else if(@$_POST['submit']) { |
|
| 47 | + } else if (@$_POST['submit']) { |
|
| 48 | 48 | $target_dir = "pfp/"; |
| 49 | 49 | $target_file = basename($_FILES["fileToUpload"]["name"]); |
| 50 | 50 | $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); |
| 51 | 51 | $target_file = $target_dir . getID($_SESSION['user'], $conn) . "." . $imageFileType; |
| 52 | 52 | $uploadOk = 1; |
| 53 | - if(isset($_POST["submit"])) { |
|
| 53 | + if (isset($_POST["submit"])) { |
|
| 54 | 54 | $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); |
| 55 | - if($check !== false) { |
|
| 55 | + if ($check !== false) { |
|
| 56 | 56 | $uploadOk = 1; |
| 57 | 57 | } else { |
| 58 | 58 | $uploadOk = 0; |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | // echo 'file with the same name already exists<hr>'; |
| 63 | 63 | // $uploadOk = 0; |
| 64 | 64 | // } |
| 65 | - if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
| 66 | - && $imageFileType != "gif" ) { |
|
| 65 | + if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" |
|
| 66 | + && $imageFileType != "gif") { |
|
| 67 | 67 | echo 'unsupported file type. must be jpg, png, jpeg, or gif<hr>'; |
| 68 | 68 | $uploadOk = 0; |
| 69 | 69 | } |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | echo 'fatal error<hr>'; |
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | - } else if(@$_POST['photoset']) { |
|
| 82 | + } else if (@$_POST['photoset']) { |
|
| 83 | 83 | $uploadOk = true; |
| 84 | 84 | $target_dir = "music/"; |
| 85 | 85 | $target_file = basename($_FILES["fileToUpload"]["name"]); |
| 86 | 86 | $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); |
| 87 | 87 | $target_file = $target_dir . getID($_SESSION['user'], $conn) . "." . $imageFileType; |
| 88 | - if(isset($_POST["submit"])) { |
|
| 88 | + if (isset($_POST["submit"])) { |
|
| 89 | 89 | $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); |
| 90 | - if($check !== false) { |
|
| 90 | + if ($check !== false) { |
|
| 91 | 91 | $uploadOk = true; |
| 92 | 92 | } else { |
| 93 | 93 | $uploadOk = false; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // echo 'file with the same name already exists<hr>'; |
| 98 | 98 | // $uploadOk = false; |
| 99 | 99 | // } |
| 100 | - if($imageFileType != "ogg" && $imageFileType != "mp3") { |
|
| 100 | + if ($imageFileType != "ogg" && $imageFileType != "mp3") { |
|
| 101 | 101 | echo 'unsupported file type. must be mp3 or ogg<hr>'; |
| 102 | 102 | $uploadOk = false; |
| 103 | 103 | } |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | <button><a href="/2fa">Manage 2-Factor Authentication</a></button><br><br> |
| 131 | 131 | <b>Bio</b> |
| 132 | 132 | <form method="post" enctype="multipart/form-data"> |
| 133 | - <textarea required cols="58" placeholder="Bio" name="bio"><?php echo $bio;?></textarea><br> |
|
| 133 | + <textarea required cols="58" placeholder="Bio" name="bio"><?php echo $bio; ?></textarea><br> |
|
| 134 | 134 | <input name="bioset" type="submit" value="Set"> |
| 135 | 135 | <small>max limit: 500 characters | supports <a href="https://www.markdownguide.org/basic-syntax">Markdown</a></small> |
| 136 | 136 | </form><br> |
| 137 | 137 | <b>CSS</b> |
| 138 | 138 | <button onclick="loadpfwin()" id="prevbtn">Show Live CSS Preview</button> |
| 139 | 139 | <form method="post" enctype="multipart/form-data"> |
| 140 | - <textarea required rows="15" cols="58" placeholder="Your CSS" name="css" id="css_code"><?php echo $css;?></textarea><br> |
|
| 140 | + <textarea required rows="15" cols="58" placeholder="Your CSS" name="css" id="css_code"><?php echo $css; ?></textarea><br> |
|
| 141 | 141 | <input name="cssset" type="submit" value="Set"> <small>max limit: 5000 characters</small> |
| 142 | 142 | </form><br> |
| 143 | 143 | </div> |
@@ -9,7 +9,9 @@ |
||
| 9 | 9 | $stmt->bind_param("s", $_SESSION['user']); |
| 10 | 10 | $stmt->execute(); |
| 11 | 11 | $result = $stmt->get_result(); |
| 12 | - if($result->num_rows === 0) header('Location: index.php'); |
|
| 12 | + if($result->num_rows === 0) { |
|
| 13 | + header('Location: index.php'); |
|
| 14 | + } |
|
| 13 | 15 | while($row = $result->fetch_assoc()) { |
| 14 | 16 | $username = $row['username']; |
| 15 | 17 | $id = $row['id']; |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - if(isset($_SESSION['user'])) { |
|
| 2 | + if (isset($_SESSION['user'])) { |
|
| 3 | 3 | $stmt = $conn->prepare("SELECT * FROM `users` WHERE username = ?"); |
| 4 | 4 | $stmt->bind_param("s", $_SESSION['user']); |
| 5 | 5 | $stmt->execute(); |
| 6 | 6 | $result = $stmt->get_result(); |
| 7 | 7 | |
| 8 | - if($result->num_rows == 0) echo('welcome to gamestop how may i help you'); |
|
| 8 | + if ($result->num_rows == 0) echo('welcome to gamestop how may i help you'); |
|
| 9 | 9 | } |
| 10 | 10 | ?> |
| 11 | 11 | |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | • <a href="/viewgroups">Groups</a> |
| 32 | 32 | |
| 33 | 33 | <span style="float:right;"> |
| 34 | - <?php if(isset($_SESSION['user'])) {?> |
|
| 34 | + <?php if (isset($_SESSION['user'])) {?> |
|
| 35 | 35 | Logged in as |
| 36 | - <a href='/?id=<?php echo(getID($_SESSION['user'], $conn));?>'> |
|
| 37 | - <?php echo($_SESSION['user']);?> |
|
| 36 | + <a href='/?id=<?php echo(getID($_SESSION['user'], $conn)); ?>'> |
|
| 37 | + <?php echo($_SESSION['user']); ?> |
|
| 38 | 38 | </a> |
| 39 | 39 | • <a href='/home'>Manage</a> |
| 40 | 40 | • <a href='/logout'>Logout</a> |
@@ -5,7 +5,9 @@ |
||
| 5 | 5 | $stmt->execute(); |
| 6 | 6 | $result = $stmt->get_result(); |
| 7 | 7 | |
| 8 | - if($result->num_rows == 0) echo('welcome to gamestop how may i help you'); |
|
| 8 | + if($result->num_rows == 0) { |
|
| 9 | + echo('welcome to gamestop how may i help you'); |
|
| 10 | + } |
|
| 9 | 11 | } |
| 10 | 12 | ?> |
| 11 | 13 | |