mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-20 21:33:54 -07:00
r537
Отказ от ограничений доступа к форуму по "загрузке сервера", из-за некорректной отработки данных ограничений с кроном, из-за некорректной работы данных ограничений на слабых серверах и в целом из-за достаточно большого числа багов с этим связанным. Окончательный отказ от PHP 5.2 (теоретическая невозможность установки форумных cookies, приводящая к неработоспособности форума). Подготовка к введению уровня пользователя "правообладатель" из-за законодательных изменений в РФ. Для обновления таблиц выполнить команду (не забывая про бекап): ALTER TABLE bb_users DROP ignore_srv_load git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@537 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
parent
0eee5c1a25
commit
a763f0339a
15 changed files with 19 additions and 238 deletions
|
@ -1455,7 +1455,6 @@ CREATE TABLE IF NOT EXISTS `bb_users` (
|
|||
`user_interests` varchar(255) NOT NULL DEFAULT '',
|
||||
`user_actkey` varchar(32) NOT NULL DEFAULT '',
|
||||
`user_newpasswd` varchar(32) NOT NULL DEFAULT '',
|
||||
`ignore_srv_load` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`autologin_id` varchar(12) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
|
||||
`user_newest_pm_id` mediumint(8) NOT NULL DEFAULT '0',
|
||||
`user_points` float(16,2) NOT NULL DEFAULT '0.00',
|
||||
|
|
|
@ -127,11 +127,6 @@ switch ($field)
|
|||
$this->response['new_value'] = bb_date($value);
|
||||
break;
|
||||
|
||||
case 'ignore_srv_load':
|
||||
$value = ($this->request['value']) ? 0 : 1;
|
||||
$this->response['new_value'] = ($profiledata['user_level'] != USER || $value) ? $lang['NO'] : $lang['YES'];
|
||||
break;
|
||||
|
||||
case 'u_up_total':
|
||||
case 'u_down_total':
|
||||
case 'u_up_release':
|
||||
|
|
|
@ -2265,24 +2265,5 @@ else if (defined('IN_TRACKER'))
|
|||
{
|
||||
dummy_exit(mt_rand(1200, 2400)); # die('d14:failure reason20:temporarily disablede');
|
||||
}
|
||||
|
||||
// Limit server load
|
||||
if ($bb_cfg['max_srv_load'] || $bb_cfg['tr_working_second'])
|
||||
{
|
||||
if ((!empty($_GET['uploaded']) || !empty($_GET['downloaded'])) && (!isset($_GET['event']) || $_GET['event'] === 'started'))
|
||||
{
|
||||
if ($bb_cfg['tr_working_second'] && (TIMENOW % $bb_cfg['tr_working_second']))
|
||||
{
|
||||
tr_drop_request('wrk_sec');
|
||||
}
|
||||
else if ($bb_cfg['max_srv_load'] && LOADAVG)
|
||||
{
|
||||
if (LOADAVG > $bb_cfg['max_srv_load'])
|
||||
{
|
||||
tr_drop_request('load');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
* Templates
|
||||
* Cookie
|
||||
* Server
|
||||
- Server load
|
||||
- Backup
|
||||
- GZip
|
||||
* Sessions
|
||||
|
@ -56,8 +55,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do
|
|||
|
||||
// Increase number of revision after update
|
||||
$bb_cfg['tp_version'] = '2.5 (unstable)';
|
||||
$bb_cfg['tp_release_date'] = '03-08-2013';
|
||||
$bb_cfg['tp_release_state'] = 'R536';
|
||||
$bb_cfg['tp_release_date'] = '06-08-2013';
|
||||
$bb_cfg['tp_release_state'] = 'R537';
|
||||
|
||||
// Database
|
||||
$charset = 'utf8';
|
||||
|
@ -109,17 +108,12 @@ $bb_cfg['server_name'] = $domain_name; // The domain name from whic
|
|||
$bb_cfg['server_port'] = (!empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : 80; // The port your server is running on
|
||||
$bb_cfg['script_path'] = '/'; // The path where FORUM is located relative to the domain name
|
||||
|
||||
// Server load
|
||||
$bb_cfg['max_srv_load'] = 0; // 0 - disable
|
||||
$bb_cfg['tr_working_second'] = 0; // 0 - disable
|
||||
|
||||
// Increase number after changing js or css
|
||||
$bb_cfg['js_ver'] = 1;
|
||||
$bb_cfg['css_ver'] = 1;
|
||||
|
||||
// Information messages
|
||||
$bb_cfg['board_disabled_msg'] = 'форум временно отключен'; // 'forums temporarily disabled'; // show this msg if board has been disabled via ON/OFF trigger
|
||||
$bb_cfg['srv_overloaded_msg'] = "Извините, в данный момент сервер перегружен\nПопробуйте повторить запрос через несколько минут";
|
||||
|
||||
// Backup
|
||||
$bb_cfg['db_backup_shell_cmd'] = ''; // '/path/to/db_backup.sh 2>&1'
|
||||
|
@ -301,7 +295,6 @@ $bb_cfg['user_session_duration'] = 1800; // sec
|
|||
$bb_cfg['admin_session_duration'] = 6*3600; // sec
|
||||
$bb_cfg['user_session_gc_ttl'] = 1800; // number of seconds that a staled session entry may remain in sessions table
|
||||
$bb_cfg['session_cache_gc_ttl'] = 1200; // sec
|
||||
$bb_cfg['max_reg_users_online'] = 0; // 0 - unlimited
|
||||
$bb_cfg['max_last_visit_days'] = 14; // days
|
||||
$bb_cfg['last_visit_update_intrv'] = 3600; // sec
|
||||
|
||||
|
|
|
@ -16,4 +16,3 @@ $next = @$_GET['next'] ? $_GET['next'] : 15;
|
|||
|
||||
require('./dbg_header.php');
|
||||
echo showSource($file, $line, $prev, $next);
|
||||
|
||||
|
|
|
@ -59,4 +59,3 @@ foreach ($del_ids as $del_id)
|
|||
}
|
||||
DB('cap')->query("DELETE FROM ". BB_CAPTCHA ." WHERE cap_id = $del_id LIMIT 1");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
##### LOG #####
|
||||
# bb_log(' ', 'hits/'. date('m-d') .'/'. date('H-') .'bb');
|
||||
### LOG END ###
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
if (!defined('BB_SCRIPT')) define('BB_SCRIPT', 'undefined');
|
||||
|
||||
// Exit if board is disabled via ON/OFF trigger
|
||||
|
@ -101,18 +96,12 @@ if (!defined('IN_AJAX'))
|
|||
if (DEBUG === true)
|
||||
{
|
||||
require(DEV_DIR .'init_debug.php');
|
||||
# if ($a);
|
||||
# trigger_error("error handler test", E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Config options
|
||||
define('TPL_LIMIT_LOAD_EXIT', TEMPLATES_DIR .'limit_load_exit.php');
|
||||
|
||||
// Cookie params
|
||||
$c = $bb_cfg['cookie_prefix'];
|
||||
define('COOKIE_DATA', $c .'data');
|
||||
define('COOKIE_FORUM', $c .'f');
|
||||
define('COOKIE_LOAD', $c .'isl');
|
||||
define('COOKIE_MARK', $c .'mark_read');
|
||||
define('COOKIE_TOPIC', $c .'t');
|
||||
unset($c);
|
||||
|
@ -126,19 +115,7 @@ define('COOKIE_MAX_TRACKS', 90);
|
|||
function bb_setcookie ($name, $val, $lifetime = COOKIE_PERSIST, $httponly = false)
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
$domain = $bb_cfg['cookie_domain'];
|
||||
|
||||
if (PHP_VERSION < 5.2)
|
||||
{
|
||||
// HttpOnly hack by Matt Mecham [http://blog.mattmecham.com/archives/2006/09/http_only_cookies_without_php.html]
|
||||
$domain .= ($httponly) ? '; HttpOnly' : '';
|
||||
return setcookie($name, $val, $lifetime, $bb_cfg['cookie_path'], $domain, $bb_cfg['cookie_secure']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return setcookie($name, $val, $lifetime, $bb_cfg['cookie_path'], $domain, $bb_cfg['cookie_secure'], $httponly);
|
||||
}
|
||||
return setcookie($name, $val, $lifetime, $bb_cfg['cookie_path'], $bb_cfg['cookie_domain'], $bb_cfg['cookie_secure'], $httponly);
|
||||
}
|
||||
|
||||
// Debug options
|
||||
|
@ -150,11 +127,12 @@ if (DBG_USER)
|
|||
|
||||
define('DELETED', -1);
|
||||
|
||||
// User Levels <- Do not change the values of USER or ADMIN
|
||||
// User Levels
|
||||
define('USER', 0);
|
||||
define('ADMIN', 1);
|
||||
define('MOD', 2);
|
||||
define('GROUP_MEMBER', 20);
|
||||
define('CP_HOLDER', 25);
|
||||
|
||||
$excluded_users = array(
|
||||
ANONYMOUS,
|
||||
|
@ -463,23 +441,10 @@ if (!empty($banned_user_agents))
|
|||
{
|
||||
if (strstr(USER_AGENT, $agent))
|
||||
{
|
||||
/*##### LOG #####
|
||||
$file = 'ban/user_agents_'. date('m-d');
|
||||
$str = array();
|
||||
$str[] = date('H:i:s');
|
||||
$str[] = @$_SERVER['HTTP_USER_AGENT'];
|
||||
$str[] = @$_SERVER['REMOTE_ADDR'];
|
||||
$str[] = @$_SERVER['REQUEST_URI'];
|
||||
$str[] = @$_SERVER['HTTP_REFERER'];
|
||||
bb_log($str, $file);
|
||||
### LOG END ###*/
|
||||
|
||||
$filename = 'Skachivajte fajly brauzerom (скачивайте файлы браузером)';
|
||||
$output = '@';
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
header('Content-Disposition: attachment; filename="'. $filename .'"');
|
||||
|
||||
die($output);
|
||||
}
|
||||
}
|
||||
|
@ -504,18 +469,6 @@ function bb_exit ($output = '')
|
|||
exit;
|
||||
}
|
||||
|
||||
// Exit if server overloaded
|
||||
if (!(defined('IN_PROFILE') || defined('IN_LOGIN') || defined('IN_ADMIN') || defined('IN_AJAX') || defined('IN_SERVICE')) && BB_ROOT == './')
|
||||
{
|
||||
if ($bb_cfg['max_srv_load'] && empty($_POST['message']) && !empty($_COOKIE[COOKIE_LOAD]) && LOADAVG)
|
||||
{
|
||||
if (LOADAVG > $bb_cfg['max_srv_load'] && (TIMENOW - $_COOKIE[COOKIE_LOAD]) > $bb_cfg['user_session_duration'])
|
||||
{
|
||||
require(TPL_LIMIT_LOAD_EXIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function prn_r ($var, $title = '', $print = true)
|
||||
{
|
||||
$r = '<pre>'. (($title) ? "<b>$title</b>\n\n" : '') . htmlspecialchars(print_r($var, true)) .'</pre>';
|
||||
|
|
|
@ -28,7 +28,6 @@ $online = $online_short = array('userlist' => '');
|
|||
$sql = "
|
||||
SELECT
|
||||
u.username, u.user_id, u.user_opt, u.user_rank, u.user_level,
|
||||
u.ignore_srv_load,
|
||||
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
|
||||
WHERE s.session_time > $time_online
|
||||
|
|
|
@ -58,9 +58,8 @@ if ($show_dbg_info)
|
|||
for ($i=0; $i < 3; $i++)
|
||||
{
|
||||
$l[$i] = round($l[$i], 1);
|
||||
$l[$i] = (IS_ADMIN && $bb_cfg['max_srv_load'] && $l[$i] > ($bb_cfg['max_srv_load'] + 4)) ? "<span style='color: red'><b>$l[$i]</b></span>" : $l[$i];
|
||||
}
|
||||
$stat .= " | <span title='". $lang['LIMIT'] ." {$bb_cfg['max_srv_load']}'>". $lang['LIMIT'] ." $l[0] $l[1] $l[2]</span>";
|
||||
$stat .= " | ". $lang['LIMIT'] ." $l[0] $l[1] $l[2]";
|
||||
}
|
||||
|
||||
$stat .= ' ]';
|
||||
|
|
|
@ -235,11 +235,6 @@ class user_common
|
|||
$user_id = (int) $this->data['user_id'];
|
||||
$mod_admin_session = ($this->data['user_level'] == ADMIN || $this->data['user_level'] == MOD);
|
||||
|
||||
if (($bb_cfg['max_srv_load'] || $bb_cfg['max_reg_users_online']) && $login && $is_user && !$this->data['ignore_srv_load'])
|
||||
{
|
||||
$this->limit_srv_load();
|
||||
}
|
||||
|
||||
// Initial ban check against user_id or IP address
|
||||
if ($is_user)
|
||||
{
|
||||
|
@ -486,7 +481,6 @@ class user_common
|
|||
{
|
||||
$delete_cookies = array(
|
||||
COOKIE_DATA,
|
||||
COOKIE_LOAD,
|
||||
COOKIE_DBG,
|
||||
'torhelp',
|
||||
'explain',
|
||||
|
@ -511,16 +505,6 @@ class user_common
|
|||
{
|
||||
bb_setcookie(COOKIE_DATA, $c_sdata_curr, COOKIE_PERSIST, true);
|
||||
}
|
||||
if ($bb_cfg['max_srv_load'])
|
||||
{
|
||||
$c_isl_resv = isset($_COOKIE[COOKIE_LOAD]) ? intval($_COOKIE[COOKIE_LOAD]) : null;
|
||||
$c_isl_curr = ($this->data['user_level'] == USER && !$this->data['ignore_srv_load']) ? TIMENOW : 0;
|
||||
|
||||
if ($c_isl_curr !== $c_isl_resv)
|
||||
{
|
||||
bb_setcookie(COOKIE_LOAD, $c_isl_curr);
|
||||
}
|
||||
}
|
||||
if (isset($bb_cfg['dbg_users'][$this->data['user_id']]) && !isset($_COOKIE[COOKIE_DBG]))
|
||||
{
|
||||
bb_setcookie(COOKIE_DBG, 1, COOKIE_SESSION);
|
||||
|
@ -572,36 +556,6 @@ class user_common
|
|||
return $autologin_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit server load
|
||||
*/
|
||||
function limit_srv_load ()
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
if (!empty($_POST['message'])) return;
|
||||
|
||||
$srv_overloaded = false;
|
||||
|
||||
if (LOADAVG)
|
||||
{
|
||||
$srv_overloaded = (LOADAVG > $bb_cfg['max_srv_load']);
|
||||
}
|
||||
if (!$srv_overloaded && $bb_cfg['max_reg_users_online'])
|
||||
{
|
||||
$sql = "SELECT COUNT(DISTINCT session_user_id) AS users_count FROM ". BB_SESSIONS ." WHERE session_time > ". (TIMENOW - 300);
|
||||
|
||||
if ($row = DB()->fetch_row($sql))
|
||||
{
|
||||
$srv_overloaded = ($row['users_count'] > $bb_cfg['max_reg_users_online']);
|
||||
}
|
||||
}
|
||||
if ($srv_overloaded)
|
||||
{
|
||||
require(TPL_LIMIT_LOAD_EXIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise user settings
|
||||
*/
|
||||
|
|
|
@ -214,12 +214,6 @@ else
|
|||
));
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'SHOW_ACCESS_PRIVILEGE' => IS_ADMIN,
|
||||
'IGNORE_SRV_LOAD' => ($profiledata['user_level'] != USER || $profiledata['ignore_srv_load']) ? $lang['NO'] : $lang['YES'],
|
||||
'IGNORE_SRV_LOAD_EDIT' => ($profiledata['user_level'] == USER),
|
||||
));
|
||||
|
||||
if (IS_ADMIN)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
|
|
|
@ -1396,8 +1396,6 @@ $lang['ONLY_FOR_MOD'] = 'This option only for moderators';
|
|||
$lang['ONLY_FOR_ADMIN'] = 'This option only for admins';
|
||||
$lang['ONLY_FOR_SUPER_ADMIN'] = 'This option only for super admins';
|
||||
|
||||
$lang['ACCESS'] = 'Access';
|
||||
$lang['ACCESS_SRV_LOAD'] = 'Depend on server load';
|
||||
$lang['LOGS'] = 'Topic history';
|
||||
$lang['FORUM_LOGS'] = 'History Forum';
|
||||
$lang['AUTOCLEAN'] = 'Autoclean:';
|
||||
|
|
|
@ -1398,8 +1398,6 @@ $lang['ONLY_FOR_MOD'] = 'Эта опция доступна только мод
|
|||
$lang['ONLY_FOR_ADMIN'] = 'Эта опция доступна только администраторам';
|
||||
$lang['ONLY_FOR_SUPER_ADMIN'] = 'Эта опция доступна только суперадминистраторам';
|
||||
|
||||
$lang['ACCESS'] = 'Доступ';
|
||||
$lang['ACCESS_SRV_LOAD'] = 'Зависит от загрузки сервера';
|
||||
$lang['LOGS'] = 'История темы';
|
||||
$lang['FORUM_LOGS'] = 'История форума';
|
||||
$lang['AUTOCLEAN'] = 'Автоочистка:';
|
||||
|
|
|
@ -82,10 +82,6 @@ $(document).ready(function(){
|
|||
<var class="ajax-params">{action: "edit_user_profile", id: "user_skype"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_gender", editableType: "yesno-gender"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "user_birthday"}</var>
|
||||
|
||||
<!-- IF IGNORE_SRV_LOAD_EDIT -->
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "ignore_srv_load", editableType: "yesno-radio"}</var>
|
||||
<!-- ENDIF -->
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "u_up_total"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "u_down_total"}</var>
|
||||
<var class="ajax-params">{action: "edit_user_profile", id: "u_up_release"}</var>
|
||||
|
@ -409,12 +405,6 @@ ajax.callback.view_profile = function(data) {
|
|||
<td><b>{AGE}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF SHOW_ACCESS_PRIVILEGE -->
|
||||
<tr>
|
||||
<th>{L_ACCESS}:</th>
|
||||
<td id="ignore_srv_load">{L_ACCESS_SRV_LOAD}: <b class="editable">{IGNORE_SRV_LOAD}</b></td>
|
||||
</tr>
|
||||
<!-- ENDIF -->
|
||||
<!-- IF SHOW_DRAFT -->
|
||||
<tr>
|
||||
<th>{L_DRAFTS}:</th>
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_FORUM')) die(basename(__FILE__));
|
||||
|
||||
global $DBS;
|
||||
|
||||
if (!empty($DBS))
|
||||
{
|
||||
DB()->close();
|
||||
}
|
||||
send_no_cache_headers();
|
||||
|
||||
$redirect_url = !empty($_POST['redirect']) ? $_POST['redirect'] : $_SERVER['REQUEST_URI'];
|
||||
|
||||
|
||||
// LOG
|
||||
global $userdata;
|
||||
|
||||
if ($userdata['username'])
|
||||
{
|
||||
$name = html_entity_decode($userdata['username']);
|
||||
}
|
||||
else if (!empty($_POST['login_username']))
|
||||
{
|
||||
$name = $_POST['login_username'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = '';
|
||||
}
|
||||
|
||||
$file = 'load/load-'. date('m-d');
|
||||
$str = array();
|
||||
$str[] = date('H:i:s');
|
||||
$str[] = sprintf('%-5s', floatval(LOADAVG));
|
||||
$str[] = sprintf('%-15s', $_SERVER['REMOTE_ADDR']);
|
||||
$str[] = sprintf('%-20s', $name);
|
||||
$str[] = $redirect_url;
|
||||
$str = join(LOG_SEPR, $str) . LOG_LF;
|
||||
bb_log($str, $file);
|
||||
|
||||
|
||||
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<title><?php echo $bb_cfg['sitename']?></title>
|
||||
<style type="text/css">
|
||||
body { min-width: 760px; color: #000000; background: #E3E3E3; font: 16px Verdana; }
|
||||
.msg { margin: 20%; text-align: center; background: #EFEFEF; border: 1px solid #B7C0C5; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form action="login.php" method="post">
|
||||
<input type="hidden" name="redirect" value="<?php echo $redirect_url ?>" />
|
||||
|
||||
<div class="msg">
|
||||
<p style="margin: 1em 0;">Извините, в данный момент сервер перегружен.</p>
|
||||
<p style="margin: 1em 0;">Попробуйте зайти через несколько минут.</p>
|
||||
<p style="margin: 1.5em 0;"><input type="submit" name="enter" value="Вход" /></p>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<?php exit; ?>
|
Loading…
Add table
Add a link
Reference in a new issue