mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
commit
5f5cefa85a
13 changed files with 65 additions and 55 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
### TorrentPier ###
|
||||
.vagrant
|
||||
.idea
|
||||
bower_components
|
||||
composer.phar
|
||||
|
|
|
@ -56,7 +56,7 @@ $default_forum_auth = [
|
|||
'auth_download' => AUTH_REG,
|
||||
];
|
||||
|
||||
$mode = ($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
|
||||
$mode = isset($_REQUEST['mode']) ? (string)$_REQUEST['mode'] : '';
|
||||
|
||||
$cat_forums = get_cat_forums();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ define('TEMPLATES_DIR', BB_PATH . '/styles/templates/');
|
|||
define('ADMIN_TPL_DIR', TEMPLATES_DIR . '/admin/');
|
||||
|
||||
// Debug
|
||||
define('DBG_LOG', false); // enable forum debug (off on production)
|
||||
define('DBG_LOG', true); // enable forum debug (off on production)
|
||||
define('DBG_TRACKER', false); // enable tracker debug (off on production)
|
||||
define('COOKIE_DBG', 'bb_dbg'); // debug cookie name
|
||||
define('SQL_DEBUG', true); // enable forum sql & cache debug
|
||||
|
@ -72,9 +72,9 @@ define('LOG_LF', "\n");
|
|||
define('LOG_MAX_SIZE', 1048576); // bytes
|
||||
|
||||
// Error reporting
|
||||
ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
//ini_set('error_reporting', E_ALL);
|
||||
//ini_set('display_errors', 0);
|
||||
//ini_set('log_errors', 1);
|
||||
ini_set('error_log', LOG_DIR . 'php_err.log');
|
||||
|
||||
// Triggers
|
||||
|
|
|
@ -500,7 +500,7 @@ class bbcode
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function bbcode()
|
||||
public function __construct()
|
||||
{
|
||||
$this->tpl = get_bbcode_tpl();
|
||||
|
||||
|
@ -900,7 +900,7 @@ class words_rate
|
|||
public $words_del_exp = '';
|
||||
public $words_cnt_exp = '#[a-zA-Zа-яА-ЯёЁ]{4,}#';
|
||||
|
||||
public function words_rate()
|
||||
public function __construct()
|
||||
{
|
||||
// слова начинающиеся на..
|
||||
$del_list = file_get_contents(BB_ROOT . '/library/words_rate_del_list.txt');
|
||||
|
|
|
@ -65,7 +65,7 @@ class sql_db
|
|||
* @param $cfg_values
|
||||
* @return sql_db
|
||||
*/
|
||||
public function sql_db($cfg_values)
|
||||
public function __construct($cfg_values)
|
||||
{
|
||||
global $DBS;
|
||||
|
||||
|
@ -94,7 +94,7 @@ class sql_db
|
|||
$this->selected_db = $this->select_db();
|
||||
|
||||
// Set charset
|
||||
if ($this->cfg['charset'] && !mysql_set_charset($this->cfg['charset'], $this->link)) {
|
||||
if ($this->cfg['charset'] && !mysqli_set_charset($this->link, $this->cfg['charset'])) {
|
||||
if (!$this->sql_query("SET NAMES {$this->cfg['charset']}")) {
|
||||
die("Could not set charset {$this->cfg['charset']}");
|
||||
}
|
||||
|
@ -113,10 +113,7 @@ class sql_db
|
|||
{
|
||||
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: {$this->cfg['dbhost']}" : 'connect';
|
||||
$this->debug('start');
|
||||
|
||||
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
|
||||
|
||||
if (!$link = $connect_type($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd'])) {
|
||||
if (!$link = mysqli_connect($this->cfg['dbhost'], $this->cfg['dbuser'], $this->cfg['dbpasswd'], $this->cfg['dbname'])) {
|
||||
$server = (DBG_USER) ? $this->cfg['dbhost'] : '';
|
||||
header("HTTP/1.0 503 Service Unavailable");
|
||||
bb_log(' ', "db_err/connect_failed_{$this->cfg['dbhost']}");
|
||||
|
@ -139,10 +136,10 @@ class sql_db
|
|||
$this->cur_query = ($this->dbg_enabled) ? "select db: {$this->cfg['dbname']}" : 'select db';
|
||||
$this->debug('start');
|
||||
|
||||
if (!mysql_select_db($this->cfg['dbname'], $this->link)) {
|
||||
$database = (DBG_USER) ? $this->cfg['dbhost'] : '';
|
||||
die("Could not select database $database");
|
||||
}
|
||||
// if (!mysqli_select_db($this->link, $this->cfg['dbname'])) {
|
||||
// $database = (DBG_USER) ? $this->cfg['dbhost'] : '';
|
||||
// die("Could not select database $database");
|
||||
// }
|
||||
|
||||
$this->debug('stop');
|
||||
$this->cur_query = null;
|
||||
|
@ -157,7 +154,7 @@ class sql_db
|
|||
*/
|
||||
public function sql_query($query)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
if ($this->link) {
|
||||
$this->init();
|
||||
}
|
||||
if (is_array($query)) {
|
||||
|
@ -169,7 +166,7 @@ class sql_db
|
|||
$this->cur_query = $query;
|
||||
$this->debug('start');
|
||||
|
||||
if (!$this->result = mysql_query($query, $this->link)) {
|
||||
if (!$this->result = mysqli_query($this->link, $query)) {
|
||||
$this->log_error();
|
||||
}
|
||||
|
||||
|
@ -208,7 +205,7 @@ class sql_db
|
|||
$num_rows = false;
|
||||
|
||||
if ($result or $result = $this->result) {
|
||||
$num_rows = is_resource($result) ? mysql_num_rows($result) : false;
|
||||
$num_rows = $result instanceof mysqli_result ? mysqli_num_rows($result) : false;
|
||||
}
|
||||
|
||||
return $num_rows;
|
||||
|
@ -219,7 +216,7 @@ class sql_db
|
|||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return is_resource($this->link) ? mysql_affected_rows($this->link) : -1;
|
||||
return $this->link ? mysqli_affected_rows($this->link) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,7 +233,7 @@ class sql_db
|
|||
}
|
||||
if ($query_id) {
|
||||
if ($rownum > -1) {
|
||||
$result = mysql_result($query_id, $rownum, $field);
|
||||
$result = mysqli_result($query_id, $rownum, $field);
|
||||
} else {
|
||||
if (empty($this->row[$query_id]) && empty($this->rowset[$query_id])) {
|
||||
if ($this->sql_fetchrow()) {
|
||||
|
@ -264,7 +261,7 @@ class sql_db
|
|||
*/
|
||||
public function sql_fetchrow($result, $field_name = '')
|
||||
{
|
||||
$row = mysql_fetch_assoc($result);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($field_name) {
|
||||
return isset($row[$field_name]) ? $row[$field_name] : false;
|
||||
|
@ -308,7 +305,7 @@ class sql_db
|
|||
{
|
||||
$rowset = array();
|
||||
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$rowset[] = ($field_name) ? $row[$field_name] : $row;
|
||||
}
|
||||
|
||||
|
@ -350,7 +347,7 @@ class sql_db
|
|||
*/
|
||||
public function sql_nextid()
|
||||
{
|
||||
return mysql_insert_id($this->link);
|
||||
return mysqli_insert_id($this->link);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,7 +357,7 @@ class sql_db
|
|||
public function sql_freeresult($result = false)
|
||||
{
|
||||
if ($result or $result = $this->result) {
|
||||
$return_value = is_resource($result) ? mysql_free_result($result) : false;
|
||||
$return_value = is_resource($result) ? mysqli_free_result($result) : false;
|
||||
}
|
||||
|
||||
$this->result = null;
|
||||
|
@ -405,11 +402,11 @@ class sql_db
|
|||
*/
|
||||
public function escape_string($str)
|
||||
{
|
||||
if (!is_resource($this->link)) {
|
||||
if (!$this->link) {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
return mysql_real_escape_string($str, $this->link);
|
||||
return mysqli_real_escape_string($this->link, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -542,8 +539,8 @@ class sql_db
|
|||
*/
|
||||
public function sql_error()
|
||||
{
|
||||
if (is_resource($this->link)) {
|
||||
return array('code' => mysql_errno($this->link), 'message' => mysql_error($this->link));
|
||||
if ($this->link) {
|
||||
return array('code' => mysqli_errno($this->link), 'message' => mysqli_error($this->link));
|
||||
} else {
|
||||
return array('code' => '', 'message' => 'not connected');
|
||||
}
|
||||
|
@ -554,7 +551,7 @@ class sql_db
|
|||
*/
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->link)) {
|
||||
if ($this->link) {
|
||||
$this->unlock();
|
||||
|
||||
if (!empty($this->locks)) {
|
||||
|
@ -565,7 +562,7 @@ class sql_db
|
|||
|
||||
$this->exec_shutdown_queries();
|
||||
|
||||
mysql_close($this->link);
|
||||
mysqli_close($this->link);
|
||||
}
|
||||
|
||||
$this->link = $this->selected_db = null;
|
||||
|
@ -710,7 +707,7 @@ class sql_db
|
|||
$info[] = "$num rows";
|
||||
}
|
||||
|
||||
if (is_resource($this->link) and $ext = mysql_info($this->link)) {
|
||||
if ($this->link and $ext = mysqli_info($this->link)) {
|
||||
$info[] = "$ext";
|
||||
} elseif (!$num && ($aff = $this->affected_rows($this->result) and $aff != -1)) {
|
||||
$info[] = "$aff rows";
|
||||
|
@ -724,7 +721,7 @@ class sql_db
|
|||
*/
|
||||
public function server_version()
|
||||
{
|
||||
preg_match('#^(\d+\.\d+\.\d+).*#', mysql_get_server_info(), $m);
|
||||
preg_match('#^(\d+\.\d+\.\d+).*#', mysqli_get_server_info(), $m);
|
||||
return $m[1];
|
||||
}
|
||||
|
||||
|
@ -953,8 +950,8 @@ class sql_db
|
|||
if (preg_match('#^SELECT#', $query)) {
|
||||
$html_table = false;
|
||||
|
||||
if ($result = mysql_query("EXPLAIN $query", $this->link)) {
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
if ($result = mysqli_query($this->link, "EXPLAIN $query")) {
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$html_table = $this->explain('add_explain_row', $html_table, $row);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -551,7 +551,7 @@ class Date_Delta
|
|||
/**
|
||||
* Date_Delta constructor.
|
||||
*/
|
||||
public function Date_Delta()
|
||||
public function __construct()
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ $online = $online_short = array('userlist' => '');
|
|||
$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
|
||||
s.session_logged_in, s.session_ip, MAX(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
|
||||
AND u.user_id = s.session_user_id
|
||||
GROUP BY s.session_user_id
|
||||
GROUP BY s.session_user_id, s.session_logged_in, s.session_ip
|
||||
ORDER BY u.username
|
||||
";
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class user_common
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function user_common()
|
||||
public function __construct()
|
||||
{
|
||||
$this->get_sessiondata();
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class template
|
|||
* @param string $root
|
||||
* @return template
|
||||
*/
|
||||
public function Template($root = '.')
|
||||
public function __construct($root = '.')
|
||||
{
|
||||
global $lang;
|
||||
|
||||
|
@ -953,8 +953,8 @@ class template
|
|||
break;
|
||||
|
||||
case 'is':
|
||||
$is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
|
||||
$is_arg = join(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
|
||||
$is_arg_start = ($tokens[$i - 1] === ')') ? array_pop($is_arg_stack) : $i - 1;
|
||||
$is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
|
||||
|
||||
$new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ class template
|
|||
$expr_end = 0;
|
||||
$negate_expr = false;
|
||||
|
||||
if (($first_token = array_shift($tokens)) == 'not') {
|
||||
if (($first_token = array_shift($tokens)) === 'not') {
|
||||
$negate_expr = true;
|
||||
$expr_type = array_shift($tokens);
|
||||
} else {
|
||||
|
@ -1018,7 +1018,7 @@ class template
|
|||
|
||||
switch ($expr_type) {
|
||||
case 'even':
|
||||
if ($tokens[$expr_end] == 'by') {
|
||||
if ($tokens[$expr_end] === 'by') {
|
||||
$expr_end++;
|
||||
$expr_arg = $tokens[$expr_end++];
|
||||
$expr = "!(($is_arg / $expr_arg) % $expr_arg)";
|
||||
|
@ -1028,7 +1028,7 @@ class template
|
|||
break;
|
||||
|
||||
case 'odd':
|
||||
if ($tokens[$expr_end] == 'by') {
|
||||
if ($tokens[$expr_end] === 'by') {
|
||||
$expr_end++;
|
||||
$expr_arg = $tokens[$expr_end++];
|
||||
$expr = "(($is_arg / $expr_arg) % $expr_arg)";
|
||||
|
@ -1038,7 +1038,7 @@ class template
|
|||
break;
|
||||
|
||||
case 'div':
|
||||
if ($tokens[$expr_end] == 'by') {
|
||||
if ($tokens[$expr_end] === 'by') {
|
||||
$expr_end++;
|
||||
$expr_arg = $tokens[$expr_end++];
|
||||
$expr = "!($is_arg % $expr_arg)";
|
||||
|
|
|
@ -49,7 +49,6 @@ $sql = DB()->fetch_rowset("
|
|||
AND tor.topic_id = t.topic_id
|
||||
AND t.forum_id = f.forum_id
|
||||
$not_auth_forums_sql
|
||||
GROUP BY tr.topic_id
|
||||
ORDER BY f.forum_name, t.topic_title
|
||||
");
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ $submit = $di->request->request->has('post');
|
|||
$preview = $di->request->request->has('preview');
|
||||
$delete = $di->request->request->has('delete');
|
||||
|
||||
$forum_id = $di->request->request->getInt(POST_FORUM_URL);
|
||||
$topic_id = $di->request->request->getInt(POST_TOPIC_URL);
|
||||
$post_id = $di->request->request->getInt(POST_POST_URL);
|
||||
$forum_id = $di->request->query->getInt(POST_FORUM_URL);
|
||||
$topic_id = $di->request->query->getInt(POST_TOPIC_URL);
|
||||
$post_id = $di->request->query->getInt(POST_POST_URL);
|
||||
|
||||
$mode = (string)$_REQUEST['mode'];
|
||||
|
||||
|
@ -628,7 +628,7 @@ if ($mode == 'newtopic' || $post_data['first_post']) {
|
|||
'S_FORM_ENCTYPE' => 'enctype="multipart/form-data"',
|
||||
'FILE_ATTACHED' => $file_attached,
|
||||
'ATTACH_MAX_SIZE' => humn_size($di->config->get('attach.max_size')),
|
||||
'ALLOWED_EXT' => ($allowed_ext) ? '*.' . join(', *.', $allowed_ext) : 'прикреплять запрещено', // TODO: перевести
|
||||
'ALLOWED_EXT' => ($allowed_ext) ? '*.' . implode(', *.', $allowed_ext) : 'прикреплять запрещено', // TODO: перевести
|
||||
'TOR_REQUIRED' => !empty($_POST['tor_required']),
|
||||
'POLL_TIP' => ($mode == 'newtopic') ? 'Вы сможете добавить опрос после создания темы' : 'Вы можете добавить опрос со страницы просмотра темы', // TODO: перевести
|
||||
));
|
||||
|
|
|
@ -169,7 +169,6 @@ if (!$forum_data['forum_parent'] && isset($forums['f'][$forum_id]['subforums'])
|
|||
WHERE f.forum_parent = $forum_id
|
||||
$only_new_sql
|
||||
$ignore_forum_sql
|
||||
GROUP BY f.forum_id
|
||||
ORDER BY f.forum_order
|
||||
";
|
||||
|
||||
|
|
|
@ -590,9 +590,23 @@ for ($i = 0; $i < $total_posts; $i++) {
|
|||
// Replace naughty words
|
||||
if (count($orig_word)) {
|
||||
if ($user_sig) {
|
||||
$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
|
||||
$user_sig = str_replace(
|
||||
'\"', '"',
|
||||
substr(
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($orig_word, $replacement_word) {
|
||||
return preg_replace($orig_word, $replacement_word, $matches[0]);
|
||||
}, '>' . $user_sig . '<'), 1, -1
|
||||
)
|
||||
);
|
||||
}
|
||||
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
|
||||
$message = str_replace(
|
||||
'\"', '"',
|
||||
substr(
|
||||
preg_replace_callback('#(\>(((?>([^><]+|(?R)))*)\<))#s', function ($matches) use ($orig_word, $replacement_word) {
|
||||
return preg_replace($orig_word, $replacement_word, $matches[0]);
|
||||
}, '>' . $message . '<'), 1, -1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue