mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Merge pull request #425 from Exile37/feature/code-analyze
Some static code analyze
This commit is contained in:
commit
d665729241
140 changed files with 1703 additions and 1725 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -2,26 +2,21 @@
|
|||
.env
|
||||
.idea
|
||||
.php_cs.cache
|
||||
bower_components
|
||||
composer.phar
|
||||
composer.lock
|
||||
configs/local.php
|
||||
data/avatars
|
||||
data/torrent_files
|
||||
internal_data/ajax_html
|
||||
internal_data/atom
|
||||
internal_data/cache
|
||||
internal_data/log
|
||||
internal_data/sitemap
|
||||
internal_data/triggers
|
||||
library/config.local.php
|
||||
node_modules
|
||||
sitemap
|
||||
vendor
|
||||
yarn.lock
|
||||
|
||||
### Archives ###
|
||||
*.log
|
||||
*.zip
|
||||
*.rar
|
||||
*.tar
|
||||
*.gz
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
namespace {
|
||||
exit("This file should not be included, only analyzed by your IDE");
|
||||
exit('This file should not be included, only analyzed by your IDE');
|
||||
|
||||
class Eloquent extends \Illuminate\Database\Eloquent\Model{
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ echo '<br /><br /><table border="1" cellspacing="0" cellpadding="6" align="cente
|
|||
|
||||
foreach ($sql as $i => $query) {
|
||||
$row = mysqli_fetch_row(OLD_DB()->query($query));
|
||||
echo "<tr><td>" . trans('messages.TR_STATS.' . $i) . "</td><td><b>{$row[0]}</b></td>";
|
||||
echo '<tr><td>' . trans('messages.TR_STATS.' . $i) . "</td><td><b>{$row[0]}</b></td>";
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
|
|
@ -185,8 +185,8 @@ if ($stopped) {
|
|||
|
||||
// Get last peer info from DB
|
||||
if (!OLD_CACHE('tr_cache')->used && !$lp_info) {
|
||||
$lp_info = OLD_DB()->fetch_row("
|
||||
SELECT * FROM " . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
|
||||
$lp_info = OLD_DB()->fetch_row('
|
||||
SELECT * FROM ' . BB_BT_TRACKER . " WHERE peer_hash = '$peer_hash' LIMIT 1
|
||||
");
|
||||
|
||||
if (DBG_LOG) {
|
||||
|
@ -208,10 +208,10 @@ if ($lp_info) {
|
|||
$info_hash_sql = rtrim(OLD_DB()->escape($info_hash), ' ');
|
||||
$passkey_sql = OLD_DB()->escape($passkey);
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT tor.topic_id, tor.poster_id, tor.tor_type, u.*
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql'
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
LEFT JOIN ' . BB_BT_USERS . " u ON u.auth_key = '$passkey_sql'
|
||||
WHERE tor.info_hash = '$info_hash_sql'
|
||||
LIMIT 1
|
||||
";
|
||||
|
@ -248,16 +248,16 @@ if ($lp_info) {
|
|||
|
||||
// Limit active torrents
|
||||
if (null === config('tp.unlimited_users.' . $user_id) && config('tracker.limit_active_tor') && ((config('tracker.limit_seed_count') && $seeder) || (config('tracker.limit_leech_count') && !$seeder))) {
|
||||
$sql = "SELECT COUNT(DISTINCT topic_id) AS active_torrents
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
$sql = 'SELECT COUNT(DISTINCT topic_id) AS active_torrents
|
||||
FROM ' . BB_BT_TRACKER . "
|
||||
WHERE user_id = $user_id
|
||||
AND seeder = $seeder
|
||||
AND topic_id != $topic_id";
|
||||
|
||||
if (!$seeder && config('tracker.leech_expire_factor') && $user_ratio < 0.5) {
|
||||
$sql .= " AND update_time > " . (TIMENOW - 60 * config('tracker.leech_expire_factor'));
|
||||
$sql .= ' AND update_time > ' . (TIMENOW - 60 * config('tracker.leech_expire_factor'));
|
||||
}
|
||||
$sql .= " GROUP BY user_id";
|
||||
$sql .= ' GROUP BY user_id';
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql)) {
|
||||
if ($seeder && config('tracker.limit_seed_count') && $row['active_torrents'] >= config('tracker.limit_seed_count')) {
|
||||
|
@ -270,17 +270,17 @@ if ($lp_info) {
|
|||
|
||||
// Limit concurrent IPs
|
||||
if (config('tracker.limit_concurrent_ips') && ((config('tracker.limit_seed_ips') && $seeder) || (config('tracker.limit_leech_ips') && !$seeder))) {
|
||||
$sql = "SELECT COUNT(DISTINCT ip) AS ips
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
$sql = 'SELECT COUNT(DISTINCT ip) AS ips
|
||||
FROM ' . BB_BT_TRACKER . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND user_id = $user_id
|
||||
AND seeder = $seeder
|
||||
AND ip != '$ip_sql'";
|
||||
|
||||
if (!$seeder && config('tracker.leech_expire_factor')) {
|
||||
$sql .= " AND update_time > " . (TIMENOW - 60 * config('tracker.leech_expire_factor'));
|
||||
$sql .= ' AND update_time > ' . (TIMENOW - 60 * config('tracker.leech_expire_factor'));
|
||||
}
|
||||
$sql .= " GROUP BY topic_id";
|
||||
$sql .= ' GROUP BY topic_id';
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql)) {
|
||||
if ($seeder && config('tracker.limit_seed_ips') && $row['ips'] >= config('tracker.limit_seed_ips')) {
|
||||
|
@ -326,10 +326,10 @@ if (config('tracker.freeleech') && $down_add) {
|
|||
|
||||
// Insert / update peer info
|
||||
$peer_info_updated = false;
|
||||
$update_time = ($stopped) ? 0 : TIMENOW;
|
||||
$update_time = $stopped ? 0 : TIMENOW;
|
||||
|
||||
if ($lp_info) {
|
||||
$sql = "UPDATE " . BB_BT_TRACKER . " SET update_time = $update_time";
|
||||
$sql = 'UPDATE ' . BB_BT_TRACKER . " SET update_time = $update_time";
|
||||
|
||||
$sql .= ", seeder = $seeder";
|
||||
$sql .= ($releaser != $lp_info['releaser']) ? ", releaser = $releaser" : '';
|
||||
|
@ -340,14 +340,14 @@ if ($lp_info) {
|
|||
$sql .= ($downloaded != $lp_info['downloaded']) ? ", downloaded = $downloaded" : '';
|
||||
$sql .= ", remain = $left";
|
||||
|
||||
$sql .= ($up_add) ? ", up_add = up_add + $up_add" : '';
|
||||
$sql .= ($down_add) ? ", down_add = down_add + $down_add" : '';
|
||||
$sql .= $up_add ? ", up_add = up_add + $up_add" : '';
|
||||
$sql .= $down_add ? ", down_add = down_add + $down_add" : '';
|
||||
|
||||
$sql .= ", speed_up = $speed_up";
|
||||
$sql .= ", speed_down = $speed_down";
|
||||
|
||||
$sql .= " WHERE peer_hash = '$peer_hash'";
|
||||
$sql .= " LIMIT 1";
|
||||
$sql .= ' LIMIT 1';
|
||||
|
||||
OLD_DB()->query($sql);
|
||||
|
||||
|
@ -362,7 +362,7 @@ if (!$lp_info || !$peer_info_updated) {
|
|||
$columns = 'peer_hash, topic_id, user_id, ip, port, seeder, releaser, tor_type, uploaded, downloaded, remain, speed_up, speed_down, up_add, down_add, update_time';
|
||||
$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";
|
||||
|
||||
OLD_DB()->query("REPLACE INTO " . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||
OLD_DB()->query('REPLACE INTO ' . BB_BT_TRACKER . " ($columns) VALUES ($values)");
|
||||
|
||||
if (DBG_LOG) {
|
||||
dbg_log(' ', 'this_peer-insert');
|
||||
|
@ -404,9 +404,9 @@ if (!$output) {
|
|||
$numwant = (int)config('tracker.numwant');
|
||||
$compact_mode = (config('tracker.compact_mode') || !empty($compact));
|
||||
|
||||
$rowset = OLD_DB()->fetch_rowset("
|
||||
$rowset = OLD_DB()->fetch_rowset('
|
||||
SELECT ip, port
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
FROM ' . BB_BT_TRACKER . "
|
||||
WHERE topic_id = $topic_id
|
||||
ORDER BY RAND()
|
||||
LIMIT $numwant
|
||||
|
@ -433,9 +433,9 @@ if (!$output) {
|
|||
$leechers = 0;
|
||||
|
||||
if (config('tracker.scrape')) {
|
||||
$row = OLD_DB()->fetch_row("
|
||||
$row = OLD_DB()->fetch_row('
|
||||
SELECT seeders, leechers
|
||||
FROM " . BB_BT_TRACKER_SNAP . "
|
||||
FROM ' . BB_BT_TRACKER_SNAP . "
|
||||
WHERE topic_id = $topic_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
order allow,deny
|
||||
deny from all
|
|
@ -45,10 +45,10 @@ require __DIR__ . '/includes/init_tr.php';
|
|||
|
||||
$info_hash_sql = rtrim(OLD_DB()->escape($info_hash), ' ');
|
||||
|
||||
$row = OLD_DB()->fetch_row("
|
||||
$row = OLD_DB()->fetch_row('
|
||||
SELECT tor.complete_count, snap.seeders, snap.leechers
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
LEFT JOIN ' . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
|
||||
WHERE tor.info_hash = '$info_hash_sql'
|
||||
LIMIT 1
|
||||
");
|
||||
|
|
26
callseed.php
26
callseed.php
|
@ -29,24 +29,24 @@ if ($t_data['seeders'] > 2) {
|
|||
|
||||
$ban_user_id = [];
|
||||
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT ban_userid FROM ' . BB_BANLIST . ' WHERE ban_userid != 0');
|
||||
|
||||
foreach ($sql as $row) {
|
||||
$ban_user_id[] = ',' . $row['ban_userid'];
|
||||
}
|
||||
$ban_user_id = implode('', $ban_user_id);
|
||||
|
||||
$user_list = OLD_DB()->fetch_rowset("
|
||||
$user_list = OLD_DB()->fetch_rowset('
|
||||
SELECT DISTINCT dl.user_id, u.user_opt, tr.user_id as active_dl
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
LEFT JOIN " . BB_USERS . " u ON(u.user_id = dl.user_id)
|
||||
LEFT JOIN " . BB_BT_TRACKER . " tr ON(tr.user_id = dl.user_id)
|
||||
FROM ' . BB_BT_DLSTATUS . ' dl
|
||||
LEFT JOIN ' . BB_USERS . ' u ON(u.user_id = dl.user_id)
|
||||
LEFT JOIN ' . BB_BT_TRACKER . " tr ON(tr.user_id = dl.user_id)
|
||||
WHERE dl.topic_id = $topic_id
|
||||
AND dl.user_status IN (" . DL_STATUS_COMPLETE . ", " . DL_STATUS_DOWN . ")
|
||||
AND dl.user_id NOT IN ({$userdata['user_id']}, " . EXCLUDED_USERS . $ban_user_id . ")
|
||||
AND dl.user_status IN (" . DL_STATUS_COMPLETE . ', ' . DL_STATUS_DOWN . ")
|
||||
AND dl.user_id NOT IN ({$userdata['user_id']}, " . EXCLUDED_USERS . $ban_user_id . ')
|
||||
AND u.user_active = 1
|
||||
GROUP BY dl.user_id
|
||||
");
|
||||
');
|
||||
|
||||
$subject = sprintf(trans('messages.CALLSEED_SUBJECT'), $t_data['topic_title']);
|
||||
$message = sprintf(trans('messages.CALLSEED_TEXT'), make_url(TOPIC_URL . $topic_id), $t_data['topic_title'], make_url(DOWNLOAD_URL . $t_data['attach_id']));
|
||||
|
@ -65,20 +65,20 @@ if ($user_list) {
|
|||
send_pm($t_data['poster_id'], $subject, $message, BOT_UID);
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TORRENTS . " SET call_seed_time = " . TIMENOW . " WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TORRENTS . ' SET call_seed_time = ' . TIMENOW . " WHERE topic_id = $topic_id");
|
||||
|
||||
meta_refresh(TOPIC_URL . $topic_id);
|
||||
bb_die(trans('messages.CALLSEED_MSG_OK'));
|
||||
|
||||
function topic_info($topic_id)
|
||||
{
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
tor.poster_id, tor.forum_id, tor.attach_id, tor.call_seed_time,
|
||||
t.topic_title, sn.seeders
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
|
||||
LEFT JOIN " . BB_BT_TRACKER_SNAP . " sn USING(topic_id)
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
LEFT JOIN ' . BB_TOPICS . ' t USING(topic_id)
|
||||
LEFT JOIN ' . BB_BT_TRACKER_SNAP . " sn USING(topic_id)
|
||||
WHERE tor.topic_id = $topic_id
|
||||
";
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ function bb_log($msg, $file_name)
|
|||
if (is_array($msg)) {
|
||||
$msg = implode(LOG_LF, $msg);
|
||||
}
|
||||
$file_name .= (LOG_EXT) ? '.' . LOG_EXT : '';
|
||||
$file_name .= LOG_EXT ? '.' . LOG_EXT : '';
|
||||
return file_write($msg, LOG_DIR . '/' . $file_name);
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ function log_request($file = '', $prepend_str = false, $add_post = true)
|
|||
}
|
||||
|
||||
if (!empty($_POST) && $add_post) {
|
||||
$str[] = "post: " . str_compact(urldecode(http_build_query($_POST)));
|
||||
$str[] = 'post: ' . str_compact(urldecode(http_build_query($_POST)));
|
||||
}
|
||||
$str = implode("\t", $str) . "\n";
|
||||
bb_log($str, $file);
|
||||
|
|
8
dl.php
8
dl.php
|
@ -31,7 +31,7 @@ function send_file_to_browser($attachment, $upload_dir)
|
|||
$gotit = false;
|
||||
|
||||
if (@!file_exists(@amod_realpath($filename))) {
|
||||
bb_die(trans('messages.ERROR_NO_ATTACHMENT') . "<br /><br />" . $filename . "<br /><br />" . trans('messages.TOR_NOT_FOUND'));
|
||||
bb_die(trans('messages.ERROR_NO_ATTACHMENT') . '<br /><br />' . $filename . '<br /><br />' . trans('messages.TOR_NOT_FOUND'));
|
||||
} else {
|
||||
$gotit = true;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ function send_file_to_browser($attachment, $upload_dir)
|
|||
}
|
||||
readfile($filename);
|
||||
} else {
|
||||
bb_die(trans('messages.ERROR_NO_ATTACHMENT') . "<br /><br />" . $filename . "<br /><br />" . trans('messages.TOR_NOT_FOUND'));
|
||||
bb_die(trans('messages.ERROR_NO_ATTACHMENT') . '<br /><br />' . $filename . '<br /><br />' . trans('messages.TOR_NOT_FOUND'));
|
||||
}
|
||||
|
||||
exit;
|
||||
|
@ -200,8 +200,8 @@ if (IS_GUEST && !bb_captcha('check')) {
|
|||
'ERROR_MESSAGE' => $message,
|
||||
));
|
||||
|
||||
require(PAGE_HEADER);
|
||||
require(PAGE_FOOTER);
|
||||
require PAGE_HEADER;
|
||||
require PAGE_FOOTER;
|
||||
}
|
||||
|
||||
send_file_to_browser($attachment, $upload_dir);
|
||||
|
|
12
dl_list.php
12
dl_list.php
|
@ -39,10 +39,10 @@ if ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status') {
|
|||
$full_url = isset($_POST['full_url']) ? str_replace('&', '&', htmlspecialchars($_POST['full_url'])) : '';
|
||||
|
||||
if (isset($_POST['redirect_type']) && $_POST['redirect_type'] == 'search') {
|
||||
$redirect_type = "search.php";
|
||||
$redirect_type = 'search.php';
|
||||
$redirect = $full_url ?: "$dl_key=1";
|
||||
} else {
|
||||
$redirect_type = (!$topic_id) ? "viewforum.php" : "viewtopic.php";
|
||||
$redirect_type = (!$topic_id) ? 'viewforum.php' : 'viewtopic.php';
|
||||
$redirect = $full_url ?: ((!$topic_id) ? POST_FORUM_URL . "=$forum_id" : POST_TOPIC_URL . "=$topic_id");
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ if (isset($_POST['cancel']) && $_POST['cancel']) {
|
|||
// Delete DL-list
|
||||
if ($mode == 'dl_delete' && $topic_id) {
|
||||
if (!IS_ADMIN) {
|
||||
$sql = "SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1";
|
||||
$sql = 'SELECT forum_id FROM ' . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1";
|
||||
|
||||
if (!$row = OLD_DB()->sql_fetchrow(OLD_DB()->sql_query($sql))) {
|
||||
bb_die('Could not obtain forum_id for this topic');
|
||||
|
@ -112,7 +112,7 @@ if ($mode == 'set_topics_dl_status') {
|
|||
|
||||
// Get existing topics
|
||||
if ($req_topics_sql = implode(',', $req_topics_ary)) {
|
||||
$sql = "SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)";
|
||||
$sql = 'SELECT topic_id FROM ' . BB_TOPICS . " WHERE topic_id IN($req_topics_sql)";
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$topics_ary[] = $row['topic_id'];
|
||||
|
@ -131,9 +131,9 @@ if ($topics_ary && ($mode == 'set_dl_status' || $mode == 'set_topics_dl_status')
|
|||
}
|
||||
$new_dlstatus_sql = OLD_DB()->build_array('MULTI_INSERT', $new_dlstatus_ary);
|
||||
|
||||
OLD_DB()->query("REPLACE INTO " . BB_BT_DLSTATUS . " $new_dlstatus_sql");
|
||||
OLD_DB()->query('REPLACE INTO ' . BB_BT_DLSTATUS . " $new_dlstatus_sql");
|
||||
|
||||
redirectToUrl("$redirect_type?$redirect");
|
||||
}
|
||||
|
||||
redirectToUrl("index.php");
|
||||
redirectToUrl('index.php');
|
||||
|
|
2
feed.php
2
feed.php
|
@ -25,7 +25,7 @@ if (!$mode) {
|
|||
if ($mode == 'get_feed_url' && ($type == 'f' || $type == 'u') && $id >= 0) {
|
||||
if ($type == 'f') {
|
||||
// Check if the user has actually sent a forum ID
|
||||
$sql = "SELECT allow_reg_tracker, forum_name FROM " . BB_FORUMS . " WHERE forum_id = $id LIMIT 1";
|
||||
$sql = 'SELECT allow_reg_tracker, forum_name FROM ' . BB_FORUMS . " WHERE forum_id = $id LIMIT 1";
|
||||
if (!$forum_data = OLD_DB()->fetch_row($sql)) {
|
||||
if ($id == 0) {
|
||||
$forum_data = array();
|
||||
|
|
118
group.php
118
group.php
|
@ -26,11 +26,11 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
|
|||
$joined = bb_date($row['user_regdate']);
|
||||
$user_time = (!empty($row['user_time'])) ? bb_date($row['user_time']) : trans('messages.NONE');
|
||||
$posts = $row['user_posts'] ?: 0;
|
||||
$pm = '<a class="txtb" href="' . (PM_URL . "?mode=post&" . POST_USERS_URL . "=" . $row['user_id']) . '">' . trans('messages.SEND_PM_TXTB') . '</a>';
|
||||
$pm = '<a class="txtb" href="' . (PM_URL . '?mode=post&' . POST_USERS_URL . '=' . $row['user_id']) . '">' . trans('messages.SEND_PM_TXTB') . '</a>';
|
||||
$avatar = get_avatar($row['user_id'], $row['avatar_ext_id'], !bf($row['user_opt'], 'user_opt', 'dis_avatar'), '', 50, 50);
|
||||
|
||||
if (bf($row['user_opt'], 'user_opt', 'user_viewemail') || $group_mod) {
|
||||
$email_uri = config('tp.board_email_form') ? ("profile.php?mode=email&" . POST_USERS_URL . "=" . $row['user_id']) : 'mailto:' . $row['user_email'];
|
||||
$email_uri = config('tp.board_email_form') ? ('profile.php?mode=email&' . POST_USERS_URL . '=' . $row['user_id']) : 'mailto:' . $row['user_email'];
|
||||
$email = '<a class="editable" href="' . $email_uri . '">' . $row['user_email'] . '</a>';
|
||||
} else {
|
||||
$email = '';
|
||||
|
@ -41,8 +41,6 @@ function generate_user_info(&$row, $date_format, $group_mod, &$from, &$posts, &$
|
|||
} else {
|
||||
$www = '';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->session_start(array('req_login' => true));
|
||||
|
@ -82,16 +80,16 @@ if (!$group_id) {
|
|||
IF(g.group_moderator = ug.user_id, 1, 0) AS is_group_mod,
|
||||
COUNT(ug2.user_id) AS members, SUM(ug2.user_pending) AS candidates
|
||||
FROM
|
||||
" . BB_GROUPS . " g
|
||||
" . BB_GROUPS . ' g
|
||||
LEFT JOIN
|
||||
" . BB_USER_GROUP . " ug ON
|
||||
' . BB_USER_GROUP . ' ug ON
|
||||
ug.group_id = g.group_id
|
||||
AND ug.user_id = " . $userdata['user_id'] . "
|
||||
AND ug.user_id = ' . $userdata['user_id'] . '
|
||||
LEFT JOIN
|
||||
" . BB_USER_GROUP . " ug2 ON
|
||||
' . BB_USER_GROUP . ' ug2 ON
|
||||
ug2.group_id = g.group_id
|
||||
LEFT JOIN
|
||||
" . BB_USERS . " u ON g.group_moderator = u.user_id
|
||||
' . BB_USERS . ' u ON g.group_moderator = u.user_id
|
||||
WHERE
|
||||
g.group_single_user = 0
|
||||
GROUP BY g.group_id
|
||||
|
@ -100,7 +98,7 @@ if (!$group_id) {
|
|||
membership DESC,
|
||||
g.group_type ASC,
|
||||
g.group_name ASC
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
if ($row['is_group_mod']) {
|
||||
|
@ -119,7 +117,7 @@ if (!$group_id) {
|
|||
continue;
|
||||
}
|
||||
|
||||
$data = array('id' => $row['group_id'], 'm' => ($row['members'] - $row['candidates']), 'c' => $row['candidates'], 'rg' => $row['release_group']);
|
||||
$data = array('id' => $row['group_id'], 'm' => $row['members'] - $row['candidates'], 'c' => $row['candidates'], 'rg' => $row['release_group']);
|
||||
|
||||
$groups[$type][$row['group_name']] = $data;
|
||||
}
|
||||
|
@ -131,11 +129,11 @@ if (!$group_id) {
|
|||
foreach ($params as $name => $data) {
|
||||
$text = htmlCHR(str_short(rtrim($name), HTML_SELECT_MAX_LENGTH));
|
||||
|
||||
$members = ($data['m']) ? trans('messages.MEMBERS_IN_GROUP') . ': ' . $data['m'] : trans('messages.NO_GROUP_MEMBERS');
|
||||
$candidates = ($data['c']) ? trans('messages.PENDING_MEMBERS') . ': ' . $data['c'] : trans('messages.NO_PENDING_GROUP_MEMBERS');
|
||||
$members = $data['m'] ? trans('messages.MEMBERS_IN_GROUP') . ': ' . $data['m'] : trans('messages.NO_GROUP_MEMBERS');
|
||||
$candidates = $data['c'] ? trans('messages.PENDING_MEMBERS') . ': ' . $data['c'] : trans('messages.NO_PENDING_GROUP_MEMBERS');
|
||||
|
||||
$options .= '<li class="pad_2"><a href="' . GROUP_URL . $data['id'] . '" class="med bold">' . $text . '</a></li>';
|
||||
$options .= ($data['rg']) ? '<ul><li class="med">' . trans('messages.RELEASE_GROUP') . '</li>' : '<ul>';
|
||||
$options .= $data['rg'] ? '<ul><li class="med">' . trans('messages.RELEASE_GROUP') . '</li>' : '<ul>';
|
||||
$options .= '<li class="seedmed">' . $members . '</li>';
|
||||
if (IS_AM) {
|
||||
$options .= '<li class="leechmed">' . $candidates . '</li>';
|
||||
|
@ -173,14 +171,14 @@ if (!$group_id) {
|
|||
bb_die(trans('messages.THIS_CLOSED_GROUP'));
|
||||
}
|
||||
|
||||
$sql = "SELECT g.group_id, g.group_name, ug.user_id, u.user_email, u.username, u.user_lang
|
||||
FROM " . BB_GROUPS . " g
|
||||
LEFT JOIN " . BB_USERS . " u ON(u.user_id = g.group_moderator)
|
||||
LEFT JOIN " . BB_USER_GROUP . " ug ON(ug.group_id = g.group_id AND ug.user_id = {$userdata['user_id']})
|
||||
$sql = 'SELECT g.group_id, g.group_name, ug.user_id, u.user_email, u.username, u.user_lang
|
||||
FROM ' . BB_GROUPS . ' g
|
||||
LEFT JOIN ' . BB_USERS . ' u ON(u.user_id = g.group_moderator)
|
||||
LEFT JOIN ' . BB_USER_GROUP . " ug ON(ug.group_id = g.group_id AND ug.user_id = {$userdata['user_id']})
|
||||
WHERE g.group_id = $group_id
|
||||
AND group_single_user = 0
|
||||
AND g.group_type = " . GROUP_OPEN . "
|
||||
LIMIT 1";
|
||||
AND g.group_type = " . GROUP_OPEN . '
|
||||
LIMIT 1';
|
||||
|
||||
$row = $moderator = OLD_DB()->fetch_row($sql);
|
||||
|
||||
|
@ -266,8 +264,8 @@ if (!$group_id) {
|
|||
}
|
||||
|
||||
if (!empty($_POST['approve'])) {
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USER_GROUP . " SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USER_GROUP . " SET
|
||||
user_pending = 0
|
||||
WHERE user_id IN($sql_in)
|
||||
AND group_id = $group_id
|
||||
|
@ -275,8 +273,8 @@ if (!$group_id) {
|
|||
|
||||
update_user_level($sql_in);
|
||||
} elseif (!empty($_POST['deny']) || !empty($_POST['remove'])) {
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_USER_GROUP . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_USER_GROUP . "
|
||||
WHERE user_id IN($sql_in)
|
||||
AND group_id = $group_id
|
||||
");
|
||||
|
@ -287,8 +285,8 @@ if (!$group_id) {
|
|||
}
|
||||
// Email users when they are approved
|
||||
if (!empty($_POST['approve']) && config('tp.group_send_email')) {
|
||||
$sql_select = "SELECT username, user_email, user_lang
|
||||
FROM " . BB_USERS . "
|
||||
$sql_select = 'SELECT username, user_email, user_lang
|
||||
FROM ' . BB_USERS . "
|
||||
WHERE user_id IN($sql_in)";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql_select)) {
|
||||
|
@ -319,20 +317,20 @@ if (!$group_id) {
|
|||
// END approve or deny
|
||||
|
||||
// Get moderator details for this group
|
||||
$group_moderator = OLD_DB()->fetch_row("
|
||||
$group_moderator = OLD_DB()->fetch_row('
|
||||
SELECT *
|
||||
FROM " . BB_USERS . "
|
||||
WHERE user_id = " . $group_info['group_moderator'] . "
|
||||
");
|
||||
FROM ' . BB_USERS . '
|
||||
WHERE user_id = ' . $group_info['group_moderator'] . '
|
||||
');
|
||||
|
||||
// Current user membership
|
||||
$is_group_member = $is_group_pending_member = false;
|
||||
|
||||
$sql = "SELECT user_pending
|
||||
FROM " . BB_USER_GROUP . "
|
||||
$sql = 'SELECT user_pending
|
||||
FROM ' . BB_USER_GROUP . "
|
||||
WHERE group_id = $group_id
|
||||
AND user_id = " . $userdata['user_id'] . "
|
||||
LIMIT 1";
|
||||
AND user_id = " . $userdata['user_id'] . '
|
||||
LIMIT 1';
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql)) {
|
||||
if ($row['user_pending'] == 0) {
|
||||
|
@ -348,9 +346,9 @@ if (!$group_id) {
|
|||
} elseif ($is_group_member || $is_group_pending_member) {
|
||||
$template->assign_vars(array(
|
||||
'SHOW_UNSUBSCRIBE_CONTROLS' => true,
|
||||
'CONTROL_NAME' => ($is_group_member) ? 'unsub' : 'unsubpending',
|
||||
'CONTROL_NAME' => $is_group_member ? 'unsub' : 'unsubpending',
|
||||
));
|
||||
$group_details = ($is_group_pending_member) ? trans('messages.PENDING_THIS_GROUP') : trans('messages.MEMBER_THIS_GROUP');
|
||||
$group_details = $is_group_pending_member ? trans('messages.PENDING_THIS_GROUP') : trans('messages.MEMBER_THIS_GROUP');
|
||||
$s_hidden_fields = '<input type="hidden" name="' . POST_GROUPS_URL . '" value="' . $group_id . '" />';
|
||||
} elseif (IS_GUEST) {
|
||||
$group_details = trans('messages.LOGIN_TO_JOIN');
|
||||
|
@ -405,12 +403,12 @@ if (!$group_id) {
|
|||
'MOD_EMAIL' => $email,
|
||||
'MOD_WWW' => $www,
|
||||
'MOD_TIME' => (!empty($group_info['mod_time'])) ? bb_date($group_info['mod_time']) : trans('messages.NONE'),
|
||||
'U_SEARCH_USER' => "search.php?mode=searchuser",
|
||||
'U_SEARCH_USER' => 'search.php?mode=searchuser',
|
||||
'U_SEARCH_RELEASES' => "tracker.php?srg=$group_id",
|
||||
'U_GROUP_RELEASES' => "group.php?view=releases&" . POST_GROUPS_URL . "=$group_id",
|
||||
'U_GROUP_MEMBERS' => "group.php?view=members&" . POST_GROUPS_URL . "=$group_id",
|
||||
'U_GROUP_RELEASES' => 'group.php?view=releases&' . POST_GROUPS_URL . "=$group_id",
|
||||
'U_GROUP_MEMBERS' => 'group.php?view=members&' . POST_GROUPS_URL . "=$group_id",
|
||||
'U_GROUP_CONFIG' => "group_edit.php?g=$group_id",
|
||||
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
|
||||
'RELEASE_GROUP' => $group_info['release_group'] ? true : false,
|
||||
'GROUP_TYPE' => $group_type,
|
||||
|
||||
'S_GROUP_OPEN_TYPE' => GROUP_OPEN,
|
||||
|
@ -423,7 +421,7 @@ if (!$group_id) {
|
|||
'S_MODE_SELECT' => $select_sort_mode,
|
||||
'S_ORDER_SELECT' => $select_sort_order,
|
||||
|
||||
'S_GROUP_ACTION' => "group.php?" . POST_GROUPS_URL . "=$group_id",
|
||||
'S_GROUP_ACTION' => 'group.php?' . POST_GROUPS_URL . "=$group_id",
|
||||
));
|
||||
|
||||
switch ($view_mode) {
|
||||
|
@ -436,26 +434,26 @@ if (!$group_id) {
|
|||
}
|
||||
|
||||
// Count releases for pagination
|
||||
$all_releases = OLD_DB()->fetch_rowset("
|
||||
$all_releases = OLD_DB()->fetch_rowset('
|
||||
SELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)
|
||||
LEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_TOPICS . ' t ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN ' . BB_FORUMS . ' f ON(p.forum_id= f.forum_id)
|
||||
LEFT JOIN ' . BB_USERS . " u ON(p.poster_id = u.user_id)
|
||||
WHERE p.poster_rg_id = $group_id
|
||||
ORDER BY t.topic_time DESC
|
||||
LIMIT $rel_limit
|
||||
");
|
||||
$count_releases = count($all_releases);
|
||||
|
||||
generate_pagination(GROUP_URL . $group_id . "&view=releases", $count_releases, $per_page, $start);
|
||||
generate_pagination(GROUP_URL . $group_id . '&view=releases', $count_releases, $per_page, $start);
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT p.topic_id, p.forum_id, p.poster_id, t.topic_title, t.topic_time, f.forum_name, u.username, u.avatar_ext_id, u.user_opt, u.user_rank
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_TOPICS . " t ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN " . BB_FORUMS . " f ON(p.forum_id= f.forum_id)
|
||||
LEFT JOIN " . BB_USERS . " u ON(p.poster_id = u.user_id)
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_TOPICS . ' t ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN ' . BB_FORUMS . ' f ON(p.forum_id= f.forum_id)
|
||||
LEFT JOIN ' . BB_USERS . " u ON(p.poster_id = u.user_id)
|
||||
WHERE p.poster_rg_id = $group_id
|
||||
ORDER BY t.topic_time DESC
|
||||
LIMIT $start, $per_page
|
||||
|
@ -490,24 +488,24 @@ if (!$group_id) {
|
|||
default:
|
||||
|
||||
// Members
|
||||
$count_members = OLD_DB()->fetch_rowset("
|
||||
$count_members = OLD_DB()->fetch_rowset('
|
||||
SELECT u.username, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, ug.user_pending, ug.user_time
|
||||
FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
|
||||
FROM ' . BB_USER_GROUP . ' ug, ' . BB_USERS . " u
|
||||
WHERE ug.group_id = $group_id
|
||||
AND ug.user_pending = 0
|
||||
AND ug.user_id <> " . $group_moderator['user_id'] . "
|
||||
AND ug.user_id <> " . $group_moderator['user_id'] . '
|
||||
AND u.user_id = ug.user_id
|
||||
ORDER BY u.username
|
||||
");
|
||||
');
|
||||
$count_members = count($count_members);
|
||||
|
||||
// Get user information for this group
|
||||
$modgroup_pending_count = 0;
|
||||
|
||||
// Members
|
||||
$group_members = OLD_DB()->fetch_rowset("
|
||||
$group_members = OLD_DB()->fetch_rowset('
|
||||
SELECT u.username, u.avatar_ext_id, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email, ug.user_pending, ug.user_time
|
||||
FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
|
||||
FROM ' . BB_USER_GROUP . ' ug, ' . BB_USERS . " u
|
||||
WHERE ug.group_id = $group_id
|
||||
AND ug.user_pending = 0
|
||||
AND ug.user_id <> " . $group_moderator['user_id'] . "
|
||||
|
@ -561,9 +559,9 @@ if (!$group_id) {
|
|||
|
||||
// Pending
|
||||
if ($is_moderator) {
|
||||
$modgroup_pending_list = OLD_DB()->fetch_rowset("
|
||||
$modgroup_pending_list = OLD_DB()->fetch_rowset('
|
||||
SELECT u.username, u.avatar_ext_id, u.user_rank, u.user_id, u.user_opt, u.user_posts, u.user_regdate, u.user_from, u.user_website, u.user_email
|
||||
FROM " . BB_USER_GROUP . " ug, " . BB_USERS . " u
|
||||
FROM ' . BB_USER_GROUP . ' ug, ' . BB_USERS . " u
|
||||
WHERE ug.group_id = $group_id
|
||||
AND ug.user_pending = 1
|
||||
AND u.user_id = ug.user_id
|
||||
|
|
|
@ -39,13 +39,13 @@ if ($is_moderator) {
|
|||
if (!empty($_FILES['avatar']['name']) && config('tp.group_avatars.up_allowed')) {
|
||||
$upload = new TorrentPier\Legacy\Common\Upload();
|
||||
|
||||
if ($upload->init(config('tp.group_avatars'), $_FILES['avatar']) and $upload->store('avatar', array("user_id" => GROUP_AVATAR_MASK . $group_id, "avatar_ext_id" => $group_info['avatar_ext_id']))) {
|
||||
if ($upload->init(config('tp.group_avatars'), $_FILES['avatar']) and $upload->store('avatar', array('user_id' => GROUP_AVATAR_MASK . $group_id, 'avatar_ext_id' => $group_info['avatar_ext_id']))) {
|
||||
$avatar_ext_id = (int)$upload->file_ext_id;
|
||||
} else {
|
||||
bb_die(implode($upload->errors));
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_GROUPS . " SET avatar_ext_id = $avatar_ext_id WHERE group_id = $group_id");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ if ($is_moderator) {
|
|||
'S_GROUP_CLOSED_CHECKED' => ($group_info['group_type'] == GROUP_CLOSED) ? ' checked="checked"' : '',
|
||||
'S_GROUP_HIDDEN_CHECKED' => ($group_info['group_type'] == GROUP_HIDDEN) ? ' checked="checked"' : '',
|
||||
'S_HIDDEN_FIELDS' => $s_hidden_fields,
|
||||
'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
|
||||
'S_GROUP_CONFIG_ACTION' => 'group_edit.php?' . POST_GROUPS_URL . "=$group_id",
|
||||
|
||||
'AVATAR_EXPLAIN' => sprintf(trans('messages.AVATAR_EXPLAIN'), config('tp.group_avatars.max_width'), config('tp.group_avatars.max_height'), round(config('tp.group_avatars.max_size') / 1024)),
|
||||
'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
|
||||
|
@ -85,11 +85,11 @@ if ($is_moderator) {
|
|||
$template->set_filenames(array('body' => 'group_edit.tpl'));
|
||||
$template->assign_vars(array('PAGE_TITLE' => trans('messages.GROUP_CONFIGURATION')));
|
||||
|
||||
require(PAGE_HEADER);
|
||||
require PAGE_HEADER;
|
||||
|
||||
$template->pparse('body');
|
||||
|
||||
require(PAGE_FOOTER);
|
||||
require PAGE_FOOTER;
|
||||
} else {
|
||||
$redirect = 'index.php';
|
||||
|
||||
|
|
50
index.php
50
index.php
|
@ -37,11 +37,11 @@ $user->session_start();
|
|||
|
||||
// Init main vars
|
||||
$viewcat = isset($_GET['c']) ? (int)$_GET['c'] : 0;
|
||||
$lastvisit = (IS_GUEST) ? TIMENOW : $userdata['user_lastvisit'];
|
||||
$lastvisit = IS_GUEST ? TIMENOW : $userdata['user_lastvisit'];
|
||||
|
||||
// Caching output
|
||||
$req_page = 'index_page';
|
||||
$req_page .= ($viewcat) ? "_c{$viewcat}" : '';
|
||||
$req_page .= $viewcat ? "_c{$viewcat}" : '';
|
||||
|
||||
define('REQUESTED_PAGE', $req_page);
|
||||
caching_output(IS_GUEST, 'send', REQUESTED_PAGE . '_guest_' . config('app.locale'));
|
||||
|
@ -74,28 +74,28 @@ $only_new = $user->opt_js['only_new'];
|
|||
|
||||
// Validate requested category id
|
||||
if ($viewcat && !($viewcat =& $forums['c'][$viewcat]['cat_id'])) {
|
||||
redirectToUrl("index.php");
|
||||
redirectToUrl('index.php');
|
||||
}
|
||||
|
||||
// Forums
|
||||
$forums_join_sql = 'f.cat_id = c.cat_id';
|
||||
$forums_join_sql .= ($viewcat) ? "
|
||||
$forums_join_sql .= $viewcat ? "
|
||||
AND f.cat_id = $viewcat
|
||||
" : '';
|
||||
$forums_join_sql .= ($excluded_forums_csv) ? "
|
||||
$forums_join_sql .= $excluded_forums_csv ? "
|
||||
AND f.forum_id NOT IN($excluded_forums_csv)
|
||||
AND f.forum_parent NOT IN($excluded_forums_csv)
|
||||
" : '';
|
||||
|
||||
// Posts
|
||||
$posts_join_sql = "p.post_id = f.forum_last_post_id";
|
||||
$posts_join_sql = 'p.post_id = f.forum_last_post_id';
|
||||
$posts_join_sql .= ($only_new == ONLY_NEW_POSTS) ? "
|
||||
AND p.post_time > $lastvisit
|
||||
" : '';
|
||||
$join_p_type = ($only_new == ONLY_NEW_POSTS) ? 'INNER JOIN' : 'LEFT JOIN';
|
||||
|
||||
// Topics
|
||||
$topics_join_sql = "t.topic_last_post_id = p.post_id";
|
||||
$topics_join_sql = 't.topic_last_post_id = p.post_id';
|
||||
$topics_join_sql .= ($only_new == ONLY_NEW_TOPICS) ? "
|
||||
AND t.topic_time > $lastvisit
|
||||
" : '';
|
||||
|
@ -108,13 +108,13 @@ $sql = "
|
|||
t.topic_id AS last_topic_id, t.topic_title AS last_topic_title,
|
||||
u.user_id AS last_post_user_id, u.user_rank AS last_post_user_rank,
|
||||
IF(p.poster_id = $anon, p.post_username, u.username) AS last_post_username
|
||||
FROM " . BB_CATEGORIES . " c
|
||||
INNER JOIN " . BB_FORUMS . " f ON($forums_join_sql)
|
||||
FROM " . BB_CATEGORIES . ' c
|
||||
INNER JOIN ' . BB_FORUMS . " f ON($forums_join_sql)
|
||||
$join_p_type " . BB_POSTS . " p ON($posts_join_sql)
|
||||
$join_t_type " . BB_TOPICS . " t ON($topics_join_sql)
|
||||
LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id)
|
||||
LEFT JOIN " . BB_USERS . ' u ON(u.user_id = p.poster_id)
|
||||
ORDER BY c.cat_order, f.forum_order
|
||||
";
|
||||
';
|
||||
|
||||
$replace_in_parent = array(
|
||||
'last_post_id',
|
||||
|
@ -191,11 +191,11 @@ foreach ($cat_forums as $cid => $c) {
|
|||
$template->assign_block_vars('h_c', array(
|
||||
'H_C_ID' => $cid,
|
||||
'H_C_TITLE' => $cat_title_html[$cid],
|
||||
'H_C_CHEKED' => in_array($cid, preg_split("/[-]+/", $hide_cat_opt)) ? 'checked' : '',
|
||||
'H_C_CHEKED' => in_array($cid, preg_split('/[-]+/', $hide_cat_opt)) ? 'checked' : '',
|
||||
));
|
||||
|
||||
$template->assign_vars(array(
|
||||
'H_C_AL_MESS' => ($hide_cat_opt && !$showhide),
|
||||
'H_C_AL_MESS' => $hide_cat_opt && !$showhide,
|
||||
));
|
||||
|
||||
if (!$showhide && isset($hide_cat_user[$cid]) && !$viewcat) {
|
||||
|
@ -216,10 +216,10 @@ foreach ($cat_forums as $cid => $c) {
|
|||
|
||||
$forums_count++;
|
||||
$new = is_unread($f['last_post_time'], $f['last_topic_id'], $f['forum_id']) ? '_new' : '';
|
||||
$folder_image = ($is_sf) ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
|
||||
$folder_image = $is_sf ? $images["icon_minipost{$new}"] : $images["forum{$new}"];
|
||||
|
||||
if ($f['forum_status'] == FORUM_LOCKED) {
|
||||
$folder_image = ($is_sf) ? $images['icon_minipost'] : $images['forum_locked'];
|
||||
$folder_image = $is_sf ? $images['icon_minipost'] : $images['forum_locked'];
|
||||
}
|
||||
|
||||
if ($is_sf) {
|
||||
|
@ -257,9 +257,9 @@ foreach ($cat_forums as $cid => $c) {
|
|||
|
||||
$template->assign_vars(array(
|
||||
'SHOW_FORUMS' => $forums_count,
|
||||
'SHOW_MAP' => (isset($_GET['map']) && !IS_GUEST),
|
||||
'PAGE_TITLE' => ($viewcat) ? $cat_title_html[$viewcat] : trans('messages.HOME'),
|
||||
'NO_FORUMS_MSG' => ($only_new) ? trans('messages.NO_NEW_POSTS') : trans('messages.NO_FORUMS'),
|
||||
'SHOW_MAP' => isset($_GET['map']) && !IS_GUEST,
|
||||
'PAGE_TITLE' => $viewcat ? $cat_title_html[$viewcat] : trans('messages.HOME'),
|
||||
'NO_FORUMS_MSG' => $only_new ? trans('messages.NO_NEW_POSTS') : trans('messages.NO_FORUMS'),
|
||||
|
||||
'TOTAL_TOPICS' => sprintf(trans('messages.POSTED_TOPICS_TOTAL'), $stats['topiccount']),
|
||||
'TOTAL_POSTS' => sprintf(trans('messages.POSTED_ARTICLES_TOTAL'), $stats['postcount']),
|
||||
|
@ -294,13 +294,13 @@ $template->assign_vars(array(
|
|||
'FORUM_LOCKED_IMG' => $images['forum_locked'],
|
||||
|
||||
'SHOW_ONLY_NEW_MENU' => true,
|
||||
'ONLY_NEW_POSTS_ON' => ($only_new == ONLY_NEW_POSTS),
|
||||
'ONLY_NEW_TOPICS_ON' => ($only_new == ONLY_NEW_TOPICS),
|
||||
'ONLY_NEW_POSTS_ON' => $only_new == ONLY_NEW_POSTS,
|
||||
'ONLY_NEW_TOPICS_ON' => $only_new == ONLY_NEW_TOPICS,
|
||||
|
||||
'U_SEARCH_NEW' => "search.php?new=1",
|
||||
'U_SEARCH_NEW' => 'search.php?new=1',
|
||||
'U_SEARCH_SELF_BY_MY' => "search.php?uid={$userdata['user_id']}&o=1",
|
||||
'U_SEARCH_LATEST' => "search.php?search_id=latest",
|
||||
'U_SEARCH_UNANSWERED' => "search.php?search_id=unanswered",
|
||||
'U_SEARCH_LATEST' => 'search.php?search_id=latest',
|
||||
'U_SEARCH_UNANSWERED' => 'search.php?search_id=unanswered',
|
||||
|
||||
'SHOW_LAST_TOPIC' => $show_last_topic,
|
||||
));
|
||||
|
@ -365,7 +365,7 @@ if (config('tp.birthday_check_day') && config('tp.birthday_enabled')) {
|
|||
}
|
||||
$week_list[] = profile_url($week) . ' <span class="small">(' . birthday_age($week['user_birthday'] - 1) . ')</span>';
|
||||
}
|
||||
$week_all = ($week_all) ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . trans('messages.ALL') . '">...</a>' : '';
|
||||
$week_all = $week_all ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="' . trans('messages.ALL') . '">...</a>' : '';
|
||||
$week_list = sprintf(trans('messages.BIRTHDAY_WEEK'), config('tp.birthday_check_day'), implode(', ', $week_list)) . $week_all;
|
||||
} else {
|
||||
$week_list = sprintf(trans('messages.NOBIRTHDAY_WEEK'), config('tp.birthday_check_day'));
|
||||
|
@ -380,7 +380,7 @@ if (config('tp.birthday_check_day') && config('tp.birthday_enabled')) {
|
|||
}
|
||||
$today_list[] = profile_url($today) . ' <span class="small">(' . birthday_age($today['user_birthday']) . ')</span>';
|
||||
}
|
||||
$today_all = ($today_all) ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="' . trans('messages.ALL') . '">...</a>' : '';
|
||||
$today_all = $today_all ? ' <a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_today\'}); return false;" title="' . trans('messages.ALL') . '">...</a>' : '';
|
||||
$today_list = trans('messages.BIRTHDAY_TODAY') . implode(', ', $today_list) . $today_all;
|
||||
} else {
|
||||
$today_list = trans('messages.NOBIRTHDAY_TODAY');
|
||||
|
|
2
info.php
2
info.php
|
@ -77,7 +77,7 @@ $require = file_exists($html_dir . $info['src']) ? $html_dir . $info['src'] : $h
|
|||
<fieldset class="pad_6">
|
||||
<legend class="med bold mrg_2 warnColor1"><?php echo mb_strtoupper($info['title'], 'UTF-8'); ?></legend>
|
||||
<div class="bCenter">
|
||||
<?php require($require); ?>
|
||||
<?php require $require; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<p class="gen tRight pad_6"><a href="javascript:window.close();" class="gen">[ <?php echo trans('messages.LOCK'); ?> ]</a>
|
||||
|
|
|
@ -370,7 +370,7 @@ class Attach
|
|||
} else {
|
||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET thumbnail = 0 WHERE attach_id = ' . (int)$actual_id_list[$i];
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Unable to update ' . BB_ATTACHMENTS_DESC);
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ class Attach
|
|||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . ' SET ' . attach_mod_sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE attach_id = ' . (int)$attachment_id;
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Unable to update the attachment');
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ class Attach
|
|||
global $post_info, $userdata;
|
||||
|
||||
$post_id = (int)$message_id;
|
||||
$user_id_1 = (isset($post_info['poster_id'])) ? (int)$post_info['poster_id'] : 0;
|
||||
$user_id_1 = isset($post_info['poster_id']) ? (int)$post_info['poster_id'] : 0;
|
||||
|
||||
if (!$user_id_1) {
|
||||
$user_id_1 = (int)$userdata['user_id'];
|
||||
|
@ -546,7 +546,7 @@ class Attach
|
|||
SET comment = '" . @attach_mod_sql_escape($this->attachment_comment_list[$i]) . "'
|
||||
WHERE attach_id = " . $this->attachment_id_list[$i];
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Unable to update the file comment');
|
||||
}
|
||||
} else {
|
||||
|
@ -568,7 +568,7 @@ class Attach
|
|||
|
||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ class Attach
|
|||
|
||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ class Attach
|
|||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS_DESC . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
|
||||
// Inform the user that his post has been created, but nothing is attached
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,7 @@ class Attach
|
|||
|
||||
$sql = 'INSERT INTO ' . BB_ATTACHMENTS . ' ' . attach_mod_sql_build_array('INSERT', $sql_ary);
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not store Attachment.<br />Your ' . $message_type . ' has been stored');
|
||||
}
|
||||
}
|
||||
|
@ -847,7 +847,7 @@ class Attach
|
|||
// Remove non-latin characters
|
||||
$this->attach_filename = preg_replace('#([\xC2\xC3])([\x80-\xBF])#', 'chr(ord(\'$1\')<<6&0xC0|ord(\'$2\')&0x3F)', $this->attach_filename);
|
||||
$this->attach_filename = rawurlencode($this->attach_filename);
|
||||
$this->attach_filename = preg_replace("/(%[0-9A-F]{1,2})/i", '', $this->attach_filename);
|
||||
$this->attach_filename = preg_replace('/(%[0-9A-F]{1,2})/i', '', $this->attach_filename);
|
||||
$this->attach_filename = trim($this->attach_filename . time());
|
||||
}
|
||||
$this->attach_filename = str_replace(['&', '&', ' '], '_', $this->attach_filename);
|
||||
|
|
|
@ -330,7 +330,7 @@ class BBCode
|
|||
// Remove our padding..
|
||||
$ret = substr(substr($ret, 0, -1), 1);
|
||||
|
||||
return ($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ class File extends Common
|
|||
$this->debug('start');
|
||||
|
||||
if (file_exists($filename)) {
|
||||
require($filename);
|
||||
require $filename;
|
||||
}
|
||||
|
||||
$this->debug('stop');
|
||||
|
@ -91,7 +91,7 @@ class File extends Common
|
|||
if (is_dir($this->dir)) {
|
||||
if ($dh = opendir($this->dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$filename = $this->dir . $file;
|
||||
|
||||
unlink($filename);
|
||||
|
@ -112,10 +112,10 @@ class File extends Common
|
|||
if (is_dir($this->dir)) {
|
||||
if ($dh = opendir($this->dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$filename = $this->dir . $file;
|
||||
|
||||
require($filename);
|
||||
require $filename;
|
||||
|
||||
if (!empty($filecache['expire']) && ($filecache['expire'] < $expire_time)) {
|
||||
unlink($filename);
|
||||
|
|
|
@ -36,7 +36,7 @@ class Memcache extends Common
|
|||
|
||||
public function connect()
|
||||
{
|
||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
|
||||
$connect_type = $this->cfg['pconnect'] ? 'pconnect' : 'connect';
|
||||
|
||||
$this->cur_query = $connect_type . ' ' . $this->cfg['host'] . ':' . $this->cfg['port'];
|
||||
$this->debug('start');
|
||||
|
@ -69,7 +69,7 @@ class Memcache extends Common
|
|||
$this->cur_query = null;
|
||||
$this->num_queries++;
|
||||
|
||||
return ($this->connected) ? $this->memcache->get($this->prefix . $name) : false;
|
||||
return $this->connected ? $this->memcache->get($this->prefix . $name) : false;
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 0)
|
||||
|
@ -84,7 +84,7 @@ class Memcache extends Common
|
|||
$this->cur_query = null;
|
||||
$this->num_queries++;
|
||||
|
||||
return ($this->connected) ? $this->memcache->set($this->prefix . $name, $value, false, $ttl) : false;
|
||||
return $this->connected ? $this->memcache->set($this->prefix . $name, $value, false, $ttl) : false;
|
||||
}
|
||||
|
||||
public function rm($name = '')
|
||||
|
@ -100,10 +100,10 @@ class Memcache extends Common
|
|||
$this->cur_query = null;
|
||||
$this->num_queries++;
|
||||
|
||||
return ($this->connected) ? $this->memcache->delete($this->prefix . $name, 0) : false;
|
||||
return $this->connected ? $this->memcache->delete($this->prefix . $name, 0) : false;
|
||||
}
|
||||
|
||||
return ($this->connected) ? $this->memcache->flush() : false;
|
||||
return $this->connected ? $this->memcache->flush() : false;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
|
|
|
@ -63,7 +63,7 @@ class Redis extends Common
|
|||
$this->cur_query = null;
|
||||
$this->num_queries++;
|
||||
|
||||
return ($this->connected) ? unserialize($this->redis->get($this->prefix . $name)) : false;
|
||||
return $this->connected ? unserialize($this->redis->get($this->prefix . $name)) : false;
|
||||
}
|
||||
|
||||
public function set($name, $value, $ttl = 0)
|
||||
|
@ -103,10 +103,10 @@ class Redis extends Common
|
|||
$this->cur_query = null;
|
||||
$this->num_queries++;
|
||||
|
||||
return ($this->connected) ? $this->redis->del($this->prefix . $name) : false;
|
||||
return $this->connected ? $this->redis->del($this->prefix . $name) : false;
|
||||
}
|
||||
|
||||
return ($this->connected) ? $this->redis->flushDB() : false;
|
||||
return $this->connected ? $this->redis->flushDB() : false;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
|
|
|
@ -55,12 +55,12 @@ class Sqlite extends Common
|
|||
array_deep($name_sql, 'SQLite3::escapeString');
|
||||
|
||||
// get available items
|
||||
$rowset = $this->db->fetch_rowset("
|
||||
$rowset = $this->db->fetch_rowset('
|
||||
SELECT cache_name, cache_value
|
||||
FROM " . $this->cfg['table_name'] . "
|
||||
WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . "
|
||||
LIMIT " . count($name) . "
|
||||
");
|
||||
FROM ' . $this->cfg['table_name'] . "
|
||||
WHERE cache_name IN('$this->prefix_sql" . implode("','$this->prefix_sql", $name_sql) . "') AND cache_expire_time > " . TIMENOW . '
|
||||
LIMIT ' . count($name) . '
|
||||
');
|
||||
|
||||
$this->db->debug('start', 'unserialize()');
|
||||
foreach ($rowset as $row) {
|
||||
|
@ -90,7 +90,7 @@ class Sqlite extends Common
|
|||
$expire = TIMENOW + $ttl;
|
||||
$value_sql = SQLite3::escapeString(serialize($value));
|
||||
|
||||
$result = $this->db->query("REPLACE INTO " . $this->cfg['table_name'] . " (cache_name, cache_expire_time, cache_value) VALUES ('$name_sql', $expire, '$value_sql')");
|
||||
$result = $this->db->query('REPLACE INTO ' . $this->cfg['table_name'] . " (cache_name, cache_expire_time, cache_value) VALUES ('$name_sql', $expire, '$value_sql')");
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
|
@ -98,16 +98,16 @@ class Sqlite extends Common
|
|||
{
|
||||
if ($name) {
|
||||
$this->db->shard($this->prefix . $name);
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
} else {
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name']);
|
||||
}
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
{
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
return $result ? $this->db->changes() : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,16 +164,16 @@ class SqliteCommon extends Common
|
|||
{
|
||||
if ($name) {
|
||||
$this->db->shard($this->prefix . $name);
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
} else {
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name']);
|
||||
}
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
{
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
return $result ? sqlite_changes($this->db->dbh) : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ class Xcache extends Common
|
|||
|
||||
xcache_clear_cache(XC_TYPE_PHP, 0);
|
||||
xcache_clear_cache(XC_TYPE_VAR, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
public function is_installed()
|
||||
|
|
|
@ -110,23 +110,23 @@ class User
|
|||
if ($session_id || !$this->sessiondata['uk']) {
|
||||
$SQL = OLD_DB()->get_empty_sql_array();
|
||||
|
||||
$SQL['SELECT'][] = "u.*, s.*";
|
||||
$SQL['SELECT'][] = 'u.*, s.*';
|
||||
|
||||
$SQL['FROM'][] = BB_SESSIONS . " s";
|
||||
$SQL['INNER JOIN'][] = BB_USERS . " u ON(u.user_id = s.session_user_id)";
|
||||
$SQL['FROM'][] = BB_SESSIONS . ' s';
|
||||
$SQL['INNER JOIN'][] = BB_USERS . ' u ON(u.user_id = s.session_user_id)';
|
||||
|
||||
if ($session_id) {
|
||||
$SQL['WHERE'][] = "s.session_id = '$session_id'";
|
||||
|
||||
if (config('tp.torhelp_enabled')) {
|
||||
$SQL['SELECT'][] = "th.topic_id_csv AS torhelp";
|
||||
$SQL['LEFT JOIN'][] = BB_BT_TORHELP . " th ON(u.user_id = th.user_id)";
|
||||
$SQL['SELECT'][] = 'th.topic_id_csv AS torhelp';
|
||||
$SQL['LEFT JOIN'][] = BB_BT_TORHELP . ' th ON(u.user_id = th.user_id)';
|
||||
}
|
||||
|
||||
$userdata_cache_id = $session_id;
|
||||
} else {
|
||||
$SQL['WHERE'][] = "s.session_ip = '" . USER_IP . "'";
|
||||
$SQL['WHERE'][] = "s.session_user_id = " . GUEST_UID;
|
||||
$SQL['WHERE'][] = 's.session_user_id = ' . GUEST_UID;
|
||||
|
||||
$userdata_cache_id = USER_IP;
|
||||
}
|
||||
|
@ -159,9 +159,9 @@ class User
|
|||
|
||||
// Only update session a minute or so after last update
|
||||
if ($update_sessions_table) {
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_SESSIONS . " SET
|
||||
session_time = " . TIMENOW . "
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_SESSIONS . ' SET
|
||||
session_time = ' . TIMENOW . "
|
||||
WHERE session_id = '$session_id'
|
||||
LIMIT 1
|
||||
");
|
||||
|
@ -234,7 +234,7 @@ class User
|
|||
$where_sql = 'ban_ip = ' . USER_IP;
|
||||
$where_sql .= $login ? " OR ban_userid = $user_id" : '';
|
||||
|
||||
$sql = "SELECT ban_id FROM " . BB_BANLIST . " WHERE $where_sql LIMIT 1";
|
||||
$sql = 'SELECT ban_id FROM ' . BB_BANLIST . " WHERE $where_sql LIMIT 1";
|
||||
|
||||
if (OLD_DB()->fetch_row($sql)) {
|
||||
header('Location: https://torrentpier.com/banned/');
|
||||
|
@ -254,7 +254,7 @@ class User
|
|||
'session_logged_in' => (int)$login,
|
||||
'session_admin' => (int)$mod_admin_session,
|
||||
]);
|
||||
$sql = "INSERT INTO " . BB_SESSIONS . $args;
|
||||
$sql = 'INSERT INTO ' . BB_SESSIONS . $args;
|
||||
|
||||
if (OLD_DB()->query($sql)) {
|
||||
break;
|
||||
|
@ -275,9 +275,9 @@ class User
|
|||
}
|
||||
|
||||
if ($last_visit != $this->data['user_lastvisit']) {
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USERS . " SET
|
||||
user_session_time = " . TIMENOW . ",
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USERS . ' SET
|
||||
user_session_time = ' . TIMENOW . ",
|
||||
user_lastvisit = $last_visit,
|
||||
user_last_ip = '" . USER_IP . "',
|
||||
user_reg_ip = IF(user_reg_ip = '', '" . USER_IP . "', user_reg_ip)
|
||||
|
@ -326,17 +326,17 @@ class User
|
|||
*/
|
||||
public function session_end($update_lastvisit = false, $set_cookie = true)
|
||||
{
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_SESSIONS . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_SESSIONS . "
|
||||
WHERE session_id = '{$this->data['session_id']}'
|
||||
");
|
||||
|
||||
if (!IS_GUEST) {
|
||||
if ($update_lastvisit) {
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USERS . " SET
|
||||
user_session_time = " . TIMENOW . ",
|
||||
user_lastvisit = " . TIMENOW . ",
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USERS . ' SET
|
||||
user_session_time = ' . TIMENOW . ',
|
||||
user_lastvisit = ' . TIMENOW . ",
|
||||
user_last_ip = '" . USER_IP . "',
|
||||
user_reg_ip = IF(user_reg_ip = '', '" . USER_IP . "', user_reg_ip)
|
||||
WHERE user_id = {$this->data['user_id']}
|
||||
|
@ -347,8 +347,8 @@ class User
|
|||
if (isset($_REQUEST['reset_autologin'])) {
|
||||
$this->create_autologin_id($this->data, false);
|
||||
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_SESSIONS . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_SESSIONS . "
|
||||
WHERE session_user_id = '{$this->data['user_id']}'
|
||||
");
|
||||
}
|
||||
|
@ -376,15 +376,15 @@ class User
|
|||
$username_sql = str_replace("\\'", "''", $username);
|
||||
$password_sql = md5(md5($password));
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT *
|
||||
FROM " . BB_USERS . "
|
||||
FROM ' . BB_USERS . "
|
||||
WHERE username = '$username_sql'
|
||||
AND user_password = '$password_sql'
|
||||
AND user_active = 1
|
||||
AND user_id != " . GUEST_UID . "
|
||||
AND user_id != " . GUEST_UID . '
|
||||
LIMIT 1
|
||||
";
|
||||
';
|
||||
|
||||
if ($userdata = OLD_DB()->fetch_row($sql)) {
|
||||
if (!$userdata['username'] || !$userdata['user_password'] || $userdata['user_id'] == GUEST_UID || md5(md5($password)) !== $userdata['user_password'] || !$userdata['user_active']) {
|
||||
|
@ -393,10 +393,10 @@ class User
|
|||
|
||||
// Start mod/admin session
|
||||
if ($mod_admin_login) {
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_SESSIONS . " SET
|
||||
session_admin = " . $this->data['user_level'] . "
|
||||
WHERE session_user_id = " . $this->data['user_id'] . "
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_SESSIONS . ' SET
|
||||
session_admin = ' . $this->data['user_level'] . '
|
||||
WHERE session_user_id = ' . $this->data['user_id'] . "
|
||||
AND session_id = '" . $this->data['session_id'] . "'
|
||||
");
|
||||
$this->data['session_admin'] = $this->data['user_level'];
|
||||
|
@ -407,16 +407,16 @@ class User
|
|||
|
||||
if ($new_session_userdata = $this->session_create($userdata, false)) {
|
||||
// Removing guest sessions from this IP
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_SESSIONS . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_SESSIONS . "
|
||||
WHERE session_ip = '" . USER_IP . "'
|
||||
AND session_user_id = " . GUEST_UID . "
|
||||
");
|
||||
AND session_user_id = " . GUEST_UID . '
|
||||
');
|
||||
|
||||
return $new_session_userdata;
|
||||
} else {
|
||||
trigger_error("Could not start session : login", E_USER_ERROR);
|
||||
}
|
||||
|
||||
trigger_error('Could not start session : login', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ class User
|
|||
}
|
||||
} else {
|
||||
$c_sdata_resv = !empty($_COOKIE[COOKIE_DATA]) ? $_COOKIE[COOKIE_DATA] : null;
|
||||
$c_sdata_curr = ($this->sessiondata) ? serialize($this->sessiondata) : '';
|
||||
$c_sdata_curr = $this->sessiondata ? serialize($this->sessiondata) : '';
|
||||
|
||||
if ($c_sdata_curr !== $c_sdata_resv) {
|
||||
bb_setcookie(COOKIE_DATA, $c_sdata_curr, COOKIE_PERSIST, true);
|
||||
|
@ -517,14 +517,14 @@ class User
|
|||
*/
|
||||
public function create_autologin_id($userdata, $create_new = true)
|
||||
{
|
||||
$autologin_id = ($create_new) ? make_rand_str(LOGIN_KEY_LENGTH) : '';
|
||||
$autologin_id = $create_new ? make_rand_str(LOGIN_KEY_LENGTH) : '';
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USERS . " SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USERS . " SET
|
||||
autologin_id = '$autologin_id'
|
||||
WHERE user_id = " . (int)$userdata['user_id'] . "
|
||||
WHERE user_id = " . (int)$userdata['user_id'] . '
|
||||
LIMIT 1
|
||||
");
|
||||
');
|
||||
|
||||
return $autologin_id;
|
||||
}
|
||||
|
@ -585,9 +585,9 @@ class User
|
|||
{
|
||||
if ($type === 'all_forums') {
|
||||
// Update session time
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_SESSIONS . " SET
|
||||
session_time = " . TIMENOW . "
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_SESSIONS . ' SET
|
||||
session_time = ' . TIMENOW . "
|
||||
WHERE session_id = '{$this->data['session_id']}'
|
||||
LIMIT 1
|
||||
");
|
||||
|
|
|
@ -54,7 +54,7 @@ class File extends Common
|
|||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file != "." && $file != "..") {
|
||||
if ($file != '.' && $file != '..') {
|
||||
$filename = $dir . $file;
|
||||
|
||||
unlink($filename);
|
||||
|
@ -82,7 +82,7 @@ class File extends Common
|
|||
$this->num_queries++;
|
||||
|
||||
if (file_exists($filename)) {
|
||||
require($filename);
|
||||
require $filename;
|
||||
|
||||
$this->data[$item] = $filecache;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class Memcache extends Common
|
|||
|
||||
public function connect()
|
||||
{
|
||||
$connect_type = ($this->cfg['pconnect']) ? 'pconnect' : 'connect';
|
||||
$connect_type = $this->cfg['pconnect'] ? 'pconnect' : 'connect';
|
||||
|
||||
$this->cur_query = $connect_type . ' ' . $this->cfg['host'] . ':' . $this->cfg['port'];
|
||||
$this->debug('start');
|
||||
|
|
|
@ -47,14 +47,14 @@ class Sqlite extends Common
|
|||
$ds_title = SQLite3::escapeString($this->prefix . $item_name);
|
||||
$ds_data = SQLite3::escapeString(serialize($item_data));
|
||||
|
||||
$result = $this->db->query("REPLACE INTO " . $this->cfg['table_name'] . " (ds_title, ds_data) VALUES ('$ds_title', '$ds_data')");
|
||||
$result = $this->db->query('REPLACE INTO ' . $this->cfg['table_name'] . " (ds_title, ds_data) VALUES ('$ds_title', '$ds_data')");
|
||||
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function clean()
|
||||
{
|
||||
$this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||
$this->db->query('DELETE FROM ' . $this->cfg['table_name']);
|
||||
}
|
||||
|
||||
public function _fetch_from_store()
|
||||
|
@ -69,9 +69,9 @@ class Sqlite extends Common
|
|||
array_deep($items, 'SQLite3::escapeString');
|
||||
$items_list = $prefix_sql . implode("','$prefix_sql", $items);
|
||||
|
||||
$rowset = $this->db->fetch_rowset("SELECT ds_title, ds_data FROM " . $this->cfg['table_name'] . " WHERE ds_title IN ('$items_list')");
|
||||
$rowset = $this->db->fetch_rowset('SELECT ds_title, ds_data FROM ' . $this->cfg['table_name'] . " WHERE ds_title IN ('$items_list')");
|
||||
|
||||
$this->db->debug('start', "unserialize()");
|
||||
$this->db->debug('start', 'unserialize()');
|
||||
foreach ($rowset as $row) {
|
||||
$this->data[substr($row['ds_title'], $prefix_len)] = unserialize($row['ds_data']);
|
||||
}
|
||||
|
|
|
@ -164,16 +164,16 @@ class SqliteCommon extends Common
|
|||
{
|
||||
if ($name) {
|
||||
$this->db->shard($this->prefix . $name);
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_name = '" . SQLite3::escapeString($this->prefix . $name) . "'");
|
||||
} else {
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name']);
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name']);
|
||||
}
|
||||
return (bool)$result;
|
||||
}
|
||||
|
||||
public function gc($expire_time = TIMENOW)
|
||||
{
|
||||
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
$result = $this->db->query('DELETE FROM ' . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
|
||||
return $result ? sqlite_changes($this->db->dbh) : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class LogAction
|
|||
];
|
||||
$sql_args = OLD_DB()->build_array('INSERT', $sql_ary);
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_LOG . " $sql_args");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_LOG . " $sql_args");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,9 +74,9 @@ class Poll
|
|||
}
|
||||
$sql_args = OLD_DB()->build_array('MULTI_INSERT', $sql_ary);
|
||||
|
||||
OLD_DB()->query("REPLACE INTO " . BB_POLL_VOTES . $sql_args);
|
||||
OLD_DB()->query('REPLACE INTO ' . BB_POLL_VOTES . $sql_args);
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_vote = 1 WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET topic_vote = 1 WHERE topic_id = $topic_id");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,7 +86,7 @@ class Poll
|
|||
*/
|
||||
public function delete_poll($topic_id)
|
||||
{
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_vote = 0 WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET topic_vote = 0 WHERE topic_id = $topic_id");
|
||||
$this->delete_votes_data($topic_id);
|
||||
}
|
||||
|
||||
|
@ -97,8 +97,8 @@ class Poll
|
|||
*/
|
||||
public function delete_votes_data($topic_id)
|
||||
{
|
||||
OLD_DB()->query("DELETE FROM " . BB_POLL_VOTES . " WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query("DELETE FROM " . BB_POLL_USERS . " WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_POLL_VOTES . " WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_POLL_USERS . " WHERE topic_id = $topic_id");
|
||||
OLD_CACHE('bb_poll_data')->rm("poll_$topic_id");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class Sitemap
|
|||
$not_forums_id = $forums['not_auth_forums']['guest_view'];
|
||||
$ignore_forum_sql = $not_forums_id ? "WHERE forum_id NOT IN($not_forums_id)" : '';
|
||||
|
||||
$sql = OLD_DB()->sql_query("SELECT forum_id, forum_name FROM " . BB_FORUMS . " " . $ignore_forum_sql . " ORDER BY forum_id ASC");
|
||||
$sql = OLD_DB()->sql_query('SELECT forum_id, forum_name FROM ' . BB_FORUMS . ' ' . $ignore_forum_sql . ' ORDER BY forum_id ASC');
|
||||
|
||||
while ($row = OLD_DB()->sql_fetchrow($sql)) {
|
||||
$forumUrls[] = [
|
||||
|
@ -67,7 +67,7 @@ class Sitemap
|
|||
$not_forums_id = $forums['not_auth_forums']['guest_view'];
|
||||
$ignore_forum_sql = $not_forums_id ? "WHERE forum_id NOT IN($not_forums_id)" : '';
|
||||
|
||||
$sql = OLD_DB()->sql_query("SELECT topic_id, topic_title, topic_time FROM " . BB_TOPICS . " " . $ignore_forum_sql . " ORDER BY topic_time ASC");
|
||||
$sql = OLD_DB()->sql_query('SELECT topic_id, topic_title, topic_time FROM ' . BB_TOPICS . ' ' . $ignore_forum_sql . ' ORDER BY topic_time ASC');
|
||||
|
||||
while ($row = OLD_DB()->sql_fetchrow($sql)) {
|
||||
$topicUrls[] = [
|
||||
|
|
|
@ -394,7 +394,7 @@ class SqlDb
|
|||
case is_int($v):
|
||||
return "$v";
|
||||
case is_bool($v):
|
||||
return ($v) ? '1' : '0';
|
||||
return $v ? '1' : '0';
|
||||
case is_float($v):
|
||||
return "'$v'";
|
||||
case null === $v:
|
||||
|
@ -514,31 +514,31 @@ class SqlDb
|
|||
foreach ($sql_ary as $clause => $ary) {
|
||||
switch ($clause) {
|
||||
case 'SELECT':
|
||||
$sql .= ($ary) ? ' SELECT ' . implode(' ', $sql_ary['select_options']) . ' ' . implode(', ', $ary) : '';
|
||||
$sql .= $ary ? ' SELECT ' . implode(' ', $sql_ary['select_options']) . ' ' . implode(', ', $ary) : '';
|
||||
break;
|
||||
case 'FROM':
|
||||
$sql .= ($ary) ? ' FROM ' . implode(', ', $ary) : '';
|
||||
$sql .= $ary ? ' FROM ' . implode(', ', $ary) : '';
|
||||
break;
|
||||
case 'INNER JOIN':
|
||||
$sql .= ($ary) ? ' INNER JOIN ' . implode(' INNER JOIN ', $ary) : '';
|
||||
$sql .= $ary ? ' INNER JOIN ' . implode(' INNER JOIN ', $ary) : '';
|
||||
break;
|
||||
case 'LEFT JOIN':
|
||||
$sql .= ($ary) ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $ary) : '';
|
||||
$sql .= $ary ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $ary) : '';
|
||||
break;
|
||||
case 'WHERE':
|
||||
$sql .= ($ary) ? ' WHERE ' . implode(' AND ', $ary) : '';
|
||||
$sql .= $ary ? ' WHERE ' . implode(' AND ', $ary) : '';
|
||||
break;
|
||||
case 'GROUP BY':
|
||||
$sql .= ($ary) ? ' GROUP BY ' . implode(', ', $ary) : '';
|
||||
$sql .= $ary ? ' GROUP BY ' . implode(', ', $ary) : '';
|
||||
break;
|
||||
case 'HAVING':
|
||||
$sql .= ($ary) ? ' HAVING ' . implode(' AND ', $ary) : '';
|
||||
$sql .= $ary ? ' HAVING ' . implode(' AND ', $ary) : '';
|
||||
break;
|
||||
case 'ORDER BY':
|
||||
$sql .= ($ary) ? ' ORDER BY ' . implode(', ', $ary) : '';
|
||||
$sql .= $ary ? ' ORDER BY ' . implode(', ', $ary) : '';
|
||||
break;
|
||||
case 'LIMIT':
|
||||
$sql .= ($ary) ? ' LIMIT ' . implode(', ', $ary) : '';
|
||||
$sql .= $ary ? ' LIMIT ' . implode(', ', $ary) : '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ class SqlDb
|
|||
|
||||
if (!empty($this->shutdown['post_html'])) {
|
||||
$post_html_sql = $this->build_array('MULTI_INSERT', $this->shutdown['post_html']);
|
||||
$this->query("REPLACE INTO " . BB_POSTS_HTML . " $post_html_sql");
|
||||
$this->query('REPLACE INTO ' . BB_POSTS_HTML . " $post_html_sql");
|
||||
}
|
||||
|
||||
if (!empty($this->shutdown['__sql'])) {
|
||||
|
@ -642,7 +642,7 @@ class SqlDb
|
|||
*/
|
||||
public function unlock()
|
||||
{
|
||||
if ($this->locked && $this->sql_query("UNLOCK TABLES")) {
|
||||
if ($this->locked && $this->sql_query('UNLOCK TABLES')) {
|
||||
$this->locked = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ switch ($mode) {
|
|||
$this->ajax_die('Invalid mode');
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET avatar_ext_id = $new_ext_id WHERE user_id = $user_id");
|
||||
|
||||
cache_rm_user_sessions($user_id);
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ if (config('tp.tor_comment')) {
|
|||
$comment = (string)$this->request['comment'];
|
||||
}
|
||||
|
||||
$tor = OLD_DB()->fetch_row("
|
||||
$tor = OLD_DB()->fetch_row('
|
||||
SELECT
|
||||
tor.poster_id, tor.forum_id, tor.topic_id, tor.tor_status, tor.checked_time, tor.checked_user_id, f.cat_id, t.topic_title
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = tor.forum_id)
|
||||
INNER JOIN " . BB_TOPICS . " t ON(t.topic_id = tor.topic_id)
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
INNER JOIN ' . BB_FORUMS . ' f ON(f.forum_id = tor.forum_id)
|
||||
INNER JOIN ' . BB_TOPICS . " t ON(t.topic_id = tor.topic_id)
|
||||
WHERE tor.attach_id = $attach_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
@ -68,7 +68,7 @@ switch ($mode) {
|
|||
if (!IS_ADMIN) {
|
||||
$this->verify_mod_rights($tor['forum_id']);
|
||||
}
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE topic_id = {$tor['topic_id']}");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . ' SET topic_status = ' . TOPIC_UNLOCKED . " WHERE topic_id = {$tor['topic_id']}");
|
||||
} else {
|
||||
$this->verify_mod_rights($tor['forum_id']);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ switch ($mode) {
|
|||
if ($tor['tor_status'] != TOR_NOT_APPROVED && $tor['checked_user_id'] != $userdata['user_id'] && $tor['checked_time'] + 2 * 3600 > TIMENOW) {
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$msg = trans('messages.TOR_STATUS_OF') . ' ' . trans('messages.TOR_STATUS_NAME.' . $tor['tor_status']) . "\n\n";
|
||||
$msg .= ($username = get_username($tor['checked_user_id'])) ? trans('messages.TOR_STATUS_CHANGED') . html_entity_decode($username) . ", " . delta_time($tor['checked_time']) . trans('messages.TOR_BACK') . "\n\n" : "";
|
||||
$msg .= ($username = get_username($tor['checked_user_id'])) ? trans('messages.TOR_STATUS_CHANGED') . html_entity_decode($username) . ', ' . delta_time($tor['checked_time']) . trans('messages.TOR_BACK') . "\n\n" : '';
|
||||
$msg .= trans('messages.PROCEED') . '?';
|
||||
$this->prompt_for_confirm($msg);
|
||||
}
|
||||
|
|
|
@ -22,18 +22,18 @@ if (!isset($this->request['type'])) {
|
|||
$attach_id = (int)$this->request['attach_id'];
|
||||
$type = (string)$this->request['type'];
|
||||
|
||||
$torrent = OLD_DB()->fetch_row("
|
||||
$torrent = OLD_DB()->fetch_row('
|
||||
SELECT
|
||||
a.post_id, d.physical_filename, d.extension, d.tracker_status,
|
||||
t.topic_first_post_id,
|
||||
p.poster_id, p.topic_id, p.forum_id,
|
||||
f.allow_reg_tracker
|
||||
FROM
|
||||
" . BB_ATTACHMENTS . " a,
|
||||
" . BB_ATTACHMENTS_DESC . " d,
|
||||
" . BB_POSTS . " p,
|
||||
" . BB_TOPICS . " t,
|
||||
" . BB_FORUMS . " f
|
||||
' . BB_ATTACHMENTS . ' a,
|
||||
' . BB_ATTACHMENTS_DESC . ' d,
|
||||
' . BB_POSTS . ' p,
|
||||
' . BB_TOPICS . ' t,
|
||||
' . BB_FORUMS . " f
|
||||
WHERE
|
||||
a.attach_id = $attach_id
|
||||
AND d.attach_id = $attach_id
|
||||
|
|
|
@ -30,7 +30,7 @@ foreach ($bf['user_opt'] as $opt_name => $opt_bit) {
|
|||
}
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_opt = {$u_data['user_opt']} WHERE user_id = $user_id");
|
||||
|
||||
// Удаляем данные из кеша
|
||||
cache_rm_user_sessions($user_id);
|
||||
|
|
|
@ -24,11 +24,11 @@ if ($rank_id != 0 && !isset($ranks[$rank_id])) {
|
|||
$this->ajax_die("invalid rank_id: $rank_id");
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id");
|
||||
|
||||
cache_rm_user_sessions($user_id);
|
||||
|
||||
$user_rank = ($rank_id) ? '<span class="' . $ranks[$rank_id]['rank_style'] . '">' . $ranks[$rank_id]['rank_title'] . '</span>' : '';
|
||||
$user_rank = $rank_id ? '<span class="' . $ranks[$rank_id]['rank_style'] . '">' . $ranks[$rank_id]['rank_title'] . '</span>' : '';
|
||||
|
||||
$this->response['html'] = ($rank_id) ? trans('messages.AWARDED_RANK') . "<b> $user_rank </b>" : trans('messages.SHOT_RANK');
|
||||
$this->response['rank_name'] = ($rank_id) ? $user_rank : trans('messages.USER');
|
||||
$this->response['html'] = $rank_id ? trans('messages.AWARDED_RANK') . "<b> $user_rank </b>" : trans('messages.SHOT_RANK');
|
||||
$this->response['rank_name'] = $rank_id ? $user_rank : trans('messages.USER');
|
||||
|
|
|
@ -20,7 +20,7 @@ if (!$mode = (string)$this->request['mode']) {
|
|||
$this->ajax_die('No mode specified');
|
||||
}
|
||||
|
||||
$value = $this->request['value'] = (string)(isset($this->request['value'])) ? $this->request['value'] : 0;
|
||||
$value = $this->request['value'] = (string)isset($this->request['value']) ? $this->request['value'] : 0;
|
||||
|
||||
if (!IS_ADMIN && $userdata['user_id'] != $group_info['group_moderator']) {
|
||||
$this->ajax_die(trans('messages.ONLY_FOR_MOD'));
|
||||
|
@ -54,4 +54,4 @@ switch ($mode) {
|
|||
}
|
||||
|
||||
$value_sql = OLD_DB()->escape($value, true);
|
||||
OLD_DB()->query("UPDATE " . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_GROUPS . " SET $mode = $value_sql WHERE group_id = $group_id");
|
||||
|
|
|
@ -19,7 +19,7 @@ if (!$field = (string)$this->request['field']) {
|
|||
}
|
||||
|
||||
$table = BB_USERS;
|
||||
$value = $this->request['value'] = (string)(isset($this->request['value'])) ? $this->request['value'] : 0;
|
||||
$value = $this->request['value'] = (string)isset($this->request['value']) ? $this->request['value'] : 0;
|
||||
|
||||
switch ($field) {
|
||||
case 'username':
|
||||
|
@ -93,7 +93,7 @@ switch ($field) {
|
|||
break;
|
||||
|
||||
case 'user_twitter':
|
||||
if ($value && !preg_match("#^[a-zA-Z0-9_]{1,15}$#", $value)) {
|
||||
if ($value && !preg_match('#^[a-zA-Z0-9_]{1,15}$#', $value)) {
|
||||
$this->ajax_die(trans('messages.TWITTER_ERROR'));
|
||||
}
|
||||
$this->response['new_value'] = $this->request['value'];
|
||||
|
|
|
@ -23,17 +23,17 @@ if (!$mode = (string)$this->request['mode']) {
|
|||
|
||||
switch ($mode) {
|
||||
case 'get_group_list':
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT ug.user_pending, g.group_id, g.group_type, g.group_name, g.group_moderator, self.user_id AS can_view
|
||||
FROM " . BB_USER_GROUP . " ug
|
||||
INNER JOIN " . BB_GROUPS . " g ON(g.group_id = ug.group_id AND g.group_single_user = 0)
|
||||
LEFT JOIN " . BB_USER_GROUP . " self ON(self.group_id = g.group_id AND self.user_id = {$user->id} AND self.user_pending = 0)
|
||||
FROM ' . BB_USER_GROUP . ' ug
|
||||
INNER JOIN ' . BB_GROUPS . ' g ON(g.group_id = ug.group_id AND g.group_single_user = 0)
|
||||
LEFT JOIN ' . BB_USER_GROUP . " self ON(self.group_id = g.group_id AND self.user_id = {$user->id} AND self.user_pending = 0)
|
||||
WHERE ug.user_id = $user_id
|
||||
ORDER BY g.group_name
|
||||
";
|
||||
$html = array();
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$class = ($row['user_pending']) ? 'med' : 'med bold';
|
||||
$class = $row['user_pending'] ? 'med' : 'med bold';
|
||||
$class .= ($row['group_moderator'] == $user_id) ? ' colorMod' : '';
|
||||
$href = "group.php?g={$row['group_id']}";
|
||||
|
||||
|
|
|
@ -68,12 +68,12 @@ switch ($mode) {
|
|||
|
||||
if (isset($mod['mod_groups'][$forum_id])) {
|
||||
foreach ($mod['mod_groups'][$forum_id] as $group_id) {
|
||||
$moderators[] = '<a href="' . "group.php?" . POST_GROUPS_URL . "=" . $group_id . '">' . $mod['name_groups'][$group_id] . '</a>';
|
||||
$moderators[] = '<a href="' . 'group.php?' . POST_GROUPS_URL . '=' . $group_id . '">' . $mod['name_groups'][$group_id] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$html = ': ';
|
||||
$html .= ($moderators) ? implode(', ', $moderators) : trans('messages.NONE');
|
||||
$html .= $moderators ? implode(', ', $moderators) : trans('messages.NONE');
|
||||
unset($moderators, $mod);
|
||||
$datastore->rm('moderators');
|
||||
break;
|
||||
|
@ -88,7 +88,7 @@ switch ($mode) {
|
|||
}
|
||||
if ($tz != config('tp.board_timezone')) {
|
||||
// Set current user timezone
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id']);
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_timezone = $tz WHERE user_id = " . $userdata['user_id']);
|
||||
config(['tp.board_timezone' => $tz]);
|
||||
cache_rm_user_sessions($userdata['user_id']);
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ switch ($mode) {
|
|||
$btu = get_bt_userdata($user_id);
|
||||
$profiledata = get_userdata($user_id);
|
||||
|
||||
$speed_up = ($btu['speed_up']) ? humn_size($btu['speed_up']) . '/s' : '0 KB/s';
|
||||
$speed_down = ($btu['speed_down']) ? humn_size($btu['speed_down']) . '/s' : '0 KB/s';
|
||||
$speed_up = $btu['speed_up'] ? humn_size($btu['speed_up']) . '/s' : '0 KB/s';
|
||||
$speed_down = $btu['speed_down'] ? humn_size($btu['speed_down']) . '/s' : '0 KB/s';
|
||||
$user_ratio = ($btu['u_down_total'] > MIN_DL_FOR_RATIO) ? '<b class="gen">' . get_bt_ratio($btu) . '</b>' : trans('messages.IT_WILL_BE_DOWN') . ' <b>' . humn_size(MIN_DL_FOR_RATIO) . '</b>';
|
||||
|
||||
$html = '
|
||||
|
|
|
@ -47,7 +47,7 @@ switch ($mode) {
|
|||
}
|
||||
|
||||
if (IS_ADMIN) {
|
||||
$user_topics = OLD_DB()->fetch_rowset("SELECT topic_id FROM " . BB_TOPICS . " WHERE topic_poster = $user_id", 'topic_id');
|
||||
$user_topics = OLD_DB()->fetch_rowset('SELECT topic_id FROM ' . BB_TOPICS . " WHERE topic_poster = $user_id", 'topic_id');
|
||||
$deleted_topics = topic_delete($user_topics);
|
||||
$deleted_posts = post_delete('user', $user_id);
|
||||
|
||||
|
@ -83,7 +83,7 @@ switch ($mode) {
|
|||
$this->prompt_for_confirm(trans('messages.DEACTIVATE_CONFIRM'));
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_active = '1' WHERE user_id = " . $user_id);
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_active = '1' WHERE user_id = " . $user_id);
|
||||
|
||||
$this->response['info'] = trans('messages.USER_ACTIVATE_ON');
|
||||
|
||||
|
@ -98,7 +98,7 @@ switch ($mode) {
|
|||
$this->prompt_for_confirm(trans('messages.ACTIVATE_CONFIRM'));
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_active = '0' WHERE user_id = " . $user_id);
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_active = '0' WHERE user_id = " . $user_id);
|
||||
delete_user_sessions($user_id);
|
||||
|
||||
$this->response['info'] = trans('messages.USER_ACTIVATE_OFF');
|
||||
|
|
|
@ -25,7 +25,7 @@ switch ($mode) {
|
|||
$this->ajax_die(trans('messages.STATUS_DOES_EXIST') . $new_status);
|
||||
}
|
||||
|
||||
$topic_ids = OLD_DB()->fetch_rowset("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($topics)", 'attach_id');
|
||||
$topic_ids = OLD_DB()->fetch_rowset('SELECT attach_id FROM ' . BB_BT_TORRENTS . " WHERE topic_id IN($topics)", 'attach_id');
|
||||
|
||||
foreach ($topic_ids as $attach_id) {
|
||||
change_tor_status($attach_id, $status);
|
||||
|
@ -46,14 +46,14 @@ switch ($mode) {
|
|||
$this->ajax_die(trans('messages.DONT_MESSAGE_TITLE'));
|
||||
}
|
||||
|
||||
if (!$t_data = OLD_DB()->fetch_row("SELECT forum_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||
if (!$t_data = OLD_DB()->fetch_row('SELECT forum_id FROM ' . BB_TOPICS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||
$this->ajax_die(trans('messages.INVALID_TOPIC_ID_DB'));
|
||||
}
|
||||
$this->verify_mod_rights($t_data['forum_id']);
|
||||
|
||||
$topic_title_sql = OLD_DB()->escape($new_title);
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET topic_title = '$topic_title_sql' WHERE topic_id = $topic_id");
|
||||
|
||||
// Обновление кеша новостей на главной
|
||||
$news_forums = array_flip(explode(',', config('tp.latest_news_forum_id')));
|
||||
|
@ -80,13 +80,13 @@ switch ($mode) {
|
|||
$this->ajax_die(trans('messages.NO_USER_ID_SPECIFIED'));
|
||||
}
|
||||
|
||||
$reg_ip = OLD_DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " . BB_USERS . "
|
||||
$reg_ip = OLD_DB()->fetch_rowset('SELECT username, user_id, user_rank FROM ' . BB_USERS . "
|
||||
WHERE user_reg_ip = '{$profiledata['user_reg_ip']}'
|
||||
AND user_reg_ip != ''
|
||||
AND user_id != {$profiledata['user_id']}
|
||||
ORDER BY username ASC");
|
||||
|
||||
$last_ip = OLD_DB()->fetch_rowset("SELECT username, user_id, user_rank FROM " . BB_USERS . "
|
||||
$last_ip = OLD_DB()->fetch_rowset('SELECT username, user_id, user_rank FROM ' . BB_USERS . "
|
||||
WHERE user_last_ip = '{$profiledata['user_last_ip']}'
|
||||
AND user_last_ip != ''
|
||||
AND user_id != {$profiledata['user_id']}");
|
||||
|
|
|
@ -20,10 +20,10 @@ if (!$mc_text = prepare_message($mc_text)) {
|
|||
$this->ajax_die(trans('messages.EMPTY_MESSAGE'));
|
||||
}
|
||||
|
||||
$post = OLD_DB()->fetch_row("
|
||||
$post = OLD_DB()->fetch_row('
|
||||
SELECT
|
||||
p.post_id, p.poster_id
|
||||
FROM " . BB_POSTS . " p
|
||||
FROM ' . BB_POSTS . " p
|
||||
WHERE p.post_id = $post_id
|
||||
");
|
||||
if (!$post) {
|
||||
|
@ -31,12 +31,12 @@ if (!$post) {
|
|||
}
|
||||
|
||||
$data = array(
|
||||
'mc_comment' => ($mc_type) ? $mc_text : '',
|
||||
'mc_comment' => $mc_type ? $mc_text : '',
|
||||
'mc_type' => $mc_type,
|
||||
'mc_user_id' => ($mc_type) ? $userdata['user_id'] : 0,
|
||||
'mc_user_id' => $mc_type ? $userdata['user_id'] : 0,
|
||||
);
|
||||
$sql_args = OLD_DB()->build_array('UPDATE', $data);
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET $sql_args WHERE post_id = $post_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . " SET $sql_args WHERE post_id = $post_id");
|
||||
|
||||
if ($mc_type && $post['poster_id'] != $userdata['user_id']) {
|
||||
$subject = sprintf(trans('messages.MC_COMMENT_PM_SUBJECT'), trans('messages.MC_COMMENT.' . $mc_type . '.type'));
|
||||
|
|
|
@ -18,8 +18,8 @@ if (!isset($this->request['type'])) {
|
|||
}
|
||||
if (isset($this->request['post_id'])) {
|
||||
$post_id = (int)$this->request['post_id'];
|
||||
$post = OLD_DB()->fetch_row("SELECT t.*, f.*, p.*, pt.post_text
|
||||
FROM " . BB_TOPICS . " t, " . BB_FORUMS . " f, " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
|
||||
$post = OLD_DB()->fetch_row('SELECT t.*, f.*, p.*, pt.post_text
|
||||
FROM ' . BB_TOPICS . ' t, ' . BB_FORUMS . ' f, ' . BB_POSTS . ' p, ' . BB_POSTS_TEXT . " pt
|
||||
WHERE p.post_id = $post_id
|
||||
AND t.topic_id = p.topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
|
@ -35,8 +35,8 @@ if (isset($this->request['post_id'])) {
|
|||
}
|
||||
} elseif (isset($this->request['topic_id'])) {
|
||||
$topic_id = (int)$this->request['topic_id'];
|
||||
$post = OLD_DB()->fetch_row("SELECT t.*, f.*
|
||||
FROM " . BB_TOPICS . " t, " . BB_FORUMS . " f
|
||||
$post = OLD_DB()->fetch_row('SELECT t.*, f.*
|
||||
FROM ' . BB_TOPICS . ' t, ' . BB_FORUMS . " f
|
||||
WHERE t.topic_id = $topic_id
|
||||
AND f.forum_id = t.forum_id
|
||||
LIMIT 1");
|
||||
|
@ -80,7 +80,7 @@ switch ($this->request['type']) {
|
|||
}
|
||||
|
||||
$quote_username = ($post['post_username'] != '') ? $post['post_username'] : get_username($post['poster_id']);
|
||||
$message = "[quote=\"" . $quote_username . "\"][qpost=" . $post['post_id'] . "]" . $post['post_text'] . "[/quote]\r";
|
||||
$message = '[quote="' . $quote_username . '"][qpost=' . $post['post_id'] . ']' . $post['post_text'] . "[/quote]\r";
|
||||
|
||||
// hide user passkey
|
||||
$message = preg_replace('#(?<=\?uk=)[a-zA-Z0-9]{10}(?=&)#', 'passkey', $message);
|
||||
|
@ -92,7 +92,7 @@ switch ($this->request['type']) {
|
|||
}
|
||||
|
||||
if ($post['post_id'] == $post['topic_first_post_id']) {
|
||||
$message = "[quote]" . $post['topic_title'] . "[/quote]\r";
|
||||
$message = '[quote]' . $post['topic_title'] . "[/quote]\r";
|
||||
}
|
||||
if (mb_strlen($message, 'UTF-8') > 1000) {
|
||||
$this->response['redirect'] = make_url(POSTING_URL . '?mode=quote&p=' . $post_id);
|
||||
|
@ -135,9 +135,9 @@ switch ($this->request['type']) {
|
|||
$this->ajax_die(sprintf(trans('messages.MAX_SMILIES_PER_POST'), config('tp.max_smilies')));
|
||||
}
|
||||
}
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS_TEXT . " SET post_text = '" . OLD_DB()->escape($text) . "' WHERE post_id = $post_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS_TEXT . " SET post_text = '" . OLD_DB()->escape($text) . "' WHERE post_id = $post_id");
|
||||
if ($post['topic_last_post_id'] != $post['post_id'] && $userdata['user_id'] == $post['poster_id']) {
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET post_edit_time = '" . TIMENOW . "', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . " SET post_edit_time = '" . TIMENOW . "', post_edit_count = post_edit_count + 1 WHERE post_id = $post_id");
|
||||
}
|
||||
$s_text = str_replace('\n', "\n", $text);
|
||||
$s_topic_title = str_replace('\n', "\n", $post['topic_title']);
|
||||
|
@ -229,9 +229,9 @@ switch ($this->request['type']) {
|
|||
$message = prepare_message($message);
|
||||
|
||||
// Flood control
|
||||
$where_sql = (IS_GUEST) ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
|
||||
$where_sql = IS_GUEST ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
|
||||
|
||||
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
|
||||
$sql = 'SELECT MAX(p.post_time) AS last_post_time FROM ' . BB_POSTS . " p WHERE $where_sql";
|
||||
if ($row = OLD_DB()->fetch_row($sql) and $row['last_post_time']) {
|
||||
if ($userdata['user_level'] == USER) {
|
||||
if (TIMENOW - $row['last_post_time'] < config('tp.flood_interval')) {
|
||||
|
@ -242,14 +242,14 @@ switch ($this->request['type']) {
|
|||
|
||||
// Double Post Control
|
||||
if (!empty($row['last_post_time']) && !IS_AM) {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT pt.post_text
|
||||
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
|
||||
FROM ' . BB_POSTS . ' p, ' . BB_POSTS_TEXT . " pt
|
||||
WHERE $where_sql
|
||||
AND p.post_time = " . (int)$row['last_post_time'] . "
|
||||
AND p.post_time = " . (int)$row['last_post_time'] . '
|
||||
AND pt.post_id = p.post_id
|
||||
LIMIT 1
|
||||
";
|
||||
';
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql)) {
|
||||
$last_msg = OLD_DB()->escape($row['post_text']);
|
||||
|
@ -267,9 +267,9 @@ switch ($this->request['type']) {
|
|||
}
|
||||
}
|
||||
|
||||
OLD_DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, " . $post['forum_id'] . ", " . $userdata['user_id'] . ", '" . TIMENOW . "', '" . USER_IP . "')");
|
||||
OLD_DB()->sql_query('INSERT INTO ' . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ($topic_id, " . $post['forum_id'] . ', ' . $userdata['user_id'] . ", '" . TIMENOW . "', '" . USER_IP . "')");
|
||||
$post_id = OLD_DB()->sql_nextid();
|
||||
OLD_DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '" . OLD_DB()->escape($message) . "')");
|
||||
OLD_DB()->sql_query('INSERT INTO ' . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '" . OLD_DB()->escape($message) . "')");
|
||||
|
||||
update_post_stats('reply', $post, $post['forum_id'], $topic_id, $post_id, $userdata['user_id']);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ switch ($mode) {
|
|||
if (!$tpl_id = (int)$this->request['tpl_id']) {
|
||||
$this->ajax_die('Выбранный шаблон не найден, создайте новый (empty tpl_id)');
|
||||
}
|
||||
if (!$tpl_data = OLD_DB()->fetch_row("SELECT * FROM " . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1")) {
|
||||
if (!$tpl_data = OLD_DB()->fetch_row('SELECT * FROM ' . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1")) {
|
||||
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
|
||||
}
|
||||
break;
|
||||
|
@ -109,13 +109,13 @@ switch ($mode) {
|
|||
$this->response['msg'] = 'Шаблоны в этом форуме отключены';
|
||||
} // включение
|
||||
else {
|
||||
if (!$tpl_name = OLD_DB()->fetch_row("SELECT tpl_name FROM " . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1", 'tpl_name')) {
|
||||
if (!$tpl_name = OLD_DB()->fetch_row('SELECT tpl_name FROM ' . BB_TOPIC_TPL . " WHERE tpl_id = $tpl_id LIMIT 1", 'tpl_name')) {
|
||||
$this->ajax_die("Шаблон [id: $tpl_id] не найден в БД");
|
||||
}
|
||||
$new_tpl_id = $tpl_id;
|
||||
$this->response['msg'] = "Включен шаблон $tpl_name";
|
||||
}
|
||||
OLD_DB()->query("UPDATE " . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_FORUMS . " SET forum_tpl_id = $new_tpl_id WHERE forum_id = $forum_id");
|
||||
break;
|
||||
|
||||
// сохранение изменений
|
||||
|
@ -126,7 +126,7 @@ switch ($mode) {
|
|||
$msg .= 'Шаблон был отредактирован: ' . html_entity_decode($last_edit_by_username) . ', ' . delta_time($tpl_data['tpl_last_edit_tm']) . " назад\n\n";
|
||||
$this->ajax_die($msg);
|
||||
}
|
||||
$sql = "UPDATE " . BB_TOPIC_TPL . " SET " . OLD_DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id";
|
||||
$sql = 'UPDATE ' . BB_TOPIC_TPL . ' SET ' . OLD_DB()->build_array('UPDATE', $sql_args) . " WHERE tpl_id = $tpl_id";
|
||||
if (!@OLD_DB()->query($sql)) {
|
||||
$sql_error = OLD_DB()->sql_error();
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ switch ($mode) {
|
|||
|
||||
// создание нового шаблона
|
||||
case 'new':
|
||||
$sql = "INSERT INTO " . BB_TOPIC_TPL . OLD_DB()->build_array('INSERT', $sql_args);
|
||||
$sql = 'INSERT INTO ' . BB_TOPIC_TPL . OLD_DB()->build_array('INSERT', $sql_args);
|
||||
if (!@OLD_DB()->query($sql)) {
|
||||
$sql_error = OLD_DB()->sql_error();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ switch ($mode) {
|
|||
} elseif (mb_strlen($pass, 'UTF-8') < 5) {
|
||||
$html = '<img src="./styles/images/bad.gif"> <span class="leechmed bold">' . sprintf(trans('messages.CHOOSE_PASS_ERR_MIN'), 5) . '</span>';
|
||||
} else {
|
||||
$text = (IS_GUEST) ? trans('messages.CHOOSE_PASS_REG_OK') : trans('messages.CHOOSE_PASS_OK');
|
||||
$text = IS_GUEST ? trans('messages.CHOOSE_PASS_REG_OK') : trans('messages.CHOOSE_PASS_OK');
|
||||
$html = '<img src="./styles/images/good.gif"> <span class="seedmed bold">' . $text . '</span>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,18 +17,18 @@ $post_id = (int)@$this->request['post_id'];
|
|||
$topic_id = (int)@$this->request['topic_id'];
|
||||
|
||||
if (!$post_id) {
|
||||
$post_id = OLD_DB()->fetch_row("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id');
|
||||
$post_id = OLD_DB()->fetch_row('SELECT topic_first_post_id FROM ' . BB_TOPICS . " WHERE topic_id = $topic_id", 'topic_first_post_id');
|
||||
}
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
p.*,
|
||||
h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text,
|
||||
f.auth_read
|
||||
FROM " . BB_POSTS . " p
|
||||
INNER JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = pt.post_id)
|
||||
INNER JOIN " . BB_FORUMS . " f ON(f.forum_id = p.forum_id)
|
||||
FROM ' . BB_POSTS . ' p
|
||||
INNER JOIN ' . BB_POSTS_TEXT . ' pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_HTML . ' h ON(h.post_id = pt.post_id)
|
||||
INNER JOIN ' . BB_FORUMS . " f ON(f.forum_id = p.forum_id)
|
||||
WHERE
|
||||
p.post_id = $post_id
|
||||
LIMIT 1
|
||||
|
|
|
@ -16,7 +16,7 @@ if (!isset($this->request['attach_id'])) {
|
|||
}
|
||||
$attach_id = (int)$this->request['attach_id'];
|
||||
|
||||
$torrent = OLD_DB()->fetch_row("SELECT attach_id, physical_filename FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id = $attach_id LIMIT 1");
|
||||
$torrent = OLD_DB()->fetch_row('SELECT attach_id, physical_filename FROM ' . BB_ATTACHMENTS_DESC . " WHERE attach_id = $attach_id LIMIT 1");
|
||||
if (!$torrent) {
|
||||
$this->ajax_die(trans('messages.ERROR_BUILD'));
|
||||
}
|
||||
|
|
|
@ -260,7 +260,7 @@ function display_attachments($post_id)
|
|||
SET download_count = download_count + 1
|
||||
WHERE attach_id = ' . (int)$attachments['_' . $post_id][$i]['attach_id'];
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not update attachment download count');
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ function display_attachments($post_id)
|
|||
if ($link && ($attachments['_' . $post_id][$i]['extension'] === TORRENT_EXT)) {
|
||||
include ATTACH_DIR . '/displaying_torrent.php';
|
||||
} elseif ($link) {
|
||||
$target_blank = ((@(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT)) ? 'target="_blank"' : '';
|
||||
$target_blank = @(int)$display_categories[$attachments['_' . $post_id][$i]['extension']] == IMAGE_CAT ? 'target="_blank"' : '';
|
||||
|
||||
// display attachment
|
||||
$template->assign_block_vars('postrow.attach.attachrow', array(
|
||||
|
|
|
@ -75,16 +75,16 @@ $tor_auth = ($bt_user_id != GUEST_UID && (($bt_user_id == $poster_id && !$locked
|
|||
$tor_auth_reg = ($tor_auth && $t_data['allow_reg_tracker'] && $post_id == $t_data['topic_first_post_id']);
|
||||
$tor_auth_del = ($tor_auth && $tor_reged);
|
||||
|
||||
$tracker_link = ($tor_reged) ? trans('messages.BT_REG_YES') : trans('messages.BT_REG_NO');
|
||||
$tracker_link = $tor_reged ? trans('messages.BT_REG_YES') : trans('messages.BT_REG_NO');
|
||||
|
||||
$download_link = DOWNLOAD_URL . $attach_id;
|
||||
$description = ($comment) ?: preg_replace("#.torrent$#i", '', $display_name);
|
||||
$description = $comment ?: preg_replace('#.torrent$#i', '', $display_name);
|
||||
|
||||
if ($tor_auth_reg || $tor_auth_del) {
|
||||
$reg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'reg\'}); return false;">' . trans('messages.BT_REG_ON_TRACKER') . '</a>';
|
||||
$unreg_tor_url = '<a class="txtb" href="#" onclick="ajax.exec({ action: \'change_torrent\', attach_id : ' . $attach_id . ', type: \'unreg\'}); return false;">' . trans('messages.BT_UNREG_FROM_TRACKER') . '</a>';
|
||||
|
||||
$tracker_link = ($tor_reged) ? $unreg_tor_url : $reg_tor_url;
|
||||
$tracker_link = $tor_reged ? $unreg_tor_url : $reg_tor_url;
|
||||
}
|
||||
|
||||
$display_name = '[' . config('tp.server_name') . '].t' . $bt_topic_id . '.torrent';
|
||||
|
@ -107,9 +107,9 @@ if (!$tor_reged) {
|
|||
$template->assign_block_vars('postrow.attach.tor_not_reged.comment', array('COMMENT' => $comment));
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT bt.*, u.user_id, u.username, u.user_rank
|
||||
FROM " . BB_BT_TORRENTS . " bt
|
||||
LEFT JOIN " . BB_USERS . " u ON(bt.checked_user_id = u.user_id)
|
||||
$sql = 'SELECT bt.*, u.user_id, u.username, u.user_rank
|
||||
FROM ' . BB_BT_TORRENTS . ' bt
|
||||
LEFT JOIN ' . BB_USERS . " u ON(bt.checked_user_id = u.user_id)
|
||||
WHERE bt.attach_id = $attach_id";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
|
@ -120,7 +120,7 @@ if (!$tor_reged) {
|
|||
}
|
||||
|
||||
if ($tor_reged && !$tor_info) {
|
||||
OLD_DB()->query("UPDATE " . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id");
|
||||
|
||||
bb_die('Torrent status fixed');
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ if ($tor_auth) {
|
|||
}
|
||||
|
||||
if ($tor_reged && $tor_info) {
|
||||
$tor_size = ($tor_info['size']) ?: 0;
|
||||
$tor_size = $tor_info['size'] ?: 0;
|
||||
$tor_id = $tor_info['topic_id'];
|
||||
$tor_type = $tor_info['tor_type'];
|
||||
|
||||
// Magnet link
|
||||
$passkey = OLD_DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = " . (int)$bt_user_id . " LIMIT 1");
|
||||
$passkey = OLD_DB()->fetch_row('SELECT auth_key FROM ' . BB_BT_USERS . ' WHERE user_id = ' . (int)$bt_user_id . ' LIMIT 1');
|
||||
$tor_magnet = create_magnet($tor_info['info_hash'], $passkey['auth_key'], $userdata['session_logged_in']);
|
||||
|
||||
// ratio limits
|
||||
|
@ -152,14 +152,14 @@ if ($tor_reged && $tor_info) {
|
|||
$user_ratio = 0;
|
||||
|
||||
if (($min_ratio_dl || $min_ratio_warn) && $bt_user_id != $poster_id) {
|
||||
$sql = "SELECT u.*, dl.user_status
|
||||
FROM " . BB_BT_USERS . " u
|
||||
LEFT JOIN " . BB_BT_DLSTATUS . " dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id
|
||||
$sql = 'SELECT u.*, dl.user_status
|
||||
FROM ' . BB_BT_USERS . ' u
|
||||
LEFT JOIN ' . BB_BT_DLSTATUS . " dl ON dl.user_id = $bt_user_id AND dl.topic_id = $bt_topic_id
|
||||
WHERE u.user_id = $bt_user_id
|
||||
LIMIT 1";
|
||||
} else {
|
||||
$sql = "SELECT user_status
|
||||
FROM " . BB_BT_DLSTATUS . "
|
||||
$sql = 'SELECT user_status
|
||||
FROM ' . BB_BT_DLSTATUS . "
|
||||
WHERE user_id = $bt_user_id
|
||||
AND topic_id = $bt_topic_id
|
||||
LIMIT 1";
|
||||
|
@ -206,8 +206,8 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
'S_UPLOAD_IMAGE' => $upload_image,
|
||||
'U_DOWNLOAD_LINK' => $download_link,
|
||||
'DL_LINK_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed',
|
||||
'DL_TITLE_CLASS' => (isset($bt_userdata['user_status'])) ? $dl_status_css[$bt_userdata['user_status']] : 'gen',
|
||||
'DL_LINK_CLASS' => isset($bt_userdata['user_status']) ? $dl_link_css[$bt_userdata['user_status']] : 'genmed',
|
||||
'DL_TITLE_CLASS' => isset($bt_userdata['user_status']) ? $dl_status_css[$bt_userdata['user_status']] : 'gen',
|
||||
'FILESIZE' => $tor_file_size,
|
||||
'MAGNET' => $tor_magnet,
|
||||
'HASH' => strtoupper(bin2hex($tor_info['info_hash'])),
|
||||
|
@ -270,24 +270,24 @@ if ($tor_reged && $tor_info) {
|
|||
}
|
||||
// SQL for each mode
|
||||
if ($s_mode == 'count') {
|
||||
$sql = "SELECT seeders, leechers, speed_up, speed_down
|
||||
FROM " . BB_BT_TRACKER_SNAP . "
|
||||
$sql = 'SELECT seeders, leechers, speed_up, speed_down
|
||||
FROM ' . BB_BT_TRACKER_SNAP . "
|
||||
WHERE topic_id = $tor_id
|
||||
LIMIT 1";
|
||||
} elseif ($s_mode == 'names') {
|
||||
$sql = "SELECT tr.user_id, tr.ip, tr.port, tr.remain, tr.seeder, u.username, u.user_rank
|
||||
FROM " . BB_BT_TRACKER . " tr, " . BB_USERS . " u
|
||||
$sql = 'SELECT tr.user_id, tr.ip, tr.port, tr.remain, tr.seeder, u.username, u.user_rank
|
||||
FROM ' . BB_BT_TRACKER . ' tr, ' . BB_USERS . " u
|
||||
WHERE tr.topic_id = $tor_id
|
||||
AND u.user_id = tr.user_id
|
||||
ORDER BY u.username
|
||||
LIMIT $show_peers_limit";
|
||||
} else {
|
||||
$sql = "SELECT
|
||||
$sql = 'SELECT
|
||||
tr.user_id, tr.ip, tr.port, tr.uploaded, tr.downloaded, tr.remain,
|
||||
tr.seeder, tr.releaser, tr.speed_up, tr.speed_down, tr.update_time,
|
||||
tr.complete_percent, u.username, u.user_rank
|
||||
FROM " . BB_BT_TRACKER . " tr
|
||||
LEFT JOIN " . BB_USERS . " u ON u.user_id = tr.user_id
|
||||
FROM ' . BB_BT_TRACKER . ' tr
|
||||
LEFT JOIN ' . BB_USERS . " u ON u.user_id = tr.user_id
|
||||
WHERE tr.topic_id = $tor_id
|
||||
ORDER BY $full_mode_order $full_mode_sort_dir
|
||||
LIMIT $show_peers_limit";
|
||||
|
@ -309,7 +309,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
if ($s_mode == 'full') {
|
||||
foreach ($peers as $pid => $peer) {
|
||||
$x = ($peer['seeder']) ? 's' : 'l';
|
||||
$x = $peer['seeder'] ? 's' : 'l';
|
||||
$cnt[$x]++;
|
||||
$sp_up_tot[$x] += $peer['speed_up'];
|
||||
$sp_down_tot[$x] += $peer['speed_down'];
|
||||
|
@ -356,13 +356,13 @@ if ($tor_reged && $tor_info) {
|
|||
$peers = $tmp;
|
||||
|
||||
$template->assign_vars(array(
|
||||
'TOR_SPEED_UP' => ($tor_speed_up) ? humn_size($tor_speed_up, 0, 'KB') . '/s' : '0 KB/s',
|
||||
'TOR_SPEED_DOWN' => ($tor_speed_down) ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s',
|
||||
'TOR_SPEED_UP' => $tor_speed_up ? humn_size($tor_speed_up, 0, 'KB') . '/s' : '0 KB/s',
|
||||
'TOR_SPEED_DOWN' => $tor_speed_down ? humn_size($tor_speed_down, 0, 'KB') . '/s' : '0 KB/s',
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($peers as $pid => $peer) {
|
||||
$u_prof_href = ($s_mode == 'count') ? '#' : "profile.php?mode=viewprofile&u=" . $peer['user_id'] . "#torrent";
|
||||
$u_prof_href = ($s_mode == 'count') ? '#' : 'profile.php?mode=viewprofile&u=' . $peer['user_id'] . '#torrent';
|
||||
|
||||
// Full details mode
|
||||
if ($s_mode == 'full') {
|
||||
|
@ -382,7 +382,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
if (!defined('SEEDER_EXIST')) {
|
||||
define('SEEDER_EXIST', true);
|
||||
$seed_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders";
|
||||
$seed_order_action = 'viewtopic.php?' . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders";
|
||||
|
||||
$template->assign_block_vars("$x_full", array(
|
||||
'SEED_ORD_ACT' => $seed_order_action,
|
||||
|
@ -396,7 +396,7 @@ if ($tor_reged && $tor_info) {
|
|||
$template->assign_block_vars("$x_full.porthead", array());
|
||||
}
|
||||
}
|
||||
$compl_perc = ($tor_size) ? round(($p_max_up / $tor_size), 1) : 0;
|
||||
$compl_perc = $tor_size ? round($p_max_up / $tor_size, 1) : 0;
|
||||
} else {
|
||||
$x = 'l';
|
||||
$x_row = 'lrow';
|
||||
|
@ -404,7 +404,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
if (!defined('LEECHER_EXIST')) {
|
||||
define('LEECHER_EXIST', true);
|
||||
$leech_order_action = "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#leechers";
|
||||
$leech_order_action = 'viewtopic.php?' . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#leechers";
|
||||
|
||||
$template->assign_block_vars("$x_full", array(
|
||||
'LEECH_ORD_ACT' => $leech_order_action,
|
||||
|
@ -420,24 +420,24 @@ if ($tor_reged && $tor_info) {
|
|||
}
|
||||
}
|
||||
$compl_size = ($peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
|
||||
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0;
|
||||
$compl_perc = $compl_size ? floor($compl_size * 100 / $tor_size) : 0;
|
||||
}
|
||||
|
||||
$rel_sign = (!$guest && $peer['releaser']) ? ' <b><sup>®</sup></b>' : '';
|
||||
$name = profile_url($peer) . $rel_sign;
|
||||
$up_tot = ($p_max_up) ? humn_size($p_max_up) : '-';
|
||||
$down_tot = ($p_max_down) ? humn_size($p_max_down) : '-';
|
||||
$up_ratio = ($p_max_down) ? round(($p_max_up / $p_max_down), 2) : '';
|
||||
$sp_up = ($peer['speed_up']) ? humn_size($peer['speed_up'], 0, 'KB') . '/s' : '-';
|
||||
$sp_down = ($peer['speed_down']) ? humn_size($peer['speed_down'], 0, 'KB') . '/s' : '-';
|
||||
$up_tot = $p_max_up ? humn_size($p_max_up) : '-';
|
||||
$down_tot = $p_max_down ? humn_size($p_max_down) : '-';
|
||||
$up_ratio = $p_max_down ? round($p_max_up / $p_max_down, 2) : '';
|
||||
$sp_up = $peer['speed_up'] ? humn_size($peer['speed_up'], 0, 'KB') . '/s' : '-';
|
||||
$sp_down = $peer['speed_down'] ? humn_size($peer['speed_down'], 0, 'KB') . '/s' : '-';
|
||||
|
||||
$bgr_class = (!($tr[$x] % 2)) ? $bgr_class_1 : $bgr_class_2;
|
||||
$row_bgr = ($change_peers_bgr_over) ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : '';
|
||||
$row_bgr = $change_peers_bgr_over ? " class=\"$bgr_class\" onmouseover=\"this.className='$bgr_class_over';\" onmouseout=\"this.className='$bgr_class';\"" : '';
|
||||
$tr[$x]++;
|
||||
|
||||
$template->assign_block_vars("$x_full.$x_row", array(
|
||||
'ROW_BGR' => $row_bgr,
|
||||
'NAME' => ($peer['update_time']) ? $name : "<s>$name</s>",
|
||||
'NAME' => $peer['update_time'] ? $name : "<s>$name</s>",
|
||||
'COMPL_PRC' => $compl_perc,
|
||||
'UP_TOTAL' => ($max_up_id[$x] == $pid) ? "<b>$up_tot</b>" : $up_tot,
|
||||
'DOWN_TOTAL' => ($max_down_id[$x] == $pid) ? "<b>$down_tot</b>" : $down_tot,
|
||||
|
@ -447,8 +447,8 @@ if ($tor_reged && $tor_info) {
|
|||
'DOWN_TOTAL_RAW' => $peer['downloaded'],
|
||||
'SPEED_UP_RAW' => $peer['speed_up'],
|
||||
'SPEED_DOWN_RAW' => $peer['speed_down'],
|
||||
'UPD_EXP_TIME' => ($peer['update_time']) ? trans('messages.DL_UPD') . bb_date($peer['update_time'], 'd-M-y H:i') . ' · ' . delta_time($peer['update_time']) . trans('messages.TOR_BACK') : trans('messages.DL_STOPPED'),
|
||||
'TOR_RATIO' => ($up_ratio) ? trans('messages.USER_RATIO') . "UL/DL: $up_ratio" : '',
|
||||
'UPD_EXP_TIME' => $peer['update_time'] ? trans('messages.DL_UPD') . bb_date($peer['update_time'], 'd-M-y H:i') . ' · ' . delta_time($peer['update_time']) . trans('messages.TOR_BACK') : trans('messages.DL_STOPPED'),
|
||||
'TOR_RATIO' => $up_ratio ? trans('messages.USER_RATIO') . "UL/DL: $up_ratio" : '',
|
||||
));
|
||||
|
||||
if ($ip) {
|
||||
|
@ -464,7 +464,7 @@ if ($tor_reged && $tor_info) {
|
|||
$seed_count = $peer['username'];
|
||||
} else {
|
||||
$compl_size = (@$peer['remain'] && $tor_size && $tor_size > $peer['remain']) ? ($tor_size - $peer['remain']) : 0;
|
||||
$compl_perc = ($compl_size) ? floor($compl_size * 100 / $tor_size) : 0;
|
||||
$compl_perc = $compl_size ? floor($compl_size * 100 / $tor_size) : 0;
|
||||
|
||||
$leechers .= '<nobr><a href="' . $u_prof_href . '" class="leechmed">' . $peer['username'] . '</a>';
|
||||
$leechers .= ($s_mode == 'names') ? ' [' . $compl_perc . '%]' : '';
|
||||
|
@ -478,14 +478,14 @@ if ($tor_reged && $tor_info) {
|
|||
$seeders[strlen($seeders) - 9] = ' ';
|
||||
$template->assign_vars(array(
|
||||
'SEED_LIST' => $seeders,
|
||||
'SEED_COUNT' => ($seed_count) ?: 0,
|
||||
'SEED_COUNT' => $seed_count ?: 0,
|
||||
));
|
||||
}
|
||||
if ($s_mode != 'full' && $leechers) {
|
||||
$leechers[strlen($leechers) - 9] = ' ';
|
||||
$template->assign_vars(array(
|
||||
'LEECH_LIST' => $leechers,
|
||||
'LEECH_COUNT' => ($leech_count) ?: 0,
|
||||
'LEECH_COUNT' => $leech_count ?: 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ if ($tor_reged && $tor_info) {
|
|||
|
||||
// Show "seeder last seen info"
|
||||
if (($s_mode == 'count' && !$seed_count) || (!$seeders && !defined('SEEDER_EXIST'))) {
|
||||
$last_seen_time = ($tor_info['seeder_last_seen']) ? delta_time($tor_info['seeder_last_seen']) : trans('messages.NEVER');
|
||||
$last_seen_time = $tor_info['seeder_last_seen'] ? delta_time($tor_info['seeder_last_seen']) : trans('messages.NEVER');
|
||||
|
||||
$template->assign_vars(array(
|
||||
'SEEDER_LAST_SEEN' => sprintf(trans('messages.SEEDER_LAST_SEEN'), $last_seen_time),
|
||||
|
@ -514,7 +514,7 @@ if ($tor_reged && $tor_info) {
|
|||
if (config('tp.bt_allow_spmode_change') && $s_mode != 'full') {
|
||||
$template->assign_vars(array(
|
||||
'PEERS_FULL_LINK' => true,
|
||||
'SPMODE_FULL_HREF' => "viewtopic.php?" . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders",
|
||||
'SPMODE_FULL_HREF' => 'viewtopic.php?' . POST_TOPIC_URL . "=$bt_topic_id&spmode=full#seeders",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ if (!function_exists('html_entity_decode')) {
|
|||
{
|
||||
$trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style));
|
||||
$trans_table['''] = "'";
|
||||
return (strtr($given_html, $trans_table));
|
||||
return strtr($given_html, $trans_table);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -345,9 +345,9 @@ function attachment_sync_topic($topics)
|
|||
$posts_without_attach = $topics_without_attach = [];
|
||||
|
||||
// Check orphan post_attachment markers
|
||||
$sql = "SELECT p.post_id
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(post_id)
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . " a USING(post_id)
|
||||
WHERE p.topic_id IN($topics)
|
||||
AND p.post_attachment = 1
|
||||
AND a.post_id IS NULL";
|
||||
|
@ -357,13 +357,13 @@ function attachment_sync_topic($topics)
|
|||
$posts_without_attach[] = $row['post_id'];
|
||||
}
|
||||
if ($posts_sql = implode(',', $posts_without_attach)) {
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
}
|
||||
}
|
||||
|
||||
// Update missing topic_attachment markers
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_TOPICS . " t, " . BB_POSTS . " p SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_TOPICS . ' t, ' . BB_POSTS . " p SET
|
||||
t.topic_attachment = 1
|
||||
WHERE p.topic_id IN($topics)
|
||||
AND p.post_attachment = 1
|
||||
|
@ -371,8 +371,8 @@ function attachment_sync_topic($topics)
|
|||
");
|
||||
|
||||
// Fix orphan topic_attachment markers
|
||||
$sql = "SELECT t.topic_id
|
||||
FROM " . BB_POSTS . " p, " . BB_TOPICS . " t
|
||||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . BB_POSTS . ' p, ' . BB_TOPICS . " t
|
||||
WHERE t.topic_id = p.topic_id
|
||||
AND t.topic_id IN($topics)
|
||||
AND t.topic_attachment = 1
|
||||
|
@ -384,7 +384,7 @@ function attachment_sync_topic($topics)
|
|||
$topics_without_attach[] = $row['topic_id'];
|
||||
}
|
||||
if ($topics_sql = implode(',', $topics_without_attach)) {
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ function user_in_group($user_id, $group_id)
|
|||
*/
|
||||
function amod_realpath($path)
|
||||
{
|
||||
return (function_exists('realpath')) ? realpath($path) : $path;
|
||||
return function_exists('realpath') ? realpath($path) : $path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -488,7 +488,7 @@ function get_var($var_name, $default, $multibyte = false)
|
|||
if (!isset($_REQUEST[$var_name]) ||
|
||||
(is_array($_REQUEST[$var_name]) && !is_array($default)) ||
|
||||
(is_array($default) && !is_array($_REQUEST[$var_name]))) {
|
||||
return (is_array($default)) ? [] : $default;
|
||||
return is_array($default) ? [] : $default;
|
||||
}
|
||||
|
||||
$var = $_REQUEST[$var_name];
|
||||
|
@ -563,7 +563,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
|
|||
} elseif (is_array($var) && is_string($var[0])) {
|
||||
$values[] = $var[0];
|
||||
} else {
|
||||
$values[] = (is_bool($var)) ? (int)$var : $var;
|
||||
$values[] = is_bool($var) ? (int)$var : $var;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
|
|||
} elseif (is_string($var)) {
|
||||
$values[] = "'" . attach_mod_sql_escape($var) . "'";
|
||||
} else {
|
||||
$values[] = (is_bool($var)) ? (int)$var : $var;
|
||||
$values[] = is_bool($var) ? (int)$var : $var;
|
||||
}
|
||||
}
|
||||
$ary[] = '(' . implode(', ', $values) . ')';
|
||||
|
@ -593,7 +593,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
|
|||
} elseif (is_string($var)) {
|
||||
$values[] = "$key = '" . attach_mod_sql_escape($var) . "'";
|
||||
} else {
|
||||
$values[] = (is_bool($var)) ? "$key = " . (int)$var : "$key = $var";
|
||||
$values[] = is_bool($var) ? "$key = " . (int)$var : "$key = $var";
|
||||
}
|
||||
}
|
||||
$query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values);
|
||||
|
|
|
@ -134,13 +134,13 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
WHERE attach_id IN (' . implode(', ', $attach_id_array) . ")
|
||||
AND $sql_id IN (" . implode(', ', $post_id_array) . ')';
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die(trans('messages.ERROR_DELETED_ATTACHMENTS'));
|
||||
}
|
||||
|
||||
//bt
|
||||
if ($sql_id == 'post_id') {
|
||||
$sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
|
||||
$sql = 'SELECT topic_id FROM ' . BB_BT_TORRENTS . ' WHERE attach_id IN(' . implode(',', $attach_id_array) . ')';
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die(trans('messages.ERROR_DELETED_ATTACHMENTS'));
|
||||
|
@ -154,7 +154,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
|
||||
if ($torrents_sql = implode(',', $torrents_sql)) {
|
||||
// Remove peers from tracker
|
||||
$sql = "DELETE FROM " . BB_BT_TRACKER . "
|
||||
$sql = 'DELETE FROM ' . BB_BT_TRACKER . "
|
||||
WHERE topic_id IN($torrents_sql)";
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
|
@ -162,8 +162,8 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
}
|
||||
}
|
||||
// Delete torrents
|
||||
$sql = "DELETE FROM " . BB_BT_TORRENTS . "
|
||||
WHERE attach_id IN(" . implode(',', $attach_id_array) . ")";
|
||||
$sql = 'DELETE FROM ' . BB_BT_TORRENTS . '
|
||||
WHERE attach_id IN(' . implode(',', $attach_id_array) . ')';
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die(trans('messages.ERROR_DELETED_ATTACHMENTS'));
|
||||
|
@ -208,7 +208,7 @@ function delete_attachment($post_id_array = 0, $attach_id_array = 0, $page = 0,
|
|||
|
||||
$sql = 'DELETE FROM ' . BB_ATTACHMENTS_DESC . ' WHERE attach_id = ' . (int)$attachments[$j]['attach_id'];
|
||||
|
||||
if (!(OLD_DB()->sql_query($sql))) {
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die(trans('messages.ERROR_DELETED_ATTACHMENTS'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ function attach_build_auth_levels($is_auth, &$s_auth_can)
|
|||
}
|
||||
|
||||
// If you want to have the rules window link within the forum view too, comment out the two lines, and comment the third line
|
||||
$s_auth_can .= (($is_auth['auth_attachments']) ? trans('messages.RULES_ATTACH_CAN') : trans('messages.RULES_ATTACH_CANNOT')) . '<br />';
|
||||
$s_auth_can .= (($is_auth['auth_download']) ? trans('messages.RULES_DOWNLOAD_CAN') : trans('messages.RULES_DOWNLOAD_CANNOT')) . '<br />';
|
||||
$s_auth_can .= ($is_auth['auth_attachments'] ? trans('messages.RULES_ATTACH_CAN') : trans('messages.RULES_ATTACH_CANNOT')) . '<br />';
|
||||
$s_auth_can .= ($is_auth['auth_download'] ? trans('messages.RULES_DOWNLOAD_CAN') : trans('messages.RULES_DOWNLOAD_CANNOT')) . '<br />';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
|
|||
}
|
||||
|
||||
include ATTACH_DIR . '/includes/functions_selects.php';
|
||||
if (!function_exists("process_quota_settings")) {
|
||||
if (!function_exists('process_quota_settings')) {
|
||||
include ATTACH_DIR . '/includes/functions_admin.php';
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ function attachment_quota_settings($admin_mode, $submit = false, $mode)
|
|||
|
||||
if ($admin_mode == 'user') {
|
||||
// We overwrite submit here... to be sure
|
||||
$submit = (isset($_POST['submit'])) ? true : false;
|
||||
$submit = isset($_POST['submit']) ? true : false;
|
||||
|
||||
if (!$submit && $mode != 'save') {
|
||||
$user_id = get_var(POST_USERS_URL, 0);
|
||||
|
|
|
@ -79,9 +79,9 @@ function get_supported_image_types($type)
|
|||
}
|
||||
|
||||
return array(
|
||||
'gd' => ($new_type) ? true : false,
|
||||
'gd' => $new_type ? true : false,
|
||||
'format' => $new_type,
|
||||
'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
|
||||
'version' => function_exists('imagecreatetruecolor') ? 2 : 1
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ function generate_smilies($mode)
|
|||
$template->assign_block_vars('switch_smilies_extra', array());
|
||||
|
||||
$template->assign_vars(array(
|
||||
'U_MORE_SMILIES' => POSTING_URL . "?mode=smilies",
|
||||
'U_MORE_SMILIES' => POSTING_URL . '?mode=smilies',
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -371,16 +371,16 @@ function extract_search_words($text)
|
|||
function add_search_words($post_id, $post_message, $topic_title = '', $only_return_words = false)
|
||||
{
|
||||
$text = $topic_title . ' ' . $post_message;
|
||||
$words = ($text) ? extract_search_words($text) : array();
|
||||
$words = $text ? extract_search_words($text) : array();
|
||||
|
||||
if ($only_return_words || config('tp.search_engine_type') == 'sphinx') {
|
||||
return implode("\n", $words);
|
||||
}
|
||||
|
||||
OLD_DB()->query("DELETE FROM " . BB_POSTS_SEARCH . " WHERE post_id = $post_id");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_POSTS_SEARCH . " WHERE post_id = $post_id");
|
||||
|
||||
if ($words_sql = OLD_DB()->escape(implode("\n", $words))) {
|
||||
OLD_DB()->query("REPLACE INTO " . BB_POSTS_SEARCH . " (post_id, search_words) VALUES ($post_id, '$words_sql')");
|
||||
OLD_DB()->query('REPLACE INTO ' . BB_POSTS_SEARCH . " (post_id, search_words) VALUES ($post_id, '$words_sql')");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ function get_words_rate($text)
|
|||
|
||||
function hide_passkey($str)
|
||||
{
|
||||
return preg_replace("#\?" . config('tp.passkey_key') . "=[a-zA-Z0-9]{" . BT_AUTH_KEY_LENGTH . "}#", "?" . config('tp.passkey_key') . "=passkey", $str);
|
||||
return preg_replace("#\?" . config('tp.passkey_key') . '=[a-zA-Z0-9]{' . BT_AUTH_KEY_LENGTH . '}#', '?' . config('tp.passkey_key') . '=passkey', $str);
|
||||
}
|
||||
|
||||
function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
|
||||
|
@ -441,5 +441,5 @@ function get_parsed_post($postrow, $mode = 'full', $return_chars = 600)
|
|||
|
||||
function update_post_html($postrow)
|
||||
{
|
||||
OLD_DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_id = " . (int)$postrow['post_id']);
|
||||
OLD_DB()->query('DELETE FROM ' . BB_POSTS_HTML . ' WHERE post_id = ' . (int)$postrow['post_id']);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@ if (!defined('BB_ROOT')) {
|
|||
bb_log(date('H:i:s - ') . getmypid() . ' --x- SELECT jobs' . LOG_LF, CRON_LOG_DIR . '/cron_check');
|
||||
|
||||
// Get cron jobs
|
||||
$cron_jobs = OLD_DB()->fetch_rowset("
|
||||
SELECT * FROM " . BB_CRON . "
|
||||
$cron_jobs = OLD_DB()->fetch_rowset('
|
||||
SELECT * FROM ' . BB_CRON . '
|
||||
WHERE cron_active = 1
|
||||
AND next_run <= NOW()
|
||||
ORDER BY run_order
|
||||
");
|
||||
');
|
||||
|
||||
// Run cron jobs
|
||||
if ($cron_jobs) {
|
||||
|
@ -32,7 +32,7 @@ if ($cron_jobs) {
|
|||
}
|
||||
}
|
||||
|
||||
require(CRON_DIR . 'cron_run.php');
|
||||
require CRON_DIR . 'cron_run.php';
|
||||
|
||||
// Update cron_last_check
|
||||
bb_update_config(array('cron_last_check' => TIMENOW + 10));
|
||||
|
|
|
@ -14,7 +14,7 @@ if (!defined('BB_ROOT')) {
|
|||
define('IN_CRON', true);
|
||||
|
||||
// Set SESSION vars
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
SET SESSION
|
||||
myisam_sort_buffer_size = 16*1024*1024
|
||||
, bulk_insert_buffer_size = 8*1024*1024
|
||||
|
@ -24,10 +24,10 @@ OLD_DB()->query("
|
|||
, sort_buffer_size = 4*1024*1024
|
||||
, tmp_table_size = 80*1024*1024
|
||||
, group_concat_max_len = 1*1024*1024
|
||||
");
|
||||
');
|
||||
|
||||
// Restore vars at shutdown
|
||||
OLD_DB()->add_shutdown_query("
|
||||
OLD_DB()->add_shutdown_query('
|
||||
SET SESSION
|
||||
myisam_sort_buffer_size = DEFAULT
|
||||
, bulk_insert_buffer_size = DEFAULT
|
||||
|
@ -37,7 +37,7 @@ OLD_DB()->add_shutdown_query("
|
|||
, sort_buffer_size = DEFAULT
|
||||
, tmp_table_size = DEFAULT
|
||||
, group_concat_max_len = DEFAULT
|
||||
");
|
||||
');
|
||||
|
||||
// $cron_jobs obtained in cron_check.php
|
||||
foreach ($cron_jobs as $job) {
|
||||
|
@ -66,7 +66,7 @@ foreach ($cron_jobs as $job) {
|
|||
}
|
||||
|
||||
set_time_limit(600);
|
||||
require($job_script);
|
||||
require $job_script;
|
||||
|
||||
if ($job['log_sql_queries']) {
|
||||
OLD_DB()->log_next_query(0);
|
||||
|
@ -86,13 +86,13 @@ foreach ($cron_jobs as $job) {
|
|||
bb_log($msg . LOG_LF, CRON_LOG_DIR . '/' . CRON_LOG_FILE);
|
||||
|
||||
if ($cron_runtime_log) {
|
||||
$runtime_log_file = ($job['log_file']) ?: $job['cron_script'];
|
||||
$runtime_log_file = $job['log_file'] ?: $job['cron_script'];
|
||||
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . '/' . basename($runtime_log_file));
|
||||
}
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_CRON . " SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_CRON . " SET
|
||||
last_run = NOW(),
|
||||
run_counter = run_counter + 1,
|
||||
next_run =
|
||||
|
|
|
@ -64,10 +64,10 @@ if ($dir = @opendir($attach_dir)) {
|
|||
|
||||
if ($check_attachments) {
|
||||
// Delete bad records
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE a, d
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
FROM ' . BB_ATTACHMENTS_DESC . ' d
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
WHERE (
|
||||
d.physical_filename = ''
|
||||
OR d.real_filename = ''
|
||||
|
@ -98,8 +98,8 @@ if ($check_attachments) {
|
|||
}
|
||||
}
|
||||
// Find DB records for attachments that exist in DB but not exist in file system
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
$sql = 'SELECT d.attach_id
|
||||
FROM ' . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN $tmp_attach_tbl f USING(physical_filename)
|
||||
WHERE f.physical_filename IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
@ -108,9 +108,9 @@ if ($check_attachments) {
|
|||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in DESC_TABLE but not exist in ATTACH_TABLE
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
$sql = 'SELECT d.attach_id
|
||||
FROM ' . BB_ATTACHMENTS_DESC . ' d
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
WHERE a.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
|
@ -118,9 +118,9 @@ if ($check_attachments) {
|
|||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in ATTACH_TABLE but not exist in DESC_TABLE
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM " . BB_ATTACHMENTS . " a
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
$sql = 'SELECT a.attach_id
|
||||
FROM ' . BB_ATTACHMENTS . ' a
|
||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
WHERE d.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
|
@ -128,9 +128,9 @@ if ($check_attachments) {
|
|||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachments without post
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM " . BB_ATTACHMENTS . " a
|
||||
LEFT JOIN " . BB_POSTS . " p USING(post_id)
|
||||
$sql = 'SELECT a.attach_id
|
||||
FROM ' . BB_ATTACHMENTS . ' a
|
||||
LEFT JOIN ' . BB_POSTS . " p USING(post_id)
|
||||
WHERE p.post_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
|
@ -140,15 +140,15 @@ if ($check_attachments) {
|
|||
// Delete all orphan attachments
|
||||
if ($orphans_sql = implode(',', $orphan_db_attach)) {
|
||||
if ($fix_errors) {
|
||||
OLD_DB()->query("DELETE FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id IN($orphans_sql)");
|
||||
OLD_DB()->query("DELETE FROM " . BB_ATTACHMENTS . " WHERE attach_id IN($orphans_sql)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_ATTACHMENTS_DESC . " WHERE attach_id IN($orphans_sql)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_ATTACHMENTS . " WHERE attach_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
|
||||
// Torrents without attachments
|
||||
$sql = "SELECT tor.topic_id
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
$sql = 'SELECT tor.topic_id
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
WHERE d.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
|
@ -158,39 +158,39 @@ if ($check_attachments) {
|
|||
// Delete all orphan torrents
|
||||
if ($orphans_sql = implode(',', $orphan_tor)) {
|
||||
if ($fix_errors) {
|
||||
OLD_DB()->query("DELETE FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($orphans_sql)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_BT_TORRENTS . " WHERE topic_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
|
||||
// Check post_attachment markers
|
||||
$sql = "SELECT p.post_id
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(post_id)
|
||||
$sql = 'SELECT p.post_id
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . ' a USING(post_id)
|
||||
WHERE p.post_attachment = 1
|
||||
AND a.post_id IS NULL";
|
||||
AND a.post_id IS NULL';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$posts_without_attach[] = $row['post_id'];
|
||||
}
|
||||
if ($posts_sql = implode(',', $posts_without_attach)) {
|
||||
if ($fix_errors) {
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
}
|
||||
}
|
||||
// Check topic_attachment markers
|
||||
$sql = "SELECT t.topic_id
|
||||
FROM " . BB_POSTS . " p, " . BB_TOPICS . " t
|
||||
$sql = 'SELECT t.topic_id
|
||||
FROM ' . BB_POSTS . ' p, ' . BB_TOPICS . ' t
|
||||
WHERE t.topic_id = p.topic_id
|
||||
AND t.topic_attachment = 1
|
||||
GROUP BY p.topic_id
|
||||
HAVING SUM(p.post_attachment) = 0";
|
||||
HAVING SUM(p.post_attachment) = 0';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$topics_without_attach[] = $row['topic_id'];
|
||||
}
|
||||
if ($topics_sql = implode(',', $topics_without_attach)) {
|
||||
if ($fix_errors) {
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ sync_all_forums();
|
|||
// Чистка bb_poll_users
|
||||
if ($poll_max_days = (int)config('tp.poll_max_days')) {
|
||||
$per_cycle = 20000;
|
||||
$row = OLD_DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_POLL_USERS);
|
||||
$row = OLD_DB()->fetch_row('SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM ' . BB_POLL_USERS);
|
||||
$start_id = (int)$row['start_id'];
|
||||
$finish_id = (int)$row['finish_id'];
|
||||
|
||||
|
@ -29,8 +29,8 @@ if ($poll_max_days = (int)config('tp.poll_max_days')) {
|
|||
set_time_limit(600);
|
||||
$end_id = $start_id + $per_cycle - 1;
|
||||
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_POLL_USERS . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_POLL_USERS . "
|
||||
WHERE topic_id BETWEEN $start_id AND $end_id
|
||||
AND vote_dt < DATE_SUB(NOW(), INTERVAL $poll_max_days DAY)
|
||||
");
|
||||
|
@ -44,9 +44,9 @@ if ($poll_max_days = (int)config('tp.poll_max_days')) {
|
|||
}
|
||||
|
||||
// Чистка user_newpasswd
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
|
||||
|
||||
// Чистка кеша постов
|
||||
if ($posts_days = (int)config('tp.posts_cache_days_keep')) {
|
||||
OLD_DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@ global $cron_runtime_log;
|
|||
foreach (config('tp.cache.engines') as $cache_name => $cache_val) {
|
||||
if (method_exists(OLD_CACHE($cache_name), 'gc')) {
|
||||
$changes = OLD_CACHE($cache_name)->gc();
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') . " -- " . str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) . " del: $changes\n";
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') . ' -- ' . str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) . " del: $changes\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,54 +32,54 @@ foreach ($keeping_dlstat as $dl_status => $days_to_keep) {
|
|||
}
|
||||
|
||||
if ($delete_dlstat_sql = implode(') OR (', $delete_dlstat_sql)) {
|
||||
OLD_DB()->query("DELETE QUICK FROM " . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
|
||||
OLD_DB()->query('DELETE QUICK FROM ' . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
|
||||
}
|
||||
|
||||
// Delete orphans
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE QUICK dl
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
LEFT JOIN " . BB_USERS . " u USING(user_id)
|
||||
FROM ' . BB_BT_DLSTATUS . ' dl
|
||||
LEFT JOIN ' . BB_USERS . ' u USING(user_id)
|
||||
WHERE u.user_id IS NULL
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE QUICK dl
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
|
||||
FROM ' . BB_BT_DLSTATUS . ' dl
|
||||
LEFT JOIN ' . BB_TOPICS . ' t USING(topic_id)
|
||||
WHERE t.topic_id IS NULL
|
||||
");
|
||||
');
|
||||
|
||||
// Tor-Stats cleanup
|
||||
if ($torstat_days_keep = (int)config('tp.torstat_days_keep')) {
|
||||
OLD_DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
|
||||
OLD_DB()->query('DELETE QUICK FROM ' . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE QUICK tst
|
||||
FROM " . BB_BT_TORSTAT . " tst
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor USING(topic_id)
|
||||
FROM ' . BB_BT_TORSTAT . ' tst
|
||||
LEFT JOIN ' . BB_BT_TORRENTS . ' tor USING(topic_id)
|
||||
WHERE tor.topic_id IS NULL
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_BT_USERS . "
|
||||
' . BB_BT_USERS . '
|
||||
SET
|
||||
up_yesterday = up_today,
|
||||
down_yesterday = down_today,
|
||||
up_release_yesterday = up_release_today,
|
||||
up_bonus_yesterday = up_bonus_today,
|
||||
points_yesterday = points_today
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_BT_USERS . "
|
||||
' . BB_BT_USERS . '
|
||||
SET
|
||||
up_today = 0,
|
||||
down_today = 0,
|
||||
up_release_today = 0,
|
||||
up_bonus_today = 0,
|
||||
points_today = 0
|
||||
");
|
||||
');
|
||||
|
|
|
@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
$log_days_keep = (int)config('tp.log_days_keep');
|
||||
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_LOG . "
|
||||
WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep) . "
|
||||
");
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_LOG . '
|
||||
WHERE log_time < ' . (TIMENOW - 86400 * $log_days_keep) . '
|
||||
');
|
||||
|
|
|
@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
$search_results_expire = TIMENOW - 3 * 3600;
|
||||
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_SEARCH . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_SEARCH . "
|
||||
WHERE search_time < $search_results_expire
|
||||
");
|
||||
|
|
|
@ -18,18 +18,18 @@ OLD_DB()->lock(array(
|
|||
));
|
||||
|
||||
// Flash buffered records
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_TOPICS . " t,
|
||||
" . BUF_TOPIC_VIEW . " buf
|
||||
' . BB_TOPICS . ' t,
|
||||
' . BUF_TOPIC_VIEW . ' buf
|
||||
SET
|
||||
t.topic_views = t.topic_views + buf.topic_views
|
||||
WHERE
|
||||
t.topic_id = buf.topic_id
|
||||
");
|
||||
');
|
||||
|
||||
// Delete buffered records
|
||||
OLD_DB()->query("DELETE buf FROM " . BUF_TOPIC_VIEW . " buf");
|
||||
OLD_DB()->query('DELETE buf FROM ' . BUF_TOPIC_VIEW . ' buf');
|
||||
|
||||
// Unlock tables
|
||||
OLD_DB()->unlock();
|
||||
|
|
|
@ -14,9 +14,9 @@ if (!defined('BB_ROOT')) {
|
|||
require_once INC_DIR . '/functions_admin.php';
|
||||
|
||||
if (config('tp.prune_enable')) {
|
||||
$sql = "SELECT forum_id, prune_days FROM " . BB_FORUMS . " WHERE prune_days != 0";
|
||||
$sql = 'SELECT forum_id, prune_days FROM ' . BB_FORUMS . ' WHERE prune_days != 0';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
topic_delete('prune', $row['forum_id'], (TIMENOW - 86400 * $row['prune_days']));
|
||||
topic_delete('prune', $row['forum_id'], TIMENOW - 86400 * $row['prune_days']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ while (true) {
|
|||
$prune_users = $not_activated_users = $not_active_users = array();
|
||||
|
||||
if ($not_activated_days = (int)config('tp.user_not_activated_days_keep')) {
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT user_id FROM ' . BB_USERS . '
|
||||
WHERE user_level = 0
|
||||
AND user_lastvisit = 0
|
||||
AND user_session_time = 0
|
||||
AND user_regdate <= " . (TIMENOW - 86400 * $not_activated_days) . "
|
||||
AND user_id NOT IN(" . EXCLUDED_USERS . ")
|
||||
AND user_regdate <= ' . (TIMENOW - 86400 * $not_activated_days) . '
|
||||
AND user_id NOT IN(' . EXCLUDED_USERS . ")
|
||||
LIMIT $users_per_cycle");
|
||||
|
||||
foreach ($sql as $row) {
|
||||
|
@ -35,11 +35,11 @@ while (true) {
|
|||
}
|
||||
|
||||
if ($not_active_days = (int)config('tp.user_not_active_days_keep')) {
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT user_id FROM ' . BB_USERS . '
|
||||
WHERE user_level = 0
|
||||
AND user_posts = 0
|
||||
AND user_lastvisit <= " . (TIMENOW - 86400 * $not_active_days) . "
|
||||
AND user_id NOT IN(" . EXCLUDED_USERS . ")
|
||||
AND user_lastvisit <= ' . (TIMENOW - 86400 * $not_active_days) . '
|
||||
AND user_id NOT IN(' . EXCLUDED_USERS . ")
|
||||
LIMIT $users_per_cycle");
|
||||
|
||||
foreach ($sql as $row) {
|
||||
|
|
|
@ -14,9 +14,9 @@ if (!defined('BB_ROOT')) {
|
|||
if (config('tp.topic_moved_days_keep')) {
|
||||
$prune_time = TIMENOW - 86400 * config('tp.topic_moved_days_keep');
|
||||
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_TOPICS . "
|
||||
WHERE topic_status = " . TOPIC_MOVED . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_TOPICS . '
|
||||
WHERE topic_status = ' . TOPIC_MOVED . "
|
||||
AND topic_time < $prune_time
|
||||
");
|
||||
}
|
||||
|
|
|
@ -24,15 +24,15 @@ OLD_DB()->lock(array(
|
|||
));
|
||||
|
||||
// Update user's session time
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_USERS . " u,
|
||||
" . BB_SESSIONS . " s
|
||||
' . BB_USERS . ' u,
|
||||
' . BB_SESSIONS . ' s
|
||||
SET
|
||||
u.user_session_time = IF(u.user_session_time < s.session_time, s.session_time, u.user_session_time)
|
||||
WHERE
|
||||
u.user_id = s.session_user_id
|
||||
AND s.session_user_id != " . GUEST_UID . "
|
||||
AND s.session_user_id != ' . GUEST_UID . "
|
||||
AND (
|
||||
(s.session_time < $user_session_expire_time AND s.session_admin = 0)
|
||||
OR
|
||||
|
@ -44,9 +44,9 @@ OLD_DB()->unlock();
|
|||
// ############################ Tables UNLOCKED ##############################
|
||||
|
||||
// Delete staled sessions
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE s
|
||||
FROM " . BB_SESSIONS . " s
|
||||
FROM ' . BB_SESSIONS . " s
|
||||
WHERE
|
||||
(s.session_time < $user_session_gc_time AND s.session_admin = 0)
|
||||
OR
|
||||
|
|
|
@ -18,11 +18,11 @@ define('OLD_BB_BT_LAST_TORSTAT', 'old_bt_last_torstat');
|
|||
define('NEW_BB_BT_LAST_USERSTAT', 'new_bt_last_userstat');
|
||||
define('OLD_BB_BT_LAST_USERSTAT', 'old_bt_last_userstat');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_TORSTAT . ", " . NEW_BB_BT_LAST_USERSTAT);
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . OLD_BB_BT_LAST_TORSTAT . ", " . OLD_BB_BT_LAST_USERSTAT);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_LAST_TORSTAT . ', ' . NEW_BB_BT_LAST_USERSTAT);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . OLD_BB_BT_LAST_TORSTAT . ', ' . OLD_BB_BT_LAST_USERSTAT);
|
||||
|
||||
OLD_DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_TORSTAT . " LIKE " . BB_BT_LAST_TORSTAT);
|
||||
OLD_DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_USERSTAT . " LIKE " . BB_BT_LAST_USERSTAT);
|
||||
OLD_DB()->query('CREATE TABLE ' . NEW_BB_BT_LAST_TORSTAT . ' LIKE ' . BB_BT_LAST_TORSTAT);
|
||||
OLD_DB()->query('CREATE TABLE ' . NEW_BB_BT_LAST_USERSTAT . ' LIKE ' . BB_BT_LAST_USERSTAT);
|
||||
|
||||
OLD_DB()->expect_slow_query(600);
|
||||
|
||||
|
@ -35,33 +35,33 @@ if (config('tracker.update_dlstat')) {
|
|||
));
|
||||
|
||||
// Get PER TORRENT user's dlstat from tracker
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . NEW_BB_BT_LAST_TORSTAT . "
|
||||
(topic_id, user_id, dl_status, up_add, down_add, release_add, speed_up, speed_down)
|
||||
SELECT
|
||||
topic_id, user_id, IF(releaser, $releaser, seeder), SUM(up_add), SUM(down_add), IF(releaser, SUM(up_add), 0), SUM(speed_up), SUM(speed_down)
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
FROM " . BB_BT_TRACKER . '
|
||||
WHERE (up_add != 0 OR down_add != 0)
|
||||
GROUP BY topic_id, user_id, releaser, seeder
|
||||
");
|
||||
');
|
||||
|
||||
// Reset up/down additions in tracker
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TRACKER . " SET up_add = 0, down_add = 0");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TRACKER . ' SET up_add = 0, down_add = 0');
|
||||
|
||||
OLD_DB()->unlock();
|
||||
// ############################ Tables UNLOCKED ##############################
|
||||
}
|
||||
|
||||
// Update last seeder info in BUF
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO " . BUF_LAST_SEEDER . "
|
||||
OLD_DB()->query('
|
||||
REPLACE INTO ' . BUF_LAST_SEEDER . '
|
||||
(topic_id, seeder_last_seen)
|
||||
SELECT
|
||||
topic_id, " . TIMENOW . "
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
topic_id, ' . TIMENOW . '
|
||||
FROM ' . BB_BT_TRACKER . '
|
||||
WHERE seeder = 1
|
||||
GROUP BY topic_id
|
||||
");
|
||||
');
|
||||
|
||||
// Clean peers table
|
||||
if (config('tracker.autoclean')) {
|
||||
|
@ -69,40 +69,40 @@ if (config('tracker.autoclean')) {
|
|||
$expire_factor = max((float)config('tracker.expire_factor'), 1);
|
||||
$peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor);
|
||||
|
||||
OLD_DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time");
|
||||
}
|
||||
|
||||
// Update dlstat (part 2)
|
||||
if (config('tracker.update_dlstat')) {
|
||||
// Set "only 1 seeder" bonus
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . NEW_BB_BT_LAST_TORSTAT . " tb,
|
||||
" . BB_BT_TRACKER_SNAP . " sn
|
||||
' . NEW_BB_BT_LAST_TORSTAT . ' tb,
|
||||
' . BB_BT_TRACKER_SNAP . ' sn
|
||||
SET
|
||||
tb.bonus_add = tb.up_add
|
||||
WHERE
|
||||
tb.topic_id = sn.topic_id
|
||||
AND sn.seeders = 1
|
||||
AND tb.up_add != 0
|
||||
AND tb.dl_status = " . DL_STATUS_COMPLETE . "
|
||||
");
|
||||
AND tb.dl_status = ' . DL_STATUS_COMPLETE . '
|
||||
');
|
||||
|
||||
// Get SUMMARIZED user's dlstat
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_LAST_USERSTAT . "
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . NEW_BB_BT_LAST_USERSTAT . '
|
||||
(user_id, up_add, down_add, release_add, bonus_add, speed_up, speed_down)
|
||||
SELECT
|
||||
user_id, SUM(up_add), SUM(down_add), SUM(release_add), SUM(bonus_add), SUM(speed_up), SUM(speed_down)
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
FROM ' . NEW_BB_BT_LAST_TORSTAT . '
|
||||
GROUP BY user_id
|
||||
");
|
||||
');
|
||||
|
||||
// Update TOTAL user's dlstat
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_BT_USERS . " u,
|
||||
" . NEW_BB_BT_LAST_USERSTAT . " ub
|
||||
' . BB_BT_USERS . ' u,
|
||||
' . NEW_BB_BT_LAST_USERSTAT . ' ub
|
||||
SET
|
||||
u.u_up_total = u.u_up_total + ub.up_add,
|
||||
u.u_down_total = u.u_down_total + ub.down_add,
|
||||
|
@ -113,47 +113,47 @@ if (config('tracker.update_dlstat')) {
|
|||
u.up_release_today = u.up_release_today + ub.release_add,
|
||||
u.up_bonus_today = u.up_bonus_today + ub.bonus_add
|
||||
WHERE u.user_id = ub.user_id
|
||||
");
|
||||
');
|
||||
|
||||
// Delete from dl_list what exists in BUF but not exsits in NEW
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE dl
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
INNER JOIN " . NEW_BB_BT_LAST_TORSTAT . " buf USING(user_id, topic_id)
|
||||
FROM ' . BB_BT_DLSTATUS . ' dl
|
||||
INNER JOIN ' . NEW_BB_BT_LAST_TORSTAT . ' buf USING(user_id, topic_id)
|
||||
WHERE buf.user_id IS NULL
|
||||
AND buf.topic_id IS NULL
|
||||
");
|
||||
');
|
||||
|
||||
// Update DL-Status
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO " . BB_BT_DLSTATUS . "
|
||||
OLD_DB()->query('
|
||||
REPLACE INTO ' . BB_BT_DLSTATUS . '
|
||||
(user_id, topic_id, user_status)
|
||||
SELECT
|
||||
user_id, topic_id, dl_status
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
");
|
||||
FROM ' . NEW_BB_BT_LAST_TORSTAT . '
|
||||
');
|
||||
|
||||
// Update PER TORRENT DL-Status (for "completed" counter)
|
||||
OLD_DB()->query("
|
||||
INSERT IGNORE INTO " . BB_BT_TORSTAT . "
|
||||
OLD_DB()->query('
|
||||
INSERT IGNORE INTO ' . BB_BT_TORSTAT . '
|
||||
(topic_id, user_id)
|
||||
SELECT
|
||||
topic_id, user_id
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
WHERE dl_status = " . DL_STATUS_COMPLETE . "
|
||||
");
|
||||
FROM ' . NEW_BB_BT_LAST_TORSTAT . '
|
||||
WHERE dl_status = ' . DL_STATUS_COMPLETE . '
|
||||
');
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
RENAME TABLE
|
||||
" . BB_BT_LAST_TORSTAT . " TO " . OLD_BB_BT_LAST_TORSTAT . ",
|
||||
" . NEW_BB_BT_LAST_TORSTAT . " TO " . BB_BT_LAST_TORSTAT . "
|
||||
");
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_TORSTAT . ", " . OLD_BB_BT_LAST_TORSTAT);
|
||||
' . BB_BT_LAST_TORSTAT . ' TO ' . OLD_BB_BT_LAST_TORSTAT . ',
|
||||
' . NEW_BB_BT_LAST_TORSTAT . ' TO ' . BB_BT_LAST_TORSTAT . '
|
||||
');
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_LAST_TORSTAT . ', ' . OLD_BB_BT_LAST_TORSTAT);
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
RENAME TABLE
|
||||
" . BB_BT_LAST_USERSTAT . " TO " . OLD_BB_BT_LAST_USERSTAT . ",
|
||||
" . NEW_BB_BT_LAST_USERSTAT . " TO " . BB_BT_LAST_USERSTAT . "
|
||||
");
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_USERSTAT . ", " . OLD_BB_BT_LAST_USERSTAT);
|
||||
' . BB_BT_LAST_USERSTAT . ' TO ' . OLD_BB_BT_LAST_USERSTAT . ',
|
||||
' . NEW_BB_BT_LAST_USERSTAT . ' TO ' . BB_BT_LAST_USERSTAT . '
|
||||
');
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_LAST_USERSTAT . ', ' . OLD_BB_BT_LAST_USERSTAT);
|
||||
|
|
|
@ -13,40 +13,40 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
if (config('tp.ocelot.enabled')) {
|
||||
// Update TORRENT "completed" counters
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_BT_TORRENTS . " tor,
|
||||
" . BB_BT_TRACKER_SNAP . " snap
|
||||
' . BB_BT_TORRENTS . ' tor,
|
||||
' . BB_BT_TRACKER_SNAP . ' snap
|
||||
SET
|
||||
tor.complete_count = snap.complete
|
||||
WHERE
|
||||
tor.topic_id = snap.topic_id
|
||||
");
|
||||
');
|
||||
} else {
|
||||
// Get complete counts
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
CREATE TEMPORARY TABLE tmp_complete_count
|
||||
SELECT
|
||||
topic_id, COUNT(*) AS compl_cnt
|
||||
FROM " . BB_BT_TORSTAT . "
|
||||
FROM ' . BB_BT_TORSTAT . '
|
||||
WHERE completed = 0
|
||||
GROUP BY topic_id
|
||||
");
|
||||
');
|
||||
|
||||
// Update USER "completed" counters
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TORSTAT . " SET completed = 1");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TORSTAT . ' SET completed = 1');
|
||||
|
||||
// Update TORRENT "completed" counters
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_BT_TORRENTS . " tor,
|
||||
' . BB_BT_TORRENTS . ' tor,
|
||||
tmp_complete_count tmp
|
||||
SET
|
||||
tor.complete_count = tor.complete_count + tmp.compl_cnt
|
||||
WHERE
|
||||
tor.topic_id = tmp.topic_id
|
||||
");
|
||||
');
|
||||
|
||||
// Drop tmp table
|
||||
OLD_DB()->query("DROP TEMPORARY TABLE tmp_complete_count");
|
||||
OLD_DB()->query('DROP TEMPORARY TABLE tmp_complete_count');
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ $limit_sql = 3000;
|
|||
|
||||
$topics_sql = $attach_sql = array();
|
||||
|
||||
$sql = "SELECT topic_id, attach_id
|
||||
FROM " . BB_BT_TORRENTS . "
|
||||
$sql = 'SELECT topic_id, attach_id
|
||||
FROM ' . BB_BT_TORRENTS . "
|
||||
WHERE reg_time < $never_seen_time
|
||||
AND seeder_last_seen < $last_seen_time
|
||||
LIMIT $limit_sql";
|
||||
|
@ -36,16 +36,16 @@ $attach_sql = implode(',', $attach_sql);
|
|||
|
||||
if ($dead_tor_sql && $attach_sql) {
|
||||
// Delete torstat
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_BT_TORSTAT . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_BT_TORSTAT . "
|
||||
WHERE topic_id IN($dead_tor_sql)
|
||||
");
|
||||
|
||||
// Update attach
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BB_ATTACHMENTS_DESC . " a,
|
||||
" . BB_BT_TORRENTS . " tor
|
||||
' . BB_ATTACHMENTS_DESC . ' a,
|
||||
' . BB_BT_TORRENTS . " tor
|
||||
SET
|
||||
a.tracker_status = 0,
|
||||
a.download_count = tor.complete_count
|
||||
|
@ -55,8 +55,8 @@ if ($dead_tor_sql && $attach_sql) {
|
|||
");
|
||||
|
||||
// Remove torrents
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_BT_TORRENTS . "
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_BT_TORRENTS . "
|
||||
WHERE topic_id IN($dead_tor_sql)
|
||||
");
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ if (!config('tp.ocelot.enabled')) {
|
|||
define('NEW_BB_BT_TRACKER_SNAP', 'new_tracker_snap');
|
||||
define('OLD_BB_BT_TRACKER_SNAP', 'old_tracker_snap');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TRACKER_SNAP . ", " . OLD_BB_BT_TRACKER_SNAP);
|
||||
OLD_DB()->query("CREATE TABLE " . NEW_BB_BT_TRACKER_SNAP . " LIKE " . BB_BT_TRACKER_SNAP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_TRACKER_SNAP . ', ' . OLD_BB_BT_TRACKER_SNAP);
|
||||
OLD_DB()->query('CREATE TABLE ' . NEW_BB_BT_TRACKER_SNAP . ' LIKE ' . BB_BT_TRACKER_SNAP);
|
||||
}
|
||||
|
||||
$per_cycle = 50000;
|
||||
$row = OLD_DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_BT_TRACKER);
|
||||
$row = OLD_DB()->fetch_row('SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM ' . BB_BT_TRACKER);
|
||||
$start_id = (int)$row['start_id'];
|
||||
$finish_id = (int)$row['finish_id'];
|
||||
|
||||
|
@ -36,19 +36,19 @@ while (true) {
|
|||
$val = array();
|
||||
|
||||
if (!config('tp.ocelot.enabled')) {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
topic_id, SUM(seeder) AS seeders, (COUNT(*) - SUM(seeder)) AS leechers,
|
||||
SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
FROM ' . BB_BT_TRACKER . "
|
||||
WHERE topic_id BETWEEN $start_id AND $end_id
|
||||
GROUP BY topic_id
|
||||
";
|
||||
} else {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
topic_id, SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
FROM ' . BB_BT_TRACKER . "
|
||||
WHERE topic_id BETWEEN $start_id AND $end_id
|
||||
GROUP BY topic_id
|
||||
";
|
||||
|
@ -60,18 +60,18 @@ while (true) {
|
|||
|
||||
if ($val) {
|
||||
if (!config('tp.ocelot.enabled')) {
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO " . NEW_BB_BT_TRACKER_SNAP . "
|
||||
OLD_DB()->query('
|
||||
REPLACE INTO ' . NEW_BB_BT_TRACKER_SNAP . '
|
||||
(topic_id, seeders, leechers, speed_up, speed_down)
|
||||
VALUES(" . implode('),(', $val) . ")
|
||||
");
|
||||
VALUES(' . implode('),(', $val) . ')
|
||||
');
|
||||
} else {
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . BB_BT_TRACKER_SNAP . "
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . BB_BT_TRACKER_SNAP . '
|
||||
(topic_id, speed_up, speed_down)
|
||||
VALUES(" . implode('),(', $val) . ")
|
||||
VALUES(' . implode('),(', $val) . ')
|
||||
ON DUPLICATE KEY UPDATE speed_up = VALUES(speed_up), speed_down = VALUES(speed_down)
|
||||
");
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,13 @@ while (true) {
|
|||
}
|
||||
|
||||
if (!config('tp.ocelot.enabled')) {
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
RENAME TABLE
|
||||
" . BB_BT_TRACKER_SNAP . " TO " . OLD_BB_BT_TRACKER_SNAP . ",
|
||||
" . NEW_BB_BT_TRACKER_SNAP . " TO " . BB_BT_TRACKER_SNAP . "
|
||||
");
|
||||
' . BB_BT_TRACKER_SNAP . ' TO ' . OLD_BB_BT_TRACKER_SNAP . ',
|
||||
' . NEW_BB_BT_TRACKER_SNAP . ' TO ' . BB_BT_TRACKER_SNAP . '
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TRACKER_SNAP . ", " . OLD_BB_BT_TRACKER_SNAP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_TRACKER_SNAP . ', ' . OLD_BB_BT_TRACKER_SNAP);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -98,29 +98,29 @@ if (!config('tp.ocelot.enabled')) {
|
|||
define('NEW_BB_BT_DLSTATUS_SNAP', 'new_dlstatus_snap');
|
||||
define('OLD_BB_BT_DLSTATUS_SNAP', 'old_dlstatus_snap');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_DLSTATUS_SNAP . ', ' . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
OLD_DB()->query("CREATE TABLE " . NEW_BB_BT_DLSTATUS_SNAP . " LIKE " . BB_BT_DLSTATUS_SNAP);
|
||||
OLD_DB()->query('CREATE TABLE ' . NEW_BB_BT_DLSTATUS_SNAP . ' LIKE ' . BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
if (config('tp.bt_show_dl_list') && config('tp.bt_dl_list_only_count')) {
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_DLSTATUS_SNAP . "
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . NEW_BB_BT_DLSTATUS_SNAP . '
|
||||
(topic_id, dl_status, users_count)
|
||||
SELECT
|
||||
topic_id, user_status, COUNT(*)
|
||||
FROM " . BB_BT_DLSTATUS . "
|
||||
WHERE user_status != " . DL_STATUS_RELEASER . "
|
||||
FROM ' . BB_BT_DLSTATUS . '
|
||||
WHERE user_status != ' . DL_STATUS_RELEASER . '
|
||||
GROUP BY topic_id, user_status
|
||||
");
|
||||
');
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
RENAME TABLE
|
||||
" . BB_BT_DLSTATUS_SNAP . " TO " . OLD_BB_BT_DLSTATUS_SNAP . ",
|
||||
" . NEW_BB_BT_DLSTATUS_SNAP . " TO " . BB_BT_DLSTATUS_SNAP . "
|
||||
");
|
||||
' . BB_BT_DLSTATUS_SNAP . ' TO ' . OLD_BB_BT_DLSTATUS_SNAP . ',
|
||||
' . NEW_BB_BT_DLSTATUS_SNAP . ' TO ' . BB_BT_DLSTATUS_SNAP . '
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_DLSTATUS_SNAP . ', ' . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
//
|
||||
// TORHELP
|
||||
|
@ -138,14 +138,14 @@ if (config('tp.torhelp_enabled')) {
|
|||
define('NEW_BB_BT_TORHELP', 'new_torhelp');
|
||||
define('OLD_BB_BT_TORHELP', 'old_torhelp');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_TORHELP . ', ' . OLD_BB_BT_TORHELP);
|
||||
|
||||
OLD_DB()->query("CREATE TABLE " . NEW_BB_BT_TORHELP . " LIKE " . BB_BT_TORHELP);
|
||||
OLD_DB()->query('CREATE TABLE ' . NEW_BB_BT_TORHELP . ' LIKE ' . BB_BT_TORHELP);
|
||||
|
||||
// Select users
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT DISTINCT session_user_id AS uid
|
||||
FROM " . BB_SESSIONS . "
|
||||
FROM ' . BB_SESSIONS . "
|
||||
WHERE session_time > (UNIX_TIMESTAMP() - $user_last_seen_online*60)
|
||||
AND session_user_id != " . GUEST_UID . "
|
||||
ORDER BY session_time DESC
|
||||
|
@ -158,13 +158,13 @@ if (config('tp.torhelp_enabled')) {
|
|||
}
|
||||
|
||||
if ($online_users_csv = implode(',', $online_users_ary)) {
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_TORHELP . " (user_id, topic_id_csv)
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . NEW_BB_BT_TORHELP . ' (user_id, topic_id_csv)
|
||||
SELECT
|
||||
dl.user_id, GROUP_CONCAT(dl.topic_id)
|
||||
FROM " . BB_BT_TRACKER_SNAP . " trsn
|
||||
INNER JOIN " . BB_BT_TORRENTS . " tor ON (tor.topic_id = trsn.topic_id)
|
||||
INNER JOIN " . BB_BT_DLSTATUS . " dl ON (dl.topic_id = tor.topic_id)
|
||||
FROM ' . BB_BT_TRACKER_SNAP . ' trsn
|
||||
INNER JOIN ' . BB_BT_TORRENTS . ' tor ON (tor.topic_id = trsn.topic_id)
|
||||
INNER JOIN ' . BB_BT_DLSTATUS . " dl ON (dl.topic_id = tor.topic_id)
|
||||
WHERE
|
||||
trsn.seeders <= $tor_min_seeders
|
||||
AND trsn.leechers >= $tor_min_leechers
|
||||
|
@ -179,13 +179,13 @@ if (config('tp.torhelp_enabled')) {
|
|||
");
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
RENAME TABLE
|
||||
" . BB_BT_TORHELP . " TO " . OLD_BB_BT_TORHELP . ",
|
||||
" . NEW_BB_BT_TORHELP . " TO " . BB_BT_TORHELP . "
|
||||
");
|
||||
' . BB_BT_TORHELP . ' TO ' . OLD_BB_BT_TORHELP . ',
|
||||
' . NEW_BB_BT_TORHELP . ' TO ' . BB_BT_TORHELP . '
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
|
||||
OLD_DB()->query('DROP TABLE IF EXISTS ' . NEW_BB_BT_TORHELP . ', ' . OLD_BB_BT_TORHELP);
|
||||
}
|
||||
|
||||
OLD_DB()->expect_slow_query(10);
|
||||
|
|
|
@ -23,9 +23,9 @@ if (config('tp.seed_bonus_enabled') && config('tp.seed_bonus_points') && config(
|
|||
|
||||
$tor_size = (config('tp.seed_bonus_tor_size') * 1073741824);
|
||||
|
||||
OLD_DB()->query("INSERT INTO tmp_bonus
|
||||
OLD_DB()->query('INSERT INTO tmp_bonus
|
||||
SELECT bt.user_id, count(bt.seeder) AS release_count
|
||||
FROM " . BB_BT_TRACKER . " bt, " . BB_BT_TORRENTS . " tor
|
||||
FROM ' . BB_BT_TRACKER . ' bt, ' . BB_BT_TORRENTS . " tor
|
||||
WHERE tor.topic_id = bt.topic_id
|
||||
AND tor.size > $tor_size
|
||||
AND bt.seeder > 0
|
||||
|
@ -44,8 +44,8 @@ if (config('tp.seed_bonus_enabled') && config('tp.seed_bonus_points') && config(
|
|||
$release = (int)$seed_release[$i];
|
||||
$user_regdate = (TIMENOW - config('tp.seed_bonus_user_regdate') * 86400);
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USERS . ' u, ' . BB_BT_USERS . " bu, tmp_bonus b
|
||||
SET
|
||||
u.user_points = u.user_points + '$user_points',
|
||||
bu.points_today = bu.points_today + '$user_points',
|
||||
|
@ -56,9 +56,9 @@ if (config('tp.seed_bonus_enabled') && config('tp.seed_bonus_points') && config(
|
|||
AND b.release_count <= $release
|
||||
AND u.user_regdate < $user_regdate
|
||||
AND u.user_active = 1
|
||||
AND u.user_id not IN(" . EXCLUDED_USERS . ")
|
||||
");
|
||||
AND u.user_id not IN(" . EXCLUDED_USERS . ')
|
||||
');
|
||||
}
|
||||
|
||||
OLD_DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_bonus");
|
||||
OLD_DB()->query('DROP TEMPORARY TABLE IF EXISTS tmp_bonus');
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@ if (!defined('BB_ROOT')) {
|
|||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
UPDATE
|
||||
" . BUF_LAST_SEEDER . " b,
|
||||
" . BB_BT_TORRENTS . " tor
|
||||
' . BUF_LAST_SEEDER . ' b,
|
||||
' . BB_BT_TORRENTS . ' tor
|
||||
SET
|
||||
tor.seeder_last_seen = b.seeder_last_seen
|
||||
WHERE
|
||||
tor.topic_id = b.topic_id
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("TRUNCATE TABLE " . BUF_LAST_SEEDER);
|
||||
OLD_DB()->query('TRUNCATE TABLE ' . BUF_LAST_SEEDER);
|
||||
|
|
|
@ -14,7 +14,7 @@ if (!defined('BB_ROOT')) {
|
|||
require_once INC_DIR . '/functions_atom.php';
|
||||
|
||||
$timecheck = TIMENOW - 600;
|
||||
$forums_data = OLD_DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM " . BB_FORUMS);
|
||||
$forums_data = OLD_DB()->fetch_rowset('SELECT forum_id, allow_reg_tracker, forum_name FROM ' . BB_FORUMS);
|
||||
|
||||
if (file_exists(config('tp.atom.path') . '/f/0.atom')) {
|
||||
if (filemtime(config('tp.atom.path') . '/f/0.atom') <= $timecheck) {
|
||||
|
|
|
@ -12,15 +12,15 @@ if (!defined('BB_ROOT')) {
|
|||
}
|
||||
|
||||
// Don't count on forbidden extensions table, because it is not allowed to allow forbidden extensions at all
|
||||
$extensions = OLD_DB()->fetch_rowset("
|
||||
$extensions = OLD_DB()->fetch_rowset('
|
||||
SELECT
|
||||
e.extension, g.cat_id, g.download_mode, g.upload_icon
|
||||
FROM
|
||||
" . BB_EXTENSIONS . " e,
|
||||
" . BB_EXTENSION_GROUPS . " g
|
||||
' . BB_EXTENSIONS . ' e,
|
||||
' . BB_EXTENSION_GROUPS . ' g
|
||||
WHERE
|
||||
e.group_id = g.group_id
|
||||
AND g.allow_group = 1
|
||||
");
|
||||
');
|
||||
|
||||
$this->store('attach_extensions', $extensions);
|
||||
|
|
|
@ -44,19 +44,19 @@ $forum_store_fields += array_flip(array(
|
|||
));
|
||||
|
||||
// Categories
|
||||
$sql = "SELECT * FROM " . BB_CATEGORIES . " ORDER BY cat_order";
|
||||
$sql = 'SELECT * FROM ' . BB_CATEGORIES . ' ORDER BY cat_order';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$data['c'][$row['cat_id']] = $row;
|
||||
$data['cat_title_html'][$row['cat_id']] = htmlCHR($row['cat_title']);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT f.*
|
||||
FROM " . BB_FORUMS . " f, " . BB_CATEGORIES . " c
|
||||
FROM ' . BB_FORUMS . ' f, ' . BB_CATEGORIES . ' c
|
||||
WHERE f.cat_id = c.cat_id
|
||||
ORDER BY c.cat_order, f.forum_order
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$fid = $row['forum_id'];
|
||||
|
@ -131,9 +131,9 @@ $this->store('viewtopic_forum_select', $data);
|
|||
if (config('tp.show_latest_news') && $news_forum_ids = config('tp.latest_news_forum_id')) {
|
||||
$news_count = max(config('tp.latest_news_count'), 1);
|
||||
|
||||
$data = OLD_DB()->fetch_rowset("
|
||||
$data = OLD_DB()->fetch_rowset('
|
||||
SELECT topic_id, topic_time, topic_title, forum_id
|
||||
FROM " . BB_TOPICS . "
|
||||
FROM ' . BB_TOPICS . "
|
||||
WHERE forum_id IN ($news_forum_ids)
|
||||
AND topic_moved_id = 0
|
||||
ORDER BY topic_time DESC
|
||||
|
@ -149,9 +149,9 @@ if (config('tp.show_latest_news') && $news_forum_ids = config('tp.latest_news_fo
|
|||
if (config('tp.show_network_news') && $net_forum_ids = config('tp.network_news_forum_id')) {
|
||||
$net_count = max(config('tp.network_news_count'), 1);
|
||||
|
||||
$data = OLD_DB()->fetch_rowset("
|
||||
$data = OLD_DB()->fetch_rowset('
|
||||
SELECT topic_id, topic_time, topic_title, forum_id
|
||||
FROM " . BB_TOPICS . "
|
||||
FROM ' . BB_TOPICS . "
|
||||
WHERE forum_id IN ($net_forum_ids)
|
||||
AND topic_moved_id = 0
|
||||
ORDER BY topic_time DESC
|
||||
|
|
|
@ -22,16 +22,16 @@ $data = array(
|
|||
|
||||
// name_users
|
||||
// mod_users
|
||||
$sql = "
|
||||
$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
|
||||
' . BB_AUTH_ACCESS . ' aa,
|
||||
' . BB_USER_GROUP . ' ug,
|
||||
' . BB_GROUPS . ' g,
|
||||
' . BB_USERS . ' u
|
||||
WHERE
|
||||
aa.forum_perm & " . BF_AUTH_MOD . "
|
||||
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
|
||||
|
@ -41,7 +41,7 @@ $sql = "
|
|||
aa.forum_id, u.user_id
|
||||
ORDER BY
|
||||
u.username
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$data['name_users'][$row['user_id']] = $row['username'];
|
||||
|
@ -50,22 +50,22 @@ foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
|||
|
||||
// name_groups
|
||||
// mod_groups
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
aa.forum_id, g.group_id, g.group_name
|
||||
FROM
|
||||
" . BB_AUTH_ACCESS . " aa,
|
||||
" . BB_GROUPS . " g
|
||||
' . BB_AUTH_ACCESS . ' aa,
|
||||
' . BB_GROUPS . ' g
|
||||
WHERE
|
||||
aa.forum_perm & " . BF_AUTH_MOD . "
|
||||
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 . "
|
||||
AND g.group_type != ' . GROUP_HIDDEN . '
|
||||
GROUP BY
|
||||
aa.forum_id, g.group_id
|
||||
ORDER BY
|
||||
g.group_name
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$data['name_groups'][$row['group_id']] = $row['group_name'];
|
||||
|
@ -73,16 +73,16 @@ foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
|||
}
|
||||
|
||||
// moderators
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
u.user_id, u.username
|
||||
FROM
|
||||
" . BB_AUTH_ACCESS . " aa,
|
||||
" . BB_USER_GROUP . " ug,
|
||||
" . BB_GROUPS . " g,
|
||||
" . BB_USERS . " u
|
||||
' . BB_AUTH_ACCESS . ' aa,
|
||||
' . BB_USER_GROUP . ' ug,
|
||||
' . BB_GROUPS . ' g,
|
||||
' . BB_USERS . ' u
|
||||
WHERE
|
||||
aa.forum_perm & " . BF_AUTH_MOD . "
|
||||
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
|
||||
|
@ -91,19 +91,19 @@ $sql = "
|
|||
u.user_id
|
||||
ORDER BY
|
||||
u.username
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$data['moderators'][$row['user_id']] = $row['username'];
|
||||
}
|
||||
|
||||
// admins
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT user_id, username
|
||||
FROM " . BB_USERS . "
|
||||
WHERE user_level = " . ADMIN . "
|
||||
FROM ' . BB_USERS . '
|
||||
WHERE user_level = ' . ADMIN . '
|
||||
ORDER BY username
|
||||
";
|
||||
';
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$data['admins'][$row['user_id']] = $row['username'];
|
||||
|
|
|
@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
$ranks = array();
|
||||
|
||||
$sql = "SELECT rank_id, rank_title, rank_image, rank_style FROM " . BB_RANKS;
|
||||
$sql = 'SELECT rank_id, rank_title, rank_image, rank_style FROM ' . BB_RANKS;
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$ranks[$row['rank_id']] = $row;
|
||||
|
|
|
@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
$smilies = [];
|
||||
|
||||
$rowset = OLD_DB()->fetch_rowset("SELECT * FROM " . BB_SMILIES);
|
||||
$rowset = OLD_DB()->fetch_rowset('SELECT * FROM ' . BB_SMILIES);
|
||||
sort($rowset);
|
||||
|
||||
foreach ($rowset as $smile) {
|
||||
|
|
|
@ -14,27 +14,27 @@ if (!defined('BB_ROOT')) {
|
|||
$data = [];
|
||||
|
||||
// usercount
|
||||
$row = OLD_DB()->fetch_row("SELECT COUNT(*) AS usercount FROM " . BB_USERS . " WHERE user_id NOT IN(" . EXCLUDED_USERS . ")");
|
||||
$row = OLD_DB()->fetch_row('SELECT COUNT(*) AS usercount FROM ' . BB_USERS . ' WHERE user_id NOT IN(' . EXCLUDED_USERS . ')');
|
||||
$data['usercount'] = number_format($row['usercount']);
|
||||
|
||||
// newestuser
|
||||
$row = OLD_DB()->fetch_row("SELECT user_id, username, user_rank FROM " . BB_USERS . " WHERE user_active = 1 ORDER BY user_id DESC LIMIT 1");
|
||||
$row = OLD_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 = OLD_DB()->fetch_row("SELECT SUM(forum_topics) AS topiccount, SUM(forum_posts) AS postcount FROM " . BB_FORUMS);
|
||||
$row = OLD_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 (config('tp.tor_stats')) {
|
||||
// torrents stat
|
||||
$row = OLD_DB()->fetch_row("SELECT COUNT(topic_id) AS torrentcount, SUM(size) AS size FROM " . BB_BT_TORRENTS);
|
||||
$row = OLD_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 = OLD_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);
|
||||
$row = OLD_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']);
|
||||
|
@ -43,9 +43,9 @@ if (config('tp.tor_stats')) {
|
|||
|
||||
// gender stat
|
||||
if (config('tp.gender')) {
|
||||
$male = OLD_DB()->fetch_row("SELECT COUNT(user_id) AS male FROM " . BB_USERS . " WHERE user_gender = " . MALE . " AND user_id NOT IN(" . EXCLUDED_USERS . ")");
|
||||
$female = OLD_DB()->fetch_row("SELECT COUNT(user_id) AS female FROM " . BB_USERS . " WHERE user_gender = " . FEMALE . " AND user_id NOT IN(" . EXCLUDED_USERS . ")");
|
||||
$unselect = OLD_DB()->fetch_row("SELECT COUNT(user_id) AS unselect FROM " . BB_USERS . " WHERE user_gender = 0 AND user_id NOT IN(" . EXCLUDED_USERS . ")");
|
||||
$male = OLD_DB()->fetch_row('SELECT COUNT(user_id) AS male FROM ' . BB_USERS . ' WHERE user_gender = ' . MALE . ' AND user_id NOT IN(' . EXCLUDED_USERS . ')');
|
||||
$female = OLD_DB()->fetch_row('SELECT COUNT(user_id) AS female FROM ' . BB_USERS . ' WHERE user_gender = ' . FEMALE . ' AND user_id NOT IN(' . EXCLUDED_USERS . ')');
|
||||
$unselect = OLD_DB()->fetch_row('SELECT COUNT(user_id) AS unselect FROM ' . BB_USERS . ' WHERE user_gender = 0 AND user_id NOT IN(' . EXCLUDED_USERS . ')');
|
||||
|
||||
$data['male'] = $male['male'];
|
||||
$data['female'] = $female['female'];
|
||||
|
@ -54,9 +54,9 @@ if (config('tp.gender')) {
|
|||
|
||||
// birthday stat
|
||||
if (config('tp.birthday_check_day') && config('tp.birthday_enabled')) {
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT user_id, username, user_rank , user_birthday
|
||||
FROM " . BB_USERS . "
|
||||
WHERE user_id NOT IN(" . EXCLUDED_USERS . ")
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT user_id, username, user_rank , user_birthday
|
||||
FROM ' . BB_USERS . '
|
||||
WHERE user_id NOT IN(' . EXCLUDED_USERS . ")
|
||||
AND user_birthday != '0000-00-00'
|
||||
AND user_active = 1
|
||||
ORDER BY user_level DESC, username
|
||||
|
|
|
@ -181,7 +181,7 @@ function bf($int, $bf_array_name, $key)
|
|||
|
||||
function setbit(&$int, $bit_num, $on)
|
||||
{
|
||||
return ($on) ? $int |= (1 << $bit_num) : $int &= ~(1 << $bit_num);
|
||||
return $on ? $int |= (1 << $bit_num) : $int &= ~(1 << $bit_num);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -262,16 +262,16 @@ function auth_user($type, $forum_id, $ug_data, array $f_access = array(), $group
|
|||
//
|
||||
// Get user or group permissions
|
||||
//
|
||||
$forum_match_sql = ($forum_id != AUTH_LIST_ALL) ? "AND aa.forum_id = " . (int)$forum_id : '';
|
||||
$forum_match_sql = ($forum_id != AUTH_LIST_ALL) ? 'AND aa.forum_id = ' . (int)$forum_id : '';
|
||||
|
||||
// GROUP mode
|
||||
if (!empty($ug_data['group_id'])) {
|
||||
$is_guest = false;
|
||||
$is_admin = false;
|
||||
|
||||
$sql = "SELECT aa.forum_id, aa.forum_perm
|
||||
FROM " . BB_AUTH_ACCESS . " aa
|
||||
WHERE aa.group_id = " . (int)$ug_data['group_id'] . "
|
||||
$sql = 'SELECT aa.forum_id, aa.forum_perm
|
||||
FROM ' . BB_AUTH_ACCESS . ' aa
|
||||
WHERE aa.group_id = ' . (int)$ug_data['group_id'] . "
|
||||
$forum_match_sql";
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
|
@ -285,15 +285,15 @@ function auth_user($type, $forum_id, $ug_data, array $f_access = array(), $group
|
|||
if ($group_perm != UG_PERM_BOTH) {
|
||||
$group_single_user = ($group_perm == UG_PERM_USER_ONLY) ? 1 : 0;
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
aa.forum_id, BIT_OR(aa.forum_perm) AS forum_perm
|
||||
FROM
|
||||
" . BB_USER_GROUP . " ug,
|
||||
" . BB_GROUPS . " g,
|
||||
" . BB_AUTH_ACCESS . " aa
|
||||
' . BB_USER_GROUP . ' ug,
|
||||
' . BB_GROUPS . ' g,
|
||||
' . BB_AUTH_ACCESS . ' aa
|
||||
WHERE
|
||||
ug.user_id = " . (int)$ug_data['user_id'] . "
|
||||
ug.user_id = ' . (int)$ug_data['user_id'] . "
|
||||
AND ug.user_pending = 0
|
||||
AND g.group_id = ug.group_id
|
||||
AND g.group_single_user = $group_single_user
|
||||
|
@ -307,9 +307,9 @@ function auth_user($type, $forum_id, $ug_data, array $f_access = array(), $group
|
|||
}
|
||||
} else {
|
||||
if (!$is_guest && !$is_admin) {
|
||||
$sql = "SELECT SQL_CACHE aa.forum_id, aa.forum_perm
|
||||
FROM " . BB_AUTH_ACCESS_SNAP . " aa
|
||||
WHERE aa.user_id = " . (int)$ug_data['user_id'] . "
|
||||
$sql = 'SELECT SQL_CACHE aa.forum_id, aa.forum_perm
|
||||
FROM ' . BB_AUTH_ACCESS_SNAP . ' aa
|
||||
WHERE aa.user_id = ' . (int)$ug_data['user_id'] . "
|
||||
$forum_match_sql";
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
|
@ -393,7 +393,7 @@ function get_select($select, $selected = null, $return_as = 'html', $first_opt =
|
|||
|
||||
switch ($select) {
|
||||
case 'groups':
|
||||
$sql = "SELECT group_id, group_name FROM " . BB_GROUPS . " WHERE group_single_user = 0 ORDER BY group_name";
|
||||
$sql = 'SELECT group_id, group_name FROM ' . BB_GROUPS . ' WHERE group_single_user = 0 ORDER BY group_name';
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$select_ary[$row['group_name']] = $row['group_id'];
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ function get_select($select, $selected = null, $return_as = 'html', $first_opt =
|
|||
break;
|
||||
|
||||
case 'forum_tpl':
|
||||
$sql = "SELECT tpl_id, tpl_name FROM " . BB_TOPIC_TPL . " ORDER BY tpl_name";
|
||||
$sql = 'SELECT tpl_id, tpl_name FROM ' . BB_TOPIC_TPL . ' ORDER BY tpl_name';
|
||||
$select_ary[$first_opt] = 0;
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$select_ary[$row['tpl_name']] = $row['tpl_id'];
|
||||
|
@ -484,7 +484,7 @@ function declension($int, $expressions, $format = '%1$s %2$s')
|
|||
}
|
||||
}
|
||||
|
||||
return ($format) ? sprintf($format, $int, $result) : $result;
|
||||
return $format ? sprintf($format, $int, $result) : $result;
|
||||
}
|
||||
|
||||
// http://forum.dklab.ru/php/advises/UrlreplaceargChangesValueOfParameterInUrl.html
|
||||
|
@ -536,7 +536,7 @@ function humn_size($size, $rounder = null, $min = null, $space = ' ')
|
|||
$ext = 'KB';
|
||||
$rounder = 1;
|
||||
} else {
|
||||
for ($i = 1, $cnt = count($sizes); ($i < $cnt && $size >= 1024); $i++) {
|
||||
for ($i = 1, $cnt = count($sizes); $i < $cnt && $size >= 1024; $i++) {
|
||||
$size /= 1024;
|
||||
$ext = $sizes[$i];
|
||||
$rnd = $rounders[$i];
|
||||
|
@ -553,7 +553,7 @@ function bt_show_ip($ip, $port = '')
|
|||
{
|
||||
if (IS_AM) {
|
||||
$ip = decode_ip($ip);
|
||||
$ip .= ($port) ? ":$port" : '';
|
||||
$ip .= $port ? ":$port" : '';
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
@ -584,7 +584,7 @@ function checkbox_get_val(&$key, &$val, $default = 1, $on = 1, $off = 0)
|
|||
} elseif (!isset($_REQUEST[$key]) && isset($_REQUEST['prev_' . $key])) {
|
||||
$val = $off;
|
||||
} elseif (isset($previous_settings[$key]) && (!IS_GUEST || !empty($search_id))) {
|
||||
$val = ($previous_settings[$key]) ? $on : $off;
|
||||
$val = $previous_settings[$key] ? $on : $off;
|
||||
} else {
|
||||
$val = $default;
|
||||
}
|
||||
|
@ -596,7 +596,7 @@ function select_get_val($key, &$val, $options_ary, $default, $num = true)
|
|||
|
||||
if (isset($_REQUEST[$key]) && is_string($_REQUEST[$key])) {
|
||||
if (isset($options_ary[$_REQUEST[$key]])) {
|
||||
$val = ($num) ? (int)$_REQUEST[$key] : $_REQUEST[$key];
|
||||
$val = $num ? (int)$_REQUEST[$key] : $_REQUEST[$key];
|
||||
}
|
||||
} elseif (isset($previous_settings[$key])) {
|
||||
$val = $previous_settings[$key];
|
||||
|
@ -629,7 +629,7 @@ function set_var(&$result, $var, $type, $multibyte = false, $strip = true)
|
|||
}
|
||||
}
|
||||
|
||||
$result = ($strip) ? stripslashes($result) : $result;
|
||||
$result = $strip ? stripslashes($result) : $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,13 +642,13 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false)
|
|||
{
|
||||
if (!$cookie && isset($_COOKIE[$var_name])) {
|
||||
if (!isset($_GET[$var_name]) && !isset($_POST[$var_name])) {
|
||||
return (is_array($default)) ? array() : $default;
|
||||
return is_array($default) ? array() : $default;
|
||||
}
|
||||
$_REQUEST[$var_name] = $_POST[$var_name] ?? $_GET[$var_name];
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) {
|
||||
return (is_array($default)) ? array() : $default;
|
||||
return is_array($default) ? array() : $default;
|
||||
}
|
||||
|
||||
$var = $_REQUEST[$var_name];
|
||||
|
@ -703,13 +703,13 @@ function get_username($user_id)
|
|||
}
|
||||
if (is_array($user_id)) {
|
||||
$usernames = array();
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN(" . get_id_csv($user_id) . ")") as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT user_id, username FROM ' . BB_USERS . ' WHERE user_id IN(' . get_id_csv($user_id) . ')') as $row) {
|
||||
$usernames[$row['user_id']] = $row['username'];
|
||||
}
|
||||
return $usernames;
|
||||
}
|
||||
|
||||
$row = OLD_DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1");
|
||||
$row = OLD_DB()->fetch_row('SELECT username FROM ' . BB_USERS . " WHERE user_id = $user_id LIMIT 1");
|
||||
return $row['username'];
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,7 @@ function get_user_id($username)
|
|||
if (empty($username)) {
|
||||
return false;
|
||||
}
|
||||
$row = OLD_DB()->fetch_row("SELECT user_id FROM " . BB_USERS . " WHERE username = '" . OLD_DB()->escape($username) . "' LIMIT 1");
|
||||
$row = OLD_DB()->fetch_row('SELECT user_id FROM ' . BB_USERS . " WHERE username = '" . OLD_DB()->escape($username) . "' LIMIT 1");
|
||||
return $row['user_id'];
|
||||
}
|
||||
|
||||
|
@ -742,20 +742,20 @@ function str_short($text, $max_length, $space = ' ')
|
|||
|
||||
function wbr($text, $max_word_length = HTML_WBR_LENGTH)
|
||||
{
|
||||
return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . "})/ui", '$1<wbr>', $text);
|
||||
return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . '})/ui', '$1<wbr>', $text);
|
||||
}
|
||||
|
||||
function get_bt_userdata($user_id)
|
||||
{
|
||||
if (!$btu = OLD_CACHE('bb_cache')->get('btu_' . $user_id)) {
|
||||
$btu = OLD_DB()->fetch_row("
|
||||
$btu = OLD_DB()->fetch_row('
|
||||
SELECT bt.*, SUM(tr.speed_up) AS speed_up, SUM(tr.speed_down) AS speed_down
|
||||
FROM " . BB_BT_USERS . " bt
|
||||
LEFT JOIN " . BB_BT_TRACKER . " tr ON (bt.user_id = tr.user_id)
|
||||
WHERE bt.user_id = " . (int)$user_id . "
|
||||
FROM ' . BB_BT_USERS . ' bt
|
||||
LEFT JOIN ' . BB_BT_TRACKER . ' tr ON (bt.user_id = tr.user_id)
|
||||
WHERE bt.user_id = ' . (int)$user_id . '
|
||||
GROUP BY bt.user_id
|
||||
LIMIT 1
|
||||
");
|
||||
');
|
||||
OLD_CACHE('bb_cache')->set('btu_' . $user_id, $btu, 300);
|
||||
}
|
||||
return $btu;
|
||||
|
@ -765,7 +765,7 @@ function get_bt_ratio($btu)
|
|||
{
|
||||
return
|
||||
(!empty($btu['u_down_total']) && $btu['u_down_total'] > MIN_DL_FOR_RATIO)
|
||||
? round((($btu['u_up_total'] + $btu['u_up_release'] + $btu['u_up_bonus']) / $btu['u_down_total']), 2)
|
||||
? round(($btu['u_up_total'] + $btu['u_up_release'] + $btu['u_up_bonus']) / $btu['u_down_total'], 2)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
@ -785,19 +785,19 @@ function show_bt_userdata($user_id)
|
|||
'USER_RATIO' => get_bt_ratio($btu),
|
||||
'MIN_DL_FOR_RATIO' => humn_size(MIN_DL_FOR_RATIO),
|
||||
'MIN_DL_BYTES' => MIN_DL_FOR_RATIO,
|
||||
'AUTH_KEY' => ($btu['auth_key']) ?: trans('messages.NONE'),
|
||||
'AUTH_KEY' => $btu['auth_key'] ?: trans('messages.NONE'),
|
||||
|
||||
'TD_DL' => humn_size($btu['down_today']),
|
||||
'TD_UL' => humn_size($btu['up_today']),
|
||||
'TD_REL' => humn_size($btu['up_release_today']),
|
||||
'TD_BONUS' => humn_size($btu['up_bonus_today']),
|
||||
'TD_POINTS' => ($btu['auth_key']) ? $btu['points_today'] : '0.00',
|
||||
'TD_POINTS' => $btu['auth_key'] ? $btu['points_today'] : '0.00',
|
||||
|
||||
'YS_DL' => humn_size($btu['down_yesterday']),
|
||||
'YS_UL' => humn_size($btu['up_yesterday']),
|
||||
'YS_REL' => humn_size($btu['up_release_yesterday']),
|
||||
'YS_BONUS' => humn_size($btu['up_bonus_yesterday']),
|
||||
'YS_POINTS' => ($btu['auth_key']) ? $btu['points_yesterday'] : '0.00',
|
||||
'YS_POINTS' => $btu['auth_key'] ? $btu['points_yesterday'] : '0.00',
|
||||
|
||||
'SPEED_UP' => humn_size($btu['speed_up'], 0, 'KB') . '/s',
|
||||
'SPEED_DOWN' => humn_size($btu['speed_down'], 0, 'KB') . '/s',
|
||||
|
@ -852,16 +852,16 @@ function get_db_stat($mode)
|
|||
{
|
||||
switch ($mode) {
|
||||
case 'usercount':
|
||||
$sql = "SELECT COUNT(user_id) AS total FROM " . BB_USERS;
|
||||
$sql = 'SELECT COUNT(user_id) AS total FROM ' . BB_USERS;
|
||||
break;
|
||||
|
||||
case 'newestuser':
|
||||
$sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id <> " . GUEST_UID . " ORDER BY user_id DESC LIMIT 1";
|
||||
$sql = 'SELECT user_id, username FROM ' . BB_USERS . ' WHERE user_id <> ' . GUEST_UID . ' ORDER BY user_id DESC LIMIT 1';
|
||||
break;
|
||||
|
||||
case 'postcount':
|
||||
case 'topiccount':
|
||||
$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total FROM " . BB_FORUMS;
|
||||
$sql = 'SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total FROM ' . BB_FORUMS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -935,21 +935,21 @@ function get_userdata($u, $force_name = false, $allow_guest = false)
|
|||
|
||||
$u_data = array();
|
||||
$name_search = false;
|
||||
$exclude_anon_sql = (!$allow_guest) ? "AND user_id != " . GUEST_UID : '';
|
||||
$exclude_anon_sql = (!$allow_guest) ? 'AND user_id != ' . GUEST_UID : '';
|
||||
|
||||
if ($force_name || !is_numeric($u)) {
|
||||
$name_search = true;
|
||||
$where_sql = "WHERE username = '" . OLD_DB()->escape(clean_username($u)) . "'";
|
||||
} else {
|
||||
$where_sql = "WHERE user_id = " . (int)$u;
|
||||
$where_sql = 'WHERE user_id = ' . (int)$u;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
$sql = 'SELECT * FROM ' . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
|
||||
if (!$u_data = OLD_DB()->fetch_row($sql)) {
|
||||
if (!is_int($u) && !$name_search) {
|
||||
$where_sql = "WHERE username = '" . OLD_DB()->escape(clean_username($u)) . "'";
|
||||
$sql = "SELECT * FROM " . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
$sql = 'SELECT * FROM ' . BB_USERS . " $where_sql $exclude_anon_sql LIMIT 1";
|
||||
$u_data = OLD_DB()->fetch_row($sql);
|
||||
}
|
||||
}
|
||||
|
@ -971,7 +971,7 @@ function make_jumpbox($selected = 0)
|
|||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'JUMPBOX' => (IS_GUEST) ? $jumpbox['guest'] : $jumpbox['user'],
|
||||
'JUMPBOX' => IS_GUEST ? $jumpbox['guest'] : $jumpbox['user'],
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1020,7 +1020,7 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
|
|||
trigger_error(__FUNCTION__ . ": invalid mode '$mode'", E_USER_ERROR);
|
||||
}
|
||||
$cat_title = $forums['c'][$f['cat_id']]['cat_title'];
|
||||
$f_name = ($f['forum_parent']) ? ' |- ' : '';
|
||||
$f_name = $f['forum_parent'] ? ' |- ' : '';
|
||||
$f_name .= $f['forum_name'];
|
||||
|
||||
while (isset($select[$cat_title][$f_name])) {
|
||||
|
@ -1107,12 +1107,12 @@ function bb_date($gmepoch, $format = false, $friendly_date = true)
|
|||
} elseif ($today != 1 && $date_today == ($today - 1) && $date_month == $month && $date_year == $year) {
|
||||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
} elseif ($today == 1 && $month != 1) {
|
||||
$yesterday = date('t', mktime(0, 0, 0, ($month - 1), 1, $year));
|
||||
$yesterday = date('t', mktime(0, 0, 0, $month - 1, 1, $year));
|
||||
if ($date_today == $yesterday && $date_month == ($month - 1) && $date_year == $year) {
|
||||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
}
|
||||
} elseif ($today == 1 && $month == 1) {
|
||||
$yesterday = date('t', mktime(0, 0, 0, 12, 1, ($year - 1)));
|
||||
$yesterday = date('t', mktime(0, 0, 0, 12, 1, $year - 1));
|
||||
if ($date_today == $yesterday && $date_month == 12 && $date_year == ($year - 1)) {
|
||||
$date = 'yesterday' . gmdate($time_format, $gmepoch + (3600 * $tz));
|
||||
}
|
||||
|
@ -1171,9 +1171,9 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
|||
if ($total_pages > ((2 * ($begin_end + $from_middle)) + 2)) {
|
||||
$init_page_max = ($total_pages > $begin_end) ? $begin_end : $total_pages;
|
||||
for ($i = 1; $i < $init_page_max + 1; $i++) {
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . '&start=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $init_page_max) {
|
||||
$page_string .= ", ";
|
||||
$page_string .= ', ';
|
||||
}
|
||||
}
|
||||
if ($total_pages > $begin_end) {
|
||||
|
@ -1185,7 +1185,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
|||
$init_page_max = ($on_page < $total_pages - ($begin_end + $from_middle)) ? $on_page : $total_pages - ($begin_end + $from_middle);
|
||||
|
||||
for ($i = $init_page_min - $from_middle; $i < $init_page_max + ($from_middle + 1); $i++) {
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . '&start=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $init_page_max + $from_middle) {
|
||||
$page_string .= ', ';
|
||||
}
|
||||
|
@ -1195,15 +1195,15 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
|||
$page_string .= ' ... ';
|
||||
}
|
||||
for ($i = $total_pages - ($begin_end - 1); $i < $total_pages + 1; $i++) {
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . '&start=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $total_pages) {
|
||||
$page_string .= ", ";
|
||||
$page_string .= ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($i = 1; $i < $total_pages + 1; $i++) {
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . '&start=' . (($i - 1) * $per_page) . '">' . $i . '</a>';
|
||||
if ($i < $total_pages) {
|
||||
$page_string .= ', ';
|
||||
}
|
||||
|
@ -1212,20 +1212,20 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
|||
|
||||
if ($add_prevnext_text) {
|
||||
if ($on_page > 1) {
|
||||
$page_string = ' <a href="' . $base_url . "&start=" . (($on_page - 2) * $per_page) . '">' . trans('messages.PREVIOUS_PAGE') . '</a> ' . $page_string;
|
||||
$page_string = ' <a href="' . $base_url . '&start=' . (($on_page - 2) * $per_page) . '">' . trans('messages.PREVIOUS_PAGE') . '</a> ' . $page_string;
|
||||
}
|
||||
|
||||
if ($on_page < $total_pages) {
|
||||
$page_string .= ' <a href="' . $base_url . "&start=" . ($on_page * $per_page) . '">' . trans('messages.NEXT_PAGE') . '</a>';
|
||||
$page_string .= ' <a href="' . $base_url . '&start=' . ($on_page * $per_page) . '">' . trans('messages.NEXT_PAGE') . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$pagination = ($page_string) ? '<a class="menu-root" href="#pg-jump">' . trans('messages.GOTO_PAGE') . '</a> : ' . $page_string : '';
|
||||
$pagination = $page_string ? '<a class="menu-root" href="#pg-jump">' . trans('messages.GOTO_PAGE') . '</a> : ' . $page_string : '';
|
||||
$pagination = str_replace('&start=0', '', $pagination);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PAGINATION' => $pagination,
|
||||
'PAGE_NUMBER' => sprintf(trans('messages.PAGE_OF'), (floor($start_item / $per_page) + 1), ceil($num_items / $per_page)),
|
||||
'PAGE_NUMBER' => sprintf(trans('messages.PAGE_OF'), floor($start_item / $per_page) + 1, ceil($num_items / $per_page)),
|
||||
'PG_BASE_URL' => $base_url,
|
||||
'PG_PER_PAGE' => $per_page,
|
||||
));
|
||||
|
@ -1257,7 +1257,7 @@ function obtain_word_list(&$orig_word, &$replacement_word)
|
|||
}
|
||||
|
||||
if (!$sql = OLD_CACHE('bb_cache')->get('censored')) {
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT word, replacement FROM " . BB_WORDS);
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT word, replacement FROM ' . BB_WORDS);
|
||||
if (!$sql) {
|
||||
$sql = array(array('word' => 1, 'replacement' => 1));
|
||||
}
|
||||
|
@ -1301,7 +1301,7 @@ function bb_die($msg_text)
|
|||
if (empty($theme)) {
|
||||
$theme = setup_style();
|
||||
}
|
||||
require(PAGE_HEADER);
|
||||
require PAGE_HEADER;
|
||||
}
|
||||
|
||||
// Check for lang variable
|
||||
|
@ -1317,7 +1317,7 @@ function bb_die($msg_text)
|
|||
$template->set_filenames(array('bb_die' => 'common.tpl'));
|
||||
$template->pparse('bb_die');
|
||||
|
||||
require(PAGE_FOOTER);
|
||||
require PAGE_FOOTER;
|
||||
|
||||
exit;
|
||||
}
|
||||
|
@ -1518,8 +1518,8 @@ if (!function_exists('array_intersect_key')) {
|
|||
|
||||
function clear_dl_list($topics_csv)
|
||||
{
|
||||
OLD_DB()->query("DELETE FROM " . BB_BT_DLSTATUS . " WHERE topic_id IN($topics_csv)");
|
||||
OLD_DB()->query("DELETE FROM " . BB_BT_DLSTATUS_SNAP . " WHERE topic_id IN($topics_csv)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_BT_DLSTATUS . " WHERE topic_id IN($topics_csv)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_BT_DLSTATUS_SNAP . " WHERE topic_id IN($topics_csv)");
|
||||
}
|
||||
|
||||
// $ids - array(id1,id2,..) or (string) id
|
||||
|
@ -1540,20 +1540,20 @@ function get_id_ary($ids)
|
|||
|
||||
function get_topic_title($topic_id)
|
||||
{
|
||||
$row = OLD_DB()->fetch_row("
|
||||
SELECT topic_title FROM " . BB_TOPICS . " WHERE topic_id = " . (int)$topic_id . "
|
||||
");
|
||||
$row = OLD_DB()->fetch_row('
|
||||
SELECT topic_title FROM ' . BB_TOPICS . ' WHERE topic_id = ' . (int)$topic_id . '
|
||||
');
|
||||
return $row['topic_title'];
|
||||
}
|
||||
|
||||
function forum_exists($forum_id)
|
||||
{
|
||||
return OLD_DB()->fetch_row("SELECT forum_id FROM " . BB_FORUMS . " WHERE forum_id = $forum_id LIMIT 1");
|
||||
return OLD_DB()->fetch_row('SELECT forum_id FROM ' . BB_FORUMS . " WHERE forum_id = $forum_id LIMIT 1");
|
||||
}
|
||||
|
||||
function cat_exists($cat_id)
|
||||
{
|
||||
return OLD_DB()->fetch_row("SELECT cat_id FROM " . BB_CATEGORIES . " WHERE cat_id = $cat_id LIMIT 1");
|
||||
return OLD_DB()->fetch_row('SELECT cat_id FROM ' . BB_CATEGORIES . " WHERE cat_id = $cat_id LIMIT 1");
|
||||
}
|
||||
|
||||
function get_topic_icon($topic, $is_unread = null)
|
||||
|
@ -1566,8 +1566,8 @@ function get_topic_icon($topic, $is_unread = null)
|
|||
if ($topic['topic_status'] == TOPIC_MOVED) {
|
||||
$folder_image = $images['folder'];
|
||||
} else {
|
||||
$folder = ($t_hot) ? $images['folder_hot'] : $images['folder'];
|
||||
$folder_new = ($t_hot) ? $images['folder_hot_new'] : $images['folder_new'];
|
||||
$folder = $t_hot ? $images['folder_hot'] : $images['folder'];
|
||||
$folder_new = $t_hot ? $images['folder_hot_new'] : $images['folder_new'];
|
||||
|
||||
if ($topic['topic_type'] == POST_ANNOUNCE) {
|
||||
$folder = $images['folder_announce'];
|
||||
|
@ -1579,11 +1579,11 @@ function get_topic_icon($topic, $is_unread = null)
|
|||
$folder = $images['folder_locked'];
|
||||
$folder_new = $images['folder_locked_new'];
|
||||
} elseif ($topic['topic_dl_type'] == TOPIC_DL_TYPE_DL) {
|
||||
$folder = ($t_hot) ? $images['folder_dl_hot'] : $images['folder_dl'];
|
||||
$folder_new = ($t_hot) ? $images['folder_dl_hot_new'] : $images['folder_dl_new'];
|
||||
$folder = $t_hot ? $images['folder_dl_hot'] : $images['folder_dl'];
|
||||
$folder_new = $t_hot ? $images['folder_dl_hot_new'] : $images['folder_dl_new'];
|
||||
}
|
||||
|
||||
$folder_image = ($is_unread) ? $folder_new : $folder;
|
||||
$folder_image = $is_unread ? $folder_new : $folder;
|
||||
}
|
||||
|
||||
return $folder_image;
|
||||
|
@ -1597,7 +1597,7 @@ function build_topic_pagination($url, $replies, $per_page)
|
|||
$total_pages = ceil($replies / $per_page);
|
||||
|
||||
for ($j = 0, $page = 1; $j < $replies; $j += $per_page, $page++) {
|
||||
$href = ($j) ? "$url&start=$j" : $url;
|
||||
$href = $j ? "$url&start=$j" : $url;
|
||||
$pg .= '<a href="' . $href . '" class="topicPG">' . $page . '</a>';
|
||||
|
||||
if ($page == 1 && $total_pages > 3) {
|
||||
|
@ -1624,9 +1624,9 @@ function get_poll_data_items_js($topic_id)
|
|||
$items = array();
|
||||
|
||||
if (!$poll_data = OLD_CACHE('bb_poll_data')->get("poll_$topic_id")) {
|
||||
$poll_data = OLD_DB()->fetch_rowset("
|
||||
$poll_data = OLD_DB()->fetch_rowset('
|
||||
SELECT topic_id, vote_id, vote_text, vote_result
|
||||
FROM " . BB_POLL_VOTES . "
|
||||
FROM ' . BB_POLL_VOTES . "
|
||||
WHERE topic_id IN($topic_id_csv)
|
||||
ORDER BY topic_id, vote_id
|
||||
");
|
||||
|
@ -1689,14 +1689,14 @@ function print_page($args, $type = '', $mode = '')
|
|||
$gen_simple_header = (is_array($args) && !empty($args['simple']) or $type === 'simple') ? true : $gen_simple_header;
|
||||
|
||||
if ($mode !== 'no_header') {
|
||||
require(PAGE_HEADER);
|
||||
require PAGE_HEADER;
|
||||
}
|
||||
|
||||
$template->set_filenames(array('body' => $tpl));
|
||||
$template->pparse('body');
|
||||
|
||||
if ($mode !== 'no_footer') {
|
||||
require(PAGE_FOOTER);
|
||||
require PAGE_FOOTER;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1719,7 @@ function caching_output($enabled, $mode, $cache_var_name, $ttl = 300)
|
|||
|
||||
function clean_title($str, $replace_underscore = false)
|
||||
{
|
||||
$str = ($replace_underscore) ? str_replace('_', ' ', $str) : $str;
|
||||
$str = $replace_underscore ? str_replace('_', ' ', $str) : $str;
|
||||
$str = htmlCHR(str_compact($str));
|
||||
return $str;
|
||||
}
|
||||
|
@ -1727,7 +1727,7 @@ function clean_title($str, $replace_underscore = false)
|
|||
function clean_text_match($text, $ltrim_star = true, $die_if_empty = false)
|
||||
{
|
||||
$text = str_compact($text);
|
||||
$ltrim_chars = ($ltrim_star) ? ' *-!' : ' ';
|
||||
$ltrim_chars = $ltrim_star ? ' *-!' : ' ';
|
||||
$wrap_with_quotes = preg_match('#^"[^"]+"$#', $text);
|
||||
|
||||
$text = ' ' . str_compact(ltrim($text, $ltrim_chars)) . ' ';
|
||||
|
@ -1817,17 +1817,17 @@ function get_title_match_topics($title_match_sql, array $forum_ids = array())
|
|||
log_sphinx_error('wrn', $warning, $title_match_sql);
|
||||
}
|
||||
} elseif (config('tp.search_engine_type') == 'mysql') {
|
||||
$where_forum = ($forum_ids) ? "AND forum_id IN(" . implode(',', $forum_ids) . ")" : '';
|
||||
$where_forum = $forum_ids ? 'AND forum_id IN(' . implode(',', $forum_ids) . ')' : '';
|
||||
$search_bool_mode = config('tp.allow_search_in_bool_mode') ? ' IN BOOLEAN MODE' : '';
|
||||
|
||||
if ($title_match) {
|
||||
$where_id = 'topic_id';
|
||||
$sql = "SELECT topic_id FROM " . BB_TOPICS . "
|
||||
$sql = 'SELECT topic_id FROM ' . BB_TOPICS . "
|
||||
WHERE MATCH (topic_title) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||
$where_forum";
|
||||
} else {
|
||||
$where_id = 'post_id';
|
||||
$sql = "SELECT p.post_id FROM " . BB_POSTS . " p, " . BB_POSTS_SEARCH . " ps
|
||||
$sql = 'SELECT p.post_id FROM ' . BB_POSTS . ' p, ' . BB_POSTS_SEARCH . " ps
|
||||
WHERE ps.post_id = p.post_id
|
||||
AND MATCH (ps.search_words) AGAINST ('$title_match_sql'$search_bool_mode)
|
||||
$where_forum";
|
||||
|
@ -1901,18 +1901,18 @@ function send_pm($user_id, $subject, $message, $poster_id = BOT_UID)
|
|||
|
||||
if ($poster_id == BOT_UID) {
|
||||
$poster_ip = '7f000001';
|
||||
} elseif ($row = OLD_DB()->fetch_row("SELECT user_reg_ip FROM " . BB_USERS . " WHERE user_id = $poster_id")) {
|
||||
} elseif ($row = OLD_DB()->fetch_row('SELECT user_reg_ip FROM ' . BB_USERS . " WHERE user_id = $poster_id")) {
|
||||
$poster_ip = $row['user_reg_ip'];
|
||||
} else {
|
||||
$poster_id = $userdata['user_id'];
|
||||
$poster_ip = USER_IP;
|
||||
}
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_PRIVMSGS . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip) VALUES (" . PRIVMSGS_NEW_MAIL . ", '$subject', {$poster_id}, $user_id, " . TIMENOW . ", '$poster_ip')");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_PRIVMSGS . ' (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip) VALUES (' . PRIVMSGS_NEW_MAIL . ", '$subject', {$poster_id}, $user_id, " . TIMENOW . ", '$poster_ip')");
|
||||
$pm_id = OLD_DB()->sql_nextid();
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_PRIVMSGS_TEXT . " (privmsgs_text_id, privmsgs_text) VALUES ($pm_id, '$message')");
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = " . TIMENOW . ", user_newest_pm_id = $pm_id WHERE user_id = $user_id");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_PRIVMSGS_TEXT . " (privmsgs_text_id, privmsgs_text) VALUES ($pm_id, '$message')");
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . ' SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = ' . TIMENOW . ", user_newest_pm_id = $pm_id WHERE user_id = $user_id");
|
||||
}
|
||||
|
||||
function profile_url($data)
|
||||
|
@ -2027,7 +2027,7 @@ function update_atom($type, $id)
|
|||
break;
|
||||
|
||||
case 'topic':
|
||||
$topic_poster = (int)OLD_DB()->fetch_row("SELECT topic_poster FROM " . BB_TOPICS . " WHERE topic_id = $id LIMIT 1", 'topic_poster');
|
||||
$topic_poster = (int)OLD_DB()->fetch_row('SELECT topic_poster FROM ' . BB_TOPICS . " WHERE topic_id = $id LIMIT 1", 'topic_poster');
|
||||
update_user_feed($topic_poster, get_username($topic_poster));
|
||||
break;
|
||||
}
|
||||
|
@ -2041,9 +2041,9 @@ function hash_search($hash)
|
|||
bb_die(sprintf(trans('messages.HASH_INVALID'), $hash));
|
||||
}
|
||||
|
||||
$info_hash = OLD_DB()->escape(pack("H*", $hash));
|
||||
$info_hash = OLD_DB()->escape(pack('H*', $hash));
|
||||
|
||||
if ($row = OLD_DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash'")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT topic_id FROM ' . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash'")) {
|
||||
redirectToUrl(TOPIC_URL . $row['topic_id']);
|
||||
} else {
|
||||
bb_die(sprintf(trans('messages.HASH_NOT_FOUND'), $hash));
|
||||
|
@ -2089,7 +2089,7 @@ function bb_captcha($mode, $callback = '')
|
|||
case 'check':
|
||||
$resp = $reCaptcha->verify(
|
||||
request_var('g-recaptcha-response', ''),
|
||||
$_SERVER["REMOTE_ADDR"]
|
||||
$_SERVER['REMOTE_ADDR']
|
||||
);
|
||||
if ($resp->isSuccess()) {
|
||||
return true;
|
||||
|
|
|
@ -13,7 +13,7 @@ if (!defined('BB_ROOT')) {
|
|||
|
||||
function sync_all_forums()
|
||||
{
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT forum_id FROM " . BB_FORUMS) as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT forum_id FROM ' . BB_FORUMS) as $row) {
|
||||
sync('forum', $row['forum_id']);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ function sync($type, $id)
|
|||
|
||||
// начальное обнуление значений
|
||||
$forum_ary = explode(',', $forum_csv);
|
||||
OLD_DB()->query("REPLACE INTO $tmp_sync_forums (forum_id) VALUES(" . implode('),(', $forum_ary) . ")");
|
||||
OLD_DB()->query("REPLACE INTO $tmp_sync_forums (forum_id) VALUES(" . implode('),(', $forum_ary) . ')');
|
||||
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO $tmp_sync_forums
|
||||
|
@ -59,14 +59,14 @@ function sync($type, $id)
|
|||
|
||||
OLD_DB()->query("
|
||||
UPDATE
|
||||
$tmp_sync_forums tmp, " . BB_FORUMS . " f
|
||||
$tmp_sync_forums tmp, " . BB_FORUMS . ' f
|
||||
SET
|
||||
f.forum_last_post_id = tmp.forum_last_post_id,
|
||||
f.forum_posts = tmp.forum_posts,
|
||||
f.forum_topics = tmp.forum_topics
|
||||
WHERE
|
||||
f.forum_id = tmp.forum_id
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TEMPORARY TABLE $tmp_sync_forums");
|
||||
|
||||
|
@ -81,7 +81,7 @@ function sync($type, $id)
|
|||
}
|
||||
|
||||
// Проверка на остаточные записи об уже удаленных топиках
|
||||
OLD_DB()->query("DELETE FROM " . BB_TOPICS . " WHERE topic_first_post_id NOT IN (SELECT post_id FROM " . BB_POSTS . ")");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_TOPICS . ' WHERE topic_first_post_id NOT IN (SELECT post_id FROM ' . BB_POSTS . ')');
|
||||
|
||||
$tmp_sync_topics = 'tmp_sync_topics';
|
||||
|
||||
|
@ -109,17 +109,17 @@ function sync($type, $id)
|
|||
MAX(p.post_id) AS topic_last_post_id,
|
||||
MAX(p.post_time) AS topic_last_post_time,
|
||||
IF(MAX(a.attach_id), 1, 0) AS topic_attachment
|
||||
FROM " . BB_TOPICS . " t
|
||||
LEFT JOIN " . BB_POSTS . " p ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = p.post_id)
|
||||
WHERE t.topic_status != " . TOPIC_MOVED . "
|
||||
FROM " . BB_TOPICS . ' t
|
||||
LEFT JOIN ' . BB_POSTS . ' p ON(p.topic_id = t.topic_id)
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . ' a ON(a.post_id = p.post_id)
|
||||
WHERE t.topic_status != ' . TOPIC_MOVED . "
|
||||
$where_sql
|
||||
GROUP BY t.topic_id
|
||||
");
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE
|
||||
$tmp_sync_topics tmp, " . BB_TOPICS . " t
|
||||
$tmp_sync_topics tmp, " . BB_TOPICS . ' t
|
||||
SET
|
||||
t.topic_replies = tmp.total_posts - 1,
|
||||
t.topic_first_post_id = tmp.topic_first_post_id,
|
||||
|
@ -128,9 +128,9 @@ function sync($type, $id)
|
|||
t.topic_attachment = tmp.topic_attachment
|
||||
WHERE
|
||||
t.topic_id = tmp.topic_id
|
||||
");
|
||||
');
|
||||
|
||||
if ($topics = OLD_DB()->fetch_rowset("SELECT topic_id FROM " . $tmp_sync_topics . " WHERE total_posts = 0", 'topic_id')) {
|
||||
if ($topics = OLD_DB()->fetch_rowset('SELECT topic_id FROM ' . $tmp_sync_topics . ' WHERE total_posts = 0', 'topic_id')) {
|
||||
topic_delete($topics);
|
||||
}
|
||||
|
||||
|
@ -158,31 +158,31 @@ function sync($type, $id)
|
|||
OLD_DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS $tmp_user_posts");
|
||||
|
||||
// Set posts count = 0 and then update to real count
|
||||
$where_user_sql = (!$all_users) ? "AND user_id IN($user_csv)" : "AND user_posts != 0";
|
||||
$where_user_sql = (!$all_users) ? "AND user_id IN($user_csv)" : 'AND user_posts != 0';
|
||||
$where_post_sql = (!$all_users) ? "AND poster_id IN($user_csv)" : '';
|
||||
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO $tmp_user_posts
|
||||
SELECT user_id, 0
|
||||
FROM " . BB_USERS . "
|
||||
WHERE user_id != " . GUEST_UID . "
|
||||
FROM " . BB_USERS . '
|
||||
WHERE user_id != ' . GUEST_UID . "
|
||||
$where_user_sql
|
||||
UNION
|
||||
SELECT poster_id, COUNT(*)
|
||||
FROM " . BB_POSTS . "
|
||||
WHERE poster_id != " . GUEST_UID . "
|
||||
FROM " . BB_POSTS . '
|
||||
WHERE poster_id != ' . GUEST_UID . "
|
||||
$where_post_sql
|
||||
GROUP BY poster_id
|
||||
");
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE
|
||||
$tmp_user_posts tmp, " . BB_USERS . " u
|
||||
$tmp_user_posts tmp, " . BB_USERS . ' u
|
||||
SET
|
||||
u.user_posts = tmp.user_posts
|
||||
WHERE
|
||||
u.user_id = tmp.user_id
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TEMPORARY TABLE $tmp_user_posts");
|
||||
|
||||
|
@ -207,9 +207,9 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru
|
|||
} else {
|
||||
$where_sql = ($forum_csv = get_id_csv($forum_id)) ? "AND forum_id IN($forum_csv)" : '';
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT topic_id, forum_id, topic_title, topic_status
|
||||
FROM " . BB_TOPICS . "
|
||||
FROM ' . BB_TOPICS . "
|
||||
WHERE topic_id IN($topic_csv)
|
||||
$where_sql
|
||||
";
|
||||
|
@ -238,9 +238,9 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru
|
|||
");
|
||||
OLD_DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS $tmp_delete_topics");
|
||||
|
||||
$where_sql = ($prune) ? "forum_id = $forum_id" : "topic_id IN($topic_csv)";
|
||||
$where_sql = $prune ? "forum_id = $forum_id" : "topic_id IN($topic_csv)";
|
||||
$where_sql .= ($prune && $prune_time) ? " AND topic_last_post_time < $prune_time" : '';
|
||||
$where_sql .= ($prune && !$prune_all) ? " AND topic_type NOT IN(" . POST_ANNOUNCE . "," . POST_STICKY . ")" : '';
|
||||
$where_sql .= ($prune && !$prune_all) ? ' AND topic_type NOT IN(' . POST_ANNOUNCE . ',' . POST_STICKY . ')' : '';
|
||||
|
||||
OLD_DB()->query("INSERT INTO $tmp_delete_topics SELECT topic_id FROM " . BB_TOPICS . " WHERE $where_sql");
|
||||
|
||||
|
@ -267,11 +267,11 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru
|
|||
OLD_DB()->query("
|
||||
INSERT INTO $tmp_user_posts
|
||||
SELECT p.poster_id, COUNT(p.post_id)
|
||||
FROM " . $tmp_delete_topics . " del, " . BB_POSTS . " p
|
||||
FROM " . $tmp_delete_topics . ' del, ' . BB_POSTS . ' p
|
||||
WHERE p.topic_id = del.topic_id
|
||||
AND p.poster_id != " . GUEST_UID . "
|
||||
AND p.poster_id != ' . GUEST_UID . '
|
||||
GROUP BY p.poster_id
|
||||
");
|
||||
');
|
||||
|
||||
// Get array for atom update
|
||||
$atom_csv = array();
|
||||
|
@ -281,39 +281,39 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru
|
|||
|
||||
OLD_DB()->query("
|
||||
UPDATE
|
||||
$tmp_user_posts tmp, " . BB_USERS . " u
|
||||
$tmp_user_posts tmp, " . BB_USERS . ' u
|
||||
SET
|
||||
u.user_posts = u.user_posts - tmp.user_posts
|
||||
WHERE
|
||||
u.user_id = tmp.user_id
|
||||
");
|
||||
');
|
||||
|
||||
OLD_DB()->query("DROP TEMPORARY TABLE $tmp_user_posts");
|
||||
|
||||
// Delete votes
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE pv, pu
|
||||
FROM " . $tmp_delete_topics . " del
|
||||
LEFT JOIN " . BB_POLL_VOTES . " pv USING(topic_id)
|
||||
LEFT JOIN " . BB_POLL_USERS . " pu USING(topic_id)
|
||||
");
|
||||
FROM ' . $tmp_delete_topics . ' del
|
||||
LEFT JOIN ' . BB_POLL_VOTES . ' pv USING(topic_id)
|
||||
LEFT JOIN ' . BB_POLL_USERS . ' pu USING(topic_id)
|
||||
');
|
||||
|
||||
// Delete attachments (from disk)
|
||||
$attach_dir = get_attachments_dir();
|
||||
|
||||
$result = OLD_DB()->query("
|
||||
$result = OLD_DB()->query('
|
||||
SELECT
|
||||
d.physical_filename
|
||||
FROM
|
||||
" . $tmp_delete_topics . " del,
|
||||
" . BB_POSTS . " p,
|
||||
" . BB_ATTACHMENTS . " a,
|
||||
" . BB_ATTACHMENTS_DESC . " d
|
||||
' . $tmp_delete_topics . ' del,
|
||||
' . BB_POSTS . ' p,
|
||||
' . BB_ATTACHMENTS . ' a,
|
||||
' . BB_ATTACHMENTS_DESC . ' d
|
||||
WHERE
|
||||
p.topic_id = del.topic_id
|
||||
AND a.post_id = p.post_id
|
||||
AND d.attach_id = a.attach_id
|
||||
");
|
||||
');
|
||||
|
||||
while ($row = OLD_DB()->fetch_next($result)) {
|
||||
if ($filename = basename($row['physical_filename'])) {
|
||||
|
@ -324,45 +324,43 @@ function topic_delete($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pru
|
|||
unset($row, $result);
|
||||
|
||||
// Delete posts, posts_text, attachments (from DB)
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE p, pt, ps, a, d, ph
|
||||
FROM " . $tmp_delete_topics . " del
|
||||
LEFT JOIN " . BB_POSTS . " p ON(p.topic_id = del.topic_id)
|
||||
LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " ph ON(ph.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_POSTS_SEARCH . " ps ON(ps.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d ON(d.attach_id = a.attach_id)
|
||||
");
|
||||
FROM ' . $tmp_delete_topics . ' del
|
||||
LEFT JOIN ' . BB_POSTS . ' p ON(p.topic_id = del.topic_id)
|
||||
LEFT JOIN ' . BB_POSTS_TEXT . ' pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_HTML . ' ph ON(ph.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_SEARCH . ' ps ON(ps.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . ' a ON(a.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . ' d ON(d.attach_id = a.attach_id)
|
||||
');
|
||||
|
||||
// Delete topics, topics watch
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE t, tw
|
||||
FROM " . $tmp_delete_topics . " del
|
||||
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
|
||||
LEFT JOIN " . BB_TOPICS_WATCH . " tw USING(topic_id)
|
||||
");
|
||||
FROM ' . $tmp_delete_topics . ' del
|
||||
LEFT JOIN ' . BB_TOPICS . ' t USING(topic_id)
|
||||
LEFT JOIN ' . BB_TOPICS_WATCH . ' tw USING(topic_id)
|
||||
');
|
||||
|
||||
// Delete topic moved stubs
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE t
|
||||
FROM " . $tmp_delete_topics . " del, " . BB_TOPICS . " t
|
||||
FROM ' . $tmp_delete_topics . ' del, ' . BB_TOPICS . ' t
|
||||
WHERE t.topic_moved_id = del.topic_id
|
||||
");
|
||||
');
|
||||
|
||||
// Delete torrents
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE tor, tr, dl
|
||||
FROM " . $tmp_delete_topics . " del
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor USING(topic_id)
|
||||
LEFT JOIN " . BB_BT_TRACKER . " tr USING(topic_id)
|
||||
LEFT JOIN " . BB_BT_DLSTATUS . " dl USING(topic_id)
|
||||
");
|
||||
FROM ' . $tmp_delete_topics . ' del
|
||||
LEFT JOIN ' . BB_BT_TORRENTS . ' tor USING(topic_id)
|
||||
LEFT JOIN ' . BB_BT_TRACKER . ' tr USING(topic_id)
|
||||
LEFT JOIN ' . BB_BT_DLSTATUS . ' dl USING(topic_id)
|
||||
');
|
||||
|
||||
// Log action
|
||||
if ($prune) {
|
||||
// TODO
|
||||
} else {
|
||||
if (!$prune) {
|
||||
foreach ($log_topics as $row) {
|
||||
if ($row['topic_status'] == TOPIC_MOVED) {
|
||||
$row['topic_title'] = '<i>' . trans('messages.TOPIC_MOVED') . '</i> ' . $row['topic_title'];
|
||||
|
@ -409,7 +407,7 @@ function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shado
|
|||
// Get topics info
|
||||
$where_sql = ($forum_csv = get_id_csv($from_forum_id)) ? "AND forum_id IN($forum_csv)" : '';
|
||||
|
||||
$sql = "SELECT * FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND topic_status != " . TOPIC_MOVED . " $where_sql";
|
||||
$sql = 'SELECT * FROM ' . BB_TOPICS . " WHERE topic_id IN($topic_csv) AND topic_status != " . TOPIC_MOVED . " $where_sql";
|
||||
|
||||
$topics = array();
|
||||
$sync_forums = array($to_forum_id => true);
|
||||
|
@ -447,13 +445,13 @@ function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shado
|
|||
);
|
||||
}
|
||||
if ($sql_args = OLD_DB()->build_array('MULTI_INSERT', $shadows)) {
|
||||
OLD_DB()->query("INSERT INTO " . BB_TOPICS . $sql_args);
|
||||
OLD_DB()->query('INSERT INTO ' . BB_TOPICS . $sql_args);
|
||||
}
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TORRENTS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TORRENTS . " SET forum_id = $to_forum_id WHERE topic_id IN($topic_csv)");
|
||||
|
||||
// Bot
|
||||
if ($insert_bot_msg) {
|
||||
|
@ -498,7 +496,7 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
|
||||
// фильтр заглавных сообщений в теме
|
||||
if ($exclude_first) {
|
||||
$sql = "SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_first_post_id IN($post_csv)";
|
||||
$sql = 'SELECT topic_first_post_id FROM ' . BB_TOPICS . " WHERE topic_first_post_id IN($post_csv)";
|
||||
|
||||
if ($first_posts = OLD_DB()->fetch_rowset($sql, 'topic_first_post_id')) {
|
||||
$posts_without_first = array_diff(explode(',', $post_csv), $first_posts);
|
||||
|
@ -514,18 +512,18 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
$log_topics = $sync_forums = $sync_topics = $sync_users = array();
|
||||
|
||||
if ($del_user_posts) {
|
||||
$sync_topics = OLD_DB()->fetch_rowset("SELECT DISTINCT topic_id FROM " . BB_POSTS . " WHERE poster_id IN($user_csv)", 'topic_id');
|
||||
$sync_topics = OLD_DB()->fetch_rowset('SELECT DISTINCT topic_id FROM ' . BB_POSTS . " WHERE poster_id IN($user_csv)", 'topic_id');
|
||||
|
||||
if ($topic_csv = get_id_csv($sync_topics)) {
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT DISTINCT forum_id FROM " . BB_TOPICS . " WHERE topic_id IN($topic_csv)") as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT DISTINCT forum_id FROM ' . BB_TOPICS . " WHERE topic_id IN($topic_csv)") as $row) {
|
||||
$sync_forums[$row['forum_id']] = true;
|
||||
}
|
||||
}
|
||||
$sync_users = explode(',', $user_csv);
|
||||
} else {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT p.topic_id, p.forum_id, t.topic_title
|
||||
FROM " . BB_POSTS . " p, " . BB_TOPICS . " t
|
||||
FROM ' . BB_POSTS . ' p, ' . BB_TOPICS . " t
|
||||
WHERE p.post_id IN($post_csv)
|
||||
AND t.topic_id = p.topic_id
|
||||
GROUP BY t.topic_id
|
||||
|
@ -537,7 +535,7 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
$sync_forums[$row['forum_id']] = true;
|
||||
}
|
||||
|
||||
$sync_users = OLD_DB()->fetch_rowset("SELECT DISTINCT poster_id FROM " . BB_POSTS . " WHERE post_id IN($post_csv)", 'poster_id');
|
||||
$sync_users = OLD_DB()->fetch_rowset('SELECT DISTINCT poster_id FROM ' . BB_POSTS . " WHERE post_id IN($post_csv)", 'poster_id');
|
||||
}
|
||||
|
||||
// Get all post_id for deleting
|
||||
|
@ -555,7 +553,7 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
$where_sql = "poster_id IN($user_csv)";
|
||||
|
||||
$exclude_posts_ary = array();
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_poster IN($user_csv)") as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT topic_first_post_id FROM ' . BB_TOPICS . " WHERE topic_poster IN($user_csv)") as $row) {
|
||||
$exclude_posts_ary[] = $row['topic_first_post_id'];
|
||||
}
|
||||
if ($exclude_posts_csv = get_id_csv($exclude_posts_ary)) {
|
||||
|
@ -578,17 +576,17 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
// Delete attachments (from disk)
|
||||
$attach_dir = get_attachments_dir();
|
||||
|
||||
$result = OLD_DB()->query("
|
||||
$result = OLD_DB()->query('
|
||||
SELECT
|
||||
d.physical_filename
|
||||
FROM
|
||||
" . $tmp_delete_posts . " del,
|
||||
" . BB_ATTACHMENTS . " a,
|
||||
" . BB_ATTACHMENTS_DESC . " d
|
||||
' . $tmp_delete_posts . ' del,
|
||||
' . BB_ATTACHMENTS . ' a,
|
||||
' . BB_ATTACHMENTS_DESC . ' d
|
||||
WHERE
|
||||
a.post_id = del.post_id
|
||||
AND d.attach_id = a.attach_id
|
||||
");
|
||||
');
|
||||
|
||||
while ($row = OLD_DB()->fetch_next($result)) {
|
||||
if ($filename = basename($row['physical_filename'])) {
|
||||
|
@ -599,17 +597,17 @@ function post_delete($mode_or_post_id, $user_id = null, $exclude_first = true)
|
|||
unset($row, $result);
|
||||
|
||||
// Delete posts, posts_text, attachments (from DB)
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE p, pt, ps, tor, a, d, ph
|
||||
FROM " . $tmp_delete_posts . " del
|
||||
LEFT JOIN " . BB_POSTS . " p ON(p.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " ph ON(ph.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_POSTS_SEARCH . " ps ON(ps.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(tor.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = del.post_id)
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d ON(d.attach_id = a.attach_id)
|
||||
");
|
||||
FROM ' . $tmp_delete_posts . ' del
|
||||
LEFT JOIN ' . BB_POSTS . ' p ON(p.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_TEXT . ' pt ON(pt.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_HTML . ' ph ON(ph.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_SEARCH . ' ps ON(ps.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_BT_TORRENTS . ' tor ON(tor.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_ATTACHMENTS . ' a ON(a.post_id = del.post_id)
|
||||
LEFT JOIN ' . BB_ATTACHMENTS_DESC . ' d ON(d.attach_id = a.attach_id)
|
||||
');
|
||||
|
||||
// Log action
|
||||
if ($del_user_posts) {
|
||||
|
@ -651,7 +649,7 @@ function user_delete($user_id, $delete_posts = false)
|
|||
if (!$user_csv = get_id_csv($user_id)) {
|
||||
return false;
|
||||
}
|
||||
if (!$user_id = OLD_DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . " WHERE user_id IN($user_csv)", 'user_id')) {
|
||||
if (!$user_id = OLD_DB()->fetch_rowset('SELECT user_id FROM ' . BB_USERS . " WHERE user_id IN($user_csv)", 'user_id')) {
|
||||
return false;
|
||||
}
|
||||
$user_csv = get_id_csv($user_id);
|
||||
|
@ -662,7 +660,7 @@ function user_delete($user_id, $delete_posts = false)
|
|||
));
|
||||
|
||||
// Avatar
|
||||
$result = OLD_DB()->query("SELECT user_id, avatar_ext_id FROM " . BB_USERS . " WHERE avatar_ext_id > 0 AND user_id IN($user_csv)");
|
||||
$result = OLD_DB()->query('SELECT user_id, avatar_ext_id FROM ' . BB_USERS . " WHERE avatar_ext_id > 0 AND user_id IN($user_csv)");
|
||||
|
||||
while ($row = OLD_DB()->fetch_next($result)) {
|
||||
delete_avatar($row['user_id'], $row['avatar_ext_id']);
|
||||
|
@ -671,60 +669,60 @@ function user_delete($user_id, $delete_posts = false)
|
|||
if ($delete_posts) {
|
||||
post_delete('user', $user_id);
|
||||
} else {
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET poster_id = " . DELETED . " WHERE poster_id IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . ' SET poster_id = ' . DELETED . " WHERE poster_id IN($user_csv)");
|
||||
}
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_GROUPS . " SET group_moderator = 2 WHERE group_single_user = 0 AND group_moderator IN($user_csv)");
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_poster = " . DELETED . " WHERE topic_poster IN($user_csv)");
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TORRENTS . " SET poster_id = " . DELETED . " WHERE poster_id IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_GROUPS . " SET group_moderator = 2 WHERE group_single_user = 0 AND group_moderator IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . ' SET topic_poster = ' . DELETED . " WHERE topic_poster IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TORRENTS . ' SET poster_id = ' . DELETED . " WHERE poster_id IN($user_csv)");
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE ug, g, a, qt1, qt2
|
||||
FROM " . BB_USER_GROUP . " ug
|
||||
LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = ug.group_id AND g.group_single_user = 1)
|
||||
LEFT JOIN " . BB_AUTH_ACCESS . " a ON(a.group_id = g.group_id)
|
||||
LEFT JOIN " . BB_QUOTA . " qt1 ON(qt1.user_id = ug.user_id)
|
||||
LEFT JOIN " . BB_QUOTA . " qt2 ON(qt2.group_id = g.group_id)
|
||||
FROM ' . BB_USER_GROUP . ' ug
|
||||
LEFT JOIN ' . BB_GROUPS . ' g ON(g.group_id = ug.group_id AND g.group_single_user = 1)
|
||||
LEFT JOIN ' . BB_AUTH_ACCESS . ' a ON(a.group_id = g.group_id)
|
||||
LEFT JOIN ' . BB_QUOTA . ' qt1 ON(qt1.user_id = ug.user_id)
|
||||
LEFT JOIN ' . BB_QUOTA . " qt2 ON(qt2.group_id = g.group_id)
|
||||
WHERE ug.user_id IN($user_csv)
|
||||
");
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE u, ban, pu, s, tw, asn
|
||||
FROM " . BB_USERS . " u
|
||||
LEFT JOIN " . BB_BANLIST . " ban ON(ban.ban_userid = u.user_id)
|
||||
LEFT JOIN " . BB_POLL_USERS . " pu ON(pu.user_id = u.user_id)
|
||||
LEFT JOIN " . BB_SESSIONS . " s ON(s.session_user_id = u.user_id)
|
||||
LEFT JOIN " . BB_TOPICS_WATCH . " tw ON(tw.user_id = u.user_id)
|
||||
LEFT JOIN " . BB_AUTH_ACCESS_SNAP . " asn ON(asn.user_id = u.user_id)
|
||||
FROM ' . BB_USERS . ' u
|
||||
LEFT JOIN ' . BB_BANLIST . ' ban ON(ban.ban_userid = u.user_id)
|
||||
LEFT JOIN ' . BB_POLL_USERS . ' pu ON(pu.user_id = u.user_id)
|
||||
LEFT JOIN ' . BB_SESSIONS . ' s ON(s.session_user_id = u.user_id)
|
||||
LEFT JOIN ' . BB_TOPICS_WATCH . ' tw ON(tw.user_id = u.user_id)
|
||||
LEFT JOIN ' . BB_AUTH_ACCESS_SNAP . " asn ON(asn.user_id = u.user_id)
|
||||
WHERE u.user_id IN($user_csv)
|
||||
");
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE btu, tr
|
||||
FROM " . BB_BT_USERS . " btu
|
||||
LEFT JOIN " . BB_BT_TRACKER . " tr ON(tr.user_id = btu.user_id)
|
||||
FROM ' . BB_BT_USERS . ' btu
|
||||
LEFT JOIN ' . BB_BT_TRACKER . " tr ON(tr.user_id = btu.user_id)
|
||||
WHERE btu.user_id IN($user_csv)
|
||||
");
|
||||
|
||||
// PM
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE pm, pmt
|
||||
FROM " . BB_PRIVMSGS . " pm
|
||||
LEFT JOIN " . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)
|
||||
FROM ' . BB_PRIVMSGS . ' pm
|
||||
LEFT JOIN ' . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)
|
||||
WHERE pm.privmsgs_from_userid IN($user_csv)
|
||||
AND pm.privmsgs_type IN(" . PRIVMSGS_SENT_MAIL . ',' . PRIVMSGS_SAVED_OUT_MAIL . ")
|
||||
");
|
||||
AND pm.privmsgs_type IN(" . PRIVMSGS_SENT_MAIL . ',' . PRIVMSGS_SAVED_OUT_MAIL . ')
|
||||
');
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE pm, pmt
|
||||
FROM " . BB_PRIVMSGS . " pm
|
||||
LEFT JOIN " . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)
|
||||
FROM ' . BB_PRIVMSGS . ' pm
|
||||
LEFT JOIN ' . BB_PRIVMSGS_TEXT . " pmt ON(pmt.privmsgs_text_id = pm.privmsgs_id)
|
||||
WHERE pm.privmsgs_to_userid IN($user_csv)
|
||||
AND pm.privmsgs_type IN(" . PRIVMSGS_READ_MAIL . ',' . PRIVMSGS_SAVED_IN_MAIL . ")
|
||||
");
|
||||
AND pm.privmsgs_type IN(" . PRIVMSGS_READ_MAIL . ',' . PRIVMSGS_SAVED_IN_MAIL . ')
|
||||
');
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_PRIVMSGS . " SET privmsgs_from_userid = " . DELETED . " WHERE privmsgs_from_userid IN($user_csv)");
|
||||
OLD_DB()->query("UPDATE " . BB_PRIVMSGS . " SET privmsgs_to_userid = " . DELETED . " WHERE privmsgs_to_userid IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_PRIVMSGS . ' SET privmsgs_from_userid = ' . DELETED . " WHERE privmsgs_from_userid IN($user_csv)");
|
||||
OLD_DB()->query('UPDATE ' . BB_PRIVMSGS . ' SET privmsgs_to_userid = ' . DELETED . " WHERE privmsgs_to_userid IN($user_csv)");
|
||||
|
||||
// Delete user feed
|
||||
foreach (explode(',', $user_csv) as $user_id) {
|
||||
|
@ -738,7 +736,7 @@ function get_usernames_for_log($user_id)
|
|||
$users_log_msg = array();
|
||||
|
||||
if ($user_csv = get_id_csv($user_id)) {
|
||||
$sql = "SELECT user_id, username FROM " . BB_USERS . " WHERE user_id IN($user_csv)";
|
||||
$sql = 'SELECT user_id, username FROM ' . BB_USERS . " WHERE user_id IN($user_csv)";
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
$users_log_msg[] = "<b>$row[username]</b> [$row[user_id]]";
|
||||
|
|
|
@ -13,7 +13,7 @@ function run_jobs($jobs)
|
|||
|
||||
define('IN_CRON', true);
|
||||
|
||||
$sql = "SELECT cron_script FROM " . BB_CRON . " WHERE cron_id IN ($jobs)";
|
||||
$sql = 'SELECT cron_script FROM ' . BB_CRON . " WHERE cron_id IN ($jobs)";
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not obtain cron script');
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ function run_jobs($jobs)
|
|||
while ($row = OLD_DB()->sql_fetchrow($result)) {
|
||||
$job = $row['cron_script'];
|
||||
$job_script = INC_DIR . '/cron/jobs/' . $job;
|
||||
require($job_script);
|
||||
require $job_script;
|
||||
}
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_CRON . " SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_CRON . " SET
|
||||
last_run = NOW(),
|
||||
run_counter = run_counter + 1,
|
||||
next_run =
|
||||
|
@ -46,21 +46,17 @@ function run_jobs($jobs)
|
|||
END
|
||||
WHERE cron_id IN ($jobs)
|
||||
");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function delete_jobs($jobs)
|
||||
{
|
||||
OLD_DB()->query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)");
|
||||
return;
|
||||
OLD_DB()->query('DELETE FROM ' . BB_CRON . " WHERE cron_id IN ($jobs)");
|
||||
}
|
||||
|
||||
function toggle_active($jobs, $cron_action)
|
||||
{
|
||||
$active = ($cron_action == 'disable') ? 0 : 1;
|
||||
OLD_DB()->query("UPDATE " . BB_CRON . " SET cron_active = $active WHERE cron_id IN ($jobs)");
|
||||
return;
|
||||
OLD_DB()->query('UPDATE ' . BB_CRON . " SET cron_active = $active WHERE cron_id IN ($jobs)");
|
||||
}
|
||||
|
||||
function validate_cron_post($cron_arr)
|
||||
|
@ -85,7 +81,7 @@ function validate_cron_post($cron_arr)
|
|||
|
||||
function insert_cron_job($cron_arr)
|
||||
{
|
||||
$row = OLD_DB()->fetch_row("SELECT cron_title, cron_script FROM " . BB_CRON . " WHERE cron_title = '" . $_POST['cron_title'] . "' or cron_script = '" . $_POST['cron_script'] . "' ");
|
||||
$row = OLD_DB()->fetch_row('SELECT cron_title, cron_script FROM ' . BB_CRON . " WHERE cron_title = '" . $_POST['cron_title'] . "' or cron_script = '" . $_POST['cron_script'] . "' ");
|
||||
|
||||
if ($row) {
|
||||
if ($_POST['cron_script'] == $row['cron_script']) {
|
||||
|
@ -94,7 +90,7 @@ function insert_cron_job($cron_arr)
|
|||
$errMess = trans('messages.TITLE_DUPLICATE');
|
||||
}
|
||||
|
||||
$message = $errMess . "<br /><br />" . sprintf(trans('messages.CLICK_RETURN_JOBS_ADDED'), "<a href=\"javascript:history.back(-1)\">", "</a>") . "<br /><br />" . sprintf(trans('messages.CLICK_RETURN_JOBS'), "<a href=\"admin_cron.php?mode=list\">", "</a>") . "<br /><br />" . sprintf(trans('messages.CLICK_RETURN_ADMIN_INDEX'), "<a href=\"index.php?pane=right\">", "</a>");
|
||||
$message = $errMess . '<br /><br />' . sprintf(trans('messages.CLICK_RETURN_JOBS_ADDED'), '<a href="javascript:history.back(-1)">', '</a>') . '<br /><br />' . sprintf(trans('messages.CLICK_RETURN_JOBS'), '<a href="admin_cron.php?mode=list">', '</a>') . '<br /><br />' . sprintf(trans('messages.CLICK_RETURN_ADMIN_INDEX'), '<a href="index.php?pane=right">', '</a>');
|
||||
|
||||
bb_die($message);
|
||||
}
|
||||
|
@ -115,7 +111,7 @@ function insert_cron_job($cron_arr)
|
|||
$disable_board = $cron_arr['disable_board'];
|
||||
$run_counter = $cron_arr['run_counter'];
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_CRON . " (cron_active, cron_title, cron_script, schedule, run_day, run_time, run_order, last_run, next_run, run_interval, log_enabled, log_file, log_sql_queries, disable_board, run_counter) VALUES (
|
||||
OLD_DB()->query('INSERT INTO ' . BB_CRON . " (cron_active, cron_title, cron_script, schedule, run_day, run_time, run_order, last_run, next_run, run_interval, log_enabled, log_file, log_sql_queries, disable_board, run_counter) VALUES (
|
||||
$cron_active, '$cron_title', '$cron_script', '$schedule', '$run_day', '$run_time', '$run_order', '$last_run', '$next_run', '$run_interval', $log_enabled, '$log_file', $log_sql_queries, $disable_board, '$run_counter')");
|
||||
}
|
||||
|
||||
|
@ -138,7 +134,7 @@ function update_cron_job($cron_arr)
|
|||
$disable_board = $cron_arr['disable_board'];
|
||||
$run_counter = $cron_arr['run_counter'];
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_CRON . " SET
|
||||
OLD_DB()->query('UPDATE ' . BB_CRON . " SET
|
||||
cron_active = '$cron_active',
|
||||
cron_title = '$cron_title',
|
||||
cron_script = '$cron_script',
|
||||
|
|
|
@ -41,7 +41,6 @@ function update_table_bool($table_name, $key, $field_name, $field_def_val)
|
|||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function set_tpl_vars($default_cfg, $cfg)
|
||||
|
@ -60,12 +59,12 @@ function set_tpl_vars_bool($default_cfg, $cfg)
|
|||
foreach ($default_cfg as $config_name => $config_value) {
|
||||
// YES/NO 'checked="checked"'
|
||||
$template->assign_vars(array(
|
||||
strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? HTML_CHECKED : '',
|
||||
strtoupper($config_name) . '_YES' => $cfg[$config_name] ? HTML_CHECKED : '',
|
||||
strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? HTML_CHECKED : '',
|
||||
));
|
||||
// YES/NO lang vars
|
||||
$template->assign_vars(array(
|
||||
'L_' . strtoupper($config_name) . '_YES' => ($cfg[$config_name]) ? '<u>' . trans('messages.YES') . '</u>' : trans('messages.YES'),
|
||||
'L_' . strtoupper($config_name) . '_YES' => $cfg[$config_name] ? '<u>' . trans('messages.YES') . '</u>' : trans('messages.YES'),
|
||||
'L_' . strtoupper($config_name) . '_NO' => (!$cfg[$config_name]) ? '<u>' . trans('messages.NO') . '</u>' : trans('messages.NO'),
|
||||
));
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ function update_config_table($table_name, $default_cfg, $cfg, $type)
|
|||
if ($type == 'str') {
|
||||
$config_value = $_POST[$config_name];
|
||||
} elseif ($type == 'bool') {
|
||||
$config_value = ($_POST[$config_name]) ? 1 : 0;
|
||||
$config_value = $_POST[$config_name] ? 1 : 0;
|
||||
} elseif ($type == 'num') {
|
||||
$config_value = abs((int)$_POST[$config_name]);
|
||||
} else {
|
||||
|
|
|
@ -23,24 +23,24 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
}
|
||||
if ($forum_id > 0 && $forum_data['allow_reg_tracker']) {
|
||||
$select_tor_sql = ', tor.size AS tor_size, tor.tor_status';
|
||||
$join_tor_sql = "LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)";
|
||||
$join_tor_sql = 'LEFT JOIN ' . BB_BT_TORRENTS . ' tor ON(t.topic_id = tor.topic_id)';
|
||||
}
|
||||
if ($forum_id == 0) {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
t.topic_id, t.topic_title, t.topic_status,
|
||||
u1.username AS first_username,
|
||||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,
|
||||
tor.size AS tor_size, tor.tor_status
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_TOPICS . " t ON(tor.topic_id = t.topic_id)
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
FROM ' . BB_BT_TORRENTS . ' tor
|
||||
LEFT JOIN ' . BB_TOPICS . ' t ON(tor.topic_id = t.topic_id)
|
||||
LEFT JOIN ' . BB_USERS . ' u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN ' . BB_POSTS . ' p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN ' . BB_POSTS . ' p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
LIMIT 100
|
||||
";
|
||||
';
|
||||
} elseif ($forum_id > 0) {
|
||||
$sql = "
|
||||
SELECT
|
||||
|
@ -49,10 +49,10 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time
|
||||
$select_tor_sql
|
||||
FROM " . BB_TOPICS . " t
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
FROM " . BB_TOPICS . ' t
|
||||
LEFT JOIN ' . BB_USERS . ' u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN ' . BB_POSTS . ' p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN ' . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
$join_tor_sql
|
||||
WHERE t.forum_id = $forum_id
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
|
@ -88,18 +88,18 @@ function update_forum_feed($forum_id, $forum_data)
|
|||
function update_user_feed($user_id, $username)
|
||||
{
|
||||
$file_path = config('tp.atom.path') . '/u/' . floor($user_id / 5000) . '/' . ($user_id % 100) . '/' . $user_id . '.atom';
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
t.topic_id, t.topic_title, t.topic_status,
|
||||
u1.username AS first_username,
|
||||
p1.post_time AS topic_first_post_time, p1.post_edit_time AS topic_first_post_edit_time,
|
||||
p2.post_time AS topic_last_post_time, p2.post_edit_time AS topic_last_post_edit_time,
|
||||
tor.size AS tor_size, tor.tor_status
|
||||
FROM " . BB_TOPICS . " t
|
||||
LEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
||||
FROM ' . BB_TOPICS . ' t
|
||||
LEFT JOIN ' . BB_USERS . ' u1 ON(t.topic_poster = u1.user_id)
|
||||
LEFT JOIN ' . BB_POSTS . ' p1 ON(t.topic_first_post_id = p1.post_id)
|
||||
LEFT JOIN ' . BB_POSTS . ' p2 ON(t.topic_last_post_id = p2.post_id)
|
||||
LEFT JOIN ' . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)
|
||||
WHERE t.topic_poster = $user_id
|
||||
ORDER BY t.topic_last_post_time DESC
|
||||
LIMIT 50
|
||||
|
@ -147,13 +147,13 @@ function create_atom($file_path, $mode, $id, $title, $topics)
|
|||
$time = bb_date($last_time, 'H:i:s', 0);
|
||||
break;
|
||||
}
|
||||
$atom = "";
|
||||
$atom = '';
|
||||
$atom .= "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
||||
$atom .= "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:base=\"http://" . config('tp.server_name') . config('tp.script_path') . "\">\n";
|
||||
$atom .= '<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://' . config('tp.server_name') . config('tp.script_path') . "\">\n";
|
||||
$atom .= "<title>$title</title>\n";
|
||||
$atom .= "<updated>" . $date . "T$time+00:00</updated>\n";
|
||||
$atom .= '<updated>' . $date . "T$time+00:00</updated>\n";
|
||||
$atom .= "<id>tag:rto.feed,2000:/$mode/$id</id>\n";
|
||||
$atom .= "<link href=\"http://" . config('tp.server_name') . config('tp.script_path') . "\" />\n";
|
||||
$atom .= '<link href="http://' . config('tp.server_name') . config('tp.script_path') . "\" />\n";
|
||||
foreach ($topics as $topic) {
|
||||
$topic_id = $topic['topic_id'];
|
||||
$tor_size = '';
|
||||
|
@ -168,7 +168,7 @@ function create_atom($file_path, $mode, $id, $title, $topics)
|
|||
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
|
||||
}
|
||||
$topic_title = wbr($topic_title);
|
||||
$author_name = ($topic['first_username']) ? wbr($topic['first_username']) : 'Гость';
|
||||
$author_name = $topic['first_username'] ? wbr($topic['first_username']) : 'Гость';
|
||||
$last_time = $topic['topic_last_post_time'];
|
||||
if ($topic['topic_last_post_edit_time']) {
|
||||
$last_time = $topic['topic_last_post_edit_time'];
|
||||
|
@ -185,12 +185,12 @@ function create_atom($file_path, $mode, $id, $title, $topics)
|
|||
$atom .= " <author>\n";
|
||||
$atom .= " <name>$author_name</name>\n";
|
||||
$atom .= " </author>\n";
|
||||
$atom .= " <updated>" . $date . "T$time+00:00</updated>\n";
|
||||
$atom .= " <id>tag:rto.feed," . $date . ":/t/$topic_id</id>\n";
|
||||
$atom .= ' <updated>' . $date . "T$time+00:00</updated>\n";
|
||||
$atom .= ' <id>tag:rto.feed,' . $date . ":/t/$topic_id</id>\n";
|
||||
$atom .= " <link href=\"viewtopic.php?t=$topic_id\" />\n";
|
||||
$atom .= "</entry>\n";
|
||||
}
|
||||
$atom .= "</feed>";
|
||||
$atom .= '</feed>';
|
||||
@unlink($file_path);
|
||||
$fp = fopen($file_path, 'wb');
|
||||
fwrite($fp, $atom);
|
||||
|
|
|
@ -33,28 +33,28 @@ function update_user_level($user_id)
|
|||
|
||||
OLD_DB()->query("
|
||||
REPLACE INTO $tmp_table (user_id, user_level)
|
||||
SELECT u.user_id, " . USER . "
|
||||
FROM " . BB_USERS . " u
|
||||
WHERE user_level NOT IN(" . USER . "," . ADMIN . ")
|
||||
SELECT u.user_id, " . USER . '
|
||||
FROM ' . BB_USERS . ' u
|
||||
WHERE user_level NOT IN(' . USER . ',' . ADMIN . ")
|
||||
$users_in
|
||||
UNION
|
||||
SELECT DISTINCT ug.user_id, " . GROUP_MEMBER . "
|
||||
FROM " . BB_GROUPS . " g, " . BB_USER_GROUP . " ug
|
||||
SELECT DISTINCT ug.user_id, " . GROUP_MEMBER . '
|
||||
FROM ' . BB_GROUPS . ' g, ' . BB_USER_GROUP . " ug
|
||||
WHERE g.group_single_user = 0
|
||||
AND ug.group_id = g.group_id
|
||||
AND ug.user_pending = 0
|
||||
$user_groups_in
|
||||
UNION
|
||||
SELECT DISTINCT ug.user_id, " . MOD . "
|
||||
FROM " . BB_AUTH_ACCESS . " aa, " . BB_USER_GROUP . " ug
|
||||
WHERE aa.forum_perm & " . BF_AUTH_MOD . "
|
||||
SELECT DISTINCT ug.user_id, " . MOD . '
|
||||
FROM ' . BB_AUTH_ACCESS . ' aa, ' . BB_USER_GROUP . ' ug
|
||||
WHERE aa.forum_perm & ' . BF_AUTH_MOD . "
|
||||
AND ug.group_id = aa.group_id
|
||||
AND ug.user_pending = 0
|
||||
$user_groups_in
|
||||
");
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_USERS . " u, $tmp_table lev SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_USERS . " u, $tmp_table lev SET
|
||||
u.user_level = lev.user_level
|
||||
WHERE lev.user_id = u.user_id
|
||||
AND u.user_level NOT IN(" . ADMIN . ")
|
||||
|
@ -72,15 +72,15 @@ function delete_group($group_id)
|
|||
{
|
||||
$group_id = (int)$group_id;
|
||||
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE ug, g, aa
|
||||
FROM " . BB_USER_GROUP . " ug
|
||||
LEFT JOIN " . BB_GROUPS . " g ON(g.group_id = $group_id)
|
||||
FROM ' . BB_USER_GROUP . ' ug
|
||||
LEFT JOIN ' . BB_GROUPS . " g ON(g.group_id = $group_id)
|
||||
LEFT JOIN " . BB_AUTH_ACCESS . " aa ON(aa.group_id = $group_id)
|
||||
WHERE ug.group_id = $group_id
|
||||
");
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_POSTS . " SET attach_rg_sig = 0, poster_rg_id = 0 WHERE poster_rg_id = " . $group_id);
|
||||
OLD_DB()->query('UPDATE ' . BB_POSTS . ' SET attach_rg_sig = 0, poster_rg_id = 0 WHERE poster_rg_id = ' . $group_id);
|
||||
|
||||
update_user_level('all');
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time
|
|||
'user_pending' => (int)$user_pending,
|
||||
'user_time' => (int)$user_time,
|
||||
));
|
||||
OLD_DB()->query("REPLACE INTO " . BB_USER_GROUP . $args);
|
||||
OLD_DB()->query('REPLACE INTO ' . BB_USER_GROUP . $args);
|
||||
|
||||
if (!$user_pending) {
|
||||
update_user_level($user_id);
|
||||
|
@ -102,23 +102,23 @@ function add_user_into_group($group_id, $user_id, $user_pending = 0, $user_time
|
|||
|
||||
function delete_user_group($group_id, $user_id)
|
||||
{
|
||||
OLD_DB()->query("
|
||||
DELETE FROM " . BB_USER_GROUP . "
|
||||
WHERE user_id = " . (int)$user_id . "
|
||||
AND group_id = " . (int)$group_id . "
|
||||
");
|
||||
OLD_DB()->query('
|
||||
DELETE FROM ' . BB_USER_GROUP . '
|
||||
WHERE user_id = ' . (int)$user_id . '
|
||||
AND group_id = ' . (int)$group_id . '
|
||||
');
|
||||
|
||||
update_user_level($user_id);
|
||||
}
|
||||
|
||||
function create_user_group($user_id)
|
||||
{
|
||||
OLD_DB()->query("INSERT INTO " . BB_GROUPS . " (group_single_user) VALUES (1)");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_GROUPS . ' (group_single_user) VALUES (1)');
|
||||
|
||||
$group_id = (int)OLD_DB()->sql_nextid();
|
||||
$user_id = (int)$user_id;
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_USER_GROUP . " (user_id, group_id, user_time) VALUES ($user_id, $group_id, " . TIMENOW . ")");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_USER_GROUP . " (user_id, group_id, user_time) VALUES ($user_id, $group_id, " . TIMENOW . ')');
|
||||
|
||||
return $group_id;
|
||||
}
|
||||
|
@ -126,21 +126,21 @@ function create_user_group($user_id)
|
|||
function get_group_data($group_id)
|
||||
{
|
||||
if ($group_id === 'all') {
|
||||
$sql = "SELECT g.*, u.username AS moderator_name, aa.group_id AS auth_mod
|
||||
FROM " . BB_GROUPS . " g
|
||||
LEFT JOIN " . BB_USERS . " u ON(g.group_moderator = u.user_id)
|
||||
LEFT JOIN " . BB_AUTH_ACCESS . " aa ON(aa.group_id = g.group_id AND aa.forum_perm & " . BF_AUTH_MOD . ")
|
||||
$sql = 'SELECT g.*, u.username AS moderator_name, aa.group_id AS auth_mod
|
||||
FROM ' . BB_GROUPS . ' g
|
||||
LEFT JOIN ' . BB_USERS . ' u ON(g.group_moderator = u.user_id)
|
||||
LEFT JOIN ' . BB_AUTH_ACCESS . ' aa ON(aa.group_id = g.group_id AND aa.forum_perm & ' . BF_AUTH_MOD . ')
|
||||
WHERE g.group_single_user = 0
|
||||
GROUP BY g.group_id
|
||||
ORDER BY g.group_name";
|
||||
ORDER BY g.group_name';
|
||||
} else {
|
||||
$sql = "SELECT g.*, u.username AS moderator_name, aa.group_id AS auth_mod
|
||||
FROM " . BB_GROUPS . " g
|
||||
LEFT JOIN " . BB_USERS . " u ON(g.group_moderator = u.user_id)
|
||||
LEFT JOIN " . BB_AUTH_ACCESS . " aa ON(aa.group_id = g.group_id AND aa.forum_perm & " . BF_AUTH_MOD . ")
|
||||
WHERE g.group_id = " . (int)$group_id . "
|
||||
$sql = 'SELECT g.*, u.username AS moderator_name, aa.group_id AS auth_mod
|
||||
FROM ' . BB_GROUPS . ' g
|
||||
LEFT JOIN ' . BB_USERS . ' u ON(g.group_moderator = u.user_id)
|
||||
LEFT JOIN ' . BB_AUTH_ACCESS . ' aa ON(aa.group_id = g.group_id AND aa.forum_perm & ' . BF_AUTH_MOD . ')
|
||||
WHERE g.group_id = ' . (int)$group_id . '
|
||||
AND g.group_single_user = 0
|
||||
LIMIT 1";
|
||||
LIMIT 1';
|
||||
}
|
||||
$method = ($group_id === 'all') ? 'fetch_rowset' : 'fetch_row';
|
||||
return OLD_DB()->$method($sql);
|
||||
|
@ -152,15 +152,15 @@ function delete_permissions($group_id = null, $user_id = null, $cat_id = null)
|
|||
$user_id = get_id_csv($user_id);
|
||||
$cat_id = get_id_csv($cat_id);
|
||||
|
||||
$forums_join_sql = ($cat_id) ? "
|
||||
INNER JOIN " . BB_FORUMS . " f ON(a.forum_id = f.forum_id AND f.cat_id IN($cat_id))
|
||||
$forums_join_sql = $cat_id ? '
|
||||
INNER JOIN ' . BB_FORUMS . " f ON(a.forum_id = f.forum_id AND f.cat_id IN($cat_id))
|
||||
" : '';
|
||||
|
||||
if ($group_id) {
|
||||
OLD_DB()->query("DELETE a FROM " . BB_AUTH_ACCESS . " a $forums_join_sql WHERE a.group_id IN($group_id)");
|
||||
OLD_DB()->query('DELETE a FROM ' . BB_AUTH_ACCESS . " a $forums_join_sql WHERE a.group_id IN($group_id)");
|
||||
}
|
||||
if ($user_id) {
|
||||
OLD_DB()->query("DELETE a FROM " . BB_AUTH_ACCESS_SNAP . " a $forums_join_sql WHERE a.user_id IN($user_id)");
|
||||
OLD_DB()->query('DELETE a FROM ' . BB_AUTH_ACCESS_SNAP . " a $forums_join_sql WHERE a.user_id IN($user_id)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ function store_permissions($group_id, $auth_ary)
|
|||
}
|
||||
$values = OLD_DB()->build_array('MULTI_INSERT', $values);
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_AUTH_ACCESS . $values);
|
||||
OLD_DB()->query('INSERT INTO ' . BB_AUTH_ACCESS . $values);
|
||||
}
|
||||
|
||||
function update_user_permissions($user_id = 'all')
|
||||
|
@ -192,17 +192,17 @@ function update_user_permissions($user_id = 'all')
|
|||
$delete_in = ($user_id !== 'all') ? " WHERE user_id IN($user_id)" : '';
|
||||
$users_in = ($user_id !== 'all') ? "AND ug.user_id IN($user_id)" : '';
|
||||
|
||||
OLD_DB()->query("DELETE FROM " . BB_AUTH_ACCESS_SNAP . $delete_in);
|
||||
OLD_DB()->query('DELETE FROM ' . BB_AUTH_ACCESS_SNAP . $delete_in);
|
||||
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . BB_AUTH_ACCESS_SNAP . "
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . BB_AUTH_ACCESS_SNAP . '
|
||||
(user_id, forum_id, forum_perm)
|
||||
SELECT
|
||||
ug.user_id, aa.forum_id, BIT_OR(aa.forum_perm)
|
||||
FROM
|
||||
" . BB_USER_GROUP . " ug,
|
||||
" . BB_GROUPS . " g,
|
||||
" . BB_AUTH_ACCESS . " aa
|
||||
' . BB_USER_GROUP . ' ug,
|
||||
' . BB_GROUPS . ' g,
|
||||
' . BB_AUTH_ACCESS . " aa
|
||||
WHERE
|
||||
ug.user_pending = 0
|
||||
$users_in
|
||||
|
@ -216,19 +216,19 @@ function update_user_permissions($user_id = 'all')
|
|||
function delete_orphan_usergroups()
|
||||
{
|
||||
// GROUP_SINGLE_USER without AUTH_ACCESS
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE g
|
||||
FROM " . BB_GROUPS . " g
|
||||
LEFT JOIN " . BB_AUTH_ACCESS . " aa USING(group_id)
|
||||
FROM ' . BB_GROUPS . ' g
|
||||
LEFT JOIN ' . BB_AUTH_ACCESS . ' aa USING(group_id)
|
||||
WHERE g.group_single_user = 1
|
||||
AND aa.group_id IS NULL
|
||||
");
|
||||
');
|
||||
|
||||
// orphan USER_GROUP (against GROUP table)
|
||||
OLD_DB()->query("
|
||||
OLD_DB()->query('
|
||||
DELETE ug
|
||||
FROM " . BB_USER_GROUP . " ug
|
||||
LEFT JOIN " . BB_GROUPS . " g USING(group_id)
|
||||
FROM ' . BB_USER_GROUP . ' ug
|
||||
LEFT JOIN ' . BB_GROUPS . ' g USING(group_id)
|
||||
WHERE g.group_id IS NULL
|
||||
");
|
||||
');
|
||||
}
|
||||
|
|
|
@ -41,8 +41,7 @@ function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &
|
|||
}
|
||||
|
||||
// Check message
|
||||
if (!empty($message)) {
|
||||
} elseif ($mode != 'delete') {
|
||||
if (empty($message) && $mode != 'delete') {
|
||||
$error_msg .= (!empty($error_msg)) ? '<br />' . trans('messages.EMPTY_MESSAGE') : trans('messages.EMPTY_MESSAGE');
|
||||
}
|
||||
|
||||
|
@ -71,10 +70,10 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
|
||||
// Flood control
|
||||
$row = null;
|
||||
$where_sql = (IS_GUEST) ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
|
||||
$where_sql = IS_GUEST ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
|
||||
|
||||
if ($mode == 'newtopic' || $mode == 'reply') {
|
||||
$sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE $where_sql";
|
||||
$sql = 'SELECT MAX(p.post_time) AS last_post_time FROM ' . BB_POSTS . " p WHERE $where_sql";
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql) && $row['last_post_time']) {
|
||||
if ($userdata['user_level'] == USER) {
|
||||
|
@ -87,15 +86,15 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
|
||||
// Double Post Control
|
||||
if ($mode != 'editpost' && !empty($row['last_post_time']) && !IS_AM) {
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT pt.post_text
|
||||
FROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt
|
||||
FROM ' . BB_POSTS . ' p, ' . BB_POSTS_TEXT . " pt
|
||||
WHERE
|
||||
$where_sql
|
||||
AND p.post_time = " . (int)$row['last_post_time'] . "
|
||||
AND p.post_time = " . (int)$row['last_post_time'] . '
|
||||
AND pt.post_id = p.post_id
|
||||
LIMIT 1
|
||||
";
|
||||
';
|
||||
|
||||
if ($row = OLD_DB()->fetch_row($sql)) {
|
||||
$last_msg = OLD_DB()->escape($row['post_text']);
|
||||
|
@ -109,16 +108,16 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) {
|
||||
$topic_dl_type = (isset($_POST['topic_dl_type']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod'])) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
|
||||
|
||||
$sql_insert = "
|
||||
$sql_insert = '
|
||||
INSERT INTO
|
||||
" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)
|
||||
' . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)
|
||||
VALUES
|
||||
('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type)
|
||||
";
|
||||
|
||||
$sql_update = "
|
||||
$sql_update = '
|
||||
UPDATE
|
||||
" . BB_TOPICS . "
|
||||
' . BB_TOPICS . "
|
||||
SET
|
||||
topic_title = '$post_subject',
|
||||
topic_type = $topic_type,
|
||||
|
@ -127,7 +126,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
topic_id = $topic_id
|
||||
";
|
||||
|
||||
$sql = ($mode != "editpost") ? $sql_insert : $sql_update;
|
||||
$sql = ($mode != 'editpost') ? $sql_insert : $sql_update;
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #1');
|
||||
|
@ -138,15 +137,15 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
}
|
||||
}
|
||||
|
||||
$edited_sql = ($mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post']) ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1" : "";
|
||||
$edited_sql = ($mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post']) ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1" : '';
|
||||
|
||||
if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) {
|
||||
$edited_sql .= ", post_time = $current_time ";
|
||||
//lpt
|
||||
OLD_DB()->sql_query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = $current_time WHERE topic_id = $topic_id");
|
||||
OLD_DB()->sql_query('UPDATE ' . BB_TOPICS . " SET topic_last_post_time = $current_time WHERE topic_id = $topic_id");
|
||||
}
|
||||
|
||||
$sql = ($mode != "editpost") ? "INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, poster_rg_id, attach_rg_sig) VALUES ($topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '" . USER_IP . "', $poster_rg_id, $attach_rg_sig)" : "UPDATE " . BB_POSTS . " SET post_username = '$post_username'" . $edited_sql . ", poster_rg_id = $poster_rg_id, attach_rg_sig = $attach_rg_sig WHERE post_id = $post_id";
|
||||
$sql = ($mode != 'editpost') ? 'INSERT INTO ' . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, poster_rg_id, attach_rg_sig) VALUES ($topic_id, $forum_id, " . $userdata['user_id'] . ", '$post_username', $current_time, '" . USER_IP . "', $poster_rg_id, $attach_rg_sig)" : 'UPDATE ' . BB_POSTS . " SET post_username = '$post_username'" . $edited_sql . ", poster_rg_id = $poster_rg_id, attach_rg_sig = $attach_rg_sig WHERE post_id = $post_id";
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #2');
|
||||
}
|
||||
|
@ -155,7 +154,7 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_
|
|||
$post_id = OLD_DB()->sql_nextid();
|
||||
}
|
||||
|
||||
$sql = ($mode != 'editpost') ? "INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '$post_message')" : "UPDATE " . BB_POSTS_TEXT . " SET post_text = '$post_message' WHERE post_id = $post_id";
|
||||
$sql = ($mode != 'editpost') ? 'INSERT INTO ' . BB_POSTS_TEXT . " (post_id, post_text) VALUES ($post_id, '$post_message')" : 'UPDATE ' . BB_POSTS_TEXT . " SET post_text = '$post_message' WHERE post_id = $post_id";
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #3');
|
||||
}
|
||||
|
@ -210,8 +209,8 @@ function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $u
|
|||
} else {
|
||||
$topic_update_sql .= 'topic_replies = topic_replies - 1';
|
||||
|
||||
$sql = "SELECT MAX(post_id) AS last_post_id, MAX(post_time) AS topic_last_post_time
|
||||
FROM " . BB_POSTS . "
|
||||
$sql = 'SELECT MAX(post_id) AS last_post_id, MAX(post_time) AS topic_last_post_time
|
||||
FROM ' . BB_POSTS . "
|
||||
WHERE topic_id = $topic_id";
|
||||
if (!($result = OLD_DB()->sql_query($sql))) {
|
||||
bb_die('Error in deleting post #1');
|
||||
|
@ -223,19 +222,19 @@ function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $u
|
|||
}
|
||||
|
||||
if ($post_data['last_topic']) {
|
||||
$sql = "SELECT MAX(post_id) AS last_post_id
|
||||
FROM " . BB_POSTS . "
|
||||
$sql = 'SELECT MAX(post_id) AS last_post_id
|
||||
FROM ' . BB_POSTS . "
|
||||
WHERE forum_id = $forum_id";
|
||||
if (!($result = OLD_DB()->sql_query($sql))) {
|
||||
bb_die('Error in deleting post #2');
|
||||
}
|
||||
|
||||
if ($row = OLD_DB()->sql_fetchrow($result)) {
|
||||
$forum_update_sql .= ($row['last_post_id']) ? ', forum_last_post_id = ' . $row['last_post_id'] : ', forum_last_post_id = 0';
|
||||
$forum_update_sql .= $row['last_post_id'] ? ', forum_last_post_id = ' . $row['last_post_id'] : ', forum_last_post_id = 0';
|
||||
}
|
||||
}
|
||||
} elseif ($post_data['first_post']) {
|
||||
$sql = "SELECT MIN(post_id) AS first_post_id FROM " . BB_POSTS . " WHERE topic_id = $topic_id";
|
||||
$sql = 'SELECT MIN(post_id) AS first_post_id FROM ' . BB_POSTS . " WHERE topic_id = $topic_id";
|
||||
if (!($result = OLD_DB()->sql_query($sql))) {
|
||||
bb_die('Error in deleting post #3');
|
||||
}
|
||||
|
@ -247,23 +246,23 @@ function update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $u
|
|||
$topic_update_sql .= 'topic_replies = topic_replies - 1';
|
||||
}
|
||||
} else {
|
||||
$forum_update_sql .= ", forum_last_post_id = $post_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : "");
|
||||
$forum_update_sql .= ", forum_last_post_id = $post_id" . (($mode == 'newtopic') ? ", forum_topics = forum_topics $sign" : '');
|
||||
$topic_update_sql = "topic_last_post_id = $post_id, topic_last_post_time = " . TIMENOW . (($mode == 'reply') ? ", topic_replies = topic_replies $sign" : ", topic_first_post_id = $post_id");
|
||||
}
|
||||
|
||||
$sql = "UPDATE " . BB_FORUMS . " SET $forum_update_sql WHERE forum_id = $forum_id";
|
||||
$sql = 'UPDATE ' . BB_FORUMS . " SET $forum_update_sql WHERE forum_id = $forum_id";
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #4');
|
||||
}
|
||||
|
||||
if ($topic_update_sql != '') {
|
||||
$sql = "UPDATE " . BB_TOPICS . " SET $topic_update_sql WHERE topic_id = $topic_id";
|
||||
$sql = 'UPDATE ' . BB_TOPICS . " SET $topic_update_sql WHERE topic_id = $topic_id";
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #5');
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE " . BB_USERS . " SET user_posts = user_posts $sign WHERE user_id = $user_id";
|
||||
$sql = 'UPDATE ' . BB_USERS . " SET user_posts = user_posts $sign WHERE user_id = $user_id";
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Error in posting #6');
|
||||
}
|
||||
|
@ -295,22 +294,22 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
|
|||
if ($mode == 'reply') {
|
||||
$update_watched_sql = $user_id_sql = array();
|
||||
|
||||
$sql = OLD_DB()->fetch_rowset("SELECT ban_userid FROM " . BB_BANLIST . " WHERE ban_userid != 0");
|
||||
$sql = OLD_DB()->fetch_rowset('SELECT ban_userid FROM ' . BB_BANLIST . ' WHERE ban_userid != 0');
|
||||
|
||||
foreach ($sql as $row) {
|
||||
$user_id_sql[] = ',' . $row['ban_userid'];
|
||||
}
|
||||
$user_id_sql = implode('', $user_id_sql);
|
||||
|
||||
$watch_list = OLD_DB()->fetch_rowset("SELECT u.username, u.user_id, u.user_email, u.user_lang
|
||||
FROM " . BB_TOPICS_WATCH . " tw, " . BB_USERS . " u
|
||||
$watch_list = OLD_DB()->fetch_rowset('SELECT u.username, u.user_id, u.user_email, u.user_lang
|
||||
FROM ' . BB_TOPICS_WATCH . ' tw, ' . BB_USERS . " u
|
||||
WHERE tw.topic_id = $topic_id
|
||||
AND tw.user_id NOT IN (" . $userdata['user_id'] . ", " . EXCLUDED_USERS . $user_id_sql . ")
|
||||
AND tw.notify_status = " . TOPIC_WATCH_NOTIFIED . "
|
||||
AND tw.user_id NOT IN (" . $userdata['user_id'] . ', ' . EXCLUDED_USERS . $user_id_sql . ')
|
||||
AND tw.notify_status = ' . TOPIC_WATCH_NOTIFIED . '
|
||||
AND u.user_id = tw.user_id
|
||||
AND u.user_active = 1
|
||||
ORDER BY u.user_id
|
||||
");
|
||||
');
|
||||
|
||||
if ($watch_list) {
|
||||
$orig_word = $replacement_word = array();
|
||||
|
@ -348,23 +347,23 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi
|
|||
}
|
||||
|
||||
if ($update_watched_sql) {
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS_WATCH . "
|
||||
SET notify_status = " . TOPIC_WATCH_UNNOTIFIED . "
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS_WATCH . '
|
||||
SET notify_status = ' . TOPIC_WATCH_UNNOTIFIED . "
|
||||
WHERE topic_id = $topic_id
|
||||
AND user_id IN ($update_watched_sql)
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
$topic_watch = OLD_DB()->fetch_row("SELECT topic_id FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}", 'topic_id');
|
||||
$topic_watch = OLD_DB()->fetch_row('SELECT topic_id FROM ' . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}", 'topic_id');
|
||||
|
||||
if (!$notify_user && !empty($topic_watch)) {
|
||||
OLD_DB()->query("DELETE FROM " . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_TOPICS_WATCH . " WHERE topic_id = $topic_id AND user_id = {$userdata['user_id']}");
|
||||
} elseif ($notify_user && empty($topic_watch)) {
|
||||
OLD_DB()->query("
|
||||
INSERT INTO " . BB_TOPICS_WATCH . " (user_id, topic_id, notify_status)
|
||||
VALUES (" . $userdata['user_id'] . ", $topic_id, " . TOPIC_WATCH_NOTIFIED . ")
|
||||
");
|
||||
OLD_DB()->query('
|
||||
INSERT INTO ' . BB_TOPICS_WATCH . ' (user_id, topic_id, notify_status)
|
||||
VALUES (' . $userdata['user_id'] . ", $topic_id, " . TOPIC_WATCH_NOTIFIED . ')
|
||||
');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -386,8 +385,8 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
return;
|
||||
}
|
||||
|
||||
$sql = "SELECT forum_id, forum_name
|
||||
FROM " . BB_FORUMS . "
|
||||
$sql = 'SELECT forum_id, forum_name
|
||||
FROM ' . BB_FORUMS . "
|
||||
WHERE forum_id IN($forum_id, $old_forum_id)";
|
||||
|
||||
$forum_names = array();
|
||||
|
@ -408,8 +407,8 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
$poster_id = BOT_UID;
|
||||
$poster_ip = '7f000001';
|
||||
} elseif ($mode == 'after_split_to_new') {
|
||||
$sql = "SELECT t.topic_title, p.post_time
|
||||
FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
|
||||
$sql = 'SELECT t.topic_title, p.post_time
|
||||
FROM ' . BB_TOPICS . ' t, ' . BB_POSTS . " p
|
||||
WHERE t.topic_id = $old_topic_id
|
||||
AND p.post_id = t.topic_first_post_id";
|
||||
|
||||
|
@ -430,7 +429,7 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
$post_columns = 'topic_id, forum_id, poster_id, post_username, post_time, poster_ip';
|
||||
$post_values = "$topic_id, $forum_id, $poster_id, '$post_username', $post_time, '$poster_ip'";
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_POSTS . " ($post_columns) VALUES ($post_values)");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_POSTS . " ($post_columns) VALUES ($post_values)");
|
||||
|
||||
$post_id = OLD_DB()->sql_nextid();
|
||||
$post_text = OLD_DB()->escape($post_text);
|
||||
|
@ -438,7 +437,7 @@ function insert_post($mode, $topic_id, $forum_id = '', $old_forum_id = '', $new_
|
|||
$post_text_columns = 'post_id, post_text';
|
||||
$post_text_values = "$post_id, '$post_text'";
|
||||
|
||||
OLD_DB()->query("INSERT INTO " . BB_POSTS_TEXT . " ($post_text_columns) VALUES ($post_text_values)");
|
||||
OLD_DB()->query('INSERT INTO ' . BB_POSTS_TEXT . " ($post_text_columns) VALUES ($post_text_values)");
|
||||
}
|
||||
|
||||
function topic_review($topic_id)
|
||||
|
@ -446,18 +445,18 @@ function topic_review($topic_id)
|
|||
global $template;
|
||||
|
||||
// Fetch posts data
|
||||
$review_posts = OLD_DB()->fetch_rowset("
|
||||
$review_posts = OLD_DB()->fetch_rowset('
|
||||
SELECT
|
||||
p.*, h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text,
|
||||
IF(p.poster_id = " . GUEST_UID . ", p.post_username, u.username) AS username, u.user_rank
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_USERS . " u ON(u.user_id = p.poster_id)
|
||||
LEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN " . BB_POSTS_HTML . " h ON(h.post_id = p.post_id)
|
||||
WHERE p.topic_id = " . (int)$topic_id . "
|
||||
IF(p.poster_id = ' . GUEST_UID . ', p.post_username, u.username) AS username, u.user_rank
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_USERS . ' u ON(u.user_id = p.poster_id)
|
||||
LEFT JOIN ' . BB_POSTS_TEXT . ' pt ON(pt.post_id = p.post_id)
|
||||
LEFT JOIN ' . BB_POSTS_HTML . ' h ON(h.post_id = p.post_id)
|
||||
WHERE p.topic_id = ' . (int)$topic_id . '
|
||||
ORDER BY p.post_time DESC
|
||||
LIMIT " . config('tp.posts_per_page') . "
|
||||
");
|
||||
LIMIT ' . config('tp.posts_per_page') . '
|
||||
');
|
||||
|
||||
// Topic posts block
|
||||
foreach ($review_posts as $i => $post) {
|
||||
|
|
|
@ -15,18 +15,18 @@ function get_torrent_info($attach_id)
|
|||
{
|
||||
$attach_id = (int)$attach_id;
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
a.post_id, d.physical_filename, d.extension, d.tracker_status,
|
||||
t.topic_first_post_id,
|
||||
p.poster_id, p.topic_id, p.forum_id,
|
||||
f.allow_reg_tracker
|
||||
FROM
|
||||
" . BB_ATTACHMENTS . " a,
|
||||
" . BB_ATTACHMENTS_DESC . " d,
|
||||
" . BB_POSTS . " p,
|
||||
" . BB_TOPICS . " t,
|
||||
" . BB_FORUMS . " f
|
||||
' . BB_ATTACHMENTS . ' a,
|
||||
' . BB_ATTACHMENTS_DESC . ' d,
|
||||
' . BB_POSTS . ' p,
|
||||
' . BB_TOPICS . ' t,
|
||||
' . BB_FORUMS . " f
|
||||
WHERE
|
||||
a.attach_id = $attach_id
|
||||
AND d.attach_id = $attach_id
|
||||
|
@ -84,7 +84,7 @@ function tracker_unregister($attach_id, $mode = '')
|
|||
}
|
||||
|
||||
if (!$topic_id) {
|
||||
$sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id";
|
||||
$sql = 'SELECT topic_id FROM ' . BB_BT_TORRENTS . " WHERE attach_id = $attach_id";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not query torrent information');
|
||||
|
@ -96,7 +96,7 @@ function tracker_unregister($attach_id, $mode = '')
|
|||
|
||||
// Unset DL-Type for topic
|
||||
if (config('tp.bt_unset_dltype_on_tor_unreg') && $topic_id) {
|
||||
$sql = "UPDATE " . BB_TOPICS . " SET topic_dl_type = " . TOPIC_DL_TYPE_NORMAL . " WHERE topic_id = $topic_id";
|
||||
$sql = 'UPDATE ' . BB_TOPICS . ' SET topic_dl_type = ' . TOPIC_DL_TYPE_NORMAL . " WHERE topic_id = $topic_id";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not update topics table #1');
|
||||
|
@ -104,7 +104,7 @@ function tracker_unregister($attach_id, $mode = '')
|
|||
}
|
||||
|
||||
// Remove peers from tracker
|
||||
$sql = "DELETE FROM " . BB_BT_TRACKER . " WHERE topic_id = $topic_id";
|
||||
$sql = 'DELETE FROM ' . BB_BT_TRACKER . " WHERE topic_id = $topic_id";
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not delete peers');
|
||||
|
@ -112,21 +112,21 @@ function tracker_unregister($attach_id, $mode = '')
|
|||
|
||||
// Ocelot
|
||||
if (config('tp.ocelot.enabled')) {
|
||||
if ($row = OLD_DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT info_hash FROM ' . BB_BT_TORRENTS . " WHERE attach_id = $attach_id LIMIT 1")) {
|
||||
$info_hash = $row['info_hash'];
|
||||
}
|
||||
ocelot_update_tracker('delete_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id));
|
||||
}
|
||||
|
||||
// Delete torrent
|
||||
$sql = "DELETE FROM " . BB_BT_TORRENTS . " WHERE attach_id = $attach_id";
|
||||
$sql = 'DELETE FROM ' . BB_BT_TORRENTS . " WHERE attach_id = $attach_id";
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not delete torrent from torrents table');
|
||||
}
|
||||
|
||||
// Update tracker_status
|
||||
$sql = "UPDATE " . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id";
|
||||
$sql = 'UPDATE ' . BB_ATTACHMENTS_DESC . " SET tracker_status = 0 WHERE attach_id = $attach_id";
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not update torrent status #1');
|
||||
|
@ -160,8 +160,6 @@ function delete_torrent($attach_id, $mode = '')
|
|||
torrent_auth_check($forum_id, $poster_id);
|
||||
tracker_unregister($attach_id);
|
||||
delete_attachment(0, $attach_id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function change_tor_status($attach_id, $new_tor_status)
|
||||
|
@ -179,8 +177,8 @@ function change_tor_status($attach_id, $new_tor_status)
|
|||
|
||||
torrent_auth_check($torrent['forum_id'], $torrent['poster_id']);
|
||||
|
||||
OLD_DB()->query("
|
||||
UPDATE " . BB_BT_TORRENTS . " SET
|
||||
OLD_DB()->query('
|
||||
UPDATE ' . BB_BT_TORRENTS . " SET
|
||||
tor_status = $new_tor_status,
|
||||
checked_user_id = {$userdata['user_id']},
|
||||
checked_time = '" . TIMENOW . "'
|
||||
|
@ -206,11 +204,11 @@ function change_tor_type($attach_id, $tor_status_gold)
|
|||
$tor_status_gold = (int)$tor_status_gold;
|
||||
$info_hash = null;
|
||||
|
||||
OLD_DB()->query("UPDATE " . BB_BT_TORRENTS . " SET tor_type = $tor_status_gold WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_BT_TORRENTS . " SET tor_type = $tor_status_gold WHERE topic_id = $topic_id");
|
||||
|
||||
// Ocelot
|
||||
if (config('tp.ocelot.enabled')) {
|
||||
if ($row = OLD_DB()->fetch_row("SELECT info_hash FROM " . BB_BT_TORRENTS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT info_hash FROM ' . BB_BT_TORRENTS . " WHERE topic_id = $topic_id LIMIT 1")) {
|
||||
$info_hash = $row['info_hash'];
|
||||
}
|
||||
ocelot_update_tracker('update_torrent', array('info_hash' => rawurlencode($info_hash), 'freetorrent' => $tor_status_gold));
|
||||
|
@ -299,7 +297,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
|
|||
ocelot_update_tracker('add_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id, 'freetorrent' => 0));
|
||||
}
|
||||
|
||||
if ($row = OLD_DB()->fetch_row("SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash_sql' LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT topic_id FROM ' . BB_BT_TORRENTS . " WHERE info_hash = '$info_hash_sql' LIMIT 1")) {
|
||||
$msg = sprintf(trans('messages.BT_REG_FAIL_SAME_HASH'), TOPIC_URL . $row['topic_id']);
|
||||
bb_die($msg);
|
||||
set_die_append_msg($forum_id, $topic_id);
|
||||
|
@ -322,7 +320,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
|
|||
$columns = ' info_hash, post_id, poster_id, topic_id, forum_id, attach_id, size, reg_time, tor_status';
|
||||
$values = "'$info_hash_sql', $post_id, $poster_id, $topic_id, $forum_id, $attach_id, '$size', $reg_time, $tor_status";
|
||||
|
||||
$sql = "INSERT INTO " . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
|
||||
$sql = 'INSERT INTO ' . BB_BT_TORRENTS . " ($columns) VALUES ($values)";
|
||||
|
||||
if (!OLD_DB()->sql_query($sql)) {
|
||||
$sql_error = OLD_DB()->sql_error();
|
||||
|
@ -352,7 +350,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
|
|||
}
|
||||
|
||||
if (config('tracker.tor_topic_up')) {
|
||||
OLD_DB()->query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = GREATEST(topic_last_post_time, " . (TIMENOW - 3 * 86400) . ") WHERE topic_id = $topic_id");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPICS . ' SET topic_last_post_time = GREATEST(topic_last_post_time, ' . (TIMENOW - 3 * 86400) . ") WHERE topic_id = $topic_id");
|
||||
}
|
||||
|
||||
if ($reg_mode == 'request' || $reg_mode == 'newtopic') {
|
||||
|
@ -360,8 +358,6 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
|
|||
$mess = sprintf(trans('messages.BT_REGISTERED'), DOWNLOAD_URL . $attach_id);
|
||||
bb_die($mess);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function send_torrent_with_passkey($filename)
|
||||
|
@ -422,10 +418,10 @@ function send_torrent_with_passkey($filename)
|
|||
|
||||
if ($min_ratio && $user_id != $poster_id && ($user_ratio = get_bt_ratio($bt_userdata)) !== null) {
|
||||
if ($user_ratio < $min_ratio && $post_id) {
|
||||
$dl = OLD_DB()->fetch_row("
|
||||
$dl = OLD_DB()->fetch_row('
|
||||
SELECT dl.user_status
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_BT_DLSTATUS . " dl ON dl.topic_id = p.topic_id AND dl.user_id = $user_id
|
||||
FROM ' . BB_POSTS . ' p
|
||||
LEFT JOIN ' . BB_BT_DLSTATUS . " dl ON dl.topic_id = p.topic_id AND dl.user_id = $user_id
|
||||
WHERE p.post_id = $post_id
|
||||
LIMIT 1
|
||||
");
|
||||
|
@ -444,7 +440,7 @@ function send_torrent_with_passkey($filename)
|
|||
bb_die('This is not a bencoded file');
|
||||
}
|
||||
|
||||
$announce = config('tp.ocelot.enabled') ? (string)(config('tp.ocelot.url') . $passkey_val . "/announce") : (string)($ann_url . "?$passkey_key=$passkey_val");
|
||||
$announce = config('tp.ocelot.enabled') ? (string)(config('tp.ocelot.url') . $passkey_val . '/announce') : (string)($ann_url . "?$passkey_key=$passkey_val");
|
||||
|
||||
// Replace original announce url with tracker default
|
||||
if (config('tp.bt_replace_ann_url') || !isset($tor['announce'])) {
|
||||
|
@ -513,7 +509,7 @@ function generate_passkey($user_id, $force_generate = false)
|
|||
|
||||
// Check if user can change passkey
|
||||
if (!$force_generate) {
|
||||
$sql = "SELECT user_opt FROM " . BB_USERS . " WHERE user_id = $user_id LIMIT 1";
|
||||
$sql = 'SELECT user_opt FROM ' . BB_USERS . " WHERE user_id = $user_id LIMIT 1";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not query userdata for passkey');
|
||||
|
@ -529,18 +525,18 @@ function generate_passkey($user_id, $force_generate = false)
|
|||
$passkey_val = make_rand_str(BT_AUTH_KEY_LENGTH);
|
||||
$old_passkey = null;
|
||||
|
||||
if ($row = OLD_DB()->fetch_row("SELECT auth_key FROM " . BB_BT_USERS . " WHERE user_id = $user_id LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT auth_key FROM ' . BB_BT_USERS . " WHERE user_id = $user_id LIMIT 1")) {
|
||||
$old_passkey = $row['auth_key'];
|
||||
}
|
||||
|
||||
// Insert new row
|
||||
OLD_DB()->query("INSERT IGNORE INTO " . BB_BT_USERS . " (user_id, auth_key) VALUES ($user_id, '$passkey_val')");
|
||||
OLD_DB()->query('INSERT IGNORE INTO ' . BB_BT_USERS . " (user_id, auth_key) VALUES ($user_id, '$passkey_val')");
|
||||
|
||||
if (OLD_DB()->affected_rows() == 1) {
|
||||
return $passkey_val;
|
||||
}
|
||||
// Update
|
||||
OLD_DB()->query("UPDATE IGNORE " . BB_BT_USERS . " SET auth_key = '$passkey_val' WHERE user_id = $user_id");
|
||||
OLD_DB()->query('UPDATE IGNORE ' . BB_BT_USERS . " SET auth_key = '$passkey_val' WHERE user_id = $user_id");
|
||||
|
||||
if (OLD_DB()->affected_rows() == 1) {
|
||||
// Ocelot
|
||||
|
@ -555,19 +551,19 @@ function generate_passkey($user_id, $force_generate = false)
|
|||
|
||||
function tracker_rm_torrent($topic_id)
|
||||
{
|
||||
return OLD_DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE topic_id = " . (int)$topic_id);
|
||||
return OLD_DB()->sql_query('DELETE FROM ' . BB_BT_TRACKER . ' WHERE topic_id = ' . (int)$topic_id);
|
||||
}
|
||||
|
||||
function tracker_rm_user($user_id)
|
||||
{
|
||||
return OLD_DB()->sql_query("DELETE FROM " . BB_BT_TRACKER . " WHERE user_id = " . (int)$user_id);
|
||||
return OLD_DB()->sql_query('DELETE FROM ' . BB_BT_TRACKER . ' WHERE user_id = ' . (int)$user_id);
|
||||
}
|
||||
|
||||
function get_registered_torrents($id, $mode)
|
||||
{
|
||||
$field = ($mode == 'topic') ? 'topic_id' : 'post_id';
|
||||
|
||||
$sql = "SELECT topic_id FROM " . BB_BT_TORRENTS . " WHERE $field = $id LIMIT 1";
|
||||
$sql = 'SELECT topic_id FROM ' . BB_BT_TORRENTS . " WHERE $field = $id LIMIT 1";
|
||||
|
||||
if (!$result = OLD_DB()->sql_query($sql)) {
|
||||
bb_die('Could not query torrent id');
|
||||
|
@ -622,7 +618,7 @@ function ocelot_send_request($get, $max_attempts = 1, &$err = false)
|
|||
$file = fsockopen(config('tp.ocelot.host'), config('tp.ocelot.port'), $error_num, $error_string);
|
||||
if ($file) {
|
||||
if (fwrite($file, $header) === false) {
|
||||
$err = "Failed to fwrite()";
|
||||
$err = 'Failed to fwrite()';
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -639,10 +635,10 @@ function ocelot_send_request($get, $max_attempts = 1, &$err = false)
|
|||
if ($data_end > $data_start) {
|
||||
$data = substr($response, $data_start, $data_end - $data_start);
|
||||
} else {
|
||||
$data = "";
|
||||
$data = '';
|
||||
}
|
||||
$status = substr($response, $data_end + 1);
|
||||
if ($status == "success") {
|
||||
if ($status == 'success') {
|
||||
$success = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ function validate_username($username, $check_ban_and_taken = true)
|
|||
// Allowed symbols
|
||||
if (!preg_match('#^[' . $name_chars . ']+$#iu', $username, $m)) {
|
||||
$invalid_chars = preg_replace('#[' . $name_chars . ']#iu', '', $username);
|
||||
return "{trans('messages.USERNAME_INVALID')}: <b>" . htmlCHR($invalid_chars) . "</b>";
|
||||
return "{trans('messages.USERNAME_INVALID')}: <b>" . htmlCHR($invalid_chars) . '</b>';
|
||||
}
|
||||
// HTML Entities
|
||||
if (preg_match_all('/&(#[0-9]+|[a-z]+);/iu', $username, $m)) {
|
||||
|
@ -46,7 +46,7 @@ function validate_username($username, $check_ban_and_taken = true)
|
|||
// Занято
|
||||
$username_sql = OLD_DB()->escape($username);
|
||||
|
||||
if ($row = OLD_DB()->fetch_row("SELECT username FROM " . BB_USERS . " WHERE username = '$username_sql' LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT username FROM ' . BB_USERS . " WHERE username = '$username_sql' LIMIT 1")) {
|
||||
if ((!IS_GUEST && $row['username'] != $user->name) || IS_GUEST) {
|
||||
return trans('messages.USERNAME_TAKEN');
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ function validate_username($username, $check_ban_and_taken = true)
|
|||
// Запрещено
|
||||
$banned_names = array();
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT disallow_username FROM " . BB_DISALLOW . " ORDER BY NULL") as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT disallow_username FROM ' . BB_DISALLOW . ' ORDER BY NULL') as $row) {
|
||||
$banned_names[] = str_replace('\*', '.*?', preg_quote($row['disallow_username'], '#u'));
|
||||
}
|
||||
if ($banned_names_exp = implode('|', $banned_names)) {
|
||||
|
@ -82,7 +82,7 @@ function validate_email($email, $check_ban_and_taken = true)
|
|||
if ($check_ban_and_taken) {
|
||||
$banned_emails = array();
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset("SELECT ban_email FROM " . BB_BANLIST . " ORDER BY NULL") as $row) {
|
||||
foreach (OLD_DB()->fetch_rowset('SELECT ban_email FROM ' . BB_BANLIST . ' ORDER BY NULL') as $row) {
|
||||
$banned_emails[] = str_replace('\*', '.*?', preg_quote($row['ban_email'], '#'));
|
||||
}
|
||||
if ($banned_emails_exp = implode('|', $banned_emails)) {
|
||||
|
@ -93,7 +93,7 @@ function validate_email($email, $check_ban_and_taken = true)
|
|||
|
||||
$email_sql = OLD_DB()->escape($email);
|
||||
|
||||
if ($row = OLD_DB()->fetch_row("SELECT `user_email` FROM " . BB_USERS . " WHERE user_email = '$email_sql' LIMIT 1")) {
|
||||
if ($row = OLD_DB()->fetch_row('SELECT `user_email` FROM ' . BB_USERS . " WHERE user_email = '$email_sql' LIMIT 1")) {
|
||||
if ($row['user_email'] == $userdata['user_email']) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ if ((empty($_POST) && !defined('IN_ADMIN') && !defined('IN_AJAX') && !file_exist
|
|||
|
||||
TorrentPier\Helpers\CronHelper::trackRunning('start');
|
||||
|
||||
require(CRON_DIR . 'cron_check.php');
|
||||
require CRON_DIR . 'cron_check.php';
|
||||
|
||||
TorrentPier\Helpers\CronHelper::trackRunning('end');
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ $users_cnt = [
|
|||
];
|
||||
$online = $online_short = array('userlist' => '');
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT
|
||||
u.username, u.user_id, u.user_opt, u.user_rank, u.user_level,
|
||||
s.session_logged_in, s.session_ip, (s.session_time - s.session_start) AS ses_len, COUNT(s.session_id) AS sessions, COUNT(DISTINCT s.session_ip) AS ips
|
||||
FROM " . BB_SESSIONS . " s, " . BB_USERS . " u
|
||||
FROM ' . BB_SESSIONS . ' s, ' . BB_USERS . " u
|
||||
WHERE s.session_time > $time_online
|
||||
AND u.user_id = s.session_user_id
|
||||
GROUP BY u.username, u.user_id, u.user_opt, u.user_rank, u.user_level, s.session_user_id, s.session_logged_in, s.session_ip, s.session_time, s.session_start
|
||||
|
@ -75,7 +75,7 @@ foreach (OLD_DB()->fetch_rowset($sql) as $u) {
|
|||
$stat[] = "t:<span style=\"color: #1E90FF\">$t</span>";
|
||||
}
|
||||
|
||||
$ulist[$level][] = ($stat) ? "$name<span class=\"ou_stat\" style=\"color: #707070\" title=\"{$u['session_ip']}\"> [<b>" . implode(', ', $stat) . '</b>]</span>' : $name;
|
||||
$ulist[$level][] = $stat ? "$name<span class=\"ou_stat\" style=\"color: #707070\" title=\"{$u['session_ip']}\"> [<b>" . implode(', ', $stat) . '</b>]</span>' : $name;
|
||||
} else {
|
||||
$guests_online = $u['ips'];
|
||||
$users_cnt['guest'] = $guests_online;
|
||||
|
|
|
@ -17,8 +17,8 @@ if (!empty($template)) {
|
|||
$template->assign_vars(array(
|
||||
'SIMPLE_FOOTER' => !empty($gen_simple_header),
|
||||
'POWERED' => 'Tracker software by <a target="_blank" href="https://torrentpier.com">TorrentPier</a> © 2005-' . date('Y'),
|
||||
'SHOW_ADMIN_LINK' => (IS_ADMIN && !defined('IN_ADMIN')),
|
||||
'ADMIN_LINK_HREF' => "admin/index.php",
|
||||
'SHOW_ADMIN_LINK' => IS_ADMIN && !defined('IN_ADMIN'),
|
||||
'ADMIN_LINK_HREF' => 'admin/index.php',
|
||||
));
|
||||
|
||||
$template->set_filenames(array('page_footer' => 'page_footer.tpl'));
|
||||
|
@ -41,7 +41,7 @@ if ($show_dbg_info) {
|
|||
|
||||
if (!empty($DBS)) {
|
||||
$sql_t = $DBS->sql_timetotal;
|
||||
$sql_time_txt = ($sql_t) ? sprintf('%.3f ' . trans('messages.SEC') . ' (%d%%) · ', $sql_t, round($sql_t * 100 / $gen_time)) : '';
|
||||
$sql_time_txt = $sql_t ? sprintf('%.3f ' . trans('messages.SEC') . ' (%d%%) · ', $sql_t, round($sql_t * 100 / $gen_time)) : '';
|
||||
$num_q = $DBS->num_queries;
|
||||
$stat .= " | MySQL: {$sql_time_txt}{$num_q} " . trans('messages.QUERIES');
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ if ($show_dbg_info) {
|
|||
for ($i = 0; $i < 3; $i++) {
|
||||
$l[$i] = round($l[$i], 1);
|
||||
}
|
||||
$stat .= " | " . trans('messages.LIMIT') . " $l[0] $l[1] $l[2]";
|
||||
$stat .= ' | ' . trans('messages.LIMIT') . " $l[0] $l[1] $l[2]";
|
||||
}
|
||||
|
||||
$stat .= ' ]';
|
||||
|
|
|
@ -22,7 +22,7 @@ $logged_in = (int)!empty($userdata['session_logged_in']);
|
|||
|
||||
// Generate logged in/logged out status
|
||||
if ($logged_in) {
|
||||
$u_login_logout = BB_ROOT . LOGIN_URL . "?logout=1";
|
||||
$u_login_logout = BB_ROOT . LOGIN_URL . '?logout=1';
|
||||
} else {
|
||||
$u_login_logout = BB_ROOT . LOGIN_URL;
|
||||
}
|
||||
|
@ -78,13 +78,13 @@ if ($logged_in && empty($gen_simple_header) && !defined('IN_ADMIN')) {
|
|||
if (!$have_new_pm && $userdata['user_unread_privmsg']) {
|
||||
// synch unread pm count
|
||||
if (defined('IN_PM')) {
|
||||
$row = OLD_DB()->fetch_row("
|
||||
$row = OLD_DB()->fetch_row('
|
||||
SELECT COUNT(*) AS pm_count
|
||||
FROM " . BB_PRIVMSGS . "
|
||||
WHERE privmsgs_to_userid = " . $userdata['user_id'] . "
|
||||
AND privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . "
|
||||
FROM ' . BB_PRIVMSGS . '
|
||||
WHERE privmsgs_to_userid = ' . $userdata['user_id'] . '
|
||||
AND privmsgs_type = ' . PRIVMSGS_UNREAD_MAIL . '
|
||||
GROUP BY privmsgs_to_userid
|
||||
");
|
||||
');
|
||||
|
||||
$real_unread_pm_count = (int)$row['pm_count'];
|
||||
|
||||
|
@ -112,17 +112,17 @@ $template->assign_vars(array(
|
|||
'CONTENT_ENCODING' => config('language.charset'),
|
||||
|
||||
'IN_ADMIN' => defined('IN_ADMIN'),
|
||||
'USER_HIDE_CAT' => (BB_SCRIPT == 'index'),
|
||||
'USER_HIDE_CAT' => BB_SCRIPT == 'index',
|
||||
|
||||
'USER_LANG' => $userdata['user_lang'],
|
||||
|
||||
'INCLUDE_BBCODE_JS' => !empty($page_cfg['include_bbcode_js']),
|
||||
'USER_OPTIONS_JS' => (IS_GUEST) ? '{}' : json_encode($user->opt_js),
|
||||
'USER_OPTIONS_JS' => IS_GUEST ? '{}' : json_encode($user->opt_js),
|
||||
|
||||
'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']),
|
||||
|
||||
'SITENAME' => config('tp.sitename'),
|
||||
'U_INDEX' => BB_ROOT . "index.php",
|
||||
'U_INDEX' => BB_ROOT . 'index.php',
|
||||
'T_INDEX' => sprintf(trans('messages.FORUM_INDEX'), config('tp.sitename')),
|
||||
|
||||
'IS_GUEST' => IS_GUEST,
|
||||
|
@ -151,20 +151,20 @@ $template->assign_vars(array(
|
|||
'S_LOGIN_ACTION' => LOGIN_URL,
|
||||
|
||||
'U_CUR_DOWNLOADS' => PROFILE_URL . $userdata['user_id'],
|
||||
'U_FORUM' => "viewforum.php",
|
||||
'U_GROUPS' => "group.php",
|
||||
'U_FORUM' => 'viewforum.php',
|
||||
'U_GROUPS' => 'group.php',
|
||||
'U_LOGIN_LOGOUT' => $u_login_logout,
|
||||
'U_MEMBERLIST' => "memberlist.php",
|
||||
'U_MODCP' => "modcp.php",
|
||||
'U_OPTIONS' => "profile.php?mode=editprofile",
|
||||
'U_PRIVATEMSGS' => PM_URL . "?folder=inbox",
|
||||
'U_MEMBERLIST' => 'memberlist.php',
|
||||
'U_MODCP' => 'modcp.php',
|
||||
'U_OPTIONS' => 'profile.php?mode=editprofile',
|
||||
'U_PRIVATEMSGS' => PM_URL . '?folder=inbox',
|
||||
'U_PROFILE' => PROFILE_URL . $userdata['user_id'],
|
||||
'U_READ_PM' => PM_URL . "?folder=inbox" . (($userdata['user_newest_pm_id'] && $userdata['user_new_privmsg'] == 1) ? "&mode=read&p={$userdata['user_newest_pm_id']}" : ''),
|
||||
'U_REGISTER' => "profile.php?mode=register",
|
||||
'U_SEARCH' => "search.php",
|
||||
'U_SEND_PASSWORD' => "profile.php?mode=sendpassword",
|
||||
'U_READ_PM' => PM_URL . '?folder=inbox' . (($userdata['user_newest_pm_id'] && $userdata['user_new_privmsg'] == 1) ? "&mode=read&p={$userdata['user_newest_pm_id']}" : ''),
|
||||
'U_REGISTER' => 'profile.php?mode=register',
|
||||
'U_SEARCH' => 'search.php',
|
||||
'U_SEND_PASSWORD' => 'profile.php?mode=sendpassword',
|
||||
'U_TERMS' => config('tp.terms_and_conditions_url'),
|
||||
'U_TRACKER' => "tracker.php",
|
||||
'U_TRACKER' => 'tracker.php',
|
||||
|
||||
'SHOW_SIDEBAR1' => !empty(config('page.show_sidebar1.' . BB_SCRIPT)) || config('tp.show_sidebar1_on_every_page'),
|
||||
'SHOW_SIDEBAR2' => !empty(config('page.show_sidebar2.' . BB_SCRIPT)) || config('tp.show_sidebar2_on_every_page'),
|
||||
|
@ -260,12 +260,12 @@ if (!empty(config('page.show_torhelp.' . BB_SCRIPT)) && !empty($userdata['torhel
|
|||
bb_setcookie('torhelp', '', COOKIE_EXPIRED);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
$sql = '
|
||||
SELECT topic_id, topic_title
|
||||
FROM " . BB_TOPICS . "
|
||||
WHERE topic_id IN(" . $userdata['torhelp'] . ")
|
||||
FROM ' . BB_TOPICS . '
|
||||
WHERE topic_id IN(' . $userdata['torhelp'] . ')
|
||||
LIMIT 8
|
||||
";
|
||||
';
|
||||
$torhelp_topics = array();
|
||||
|
||||
foreach (OLD_DB()->fetch_rowset($sql) as $row) {
|
||||
|
@ -279,7 +279,7 @@ if (!empty(config('page.show_torhelp.' . BB_SCRIPT)) && !empty($userdata['torhel
|
|||
}
|
||||
|
||||
// Login box
|
||||
$in_out = ($logged_in) ? 'in' : 'out';
|
||||
$in_out = $logged_in ? 'in' : 'out';
|
||||
$template->assign_block_vars("switch_user_logged_{$in_out}", array());
|
||||
|
||||
if (!IS_GUEST) {
|
||||
|
|
|
@ -15,14 +15,14 @@ $can_edit_tpl = IS_SUPER_ADMIN;
|
|||
$edit_tpl_mode = ($can_edit_tpl && !empty($_REQUEST['edit_tpl']));
|
||||
|
||||
// forum_data
|
||||
$sql = "SELECT forum_name, allow_reg_tracker, forum_tpl_id FROM " . BB_FORUMS . " WHERE forum_id = $forum_id LIMIT 1";
|
||||
$sql = 'SELECT forum_name, allow_reg_tracker, forum_tpl_id FROM ' . BB_FORUMS . " WHERE forum_id = $forum_id LIMIT 1";
|
||||
|
||||
if (!$forum_id || !$f_data = OLD_DB()->fetch_row($sql)) {
|
||||
bb_die(trans('messages.FORUM_NOT_EXIST'));
|
||||
}
|
||||
// tpl_data
|
||||
$tpl_data = array();
|
||||
$sql = "SELECT * FROM " . BB_TOPIC_TPL . " WHERE tpl_id = {$f_data['forum_tpl_id']} LIMIT 1";
|
||||
$sql = 'SELECT * FROM ' . BB_TOPIC_TPL . " WHERE tpl_id = {$f_data['forum_tpl_id']} LIMIT 1";
|
||||
|
||||
if (!$f_data['forum_tpl_id'] || !$tpl_data = OLD_DB()->fetch_row($sql)) {
|
||||
if (!$edit_tpl_mode) {
|
||||
|
@ -47,9 +47,9 @@ if ($tpl_data) {
|
|||
$tpl_rules_html = '';
|
||||
|
||||
if ($tpl_data['tpl_rules_post_id']) {
|
||||
if (!$tpl_rules_html = bbcode2html(OLD_DB()->fetch_row("SELECT post_text FROM " . BB_POSTS_TEXT . " WHERE post_id = " . $tpl_data['tpl_rules_post_id'], 'post_text'))) {
|
||||
if (!$tpl_rules_html = bbcode2html(OLD_DB()->fetch_row('SELECT post_text FROM ' . BB_POSTS_TEXT . ' WHERE post_id = ' . $tpl_data['tpl_rules_post_id'], 'post_text'))) {
|
||||
$tpl_data['tpl_rules_post_id'] = 0;
|
||||
OLD_DB()->query("UPDATE " . BB_TOPIC_TPL . " SET tpl_rules_post_id = 0 WHERE tpl_id = {$f_data['forum_tpl_id']}");
|
||||
OLD_DB()->query('UPDATE ' . BB_TOPIC_TPL . " SET tpl_rules_post_id = 0 WHERE tpl_id = {$f_data['forum_tpl_id']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ if ($tpl_data) {
|
|||
|
||||
if ($edit_tpl_mode) {
|
||||
$template->assign_vars(array(
|
||||
'NO_TPL_ASSIGNED' => !($f_data['forum_tpl_id']),
|
||||
'NO_TPL_ASSIGNED' => !$f_data['forum_tpl_id'],
|
||||
'TPL_SELECT' => get_select('forum_tpl', $f_data['forum_tpl_id']),
|
||||
));
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ function cache_rm_user_sessions($user_id)
|
|||
{
|
||||
$user_id = get_id_csv($user_id);
|
||||
|
||||
$rowset = OLD_DB()->fetch_rowset("
|
||||
SELECT session_id FROM " . BB_SESSIONS . " WHERE session_user_id IN($user_id)
|
||||
$rowset = OLD_DB()->fetch_rowset('
|
||||
SELECT session_id FROM ' . BB_SESSIONS . " WHERE session_user_id IN($user_id)
|
||||
");
|
||||
|
||||
foreach ($rowset as $row) {
|
||||
|
@ -83,7 +83,7 @@ function db_update_userdata($userdata, $sql_ary, $data_already_escaped = true)
|
|||
}
|
||||
|
||||
$sql_args = OLD_DB()->build_array('UPDATE', $sql_ary, $data_already_escaped);
|
||||
OLD_DB()->query("UPDATE " . BB_USERS . " SET $sql_args WHERE user_id = {$userdata['user_id']}");
|
||||
OLD_DB()->query('UPDATE ' . BB_USERS . " SET $sql_args WHERE user_id = {$userdata['user_id']}");
|
||||
|
||||
if (OLD_DB()->affected_rows()) {
|
||||
cache_rm_userdata($userdata);
|
||||
|
@ -96,7 +96,7 @@ function delete_user_sessions($user_id)
|
|||
cache_rm_user_sessions($user_id);
|
||||
|
||||
$user_id = get_id_csv($user_id);
|
||||
OLD_DB()->query("DELETE FROM " . BB_SESSIONS . " WHERE session_user_id IN($user_id)");
|
||||
OLD_DB()->query('DELETE FROM ' . BB_SESSIONS . " WHERE session_user_id IN($user_id)");
|
||||
}
|
||||
|
||||
// deprecated
|
||||
|
|
|
@ -29,8 +29,8 @@ $show_dl_buttons = ($dl_topic && config('tp.bt_show_dl_list_buttons'));
|
|||
|
||||
// link to clear DL-List
|
||||
$template->assign_vars(array('S_DL_DELETE' => false));
|
||||
if (($is_auth['auth_mod']) && ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL)) {
|
||||
$s_dl_delete = "<br /><a href=\"dl_list.php?mode=dl_delete&" . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">' . trans('messages.DL_LIST_DEL') . '</a>';
|
||||
if ($is_auth['auth_mod'] && ($t_data['topic_dl_type'] == TOPIC_DL_TYPE_DL)) {
|
||||
$s_dl_delete = '<br /><a href="dl_list.php?mode=dl_delete&' . POST_TOPIC_URL . "=$topic_id&sid=" . $userdata['session_id'] . '">' . trans('messages.DL_LIST_DEL') . '</a>';
|
||||
$template->assign_vars(array('S_DL_DELETE' => $s_dl_delete));
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,12 @@ if ($show_dl_list) {
|
|||
}
|
||||
|
||||
if ($count_mode) {
|
||||
$sql = "SELECT dl_status AS user_status, users_count AS username
|
||||
FROM " . BB_BT_DLSTATUS_SNAP . "
|
||||
$sql = 'SELECT dl_status AS user_status, users_count AS username
|
||||
FROM ' . BB_BT_DLSTATUS_SNAP . "
|
||||
WHERE topic_id = $topic_id";
|
||||
} else {
|
||||
$sql = "SELECT d.user_status, d.user_id, DATE_FORMAT(d.last_modified_dlstatus, '%Y-%m-%d') AS last_modified_dlstatus, u.username, u.user_rank
|
||||
FROM " . BB_BT_DLSTATUS . " d, " . BB_USERS . " u
|
||||
FROM " . BB_BT_DLSTATUS . ' d, ' . BB_USERS . " u
|
||||
WHERE d.topic_id = $topic_id
|
||||
AND d.user_id = u.user_id
|
||||
AND d.user_status != " . DL_STATUS_RELEASER . "
|
||||
|
@ -70,7 +70,7 @@ if ($show_dl_list) {
|
|||
$dl_cat[$u['user_status']] = $u['username'];
|
||||
$dl_count[$u['user_status']] = $u['username'];
|
||||
} else {
|
||||
$u_prof_href = ($u['user_id'] == GUEST_UID) ? '#' : "profile.php?mode=viewprofile&u=" . $u['user_id'] . "#torrent";
|
||||
$u_prof_href = ($u['user_id'] == GUEST_UID) ? '#' : 'profile.php?mode=viewprofile&u=' . $u['user_id'] . '#torrent';
|
||||
$dl_cat[$u['user_status']] .= '<nobr><a class="' . $u_link_class . '" href="' . $u_prof_href . '" title="' . $u['last_modified_dlstatus'] . '">' . profile_url(array('username' => $u['username'], 'user_rank' => $u['user_rank'])) . '</a></nobr>, ';
|
||||
$dl_count[$u['user_status']]++;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ if ($show_dl_buttons) {
|
|||
|
||||
$template->assign_vars(array(
|
||||
'DL_HIDDEN_FIELDS' => $dl_hidden_fields,
|
||||
'S_DL_ACTION' => "dl_list.php?" . POST_TOPIC_URL . "=$topic_id",
|
||||
'S_DL_ACTION' => 'dl_list.php?' . POST_TOPIC_URL . "=$topic_id",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue