Вход Регистрация
Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/plugins/adv_player_embed.plugin.php
Строк: 50
<?php
defined
('_VALID') or die('Restricted Access!');
function 
template_plugin_adv_player_embed($categories=array())
{
    if (empty(
$categories)) {
        return;
    }

    if (
VF::cfg_item('ads') === 0) {
        return;
    }
    
    if (
is_string($categories)) {
        
$categories explode(','$categories);
    }
    
    
$db        VF::factory('database');
    
$cache    VF::factory('cache');
    
    if (!
$group $cache->get('group_player-embed-category'86400)) {
        
$db->query("SELECT adv_group_id, adv_rotate
                    FROM #__adv_groups
                    WHERE adv_group_slug = 'player-embed-category'
                    AND status = '1'
                    LIMIT 1"
);
        if (!
$db->affected_rows()) {
            return;
        }
        
        
$group    $db->fetch_assoc();
        
$cache->store('group_player-embed-category'$group86400);
    }
    
    
$limit = ($group['adv_rotate'] == '0') ? ' LIMIT 1' '';
    foreach (
$categories as $category) {
        if (!
$advs $cache->get('player-embed-'.$category86400)) {
            
$db->query("SELECT a.adv_id, a.title, a.description, a.type, a.url,
                               a.code, a.image_type, a.image_url, a.image_ext, a.expire
                        FROM #__adv_embed_category AS c
                        INNER JOIN #__adv AS a ON (a.adv_id = c.adv_id)
                        WHERE c.cat_id = "
.(int) $category.$limit);
            if (
$db->affected_rows()) {
                
$advs $db->fetch_rows();
                
$cache->store('player-embed-'.$category$advs86400);
            }            
        }
        
        if (
$advs) {
            
$count      = (count($advs)-1);
            
$index      = ($group['adv_rotate'] == '1') ? rand(0$count) : 0;
            
$adv        $advs[$index];
            
$expired    FALSE;
            
            if (
$adv['expire'] != '0000-00-00') {
                if (
time() > strtotime($adv['expire'])) {
                    
$expired TRUE;
                }
            }
          
            if (!
$expired) {
                
$db->query("UPDATE #__adv SET views = views+1 WHERE adv_id = ".$adv['adv_id']." LIMIT 1");
                
                return 
display_overlay($adv);
            }
        }
    }
    
    if (!
$group $cache->get('group_player-embed'86400)) {
        
$db->query("SELECT adv_group_id, adv_rotate
                    FROM #__adv_groups
                    WHERE adv_group_slug = 'player-embed'
                    AND status = '1'
                    LIMIT 1"
);
        if (!
$db->affected_rows()) {
            return;
        }

        
$group $db->fetch_assoc();
        
$cache->store('group_player-embed'$group86400);
    }

    
$limit = ($group['adv_rotate'] == '0') ? ' LIMIT 1' '';
    if (!
$advs $cache->get('player-embed-global'86400)) {
        
$db->query("SELECT adv_id, title, description, type, url, code,
                           image_type, image_url, image_ext, expire, blank
                    FROM #__adv
                    WHERE adv_group_id = "
.(int) $group['adv_group_id']."
                    AND status = '1'"
.$limit);
        if (!
$db->affected_rows()) {
            return;
        }

        
$advs $db->fetch_rows();
        
$cache->store('player-embed-global'$advs86400);
    }

    
$count      = (count($advs)-1);
    
$index      = ($group['adv_rotate'] == '1') ? rand(0$count) : 0;
    
$adv        $advs[$index];

    if (
$adv['expire'] != '0000-00-00') {
        if (
time() > strtotime($adv['expire'])) {
            return;
        }
    }
    
    return 
display_overlay($adv);
}

function 
display_overlay($adv)
{
    
$rel    ' rel="nofollow"';
    
$header '<span>'.__('advertising').'</span><a href="#close" id="video-embed-ads-close" class="close">x</a><div class="clear"></div>';

    
$rel        ' rel="nofollow"';
    
$output     = array();
    
$output[]   = '<div id="player-advertising">';
    
$output[]   = '<p>Advertisement</p>';


    if (
$adv['type'] == 'html') {
        
$output[]    = $adv['code'];
    } elseif (
$adv['type'] == 'text') {
        
$title         = ($adv['description'] != '') ? 'title="'.htmlspecialchars($adv['description'], ENT_QUOTES'UTF-8').'"' '';
        
$target     = ($adv['blank'] == '1') ? ' target="_blank"' '';
        
$output[]    = '<a href="'.BASE_URL.'/adv/'.$adv['adv_id'].'/"'.$rel.$title.$target.'>'.htmlspecialchars($adv['title'], ENT_QUOTES'UTF-8').'</a>';
    } elseif (
$adv['type'] == 'image') {
        
$image_url    = ($adv['image_type'] == 'url') ? $adv['image_url'] : MEDIA_URL.'/banners/'.$adv['adv_id'].'.'.$adv['image_ext'];
        
$target     = ($adv['blank'] == '1') ? ' target="_blank"' '';
        
$output[]    = '<a href="'.BASE_URL.'/adv/'.$adv['adv_id'].'/"'.$rel.$target.'><img src="'.$image_url.'" alt="" /></a>';
    }
    
    
$output[]   = '<a href="#close" id="close-ads" class="close-ads">Close & Play</a>';
    
$output[]   = '</div>';
        
    return 
implode("n"$output);
}
Онлайн: 0
Реклама