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

Improve image404

This commit is contained in:
Daniel Neto 2024-02-28 10:40:51 -03:00
parent f279deb283
commit 57c159ee79
7 changed files with 36 additions and 15 deletions

View file

@ -11,7 +11,7 @@ includeLangFile();
function includeLangFile() {
global $t, $global;
if(empty($_SESSION)){
if(empty($_SESSION) && function_exists('_session_start')){
_session_start();
}
if(empty($_SESSION['language'])){

View file

@ -78,6 +78,9 @@ abstract class ObjectYPT implements ObjectInterface
static function getFromDb($id, $refreshCache = false)
{
global $global;
if(!class_exists('sqlDAL')){
return false;
}
$id = intval($id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE id = ? LIMIT 1";
//var_dump($sql, $id);
@ -416,6 +419,9 @@ abstract class ObjectYPT implements ObjectInterface
private function getAllFields()
{
global $global, $mysqlDatabase;
if(!class_exists('sqlDAL')){
return array();
}
$sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = '" . static::getTableName() . "'";
$res = sqlDAL::readSql($sql, "s", [$mysqlDatabase]);
$fullData = sqlDAL::fetchAllAssoc($res);
@ -1011,6 +1017,9 @@ abstract class ObjectYPT implements ObjectInterface
public static function isTableInstalled($tableName = "")
{
global $global, $tableExists;
if(!class_exists('sqlDAL')){
return false;
}
if (empty($tableName)) {
$tableName = static::getTableName();
}

View file

@ -8852,7 +8852,7 @@ function getCDN($type = 'CDN', $id = 0)
if ($type == 'CDN') {
if (!empty($global['ignoreCDN'])) {
return $global['webSiteRootURL'];
} elseif (!empty($advancedCustom) && isValidURL($advancedCustom->videosCDN)) {
} elseif (!empty($advancedCustom) && !empty($advancedCustom->videosCDN) && isValidURL($advancedCustom->videosCDN)) {
$_getCDNURL[$index] = addLastSlash($advancedCustom->videosCDN);
} elseif (empty($_getCDNURL[$index])) {
$_getCDNURL[$index] = $global['webSiteRootURL'];

View file

@ -1,5 +1,7 @@
<?php
if (!isset($global['skippPlugins'])) {
$global['skippPlugins'] = array();
}
/**
* Global variables.
*
@ -12,9 +14,6 @@ if (!empty($doNotIncludeConfig)) {
return false;
}
if (!isset($global['skippPlugins'])) {
$global['skippPlugins'] = array();
}
/*
if($_SERVER["HTTP_HOST"] === 'localhost' || $_SERVER["HTTP_HOST"] === '127.0.0.1'){
$global["webSiteRootURL"] = $_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["HTTP_HOST"].$global["webSiteRootPath"];

View file

@ -408,6 +408,9 @@ class Plugin extends ObjectYPT
public static function getEnabled($uuid)
{
global $global, $getEnabled;
if(!class_exists('sqlDAL')){
return array();
}
if (empty($getEnabled)) {
$getEnabled = [];
}

View file

@ -675,6 +675,9 @@ class AVideoPlugin
public static function isEnabled($uuid)
{
if(!class_exists('Plugin')){
return false;
}
return !empty(Plugin::getEnabled($uuid));
}

View file

@ -1,11 +1,17 @@
<?php
include(dirname(__FILE__) . '/image404Raw.php');
$doNotIncludeConfig = 1;
// Load configuration
$configFile = dirname(__FILE__) . '/../../videos/configuration.php';
require_once $configFile;
_session_write_close();
require_once $global['systemRootPath'] . 'objects/plugin.php';
require_once $global['systemRootPath'] . 'plugin/AVideoPlugin.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
require_once $global['systemRootPath'] . 'objects/images.php';
//_session_write_close();
// Default image settings
$file = ImagesPlaceHolders::getVideoPlaceholder(ImagesPlaceHolders::$RETURN_PATH);
@ -17,7 +23,8 @@ $imageURL = !empty($_GET['image']) ? $_GET['image'] : $_SERVER["REQUEST_URI"];
// Handle Thumbnails
if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
$video_filename = $matches[2];
$jpg = Video::getPathToFile("{$video_filename}.jpg");
$jpg = "{$global['systemRootPath']}videos/{$video_filename}/{$video_filename}.jpg";
if (file_exists($jpg)) {
$file = $jpg;
@ -26,12 +33,12 @@ if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
if (strpos($imageURL, '_thumbsV2') !== false) {
$imgDestination = "{$global['systemRootPath']}{$imageURL}";
if(!file_exists($imgDestination)){
_error_log("Converting thumbnail: {$jpg} to {$imgDestination}");
error_log("Converting thumbnail: {$jpg} to {$imgDestination}");
convertThumbsIfNotExists($jpg, $imgDestination);
}
}
} else {
_error_log("Thumbnail image not found: {$imageURL}");
error_log("Thumbnail image not found: {$imageURL}");
}
// Handle Roku Images
} elseif (preg_match('/videos\/(.*\/)?(.*)_roku.jpg/', $imageURL, $matches)) {
@ -45,13 +52,13 @@ if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
if (strpos($imageURL, '_roku') !== false) {
$rokuDestination = "{$global['systemRootPath']}{$imageURL}";
if(!file_exists($rokuDestination)){
_error_log("Converting for Roku: {$jpg} to {$rokuDestination}");
error_log("Converting for Roku: {$jpg} to {$rokuDestination}");
convertImageToRoku($jpg, $rokuDestination);
}
}
} else {
_error_log("Roku image not found: {$imageURL}");
error_log("Roku image not found: {$imageURL}");
}
} else {
@ -62,7 +69,7 @@ if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
){
}else{
_error_log("Unmatched image request: {$imageURL}");
error_log("Unmatched image request: {$imageURL}");
}
}