1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
Daniel Neto 2023-08-30 10:37:39 -03:00
parent ef42c8459f
commit 67847a29de
38 changed files with 116 additions and 31 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
/.scannerwork/
/YouPHPTube.code-workspace
/git.php
/imageToWebp.php
/iptvsource_one_one.csv
/nbproject/
/nbproject/private/

View file

@ -91,7 +91,7 @@ Options All -Indexes
RewriteEngine on
#VideoHLS for DRM
RewriteRule ^buy/? plugin/Layout/buy.php [NC,L,QSA]
RewriteRule ^buy/? plugin/YPTWallet/buy.php [NC,L,QSA]
RewriteRule ^id/? view/id.php [NC,L,QSA]
RewriteRule ^logo.png view/logo.png.php [NC,L,QSA]

View file

@ -1,6 +1,7 @@
<?php
Class ImagesPlaceHolders {
class ImagesPlaceHolders
{
public static $RETURN_RELATIVE = 0;
public static $RETURN_PATH = 1;
@ -33,12 +34,21 @@ Class ImagesPlaceHolders {
'videoNotFoundPoster' => 'view/img/this-video-is-not-available.jpg'
];
static private function getComponent($type, $return = 0) {
static private function getComponent($type, $return = 0)
{
global $global;
if (!isset(self::$placeholders[$type])) {
return null; // handle invalid type
}
$relativePath = self::$placeholders[$type];
if(self::supportsWebP()){
$relativePathWebp = str_replace(array('.jpg', '.png'), array('.webp', '.webp'), $relativePath);
if(file_exists($global['systemRootPath'] . $relativePathWebp)){
$relativePath = $relativePathWebp;
}
}
if (!empty($global[$type])) {
$relativePath = $global[$type];
}
@ -62,7 +72,58 @@ Class ImagesPlaceHolders {
return $relativePath;
}
static function isDefaultImage($path) {
static function supportsWebP()
{
static $supportsWebP = null;
// If we've already tested this before, return the cached value
if ($supportsWebP !== null) {
return $supportsWebP;
}
// First, check the HTTP_ACCEPT value
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') !== false) {
$supportsWebP = true;
return $supportsWebP;
}
// If HTTP_ACCEPT is inconclusive, check User-Agent as a fallback
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$ua = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/Firefox\/(\d+)/', $ua, $matches) && intval($matches[1]) >= 65) {
$supportsWebP = true;
return $supportsWebP;
}
if (preg_match('/Opera\/.*Version\/(\d+)/', $ua, $matches) && intval($matches[1]) >= 56) {
$supportsWebP = true;
return $supportsWebP;
}
$webpBrowsersPatterns = [
'/Chrome\//', // Chrome (and most Chromium-based browsers)
'/Edge\//', // Edge
'/UCBrowser\//', // UC Browser
'/SamsungBrowser/' // Samsung Internet Browser
];
foreach ($webpBrowsersPatterns as $pattern) {
if (preg_match($pattern, $ua)) {
$supportsWebP = true;
return $supportsWebP;
}
}
}
// Default to false if no evidence found
$supportsWebP = false;
return $supportsWebP;
}
static function isDefaultImage($path)
{
global $global;
foreach (self::$placeholders as $key => $defaultImagePath) {
@ -85,98 +146,121 @@ Class ImagesPlaceHolders {
return false;
}
static function getImageIcon($return = 0) {
static function getImageIcon($return = 0)
{
return self::getComponent('imageIcon', $return);
}
static function getImageLandscape($return = 0) {
static function getImageLandscape($return = 0)
{
return self::getComponent('imageLandscape', $return);
}
static function getImagePortrait($return = 0) {
static function getImagePortrait($return = 0)
{
return self::getComponent('imagePortrait', $return);
}
static function getImageNotFoundIcon($return = 0) {
static function getImageNotFoundIcon($return = 0)
{
return self::getComponent('imageNotFoundIcon', $return);
}
static function getImageNotFoundLandscape($return = 0) {
static function getImageNotFoundLandscape($return = 0)
{
return self::getComponent('imageNotFoundLandscape', $return);
}
static function getImageNotFoundPortrait($return = 0) {
static function getImageNotFoundPortrait($return = 0)
{
return self::getComponent('imageNotFoundPortrait', $return);
}
static function getArticlesIcon($return = 0) {
static function getArticlesIcon($return = 0)
{
return self::getComponent('articlesIcon', $return);
}
static function getArticlesLandscape($return = 0) {
static function getArticlesLandscape($return = 0)
{
return self::getComponent('articlesLandscape', $return);
}
static function getArticlesPortrait($return = 0) {
static function getArticlesPortrait($return = 0)
{
return self::getComponent('articlesPortrait', $return);
}
static function getAudioIcon($return = 0) {
static function getAudioIcon($return = 0)
{
return self::getComponent('audioIcon', $return);
}
static function getAudioLandscape($return = 0) {
static function getAudioLandscape($return = 0)
{
return self::getComponent('audioLandscape', $return);
}
static function getAudioPortrait($return = 0) {
static function getAudioPortrait($return = 0)
{
return self::getComponent('audioPortrait', $return);
}
static function getPdfIcon($return = 0) {
static function getPdfIcon($return = 0)
{
return self::getComponent('pdfIcon', $return);
}
static function getPdfLandscape($return = 0) {
static function getPdfLandscape($return = 0)
{
return self::getComponent('pdfLandscape', $return);
}
static function getPdfPortrait($return = 0) {
static function getPdfPortrait($return = 0)
{
return self::getComponent('pdfPortrait', $return);
}
static function getUserIcon($return = 0) {
static function getUserIcon($return = 0)
{
return self::getComponent('userIcon', $return);
}
static function getUserLandscape($return = 0) {
static function getUserLandscape($return = 0)
{
return self::getComponent('userLandscape', $return);
}
static function getUserPortrait($return = 0) {
static function getUserPortrait($return = 0)
{
return self::getComponent('userPortrait', $return);
}
static function getZipIcon($return = 0) {
static function getZipIcon($return = 0)
{
return self::getComponent('zipIcon', $return);
}
static function getZipLandscape($return = 0) {
static function getZipLandscape($return = 0)
{
return self::getComponent('zipLandscape', $return);
}
static function getZipPortrait($return = 0) {
static function getZipPortrait($return = 0)
{
return self::getComponent('zipPortrait', $return);
}
static function getVideoPlaceholder($return = 0) {
static function getVideoPlaceholder($return = 0)
{
return self::getComponent('videoPlaceholder', $return);
}
static function getVideoPlaceholderPortrait($return = 0) {
static function getVideoPlaceholderPortrait($return = 0)
{
return self::getComponent('videoPlaceholderPortrait', $return);
}
static function getVideoNotFoundPoster($return = 0) {
static function getVideoNotFoundPoster($return = 0)
{
return self::getComponent('videoNotFoundPoster', $return);
}
}

View file

@ -10,7 +10,7 @@ if (!empty($videos_id)) {
$poster = Video::getPoster($videos_id);
}
$_page = new Page($title);
$_page->setExtraStyles(array('plugin/Layout/buy.css'));
$_page->setExtraStyles(array('plugin/YPTWallet/buy.css'));
$paymentOptions = array();
$paymentPanel = array();

BIN
view/img/background.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
view/img/favicon.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
view/img/id.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
view/img/logo.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
view/img/sampleGuide.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Before After
Before After

BIN
view/img/social/gab.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB