@@ -10,20 +10,20 @@ |
||
10 | 10 | class user_update { |
11 | 11 | public $__db; |
12 | 12 | |
13 | - public function __construct($conn){ |
|
13 | + public function __construct($conn) { |
|
14 | 14 | $this->__db = $conn; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // fuck this, this can be compressed into 2 functions |
18 | 18 | |
19 | 19 | function update_cooldown_time($username, $rowName) { |
20 | - $stmt = $this->__db->prepare("UPDATE users SET ".$rowName." = now() WHERE username = :username"); |
|
20 | + $stmt = $this->__db->prepare("UPDATE users SET " . $rowName . " = now() WHERE username = :username"); |
|
21 | 21 | $stmt->bindParam(":username", $username); |
22 | 22 | $stmt->execute(); |
23 | 23 | } |
24 | 24 | |
25 | 25 | function update_row($username, $rowName, $new) { |
26 | - $stmt = $this->__db->prepare("UPDATE users SET ".$rowName." = :new WHERE username = :username"); |
|
26 | + $stmt = $this->__db->prepare("UPDATE users SET " . $rowName . " = :new WHERE username = :username"); |
|
27 | 27 | $stmt->bindParam(":new", $new); |
28 | 28 | $stmt->bindParam(":username", $username); |
29 | 29 | $stmt->execute(); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | class user_helper { |
12 | 12 | public $__db; |
13 | 13 | |
14 | - public function __construct($conn){ |
|
14 | + public function __construct($conn) { |
|
15 | 15 | $this->__db = $conn; |
16 | 16 | } |
17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $stmt = $this->__db->prepare("SELECT pfp FROM users WHERE username = :username") |
20 | 20 | $stmt->bindParam(":username", $username); |
21 | 21 | $stmt->execute(); |
22 | - while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
22 | + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
23 | 23 | $pfp = $row['pfp']; |
24 | 24 | } // why the while statement? just remove it (i cant be bothered to) |
25 | 25 |
@@ -12,19 +12,19 @@ discard block |
||
12 | 12 | |
13 | 13 | public function sh_exec(string $cmd, string $outputfile = "", string $pidfile = "", bool $mergestderror = true, bool $bg = false) { |
14 | 14 | $fullcmd = $cmd; |
15 | - if(strlen($outputfile) > 0) $fullcmd .= " >> " . $outputfile; |
|
16 | - if($mergestderror) $fullcmd .= " 2>&1"; |
|
15 | + if (strlen($outputfile) > 0) $fullcmd .= " >> " . $outputfile; |
|
16 | + if ($mergestderror) $fullcmd .= " 2>&1"; |
|
17 | 17 | |
18 | - if($bg) { |
|
18 | + if ($bg) { |
|
19 | 19 | $fullcmd = "nohup " . $fullcmd . " &"; |
20 | - if(strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile; |
|
20 | + if (strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile; |
|
21 | 21 | } else { |
22 | - if(strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile; |
|
22 | + if (strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile; |
|
23 | 23 | } |
24 | 24 | shell_exec($fullcmd); |
25 | 25 | } |
26 | 26 | |
27 | - public function __construct($conn){ |
|
27 | + public function __construct($conn) { |
|
28 | 28 | $this->__db = $conn; |
29 | 29 | } |
30 | 30 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | |
47 | 47 | function shorten_description(string $description, int $limit, bool $newlines = false) { |
48 | 48 | $description = trim($description); |
49 | - if(strlen($description) >= $limit) { |
|
49 | + if (strlen($description) >= $limit) { |
|
50 | 50 | $description = substr($description, 0, $limit) . "..."; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $description = htmlspecialchars($description); |
54 | - if($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
54 | + if ($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
55 | 55 | return $description; |
56 | 56 | } |
57 | 57 |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | "db_connected" => false, |
22 | 22 | ], |
23 | 23 | |
24 | - "video_properties" => (object) [ "status" => "unloaded" ], |
|
25 | - "user_properties" => (object) [ "status" => "unloaded" ], |
|
26 | - "group_properties" => (object) [ "status" => "unloaded" ], |
|
27 | - "forum_properties" => (object) [ "status" => "unloaded" ], |
|
24 | + "video_properties" => (object) ["status" => "unloaded"], |
|
25 | + "user_properties" => (object) ["status" => "unloaded"], |
|
26 | + "group_properties" => (object) ["status" => "unloaded"], |
|
27 | + "forum_properties" => (object) ["status" => "unloaded"], |
|
28 | 28 | ]; |
29 | 29 | |
30 | 30 | try |
31 | 31 | { |
32 | - $__db = new PDO("mysql:host=".$__server->db_properties->db_host.";dbname=".$__server->db_properties->db_database.";charset=utf8mb4", |
|
32 | + $__db = new PDO("mysql:host=" . $__server->db_properties->db_host . ";dbname=" . $__server->db_properties->db_database . ";charset=utf8mb4", |
|
33 | 33 | $__server->db_properties->db_user, |
34 | 34 | $__server->db_properties->db_password, |
35 | 35 | [ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ); |
40 | 40 | $__server->db_properties->db_connected = true; |
41 | 41 | } |
42 | - catch(PDOException $e) |
|
42 | + catch (PDOException $e) |
|
43 | 43 | { |
44 | 44 | $__server->db_properties->db_connected = false; |
45 | 45 | // wtf is the point of this? cant you just vomit out the error? why????????????? |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | <?php |
141 | 141 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
142 | 142 | $stmt->execute(); |
143 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
143 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
144 | 144 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
145 | 145 | $video['duration'] = $__time_h->timestamp($video['duration']); |
146 | 146 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | <?php |
176 | 176 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
177 | 177 | $stmt->execute(); |
178 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
178 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
179 | 179 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
180 | 180 | $video['duration'] = $__time_h->timestamp($video['duration']); |
181 | 181 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | <?php |
211 | 211 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
212 | 212 | $stmt->execute(); |
213 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
213 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
214 | 214 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
215 | 215 | $video['duration'] = $__time_h->timestamp($video['duration']); |
216 | 216 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | <?php |
246 | 246 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
247 | 247 | $stmt->execute(); |
248 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
248 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
249 | 249 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
250 | 250 | $video['duration'] = $__time_h->timestamp($video['duration']); |
251 | 251 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | <?php |
281 | 281 | $stmt = $__db->prepare("SELECT * FROM videos WHERE category = 'Autos & Vehicles' ORDER BY rand() LIMIT 4"); |
282 | 282 | $stmt->execute(); |
283 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
283 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
284 | 284 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
285 | 285 | $video['duration'] = $__time_h->timestamp($video['duration']); |
286 | 286 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | <?php $__user_h = new user_helper($__db); ?> |
11 | 11 | <?php $__db_h = new db_helper(); ?> |
12 | 12 | <?php $__time_h = new time_helper(); error_reporting(E_ERROR | E_PARSE); ?> |
13 | -<?php if(!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
13 | +<?php if (!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
14 | 14 | <!DOCTYPE html> |
15 | 15 | <html dir="ltr"> |
16 | 16 | <head> |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | $stmt->execute(); |
164 | 164 | |
165 | 165 | $number_of_result = $stmt->rowCount(); |
166 | - $number_of_page = ceil ($number_of_result / $results_per_page); |
|
166 | + $number_of_page = ceil($number_of_result/$results_per_page); |
|
167 | 167 | |
168 | - if (!isset ($_GET['page']) ) { |
|
168 | + if (!isset ($_GET['page'])) { |
|
169 | 169 | $page = 1; |
170 | 170 | } else { |
171 | - $page = (int)$_GET['page']; |
|
171 | + $page = (int) $_GET['page']; |
|
172 | 172 | } |
173 | 173 | |
174 | - $page_first_result = ($page - 1) * $results_per_page; |
|
174 | + $page_first_result = ($page - 1)*$results_per_page; |
|
175 | 175 | ?> |
176 | 176 | <?php |
177 | 177 | $stmt6 = $__db->prepare("SELECT * FROM favorite_video WHERE sender = :search ORDER BY id DESC LIMIT :pfirst, :pper"); |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | </tr> |
192 | 192 | |
193 | 193 | <?php |
194 | - while($video = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
195 | - if($__video_h->video_exists($video['reciever'])) { |
|
194 | + while ($video = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
195 | + if ($__video_h->video_exists($video['reciever'])) { |
|
196 | 196 | $_video = $__video_h->fetch_video_rid($video['reciever']); |
197 | 197 | $_video['video_responses'] = $__video_h->get_video_responses($_video['rid']); |
198 | 198 | $_video['age'] = $__time_h->time_elapsed_string($_video['publish']); |
@@ -202,19 +202,19 @@ discard block |
||
202 | 202 | $_video['title'] = htmlspecialchars($_video['title']); |
203 | 203 | $_video['description'] = $__video_h->shorten_description($_video['description'], 50); |
204 | 204 | |
205 | - if($_video['thumbnail'] == ".png" && $_video['filename'] == ".mp4") { |
|
205 | + if ($_video['thumbnail'] == ".png" && $_video['filename'] == ".mp4") { |
|
206 | 206 | $status = "Corrupted"; |
207 | - } else if($_video['visibility'] == "v") { |
|
207 | + } else if ($_video['visibility'] == "v") { |
|
208 | 208 | $status = "Approved"; |
209 | - } else if($_video['visibility'] == "n") { |
|
209 | + } else if ($_video['visibility'] == "n") { |
|
210 | 210 | $status = "Approved"; |
211 | - } else if($_video['visibility'] == "o") { |
|
211 | + } else if ($_video['visibility'] == "o") { |
|
212 | 212 | $status = "Disapproved"; |
213 | 213 | } else { |
214 | 214 | $status = "Unknown"; |
215 | 215 | } |
216 | 216 | |
217 | - if($_video['commenting'] == "a") |
|
217 | + if ($_video['commenting'] == "a") |
|
218 | 218 | $_video['commentstatus'] = "Commenting allowed"; |
219 | 219 | else |
220 | 220 | $_video['commentstatus'] = "Commenting disallowed"; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | </div> |
261 | 261 | </center> |
262 | 262 | |
263 | - <?php for($page = 1; $page<= $number_of_page; $page++) { ?> |
|
263 | + <?php for ($page = 1; $page <= $number_of_page; $page++) { ?> |
|
264 | 264 | <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button> |
265 | 265 | <?php } ?> |
266 | 266 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | </script> |
307 | 307 | |
308 | 308 | <?php |
309 | - if($stmt6->rowCount() == 0) { echo " |
|
309 | + if ($stmt6->rowCount() == 0) { echo " |
|
310 | 310 | <br>Welcome to your Video Manager! You can manage your uploaded videos here.<br> |
311 | 311 | <a href=\"upload_video\"> |
312 | 312 | <button type=\"button\" class=\" yt-uix-button yt-uix-button-default\" role=\"button\"> |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | <?php $__time_h = new time_helper(); ?> |
12 | 12 | <?php header('Content-Type: application/json'); ?> |
13 | 13 | <?php |
14 | - if(!isset($_GET['action_load_user_feed'])) { |
|
15 | - switch(@$_GET['chart_name']) { |
|
14 | + if (!isset($_GET['action_load_user_feed'])) { |
|
15 | + switch (@$_GET['chart_name']) { |
|
16 | 16 | case "trending": |
17 | 17 | $category = 'Trending'; |
18 | 18 | $diviconn = 'trending'; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | break; |
48 | 48 | } |
49 | 49 | |
50 | - switch(@$_GET['feed_name']) { |
|
50 | + switch (@$_GET['feed_name']) { |
|
51 | 51 | case "trending": |
52 | 52 | $category = 'Trending'; |
53 | 53 | $diviconn = 'trending'; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | <div class=\'feed-page\'> |
108 | 108 | <ul> |
109 | 109 | <?php |
110 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
110 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
111 | 111 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
112 | 112 | $video['duration'] = $__time_h->timestamp($video['duration']); |
113 | 113 | $video['views'] = $__video_h->fetch_video_views($video['rid']); |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | <?php $__user_u = new user_update($__db); ?> |
13 | 13 | <?php $__db_h = new db_helper(); ?> |
14 | 14 | <?php $__time_h = new time_helper(); ?> |
15 | -<?php if(!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
15 | +<?php if (!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
16 | 16 | <?php |
17 | - if($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
18 | - if(!isset($_SESSION['siteusername'])){ $error_legacy = "you are not logged in"; goto skipcomment; } |
|
19 | - if(!$_POST['comment']){ $error_legacy = "your description cannot be blank"; goto skipcomment; } |
|
20 | - if(strlen($_POST['comment']) > 1024){ $error_legacy = "your comment must be shorter than 1000 characters"; goto skipcomment; } |
|
21 | - if($__user_h->if_cooldown($_SESSION['siteusername'])) { $error_legacy = "You are on a cooldown! Wait for a minute before posting another comment."; goto skipcomment; } |
|
17 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
18 | + if (!isset($_SESSION['siteusername'])) { $error_legacy = "you are not logged in"; goto skipcomment; } |
|
19 | + if (!$_POST['comment']) { $error_legacy = "your description cannot be blank"; goto skipcomment; } |
|
20 | + if (strlen($_POST['comment']) > 1024) { $error_legacy = "your comment must be shorter than 1000 characters"; goto skipcomment; } |
|
21 | + if ($__user_h->if_cooldown($_SESSION['siteusername'])) { $error_legacy = "You are on a cooldown! Wait for a minute before posting another comment."; goto skipcomment; } |
|
22 | 22 | |
23 | 23 | $stmt = $__db->prepare("INSERT INTO playlists (title, description, rid, author) VALUES (:title, :desc, :rid, :username)"); |
24 | 24 | $stmt->bindParam(":title", $_POST['title']); |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | $stmt->execute(); |
188 | 188 | |
189 | 189 | $number_of_result = $stmt->rowCount(); |
190 | - $number_of_page = ceil ($number_of_result / $results_per_page); |
|
190 | + $number_of_page = ceil($number_of_result/$results_per_page); |
|
191 | 191 | |
192 | - if (!isset ($_GET['page']) ) { |
|
192 | + if (!isset ($_GET['page'])) { |
|
193 | 193 | $page = 1; |
194 | 194 | } else { |
195 | - $page = (int)$_GET['page']; |
|
195 | + $page = (int) $_GET['page']; |
|
196 | 196 | } |
197 | 197 | |
198 | - $page_first_result = ($page - 1) * $results_per_page; |
|
198 | + $page_first_result = ($page - 1)*$results_per_page; |
|
199 | 199 | ?> |
200 | 200 | <?php |
201 | 201 | $stmt6 = $__db->prepare("SELECT * FROM playlists WHERE author = :search ORDER BY id DESC LIMIT :pfirst, :pper"); |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | </tr> |
241 | 241 | |
242 | 242 | <?php |
243 | - while($playlist = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
243 | + while ($playlist = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
244 | 244 | $playlist['videos'] = json_decode($playlist['videos']); |
245 | - if($__video_h->video_exists(@$playlist['videos'][0])) { |
|
246 | - if(count($playlist['videos']) != 0) { |
|
245 | + if ($__video_h->video_exists(@$playlist['videos'][0])) { |
|
246 | + if (count($playlist['videos']) != 0) { |
|
247 | 247 | $video = $__video_h->fetch_video_rid($playlist['videos'][0]); |
248 | 248 | $video['video_responses'] = $__video_h->get_video_responses($video['rid']); |
249 | 249 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | </div> |
295 | 295 | </center> |
296 | 296 | |
297 | - <?php for($page = 1; $page<= $number_of_page; $page++) { ?> |
|
297 | + <?php for ($page = 1; $page <= $number_of_page; $page++) { ?> |
|
298 | 298 | <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button> |
299 | 299 | <?php } ?> |
300 | 300 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | </script> |
341 | 341 | |
342 | 342 | <?php |
343 | - if($stmt6->rowCount() == 0) { echo " |
|
343 | + if ($stmt6->rowCount() == 0) { echo " |
|
344 | 344 | <br>Welcome to your playlists! You can make collections of videos for you to share with others.<br> |
345 | 345 | "; |
346 | 346 | } ?> |
@@ -35,7 +35,7 @@ |
||
35 | 35 | 'target_upload_name' => md5_file($_FILES["video_file"]["tmp_name"]) . "." . strtolower(pathinfo($_FILES["video_file"]["name"], PATHINFO_EXTENSION)) // use video_file_type plzs |
36 | 36 | ]; |
37 | 37 | |
38 | - if(move_uploaded_file( |
|
38 | + if (move_uploaded_file( |
|
39 | 39 | $_FILES['video_file']['tmp_name'], |
40 | 40 | "../temp/" . $video_properties->video_rid . $video_validation->video_file_type |
41 | 41 | )) { |