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 @@
= $stream[$row]['title'] ?>
-= $names[$row] ?>
-= $stream[$row]['title'] ?>
+= $names[$row] ?>
+