mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
feat: Restore some deprecated code for backward compatibility (#2028)
* feat: Restore some deprecated code for backward compatibility * feat: Restore some constants * feat: Restore `commify()` function * feat: Restored functions: `bb_ltrim`, `bb_rtrim`, `get_db_stat` * feat: Restore `bb_realpath` * Update functions.php * feat: Restore `AJAX_HTML_DIR` constant * Update defines.php * Update attach_maintenance.php * Update viewtopic.php
This commit is contained in:
parent
90121aa21d
commit
695864ef69
12 changed files with 94 additions and 3 deletions
|
@ -800,6 +800,11 @@ function str_short($text, $max_length, $space = ' ')
|
|||
return $text ?? '';
|
||||
}
|
||||
|
||||
function wbr($text, $max_word_length = HTML_WBR_LENGTH)
|
||||
{
|
||||
return preg_replace("/([\w\->;:.,~!?(){}@#$%^*\/\\\\]{" . $max_word_length . "})/ui", '$1<wbr>', $text);
|
||||
}
|
||||
|
||||
function generate_user_info($row, bool $have_auth = IS_ADMIN): array
|
||||
{
|
||||
global $userdata, $lang, $images, $bb_cfg;
|
||||
|
@ -940,6 +945,47 @@ function bb_update_config($params, $table = BB_CONFIG)
|
|||
bb_get_config($table, true, true);
|
||||
}
|
||||
|
||||
function get_db_stat($mode)
|
||||
{
|
||||
switch ($mode) {
|
||||
case 'usercount':
|
||||
$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";
|
||||
break;
|
||||
|
||||
case 'postcount':
|
||||
case 'topiccount':
|
||||
$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total FROM " . BB_FORUMS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!($result = DB()->sql_query($sql))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$row = DB()->sql_fetchrow($result);
|
||||
|
||||
switch ($mode) {
|
||||
case 'usercount':
|
||||
return $row['total'];
|
||||
break;
|
||||
case 'newestuser':
|
||||
return $row;
|
||||
break;
|
||||
case 'postcount':
|
||||
return $row['post_total'];
|
||||
break;
|
||||
case 'topiccount':
|
||||
return $row['topic_total'];
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function clean_username($username)
|
||||
{
|
||||
$username = mb_substr(htmlspecialchars(str_replace("\'", "'", trim($username))), 0, 25, DEFAULT_CHARSET);
|
||||
|
@ -949,6 +995,28 @@ function clean_username($username)
|
|||
return $username;
|
||||
}
|
||||
|
||||
function bb_ltrim($str, $charlist = false)
|
||||
{
|
||||
if ($charlist === false) {
|
||||
return ltrim($str);
|
||||
}
|
||||
|
||||
$str = ltrim($str, $charlist);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
function bb_rtrim($str, $charlist = false)
|
||||
{
|
||||
if ($charlist === false) {
|
||||
return rtrim($str);
|
||||
}
|
||||
|
||||
$str = rtrim($str, $charlist);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Userdata
|
||||
*
|
||||
|
@ -1094,6 +1162,7 @@ function setup_style()
|
|||
$css_dir = 'styles/' . basename(TEMPLATES_DIR) . '/' . $tpl_dir_name . '/css/';
|
||||
|
||||
$template->assign_vars([
|
||||
'BB_ROOT' => BB_ROOT,
|
||||
'SPACER' => make_url('styles/images/spacer.gif'),
|
||||
'STYLESHEET' => make_url($css_dir . $stylesheet),
|
||||
'EXT_LINK_NEW_WIN' => $bb_cfg['ext_link_new_win'],
|
||||
|
@ -1412,6 +1481,11 @@ function bb_simple_die($txt, $status_code = null)
|
|||
die($txt);
|
||||
}
|
||||
|
||||
function bb_realpath($path)
|
||||
{
|
||||
return realpath($path);
|
||||
}
|
||||
|
||||
function login_redirect($url = '')
|
||||
{
|
||||
redirect(LOGIN_URL . '?redirect=' . (($url) ?: ($_SERVER['REQUEST_URI'] ?? '/')));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue