diff --git a/upgrade/r571-dl_upgrade.php b/upgrade/r571-dl_upgrade.php new file mode 100644 index 000000000..daf4a9999 --- /dev/null +++ b/upgrade/r571-dl_upgrade.php @@ -0,0 +1,57 @@ +session_start(); + +set_die_append_msg(); +if (!IS_SUPER_ADMIN) bb_die($lang['ONLY_FOR_SUPER_ADMIN']); + +$confirm = request_var('confirm', ''); + +if ($confirm) +{ + DB()->query(" + CREATE TEMPORARY TABLE tmp_buf_dlstatus ( + user_id mediumint(9) NOT NULL default '0', + topic_id mediumint(8) unsigned NOT NULL default '0', + user_status tinyint(1) NOT NULL default '0', + PRIMARY KEY (user_id, topic_id) + ) ENGINE = MyISAM + "); + + DB()->query(" + INSERT INTO tmp_buf_dlstatus + (user_id, topic_id, user_status) + SELECT + user_id, topic_id, user_status + FROM bb_bt_dlstatus_new + "); + + DB()->query(" + REPLACE INTO bb_bt_dlstatus_main + (user_id, topic_id, user_status) + SELECT + user_id, topic_id, user_status + FROM tmp_buf_dlstatus + "); + + DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_buf_dlstatus"); + DB()->query("RENAME TABLE bb_bt_dlstatus_main TO bb_bt_dlstatus"); + + DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_mrg"); + DB()->query("DROP TABLE IF EXISTS bb_bt_dlstatus_new"); + + bb_die('

База данных обновлена

'); +} +else +{ + $msg = '
'; + $msg .= '

!!! Перед тем как нажать на кнопку, сделайте бекап базы данных !!!


'; + $msg .= ''; + $msg .= '
'; + + bb_die($msg); +} \ No newline at end of file diff --git a/upload/admin/admin_user_search.php b/upload/admin/admin_user_search.php index e087a2d2b..a2d226b32 100644 --- a/upload/admin/admin_user_search.php +++ b/upload/admin/admin_user_search.php @@ -1232,7 +1232,10 @@ else { $pagination .= ( $pagination == '' ) ? ''.$lang['NEXT'].'' : ' | '.$lang['NEXT'].''; } - + if ($num_pages > 2) + { + $pagination .= '   '; + } $template->assign_vars(array( 'TPL_ADMIN_USER_SEARCH_RESULTS' => true, diff --git a/upload/common.php b/upload/common.php index 8a38ee5e3..846880951 100644 --- a/upload/common.php +++ b/upload/common.php @@ -1995,7 +1995,7 @@ function mkdir_rec ($path, $mode) function verify_id ($id, $length) { - return (preg_match('#^[a-zA-Z0-9]{'. $length .'}$#', $id) && is_string($id)); + return (is_string($id) && preg_match('#^[a-zA-Z0-9]{'. $length .'}$#', $id)); } function clean_filename ($fname) @@ -2004,45 +2004,33 @@ function clean_filename ($fname) return str_replace($s, '_', str_compact($fname)); } -function encode_ip ($dotquad_ip) +function encode_ip ($ip) { - $ip_sep = explode('.', $dotquad_ip); - if (count($ip_sep) == 4) - { - return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]); - } - - $ip_sep = explode(':', preg_replace('/(^:)|(:$)/', '', $dotquad_ip)); - $res = ''; - foreach ($ip_sep as $x) - { - $res .= sprintf('%0'. ($x == '' ? (9 - count($ip_sep)) * 4 : 4) .'s', $x); - } - return $res; + $d = explode('.', $ip); + return sprintf('%02x%02x%02x%02x', $d[0], $d[1], $d[2], $d[3]); } -function decode_ip ($int_ip) +function decode_ip ($ip) { - $int_ip = trim($int_ip); + return long2ip("0x{$ip}"); +} - if (strlen($int_ip) == 32) - { - $int_ip = substr(chunk_split($int_ip, 4, ':'), 0, 39); - $int_ip = ':'. implode(':', array_map("hexhex", explode(':',$int_ip))) .':'; - preg_match_all("/(:0)+/", $int_ip, $zeros); - if (count($zeros[0]) > 0) - { - $match = ''; - foreach($zeros[0] as $zero) - if (strlen($zero) > strlen($match)) - $match = $zero; - $int_ip = preg_replace('/'. $match .'/', ':', $int_ip, 1); - } - return preg_replace('/(^:([^:]))|(([^:]):$)/', '$2$4', $int_ip); - } - if (strlen($int_ip) !== 8) $int_ip = '00000000'; - $hexipbang = explode('.', chunk_split($int_ip, 2, '.')); - return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]); +function ip2int ($ip) +{ + return (float) sprintf('%u', ip2long($ip)); // для совместимости с 32 битными системами +} + +// long2ip( mask_ip_int(ip2int('1.2.3.4'), 24) ) = '1.2.3.255' +function mask_ip_int ($ip, $mask) +{ + $ip_int = is_numeric($ip) ? $ip : ip2int($ip); + $ip_masked = $ip_int | ((1 << (32 - $mask)) - 1); + return (float) sprintf('%u', $ip_masked); +} + +function bb_crc32 ($str) +{ + return (float) sprintf('%u', crc32($str)); } function hexhex ($value) @@ -2174,21 +2162,7 @@ function hide_bb_path ($path) function tr_drop_request ($drop_type) { if (DBG_LOG) dbg_log(' ', "request-dropped-$drop_type"); - dummy_exit(mt_rand(300, 900)); -} - -function get_loadavg () -{ - if (is_callable('sys_getloadavg')) - { - $loadavg = join(' ', sys_getloadavg()); - } - else if (strpos(PHP_OS, 'Linux') !== false) - { - $loadavg = @file_get_contents('/proc/loadavg'); - } - - return !empty($loadavg) ? $loadavg : 0; + dummy_exit(mt_rand(60, 600)); } function sys ($param) @@ -2277,7 +2251,7 @@ else if (defined('IN_TRACKER')) // Exit if tracker is disabled via ON/OFF trigger if (file_exists(BB_DISABLED)) { - dummy_exit(mt_rand(1200, 2400)); # die('d14:failure reason20:temporarily disablede'); + dummy_exit(mt_rand(60, 2400)); # die('d14:failure reason20:temporarily disablede'); } } } \ No newline at end of file diff --git a/upload/config.php b/upload/config.php index e5cadecbb..f5eac042d 100644 --- a/upload/config.php +++ b/upload/config.php @@ -56,7 +56,7 @@ $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'] = '30-01-2014'; -$bb_cfg['tp_release_state'] = 'R573'; +$bb_cfg['tp_release_state'] = 'R574'; // Database $charset = 'utf8'; @@ -475,10 +475,10 @@ $bb_cfg['max_smilies'] = 10; // Максимальное // PM $bb_cfg['privmsg_disable'] = false; // отключить систему личных сообщений на форуме $bb_cfg['max_outgoing_pm_cnt'] = 10; // ограничение на кол. одновременных исходящих лс (для замедления рассылки спама) -$bb_cfg['max_inbox_privmsgs'] = 200; -$bb_cfg['max_savebox_privmsgs'] = 20; -$bb_cfg['max_sentbox_privmsgs'] = 50; -$bb_cfg['pm_days_keep'] = 180; // время хранения ЛС +$bb_cfg['max_inbox_privmsgs'] = 200; // максимальное число сообщений в папке входящие +$bb_cfg['max_savebox_privmsgs'] = 25; // максимальное число сообщений в папке сохраненные +$bb_cfg['max_sentbox_privmsgs'] = 50; // максимальное число сообщений в папке отправленные +$bb_cfg['pm_days_keep'] = 180; // время хранения ЛС // Actions log $bb_cfg['log_days_keep'] = 90; @@ -509,7 +509,6 @@ $bb_cfg['ad_blocks'] = array( ); // Misc -define('LOADAVG', function_exists('get_loadavg') ? get_loadavg() : 0); define('MEM_USAGE', function_exists('memory_get_usage')); $bb_cfg['mem_on_start'] = (MEM_USAGE) ? memory_get_usage() : 0; diff --git a/upload/includes/cron/cron_run.php b/upload/includes/cron/cron_run.php index e1f059deb..116b143f5 100644 --- a/upload/includes/cron/cron_run.php +++ b/upload/includes/cron/cron_run.php @@ -48,7 +48,6 @@ foreach ($cron_jobs as $job) $msg[] = 'start'; $msg[] = date('m-d'); $msg[] = date('H:i:s'); - $msg[] = sprintf('%-4s', round(get_loadavg(), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = $job['cron_title']; $msg = join(LOG_SEPR, $msg); @@ -75,7 +74,6 @@ foreach ($cron_jobs as $job) $msg[] = ' end'; $msg[] = date('m-d'); $msg[] = date('H:i:s'); - $msg[] = sprintf('%-4s', round(get_loadavg(), 1)); $msg[] = sprintf('%05d', getmypid()); $msg[] = round(utime() - $cron_start_time) .'/'. round(utime() - TIMESTART) . ' sec'; $msg = join(LOG_SEPR, $msg); diff --git a/upload/includes/functions.php b/upload/includes/functions.php index a5f8c163c..f0d6f34a4 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -1916,10 +1916,6 @@ function message_die ($msg_code, $msg_text = '', $msg_title = '', $err_line = '' if (!$msg_title) $msg_title = $lang['INFORMATION']; break; - case CRITICAL_MESSAGE: - if (!$msg_title) $msg_title = $lang['CRITICAL_INFORMATION']; - break; - case GENERAL_ERROR: if (!$msg_text) $msg_text = $lang['AN_ERROR_OCCURED']; if (!$msg_title) $msg_title = $lang['GENERAL_ERROR']; diff --git a/upload/includes/functions_post.php b/upload/includes/functions_post.php index d04a39f6e..e6b08ca20 100644 --- a/upload/includes/functions_post.php +++ b/upload/includes/functions_post.php @@ -7,14 +7,14 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); // function prepare_post(&$mode, &$post_data, &$error_msg, &$username, &$subject, &$message, &$poll_title, &$poll_options, &$poll_length) { - global $bb_cfg, $userdata, $lang; + global $bb_cfg, $user, $userdata, $lang; // Check username if (!empty($username)) { $username = clean_username($username); - if (!$userdata['session_logged_in'] || ($userdata['session_logged_in'] && $username != $userdata['username'])) + if (!$userdata['session_logged_in'] || ($userdata['session_logged_in'] && $username != $user->name)) { require(INC_DIR .'functions_validate.php'); @@ -462,7 +462,7 @@ function delete_post($mode, $post_data, &$message, &$meta, $forum_id, $topic_id, // function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topic_id, &$post_id, &$notify_user) { - global $bb_cfg, $lang, $userdata; + global $bb_cfg, $lang, $user, $userdata; if (!$bb_cfg['topic_notify_enabled']) { @@ -565,7 +565,7 @@ function user_notification($mode, &$post_data, &$topic_title, &$forum_id, &$topi $emailer->assign_vars(array( 'TOPIC_TITLE' => $topic_title, 'SITENAME' => $bb_cfg['sitename'], - 'USERNAME' => $userdata['username'], + 'USERNAME' => $user->name, 'EMAIL_SIG' => (!empty($bb_cfg['board_email_sig'])) ? str_replace('
', "\n", "-- \n" . $bb_cfg['board_email_sig']) : '', 'U_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_POST_URL . "=$post_id#$post_id", 'U_STOP_WATCHING_TOPIC' => $server_protocol . $server_name . $server_port . $script_name . '?' . POST_TOPIC_URL . "=$topic_id&unwatch=topic") diff --git a/upload/includes/functions_report.php b/upload/includes/functions_report.php index bad0a6261..1970611cc 100644 --- a/upload/includes/functions_report.php +++ b/upload/includes/functions_report.php @@ -295,7 +295,7 @@ function reports_module_action($reports, $action_name, $action_params = array()) // function report_notify($mode) { - global $userdata, $bb_cfg; + global $user, $userdata, $bb_cfg; $num_args = func_num_args(); $notify_users = $reports = array(); @@ -550,7 +550,7 @@ function report_notify($mode) } $vars = array_merge($vars, array( - 'REPORT_AUTHOR' => $userdata['username'], + 'REPORT_AUTHOR' => $user->name, 'REPORT_TIME' => bb_date($report['report_time']), 'REPORT_REASON' => $report_reason) ); @@ -1067,6 +1067,9 @@ function report_insert($module_id, $report_subject, $report_reason, $report_titl } } + CACHE('bb_cache')->rm('report_count_obtain'); + CACHE('bb_cache')->rm('report_count_obtain_exp'); + return $report_id; } @@ -1152,6 +1155,9 @@ function reports_update_status($report_ids, $report_status, $comment = '', $auth { report_notify('change', $report_status, $report_ids); } + + CACHE('bb_cache')->rm('report_count_obtain'); + CACHE('bb_cache')->rm('report_count_obtain_exp'); } // @@ -1235,6 +1241,9 @@ function reports_delete($report_ids, $auth_check = true, $module_action = true) { reports_module_action($reports, 'delete'); } + + CACHE('bb_cache')->rm('report_count_obtain'); + CACHE('bb_cache')->rm('report_count_obtain_exp'); } // diff --git a/upload/includes/functions_validate.php b/upload/includes/functions_validate.php index 9696cbf73..3f6fa9ecb 100644 --- a/upload/includes/functions_validate.php +++ b/upload/includes/functions_validate.php @@ -5,7 +5,7 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); // !!! $username должен быть предварительно обработан clean_username() !!! function validate_username ($username, $check_ban_and_taken = true) { - global $userdata, $lang; + global $user, $lang; static $name_chars = 'a-z0-9а-яё_@$%^&;(){}\#\-\'.:+ '; @@ -45,7 +45,7 @@ function validate_username ($username, $check_ban_and_taken = true) if ($row = DB()->fetch_row("SELECT username FROM ". BB_USERS ." WHERE username = '$username_sql' LIMIT 1")) { - if ((!IS_GUEST && $row['username'] != $userdata['username']) || IS_GUEST) + if ((!IS_GUEST && $row['username'] != $user->name) || IS_GUEST) { return $lang['USERNAME_TAKEN']; } diff --git a/upload/includes/init_bb.php b/upload/includes/init_bb.php index 1a92c6994..f83e32a3f 100644 --- a/upload/includes/init_bb.php +++ b/upload/includes/init_bb.php @@ -185,7 +185,6 @@ define('SEARCH_TYPE_TRACKER', 1); // Error codes define('GENERAL_MESSAGE', 200); define('GENERAL_ERROR', 202); -define('CRITICAL_MESSAGE', 203); define('CRITICAL_ERROR', 204); define('E_AJAX_GENERAL_ERROR', 1000); @@ -415,12 +414,12 @@ define('PROFILE_URL', 'profile.php?mode=viewprofile&u='); define('BONUS_URL', 'profile.php?mode=bonus'); define('TOPIC_URL', 'viewtopic.php?t='); -define('USER_AGENT', @strtolower($_SERVER['HTTP_USER_AGENT'])); +define('USER_AGENT', strtolower($_SERVER['HTTP_USER_AGENT'])); define('UA_OPERA', strpos(USER_AGENT, 'pera')); define('UA_IE', strpos(USER_AGENT, 'msie')); define('HTML_SELECT_MAX_LENGTH', 60); -define('HTML_WBR_LENGTH', 12); +define('HTML_WBR_LENGTH', 12); define('HTML_CHECKED', ' checked="checked" '); define('HTML_DISABLED', ' disabled="disabled" '); diff --git a/upload/includes/page_header.php b/upload/includes/page_header.php index f0e77922e..c1a62d1c0 100644 --- a/upload/includes/page_header.php +++ b/upload/includes/page_header.php @@ -176,7 +176,7 @@ $template->assign_vars(array( 'USER_RUS' => ($userdata['user_lang'] != 'english') ? true : false, 'INCLUDE_BBCODE_JS' => !empty($page_cfg['include_bbcode_js']), - 'USER_OPTIONS_JS' => ($logged_in) ? bb_json_encode($user->opt_js) : '{}', + 'USER_OPTIONS_JS' => (IS_GUEST) ? '{}' : bb_json_encode($user->opt_js), 'USE_TABLESORTER' => !empty($page_cfg['use_tablesorter']), diff --git a/upload/includes/sessions.php b/upload/includes/sessions.php index 39e552935..cbb0dd070 100644 --- a/upload/includes/sessions.php +++ b/upload/includes/sessions.php @@ -33,6 +33,16 @@ class user_common 'h_tsp' => 0, // show released title {...} ); + /** + * Defaults options for guests + */ + var $opt_js_guest = array( + 'h_av' => 1, + 'h_rnk_i' => 1, + 'h_smile' => 1, + 'h_sig' => 1, + ); + /** * Sessiondata */ @@ -556,6 +566,22 @@ class user_common return $autologin_id; } + /** + * Set shortcuts + */ + function set_shortcuts () + { + $this->id =& $this->data['user_id']; + $this->active =& $this->data['user_active']; + $this->name =& $this->data['username']; + $this->lastvisit =& $this->data['user_lastvisit']; + $this->regdate =& $this->data['user_regdate']; + $this->level =& $this->data['user_level']; + $this->opt =& $this->data['user_opt']; + + $this->ip = CLIENT_IP; + } + /** * Initialise user settings */ @@ -642,7 +668,11 @@ class user_common */ function load_opt_js () { - if (!IS_GUEST && !empty($_COOKIE['opt_js'])) + if (IS_GUEST) + { + $this->opt_js = array_merge($this->opt_js, $this->opt_js_guest); + } + else if (!empty($_COOKIE['opt_js'])) { $opt_js = bb_json_decode($_COOKIE['opt_js']); @@ -653,15 +683,6 @@ class user_common } } - /** - * Set shortcuts - */ - function set_shortcuts () - { - $this->id =& $this->data['user_id']; - $this->opt =& $this->data['user_opt']; - } - /** * Get not auth forums */ diff --git a/upload/language/lang_english/lang_main.php b/upload/language/lang_english/lang_main.php index 30e0e30f5..c06d95c59 100644 --- a/upload/language/lang_english/lang_main.php +++ b/upload/language/lang_english/lang_main.php @@ -59,8 +59,8 @@ $lang['DISABLED'] = 'Disabled'; $lang['ERROR'] = 'Error'; $lang['SELECT_ACTION'] = 'Select action'; -$lang['NEXT'] = 'Next'; -$lang['PREVIOUS'] = 'Previous'; +$lang['NEXT_PAGE'] = 'Next'; +$lang['PREVIOUS_PAGE'] = 'Previous'; $lang['GOTO_PAGE'] = 'Goto page'; $lang['GOTO_SHORT'] = 'Page'; $lang['JOINED'] = 'Joined'; diff --git a/upload/stats/tracker.php b/upload/stats/tracker.php index 5798b3d17..56014a7fa 100644 --- a/upload/stats/tracker.php +++ b/upload/stats/tracker.php @@ -73,8 +73,6 @@ foreach ($rowset as $cnt => $row) $peers_in_last_sec[] = sprintf('%3s', $row['peers']) . (($cnt && !(++$cnt%15)) ? " \n" : ''); } - - function commify_callback ($matches) { return commify($matches[0]); @@ -85,7 +83,6 @@ function commify_ob ($contents) } ob_start('commify_ob'); - echo ''; echo '


@@ -125,9 +122,14 @@ echo ''; echo '
';
 
-if ($loadavg = get_loadavg())
+if ($l = sys('la'))
 {
-	echo "\n\nloadavg: $loadavg\n\n";
+	$l = explode(' ', $l);
+	for ($i=0; $i < 3; $i++)
+	{
+		$l[$i] = round($l[$i], 1);
+	}
+	echo "\n\nloadavg: $l[0] $l[1] $l[2]\n\n";
 }
 
 echo 'gen time: '. sprintf('%.3f', (array_sum(explode(' ', microtime())) - TIMESTART)) ." sec\n";