diff --git a/.htaccess b/.htaccess index d6caa7bada..26694a8938 100644 --- a/.htaccess +++ b/.htaccess @@ -74,6 +74,7 @@ Options All -Indexes 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] diff --git a/objects/category.php b/objects/category.php index 8f42af1807..1396001f10 100644 --- a/objects/category.php +++ b/objects/category.php @@ -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; diff --git a/objects/status.json.php b/objects/status.json.php index 2834fd7cf6..a79c0b9848 100644 --- a/objects/status.json.php +++ b/objects/status.json.php @@ -1,11 +1,11 @@ max_file_size = get_max_file_size(); diff --git a/plugin/CustomizeAdvanced/CustomizeAdvanced.php b/plugin/CustomizeAdvanced/CustomizeAdvanced.php index 86324e82e5..4359c7a11e 100644 --- a/plugin/CustomizeAdvanced/CustomizeAdvanced.php +++ b/plugin/CustomizeAdvanced/CustomizeAdvanced.php @@ -121,6 +121,7 @@ class CustomizeAdvanced extends PluginAbstract { } } + $obj->disablePlayLink = false; $obj->disableHelpLeftMenu = false; $obj->disableAboutLeftMenu = false; $obj->disableContactLeftMenu = false; diff --git a/plugin/Live/Live.php b/plugin/Live/Live.php index 493de3877e..a2c400e2cd 100644 --- a/plugin/Live/Live.php +++ b/plugin/Live/Live.php @@ -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; } diff --git a/plugin/Live/install/nginx.conf b/plugin/Live/install/nginx.conf index 65e12e3f81..a3633b98c4 100644 --- a/plugin/Live/install/nginx.conf +++ b/plugin/Live/install/nginx.conf @@ -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; diff --git a/plugin/Live/install/nginx.old.conf b/plugin/Live/install/nginx.old.conf deleted file mode 100644 index 5f24ca9640..0000000000 --- a/plugin/Live/install/nginx.old.conf +++ /dev/null @@ -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; - } - } -} - - - diff --git a/plugin/LiveLinks/LiveLinks.php b/plugin/LiveLinks/LiveLinks.php index 7baddc10bf..aaccc2b08b 100644 --- a/plugin/LiveLinks/LiveLinks.php +++ b/plugin/LiveLinks/LiveLinks.php @@ -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) diff --git a/plugin/LoginTwitter/LoginTwitter.php b/plugin/LoginTwitter/LoginTwitter.php index 18d60c0965..595975dda8 100644 --- a/plugin/LoginTwitter/LoginTwitter.php +++ b/plugin/LoginTwitter/LoginTwitter.php @@ -16,8 +16,8 @@ class LoginTwitter extends PluginAbstract { $name = $obj->type; $str = "Login with {$name} OAuth Integration"; $str .= "
Get {$name} ID and Key" - . "
Valid OAuth redirect URIs: {$global['webSiteRootURL']}objects/login.json.php?type=$name" - . "
For mobile a Valid OAuth redirect URIs: {$global['webSiteRootURL']}plugin/MobileManager/oauth2.php?type=$name"; + . "
Valid OAuth redirect URIs: {$global['webSiteRootURL']}objects/login.json.php" + . "
For mobile a Valid OAuth redirect URIs: {$global['webSiteRootURL']}plugin/MobileManager/oauth2.php"; return $str; } diff --git a/plugin/YPTSocket/YPTSocket.php b/plugin/YPTSocket/YPTSocket.php index 120298623e..8a6103d7db 100644 --- a/plugin/YPTSocket/YPTSocket.php +++ b/plugin/YPTSocket/YPTSocket.php @@ -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
"; - $desc .= "nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &"; + $desc .= "sudo nohup php {$global['systemRootPath']}plugin/YPTSocket/server.php &"; $help = "
run this command start the server Help"; //$desc .= $this->isReadyLabel(array('YPTWallet')); diff --git a/plugin/YPTSocket/server.php b/plugin/YPTSocket/server.php index 532e5947d0..1d30656334 100644 --- a/plugin/YPTSocket/server.php +++ b/plugin/YPTSocket/server.php @@ -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, diff --git a/view/include/navbar.php b/view/include/navbar.php index d97943deb5..420c6c16c5 100644 --- a/view/include/navbar.php +++ b/view/include/navbar.php @@ -1153,7 +1153,11 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
  • -

    CategoryLabel); ?>

    +

    + + CategoryLabel); ?> + +

  • userMustBeLoggedIn) && !emp
    disablePlayLink)) { + ?> + + disableHelpLeftMenu)) { ?>
  • diff --git a/view/listCategories.php b/view/listCategories.php new file mode 100644 index 0000000000..5d581c9eec --- /dev/null +++ b/view/listCategories.php @@ -0,0 +1,177 @@ + + + + + + + + + +
    + + +
    +
    + 1 {$value['name']}"); + continue; + } + if ($advancedCustom->ShowAllVideosOnCategory) { + $total = $value['fullTotal']; + } else { + $total = $value['total']; + } + if (empty($total)) { + //var_dump("
    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 = ' ' ; + if (!$imageNotFound) { + ?> + + + + + +
    +
    +
    + +
    + +
    + +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + " value="" id="playFormInput" /> + + + +
    +
    +
    +
    +
    +
    +
    +
    + + + +