1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Version 11.2 that add more support to track video views

This commit is contained in:
Daniel 2021-08-02 12:45:30 -03:00
parent 8db4802076
commit a5a91dc9d2
11 changed files with 320 additions and 22 deletions

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit; exit;
} }
$installationVersion = "11.1"; $installationVersion = "11.2";
error_log("Installation: ".__LINE__." ". json_encode($_POST)); error_log("Installation: ".__LINE__." ". json_encode($_POST));
header('Content-Type: application/json'); header('Content-Type: application/json');

View file

@ -150,6 +150,7 @@ CREATE TABLE IF NOT EXISTS `videos` (
`filepath` VARCHAR(255) NULL DEFAULT NULL, `filepath` VARCHAR(255) NULL DEFAULT NULL,
`filesize` BIGINT(19) UNSIGNED NULL DEFAULT 0, `filesize` BIGINT(19) UNSIGNED NULL DEFAULT 0,
`live_transmitions_history_id` INT(11) NULL DEFAULT NULL, `live_transmitions_history_id` INT(11) NULL DEFAULT NULL,
`total_seconds_watching` INT(11) NULL DEFAULT 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `fk_videos_users_idx` (`users_id` ASC), INDEX `fk_videos_users_idx` (`users_id` ASC),
INDEX `fk_videos_categories1_idx` (`categories_id` ASC), INDEX `fk_videos_categories1_idx` (`categories_id` ASC),
@ -162,6 +163,7 @@ CREATE TABLE IF NOT EXISTS `videos` (
INDEX `video_status_idx` (`status` ASC), INDEX `video_status_idx` (`status` ASC),
INDEX `video_type_idx` (`type` ASC) , INDEX `video_type_idx` (`type` ASC) ,
INDEX `fk_videos_live_transmitions_history1_idx` (`live_transmitions_history_id` ASC), INDEX `fk_videos_live_transmitions_history1_idx` (`live_transmitions_history_id` ASC),
INDEX `total_sec_watchinindex` (`total_seconds_watching` ASC),
FULLTEXT INDEX `index17vname` (`title`), FULLTEXT INDEX `index17vname` (`title`),
FULLTEXT INDEX `index18vdesc` (`description`), FULLTEXT INDEX `index18vdesc` (`description`),
CONSTRAINT `fk_videos_sites1` CONSTRAINT `fk_videos_sites1`
@ -307,11 +309,13 @@ CREATE TABLE IF NOT EXISTS `videos_statistics` (
`modified` DATETIME NULL DEFAULT NULL, `modified` DATETIME NULL DEFAULT NULL,
`lastVideoTime` INT(11) NULL DEFAULT NULL, `lastVideoTime` INT(11) NULL DEFAULT NULL,
`session_id` VARCHAR(45) NOT NULL, `session_id` VARCHAR(45) NOT NULL,
`seconds_watching_video` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC), INDEX `fk_videos_statistics_users1_idx` (`users_id` ASC),
INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC), INDEX `fk_videos_statistics_videos1_idx` (`videos_id` ASC),
INDEX `when_statisci` (`when` ASC), INDEX `when_statisci` (`when` ASC),
INDEX `session_id_statistics` (`session_id` ASC), INDEX `session_id_statistics` (`session_id` ASC),
INDEX `sec_watchin_videos` (`seconds_watching_video` ASC),
CONSTRAINT `fk_videos_statistics_users1` CONSTRAINT `fk_videos_statistics_users1`
FOREIGN KEY (`users_id`) FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`) REFERENCES `users` (`id`)

View file

@ -2157,7 +2157,7 @@ function combineFiles($filesArray, $extension = "js") {
$str = ""; $str = "";
$fileName = ""; $fileName = "";
foreach ($filesArray as $value) { foreach ($filesArray as $value) {
$fileName .= $value.filectime($global['systemRootPath'] . $value).filemtime($global['systemRootPath'] . $value); $fileName .= $value . filectime($global['systemRootPath'] . $value) . filemtime($global['systemRootPath'] . $value);
} }
if ($advancedCustom != false) { if ($advancedCustom != false) {
$minifyEnabled = $advancedCustom->EnableMinifyJS; $minifyEnabled = $advancedCustom->EnableMinifyJS;
@ -2543,7 +2543,7 @@ function isMobile($userAgent = null, $httpHeaders = null) {
return $detect->isMobile($userAgent, $httpHeaders); return $detect->isMobile($userAgent, $httpHeaders);
} }
function isChannelPage(){ function isChannelPage() {
return strpos($_SERVER["SCRIPT_NAME"], 'view/channel.php') !== false; return strpos($_SERVER["SCRIPT_NAME"], 'view/channel.php') !== false;
} }
@ -5174,8 +5174,8 @@ function getPagination($total, $page = 0, $link = "", $maxVisible = 10, $infinit
if (preg_match("/(current=[0-9]+)/i", $link, $match)) { if (preg_match("/(current=[0-9]+)/i", $link, $match)) {
$link = str_replace($match[1], "current={page}", $link); $link = str_replace($match[1], "current={page}", $link);
} else { } else {
$link = addQueryStringParameter($link, 'current', '{page}'); //$link = addQueryStringParameter($link, 'current', '{page}');
//$link .= (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'current={page}'; $link .= (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'current={page}';
} }
} }
@ -6292,7 +6292,7 @@ function getStatsNotifications($force_recreate = false) {
$json = ObjectYPT::getCache($cacheName, 0, true); $json = ObjectYPT::getCache($cacheName, 0, true);
} }
if (empty($json)) { if (empty($json)) {
_error_log('getStatsNotifications: 1 ' . json_encode(debug_backtrace())); //_error_log('getStatsNotifications: 1 ' . json_encode(debug_backtrace()));
$json = Live::getStats(); $json = Live::getStats();
$json = object_to_array($json); $json = object_to_array($json);
@ -7003,3 +7003,31 @@ function number_format_short($n, $precision = 1) {
return $n_format . $suffix; return $n_format . $suffix;
} }
function seconds2human($ss) {
$s = $ss % 60;
$m = floor(($ss % 3600) / 60);
$h = floor(($ss % 86400) / 3600);
$d = floor(($ss % 2592000) / 86400);
$M = floor($ss / 2592000);
$times = array();
if(!empty($M)){
$times[] = "$M ".__('m');
}
if(!empty($d)){
$times[] = "$d ".__('d');
}
if(!empty($h)){
$times[] = "$h ".__('h');
}
if(!empty($m)){
$times[] = "$m ".__('min');
}
if(!empty($s)){
$times[] = "$s ".__('sec');
}
return implode(', ', $times);
}

View file

@ -57,6 +57,7 @@ if (!class_exists('Video')) {
private $filepath; private $filepath;
private $filesize; private $filesize;
private $live_transmitions_history_id; private $live_transmitions_history_id;
private $total_seconds_watching;
public static $statusDesc = array( public static $statusDesc = array(
'a' => 'Active', 'a' => 'Active',
'k' => 'Active and Encoding', 'k' => 'Active and Encoding',
@ -117,6 +118,23 @@ if (!class_exists('Video')) {
} }
die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
} }
public function addSecondsWatching($seconds_watching) {
global $global;
$seconds_watching = intval($seconds_watching);
if(empty($seconds_watching)){
return false;
}
if (empty($this->id)) {
return false;
}
$sql = "UPDATE videos SET total_seconds_watching = total_seconds_watching+{$seconds_watching}, modified = now() WHERE id = ?";
_error_log($sql."={$this->id}");
return sqlDAL::writeSql($sql, "i", array($this->id));
}
public function updateViewsCount($total) { public function updateViewsCount($total) {
global $global; global $global;
@ -1203,6 +1221,8 @@ if (!class_exists('Video')) {
$row['isWatchLater'] = self::isWatchLater($row['id']); $row['isWatchLater'] = self::isWatchLater($row['id']);
$row['favoriteId'] = self::getFavoriteIdFromUser(User::getId()); $row['favoriteId'] = self::getFavoriteIdFromUser(User::getId());
$row['watchLaterId'] = self::getWatchLaterIdFromUser(User::getId()); $row['watchLaterId'] = self::getWatchLaterIdFromUser(User::getId());
$row['total_seconds_watching_human'] = seconds2human($row['total_seconds_watching']);
$row['views_count_short'] = number_format_short($row['views_count']);
if (empty($row['externalOptions'])) { if (empty($row['externalOptions'])) {
$row['externalOptions'] = json_encode(array('videoStartSeconds' => '00:00:00')); $row['externalOptions'] = json_encode(array('videoStartSeconds' => '00:00:00'));
@ -4492,7 +4512,15 @@ if (!class_exists('Video')) {
$btnHTML = str_replace($search, $replace, $content); $btnHTML = str_replace($search, $replace, $content);
return $btnHTML; return $btnHTML;
} }
function getTotal_seconds_watching() {
return $this->total_seconds_watching;
}
function setTotal_seconds_watching($total_seconds_watching) {
$this->total_seconds_watching = $total_seconds_watching;
}
} }
} }

View file

@ -52,8 +52,17 @@ if (empty($_SESSION['addViewCount'][$_REQUEST['id']]['time'])) {
$resp = $obj->addView(); $resp = $obj->addView();
_session_start(); _session_start();
$_SESSION['addViewCount'][$_REQUEST['id']]['time'] = strtotime("+{$seconds} seconds"); $_SESSION['addViewCount'][$_REQUEST['id']]['time'] = strtotime("+{$seconds} seconds");
} elseif (!empty($_REQUEST['currentTime'])) { } elseif (isset($_REQUEST['currentTime'])) {
$resp = VideoStatistic::updateStatistic($obj->getId(), User::getId(), intval($_REQUEST['currentTime'])); $currentTime = intval($_REQUEST['currentTime']);
if($currentTime<0){
$currentTime = 0;
}
$seconds_watching_video = intval(@$_REQUEST['seconds_watching_video']);
if($seconds_watching_video<0){
$seconds_watching_video = 0;
}
$resp = VideoStatistic::updateStatistic($obj->getId(), User::getId(), $currentTime, $seconds_watching_video);
} else { } else {
$resp = 0; $resp = 0;
} }

View file

@ -19,6 +19,7 @@ class VideoStatistic extends ObjectYPT {
protected $videos_id; protected $videos_id;
protected $lastVideoTime; protected $lastVideoTime;
protected $session_id; protected $session_id;
protected $seconds_watching_video;
public static function getSearchFieldsNames() { public static function getSearchFieldsNames() {
return array(); return array();
@ -69,7 +70,7 @@ class VideoStatistic extends ObjectYPT {
} }
} }
public static function updateStatistic($videos_id, $users_id, $lastVideoTime) { public static function updateStatistic($videos_id, $users_id, $lastVideoTime, $seconds_watching_video=0) {
$lastStatistic = self::getLastStatistics($videos_id, $users_id); $lastStatistic = self::getLastStatistics($videos_id, $users_id);
if (empty($lastStatistic)) { if (empty($lastStatistic)) {
$vs = new VideoStatistic(0); $vs = new VideoStatistic(0);
@ -80,7 +81,26 @@ class VideoStatistic extends ObjectYPT {
$vs = new VideoStatistic($lastStatistic['id']); $vs = new VideoStatistic($lastStatistic['id']);
} }
$vs->setLastVideoTime($lastVideoTime); $vs->setLastVideoTime($lastVideoTime);
return $vs->save();
if(!empty($seconds_watching_video) && $seconds_watching_video > 0){
$totalVideoWatched = $vs->getSeconds_watching_video()+$seconds_watching_video;
$vs->setSeconds_watching_video($totalVideoWatched);
$v = new Video('', '', $videos_id);
$v->addSecondsWatching($seconds_watching_video);
//$totalVideoSeconds = timeToSeconds($hms);
//Video::addViewPercent();
}
$id = $vs->save();
/*
if(!empty($id)){
Video::clearCache($videos_id);
}
*/
return $id;
} }
public function save() { public function save() {
@ -460,5 +480,70 @@ class VideoStatistic extends ObjectYPT {
_error_log("Id for table " . static::getTableName() . " not defined for deletion", AVideoLog::$ERROR); _error_log("Id for table " . static::getTableName() . " not defined for deletion", AVideoLog::$ERROR);
return false; return false;
} }
function getSeconds_watching_video() {
return intval($this->seconds_watching_video);
}
function setSeconds_watching_video($seconds_watching_video) {
$this->seconds_watching_video = intval($seconds_watching_video);
}
public static function getAllFromVideos_id($videos_id) {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$videos_id = intval($videos_id);
if(empty($videos_id)){
return false;
}
$sql = "SELECT * FROM " . static::getTableName() . " WHERE videos_id=$videos_id ";
$sql .= self::getSqlFromPost();
//echo $sql;//exit;
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
public static function getTotalFromVideos_id($videos_id) {
global $global;
if (!static::isTableInstalled()) {
return false;
}
$videos_id = intval($videos_id);
if(empty($videos_id)){
return false;
}
$sql = "SELECT count(id) as total FROM " . static::getTableName() . " WHERE videos_id=$videos_id ";
$sql .= self::getSqlSearchFromPost();
//echo $sql;//exit;
$res = sqlDAL::readSql($sql);
$result = sqlDAL::fetchAssoc($res);
if (!empty($result)) {
return intval($result['total']);
}
return 0;
}
} }

View file

@ -373,7 +373,7 @@ class PlayerSkins extends PluginAbstract {
if (empty($currentTime) && isVideoPlayerHasProgressBar()) { if (empty($currentTime) && isVideoPlayerHasProgressBar()) {
$currentTime = self::getCurrentTime(); $currentTime = self::getCurrentTime();
} }
if (!empty($global['doNotLoadPlayer'])) { if (!empty($global['doNotLoadPlayer'])) {
return ''; return '';
} }
@ -384,7 +384,6 @@ class PlayerSkins extends PluginAbstract {
if (empty($prepareStartPlayerJS_getDataSetup)) { if (empty($prepareStartPlayerJS_getDataSetup)) {
$prepareStartPlayerJS_getDataSetup = array(); $prepareStartPlayerJS_getDataSetup = array();
} }
if (empty($noReadyFunction)) { if (empty($noReadyFunction)) {
$js .= "var originalVideo; $js .= "var originalVideo;
var adTagOptions; var adTagOptions;
@ -471,9 +470,9 @@ class PlayerSkins extends PluginAbstract {
$videos_id = getVideos_id(); $videos_id = getVideos_id();
if (!empty($videos_id)) { if (!empty($videos_id)) {
$video = Video::getVideoLight($videos_id); $video = Video::getVideoLight($videos_id);
$progress = Video::getVideoPogressPercent($videos_id); $progress = Video::getVideoPogressPercent($videos_id);
if (!empty($progress) && !empty($progress['lastVideoTime'])) { if (!empty($progress) && !empty($progress['lastVideoTime'])) {
$currentTime = intval($video['progress']['lastVideoTime']); $currentTime = intval($progress['lastVideoTime']);
} else if (!empty($video['externalOptions'])) { } else if (!empty($video['externalOptions'])) {
$json = _json_decode($video['externalOptions']); $json = _json_decode($video['externalOptions']);
if (!empty($json->videoStartSeconds)) { if (!empty($json->videoStartSeconds)) {

View file

@ -0,0 +1,17 @@
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
ALTER TABLE `videos`
ADD COLUMN `total_seconds_watching` INT(11) NULL DEFAULT 0 AFTER `live_transmitions_history_id`,
ADD INDEX `total_sec_watchinindex` (`total_seconds_watching` ASC);
ALTER TABLE `videos_statistics`
ADD COLUMN `seconds_watching_video` INT(11) NULL DEFAULT NULL AFTER `session_id`,
ADD INDEX `sec_watchin_videos` (`seconds_watching_video` ASC);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
UPDATE configurations SET version = '11.2', modified = now() WHERE id = 1;

View file

@ -170,6 +170,9 @@ lazyImage();
var pleaseWaitIsINUse = false; var pleaseWaitIsINUse = false;
var pauseIfIsPlayinAdsInterval; var pauseIfIsPlayinAdsInterval;
var seconds_watching_video = 0;
var _startCountPlayingTime;
function setPlayerListners() { function setPlayerListners() {
if (typeof player !== 'undefined') { if (typeof player !== 'undefined') {
player.on('pause', function () { player.on('pause', function () {
@ -177,6 +180,7 @@ function setPlayerListners() {
console.log("setPlayerListners: pause"); console.log("setPlayerListners: pause");
//userIsControling = true; //userIsControling = true;
clearInterval(pauseIfIsPlayinAdsInterval); clearInterval(pauseIfIsPlayinAdsInterval);
clearInterval(_startCountPlayingTime);
}); });
player.on('play', function () { player.on('play', function () {
@ -187,6 +191,9 @@ function setPlayerListners() {
pauseIfIsPlayinAdsInterval = setInterval(function () { pauseIfIsPlayinAdsInterval = setInterval(function () {
pauseIfIsPlayinAds(); pauseIfIsPlayinAds();
}, 500); }, 500);
_startCountPlayingTime = setInterval(function(){
seconds_watching_video++;
},1000);
}); });
$("#mainVideo .vjs-mute-control").click(function () { $("#mainVideo .vjs-mute-control").click(function () {
@ -436,7 +443,6 @@ function addView(videos_id, currentTime) {
} }
videoViewAdded = videos_id; videoViewAdded = videos_id;
last_videos_id = videos_id; last_videos_id = videos_id;
last_currentTime = currentTime; last_currentTime = currentTime;
_addView(videos_id, currentTime); _addView(videos_id, currentTime);
@ -447,6 +453,7 @@ function addViewBeacon() {
var url = webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID; var url = webSiteRootURL + 'objects/videoAddViewCount.json.php?PHPSESSID=' + PHPSESSID;
url = addGetParam(url, 'id', mediaId); url = addGetParam(url, 'id', mediaId);
url = addGetParam(url, 'currentTime', player.currentTime()); url = addGetParam(url, 'currentTime', player.currentTime());
url = addGetParam(url, 'seconds_watching_video', seconds_watching_video);
var beacon = new Image(); var beacon = new Image();
beacon.src = url; beacon.src = url;
} }

View file

@ -290,16 +290,19 @@
<th data-column-id="title" data-formatter="titleTag" ><?php echo __("Title"); ?></th> <th data-column-id="title" data-formatter="titleTag" ><?php echo __("Title"); ?></th>
<th data-column-id="tags" data-formatter="tags" data-sortable="false" data-width="300px" data-header-css-class='hidden-xs' data-css-class='hidden-xs tagsInfo'><?php echo __("Tags"); ?></th> <th data-column-id="tags" data-formatter="tags" data-sortable="false" data-width="300px" data-header-css-class='hidden-xs' data-css-class='hidden-xs tagsInfo'><?php echo __("Tags"); ?></th>
<th style="display: none;" data-column-id="duration" data-width="80px" data-header-css-class='hidden-md hidden-sm hidden-xs showOnGridDone' data-css-class='hidden-md hidden-sm hidden-xs'> <th style="display: none;" data-column-id="duration" data-width="80px" data-header-css-class='hidden-md hidden-sm hidden-xs showOnGridDone' data-css-class='hidden-md hidden-sm hidden-xs'>
<?php echo htmlentities('<i class="fas fa-stopwatch" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Video Duration") . '"></i>'); ?> <?php echo htmlentities('<i class="fas fa-stopwatch" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Duration") . '"></i>'); ?>
</th> </th>
<th style="display: none;" data-column-id="views_count" data-width="50px" data-header-css-class='hidden-sm hidden-xs showOnGridDone' data-css-class='hidden-sm hidden-xs'> <th style="display: none;" data-column-id="views_count" data-formatter="views_count" data-width="50px" data-header-css-class='hidden-sm hidden-xs showOnGridDone' data-css-class='hidden-sm hidden-xs'>
<?php echo htmlentities('<i class="fas fa-eye" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Video Views") . '"></i>'); ?> <?php echo htmlentities('<i class="fas fa-eye" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Views") . '"></i>'); ?>
</th>
<th style="display: none;" data-column-id="total_seconds_watching" data-formatter="total_seconds_watching" data-width="100px" data-header-css-class='hidden-sm hidden-xs showOnGridDone' data-css-class='hidden-sm hidden-xs'>
<?php echo htmlentities('<i class="fas fa-stopwatch" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Time Watching") . '"></i>'); ?>
</th> </th>
<?php <?php
if (Permissions::canAdminVideos()) { if (Permissions::canAdminVideos()) {
?> ?>
<th style="display: none;" data-column-id="isSuggested" data-formatter="isSuggested" data-width="42px" data-header-css-class='hidden-xs showOnGridDone' data-css-class='hidden-xs'> <th style="display: none;" data-column-id="isSuggested" data-formatter="isSuggested" data-width="42px" data-header-css-class='hidden-xs showOnGridDone' data-css-class='hidden-xs'>
<?php echo htmlentities('<i class="fas fa-star" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Suggested Video") . '"></i>'); ?> <?php echo htmlentities('<i class="fas fa-star" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Suggested") . '"></i>'); ?>
</th> </th>
<?php <?php
} }
@ -1396,7 +1399,7 @@ echo AVideoPlugin::getManagerVideosReset();
item += '</div><div class="progress progress-striped active " id="downloadProgress' + id + '" style="height: 10px; border-top-right-radius: 0; border-top-left-radius: 0;"><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;"></div></div> '; item += '</div><div class="progress progress-striped active " id="downloadProgress' + id + '" style="height: 10px; border-top-right-radius: 0; border-top-left-radius: 0;"><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;"></div></div> ';
$('#encodeProgress' + id).html(item); $('#encodeProgress' + id).html(item);
} }
/*
function viewsDetails(views_count, views_count_25, views_count_50, views_count_75, views_count_100) { function viewsDetails(views_count, views_count_25, views_count_50, views_count_75, views_count_100) {
viewsDetailsReset(); viewsDetailsReset();
$("#videoViewFormModal .modal-title").html("Total views: " + views_count); $("#videoViewFormModal .modal-title").html("Total views: " + views_count);
@ -1404,6 +1407,8 @@ echo AVideoPlugin::getManagerVideosReset();
var p50 = (views_count_50 / views_count) * 100; var p50 = (views_count_50 / views_count) * 100;
var p75 = (views_count_75 / views_count) * 100; var p75 = (views_count_75 / views_count) * 100;
var p100 = (views_count_100 / views_count) * 100; var p100 = (views_count_100 / views_count) * 100;
console.log('views', views_count, views_count_25, views_count_50, views_count_75, views_count_100);
console.log('p',p25, p50, p75, p100);
$('#videoViewFormModal').modal(); $('#videoViewFormModal').modal();
$("#progress25 .progress-bar") $("#progress25 .progress-bar")
.css("width", p25 + "%") .css("width", p25 + "%")
@ -1442,7 +1447,7 @@ echo AVideoPlugin::getManagerVideosReset();
.attr("aria-valuenow", "0") .attr("aria-valuenow", "0")
.text("Loading ..."); .text("Loading ...");
} }
*/
$(document).ready(function () { $(document).ready(function () {
@ -1868,7 +1873,7 @@ if (Permissions::canAdminVideos()) {
tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'>" + row.tags[i].label + ": </span><span class=\"label label-" + row.tags[i].type + " \">" + text + "</span>"; tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'>" + row.tags[i].label + ": </span><span class=\"label label-" + row.tags[i].type + " \">" + text + "</span>";
} }
tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Type") . ":"; ?> </span><span class=\"label label-default \">" + row.type + "</span>"; tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Type") . ":"; ?> </span><span class=\"label label-default \">" + row.type + "</span>";
tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Views") . ":"; ?> </span><span class=\"label label-default \">" + row.views_count + " <a href='#' class='viewsDetails' onclick='viewsDetails(" + row.views_count + ", " + row.views_count_25 + "," + row.views_count_50 + "," + row.views_count_75 + "," + row.views_count_100 + ");'>[<i class='fas fa-info-circle'></i> Details]</a></span>"; //tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Views") . ":"; ?> </span><span class=\"label label-default \">" + row.views_count_short + " <a href='#' class='viewsDetails' onclick='viewsDetails(" + row.views_count + ", " + row.views_count_25 + "," + row.views_count_50 + "," + row.views_count_75 + "," + row.views_count_100 + ");'>[<i class='fas fa-info-circle'></i> Details]</a></span>";
tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Format") . ":"; ?> </span>" + row.typeLabels + ""; tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Format") . ":"; ?> </span>" + row.typeLabels + "";
if (row.encoderURL) { if (row.encoderURL) {
tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Encoder") . ":"; ?> </span><span class=\"label label-default \">" + row.encoderURL + "</span>"; tags += "<div class=\"clearfix\"></div><span class='label label-primary tagTitle'><?php echo __("Encoder") . ":"; ?> </span><span class=\"label label-default \">" + row.encoderURL + "</span>";
@ -1903,6 +1908,15 @@ if (Permissions::canAdminVideos()) {
var tags = "<input type='checkbox' name='checkboxVideo' class='checkboxVideo' value='" + row.id + "'>"; var tags = "<input type='checkbox' name='checkboxVideo' class='checkboxVideo' value='" + row.id + "'>";
return tags; return tags;
}, },
"total_seconds_watching": function (column, row) {
return '<small style="white-space: normal;">'
+'<a href="#" onclick="avideoModalIframe(webSiteRootURL +\'view/videoViewsInfo.php?videos_id='+(row.id.toString())+'\');return false;">'
+(row.total_seconds_watching_human.toString())
+'</a></small>';
},
"views_count": function (column, row) {
return row.views_count_short;
},
"titleTag": function (column, row) { "titleTag": function (column, row) {
var tags = ""; var tags = "";
var youTubeLink = "", youTubeUpload = ""; var youTubeLink = "", youTubeUpload = "";

107
view/videoViewsInfo.php Normal file
View file

@ -0,0 +1,107 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
$videos_id = intval(@$_REQUEST['videos_id']);
if (empty($videos_id)) {
forbiddenPage("Videos IF is required");
}
if (!Video::canEdit($videos_id)) {
forbiddenPage("You cannot see this info");
}
$_REQUEST['rowCount'] = 20;
$_POST['sort']['created'] = 'DESC';
$statistics = VideoStatistic::getAllFromVideos_id($videos_id);
$total = VideoStatistic::getTotalFromVideos_id($videos_id);
$totalPages = ceil($total/$_REQUEST['rowCount']);
$v = new Video('', '', $videos_id);
//var_dump($total);exit;
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<title><?php echo $titleTag . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container-fluid">
<h1>
<?php
echo $v->getTitle();
?>
</h1>
<h3>
<?php
echo number_format_short($v->getViews_count());
?>
Views and watched
<?php
echo seconds2human($v->getTotal_seconds_watching());
?>
</h3>
<?php
$pag = getPagination($totalPages);
echo $pag;
?>
<table class="table table-hover">
<thead>
<tr>
<th>User</th>
<th>When</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<?php
foreach ($statistics as $value) {
?>
<tr>
<td>
<?php
echo User::getNameIdentificationById($value['users_id']);
?>
</td>
<td>
<?php
echo humanTimingAgo($value['when']);
?>
</td>
<td>
<?php
echo seconds2human($value['seconds_watching_video']);
?>
</td>
</tr>
<?php
}
?>
</tbody>
<tfoot>
<th>User</th>
<th>When</th>
<th>Time</th>
</tfoot>
</table>
<?php
echo $pag;
?>
</div>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
</body>
</html>