Passed
Push — main ( fcdcda...b78c1f )
by chief
02:32
created
upload_video.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 <?php $__user_h = new user_helper($__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
 <!DOCTYPE html>
13 13
 <html>
14 14
 	<head>
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                                 <b>Category</b> <br>
91 91
                                 <select style="margin-top:5px;" name="category" class="yt-uix-button yt-uix-button-default">
92 92
                                     <?php $categories = ["None", "Film & Animation", "Autos & Vehicles", "Music", "Pets & Animals", "Sports", "Travel & Events", "Gaming", "People & Blogs", "Comedy", "Entertainment", "News & Politics", "Howto & Style", "Education", "Science & Technology", "Nonprofits & Activism"]; ?>
93
-                                    <?php foreach($categories as $categoryTag) { ?>
93
+                                    <?php foreach ($categories as $categoryTag) { ?>
94 94
                                         <option value="<?php echo $categoryTag; ?>"><?php echo $categoryTag; ?></option>
95 95
                                     <?php } ?>
96 96
                                 </select><br><br>
Please login to merge, or discard this patch.
my_videos.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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(); ?>
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>
@@ -170,15 +170,15 @@  discard block
 block discarded – undo
170 170
                                     $results = $result->num_rows;
171 171
 
172 172
                                     $number_of_result = $result->num_rows;
173
-                                    $number_of_page = ceil ($number_of_result / $results_per_page);  
173
+                                    $number_of_page = ceil($number_of_result/$results_per_page);  
174 174
 
175
-                                    if (!isset ($_GET['page']) ) {  
175
+                                    if (!isset ($_GET['page'])) {  
176 176
                                         $page = 1;  
177 177
                                     } else {  
178
-                                        $page = (int)$_GET['page'];  
178
+                                        $page = (int) $_GET['page'];  
179 179
                                     }  
180 180
 
181
-                                    $page_first_result = ($page - 1) * $results_per_page;  
181
+                                    $page_first_result = ($page - 1)*$results_per_page;  
182 182
 
183 183
                                     $stmt->close();
184 184
                                 ?>
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
                                     </tr>
205 205
                                     
206 206
                                     <?php
207
-                                        while($video = $result6->fetch_assoc()) { 
207
+                                        while ($video = $result6->fetch_assoc()) { 
208 208
                                             $video['video_responses'] = $__video_h->get_video_responses($video['rid']);
209 209
                                             $video['age'] = $__time_h->time_elapsed_string($video['publish']);		
210 210
                                             $video['duration'] = $__time_h->timestamp($video['duration']);
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
                                             $video['title'] = htmlspecialchars($video['title']);
214 214
                                             $video['description'] = $__video_h->shorten_description($video['description'], 50);
215 215
 
216
-                                            if($video['thumbnail'] == ".png" && $video['filename'] == ".mp4") {
216
+                                            if ($video['thumbnail'] == ".png" && $video['filename'] == ".mp4") {
217 217
                                                 $status = "Corrupted";
218
-                                            } else if($video['visibility'] == "v") {
218
+                                            } else if ($video['visibility'] == "v") {
219 219
                                                 $status = "Approved";
220
-                                            } else if($video['visibility'] == "n") {
220
+                                            } else if ($video['visibility'] == "n") {
221 221
                                                 $status = "Approved";
222
-                                            } else if($video['visibility'] == "o") {
222
+                                            } else if ($video['visibility'] == "o") {
223 223
                                                 $status = "Disapproved";
224 224
                                             } else {
225 225
                                                 $status = "Unknown";
226 226
                                             }                      
227 227
                                             
228
-                                            if($video['commenting'] == "a") 
228
+                                            if ($video['commenting'] == "a") 
229 229
                                                 $video['commentstatus'] = "Commenting allowed";
230 230
                                             else 
231 231
                                                 $video['commentstatus'] = "Commenting disallowed";
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                                     </div>
287 287
                                 </center>
288 288
 
289
-                                <?php for($page = 1; $page<= $number_of_page; $page++) { ?>
289
+                                <?php for ($page = 1; $page <= $number_of_page; $page++) { ?>
290 290
                                     <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button>
291 291
                                 <?php } ?>   
292 292
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                                 </script>
333 333
 
334 334
                                 <?php 
335
-                                    if($result6->num_rows == 0) { echo "
335
+                                    if ($result6->num_rows == 0) { echo "
336 336
                                         <br>Welcome to your Video Manager! You can manage your uploaded videos here.<br>
337 337
                                         <a href=\"upload_video\">
338 338
                                             <button type=\"button\" class=\" yt-uix-button yt-uix-button-default\" role=\"button\">
Please login to merge, or discard this patch.
s/classes/video_helper.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
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
 
31 31
     function fetch_video_views(string $id) {
32 32
         $stmt = $this->__db->prepare("SELECT * FROM views WHERE videoid = ?");
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,19 +12,19 @@  discard block
 block discarded – undo
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
 
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 
50 50
     function shorten_description(string $description, int $limit, bool $newlines = false) {
51 51
         $description = trim($description);
52
-        if(strlen($description) >= $limit) {
52
+        if (strlen($description) >= $limit) {
53 53
             $description = substr($description, 0, $limit) . "...";
54 54
         } 
55 55
 
56 56
         $description = htmlspecialchars($description);
57
-        if($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); }
57
+        if ($newlines) { $description = str_replace(PHP_EOL, "<br>", $description); }
58 58
         return $description;
59 59
     }
60 60
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $result = $stmt->get_result();
77 77
         $video = $result->fetch_assoc();
78 78
 
79
-        if($result->num_rows === 0) 
79
+        if ($result->num_rows === 0) 
80 80
             return 0;
81 81
         else
82 82
             return $video;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $stmt->execute();
102 102
         $result = $stmt->get_result();
103 103
         $user = $result->fetch_assoc();
104
-        if($result->num_rows === 1) { return true; } else { return false; }
104
+        if ($result->num_rows === 1) { return true; } else { return false; }
105 105
         $stmt->close();
106 106
         
107 107
         return $user;
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,14 +12,22 @@  discard block
 block discarded – undo
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) {
16
+            $fullcmd .= " >> " . $outputfile;
17
+        }
18
+        if($mergestderror) {
19
+            $fullcmd .= " 2>&1";
20
+        }
17 21
         
18 22
         if($bg) {
19 23
             $fullcmd = "nohup " . $fullcmd . " &";
20
-            if(strlen($pidfile)) $fullcmd .= " echo $! > " . $pidfile;
24
+            if(strlen($pidfile)) {
25
+                $fullcmd .= " echo $! > " . $pidfile;
26
+            }
21 27
         } else {
22
-            if(strlen($pidfile) > 0) $fullcmd .= "; echo $$ > " . $pidfile;
28
+            if(strlen($pidfile) > 0) {
29
+                $fullcmd .= "; echo $$ > " . $pidfile;
30
+            }
23 31
         }
24 32
         shell_exec($fullcmd);
25 33
     }
@@ -76,10 +84,11 @@  discard block
 block discarded – undo
76 84
         $result = $stmt->get_result();
77 85
         $video = $result->fetch_assoc();
78 86
 
79
-        if($result->num_rows === 0) 
80
-            return 0;
81
-        else
82
-            return $video;
87
+        if($result->num_rows === 0) {
88
+                    return 0;
89
+        } else {
90
+                    return $video;
91
+        }
83 92
 
84 93
         $stmt->close();
85 94
     }
Please login to merge, or discard this patch.
playlists.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
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 (?, ?, ?, ?)");
24 24
         $stmt->bind_param("ssss", $_POST['title'], $_POST['comment'], $rid, $_SESSION['siteusername']);
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
                                     $results = $result->num_rows;
195 195
 
196 196
                                     $number_of_result = $result->num_rows;
197
-                                    $number_of_page = ceil ($number_of_result / $results_per_page);  
197
+                                    $number_of_page = ceil($number_of_result/$results_per_page);  
198 198
 
199
-                                    if (!isset ($_GET['page']) ) {  
199
+                                    if (!isset ($_GET['page'])) {  
200 200
                                         $page = 1;  
201 201
                                     } else {  
202
-                                        $page = (int)$_GET['page'];  
202
+                                        $page = (int) $_GET['page'];  
203 203
                                     }  
204 204
 
205
-                                    $page_first_result = ($page - 1) * $results_per_page;  
205
+                                    $page_first_result = ($page - 1)*$results_per_page;  
206 206
 
207 207
                                     $stmt->close();
208 208
                                 ?>
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
                                     </tr>
249 249
                                     
250 250
                                     <?php
251
-                                        while($playlist = $result->fetch_assoc()) { 
251
+                                        while ($playlist = $result->fetch_assoc()) { 
252 252
                                             $playlist['videos'] = json_decode($playlist['videos']);
253
-                                            if($__video_h->video_exists(@$playlist['videos'][0])) {
254
-                                                if(count($playlist['videos']) != 0) {
253
+                                            if ($__video_h->video_exists(@$playlist['videos'][0])) {
254
+                                                if (count($playlist['videos']) != 0) {
255 255
                                                     $video = $__video_h->fetch_video_rid($playlist['videos'][0]);
256 256
                                                     $video['video_responses'] = $__video_h->get_video_responses($video['rid']);
257 257
                                                     $video['age'] = $__time_h->time_elapsed_string($video['publish']);		
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                                     </div>
303 303
                                 </center>
304 304
 
305
-                                <?php for($page = 1; $page<= $number_of_page; $page++) { ?>
305
+                                <?php for ($page = 1; $page <= $number_of_page; $page++) { ?>
306 306
                                     <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button>
307 307
                                 <?php } ?>   
308 308
 
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                                 </script>
349 349
 
350 350
                                 <?php 
351
-                                    if($result6->num_rows == 0) { echo "
351
+                                    if ($result6->num_rows == 0) { echo "
352 352
                                         <br>Welcome to your playlists! You can make collections of videos for you to share with others.<br>
353 353
                                     "; 
354 354
                                 } ?>
Please login to merge, or discard this patch.
favorite_videos.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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>
@@ -170,15 +170,15 @@  discard block
 block discarded – undo
170 170
                                     $results = $result->num_rows;
171 171
 
172 172
                                     $number_of_result = $result->num_rows;
173
-                                    $number_of_page = ceil ($number_of_result / $results_per_page);  
173
+                                    $number_of_page = ceil($number_of_result/$results_per_page);  
174 174
 
175
-                                    if (!isset ($_GET['page']) ) {  
175
+                                    if (!isset ($_GET['page'])) {  
176 176
                                         $page = 1;  
177 177
                                     } else {  
178
-                                        $page = (int)$_GET['page'];  
178
+                                        $page = (int) $_GET['page'];  
179 179
                                     }  
180 180
 
181
-                                    $page_first_result = ($page - 1) * $results_per_page;  
181
+                                    $page_first_result = ($page - 1)*$results_per_page;  
182 182
 
183 183
                                     $stmt->close();
184 184
                                 ?>
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
                                     </tr>
200 200
                                     
201 201
                                     <?php
202
-                                        while($video = $result6->fetch_assoc()) { 
203
-											if($__video_h->video_exists($video['reciever'])) {
202
+                                        while ($video = $result6->fetch_assoc()) { 
203
+											if ($__video_h->video_exists($video['reciever'])) {
204 204
 												$_video = $__video_h->fetch_video_rid($video['reciever']);
205 205
 												$_video['video_responses'] = $__video_h->get_video_responses($_video['rid']);
206 206
 												$_video['age'] = $__time_h->time_elapsed_string($_video['publish']);		
@@ -210,19 +210,19 @@  discard block
 block discarded – undo
210 210
 												$_video['title'] = htmlspecialchars($_video['title']);
211 211
 												$_video['description'] = $__video_h->shorten_description($_video['description'], 50);
212 212
 
213
-												if($_video['thumbnail'] == ".png" && $_video['filename'] == ".mp4") {
213
+												if ($_video['thumbnail'] == ".png" && $_video['filename'] == ".mp4") {
214 214
 													$status = "Corrupted";
215
-												} else if($_video['visibility'] == "v") {
215
+												} else if ($_video['visibility'] == "v") {
216 216
 													$status = "Approved";
217
-												} else if($_video['visibility'] == "n") {
217
+												} else if ($_video['visibility'] == "n") {
218 218
 													$status = "Approved";
219
-												} else if($_video['visibility'] == "o") {
219
+												} else if ($_video['visibility'] == "o") {
220 220
 													$status = "Disapproved";
221 221
 												} else {
222 222
 													$status = "Unknown";
223 223
 												}                      
224 224
 												
225
-												if($_video['commenting'] == "a") 
225
+												if ($_video['commenting'] == "a") 
226 226
 													$_video['commentstatus'] = "Commenting allowed";
227 227
 												else 
228 228
 													$_video['commentstatus'] = "Commenting disallowed";
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                                     </div>
269 269
                                 </center>
270 270
 
271
-                                <?php for($page = 1; $page<= $number_of_page; $page++) { ?>
271
+                                <?php for ($page = 1; $page <= $number_of_page; $page++) { ?>
272 272
                                     <button class="yt-uix-button yt-uix-button-default" onclick="ajax_fetch_videomanager(<?php echo $page; ?>)"><?php echo $page; ?></button>
273 273
                                 <?php } ?>   
274 274
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
                                 </script>
315 315
 
316 316
                                 <?php 
317
-                                    if($result6->num_rows == 0) { echo "
317
+                                    if ($result6->num_rows == 0) { echo "
318 318
                                         <br>Welcome to your Video Manager! You can manage your uploaded videos here.<br>
319 319
                                         <a href=\"upload_video\">
320 320
                                             <button type=\"button\" class=\" yt-uix-button yt-uix-button-default\" role=\"button\">
Please login to merge, or discard this patch.