From 80c7d76fbf7f2e1a1fdfa9c1fd9aa3c6fbdf2096 Mon Sep 17 00:00:00 2001 From: DaWe <10603822+DaWe35@users.noreply.github.com> Date: Wed, 14 Oct 2020 11:26:11 +0200 Subject: [PATCH 1/6] use tabs --- get/channel.php | 140 ++++++++--------- view/channel.php | 390 +++++++++++++++++++++++------------------------ 2 files changed, 265 insertions(+), 265 deletions(-) diff --git a/get/channel.php b/get/channel.php index ef2be8e..c3809a8 100644 --- a/get/channel.php +++ b/get/channel.php @@ -1,19 +1,19 @@ prepare("SELECT COUNT(*) FROM stream"); +$stmt = $db->prepare("SELECT COUNT(id) FROM stream"); if (!$stmt->execute()) { - exit('Database error'); + exit('Database error'); } $num_videos = $stmt->fetch(PDO::FETCH_NUM)[0]; $stmt = null; @@ -21,87 +21,87 @@ //number of thumbnails per page $thumbs = array(5, 10, 20); if (isset($_GET['numperpage']) && !empty($_GET['numperpage'])) { - $thumbs_per_page = htmlspecialchars($_GET['numperpage']); - if (!in_array($thumbs_per_page, $thumbs)) { - $thumbs_per_page = $thumbs[0]; - } + $thumbs_per_page = htmlspecialchars($_GET['numperpage']); + if (!in_array($thumbs_per_page, $thumbs)) { + $thumbs_per_page = $thumbs[0]; + } } else { - $thumbs_per_page = $thumbs[0]; + $thumbs_per_page = $thumbs[0]; } //current page if (isset($_GET['current']) && !empty($_GET['current'])) { - $current = htmlspecialchars($_GET['current']); - if (($current < 1) or ($current > ceil($num_videos / $thumbs_per_page))) { - $current = 1; - } + $current = htmlspecialchars($_GET['current']); + if (($current < 1) or ($current > ceil($num_videos / $thumbs_per_page))) { + $current = 1; + } } else { - $current = 1; + $current = 1; } $offset = $thumbs_per_page * ($current - 1); //sort by user if (isset($_GET['user']) && !empty($_GET['user'])) { - $userid = htmlspecialchars($_GET['user']); - if ($userid < 1) { - $userid = 0; - } + $userid = htmlspecialchars($_GET['user']); + if ($userid < 1) { + $userid = 0; + } } else { - $userid = 0; + $userid = 0; } if ($userid == 0) { //select all users - $stmt = $db->prepare("SELECT streamid, userid, title, description, scheule_time, visibility FROM stream LIMIT $thumbs_per_page OFFSET $offset"); - if (!$stmt->execute()) { - exit('Database error'); - } - $stream = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt = null; - $names = array(); - $avatars = array(); - $ids = array(); - $stmt = $db->prepare("SELECT name, avatar FROM users WHERE id = ? LIMIT 1"); - for ($i = 0; $i < count($stream); $i++) { - if (!array_key_exists($stream[$i]['userid'], $names)) { - if (!$stmt->execute([$stream[$i]['userid']])) { - exit('Database error'); - } - $user = $stmt->fetch(PDO::FETCH_ASSOC); - } - $names[$i] = $user['name']; - $ids[$i] = $stream[$i]['userid']; - if ($user['avatar'] == '') { - $avatars[$i] = 'assets/logos/skylive round logo dark.png'; - } else { - $avatars[$i] = $user['avatar']; - } - } - $stmt = null; + $stmt = $db->prepare("SELECT streamid, userid, title, description, scheule_time, visibility FROM stream LIMIT $thumbs_per_page OFFSET $offset"); + if (!$stmt->execute()) { + exit('Database error'); + } + $stream = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt = null; + $names = array(); + $avatars = array(); + $ids = array(); + $stmt = $db->prepare("SELECT name, avatar FROM users WHERE id = ? LIMIT 1"); + for ($i = 0; $i < count($stream); $i++) { + if (!array_key_exists($stream[$i]['userid'], $names)) { + if (!$stmt->execute([$stream[$i]['userid']])) { + exit('Database error'); + } + $user = $stmt->fetch(PDO::FETCH_ASSOC); + } + $names[$i] = $user['name']; + $ids[$i] = $stream[$i]['userid']; + if ($user['avatar'] == '') { + $avatars[$i] = 'assets/logos/skylive round logo dark.png'; + } else { + $avatars[$i] = $user['avatar']; + } + } + $stmt = null; } else { - $stmt = $db->prepare("SELECT name, avatar FROM users WHERE id = $userid LIMIT 1"); - if (!$stmt->execute()) { - exit('Database error'); - } - $user = $stmt->fetch(PDO::FETCH_ASSOC); - $stmt = null; - $names = array(); - $avatars = array(); - $ids = array(); - $stmt = $db->prepare("SELECT streamid, userid, title, description, scheule_time, visibility FROM stream WHERE userid = $userid LIMIT $thumbs_per_page OFFSET $offset"); - if (!$stmt->execute()) { - exit('Database error'); - } - $stream = $stmt->fetchAll(PDO::FETCH_ASSOC); - $stmt = null; - for ($i = 0; $i < count($stream); $i++) { - $names[$i] = $user['name']; - $ids[$i] = $userid; - if ($user['avatar'] == '') { - $avatars[$i] = 'assets/logos/skylive round logo dark.png'; - } else { - $avatars[$i] = $user['avatar']; - } - } + $stmt = $db->prepare("SELECT name, avatar FROM users WHERE id = $userid LIMIT 1"); + if (!$stmt->execute()) { + exit('Database error'); + } + $user = $stmt->fetch(PDO::FETCH_ASSOC); + $stmt = null; + $names = array(); + $avatars = array(); + $ids = array(); + $stmt = $db->prepare("SELECT streamid, userid, title, description, scheule_time, visibility FROM stream WHERE userid = $userid LIMIT $thumbs_per_page OFFSET $offset"); + if (!$stmt->execute()) { + exit('Database error'); + } + $stream = $stmt->fetchAll(PDO::FETCH_ASSOC); + $stmt = null; + for ($i = 0; $i < count($stream); $i++) { + $names[$i] = $user['name']; + $ids[$i] = $userid; + if ($user['avatar'] == '') { + $avatars[$i] = 'assets/logos/skylive round logo dark.png'; + } else { + $avatars[$i] = $user['avatar']; + } + } } include 'model/display.php'; diff --git a/view/channel.php b/view/channel.php index d0938e8..c2a9291 100644 --- a/view/channel.php +++ b/view/channel.php @@ -2,225 +2,225 @@
- - - + + +
- - - -
-
- -
-
-
- - - - - -
-
-
+ + + +
+
+ +
+
+
+ + + + + +
+
+
-
- - - - -
+
+ + + + +
From 88ef43ce348b1c9d5261b320b92875a8db86ca20 Mon Sep 17 00:00:00 2001 From: DaWe <10603822+DaWe35@users.noreply.github.com> Date: Wed, 14 Oct 2020 11:40:36 +0200 Subject: [PATCH 2/6] add url to player, small fixes --- get/channel.php | 2 +- get/player.php | 2 +- view/channel.php | 3 ++- view/player.php | 7 ++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/get/channel.php b/get/channel.php index c3809a8..3e36fd2 100644 --- a/get/channel.php +++ b/get/channel.php @@ -11,7 +11,7 @@ } //total number of videos -$stmt = $db->prepare("SELECT COUNT(id) FROM stream"); +$stmt = $db->prepare("SELECT COUNT(streamid) FROM stream"); if (!$stmt->execute()) { exit('Database error'); } diff --git a/get/player.php b/get/player.php index 7be234a..099b857 100644 --- a/get/player.php +++ b/get/player.php @@ -21,7 +21,7 @@ exit('Access denied, please log in if this is your content'); } -$stmt = $db->prepare("SELECT name, avatar FROM users WHERE id = ? LIMIT 1"); +$stmt = $db->prepare("SELECT name, avatar, id FROM users WHERE id = ? LIMIT 1"); if (!$stmt->execute([$stream['userid']])) { exit('Database error'); } diff --git a/view/channel.php b/view/channel.php index c2a9291..73c68ba 100644 --- a/view/channel.php +++ b/view/channel.php @@ -2,6 +2,7 @@ - - - + \ No newline at end of file