1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Daniel Neto 2024-01-12 16:11:53 -03:00
parent 204822fd0e
commit d24e45fb58
11 changed files with 61 additions and 31 deletions

View file

@ -386,7 +386,11 @@ class Category
} }
if ($onlyWithVideos) { 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 AND id != c.id)) > 0 "; $sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if(isForKidsSet()){
$sql .= " AND v.made_for_kids = 1 ";
}
$sql .= " AND v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id AND id != c.id)) > 0 ";
if (AVideoPlugin::isEnabledByName("Live")) { if (AVideoPlugin::isEnabledByName("Live")) {
$sql .= " OR " $sql .= " OR "
. " (" . " ("
@ -404,6 +408,7 @@ class Category
} }
$sql .= ")"; $sql .= ")";
} }
if ($sameUserGroupAsMe) { if ($sameUserGroupAsMe) {
//_error_log('getAllCategories getUserGroups'); //_error_log('getAllCategories getUserGroups');
$users_groups = UserGroups::getUserGroups($sameUserGroupAsMe); $users_groups = UserGroups::getUserGroups($sameUserGroupAsMe);
@ -941,7 +946,11 @@ class Category
$sql .= "AND parentId = 0 OR parentId = -1 "; $sql .= "AND parentId = 0 OR parentId = -1 ";
} }
if ($onlyWithVideos) { 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 AND id != c.id)) > 0 "; $sql .= " AND ((SELECT count(*) FROM videos v where 1=1 ";
if(isForKidsSet()){
$sql .= " AND v.made_for_kids = 1 ";
}
$sql .= " AND v.categories_id = c.id OR categories_id IN (SELECT id from categories where parentId = c.id AND id != c.id) ) > 0 ";
if (AVideoPlugin::isEnabledByName("Live")) { if (AVideoPlugin::isEnabledByName("Live")) {
$sql .= " OR " $sql .= " OR "
. " (" . " ("

View file

@ -213,6 +213,12 @@ if ($resp === User::USER_NOT_VERIFIED) {
die(json_encode($object)); die(json_encode($object));
} }
if ($resp === User::SYSTEM_ERROR) {
_error_log("login.json.php System error", AVideoLog::$ERROR);
$object->error = __("System error, check your logs");
die(json_encode($object));
}
if ($resp === User::CAPTCHA_ERROR) { if ($resp === User::CAPTCHA_ERROR) {
_error_log("login.json.php invalid captcha"); _error_log("login.json.php invalid captcha");
$object->error = __("Invalid Captcha"); $object->error = __("Invalid Captcha");

View file

@ -105,7 +105,7 @@ class sqlDAL
// make sure it does not store autid transactions // make sure it does not store autid transactions
if(strpos($preparedStatement, 'CachesInDB')===false){ if(strpos($preparedStatement, 'CachesInDB')===false){
$debug = debug_backtrace(); $debug = debug_backtrace();
if (empty($debug[2]['class']) || $debug[2]['class'] !== "AuditTable") { if (empty($debug[2]['class']) || $debug[2]['class'] !== "AuditTable" && class_exists('AVideoPlugin')) {
$audit = AVideoPlugin::loadPluginIfEnabled('Audit'); $audit = AVideoPlugin::loadPluginIfEnabled('Audit');
if (!empty($audit)) { if (!empty($audit)) {
try { try {

View file

@ -325,6 +325,10 @@ class PlayList extends ObjectYPT
$sql .= " LEFT JOIN videos v ON pl.id = serie_playlists_id "; $sql .= " LEFT JOIN videos v ON pl.id = serie_playlists_id ";
} }
$sql .= " LEFT JOIN users u ON u.id = pl.users_id WHERE 1=1 "; $sql .= " LEFT JOIN users u ON u.id = pl.users_id WHERE 1=1 ";
if($includeSeries && isForKidsSet()){
$sql .= " AND v.made_for_kids = 1 ";
}
if (!empty($playlists_id)) { if (!empty($playlists_id)) {
$sql .= " AND pl.id = '{$playlists_id}' "; $sql .= " AND pl.id = '{$playlists_id}' ";
} }

View file

@ -131,9 +131,9 @@ class User
function setBirth_date($birth_date): void function setBirth_date($birth_date): void
{ {
if(_empty($birth_date)){ if (_empty($birth_date)) {
$this->birth_date = 'NULL'; $this->birth_date = 'NULL';
}else{ } else {
$time = strtotime($birth_date); $time = strtotime($birth_date);
$this->birth_date = date('Y/m/d', $time); $this->birth_date = date('Y/m/d', $time);
} }
@ -817,7 +817,7 @@ if (typeof gtag !== \"function\") {
} }
if (!_empty($this->birth_date)) { if (!_empty($this->birth_date)) {
$values[] = $this->birth_date; $values[] = $this->birth_date;
}else{ } else {
$values[] = null; $values[] = null;
} }
$formats .= "s"; $formats .= "s";
@ -1125,9 +1125,14 @@ if (typeof gtag !== \"function\") {
public const USER_NOT_FOUND = 2; public const USER_NOT_FOUND = 2;
public const CAPTCHA_ERROR = 3; public const CAPTCHA_ERROR = 3;
public const REQUIRE2FA = 4; public const REQUIRE2FA = 4;
public const SYSTEM_ERROR = 5;
public function login($noPass = false, $encodedPass = false, $ignoreEmailVerification = false) public function login($noPass = false, $encodedPass = false, $ignoreEmailVerification = false)
{ {
if (!class_exists('AVideoPlugin')) {
_error_log("ERROR login($noPass, $encodedPass, $ignoreEmailVerification) " . json_encode(debug_backtrace()));
return self::SYSTEM_ERROR;
}
if (User::isLogged()) { if (User::isLogged()) {
//_error_log('User:login is already logged '.json_encode($_SESSION['user']['id'])); //_error_log('User:login is already logged '.json_encode($_SESSION['user']['id']));
return self::USER_LOGGED; return self::USER_LOGGED;
@ -1371,12 +1376,12 @@ if (typeof gtag !== \"function\") {
$user = new User($users_id); $user = new User($users_id);
$birth_date = $user->getBirth_date(); $birth_date = $user->getBirth_date();
} else { } else {
if(empty($_SESSION['user']['birth_date'])){ if (empty($_SESSION['user']['birth_date'])) {
self::recreateLoginFromCookie(); self::recreateLoginFromCookie();
} }
if(!empty($_SESSION['user']['birth_date'])){ if (!empty($_SESSION['user']['birth_date'])) {
$birth_date = $_SESSION['user']['birth_date']; $birth_date = $_SESSION['user']['birth_date'];
}else{ } else {
$user = new User(User::getId()); $user = new User(User::getId());
$birth_date = $_SESSION['user']['birth_date'] = $user->getBirth_date(); $birth_date = $_SESSION['user']['birth_date'] = $user->getBirth_date();
} }
@ -1393,7 +1398,7 @@ if (typeof gtag !== \"function\") {
$birth_date = new DateTime($birth_date); $birth_date = new DateTime($birth_date);
$current_date = new DateTime('now'); $current_date = new DateTime('now');
$age = $current_date->diff($birth_date)->y; $age = $current_date->diff($birth_date)->y;
if($age<0){ if ($age < 0) {
return 0; return 0;
} }
return $age; return $age;
@ -3028,6 +3033,9 @@ if (typeof gtag !== \"function\") {
case self::REQUIRE2FA: case self::REQUIRE2FA:
_error_log("loginFromRequest REQUIRE2FA {$_REQUEST['user']}"); _error_log("loginFromRequest REQUIRE2FA {$_REQUEST['user']}");
break; break;
case self::SYSTEM_ERROR:
_error_log("loginFromRequest SYSTEM_ERROR {$_REQUEST['user']}");
break;
default: default:
_error_log("loginFromRequest UNDEFINED {$_REQUEST['user']}"); _error_log("loginFromRequest UNDEFINED {$_REQUEST['user']}");
break; break;

View file

@ -1472,7 +1472,7 @@ if (!class_exists('Video')) {
$sql .= " UNION "; $sql .= " UNION ";
$sql .= "SELECT * FROM videos v WHERE v.id != {$videos_id} AND v.status='a' "; $sql .= "SELECT * FROM videos v WHERE v.id != {$videos_id} AND v.status='".Video::$statusActive."' ";
if(isForKidsSet()){ if(isForKidsSet()){
$sql .= " AND made_for_kids = 1 "; $sql .= " AND made_for_kids = 1 ";

View file

@ -1052,7 +1052,7 @@ class CDNStorage
$totalTime = time() - $modified; $totalTime = time() - $modified;
if ($totalTime > 300) { if ($totalTime > 300) {
if ($totalTime > 10000) { if ($totalTime > 10000) {
unlink($file); @unlink($file);
return false; return false;
} else { } else {
// if is laonger than 5 min say it is not moving // if is laonger than 5 min say it is not moving
@ -1071,7 +1071,7 @@ class CDNStorage
$extension = strtolower($path_parts['extension']); $extension = strtolower($path_parts['extension']);
if ($extension == 'ts') { if ($extension == 'ts') {
unlink($file_path); @unlink($file_path);
} elseif (in_array($extension, CDNStorage::$allowedFiles)) { } elseif (in_array($extension, CDNStorage::$allowedFiles)) {
file_put_contents($file_path, 'Dummy File'); file_put_contents($file_path, 'Dummy File');
} else { } else {
@ -1301,7 +1301,7 @@ class CDNStorage
if (empty($file_exists)) { if (empty($file_exists)) {
$file_exists = CDNStorage::file_exists_on_cdn($relativeFilename); $file_exists = CDNStorage::file_exists_on_cdn($relativeFilename);
if (!$file_exists && isDummyFile($localFile)) { if (!$file_exists && isDummyFile($localFile)) {
unlink($localFile); @unlink($localFile);
} else if ($file_exists && !isDummyFile($localFile)) { } else if ($file_exists && !isDummyFile($localFile)) {
self::createDummy($localFile); self::createDummy($localFile);
} }
@ -1318,7 +1318,7 @@ class CDNStorage
} else { } else {
$filesize = filesize($localFile); $filesize = filesize($localFile);
if (empty($filesize) || isDummyFile($localFile)) { if (empty($filesize) || isDummyFile($localFile)) {
unlink($localFile); @unlink($localFile);
} else if (!isDummyFile($localFile)) { } else if (!isDummyFile($localFile)) {
_error_log('convertCDNHLSVideoToDownlaod: Upload file to CDN ' . $localFile); _error_log('convertCDNHLSVideoToDownlaod: Upload file to CDN ' . $localFile);
$client = CDNStorage::getStorageClient(); $client = CDNStorage::getStorageClient();

View file

@ -17,6 +17,9 @@ if(empty($_GET['tagsid']) && !empty($_REQUEST['tags_id'])){
$onlySuggested = $obj->CategoriesShowOnlySuggested; $onlySuggested = $obj->CategoriesShowOnlySuggested;
if(!empty(getSearchVar())){ if(!empty(getSearchVar())){
$onlySuggested = false; $onlySuggested = false;
echo '<!-- modeGalleryCategory start -->';
}else{
echo '<!-- modeGalleryCategory onlySuggested start -->';
} }
$sort = @$_POST['sort']; $sort = @$_POST['sort'];
unset($_POST['sort']); unset($_POST['sort']);
@ -34,7 +37,6 @@ if (empty($categories)) {
unsetCurrentPage(); unsetCurrentPage();
$_REQUEST['rowCount'] = $obj->CategoriesRowCount; $_REQUEST['rowCount'] = $obj->CategoriesRowCount;
?> ?>
<!-- modeGalleryCategory start -->
<div class="categoriesContainerItem"> <div class="categoriesContainerItem">
<?php <?php
//var_dump($categories);exit; //var_dump($categories);exit;

View file

@ -1,9 +1,8 @@
<style> <style>
.row-label { .row-label {
display: flex; display: flex;
/* Enables Flexbox */
align-items: center; align-items: center;
/* Centers items vertically */ justify-content: space-between;
} }
.colorful-text { .colorful-text {

View file

@ -40,15 +40,6 @@
</li> </li>
<?php <?php
} }
if (Video::videoMadeForKidsExists()) {
?>
<li style="width: 100%;">
<?php
include $global['systemRootPath'] . 'view/include/forKids.php';
?>
</li>
<?php
}
?> ?>
</ul> </ul>
</li> </li>

View file

@ -9,18 +9,15 @@ global $avideoLayout;
if (empty($advancedCustom->doNotShowLeftHomeButton)) { if (empty($advancedCustom->doNotShowLeftHomeButton)) {
?> ?>
<li> <li>
<div> <div>
<a href="<?php echo getHomePageURL(); ?>" class="btn btn-primary btn-block " style="border-radius: 4px 4px 0 0;"> <a href="<?php echo getHomePageURL(); ?>" class="btn btn-primary btn-block " style="border-radius: 4px 4px 0 0;">
<span class="fa fa-home"></span> <span class="fa fa-home"></span>
<?php echo __("Home"); ?> <?php echo __("Home"); ?>
</a> </a>
</div> </div>
</li> </li>
<?php <?php
} }
if (AVideoPlugin::isEnabledByName("PlayLists") && PlayLists::showTVFeatures()) { if (AVideoPlugin::isEnabledByName("PlayLists") && PlayLists::showTVFeatures()) {
?> ?>
<li> <li>
@ -66,6 +63,20 @@ global $avideoLayout;
</li> </li>
<?php <?php
} }
if (Video::videoMadeForKidsExists()) {
?>
<li>
<hr>
</li>
<li>
<div>
<?php
include $global['systemRootPath'] . 'view/include/forKids.php';
?>
</div>
</li>
<?php
}
if (empty($advancedCustomUser->doNotShowLeftProfile)) { if (empty($advancedCustomUser->doNotShowLeftProfile)) {
if (User::isLogged()) { if (User::isLogged()) {
?> ?>