mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Improve image404
This commit is contained in:
parent
f279deb283
commit
57c159ee79
7 changed files with 36 additions and 15 deletions
|
@ -11,7 +11,7 @@ includeLangFile();
|
||||||
|
|
||||||
function includeLangFile() {
|
function includeLangFile() {
|
||||||
global $t, $global;
|
global $t, $global;
|
||||||
if(empty($_SESSION)){
|
if(empty($_SESSION) && function_exists('_session_start')){
|
||||||
_session_start();
|
_session_start();
|
||||||
}
|
}
|
||||||
if(empty($_SESSION['language'])){
|
if(empty($_SESSION['language'])){
|
||||||
|
|
|
@ -78,6 +78,9 @@ abstract class ObjectYPT implements ObjectInterface
|
||||||
static function getFromDb($id, $refreshCache = false)
|
static function getFromDb($id, $refreshCache = false)
|
||||||
{
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
if(!class_exists('sqlDAL')){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$id = intval($id);
|
$id = intval($id);
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE id = ? LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE id = ? LIMIT 1";
|
||||||
//var_dump($sql, $id);
|
//var_dump($sql, $id);
|
||||||
|
@ -416,6 +419,9 @@ abstract class ObjectYPT implements ObjectInterface
|
||||||
private function getAllFields()
|
private function getAllFields()
|
||||||
{
|
{
|
||||||
global $global, $mysqlDatabase;
|
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() . "'";
|
$sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = '" . static::getTableName() . "'";
|
||||||
$res = sqlDAL::readSql($sql, "s", [$mysqlDatabase]);
|
$res = sqlDAL::readSql($sql, "s", [$mysqlDatabase]);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
|
@ -1011,6 +1017,9 @@ abstract class ObjectYPT implements ObjectInterface
|
||||||
public static function isTableInstalled($tableName = "")
|
public static function isTableInstalled($tableName = "")
|
||||||
{
|
{
|
||||||
global $global, $tableExists;
|
global $global, $tableExists;
|
||||||
|
if(!class_exists('sqlDAL')){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (empty($tableName)) {
|
if (empty($tableName)) {
|
||||||
$tableName = static::getTableName();
|
$tableName = static::getTableName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8852,7 +8852,7 @@ function getCDN($type = 'CDN', $id = 0)
|
||||||
if ($type == 'CDN') {
|
if ($type == 'CDN') {
|
||||||
if (!empty($global['ignoreCDN'])) {
|
if (!empty($global['ignoreCDN'])) {
|
||||||
return $global['webSiteRootURL'];
|
return $global['webSiteRootURL'];
|
||||||
} elseif (!empty($advancedCustom) && isValidURL($advancedCustom->videosCDN)) {
|
} elseif (!empty($advancedCustom) && !empty($advancedCustom->videosCDN) && isValidURL($advancedCustom->videosCDN)) {
|
||||||
$_getCDNURL[$index] = addLastSlash($advancedCustom->videosCDN);
|
$_getCDNURL[$index] = addLastSlash($advancedCustom->videosCDN);
|
||||||
} elseif (empty($_getCDNURL[$index])) {
|
} elseif (empty($_getCDNURL[$index])) {
|
||||||
$_getCDNURL[$index] = $global['webSiteRootURL'];
|
$_getCDNURL[$index] = $global['webSiteRootURL'];
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
if (!isset($global['skippPlugins'])) {
|
||||||
|
$global['skippPlugins'] = array();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Global variables.
|
* Global variables.
|
||||||
*
|
*
|
||||||
|
@ -12,9 +14,6 @@ if (!empty($doNotIncludeConfig)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($global['skippPlugins'])) {
|
|
||||||
$global['skippPlugins'] = array();
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
if($_SERVER["HTTP_HOST"] === 'localhost' || $_SERVER["HTTP_HOST"] === '127.0.0.1'){
|
if($_SERVER["HTTP_HOST"] === 'localhost' || $_SERVER["HTTP_HOST"] === '127.0.0.1'){
|
||||||
$global["webSiteRootURL"] = $_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["HTTP_HOST"].$global["webSiteRootPath"];
|
$global["webSiteRootURL"] = $_SERVER["REQUEST_SCHEME"].'://'.$_SERVER["HTTP_HOST"].$global["webSiteRootPath"];
|
||||||
|
|
|
@ -408,6 +408,9 @@ class Plugin extends ObjectYPT
|
||||||
public static function getEnabled($uuid)
|
public static function getEnabled($uuid)
|
||||||
{
|
{
|
||||||
global $global, $getEnabled;
|
global $global, $getEnabled;
|
||||||
|
if(!class_exists('sqlDAL')){
|
||||||
|
return array();
|
||||||
|
}
|
||||||
if (empty($getEnabled)) {
|
if (empty($getEnabled)) {
|
||||||
$getEnabled = [];
|
$getEnabled = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ class AVideoPlugin
|
||||||
if (!isset($_loadPluginIfEnabled)) {
|
if (!isset($_loadPluginIfEnabled)) {
|
||||||
$_loadPluginIfEnabled = array();
|
$_loadPluginIfEnabled = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $global
|
* @var array $global
|
||||||
*/
|
*/
|
||||||
|
@ -675,6 +675,9 @@ class AVideoPlugin
|
||||||
|
|
||||||
public static function isEnabled($uuid)
|
public static function isEnabled($uuid)
|
||||||
{
|
{
|
||||||
|
if(!class_exists('Plugin')){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return !empty(Plugin::getEnabled($uuid));
|
return !empty(Plugin::getEnabled($uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include(dirname(__FILE__) . '/image404Raw.php');
|
include(dirname(__FILE__) . '/image404Raw.php');
|
||||||
|
$doNotIncludeConfig = 1;
|
||||||
// Load configuration
|
// Load configuration
|
||||||
$configFile = dirname(__FILE__) . '/../../videos/configuration.php';
|
$configFile = dirname(__FILE__) . '/../../videos/configuration.php';
|
||||||
require_once $configFile;
|
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
|
// Default image settings
|
||||||
$file = ImagesPlaceHolders::getVideoPlaceholder(ImagesPlaceHolders::$RETURN_PATH);
|
$file = ImagesPlaceHolders::getVideoPlaceholder(ImagesPlaceHolders::$RETURN_PATH);
|
||||||
|
@ -17,7 +23,8 @@ $imageURL = !empty($_GET['image']) ? $_GET['image'] : $_SERVER["REQUEST_URI"];
|
||||||
// Handle Thumbnails
|
// Handle Thumbnails
|
||||||
if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
|
if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
|
||||||
$video_filename = $matches[2];
|
$video_filename = $matches[2];
|
||||||
$jpg = Video::getPathToFile("{$video_filename}.jpg");
|
|
||||||
|
$jpg = "{$global['systemRootPath']}videos/{$video_filename}/{$video_filename}.jpg";
|
||||||
|
|
||||||
if (file_exists($jpg)) {
|
if (file_exists($jpg)) {
|
||||||
$file = $jpg;
|
$file = $jpg;
|
||||||
|
@ -26,12 +33,12 @@ if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
|
||||||
if (strpos($imageURL, '_thumbsV2') !== false) {
|
if (strpos($imageURL, '_thumbsV2') !== false) {
|
||||||
$imgDestination = "{$global['systemRootPath']}{$imageURL}";
|
$imgDestination = "{$global['systemRootPath']}{$imageURL}";
|
||||||
if(!file_exists($imgDestination)){
|
if(!file_exists($imgDestination)){
|
||||||
_error_log("Converting thumbnail: {$jpg} to {$imgDestination}");
|
error_log("Converting thumbnail: {$jpg} to {$imgDestination}");
|
||||||
convertThumbsIfNotExists($jpg, $imgDestination);
|
convertThumbsIfNotExists($jpg, $imgDestination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_error_log("Thumbnail image not found: {$imageURL}");
|
error_log("Thumbnail image not found: {$imageURL}");
|
||||||
}
|
}
|
||||||
// Handle Roku Images
|
// Handle Roku Images
|
||||||
} elseif (preg_match('/videos\/(.*\/)?(.*)_roku.jpg/', $imageURL, $matches)) {
|
} 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) {
|
if (strpos($imageURL, '_roku') !== false) {
|
||||||
$rokuDestination = "{$global['systemRootPath']}{$imageURL}";
|
$rokuDestination = "{$global['systemRootPath']}{$imageURL}";
|
||||||
if(!file_exists($rokuDestination)){
|
if(!file_exists($rokuDestination)){
|
||||||
_error_log("Converting for Roku: {$jpg} to {$rokuDestination}");
|
error_log("Converting for Roku: {$jpg} to {$rokuDestination}");
|
||||||
convertImageToRoku($jpg, $rokuDestination);
|
convertImageToRoku($jpg, $rokuDestination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_error_log("Roku image not found: {$imageURL}");
|
error_log("Roku image not found: {$imageURL}");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +69,7 @@ if (preg_match('/videos\/(.*\/)?(.*)_thumbs(V2)?.jpg/', $imageURL, $matches)) {
|
||||||
){
|
){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
_error_log("Unmatched image request: {$imageURL}");
|
error_log("Unmatched image request: {$imageURL}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue