Test Failed
Push — main ( 8ba42a...e78405 )
by chief
02:52
created
web/public/watch.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@  discard block
 block discarded – undo
11 11
 <?php $__user_u = new user_update($__db); ?>
12 12
 <?php $__db_h = new db_helper(); ?>
13 13
 <?php $__time_h = new time_helper(); ?>
14
-<?php if(!$__video_h->video_exists($_GET['v'])) { header("Location: /?error=This video doesn't exist!"); } ?>
14
+<?php if (!$__video_h->video_exists($_GET['v'])) { header("Location: /?error=This video doesn't exist!"); } ?>
15 15
 <?php $_video = $__video_h->fetch_video_rid($_GET['v']); ?>
16 16
 <?php $_video['comments'] = $__video_h->get_comments_from_video($_video['rid']); ?>
17 17
 <?php
18
-	if(isset($_SESSION['siteusername']))
18
+	if (isset($_SESSION['siteusername']))
19 19
 		$__video_h->check_view($_GET['v'], @$_SESSION['siteusername']);
20 20
 
21 21
 	$_SESSION['current_video'] = $_video['rid'];
22
-    if($_SERVER['REQUEST_METHOD'] == 'POST') {
22
+    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
23 23
         $error = array();
24 24
 
25
-        if(!isset($_SESSION['siteusername'])){ $error['message'] = "you are not logged in"; $error['status'] = true; }
26
-        if(!$_POST['comment']){ $error['message'] = "your comment cannot be blank"; $error['status'] = true; }
27
-        if(strlen($_POST['comment']) > 1000){ $error['message'] = "your comment must be shorter than 1000 characters"; $error['status'] = true; }
28
-        if($__user_h->if_cooldown($_SESSION['siteusername'])) { $error['message'] = "You are on a cooldown! Wait for a minute before posting another comment."; $error['status'] = true; }
25
+        if (!isset($_SESSION['siteusername'])) { $error['message'] = "you are not logged in"; $error['status'] = true; }
26
+        if (!$_POST['comment']) { $error['message'] = "your comment cannot be blank"; $error['status'] = true; }
27
+        if (strlen($_POST['comment']) > 1000) { $error['message'] = "your comment must be shorter than 1000 characters"; $error['status'] = true; }
28
+        if ($__user_h->if_cooldown($_SESSION['siteusername'])) { $error['message'] = "You are on a cooldown! Wait for a minute before posting another comment."; $error['status'] = true; }
29 29
 
30
-        if(!isset($error['message'])) {
30
+        if (!isset($error['message'])) {
31 31
 			$text = $_POST['comment'];
32 32
             $stmt = $__db->prepare("INSERT INTO comments (toid, author, comment) VALUES (:v, :username, :comment)");
33 33
             $stmt->bindParam(":v", $_GET['v']);
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
          if (window.yt.timing) {yt.timing.tick("ct");}    
85 85
       </script>
86 86
 		<?php
87
-			$_video['dislikes'] =  $__video_h->get_video_stars_level($_video['rid'], 1);
87
+			$_video['dislikes'] = $__video_h->get_video_stars_level($_video['rid'], 1);
88 88
 			$_video['dislikes'] += $__video_h->get_video_stars_level($_video['rid'], 2);
89 89
 
90
-			$_video['likes'] =     $__video_h->get_video_stars_level($_video['rid'], 4);
91
-			$_video['likes'] +=    $__video_h->get_video_stars_level($_video['rid'], 5);
90
+			$_video['likes'] = $__video_h->get_video_stars_level($_video['rid'], 4);
91
+			$_video['likes'] += $__video_h->get_video_stars_level($_video['rid'], 5);
92 92
 
93 93
 			$_video['dislikes'] += $__video_h->get_video_likes($_video['rid'], false);
94 94
 			$_video['likes'] += $__video_h->get_video_likes($_video['rid'], true);
95 95
 
96
-			if($_video['likes'] == 0 && $_video['dislikes'] == 0) {
96
+			if ($_video['likes'] == 0 && $_video['dislikes'] == 0) {
97 97
 				$_video['likeswidth'] = 0;
98 98
 				$_video['dislikeswidth'] = 0;
99 99
 			} else {
100
-				$_video['likeswidth'] = $_video['likes'] / ($_video['likes'] + $_video['dislikes']) * 100;
100
+				$_video['likeswidth'] = $_video['likes']/($_video['likes'] + $_video['dislikes'])*100;
101 101
 				$_video['dislikeswidth'] = 100 - $_video['likeswidth'];
102 102
 			}
103 103
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 									</div>
132 132
 									<div id="instream_google_companion_ad_div"></div>
133 133
 								</div>
134
-								<?php if(@$_SESSION['siteusername'] == $_video['author']) { ?>
134
+								<?php if (@$_SESSION['siteusername'] == $_video['author']) { ?>
135 135
 									<div id="watch-owner-container">
136 136
 										<div id="masthead-subnav" class="yt-nav yt-nav-dark ">
137 137
 											<ul class="yt-nav-aside">
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 											title="" 
167 167
 											id="subscribe-button"
168 168
 											type="button" 
169
-											class="<?php if($_video['subscribed']) { echo "subscribed "; } ?>yt-subscription-button  yt-uix-button yt-uix-button-subscription yt-uix-tooltip" 
169
+											class="<?php if ($_video['subscribed']) { echo "subscribed "; } ?>yt-subscription-button  yt-uix-button yt-uix-button-subscription yt-uix-tooltip" 
170 170
 											role="button">
171 171
 											<span class="yt-uix-button-icon-wrapper">
172 172
 												<img class="yt-uix-button-icon yt-uix-button-icon-subscribe" src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt="">
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 											<button onclick=";like_video();return false;"
248 248
 											title="I like this" 
249 249
 											type="button" 
250
-											class="start <?php if($_video['liked']) { echo "liked "; } ?>yt-uix-tooltip-reverse  yt-uix-button yt-uix-button-default yt-uix-tooltip" 
250
+											class="start <?php if ($_video['liked']) { echo "liked "; } ?>yt-uix-tooltip-reverse  yt-uix-button yt-uix-button-default yt-uix-tooltip" 
251 251
 											id="watch-like"  
252 252
 											href="/get/like_video?v=<?php echo $_video['rid']; ?>"
253 253
 											role="button"><span class="yt-uix-button-icon-wrapper">
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 											type="button" 
262 262
 											style="margin-left: -2px;"
263 263
 											href="/get/dislike_video?v=<?php echo $_video['rid']; ?>"
264
-											class="end yt-uix-tooltip-reverse <?php if($_video['disliked']) { echo "unliked "; } ?>  yt-uix-button yt-uix-button-default yt-uix-tooltip yt-uix-button-empty" 
264
+											class="end yt-uix-tooltip-reverse <?php if ($_video['disliked']) { echo "unliked "; } ?>  yt-uix-button yt-uix-button-default yt-uix-tooltip yt-uix-button-empty" 
265 265
 											id="watch-unlike" 
266 266
 											role="button">
267 267
 												<span class="yt-uix-button-icon-wrapper">
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 												not implemented ismnf
280 280
 											</div>
281 281
 											<div id="watch-actions-logged-out" class="watch-actions-panel hid">
282
-												<?php if(!isset($_SESSION['siteusername'])) { ?>
282
+												<?php if (!isset($_SESSION['siteusername'])) { ?>
283 283
 												<div class="yt-alert yt-alert-naked yt-alert-warn  ">
284 284
 													<div class="yt-alert-icon">
285 285
 														<img src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" class="icon master-sprite" alt="Alert icon">
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 												<?php } else { ?>
296 296
 													<h3>Be friends with the creator</h3>
297 297
 
298
-													<?php if($_SESSION['siteusername'] != $_video['author']) { ?>
298
+													<?php if ($_SESSION['siteusername'] != $_video['author']) { ?>
299 299
 														<img style="width: 50px;height:50px;" src="/dynamic/pfp/<?php echo $__user_h->fetch_pfp($_video['author']); ?>">
300 300
 														<span style="display: inline-block; vertical-align:top;width: 100px;font-size:11px;">
301 301
 															<b><a href="/user/<?php echo htmlspecialchars($_video['author']); ?>"><?php echo htmlspecialchars($_video['author']); ?></a></b><br>
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 														</span><br><br>
310 310
 													<?php } ?>
311 311
 
312
-													<?php if($_SESSION['siteusername'] != $_video['author']) { ?>
313
-														<?php if($_video['friended'] == false) { ?>
312
+													<?php if ($_SESSION['siteusername'] != $_video['author']) { ?>
313
+														<?php if ($_video['friended'] == false) { ?>
314 314
 															<a href="/friends">Send a friend request</a>
315 315
 														<?php } else { ?>
316 316
 															Your friend request is pending.
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 													<?php } ?>
321 321
 													<hr><br>
322 322
 													<h3>Add to Favorites</h3>
323
-													<?php if($_video['favorited'] == false) { ?>
323
+													<?php if ($_video['favorited'] == false) { ?>
324 324
 														<a href="/get/favorite?v=<?php echo $_video['rid']; ?>">Favorite Video</a>
325 325
 													<?php } else { ?>
326 326
 														<a href="/get/unfavorite?v=<?php echo $_video['rid']; ?>">Unfavorite Video</a>
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 														$stmt = $__db->prepare("SELECT * FROM playlists WHERE author = :username ORDER BY id DESC LIMIT 20");
332 332
 														$stmt->bindParam(":username", $_SESSION['siteusername']);
333 333
 														$stmt->execute();
334
-														while($playlist = $stmt->fetch(PDO::FETCH_ASSOC)) { 
334
+														while ($playlist = $stmt->fetch(PDO::FETCH_ASSOC)) { 
335 335
 															$buffer = json_decode($playlist['videos']);
336 336
 															@$rid = $buffer[0];
337
-															if(!empty($rid)) {
337
+															if (!empty($rid)) {
338 338
 																@$video = $__video_h->fetch_video_rid($rid);
339 339
 															} else {
340 340
 																$video['thumbnail'] = "";
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 												$stmt->execute();
613 613
 											?>
614 614
 
615
-											<?php if($stmt->rowCount() != 0) { ?>
615
+											<?php if ($stmt->rowCount() != 0) { ?>
616 616
 												<div class="comments-section">
617 617
 													<a class="comments-section-see-all" href="/video_response_view_all?v=<?php echo htmlspecialchars($_video['rid']); ?>">
618 618
 													see all
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 													<h4>Video Responses</h4>
621 621
 													<ul class="video-list">
622 622
 													<?php 
623
-														while($video = $stmt->fetch(PDO::FETCH_ASSOC)) { 
624
-															if($__video_h->video_exists($video['video'])) { 
623
+														while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) { 
624
+															if ($__video_h->video_exists($video['video'])) { 
625 625
 																$video = $__video_h->fetch_video_rid($video['video']);
626 626
 																$video['age'] = $__time_h->time_elapsed_string($video['publish']);		
627 627
 																$video['duration'] = $__time_h->timestamp($video['duration']);
@@ -652,19 +652,19 @@  discard block
 block discarded – undo
652 652
 														</h4>
653 653
 													</div>
654 654
 												</div>
655
-												<?php if(!isset($_SESSION['siteusername'])) { ?>
655
+												<?php if (!isset($_SESSION['siteusername'])) { ?>
656 656
 													<div class="comments-post-container clearfix">
657 657
 														<div class="comments-post-alert">
658 658
 															<a href="/sign_in">Sign In</a> or <a href="/sign_up">Sign Up</a><span class="comments-post-form-rollover-text"> now to post a comment!</span>
659 659
 														</div>
660 660
 													</div>
661
-												<?php } else if($_video['commenting'] == "d") { ?>
661
+												<?php } else if ($_video['commenting'] == "d") { ?>
662 662
 													<div class="comments-post-container clearfix">
663 663
 														<div class="comments-post-alert">
664 664
 															This video has comemnting disabled!
665 665
 														</div>
666 666
 													</div>
667
-												<?php } else if($__user_h->if_blocked($_video['author'], $_SESSION['siteusername'])) { ?>
667
+												<?php } else if ($__user_h->if_blocked($_video['author'], $_SESSION['siteusername'])) { ?>
668 668
 													<div class="comments-post-container clearfix">
669 669
 														<div class="comments-post-alert">
670 670
 															This user has blocked you!
@@ -718,15 +718,15 @@  discard block
 block discarded – undo
718 718
 														$stmt->execute();
719 719
 
720 720
 														$number_of_result = $stmt->rowCount();
721
-														$number_of_page = ceil ($number_of_result / $results_per_page);  
721
+														$number_of_page = ceil($number_of_result/$results_per_page);  
722 722
 
723
-														if (!isset ($_GET['page']) ) {  
723
+														if (!isset ($_GET['page'])) {  
724 724
 															$page = 1;  
725 725
 														} else {  
726
-															$page = (int)$_GET['page'];  
726
+															$page = (int) $_GET['page'];  
727 727
 														}  
728 728
 
729
-														$page_first_result = ($page - 1) * $results_per_page;  
729
+														$page_first_result = ($page - 1)*$results_per_page;  
730 730
 
731 731
 														$stmt = $__db->prepare("SELECT * FROM comments WHERE toid = :rid ORDER BY id DESC LIMIT :pfirst, :pper");
732 732
 														$stmt->bindParam(":rid", $_video['rid']);
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 														$stmt->bindParam(":pper", $results_per_page);
735 735
 														$stmt->execute();
736 736
 
737
-														while($comment = $stmt->fetch(PDO::FETCH_ASSOC)) { 
738
-															if($__video_h->if_comment_liked($comment['id'], $_SESSION['siteusername'], true))
737
+														while ($comment = $stmt->fetch(PDO::FETCH_ASSOC)) { 
738
+															if ($__video_h->if_comment_liked($comment['id'], $_SESSION['siteusername'], true))
739 739
 																$comment['liked'] = true;
740
-															else if($__video_h->if_comment_liked($comment['id'], $_SESSION['siteusername'], false))
740
+															else if ($__video_h->if_comment_liked($comment['id'], $_SESSION['siteusername'], false))
741 741
 																$comment['disliked'] = true;
742 742
 																
743 743
 															$comment['likes']  = $__video_h->get_comment_likes($comment['id'], true);
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 																		<span dir="ltr"><?php echo $__time_h->time_elapsed_string($comment['date']); ?><span>
760 760
 																		</span>
761 761
 																		</span></span>
762
-																		<?php if($comment['likes'] != 0) { ?>
762
+																		<?php if ($comment['likes'] != 0) { ?>
763 763
 																		<span dir="ltr" class="comments-rating-positive" title="9 up, 1 down">
764 764
 																			<?php echo $comment['likes']; ?>
765 765
 																			<img class="comments-rating-thumbs-up" src="//s.ytimg.com/yts/img/pixel-vfl3z5WfW.gif">
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 												<?php
830 830
 													$stmt = $__db->prepare("SELECT * FROM videos ORDER BY rand() LIMIT 20");
831 831
 													$stmt->execute();
832
-													while($video = $stmt->fetch(PDO::FETCH_ASSOC)) {	
832
+													while ($video = $stmt->fetch(PDO::FETCH_ASSOC)) {	
833 833
 														$video['age'] = $__time_h->time_elapsed_string($video['publish']);		
834 834
 														$video['duration'] = $__time_h->timestamp($video['duration']);
835 835
 														$video['views'] = $__video_h->fetch_video_views($video['rid']);
Please login to merge, or discard this patch.