Файл: autoload/ads.php
Строк: 98
<?php
/**
* Функция рекламы
* Буду рад предложениям, как уменьшить код в разы, при этом, не трогая функционал
**/
function ads($type) {
global $module;
switch($type) {
/**
* Показ рекламы - Верх, все страницы
**/
case 1:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'up' AND `pages` = 'all' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0) {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
/**
* Показ рекламы - Верх, только главная
**/
case 2:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'up' AND `pages` = 'index' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0 && $module == 'homepage') {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
/**
* Показ рекламы - Верх, все, кроме главной
**/
case 3:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'up' AND `pages` = 'other' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0 && $module != 'homepage') {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
/**
* Показ рекламы - Низ, все страницы
**/
case 4:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'down' AND `pages` = 'all' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0) {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
/**
* Показ рекламы - Низ, только главная
**/
case 5:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'down' AND `pages` = 'index' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0 && $module == 'homepage') {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
/**
* Показ рекламы - Низ, все, кроме главной
**/
case 6:
$ads_q = mysql_query("SELECT * FROM `cms_ads` WHERE `position` = 'down' AND `pages` = 'other' AND `link_time` > '" . time() . "' ORDER BY `id` ASC");
if (mysql_num_rows($ads_q) > 0 && $module != 'homepage') {
while ($ads = mysql_fetch_assoc($ads_q)) {
echo '<a href="' . txt($ads['link_link']) . '">' .
($ads['strong'] == 'yes' ? '<b>' : '') . (!empty($ads['color']) ? '<span style="color: ' . $ads['color'] . '">' : '') . ($ads['underline'] == 'yes' ? '<u>' : '') . ($ads['italic'] == 'yes' ? '<i>' : '') .
txt($ads['link_name']) .
($ads['italic'] == 'yes' ? '</i>' : '') . ($ads['underline'] == 'yes' ? '</u>' : '') . (!empty($ads['color']) ? '</span>' : '') . ($ads['strong'] == 'yes' ? '</b>' : '') .
'</a>';
echo "<br />";
}
}
break;
}
}
?>