1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Daniel Neto 2024-11-13 09:56:09 -03:00
parent 9776de2680
commit aa48a4bd12
2 changed files with 57 additions and 29 deletions

View file

@ -2627,8 +2627,7 @@ function getAdsDebugTag($adCode)
if(!empty($_REQUEST['AdsDebug']) && User::isAdmin()){ if(!empty($_REQUEST['AdsDebug']) && User::isAdmin()){
$function = debug_backtrace()[1]["function"]; $function = debug_backtrace()[1]["function"];
$function = str_replace('get', '', $function); $function = str_replace('get', '', $function);
$reason = ADs::getAdsCodeReason($global['lastAdsCodeType']); $adCode = "<div class=\"AdsDebug\">{$function}<br>{$global['lastAdsCodeReason']}<br>$adCode</div>";
$adCode = "<div class=\"AdsDebug\">{$function}<br>".implode('<br>', $reason)."<br>$adCode</div>";
} }
return $adCode; return $adCode;
} }

View file

@ -379,48 +379,77 @@ class ADs extends PluginAbstract
{ {
global $global; global $global;
$global['lastAdsCodeType'] = $type; $global['lastAdsCodeType'] = $type;
$global['lastAdsCodeReason'] = ''; // Initialize last reason as an empty string
// Check for infinite scroll
if (isInfiniteScroll()) { if (isInfiniteScroll()) {
$global['lastAdsCodeReason'] = 'Infinite scroll is enabled, ads are disabled in this mode.';
return false; return false;
} }
// Check if viewer is a bot
if (isBot()) { if (isBot()) {
$global['lastAdsCodeReason'] = 'Viewer is a bot, ads are not shown to bots.';
self::debug(__LINE__); self::debug(__LINE__);
return false; return false;
} }
$videos_id = 0;
$videos_id = getVideos_id();
if (empty($videos_id)) { if (empty($videos_id)) {
$videos_id = getVideos_id(); $global['lastAdsCodeReason'] = 'No video ID found, unable to retrieve ads for specific content.';
} }
// Check if ADs plugin is enabled
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs'); $ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = ''; $adCode = '';
if (!empty($ad)) { if (empty($ad)) {
$showOnVideoPlayerPage = true; $global['lastAdsCodeReason'] = 'ADs plugin is disabled, ads cannot be displayed without this plugin.';
eval("\$showOnVideoPlayerPage = \$obj->{$type}ShowOnVideoPlayerPage;"); return false;
if (!$showOnVideoPlayerPage && isVideo()) { }
return false;
} // Determine if ads should be shown on video player page
self::debug(__LINE__); $showOnVideoPlayerPage = true;
if (isMobile()) { // Check if ads are configured to show on the video player page for the specified ad type
$type = $type . 'Mobile'; eval("\$showOnVideoPlayerPage = \$ad->{$type}ShowOnVideoPlayerPage;");
} if (!$showOnVideoPlayerPage && isVideo()) {
$users_id = getUsers_idOwnerFromRequest(); $global['lastAdsCodeReason'] = 'Ads are configured not to show on the video player page for this ad type. '
//var_dump($users_id);exit; . '<br>To enable ads here, go to the Ads plugin settings and set the parameter '
$adC = self::getAdsFromUsersId($type, $users_id); . "{$type}ShowOnVideoPlayerPage to true if you want to display ads on the video page.";
if (_empty($adC['adCode'])) { return false;
self::debug(__LINE__);
$adC = self::getAdsHTML($type);
if (!_empty($adC['html'])) {
return $adC['html'];
}
} else {
self::debug(__LINE__);
}
$adCode = ADs::giveGoogleATimeout($adC['adCode']);
$adCode = ADs::addLabel($adCode, $adC['label']);
} }
self::debug(__LINE__); self::debug(__LINE__);
// Adjust ad type for mobile if applicable
if (isMobile()) {
$type .= 'Mobile';
}
// Retrieve ads based on user ID or video ID
$users_id = getUsers_idOwnerFromRequest();
$adC = self::getAdsFromUsersId($type, $users_id);
if (_empty($adC['adCode'])) {
self::debug(__LINE__);
$adC = self::getAdsHTML($type);
if (!_empty($adC['html'])) {
return $adC['html'];
} else {
$global['lastAdsCodeReason'] = 'No ad code found for this content type and user ID.';
return false;
}
} else {
self::debug(__LINE__);
}
// Finalize ad code if found, adding label and Google timeout if applicable
$adCode = ADs::giveGoogleATimeout($adC['adCode']);
$adCode = ADs::addLabel($adCode, $adC['label']);
$global['lastAdsCodeReason'] = 'Ad code successfully generated.';
self::debug(__LINE__);
return $adCode; return $adCode;
} }
public static function getAdsCodeReason($type) public static function getAdsCodeReason($type)
{ {
$reasons = array(); $reasons = array();
@ -433,7 +462,7 @@ class ADs extends PluginAbstract
// Get the video ID, if available // Get the video ID, if available
$videos_id = getVideos_id(); $videos_id = getVideos_id();
if (empty($videos_id)) { if (empty($videos_id)) {
$reasons[] = 'No video ID found, this might prevent ads from displaying.'; $reasons[] = 'No video ID found';
} else { } else {
$reasons[] = 'Video ID detected: ' . $videos_id; $reasons[] = 'Video ID detected: ' . $videos_id;
} }