Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/plugins/adv_channel.plugin.php
Строк: 26
<?php
defined('_VALID') or die('Restricted Access!');
function template_plugin_adv_channel($adv_id, $class = null)
{
if (VF::cfg_item('ads') === 0) {
return;
}
$db = VF::factory('database');
$cache = VF::factory('cache');
$cache_id = 'adv-'.$adv_id;
if (!$adv = $cache->get($cache_id, 86400)) {
$db->query("SELECT adv_id, title, description, type, url, code, expire,
image_type, image_url, image_ext, expire, blank
FROM #__adv
WHERE adv_id = ".(int) $adv_id."
AND status = '1'
LIMIT 1");
if (!$db->affected_rows()) {
return;
}
$adv = $db->fetch_assoc();
$cache->store($cache_id, $adv, 86400);
}
if ($adv['expire'] != '0000-00-00') {
if (time() > strtotime($adv['expire'])) {
return;
}
}
$db->query("UPDATE #__adv SET views = views+1 WHERE adv_id = ".$adv['adv_id']." LIMIT 1");
$rel = ' rel="nofollow"';
$class = (isset($class)) ? $class : 'ads';
if ($adv['type'] == 'html') {
return '<div class="'.$class.'">'.$adv['code'].'</div>';
} elseif ($adv['type'] == 'text') {
$title = ($adv['description'] != '') ? 'title="'.htmlspecialchars($adv['description'], ENT_QUOTES, 'UTF-8').'"' : '';
$target = ($adv['blank'] == '1') ? ' target="_blank"' : '';
return '<div class="'.$class.'"><a href="'.BASE_URL.'/adv/'.$adv['adv_id'].'/"'.$rel.$title.$target.'>'.htmlspecialchars($adv['title'], ENT_QUOTES, 'UTF-8').'</a></div>';
} 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"' : '';
return '<div class="'.$class.'"><a href="'.BASE_URL.'/adv/'.$adv['adv_id'].'/"'.$rel.$target.'><img src="'.$image_url.'" alt="" /></a></div>';
}
}