1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00

Improve videos performance adding the likes and dislikes count on the videos table

also the admin can edit the total likes now
This commit is contained in:
Daniel 2021-11-16 09:51:04 -03:00
parent da071dad02
commit 57a7de324d
23 changed files with 484 additions and 101 deletions

View file

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

View file

@ -152,6 +152,8 @@ CREATE TABLE IF NOT EXISTS `videos` (
`live_transmitions_history_id` INT(11) NULL DEFAULT NULL,
`total_seconds_watching` INT(11) NULL DEFAULT 0,
`duration_in_seconds` INT NULL DEFAULT NULL,
`likes` INT(11) NULL DEFAULT NULL,
`dislikes` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `fk_videos_users_idx` (`users_id` ASC),
INDEX `fk_videos_categories1_idx` (`categories_id` ASC),
@ -163,6 +165,8 @@ CREATE TABLE IF NOT EXISTS `videos` (
INDEX `video_filename_INDEX` (`filename` ASC),
INDEX `video_status_idx` (`status` ASC),
INDEX `video_type_idx` (`type` ASC) ,
INDEX `videos_likes_index` (`likes` ASC),
INDEX `videos_dislikes_index` (`dislikes` 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`),

View file

@ -7524,10 +7524,10 @@ function getTimestampFromTimezone($date, $fromTimezone) {
}
function getCSSAnimation($type='animate__fadeInUp', $loaderSequenceName='default', $delay = 0.1){
function getCSSAnimation($type='animate__flipInX', $loaderSequenceName='default', $delay = 0.1){
global $_getCSSAnimationClassDelay;
getCSSAnimationClassAndStyleAddWait($delay, $loaderSequenceName);
return array('css'=>'animate__animated '.$type, 'style'=>"-webkit-animation-delay: {$_getCSSAnimationClassDelay[$loaderSequenceName]}s; animation-delay: {$_getCSSAnimationClassDelay[$loaderSequenceName]}s;");
return array('class'=>'animate__animated '.$type, 'style'=>"-webkit-animation-delay: {$_getCSSAnimationClassDelay[$loaderSequenceName]}s; animation-delay: {$_getCSSAnimationClassDelay[$loaderSequenceName]}s;");
}
function getCSSAnimationClassAndStyleAddWait($delay, $loaderSequenceName='default'){
@ -7543,5 +7543,5 @@ function getCSSAnimationClassAndStyleAddWait($delay, $loaderSequenceName='defaul
function getCSSAnimationClassAndStyle($type='animate__flipInX', $loaderSequenceName='default', $delay = 0.1){
$array = getCSSAnimation($type, $loaderSequenceName, $delay);
return "{$array['css']}\" style=\"{$array['style']}";
return "{$array['class']}\" style=\"{$array['style']}";
}

View file

@ -16,4 +16,4 @@ if(empty($_POST['videos_id']) && !empty($_GET['videos_id'])){
}
$like = new Like($_GET['like'], $_POST['videos_id']);
echo json_encode(Like::getLikes($_POST['videos_id']));
echo json_encode(Video::getVideoLikes($_POST['videos_id']));

View file

@ -25,9 +25,29 @@ class Like
// if click again in the same vote, remove the vote
if ($this->like == $like) {
$like = 0;
if($this->like==1){
Video::updateLikesDislikes($videos_id, 'likes', '-1');
}else if($this->like==-1){
Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
}
}else{
if(!empty($this->like)){
// need to remove some like or dislike
if($like==1){
Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
}else if($like==-1){
Video::updateLikesDislikes($videos_id, 'likes', '-1');
}
}
if($like==1){
Video::updateLikesDislikes($videos_id, 'likes', '+1');
}else if($like==-1){
Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
}
}
//exit;
$this->setLike($like);
$this->save();
$saved = $this->save();
}
private function setLike($like)
@ -85,9 +105,16 @@ class Like
return $res;
}
public static function getLikes($videos_id)
{
global $global;
public static function getLikes($videos_id){
global $global, $_getLikes;
if(!isset($_getLikes)){
$_getLikes = array();
}
if(!empty($_getLikes[$videos_id])){
return $_getLikes[$videos_id];
}
$obj = new stdClass();
$obj->videos_id = $videos_id;
@ -113,6 +140,7 @@ class Like
die($sql.'\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
$obj->dislikes = intval($row['total']);
$_getLikes[$videos_id] = $obj;
return $obj;
}

View file

@ -0,0 +1,39 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
header('Content-Type: application/json');
$obj = new stdClass();
$obj->videos_id = intval($_REQUEST['videos_id']);
if (isset($_REQUEST['likes'])) {
$obj->likes = intval($_REQUEST['likes']);
}
if (isset($_REQUEST['dislikes'])) {
$obj->dislikes = intval($_REQUEST['dislikes']);
}
$obj->video_likes = 0;
$obj->video_dislikes = 0;
$obj->error = true;
$obj->msg = '';
if (empty($obj->videos_id)) {
$obj->msg = 'invalid videos_id';
die(json_encode($obj));
}
if (!Permissions::canAdminVideos()) {
$obj->msg = 'Cannot admin videos';
die(json_encode($obj));
}
if (isset($obj->likes)) {
$obj->video_likes = Video::updateLikesDislikes($obj->videos_id, 'likes', $obj->likes);
}
if (isset($obj->dislikes)) {
$obj->video_dislikes = Video::updateLikesDislikes($obj->videos_id, 'dislikes', $obj->dislikes);
}
$obj->error = false;
die(json_encode($obj));

View file

@ -345,7 +345,7 @@ class PlayList extends ObjectYPT {
public static function getVideosFromPlaylist($playlists_id) {
$sql = "SELECT *,v.created as cre, p.`order` as video_order, v.externalOptions as externalOptions "
. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
. " FROM playlists_has_videos p "
. " LEFT JOIN videos as v ON videos_id = v.id "
. " LEFT JOIN users u ON u.id = v.users_id "

View file

@ -59,6 +59,8 @@ if (!class_exists('Video')) {
private $live_transmitions_history_id;
private $total_seconds_watching;
private $duration_in_seconds;
private $likes;
private $dislikes;
public static $statusDesc = array(
'a' => 'Active',
'k' => 'Active and Encoding',
@ -707,9 +709,10 @@ if (!class_exists('Video')) {
. " nv.clean_title as next_clean_title,"
. " nv.filename as next_filename,"
. " nv.id as next_id,"
. " c.id as category_id,c.iconClass,c.name as category,c.iconClass, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes ";
. " c.id as category_id,c.iconClass,c.name as category,c.iconClass, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes "
;
if (User::isLogged()) {
$sql .= ", (SELECT `like` FROM likes as l where l.videos_id = v.id AND users_id = '" . User::getId() . "' ) as myVote ";
} else {
@ -825,6 +828,12 @@ if (!class_exists('Video')) {
$res = sqlDAL::readSql($sql);
$video = sqlDAL::fetchAssoc($res);
if (is_null($video['likes'])) {
$video['likes'] = self::updateLikesDislikes($video['id'], 'likes');
}
if (is_null($video['dislikes'])) {
$video['dislikes'] = self::updateLikesDislikes($video['id'], 'dislikes');
}
// if there is a search, and there is no data and is inside a channel try again without a channel
if (!empty($_GET['search']) && empty($video) && !empty($_GET['channelName'])) {
$channelName = $_GET['channelName'];
@ -846,6 +855,32 @@ if (!class_exists('Video')) {
return $video;
}
public static function getVideoLikes($videos_id) {
global $global, $_getLikes;
if (!isset($_getLikes)) {
$_getLikes = array();
}
if (!empty($_getLikes[$videos_id])) {
return $_getLikes[$videos_id];
}
require_once $global['systemRootPath'] . 'objects/like.php';
$obj = new stdClass();
$obj->videos_id = $videos_id;
$obj->likes = 0;
$obj->dislikes = 0;
$obj->myVote = Like::getMyVote($videos_id);
$video = Video::getVideoLight($obj->videos_id);
$obj->likes = intval($video['likes']);
$obj->dislikes = intval($video['dislikes']);
$_getLikes[$videos_id] = $obj;
return $obj;
}
public static function getVideoLight($id) {
global $global, $config;
$id = intval($id);
@ -1020,9 +1055,9 @@ if (!class_exists('Video')) {
}
$status = str_replace("'", "", $status);
$sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes, "
. " (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes "
$sql = "SELECT u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description, v.created as videoCreation, v.modified as videoModified "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes "
. " FROM videos as v "
. " LEFT JOIN categories c ON categories_id = c.id "
. " LEFT JOIN users u ON v.users_id = u.id "
@ -1222,6 +1257,12 @@ if (!class_exists('Video')) {
TimeLogEnd($timeLogName, __LINE__, 0.2);
$global['mysqli']->begin_transaction();
foreach ($fullData as $row) {
if (is_null($row['likes'])) {
$row['likes'] = self::updateLikesDislikes($row['id'], 'likes');
}
if (is_null($row['dislikes'])) {
$row['dislikes'] = self::updateLikesDislikes($row['id'], 'dislikes');
}
if (empty($row['duration_in_seconds'])) {
$row['duration_in_seconds'] = self::updateDurationInSeconds($row['id'], $row['duration']);
}
@ -1286,7 +1327,6 @@ if (!class_exists('Video')) {
$row['statistc_week'] = VideoStatistic::getStatisticTotalViews($row['id'], false, $previewsWeek, $today);
$row['statistc_month'] = VideoStatistic::getStatisticTotalViews($row['id'], false, $previewsMonth, $today);
$row['statistc_unique_user'] = VideoStatistic::getStatisticTotalViews($row['id'], true);
}
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
$otherInfocachename = "otherInfo{$row['id']}";
@ -4119,6 +4159,26 @@ if (!class_exists('Video')) {
return $r;
}
public static function getTotalVideosThumbsUpFromUserFromVideos($users_id) {
global $global;
$sql = "SELECT sum(likes) as thumbsUp, sum(dislikes) as thumbsDown from videos WHERE users_id = ? ";
$res = sqlDAL::readSql($sql, "i", array($users_id));
$videoRows = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$r = array('thumbsUp' => 0, 'thumbsDown' => 0);
if ($res != false) {
foreach ($videoRows as $row) {
$r['thumbsUp'] += intval($row['thumbsUp']);
$r['thumbsDown'] += intval($row['thumbsDown']);
}
}
return $r;
}
public static function deleteThumbs($filename, $doNotDeleteSprit = false) {
if (empty($filename)) {
return false;
@ -4872,6 +4932,69 @@ if (!class_exists('Video')) {
$this->duration_in_seconds = intval($duration_in_seconds);
}
function getLikes() {
return $this->likes;
}
function getDislikes() {
return $this->dislikes;
}
function setLikes($likes): void {
$this->likes = intval($likes);
}
function setDislikes($dislikes): void {
$this->dislikes = intval($dislikes);
}
/**
*
* @param type $videos_id
* @param type $type [like or dislike]
* @param type $value
* @return boolean
*
* automatic = will get from like table
* +1 = add one
* -1 = remove one
* any number = will change the database
*/
public static function updateLikesDislikes($videos_id, $type, $value = 'automatic') {
global $global;
require_once $global['systemRootPath'] . 'objects/like.php';
$videos_id = intval($videos_id);
if (empty($videos_id)) {
return false;
}
if (strtolower($type) == 'likes') {
$type = 'likes';
} else {
$type = 'dislikes';
}
//var_dump($videos_id, $type, $value);
$sql = "UPDATE videos SET ";
if ($value == 'automatic') {
$likes = Like::getLikes($videos_id);
return self::updateLikesDislikes($videos_id, $type, $likes->$type);
} else if (preg_match('/\+([0-9]+)/', $value, $matches)) {
$value = intval($matches[1]);
$sql .= " {$type} = {$type}+{$value} ";
} else if (preg_match('/-([0-9]+)/', $value, $matches)) {
$value = intval($matches[1]);
$sql .= " {$type} = {$type}-{$value} ";
} else {
$value = intval($value);
$sql .= " {$type} = {$value} ";
}
$sql .= ", modified = now() WHERE id = {$videos_id}";
//secho $sql.PHP_EOL;
$saved = sqlDAL::writeSql($sql);
self::clearCache($videos_id);
return $value;
}
static function checkIfIsBroken($videos_id) {
$video = new Video('', '', $videos_id);
if ($video->getStatus() == Video::$statusActive || $video->getStatus() == Video::$statusUnlisted) {

View file

@ -174,4 +174,12 @@ class VastCampaignsVideos extends ObjectYPT {
return parent::delete();
}
public function save() {
if(empty($this->vast_campaigns_id)){
return false;
}
return parent::save();
}
}

View file

@ -20,7 +20,7 @@ $leaderBoardTop = getAdsLeaderBoardTop();
echo '<div class="row text-center" style="padding: 10px;">'.$leaderBoardTop.'</div>';
}
?>
<div class="col-lg-10 col-lg-offset-1 addWidthOnMenuOpen">
<div class="col-lg-10 col-lg-offset-1">
<div class="panel panel-default">
<div class="panel-body">
<?php

View file

@ -46,9 +46,7 @@ if (empty($obj->hideTopButton)) {
overflow: hidden;
}
</style>
<li class="dropdown" onclick="setTimeout(function () {
lazyImage();
}, 200);">
<li class="dropdown" onclick="setTimeout(function () {lazyImage();}, 500);setTimeout(function () {lazyImage();}, 1000);setTimeout(function () {lazyImage();}, 1500);">
<a href="#" class="faa-parent animated-hover btn btn-default navbar-btn" data-toggle="dropdown">
<span class="fas fa-bell faa-ring"></span>
<span class="badge onlineApplications" style=" background: rgba(255,0,0,1); color: #FFF;">0</span>
@ -252,6 +250,7 @@ if (empty($obj->hideTopButton)) {
} else {
$('#availableLiveStream').prepend(notificationHTML);
}
animateChilds('#availableLiveStream', 'animate__bounceInRight', 0.05);
} else {
//console.log('processApplication is already present '+notificatioID, application.className);
}

View file

@ -36,11 +36,13 @@ class PayPalYPT extends PluginAbstract {
}
public function getDescription() {
return "Paypal module for several purposes<br>
$msg = "Paypal module for several purposes<br>
Go to Paypal developer <a href='https://developer.paypal.com/developer/applications' target='_blank'>Site here</a> (you must have Paypal account, of course)
<br>Click on Create App on right side of page
<br>Choose name of your app and click Create App
<br>Now you can see and manage everything include client ID and secret.";
$msg .= "<br>Payouts need to be enabled for the live environment. They work in the sandbox but until you actually go to the account status page and click on the link to enable it you will get the AUTHORIZATION_ERROR. It will ask you some questions. Answer them and get ready for them to email you back for a more complete description of how you are going to use their services. This can take a few days.";
return $msg;
}
public function getName() {

View file

@ -118,11 +118,48 @@ class VideosStatistics extends PluginAbstract {
}
static public function getTotalLikes($users_id) {
return self::getTotalLikesDislikes($users_id, 1, 0);
return self::getTotalLikesDislikesFromVideos($users_id, 1, 0);
}
static public function getTotalDislikes($users_id) {
return self::getTotalLikesDislikes($users_id, -1, 0);
return self::getTotalLikesDislikesFromVideos($users_id, -1, 0);
}
static public function getTotalLikesDislikesFromVideos($users_id, $like, $days) {
global $_getTotalLikesDislikes;
$index = "$users_id, $like, $days";
if(!isset($_getTotalLikesDislikes)){
$_getTotalLikesDislikes = array();
}
if(isset($_getTotalLikesDislikes[$index])){
return $_getTotalLikesDislikes[$index];
}
$column = 'likes';
if($like == -1){
$column = 'dislikes';
}
$sql = "SELECT sum({$column}) as total FROM videos WHERE 1=1 ";
$users_id = intval($users_id);
if (!empty($users_id)) {
$sql .= " AND users_id = $users_id ";
}
if (!empty($days)) {
$sql .= " AND modified > (NOW() - INTERVAL {$days} DAY) ";
}
$total = 0;
$res = sqlDAL::readSql($sql);
if ($res != false) {
$row = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
$total = intval($row['total']);
}
$_getTotalLikesDislikes[$index] = $total;
return $total;
}
static public function getTotalLikesDislikes($users_id, $like, $days) {

View file

@ -138,12 +138,12 @@ if (!empty($obj->debugAllUsersSocket) || (User::isAdmin() && !empty($obj->debugS
echo getSocketConnectionLabel();
?>
</div>
<div class="socketItem hideNotDisconnected" ><button class="btn btn-xs btn-block btn-default" onclick="copyToClipboard('<?php echo addcslashes($command,'\\'); ?>')">Copy code to run on terminal</button></div>
<div class="socketItem hideNotConected" ><i class="fas fa-user"></i> Your User ID <span class="socket_users_id">0</span></div>
<div class="socketItem hideNotConected" ><i class="fas fa-id-card"></i> Socket ResourceId <span class="socket_resourceId">0</span></div>
<div class="socketItem hideNotConected" ><i class="fas fa-network-wired"></i> Total Different Devices <span class="total_devices_online">0</span></div>
<div class="socketItem hideNotConected" ><i class="fas fa-users"></i> Total Users Online <span class="total_users_online">0</span></div>
<div class="socketItem hideNotConected" id="socketUsersURI">
<div class="socketItem hideNotDisconnected <?php echo getCSSAnimationClassAndStyle('animate__flipInX', 'socket'); ?>" ><button class="btn btn-xs btn-block btn-default" onclick="copyToClipboard('<?php echo addcslashes($command,'\\'); ?>')">Copy code to run on terminal</button></div>
<div class="socketItem hideNotConected <?php echo getCSSAnimationClassAndStyle('animate__flipInX', 'socket'); ?>" ><i class="fas fa-user"></i> Your User ID <span class="socket_users_id">0</span></div>
<div class="socketItem hideNotConected <?php echo getCSSAnimationClassAndStyle('animate__flipInX', 'socket'); ?>" ><i class="fas fa-id-card"></i> Socket ResourceId <span class="socket_resourceId">0</span></div>
<div class="socketItem hideNotConected <?php echo getCSSAnimationClassAndStyle('animate__flipInX', 'socket'); ?>" ><i class="fas fa-network-wired"></i> Total Different Devices <span class="total_devices_online">0</span></div>
<div class="socketItem hideNotConected <?php echo getCSSAnimationClassAndStyle('animate__flipInX', 'socket'); ?>" ><i class="fas fa-users"></i> Total Users Online <span class="total_users_online">0</span></div>
<div class="socketItem hideNotConected <?php echo getCSSAnimationClassAndStyle('animate__flipInY', 'socket'); ?>" id="socketUsersURI">
</div>
</div>
<script>

View file

@ -0,0 +1,16 @@
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 `likes` INT(11) NULL DEFAULT NULL,
ADD COLUMN `dislikes` INT(11) NULL DEFAULT NULL,
ADD INDEX `videos_likes_index` (`likes` ASC),
ADD INDEX `videos_dislikes_index` (`dislikes` 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.5', modified = now() WHERE id = 1;

View file

@ -147,6 +147,10 @@ footer ul.list-inline li {
border-bottom-right-radius: 5px;
margin-bottom: 10px;
}
.container-fluid{
margin: 0;
transition: width 0.3s, margin 0.3s;
}
@media (max-width: 767px) {
.navbar-form, #modeYoutubeBottomContent, .principalContainer,
.nopaddingOnSmall,.container-fluid,.container, #yptRightBar,
@ -826,28 +830,6 @@ img.blur{
flex: 1
}
.addWidthOnMenuOpen {
transition: width 0.3s;
}
@media (min-width: 1200px){
body.youtube .lessMarginLeftOnMenuOpen{
margin-left: -200px;
}
body.youtube .col-lg-4.addWidthOnMenuOpen {
margin-left: -150px;
width: calc(33.3333333333% + 300px);
}
body.youtube .col-lg-10.addWidthOnMenuOpen {
width: 100%;
}
body.youtube .col-lg-offset-1.addWidthOnMenuOpen {
margin-left: 0;
}
}
.liveVideo .thumbsImage img{
width: 100%;
}

View file

@ -458,7 +458,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
echo '<!-- navbar line ' . __LINE__ . '-->';
?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="">
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu">
<?php
include $global['systemRootPath'] . 'view/include/navbarEncoder.php';
if (empty($advancedCustom->doNotShowUploadMP4Button)) {
@ -505,7 +505,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
} else {
echo '<!-- navbar line ' . __LINE__ . '-->';
?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="">
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu">
<li>
<a href="" >
<span class="fa fa-exclamation faa-flash animated"></span> <?php echo __("Only verified users can upload"); ?>
@ -537,7 +537,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
<i class="<?php echo isset($advancedCustom->uploadButtonDropdownIcon) ? $advancedCustom->uploadButtonDropdownIcon : "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? __($advancedCustom->uploadButtonDropdownText) : ""; ?> <span class="caret"></span>
</button>
<?php echo '<!-- navbar line ' . __LINE__ . '-->'; ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="">
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu">
<?php
echo $getUploadMenuButton;
?>
@ -625,19 +625,39 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
}
?>
<li class="rightProfile" <?php echo $tooltip; ?> >
<div class="btn-group" >
<div class="btn-group" id="rightProfileBtnGroup" >
<?php
if (User::isLogged()) {
?>
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left btn-circle" data-toggle="dropdown" id="rightProfileButton" style="padding:0;">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left btn-circle" id="rightProfileButton" style="padding:0;" onclick="toogleRightProfile();">
<img src="<?php echo User::getPhoto(); ?>"
style="width: 32px; height: 32px; max-width: 32px;"
class="img img-responsive img-circle" alt="User Photo"
/>
</button>
<script>
function toogleRightProfile(){
if($('#rightProfileBtnGroup').hasClass('open')){
$('#rightProfileButton').removeClass('glowBox');
$('#rightProfileBtnGroup .dropdown-menu').removeClass('animate__bounceInRight');
$('#rightProfileBtnGroup .dropdown-menu').addClass('animate__bounceOutRight');
setTimeout(function(){
$('#rightProfileBtnGroup').removeClass('open');
$('#rightProfileButton').attr('aria-expanded', false);
},500);
}else{
$('#rightProfileButton').addClass('glowBox');
$('#rightProfileBtnGroup .dropdown-menu').removeClass('animate__bounceOutRight');
$('#rightProfileBtnGroup .dropdown-menu').addClass('animate__bounceInRight');
$('#rightProfileBtnGroup').addClass('open');
$('#rightProfileButton').attr('aria-expanded', true).focus();
}
}
</script>
<?php echo '<!-- navbar line ' . __LINE__ . '-->'; ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="margin-right:10px;">
<ul class="dropdown-menu dropdown-menu-right <?php echo getCSSAnimationClassAndStyle('animate__bounceInRight', 'rightProfileButton', 0); ?>margin-right:10px;" >
<li>
<div class="pull-left" style="margin-left: 10px;">
<img src="<?php echo User::getPhoto(); ?>" style="max-width: 50px;" class="img img-responsive img-circle" alt="User Photo"/>

View file

@ -131,7 +131,12 @@ function clean_name(str) {
return str.replace(/[!#$&'()*+,/:;=?@[\] ]+/g, "-");
}
var processing_lazyImage = false;
function lazyImage() {
if(processing_lazyImage){
return false;
}
processing_lazyImage = true;
try {
if ($(".thumbsJPG").length) {
$('.thumbsJPG').lazy({
@ -152,6 +157,13 @@ function lazyImage() {
gif.lazy({
effect: 'fadeIn'
});
/*
gif.addClass('animate__animated');
gif.addClass('animate__bounceIn');
gif.css('-webkit-animation-delay', step+"s");
gif.css('animation-delay', "1s");
*/
gif.height(element.height());
gif.width(element.width());
//console.log('lazyImage', gif);
@ -166,6 +178,7 @@ function lazyImage() {
}
} catch (e) {
}
processing_lazyImage=false;
}
lazyImage();
@ -1412,6 +1425,12 @@ function checkDescriptionArea() {
});
}
$(document).ready(function () {
//animateChilds('#sideBarContainer > ul', 'animate__bounceInLeft', 0.05);
//animateChilds('#uploadMenu', 'animate__bounceIn', 0.05);
//animateChilds('#myNavbar > ul > li.dropdown > ul > div.btn-group.btn-group-justified', 'animate__bounceIn', 0.1);
//animateChilds('#lastItemOnMenu > div.navbar-header > ul > li > div > ul', 'animate__bounceInRight', 0.05);
//animateChilds('.gallerySectionContent, .categoriesContainerItem .clearfix', 'animate__fadeInUp', 0.05);
//animateChilds('#videosList', 'animate__bounceInRight', 0.1);
addViewFromCookie();
checkDescriptionArea();
setInterval(function () {// check for the carousel
@ -1965,3 +1984,15 @@ function socketClearSessionCache(json) {
console.log('socketClearSessionCache', json);
clearCache(false, 0, 1);
}
function animateChilds(selector, type, delay){
var step = delay;
$(selector).children().each(function () {
var $currentElement = $(this);
$currentElement.addClass('animate__animated');
$currentElement.addClass(type);
$currentElement.css('-webkit-animation-delay', step+"s");
$currentElement.css('animation-delay', step+"s");
step+=delay;
});
}

76
view/likes.edit.form.php Normal file
View file

@ -0,0 +1,76 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
if (!Permissions::canAdminVideos()) {
forbiddenPage("Cannot edit videos likes");
}
if (empty($_REQUEST['videos_id'])) {
forbiddenPage("videos_id is empty");
}
$video = Video::getVideoLight($_REQUEST['videos_id']);
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<title>Edit Likes</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="panel panel-default">
<div class="panel-heading">
<?php
echo $video['title'];
?>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-6">
<div class="input-group input-group-lg">
<span class="input-group-addon"><i class="far fa-thumbs-up"></i></span>
<input id="editLikes" type="number" step="1" class="form-control" placeholder="<?php echo __('Likes'); ?>" aria-label="<?php echo __('Likes'); ?>" value="<?php echo $video['likes']; ?>">
</div>
</div>
<div class="col-xs-6">
<div class="input-group input-group-lg">
<span class="input-group-addon"><i class="far fa-thumbs-down"></i></span>
<input id="editDislikes" type="number" step="1" class="form-control" placeholder="<?php echo __('Dislikes'); ?>" aria-label="<?php echo __('Dislikes'); ?>" value="<?php echo $video['dislikes']; ?>">
</div>
</div>
</div>
</div>
<div class="panel-footer">
<button class="btn btn-success btn-lg btn-block" onclick="saveLikes()">
<i class="fas fa-save"></i> <?php echo __('Save'); ?>
</button>
</div>
</div>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script>
function saveLikes() {
modal.showPleaseWait();
$.ajax({
url: webSiteRootURL +'objects/likes.edit.json.php',
data: {"videos_id": <?php echo $video['id']; ?>, likes:$('#editLikes').val(), dislikes:$('#editDislikes').val()},
type: 'post',
success: function (response) {
modal.hidePleaseWait();
avideoResponse(response);
}
});
}
</script>
</body>
</html>

View file

@ -80,7 +80,7 @@
<div class="panel-body">
<div class="btn-group btn-block" >
<?php if (User::isAdmin()) { ?>
<?php if (Permissions::canAdminVideos()) { ?>
<a href="<?php echo $global['webSiteRootURL']; ?>usersGroups" class="btn btn-sm btn-xs btn-warning">
<span class="fa fa-users"></span> <span class="hidden-md hidden-sm hidden-xs"><?php echo __("User Groups"); ?></span>
</a>
@ -93,7 +93,7 @@
<span class="hidden-md hidden-sm hidden-xs"><?php echo __("Video Chart"); ?></span>
</a>
<?php
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
?>
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/AD_Server/" class="btn btn-sm btn-xs btn-danger">
<span class="far fa-money-bill-alt"></span> <span class="hidden-md hidden-sm hidden-xs"><?php echo __("Advertising Manager"); ?></span>
@ -103,7 +103,7 @@
?>
<?php
unset($_GET['parentsOnly']);
$categories = Category::getAllCategories(User::isAdmin() ? false : true);
$categories = Category::getAllCategories(Permissions::canAdminVideos() ? false : true);
array_multisort(array_column($categories, 'hierarchyAndName'), SORT_ASC, $categories);
if (User::canUpload()) {
if (empty($advancedCustom->doNotShowEncoderButton)) {
@ -164,7 +164,7 @@
?>
</small>
<?php
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
echo diskUsageBars();
}
if (!empty($global['videoStorageLimitMinutes'])) {
@ -199,7 +199,7 @@
<?php
}
if ($advancedCustom->videosManegerBulkActionButtons) {
if (empty($advancedCustomUser->userCanNotChangeCategory) || User::isAdmin()) {
if (empty($advancedCustomUser->userCanNotChangeCategory) || Permissions::canAdminVideos()) {
?>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
@ -226,7 +226,7 @@
</ul>
</div>
<?php
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || Permissions::canAdminVideos()) {
?>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
@ -268,14 +268,14 @@
</div>
<?php
}
if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwapVideosOnlyForAdmin) || User::isAdmin())) {
if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwapVideosOnlyForAdmin) || Permissions::canAdminVideos())) {
?>
<button class="btn btn-primary" id="swapBtn">
<i class="fas fa-random"></i> <span class="hidden-md hidden-sm hidden-xs"><?php echo __('Swap Video File'); ?></span>
</button>
<?php
}
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
?>
<button class="btn btn-primary" id="updateAllUsage">
<i class="fas fa-chart-line"></i> <span class="hidden-md hidden-sm hidden-xs"><?php echo __('Update all videos disk usage'); ?></span>
@ -331,6 +331,12 @@
<th style="display: none;" data-column-id="sites_id" data-formatter="sites_id" data-width="50px" data-header-css-class='hidden-xs' data-css-class='hidden-xs'>
<?php echo htmlentities('<i class="fas fa-hdd" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Storage") . '"></i>'); ?>
</th>
<th style="display: none;" data-column-id="likes" data-width="50px" data-header-css-class='hidden-xs' data-css-class='hidden-xs'>
<?php echo htmlentities('<i class="far fa-thumbs-up" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Likes") . '"></i>'); ?>
</th>
<th style="display: none;" data-column-id="dislikes" data-width="50px" data-header-css-class='hidden-xs' data-css-class='hidden-xs'>
<?php echo htmlentities('<i class="far fa-thumbs-down" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Dislikes") . '"></i>'); ?>
</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'>
<?php echo htmlentities('<i class="fas fa-stopwatch" aria-hidden="true" data-placement="top" data-toggle="tooltip" title="' . __("Duration") . '"></i>'); ?>
</th>
@ -437,7 +443,7 @@
<label for="inputDescription" ><?php echo __("Description"); ?></label>
<textarea id="inputDescription" class="form-control" placeholder="<?php echo __("Description"); ?>" required></textarea>
<?php
if (empty($advancedCustomUser->userCanNotChangeCategory) || User::isAdmin()) {
if (empty($advancedCustomUser->userCanNotChangeCategory) || Permissions::canAdminVideos()) {
?>
<label for="inputCategory" ><?php echo __("Category"); ?></label>
<select class="form-control last" id="inputCategory" required>
@ -464,7 +470,7 @@
}
?>
</select>
<div class="row" <?php if (empty($advancedCustomUser->userCanChangeVideoOwner) && !User::isAdmin()) { ?> style="display: none;" <?php } ?>>
<div class="row" <?php if (empty($advancedCustomUser->userCanChangeVideoOwner) && !Permissions::canAdminVideos()) { ?> style="display: none;" <?php } ?>>
<h3><?php echo __("Media Owner"); ?></h3>
<div class="col-md-2">
<img id="inputUserOwner-img" src="view/img/userSilhouette.jpg" class="img img-responsive img-circle" style="max-height: 60px;" alt="User Photo">
@ -503,7 +509,7 @@
</li>
<?php
}
if (!empty($advancedCustomUser->userCanProtectVideosWithPassword) || User::isAdmin()) {
if (!empty($advancedCustomUser->userCanProtectVideosWithPassword) || Permissions::canAdminVideos()) {
?>
<li class="list-group-item">
<label for="inputVideoPassword"><?php echo __("Password Protected"); ?></label>
@ -511,8 +517,8 @@
</li>
<?php
}
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
if ($advancedCustom->paidOnlyUsersTellWhatVideoIs || User::isAdmin()) {
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || Permissions::canAdminVideos()) {
if ($advancedCustom->paidOnlyUsersTellWhatVideoIs || Permissions::canAdminVideos()) {
?>
<li class="list-group-item">
<i class="fas fa-money-check-alt"></i> <?php echo __("Only Paid Users Can see"); ?>
@ -582,7 +588,7 @@
</div>
<?php
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
?>
<div>
<label for="videoStartSecond" ><?php echo __("Video Views"); ?></label>
@ -728,7 +734,7 @@
</div>
<?php
}
if ((User::isAdmin()) && (!$config->getDisable_youtubeupload())) {
if ((Permissions::canAdminVideos()) && (!$config->getDisable_youtubeupload())) {
?>
<div class="alert alert-info">
<h1><span class="fab fa-youtube-square"></span> <?php echo __("Let us upload your video to YouTube"); ?></h1>
@ -845,7 +851,7 @@ if (empty($advancedCustom->disableHTMLDescription)) {
}
<?php
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
if (empty($advancedCustomUser->userCanNotChangeUserGroup) || Permissions::canAdminVideos()) {
?>
function userGroupSave(users_groups_id, add) {
modal.showPleaseWait();
@ -1704,7 +1710,7 @@ echo AVideoPlugin::getManagerVideosReset();
});
});
<?php
if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwapVideosOnlyForAdmin) || User::isAdmin())) {
if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwapVideosOnlyForAdmin) || Permissions::canAdminVideos())) {
?>
$("#swapBtn").click(function () {
@ -1731,7 +1737,7 @@ if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwap
});
<?php
}
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
?>
$("#updateAllUsage").click(function () {
@ -1856,7 +1862,7 @@ if (CustomizeUser::canDownloadVideos()) {
}
<?php
}
if (User::isAdmin()) {
if (Permissions::canAdminVideos()) {
?>
download += '<button type="button" class="btn btn-default btn-xs btn-block" onclick="whyICannotDownload(' + row.id + ');" data-toggle="tooltip" title="<?php echo str_replace("'", "\\'", __("Download disabled")); ?>"><span class="fa-stack" style="font-size: 0.8em;"><i class="fa fa-download fa-stack-1x"></i><i class="fas fa-ban fa-stack-2x" style="color:Tomato"></i></span></button>';
<?php
@ -1893,9 +1899,12 @@ if (User::isAdmin()) {
}
var suggestBtn = "";
var editLikes = "";
<?php
if (Permissions::canAdminVideos()) {
?>
editLikes = '<button type="button" class="btn btn-default btn-xs command-editlikes" data-toggle="tooltip" title="<?php echo str_replace("'", "\\'", __("Edit Likes")); ?>"><i class="far fa-thumbs-up"></i> <i class="far fa-thumbs-down"></i></button>';
var suggest = '<button style="color: #C60" type="button" class="btn btn-default btn-xs command-suggest" data-toggle="tooltip" title="<?php echo str_replace("'", "\\'", __("Unsuggest")); ?>"><i class="fas fa-star" aria-hidden="true"></i></button>';
var unsuggest = '<button style="" type="button" class="btn btn-default btn-xs command-suggest unsuggest" data-toggle="tooltip" title="<?php echo str_replace("'", "\\'", __("Suggest")); ?>"><i class="far fa-star" aria-hidden="true"></i></button>';
suggestBtn = unsuggest;
@ -1907,7 +1916,7 @@ if (Permissions::canAdminVideos()) {
?>
var playBtn = '<button type="button" class="btn btn-default btn-xs" onclick="avideoModalIframe(\'' + row.embedlink + '\')" data-toggle="tooltip" title="<?php echo __('Play'); ?>"><span class="fas fa-play" aria-hidden="true"></span></button>';
return playBtn + embedBtn + editBtn + deleteBtn + status + suggestBtn + pluginsButtons + download + nextIsSet;
return playBtn + embedBtn + editBtn + deleteBtn + status + suggestBtn + editLikes + pluginsButtons + download + nextIsSet;
},
"tags": function (column, row) {
var tags = "";
@ -2213,7 +2222,7 @@ if (Permissions::canAdminVideos()) {
var isSuggested = $(this).hasClass('unsuggest');
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>objects/videoSuggest.php',
url: webSiteRootURL + 'objects/videoSuggest.php',
data: {"id": row.id, "isSuggested": isSuggested},
type: 'post',
success: function (response) {
@ -2222,6 +2231,11 @@ if (Permissions::canAdminVideos()) {
}
});
});
grid.find(".command-editlikes").on("click", function (e) {
var row_index = $(this).closest('tr').index();
var row = $("#grid").bootgrid("getCurrentRows")[row_index];
avideoModalIframeSmall(webSiteRootURL + 'view/likes.edit.form.php?videos_id=' + row.id);
});
<?php
}
?>

View file

@ -29,7 +29,8 @@ $rows = array();
foreach ($users as $key => $value) {
// list all videos on that channel
$identification = User::getNameIdentificationById($value['id']);
$thumbs = Video::getTotalVideosThumbsUpFromUser($value['id'], $from, $to);
//$thumbs = Video::getTotalVideosThumbsUpFromUser($value['id'], $from, $to);
$thumbs = Video::getTotalVideosThumbsUpFromUserFromVideos($value['id']);
if(empty($thumbs['thumbsUp']) && empty($thumbs['thumbsDown'])){
continue;
}

View file

@ -1,3 +1,4 @@
<!--
<div class="row">
<div class="form-group col-sm-3">
<label for="datefrom3" class="col-sm-2 col-form-label"><?php echo __('From'); ?>:</label>
@ -15,6 +16,7 @@
<button class="btn btn-primary" id="refresh3"><i class="fa fa-refresh"></i> <?php echo __('Refresh'); ?></button>
</div>
</div>
-->
<table id="dt3" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
@ -39,11 +41,12 @@
};
}
$(document).ready(function () {
/*
$( "#datefrom3" ).datepicker();
$( "#datefrom3" ).datepicker( "setDate", "<?php echo date("m/d/Y", strtotime("-30 days"));?>" );
$( "#dateto3" ).datepicker();
$( "#dateto3" ).datepicker( "setDate", "<?php echo date("m/d/Y");?>" );
*/
$('#refresh3').click(function(){
$('#dt3').DataTable().ajax.reload();
});
@ -75,7 +78,7 @@
"ajax": {
'type': 'POST',
'url': "<?php echo $global['webSiteRootURL']; ?>view/report3.json.php",
'data': getData3,
//'data': getData3,
},
"columns": [
{"data": "channel"},

View file

@ -54,7 +54,7 @@ if (empty($_COOKIE) && get_browser_name() !== 'Other (Unknown)') {
?>
<div class="row loginPage">
<div class="hidden-xs col-sm-2 col-md-3 "></div>
<div class="col-xs-12 col-sm-8 col-md-6 addWidthOnMenuOpen">
<div class="col-xs-12 col-sm-8 col-md-6">
<div class="panel panel-default <?php echo getCSSAnimationClassAndStyle();getCSSAnimationClassAndStyleAddWait(0.5); ?>">
<div class="panel-heading">