@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | <?php $__user_u = new user_update($__db); ?> |
9 | 9 | <?php $__db_h = new db_helper(); ?> |
10 | 10 | <?php $__time_h = new time_helper(); ?> |
11 | -<?php if(!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
11 | +<?php if (!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
12 | 12 | <?php |
13 | - if($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
13 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
14 | 14 | $error = array(); |
15 | 15 | |
16 | - if(!isset($_SESSION['siteusername'])){ $error['message'] = "You are not logged in"; $error['status'] = true; } |
|
17 | - if(!$_POST['comment']){ $error['message'] = "Your description cannot be blank"; $error['status'] = true; } |
|
18 | - if(empty(trim($_POST['title']))){ $error['message'] = "Your title cannot be blank"; $error['status'] = true; } |
|
19 | - if(strlen($_POST['comment']) > 1000){ $error['message'] = "Your description must be shorter than 1000 characters"; $error['status'] = true; } |
|
20 | - if($__user_h->if_cooldown($_SESSION['siteusername'])) { $error['message'] = "You are on a cooldown! Wait for a minute before making a playlist."; $error['status'] = true; } |
|
16 | + if (!isset($_SESSION['siteusername'])) { $error['message'] = "You are not logged in"; $error['status'] = true; } |
|
17 | + if (!$_POST['comment']) { $error['message'] = "Your description cannot be blank"; $error['status'] = true; } |
|
18 | + if (empty(trim($_POST['title']))) { $error['message'] = "Your title cannot be blank"; $error['status'] = true; } |
|
19 | + if (strlen($_POST['comment']) > 1000) { $error['message'] = "Your description must be shorter than 1000 characters"; $error['status'] = true; } |
|
20 | + if ($__user_h->if_cooldown($_SESSION['siteusername'])) { $error['message'] = "You are on a cooldown! Wait for a minute before making a playlist."; $error['status'] = true; } |
|
21 | 21 | |
22 | - if(!isset($error['message'])) { |
|
22 | + if (!isset($error['message'])) { |
|
23 | 23 | $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'; |
24 | 24 | $result = ''; |
25 | 25 | for ($i = 0; $i < 11; $i++) |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | $stmt->execute(); |
189 | 189 | |
190 | 190 | $number_of_result = $stmt->rowCount(); |
191 | - $number_of_page = ceil ($number_of_result / $results_per_page); |
|
191 | + $number_of_page = ceil($number_of_result/$results_per_page); |
|
192 | 192 | |
193 | - if (!isset ($_GET['page']) ) { |
|
193 | + if (!isset ($_GET['page'])) { |
|
194 | 194 | $page = 1; |
195 | 195 | } else { |
196 | - $page = (int)$_GET['page']; |
|
196 | + $page = (int) $_GET['page']; |
|
197 | 197 | } |
198 | 198 | |
199 | - $page_first_result = ($page - 1) * $results_per_page; |
|
199 | + $page_first_result = ($page - 1)*$results_per_page; |
|
200 | 200 | ?> |
201 | 201 | <?php |
202 | 202 | $stmt6 = $__db->prepare("SELECT * FROM playlists WHERE author = :search ORDER BY id DESC LIMIT :pfirst, :pper"); |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | </tr> |
242 | 242 | |
243 | 243 | <?php |
244 | - while($playlist = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
244 | + while ($playlist = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
245 | 245 | $playlist['videos'] = json_decode($playlist['videos']); |
246 | - if($__video_h->video_exists(@$playlist['videos'][0])) { |
|
247 | - if(count($playlist['videos']) != 0) { |
|
246 | + if ($__video_h->video_exists(@$playlist['videos'][0])) { |
|
247 | + if (count($playlist['videos']) != 0) { |
|
248 | 248 | $video = $__video_h->fetch_video_rid($playlist['videos'][0]); |
249 | 249 | $video['video_responses'] = $__video_h->get_video_responses($video['rid']); |
250 | 250 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | </div> |
327 | 327 | </center> |
328 | 328 | |
329 | - <?php for($page = 1; $page<= $number_of_page; $page++) { ?> |
|
329 | + <?php for ($page = 1; $page <= $number_of_page; $page++) { ?> |
|
330 | 330 | <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button> |
331 | 331 | <?php } ?> |
332 | 332 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | </script> |
373 | 373 | |
374 | 374 | <?php |
375 | - if($stmt6->rowCount() == 0) { echo " |
|
375 | + if ($stmt6->rowCount() == 0) { echo " |
|
376 | 376 | <br>Welcome to your playlists! You can make collections of videos for you to share with others.<br> |
377 | 377 | "; |
378 | 378 | } ?> |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | $results_per_page = 12; |
23 | 23 | $number_of_result = $request->search_amount; |
24 | - $number_of_page = ceil ($number_of_result / $results_per_page); |
|
24 | + $number_of_page = ceil($number_of_result/$results_per_page); |
|
25 | 25 | |
26 | - if (!isset ($_GET['page']) ) { |
|
26 | + if (!isset ($_GET['page'])) { |
|
27 | 27 | $page = 1; |
28 | 28 | } else { |
29 | - $page = (int)$_GET['page']; |
|
29 | + $page = (int) $_GET['page']; |
|
30 | 30 | } |
31 | 31 | |
32 | - $page_first_result = ($page - 1) * $results_per_page; |
|
32 | + $page_first_result = ($page - 1)*$results_per_page; |
|
33 | 33 | |
34 | 34 | $stmt6 = $__db->prepare("SELECT * FROM playlists WHERE lower(author) LIKE lower(:search) ORDER BY id DESC LIMIT :pfirst, :pper"); |
35 | 35 | $stmt6->bindParam(":search", $request->like_search_term); |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | </tr> |
51 | 51 | |
52 | 52 | <?php |
53 | - while($playlist = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
53 | + while ($playlist = $stmt6->fetch(PDO::FETCH_ASSOC)) { |
|
54 | 54 | $playlist['videos'] = json_decode($playlist['videos']); |
55 | - if($__video_h->video_exists(@$playlist['videos'][0])) { |
|
56 | - if(count($playlist['videos']) != 0) { |
|
55 | + if ($__video_h->video_exists(@$playlist['videos'][0])) { |
|
56 | + if (count($playlist['videos']) != 0) { |
|
57 | 57 | $video = $__video_h->fetch_video_rid($playlist['videos'][0]); |
58 | 58 | $video['video_responses'] = $__video_h->get_video_responses($video['rid']); |
59 | 59 | $video['age'] = $__time_h->time_elapsed_string($video['publish']); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | $__server->page_embeds->page_image = "/yt/imgbin/full-size-logo.png"; |
14 | 14 | $__server->page_embeds->page_url = "https://subrock.rocks/"; |
15 | 15 | ?> |
16 | -<?php if(!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
16 | +<?php if (!isset($_SESSION['siteusername'])) { header("Location: /sign_in"); } ?> |
|
17 | 17 | <?php $_playlist = $__video_h->fetch_playlist_rid($_GET['id']); ?> |
18 | 18 | <!DOCTYPE html> |
19 | 19 | <html dir="ltr"> |
@@ -13,8 +13,8 @@ |
||
13 | 13 | <?php |
14 | 14 | $video = $__video_h->fetch_video_rid($_GET['id']); |
15 | 15 | |
16 | -if($video['author'] == $_SESSION['siteusername']) { |
|
17 | - if($video['commenting'] == "a") { |
|
16 | +if ($video['author'] == $_SESSION['siteusername']) { |
|
17 | + if ($video['commenting'] == "a") { |
|
18 | 18 | $__video_u->update_row($_GET['id'], "commenting", "d"); |
19 | 19 | } else { |
20 | 20 | $__video_u->update_row($_GET['id'], "commenting", "a"); |
@@ -11,7 +11,7 @@ |
||
11 | 11 | <?php $video = $__video_h->fetch_video_rid($_GET['id']); ?> |
12 | 12 | <?php |
13 | 13 | |
14 | -if($video['author'] == $_SESSION['siteusername']) { |
|
14 | +if ($video['author'] == $_SESSION['siteusername']) { |
|
15 | 15 | $stmt = $__db->prepare("DELETE FROM videos WHERE rid=:rid AND author=:author"); |
16 | 16 | $stmt->execute(array( |
17 | 17 | ':author' => $video['author'], |
@@ -12,7 +12,7 @@ |
||
12 | 12 | <?php $__time_h = new time_helper(); ?> |
13 | 13 | <?php |
14 | 14 | $_playlist = $__video_h->fetch_playlist_rid($_GET['v']); |
15 | - if($_playlist['author'] != @$_SESSION['siteusername']) { |
|
15 | + if ($_playlist['author'] != @$_SESSION['siteusername']) { |
|
16 | 16 | die(); |
17 | 17 | } |
18 | 18 |
@@ -39,8 +39,8 @@ |
||
39 | 39 | ?> |
40 | 40 | <div id="browse-side-column" class="ytg-2col ytg-last"> |
41 | 41 | <ol class="navigation-menu"> |
42 | - <?php foreach($__tabs as $_tab) { |
|
43 | - if(parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) != $_tab->url) |
|
42 | + <?php foreach ($__tabs as $_tab) { |
|
43 | + if (parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH) != $_tab->url) |
|
44 | 44 | $_tab->selected = true; |
45 | 45 | ?> |
46 | 46 | <li class="menu-item"> |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | class video_updater { |
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 | function update_row($video, $rowName, $new) { |
18 | - $stmt = $this->__db->prepare("UPDATE videos SET ".$rowName." = :new WHERE rid = :rid"); |
|
18 | + $stmt = $this->__db->prepare("UPDATE videos SET " . $rowName . " = :new WHERE rid = :rid"); |
|
19 | 19 | $stmt->bindParam(":new", $new); |
20 | 20 | $stmt->bindParam(":rid", $video); |
21 | 21 | $stmt->execute(); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | function playlist_update_row($video, $rowName, $new) { |
27 | - $stmt = $this->__db->prepare("UPDATE playlists SET ".$rowName." = :new WHERE rid = :rid"); |
|
27 | + $stmt = $this->__db->prepare("UPDATE playlists SET " . $rowName . " = :new WHERE rid = :rid"); |
|
28 | 28 | $stmt->bindParam(":new", $new); |
29 | 29 | $stmt->bindParam(":rid", $video); |
30 | 30 | $stmt->execute(); |
@@ -12,14 +12,14 @@ 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 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | $handle = fopen($file, "r"); |
30 | 30 | $i = 0; |
31 | 31 | while (!feof($handle)) { |
32 | - call_user_func_array($callback,array(fread($handle,$chunk_size),&$handle,$i)); |
|
32 | + call_user_func_array($callback, array(fread($handle, $chunk_size), &$handle, $i)); |
|
33 | 33 | $i++; |
34 | 34 | } |
35 | 35 | |
36 | 36 | fclose($handle); |
37 | 37 | } |
38 | - catch(Exception $e) { |
|
39 | - trigger_error("file_get_contents_chunked::" . $e->getMessage(),E_USER_NOTICE); |
|
38 | + catch (Exception $e) { |
|
39 | + trigger_error("file_get_contents_chunked::" . $e->getMessage(), E_USER_NOTICE); |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | return true; |
44 | 44 | } |
45 | 45 | |
46 | - public function __construct($conn){ |
|
46 | + public function __construct($conn) { |
|
47 | 47 | $this->__db = $conn; |
48 | 48 | } |
49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $stmt->execute(); |
62 | 62 | |
63 | 63 | $views = 0; |
64 | - while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
64 | + while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { |
|
65 | 65 | $views = $views + $this->fetch_video_views($video['rid']); |
66 | 66 | } |
67 | 67 | return $views; |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | for ($i = 0; $i < $timesc; $i++) { |
86 | 86 | $remaining = $timesc - $i - 1; |
87 | 87 | if ($i < $timesc - 1) { |
88 | - $final.=$times[$i].'*'.(60 ** $remaining).'+'; |
|
88 | + $final .= $times[$i] . '*' . (60 ** $remaining) . '+'; |
|
89 | 89 | } else { |
90 | - $final.=$times[$i]; |
|
90 | + $final .= $times[$i]; |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } else { |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | |
99 | 99 | function shorten_description(string $description, int $limit, bool $newlines = false) { |
100 | 100 | $description = trim($description); |
101 | - if(strlen($description) >= $limit) { |
|
101 | + if (strlen($description) >= $limit) { |
|
102 | 102 | $description = substr($description, 0, $limit) . "..."; |
103 | 103 | } |
104 | 104 | |
105 | 105 | $description = htmlspecialchars($description); |
106 | - if($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
106 | + if ($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); } |
|
107 | 107 | $description = preg_replace("/@([a-zA-Z0-9-]+|\\+\\])/", "<a href='/user/$1'>@$1</a>", $description); |
108 | 108 | $description = preg_replace("/((\d{1,2}:)+\d{2})/", "<a onclick=\"yt.www.watch.player.seekTo('$1', false)\">$1</a>", $description); |
109 | 109 | return $description; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | function get_video_likes($reciever, $liked) { |
121 | - if($liked) { |
|
121 | + if ($liked) { |
|
122 | 122 | $stmt = $this->__db->prepare("SELECT `sender` FROM likes WHERE reciever = :reciever AND type = 'l'"); |
123 | 123 | $stmt->bindParam(":reciever", $reciever); |
124 | 124 | $stmt->execute(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $stmt->bindParam(":viewer", $user); |
139 | 139 | $stmt->bindParam(":rid", $vidid); |
140 | 140 | $stmt->execute(); |
141 | - if($stmt->rowCount() === 0) { |
|
141 | + if ($stmt->rowCount() === 0) { |
|
142 | 142 | $this->add_view($vidid, $user); |
143 | 143 | } |
144 | 144 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | function get_comment_likes($reciever, $liked) { |
154 | - if($liked) { |
|
154 | + if ($liked) { |
|
155 | 155 | $stmt = $this->__db->prepare("SELECT `sender` FROM comment_likes WHERE reciever = :reciever AND type = 'l'"); |
156 | 156 | $stmt->bindParam(":reciever", $reciever); |
157 | 157 | $stmt->execute(); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | function if_liked($user, $reciever, $liked) { |
170 | - if($liked) { |
|
170 | + if ($liked) { |
|
171 | 171 | $stmt = $this->__db->prepare("SELECT `sender` FROM likes WHERE sender = :sender AND reciever = :reciever AND type = 'l'"); |
172 | 172 | $stmt->bindParam(":sender", $user); |
173 | 173 | $stmt->bindParam(":reciever", $reciever); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | function if_comment_liked($user, $reciever, $liked) { |
188 | - if($liked) { |
|
188 | + if ($liked) { |
|
189 | 189 | $stmt = $this->__db->prepare("SELECT `sender` FROM comment_likes WHERE sender = :sender AND reciever = :reciever AND type = 'l'"); |
190 | 190 | $stmt->bindParam(":sender", $user); |
191 | 191 | $stmt->bindParam(":reciever", $reciever); |