Удаление обрезков рекламного мода

Избавляемся от неиспользуемого кода. Поскольку весь datastore под большим вопросом, использование рекламной системы на его основе возможным далее не представляется. Реализация возможности установки рекламных баннеров в движке будет представлена позднее.
This commit is contained in:
Exile 2014-12-10 19:46:43 +03:00
commit a0b6d64729
9 changed files with 5 additions and 215 deletions

View file

@ -1,24 +1,5 @@
SET SQL_MODE = "";
-- ----------------------------
-- Table structure for `bb_ads`
-- ----------------------------
DROP TABLE IF EXISTS `bb_ads`;
CREATE TABLE IF NOT EXISTS `bb_ads` (
`ad_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`ad_block_ids` varchar(255) NOT NULL DEFAULT '',
`ad_start_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ad_active_days` smallint(6) NOT NULL DEFAULT '0',
`ad_status` tinyint(4) NOT NULL DEFAULT '1',
`ad_desc` varchar(255) NOT NULL DEFAULT '',
`ad_html` text NOT NULL,
PRIMARY KEY (`ad_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of bb_ads
-- ----------------------------
-- ----------------------------
-- Table structure for `bb_attachments`
-- ----------------------------
@ -509,7 +490,6 @@ INSERT INTO `bb_config` VALUES ('smilies_path', 'styles/images/smiles');
INSERT INTO `bb_config` VALUES ('static_sitemap', '');
INSERT INTO `bb_config` VALUES ('topics_per_page', '50');
INSERT INTO `bb_config` VALUES ('xs_use_cache', '1');
INSERT INTO `bb_config` VALUES ('active_ads', '');
INSERT INTO `bb_config` VALUES ('cron_enabled', '1');
INSERT INTO `bb_config` VALUES ('cron_check_interval', '180');
INSERT INTO `bb_config` VALUES ('magnet_links_enabled', '1');

View file

@ -48,7 +48,6 @@
* Users
* Groups
* Tidy
* Ads
* Misc
* Extensions
* Attachments
@ -531,23 +530,6 @@ $bb_cfg['group_members_per_page'] = 50;
// Tidy
$bb_cfg['tidy_post'] = (!in_array('tidy', get_loaded_extensions())) ? false : true;
// Ads
$bb_cfg['show_ads'] = false;
$bb_cfg['show_ads_users'] = array(
# user_id => 'name',
2 => 'admin',
);
// block_type => [block_id => block_desc]
$bb_cfg['ad_blocks'] = array(
'trans' => array(
100 => 'сквозная сверху',
),
'index' => array(
200 => 'главная, под новостями',
),
);
// Misc
define('MEM_USAGE', function_exists('memory_get_usage'));

View file

@ -161,35 +161,4 @@ if ($bb_cfg['show_network_news'] AND $net_forum_ids = $bb_cfg['network_news_foru
");
$this->store('network_news', $data);
}
//
// Ads
//
if ($bb_cfg['show_ads'])
{
$ad_html = $ad_block_assignment = array();
$active_ads = DB()->fetch_rowset("
SELECT *
FROM ". BB_ADS ."
WHERE ad_status = 1
AND ad_start_time < NOW()
AND DATE_ADD(ad_start_time, INTERVAL ad_active_days DAY) > NOW()
");
foreach ($active_ads as $ad)
{
if ($ad['ad_block_ids'])
{
foreach(explode(',', $ad['ad_block_ids']) as $block_id)
{
$ad_block_assignment[$block_id][] = $ad['ad_id'];
}
}
$ad_html[$ad['ad_id']] = $ad['ad_html'];
}
$this->store('ads', $ad_html);
bb_update_config(array('active_ads' => serialize($ad_block_assignment)));
}

View file

@ -30,7 +30,6 @@ class datastore_common
'viewtopic_forum_select' => 'build_cat_forums.php',
'latest_news' => 'build_cat_forums.php',
'network_news' => 'build_cat_forums.php',
'ads' => 'build_cat_forums.php',
'moderators' => 'build_moderators.php',
'stats' => 'build_stats.php',
'ranks' => 'build_ranks.php',

View file

@ -113,103 +113,6 @@ function is_unread ($ref, $topic_id = 0, $forum_id = 0)
return (!IS_GUEST && $ref > get_last_read($topic_id, $forum_id));
}
//
// Ads
//
class ads_common
{
var $ad_blocks = array();
var $active_ads = array();
/**
* Constructor
*/
function ads_common ()
{
global $bb_cfg;
$this->ad_blocks =& $bb_cfg['ad_blocks'];
$this->active_ads = !empty($bb_cfg['active_ads']) ? @unserialize($bb_cfg['active_ads']) : array();
}
/**
* Get ads to show for each block
*/
function get ($block_types)
{
$ads = array();
if ($this->active_ads)
{
$block_ids = $this->get_block_ids($block_types);
if ($ad_ids = $this->get_ad_ids($block_ids))
{
$ad_html = $this->get_ads_html();
foreach ($ad_ids as $block_id => $ad_id)
{
$ads[$block_id] =& $ad_html[$ad_id];
}
}
}
return $ads;
}
/**
* Get ads html
*/
function get_ads_html ()
{
global $datastore;
if (!$ads_html = $datastore->get('ads'))
{
$datastore->update('ads');
$ads_html = $datastore->get('ads');
}
return $ads_html;
}
/**
* Get block_ids for specified block_types
*/
function get_block_ids ($block_types)
{
$block_ids = array();
foreach ($block_types as $block_type)
{
if ($blocks =& $this->ad_blocks[$block_type])
{
$block_ids = array_merge($block_ids, array_keys($blocks));
}
}
return $block_ids;
}
/**
* Get ad_ids for specified blocks
*/
function get_ad_ids ($block_ids)
{
$ad_ids = array();
foreach ($block_ids as $block_id)
{
if ($ads =& $this->active_ads[$block_id])
{
shuffle($ads);
$ad_ids[$block_id] = $ads[0];
}
}
return $ad_ids;
}
}
//
// Auth
//
@ -272,7 +175,7 @@ $bf['user_opt'] = array(
'dis_passkey' => 7, // Запрет на добавление passkey, он же запрет на скачивание торрентов
'user_porn_forums' => 8, // Скрывать контент 18+
'user_callseed' => 9, // Позвать скачавших
'user_hide_ads' => 10, // Запрет на показ рекламы
'user_hide_ads' => 10, // TODO: не используется
'dis_topic' => 11, // Запрет на создание новых тем
'dis_post' => 12, // Запрет на отправку сообщений
'dis_post_edit' => 13, // Запрет на редактирование сообщений

View file

@ -252,7 +252,6 @@ $bb_cfg['tor_no_tor_act'] = array(
// Table names
define('BUF_TOPIC_VIEW', 'buf_topic_view');
define('BUF_LAST_SEEDER', 'buf_last_seeder');
define('BB_ADS', 'bb_ads');
define('BB_ATTACH_CONFIG', 'bb_attachments_config');
define('BB_ATTACHMENTS_DESC', 'bb_attachments_desc');
define('BB_ATTACHMENTS', 'bb_attachments');
@ -441,7 +440,6 @@ if (DBG_USER) require(INC_DIR .'functions_dev.php');
$html = new html_common();
$log_action = new log_action();
$ads = new ads_common();
// TODO temporarily 'cat_forums' always enqueued
$datastore->enqueue(array('cat_forums'));

View file

@ -5,7 +5,7 @@ if (defined('PAGE_HEADER_SENT')) return;
// Parse and show the overall page header
global $page_cfg, $userdata, $user, $ads, $bb_cfg, $template, $lang, $images;
global $page_cfg, $userdata, $user, $bb_cfg, $template, $lang, $images;
$logged_in = (int) !empty($userdata['session_logged_in']);
@ -113,7 +113,6 @@ $template->assign_vars(array(
'CONTENT_ENCODING' => $bb_cfg['lang'][$userdata['user_lang']]['encoding'],
'IN_ADMIN' => defined('IN_ADMIN'),
'SHOW_ADS' => (!$logged_in || isset($bb_cfg['show_ads_users'][$user->id]) || (!IS_AM && $user->show_ads)),
'USER_HIDE_CAT' => (BB_SCRIPT == 'index'),
'USER_LANG' => $userdata['user_lang'],
@ -241,20 +240,6 @@ if (!empty($page_cfg['show_torhelp'][BB_SCRIPT]) && !empty($userdata['torhelp'])
}
}
// Ads
if ($user->show_ads)
{
$load_ads = array('trans');
if (defined('BB_SCRIPT'))
{
$load_ads[] = BB_SCRIPT;
}
foreach ($ads->get($load_ads) as $block_id => $ad_html)
{
$template->assign_var("AD_BLOCK_{$block_id}", $ad_html);
}
}
// Login box
$in_out = ($logged_in) ? 'in' : 'out';
$template->assign_block_vars("switch_user_logged_{$in_out}", array());

View file

@ -62,11 +62,6 @@ class user_common
*/
var $id = null;
/**
* Misc
*/
var $show_ads = false;
/**
* Constructor
*/
@ -607,7 +602,6 @@ class user_common
}
$this->load_opt_js();
$this->enqueue_ads();
}
/**
@ -760,20 +754,6 @@ class user_common
case 'flip': return array_flip(explode(',', $excluded));
}
}
/**
* Enqueue ads
*/
function enqueue_ads ()
{
global $datastore, $bb_cfg;
if ($bb_cfg['show_ads'] && !bf($this->opt, 'user_opt', 'user_hide_ads') && !defined('IN_ADMIN') && !defined('IN_AJAX'))
{
$datastore->enqueue('ads');
$this->show_ads = true;
}
}
}
//

View file

@ -279,9 +279,9 @@ if ( (typeof(window.opera) != "undefined" && window.opera.version() < 12) || (wi
<script type="text/javascript">
ajax.index_data = function(tz) {
ajax.exec({
action : 'index_data',
mode : 'change_tz',
tz : tz
action : 'index_data',
mode : 'change_tz',
tz : tz
});
};
ajax.callback.index_data = function(data) {};
@ -493,12 +493,6 @@ $(document).ready(function() {
</table>
</div>
<!-- IF AD_BLOCK_200 -->
<div id="ad-200">{AD_BLOCK_200}</div><!--/ad-200-->
<!-- ELSEIF AD_BLOCK_100 -->
<div id="ad-100">{AD_BLOCK_100}</div><!--/ad-100-->
<!-- ENDIF / AD_BLOCK_100 -->
<!--=======================-->
<!-- ENDIF / COMMON_HEADER -->
<!--***********************-->