mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 05:43:55 -07:00
Перенос файлов движка в корень
This commit is contained in:
parent
584f692288
commit
f94c0dd2ee
585 changed files with 14 additions and 14 deletions
2
library/includes/datastore/.htaccess
Normal file
2
library/includes/datastore/.htaccess
Normal file
|
@ -0,0 +1,2 @@
|
|||
order allow,deny
|
||||
deny from all
|
17
library/includes/datastore/build_attach_extensions.php
Normal file
17
library/includes/datastore/build_attach_extensions.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
// Don't count on forbidden extensions table, because it is not allowed to allow forbidden extensions at all
|
||||
$extensions = DB()->fetch_rowset("
|
||||
SELECT
|
||||
e.extension, g.cat_id, g.download_mode, g.upload_icon
|
||||
FROM
|
||||
". BB_EXTENSIONS ." e,
|
||||
". BB_EXTENSION_GROUPS ." g
|
||||
WHERE
|
||||
e.group_id = g.group_id
|
||||
AND g.allow_group = 1
|
||||
");
|
||||
|
||||
$this->store('attach_extensions', $extensions);
|
195
library/includes/datastore/build_cat_forums.php
Normal file
195
library/includes/datastore/build_cat_forums.php
Normal file
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
global $bf, $bb_cfg;
|
||||
|
||||
//
|
||||
// cat_forums
|
||||
//
|
||||
$data = array(
|
||||
'not_auth_forums' => array(
|
||||
'guest_view' => array(),
|
||||
'guest_read' => array(),
|
||||
'user_view' => array(),
|
||||
'user_read' => array(),
|
||||
),
|
||||
'tracker_forums' => array(),
|
||||
'cat_title_html' => array(),
|
||||
'forum_name_html' => array(),
|
||||
'c' => array(), // also has $data['c']['cat_id']['forums'] key
|
||||
'f' => array(), // also has $data['f']['forum_id']['subforums'] key
|
||||
);
|
||||
|
||||
// Store only these fields from BB_FORUMS in $data['f']
|
||||
$forum_store_fields = array_flip(array_keys($bf['forum_perm']));
|
||||
$forum_store_fields += array_flip(array(
|
||||
'forum_id',
|
||||
'cat_id',
|
||||
'forum_name',
|
||||
'forum_desc',
|
||||
'forum_status',
|
||||
'forum_posts',
|
||||
'forum_topics',
|
||||
'forum_parent',
|
||||
));
|
||||
|
||||
// Categories
|
||||
$sql = "SELECT * FROM ". BB_CATEGORIES ." ORDER BY cat_order";
|
||||
|
||||
foreach(DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$data['c'][$row['cat_id']] = $row;
|
||||
$data['cat_title_html'][$row['cat_id']] = htmlCHR($row['cat_title']);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT f.*
|
||||
FROM ". BB_FORUMS ." f, ". BB_CATEGORIES ." c
|
||||
WHERE f.cat_id = c.cat_id
|
||||
ORDER BY c.cat_order, f.forum_order
|
||||
";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$fid = $row['forum_id'];
|
||||
$not_auth =& $data['not_auth_forums'];
|
||||
|
||||
// Find not auth forums
|
||||
if ($row['auth_view'] != AUTH_ALL)
|
||||
{
|
||||
$not_auth['guest_view'][] = $fid;
|
||||
}
|
||||
if ($row['auth_view'] != AUTH_ALL && $row['auth_view'] != AUTH_REG)
|
||||
{
|
||||
$not_auth['user_view'][] = $fid;
|
||||
}
|
||||
if ($row['auth_read'] != AUTH_ALL)
|
||||
{
|
||||
$not_auth['guest_read'][] = $fid;
|
||||
}
|
||||
if ($row['auth_read'] != AUTH_ALL && $row['auth_read'] != AUTH_REG)
|
||||
{
|
||||
$not_auth['user_read'][] = $fid;
|
||||
}
|
||||
|
||||
$data['forum'][$fid] = $row;
|
||||
|
||||
// Store forums data
|
||||
if ($parent_id = $row['forum_parent'])
|
||||
{
|
||||
$parent =& $data['f'][$parent_id];
|
||||
|
||||
$parent['subforums'][] = $fid;
|
||||
$parent['forum_posts'] += $row['forum_posts'];
|
||||
$parent['forum_topics'] += $row['forum_topics'];
|
||||
}
|
||||
if ($row['allow_reg_tracker'])
|
||||
{
|
||||
$data['tracker_forums'][] = $fid;
|
||||
}
|
||||
|
||||
$data['f'][$fid] = array_intersect_key($row, $forum_store_fields);
|
||||
$data['forum_name_html'][$fid] = htmlCHR($row['forum_name']);
|
||||
|
||||
// Forum ids in cat
|
||||
$data['c'][$row['cat_id']]['forums'][] = $fid;
|
||||
}
|
||||
foreach ($data['not_auth_forums'] as $key => $val)
|
||||
{
|
||||
$data['not_auth_forums'][$key] = join(',', $val);
|
||||
}
|
||||
$data['tracker_forums'] = join(',', $data['tracker_forums']);
|
||||
|
||||
$this->store('cat_forums', $data);
|
||||
|
||||
//
|
||||
// jumpbox
|
||||
//
|
||||
$data = array(
|
||||
'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'viewforum.php?f=\'+this.value;"'),
|
||||
'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'viewforum.php?f=\'+this.value;"'),
|
||||
);
|
||||
|
||||
$this->store('jumpbox', $data);
|
||||
|
||||
file_write($data['guest'], AJAX_HTML_DIR .'jumpbox_guest.html', false, true, true);
|
||||
file_write($data['user'], AJAX_HTML_DIR .'jumpbox_user.html', false, true, true);
|
||||
|
||||
//
|
||||
// viewtopic_forum_select
|
||||
//
|
||||
$data = array(
|
||||
'viewtopic_forum_select' => get_forum_select('admin', 'new_forum_id'),
|
||||
);
|
||||
|
||||
$this->store('viewtopic_forum_select', $data);
|
||||
|
||||
//
|
||||
// latest_news
|
||||
//
|
||||
if ($bb_cfg['show_latest_news'] AND $news_forum_ids = $bb_cfg['latest_news_forum_id'])
|
||||
{
|
||||
$news_count = max($bb_cfg['latest_news_count'], 1);
|
||||
|
||||
$data = DB()->fetch_rowset("
|
||||
SELECT topic_id, topic_time, topic_title, forum_id
|
||||
FROM ". BB_TOPICS ."
|
||||
WHERE forum_id IN ($news_forum_ids)
|
||||
AND topic_moved_id = 0
|
||||
ORDER BY topic_time DESC
|
||||
LIMIT $news_count
|
||||
");
|
||||
|
||||
$this->store('latest_news', $data);
|
||||
}
|
||||
|
||||
//
|
||||
// Network_news
|
||||
//
|
||||
if ($bb_cfg['show_network_news'] AND $net_forum_ids = $bb_cfg['network_news_forum_id'])
|
||||
{
|
||||
$net_count = max($bb_cfg['network_news_count'], 1);
|
||||
|
||||
$data = DB()->fetch_rowset("
|
||||
SELECT topic_id, topic_time, topic_title, forum_id
|
||||
FROM ". BB_TOPICS ."
|
||||
WHERE forum_id IN ($net_forum_ids)
|
||||
AND topic_moved_id = 0
|
||||
ORDER BY topic_time DESC
|
||||
LIMIT $net_count
|
||||
");
|
||||
|
||||
$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)));
|
||||
}
|
107
library/includes/datastore/build_moderators.php
Normal file
107
library/includes/datastore/build_moderators.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
$data = array(
|
||||
'name_users' => array(), // only by personal permissions
|
||||
'name_groups' => array(), // only visible to all users
|
||||
'mod_users' => array(), // only by personal permissions
|
||||
'mod_groups' => array(), // only visible to all users
|
||||
'moderators' => array(), // all moderators
|
||||
'admins' => array(), // all admins
|
||||
);
|
||||
|
||||
// name_users
|
||||
// mod_users
|
||||
$sql = "
|
||||
SELECT
|
||||
aa.forum_id, u.user_id, u.username
|
||||
FROM
|
||||
". BB_AUTH_ACCESS ." aa,
|
||||
". BB_USER_GROUP ." ug,
|
||||
". BB_GROUPS ." g,
|
||||
". BB_USERS ." u
|
||||
WHERE
|
||||
aa.forum_perm & ". BF_AUTH_MOD ."
|
||||
AND ug.group_id = aa.group_id
|
||||
AND ug.user_pending = 0
|
||||
AND g.group_id = ug.group_id
|
||||
AND g.group_single_user = 1
|
||||
AND u.user_id = ug.user_id
|
||||
GROUP BY
|
||||
aa.forum_id, u.user_id
|
||||
ORDER BY
|
||||
u.username
|
||||
";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$data['name_users'][$row['user_id']] = $row['username'];
|
||||
$data['mod_users'][$row['forum_id']][] = $row['user_id'];
|
||||
}
|
||||
|
||||
// name_groups
|
||||
// mod_groups
|
||||
$sql = "
|
||||
SELECT
|
||||
aa.forum_id, g.group_id, g.group_name
|
||||
FROM
|
||||
". BB_AUTH_ACCESS ." aa,
|
||||
". BB_GROUPS ." g
|
||||
WHERE
|
||||
aa.forum_perm & ". BF_AUTH_MOD ."
|
||||
AND g.group_id = aa.group_id
|
||||
AND g.group_single_user = 0
|
||||
AND g.group_type != ". GROUP_HIDDEN ."
|
||||
GROUP BY
|
||||
aa.forum_id, g.group_id
|
||||
ORDER BY
|
||||
g.group_name
|
||||
";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$data['name_groups'][$row['group_id']] = $row['group_name'];
|
||||
$data['mod_groups'][$row['forum_id']][] = $row['group_id'];
|
||||
}
|
||||
|
||||
// moderators
|
||||
$sql = "
|
||||
SELECT
|
||||
u.user_id, u.username
|
||||
FROM
|
||||
". BB_AUTH_ACCESS ." aa,
|
||||
". BB_USER_GROUP ." ug,
|
||||
". BB_GROUPS ." g,
|
||||
". BB_USERS ." u
|
||||
WHERE
|
||||
aa.forum_perm & ". BF_AUTH_MOD ."
|
||||
AND ug.group_id = aa.group_id
|
||||
AND ug.user_pending = 0
|
||||
AND g.group_id = ug.group_id
|
||||
AND u.user_id = ug.user_id
|
||||
GROUP BY
|
||||
u.user_id
|
||||
ORDER BY
|
||||
u.username
|
||||
";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$data['moderators'][$row['user_id']] = $row['username'];
|
||||
}
|
||||
|
||||
// admins
|
||||
$sql = "
|
||||
SELECT user_id, username
|
||||
FROM ". BB_USERS ."
|
||||
WHERE user_level = ". ADMIN ."
|
||||
ORDER BY username
|
||||
";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$data['admins'][$row['user_id']] = $row['username'];
|
||||
}
|
||||
|
||||
$this->store('moderators', $data);
|
14
library/includes/datastore/build_ranks.php
Normal file
14
library/includes/datastore/build_ranks.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
$ranks = array();
|
||||
|
||||
$sql = "SELECT rank_id, rank_title, rank_image, rank_style FROM ". BB_RANKS;
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$ranks[$row['rank_id']] = $row;
|
||||
}
|
||||
|
||||
$this->store('ranks', $ranks);
|
19
library/includes/datastore/build_smilies.php
Normal file
19
library/includes/datastore/build_smilies.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
$smilies = array();
|
||||
|
||||
$rowset = DB()->fetch_rowset("SELECT * FROM ". BB_SMILIES);
|
||||
sort($rowset);
|
||||
|
||||
foreach ($rowset as $smile)
|
||||
{
|
||||
$smilies['orig'][] = '#(?<=^|\W)'. preg_quote($smile['code'], '#') .'(?=$|\W)#';
|
||||
$smilies['repl'][] = ' <img class="smile" src="'. $bb_cfg['smilies_path'] .'/'. $smile['smile_url'] .'" alt="'. $smile['emoticon'] .'" align="absmiddle" border="0" />';
|
||||
$smilies['smile'][] = $smile;
|
||||
}
|
||||
|
||||
$this->store('smile_replacements', $smilies);
|
96
library/includes/datastore/build_stats.php
Normal file
96
library/includes/datastore/build_stats.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
$data = array();
|
||||
|
||||
// usercount
|
||||
$row = DB()->fetch_row("SELECT COUNT(*) AS usercount FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .")");
|
||||
$data['usercount'] = number_format($row['usercount']);
|
||||
|
||||
// newestuser
|
||||
$row = DB()->fetch_row("SELECT user_id, username, user_rank FROM ". BB_USERS ." WHERE user_active = 1 ORDER BY user_id DESC LIMIT 1");
|
||||
$data['newestuser'] = $row;
|
||||
|
||||
// post/topic count
|
||||
$row = DB()->fetch_row("SELECT SUM(forum_topics) AS topiccount, SUM(forum_posts) AS postcount FROM ". BB_FORUMS);
|
||||
$data['postcount'] = number_format($row['postcount']);
|
||||
$data['topiccount'] = number_format($row['topiccount']);
|
||||
|
||||
// Tracker stats
|
||||
if ($bb_cfg['tor_stats'])
|
||||
{
|
||||
// torrents stat
|
||||
$row = DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM ". BB_BT_TORRENTS);
|
||||
$data['torrentcount'] = number_format($row['torrentcount']);
|
||||
$data['size'] = $row['size'];
|
||||
|
||||
// peers stat
|
||||
$row = DB()->fetch_row("SELECT SUM(seeders) AS seeders, SUM(leechers) AS leechers, ((SUM(speed_up) + SUM(speed_down))/2) AS speed FROM ". BB_BT_TRACKER_SNAP);
|
||||
$data['seeders'] = number_format($row['seeders']);
|
||||
$data['leechers'] = number_format($row['leechers']);
|
||||
$data['peers'] = number_format($row['seeders'] + $row['leechers']);
|
||||
$data['speed'] = $row['speed'];
|
||||
}
|
||||
|
||||
// gender stat
|
||||
if ($bb_cfg['gender'])
|
||||
{
|
||||
$male = DB()->fetch_row("SELECT COUNT(user_id) AS male FROM ". BB_USERS ." WHERE user_gender = ". MALE ." AND user_id NOT IN(". EXCLUDED_USERS_CSV .")");
|
||||
$female = DB()->fetch_row("SELECT COUNT(user_id) AS female FROM ". BB_USERS ." WHERE user_gender = ". FEMALE ." AND user_id NOT IN(". EXCLUDED_USERS_CSV .")");
|
||||
$unselect = DB()->fetch_row("SELECT COUNT(user_id) AS unselect FROM ". BB_USERS ." WHERE user_gender = 0 AND user_id NOT IN(". EXCLUDED_USERS_CSV .")");
|
||||
|
||||
$data['male'] = $male['male'];
|
||||
$data['female'] = $female['female'];
|
||||
$data['unselect'] = $unselect['unselect'];
|
||||
}
|
||||
|
||||
// birthday stat
|
||||
if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
|
||||
{
|
||||
$sql = DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday
|
||||
FROM ". BB_USERS ."
|
||||
WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .")
|
||||
AND user_birthday != '0000-00-00'
|
||||
AND user_active = 1
|
||||
ORDER BY user_level DESC, username
|
||||
");
|
||||
|
||||
$date_today = bb_date(TIMENOW, 'md', false);
|
||||
$date_forward = bb_date(TIMENOW + ($bb_cfg['birthday_check_day']*86400), 'md', false);
|
||||
|
||||
$birthday_today_list = $birthday_week_list = array();
|
||||
|
||||
foreach ($sql as $row)
|
||||
{
|
||||
$user_birthday = date('md', strtotime($row['user_birthday']));
|
||||
|
||||
if ($user_birthday > $date_today && $user_birthday <= $date_forward)
|
||||
{
|
||||
// user are having birthday within the next days
|
||||
$birthday_week_list[] = array(
|
||||
'user_id' => $row['user_id'],
|
||||
'username' => $row['username'],
|
||||
'user_rank' => $row['user_rank'],
|
||||
'user_birthday' => $row['user_birthday'],
|
||||
);
|
||||
}
|
||||
elseif ($user_birthday == $date_today)
|
||||
{
|
||||
//user have birthday today
|
||||
$birthday_today_list[] = array(
|
||||
'user_id' => $row['user_id'],
|
||||
'username' => $row['username'],
|
||||
'user_rank' => $row['user_rank'],
|
||||
'user_birthday' => $row['user_birthday'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$data['birthday_today_list'] = $birthday_today_list;
|
||||
$data['birthday_week_list'] = $birthday_week_list;
|
||||
}
|
||||
|
||||
$this->store('stats', $data);
|
Loading…
Add table
Add a link
Reference in a new issue