1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

Categories page

PlayO page
This commit is contained in:
DanielnetoDotCom 2021-01-29 09:41:47 -03:00
parent 83d89c98b6
commit 546c3e6761
14 changed files with 415 additions and 79 deletions

View file

@ -74,6 +74,7 @@ Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
#VideoHLS for DRM
RewriteRule ^playLink/?$ view/modePlayLink.php [QSA]
RewriteRule ^videos/([^/]+)/(.*).key$ plugin/VideoHLS/downloadProtection.php?filename=$1&key=$2 [QSA]
RewriteRule glyphicons-halflings-regular(.+)$ view/bootstrap/fonts/glyphicons-halflings-regular$1 [NC,L]
@ -196,6 +197,7 @@ Options All -Indexes
RewriteRule ^categories.json$ objects/categories.json.php [NC,L]
RewriteRule ^addNewCategory$ objects/categoryAddNew.json.php [NC,L]
RewriteRule ^deleteCategory$ objects/categoryDelete.json.php [NC,L]
RewriteRule ^listCategories$ view/listCategories.php [NC,L]
#manager plugin
RewriteRule ^plugins$ view/managerPlugins.php [NC,L]

View file

@ -369,7 +369,7 @@ class Category {
}
if ($onlyWithVideos) {
$sql .= " AND ((SELECT count(*) FROM videos v where v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id)) > 0 ";
if(AVideoPlugin::isEnabledByName("Live")){
if (AVideoPlugin::isEnabledByName("Live")) {
$sql .= " OR "
. " ("
. " SELECT count(*) FROM live_transmitions lt where "
@ -377,7 +377,7 @@ class Category {
//. " AND lt.id = (select id FROM live_transmitions lt2 WHERE lt.users_id = lt2.users_id ORDER BY CREATED DESC LIMIT 1 )"
. " ) > 0 ";
}
if(AVideoPlugin::isEnabledByName("LiveLinks")){
if (AVideoPlugin::isEnabledByName("LiveLinks")) {
$sql .= " OR "
. " ("
. " SELECT count(*) FROM LiveLinks ll where "
@ -390,7 +390,7 @@ class Category {
unset($_POST['sort']['title']);
}
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC ");
$cacheName = md5($sql);
if (empty($_SESSION['user']['sessionCache']['getAllCategoriesClearCache'])) {
$category = object_to_array(ObjectYPT::getCache($cacheName, 36000));
@ -405,10 +405,10 @@ class Category {
$category = array();
if ($res) {
foreach ($fullResult as $row) {
$totals = self::getTotalFromCategory($row['id']);
$fullTotals = self::getTotalFromCategory($row['id'], false, true, true);
$row['name'] = xss_esc_back($row['name']);
$row['total'] = $totals['total'];
$row['fullTotal'] = $fullTotals['total'];
@ -556,18 +556,39 @@ class Category {
return self::getChildCategories($row['id']);
}
static function getTotalFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) {
$videos = self::getTotalVideosFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew);
$lives = self::getTotalLivesFromCategory($categories_id, $showUnlisted, $renew);
$livelinkss = self::getTotalLiveLinksFromCategory($categories_id, $showUnlisted, $renew);
$total = $videos+$lives+$livelinkss;
return array('videos'=>$videos, 'lives'=>$lives, 'livelinks'=>$livelinkss, 'total'=>$total);
$total = $videos + $lives + $livelinkss;
return array('videos' => $videos, 'lives' => $lives, 'livelinks' => $livelinkss, 'total' => $total);
}
static function getTotalFromChildCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) {
$categories = self::getChildCategories($categories_id);
$array = array('videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0);
foreach ($categories as $value) {
$totals = self::getTotalFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew);
$array = array(
'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']);
$totals = self::getTotalFromChildCategory($value['id'], $showUnlisted, $getAllVideos, $renew);
$array = array(
'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']);
}
return $array;
}
static function getTotalVideosFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) {
global $global, $config;
if (true || $renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) {
if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) {
$sql = "SELECT count(id) as total FROM videos v WHERE 1=1 AND categories_id = ? ";
if (User::isLogged()) {
@ -592,21 +613,73 @@ class Category {
}
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'];
}
static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false) {
global $global, $config;
$sql = "SELECT * FROM videos v WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))";
if (User::isLogged()) {
$sql .= " AND (v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "') OR (v.status='u' AND v.users_id ='" . User::getId() . "'))";
} else {
$sql .= " AND v.status IN ('" . implode("','", Video::getViewableStatus($showUnlisted)) . "')";
}
if (!$getAllVideos) {
$sql .= Video::getUserGroupsCanSeeSQL();
}
$sql .= "ORDER BY created DESC LIMIT 1";
//var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $result;
}
static function getLatestLiveFromCategory($categories_id) {
if (!AVideoPlugin::isEnabledByName("Live")) {
return array();
}
global $global, $config;
$sql = "SELECT * FROM live_transmitions lt LEFT JOIN live_transmitions_history lth ON lt.users_id = lth.users_id "
. " WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))";
$sql .= "ORDER BY lth.created DESC LIMIT 1";
//var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $result;
}
static function getLatestLiveLinksFromCategory($categories_id) {
if (AVideoPlugin::isEnabledByName("LiveLinks")) {
return array();
}
global $global, $config;
$sql = "SELECT * FROM livelinks WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))";
$sql .= "ORDER BY created DESC LIMIT 1";
//var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id));
$result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $result;
}
static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false) {
global $global;
if(!AVideoPlugin::isEnabledByName("LiveLinks")){
if (!AVideoPlugin::isEnabledByName("LiveLinks")) {
return 0;
}
if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks'])) {
$sql = "SELECT count(id) as total FROM LiveLinks v WHERE 1=1 AND categories_id = ? ";
if (empty($showUnlisted)) {
$sql .= " AND `type` = 'public' ";
}
}
//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id));
$fullResult = sqlDAL::fetchAllAssoc($res);
@ -621,22 +694,22 @@ class Category {
}
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks'];
}
static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false) {
if(!AVideoPlugin::isEnabledByName("Live")){
if (!AVideoPlugin::isEnabledByName("Live")) {
return 0;
}
global $global;
if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live'])) {
$sql = "SELECT count(id) as total FROM live_transmitions v WHERE 1=1 AND categories_id = ? ";
if (empty($showUnlisted)) {
$sql .= " AND public = 1 ";
}
}
//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id));
$fullResult = sqlDAL::fetchAllAssoc($res);
@ -652,13 +725,13 @@ class Category {
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live'];
}
static function clearCacheCount($categories_id=0) {
static function clearCacheCount($categories_id = 0) {
// clear category count cache
_session_start();
if(empty($categories_id)){
if (empty($categories_id)) {
unset($_SESSION['user']['sessionCache']['categoryTotal']);
$_SESSION['user']['sessionCache']['getAllCategoriesClearCache'] = 1;
}else{
} else {
unset($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id]);
}
//session_write_close();
@ -742,7 +815,7 @@ class Category {
static function isAssetsValids($categories_id) {
$photo = Category::getCategoryPhotoPath($categories_id);
$background = Category::getCategoryBackgroundPath($categories_id);
if(!file_exists($photo['path']) || !file_exists($background['path'])){
if (!file_exists($photo['path']) || !file_exists($background['path'])) {
return false;
}
return true;

View file

@ -1,11 +1,11 @@
<?php
header('Access-Control-Allow-Origin: *');
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'plugin/MobileManager/MobileManager.php';
require_once 'functions.php';
header('Access-Control-Allow-Origin: *');
allowOrigin();
AVideoPlugin::loadPlugin('MobileManager');
header('Content-Type: application/json');
$obj = new stdClass();
$obj->max_file_size = get_max_file_size();

View file

@ -121,6 +121,7 @@ class CustomizeAdvanced extends PluginAbstract {
}
}
$obj->disablePlayLink = false;
$obj->disableHelpLeftMenu = false;
$obj->disableAboutLeftMenu = false;
$obj->disableContactLeftMenu = false;

View file

@ -1123,7 +1123,7 @@ class Live extends PluginAbstract {
$url = $p->getLivePosterImage($users_id, $live_servers_id);
$url = addQueryStringParameter($url, "playlists_id_live", $playlists_id_live);
} else {
$file = self::getOfflineImage(false);
$url = self::getOfflineImage(false);
}
return $url;
}

View file

@ -18,6 +18,7 @@ worker_processes 1;
hls_playlist_length 60m;
hls_fragment 4s;
on_publish http://localhost/AVideo/plugin/Live/on_publish.php;
on_publish_done http://localhost/AVideo/plugin/Live/on_publish_done.php;
on_play http://localhost/AVideo/plugin/Live/on_play.php;
on_record_done http://localhost/AVideo/plugin/Live/on_record_done.php;

View file

@ -1,45 +0,0 @@
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 81;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root html;
}
location /control {
rtmp_control all;
}
}
}
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
on_publish http://[AVideoURL]/plugin/Live/on_publish.php;
}
}
}

View file

@ -160,6 +160,7 @@ class LiveLinks extends PluginAbstract {
"htmlExtraVideoPage" => $newContentExtraVideoPage,
"UserPhoto" => $UserPhoto,
"title" => $value['title'],
"users_id" => $value['users_id'],
"name" => $name,
"poster" => self::getPosterToLiveFromId($value['id']),
"link" => self::getLinkToLiveFromId($value['id'], true)

View file

@ -16,8 +16,8 @@ class LoginTwitter extends PluginAbstract {
$name = $obj->type;
$str = "Login with {$name} OAuth Integration";
$str .= "<br><a href='{$obj->linkToDevelopersPage}'>Get {$name} ID and Key</a>"
. "<br>Valid OAuth redirect URIs: <strong>{$global['webSiteRootURL']}objects/login.json.php?type=$name</strong>"
. "<br>For mobile a Valid OAuth redirect URIs: <strong>{$global['webSiteRootURL']}plugin/MobileManager/oauth2.php?type=$name</strong>";
. "<br>Valid OAuth redirect URIs: <strong>{$global['webSiteRootURL']}objects/login.json.php</strong>"
. "<br>For mobile a Valid OAuth redirect URIs: <strong>{$global['webSiteRootURL']}plugin/MobileManager/oauth2.php</strong>";
return $str;
}

View file

@ -17,7 +17,7 @@ class YPTSocket extends PluginAbstract {
global $global;
$desc = getSocketConnectionLabel();
$desc .= "Socket Plugin, WebSockets allow for a higher amount of efficiency compared to REST because they do not require the HTTP request/response overhead for each message sent and received<br>";
$desc .= "<code>nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &</code>";
$desc .= "<code>sudo nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &</code>";
$help = "<br>run this command start the server <small><a href='https://github.com/WWBN/AVideo/wiki/Socket-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
//$desc .= $this->isReadyLabel(array('YPTWallet'));

View file

@ -39,6 +39,13 @@ if(strtolower($scheme)!=='https'){
$server->run();
} else {
if(!file_exists($SocketDataObj->server_crt_file) || !is_readable($SocketDataObj->server_crt_file)){
echo "SSL ERROR, we could not access the CRT file {$SocketDataObj->server_crt_file}, try to run this command as root or use sudo ".PHP_EOL;
}
if(!file_exists($SocketDataObj->server_key_file) || !is_readable($SocketDataObj->server_key_file)){
echo "SSL ERROR, we could not access the KEY file {$SocketDataObj->server_key_file}, try to run this command as root or use sudo ".PHP_EOL;
}
echo "Your socket server uses a secure connection".PHP_EOL;
$parameters = [
'local_cert' => $SocketDataObj->server_crt_file,

View file

@ -1153,7 +1153,11 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
</li>
<!-- categories -->
<li>
<h3 class="text-danger"><?php echo __($advancedCustom->CategoryLabel); ?></h3>
<h3>
<a href="<?php echo $global['webSiteRootURL']; ?>listCategories" class="text-danger">
<?php echo __($advancedCustom->CategoryLabel); ?>
</a>
</h3>
</li>
<?php
$_rowCount = getRowCount();
@ -1237,6 +1241,16 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
<hr>
</li>
<?php
if (empty($advancedCustom->disablePlayLink)) {
?>
<li class="nav-item">
<a class="nav-link" href="<?php echo $global['webSiteRootURL']; ?>playLink">
<i class="fas fa-play-circle"></i>
<?php echo __("Play a Link"); ?>
</a>
</li>
<?php
}
if (empty($advancedCustom->disableHelpLeftMenu)) {
?>
<li>

177
view/listCategories.php Normal file
View file

@ -0,0 +1,177 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<?php
echo getHTMLTitle(array('Categories'));
include $global['systemRootPath'] . 'view/include/head.php';
?>
<style>
.categoryItem .categoryName {
position: absolute;
clear: both;
overflow: hidden;
bottom: 0;
left: 0;
padding: 10px 10px 10px calc( 20% + 20px);
width: 100%;
color: #fff;
background-image: linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,1));
}
.categoryItem .panel-default{
position: relative;
}
.categoryItem img{
max-width: 20%;
position: absolute;
bottom: 10px;
left: 10px;
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.categoryItem:hover img {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
.categoryItem>div{
background-size: cover;
box-shadow: 0 1px 2px rgba(0,0,0,0.15);
transition: box-shadow 0.3s ease-in-out;
}
.categoryItem:hover>div{
-webkit-animation: zoomin 0.3s linear;
animation: zoomin 0.3s linear;
animation-fill-mode: forwards;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
@-webkit-keyframes zoomin {
0% {
-webkit-transform: scale(1);
transform: scale(1);
}
100% {
-webkit-transform: scale(1.05);
transform: scale(1.05);
}
}
</style>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<br>
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container-fluid">
<div class="row">
<?php
$_GET['parentsOnly'] = 1;
$categories = Category::getAllCategories(false, true);
//var_dump(count($categories));
foreach ($categories as $value) {
if (!empty($value['parentId'])) {
//var_dump("<br> 1 {$value['name']}");
continue;
}
if ($advancedCustom->ShowAllVideosOnCategory) {
$total = $value['fullTotal'];
} else {
$total = $value['total'];
}
if (empty($total)) {
//var_dump("<br> 2 {$value['name']}");
continue;
}
if(!empty($value['fullTotal_videos'])){
$video = Category::getLatestVideoFromCategory($value['id'], true, true);
$images = Video::getImageFromID($video['id']);
$image = $images->poster;
}else
if(!empty($value['fullTotal_lives'])){
$live = Category::getLatestLiveFromCategory($value['id'], true, true);
$image = Live::getImage($live['users_id'], $live['live_servers_id']);
}else
if(!empty($value['fullTotal_livelinks'])){
$liveLinks = Category::getLatestLiveLinksFromCategory($value['id'], true, true);
$image = LiveLinks::getImage($liveLinks['id']);
}
$totalVideosOnChilds = Category::getTotalFromChildCategory($value['id']);
$childs = Category::getChildCategories($value['id']);
$photo = Category::getCategoryPhotoPath($value['id']);
$photoBg = Category::getCategoryBackgroundPath($value['id']);
$link = $global['webSiteRootURL'] . 'cat/' . $value['clean_name'];
$imageNotFound = preg_match('/notfound/i', $image);
$photoNotFound = preg_match('/notfound/i', $photo['url']);
$icon = '<i class="' . (empty($value['iconClass']) ? "fa fa-folder" : $value['iconClass']) . '"></i> ' ;
if (!$imageNotFound) {
?>
<style>
.categoryItem<?php echo $value['id']; ?>>div{
background-image: url(<?php echo $image; ?>);
}
</style>
<?php
}
if ($photoNotFound || !Category::isAssetsValids($value['id'])) {
?>
<style>
.categoryItem<?php echo $value['id']; ?> img{
display: none;
}
.categoryItem<?php echo $value['id']; ?> .categoryName {
padding-left: 10px ;
}
</style>
<?php
}
?>
<a href="<?php echo $link; ?>">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 categoryItem categoryItem<?php echo $value['id']; ?>" >
<div class="panel panel-default embed-responsive embed-responsive-16by9 ">
<div class="panel-body ">
<?php
//var_dump($images, $totalVideosOnChilds['total'], $value['name'], $value['fullTotal']);
?>
<div class="categoryName">
<?php echo $icon, ' ', $value['name']; ?>
</div>
<img src="<?php echo $photo['url+timestamp']; ?>" class=" img img-responsive" />
</div>
</div>
</div>
</a>
<?php
}
?>
</div>
</div><!--/.container-->
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script>
$(document).ready(function () {
});
</script>
</body>
</html>
<?php
include $global['systemRootPath'].'objects/include_end.php';

105
view/modePlayLink.php Normal file
View file

@ -0,0 +1,105 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<?php
echo getHTMLTitle(array('Categories'));
include $global['systemRootPath'] . 'view/include/head.php';
?><style>
#custom-search-input{
padding: 3px;
border: solid 1px #E4E4E4;
border-radius: 6px;
background-color: #fff;
}
#custom-search-input input{
border: 0;
box-shadow: none;
}
#custom-search-input button{
margin: 2px 0 0 0;
background: none;
box-shadow: none;
border: 0;
color: #666666;
padding: 0 8px 0 10px;
border-left: solid 1px #ccc;
}
#custom-search-input button:hover{
border: 0;
box-shadow: none;
border-left: solid 1px #ccc;
}
#custom-search-input .glyphicon-search{
font-size: 23px;
}
</style>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<br>
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container">
<div class="row">
<div class="input-group col-md-12">
<div class="panel">
<div class="panel-body" id="linkPanel">
<form id="play-form" name="play-form" method="get">
<div id="custom-search-input">
<div class="input-group col-md-12">
<input type="search" name="urlToPlay" class="form-control input-lg" placeholder="<?php echo __("Place a Link to play"); ?>" value="<?php
echo @$_GET['urlToPlay'];
?>" id="playFormInput" />
<span class="input-group-btn">
<button class="btn btn-info btn-lg" type="submit">
<i class="fas fa-play-circle"></i>
</button>
</span>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div><!--/.container-->
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script>
$(document).ready(function () {
$('#play-form').submit(function (event) {
if (seachFormIsRunning) {
event.preventDefault();
return false;
}
seachFormIsRunning = 1;
var str = $('#playFormInput').val();
if (isMediaSiteURL(str)) {
event.preventDefault();
console.log("playForm is URL " + str);
seachFormPlayURL(str);
return false;
} else {
avideoToast('<?php echo __('This is not a valid URL'); ?>');
}
});
});
</script>
</body>
</html>