- BBCode bugs

- PostgreSQL now gives us database info (if you are running 8.1 or have the dbsize contrib module installed)


git-svn-id: file:///svn/phpbb/trunk@6042 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2006-06-10 16:51:24 +00:00
parent 6bbeda9450
commit 4613de6f87
4 changed files with 98 additions and 46 deletions

View file

@ -466,6 +466,7 @@ class bbcode
// when using the /e modifier, preg_replace slashes double-quotes but does not
// seem to slash anything else
$quote = str_replace('\"', '"', $quote);
$username = str_replace('\"', '"', $username);
// remove newline at the beginning
if ($quote{0} == "\n")

View file

@ -1844,15 +1844,15 @@ function make_clickable($text, $server_url = false)
// Be sure to not let the matches cross over. ;)
// relative urls for this board
$magic_url_match[] = '#(^|[\n \]]|\()(' . preg_quote($server_url, '#') . ')/(([^[ \t\n\r<"\'\)&]+|&(?!lt;))*)#i';
$magic_url_match[] = '#(^|[\n \]]|\()(' . preg_quote($server_url, '#') . ')/(([^[ \t\n\r<"\'\)&]+|&(?!lt;|quot;))*)#i';
$magic_url_replace[] = '$1<!-- l --><a href="$2/$3">$3</a><!-- l -->';
// matches a xxxx://aaaaa.bbb.cccc. ...
$magic_url_match[] = '#(^|[\n \]]|\()([\w]+:/{2}.*?([^[ \t\n\r<"\'\)&]+|&(?!lt;))*)#ie';
$magic_url_match[] = '#(^|[\n \]]|\()([\w]+:/{2}.*?([^[ \t\n\r<"\'\)&]+|&(?!lt;|quot;))*)#ie';
$magic_url_replace[] = "'\$1<!-- m --><a href=\"\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace('&amp;', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&amp;', '&', '\$2'), -10) : '\$2') . '</a><!-- m -->'";
// matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
$magic_url_match[] = '#(^|[\n \]]|\()(w{3}\.[\w\-]+\.[\w\-.\~]+(?:[^[ \t\n\r<"\'\)&]+|&(?!lt;))*)#ie';
$magic_url_match[] = '#(^|[\n \]]|\()(w{3}\.[\w\-]+\.[\w\-.\~]+(?:[^[ \t\n\r<"\'\)&]+|&(?!lt;|quot;))*)#ie';
$magic_url_replace[] = "'\$1<!-- w --><a href=\"http://\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace('&amp;', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&amp;', '&', '\$2'), -10) : '\$2') . '</a><!-- w -->'";
// matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode.
@ -1895,7 +1895,14 @@ function smiley_text($text, $force_option = false)
{
global $config, $user, $phpbb_root_path;
return ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $text) : str_replace('<img src="{SMILIES_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $text);
if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{
return preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILIES_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $text);
}
else
{
return str_replace('<img src="{SMILIES_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $text);
}
}
/**

View file

@ -2266,66 +2266,110 @@ function get_database_size()
global $db, $user, $table_prefix;
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
if (preg_match('#^mysql#', SQL_LAYER))
switch (SQL_LAYER)
{
$sql = 'SELECT VERSION() AS mysql_version';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
case 'mysql':
case 'mysql4':
case 'mysqli':
$sql = 'SELECT VERSION() AS mysql_version';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$version = $row['mysql_version'];
if (preg_match('#(3\.23|[45]\.)#', $version))
if ($row)
{
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname;
$version = $row['mysql_version'];
$sql = "SHOW TABLE STATUS
FROM " . $db_name;
$result = $db->sql_query($sql);
$dbsize = 0;
while ($row = $db->sql_fetchrow($result))
if (preg_match('#(3\.23|[45]\.)#', $version))
{
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname;
$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;
$result = $db->sql_query($sql);
$dbsize = 0;
while ($row = $db->sql_fetchrow($result))
{
if ($table_prefix != '')
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB')))
{
if (strstr($row['Name'], $table_prefix))
if ($table_prefix != '')
{
if (strstr($row['Name'], $table_prefix))
{
$dbsize += $row['Data_length'] + $row['Index_length'];
}
}
else
{
$dbsize += $row['Data_length'] + $row['Index_length'];
}
}
else
{
$dbsize += $row['Data_length'] + $row['Index_length'];
}
}
$db->sql_freeresult($result);
}
else
{
$dbsize = $user->lang['NOT_AVAILABLE'];
}
$db->sql_freeresult($result);
}
else
{
$dbsize = $user->lang['NOT_AVAILABLE'];
}
}
else
{
break;
case 'mssql':
case 'mssql_odbc':
$sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
FROM sysfiles';
$result = $db->sql_query($sql);
$dbsize = ($row = $db->sql_fetchrow($result)) ? intval($row['dbsize']) : $user->lang['NOT_AVAILABLE'];
$db->sql_freeresult($result);
break;
case 'postgres':
$sql = "SELECT proname
FROM pg_proc
WHERE proname = 'pg_database_size'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row['proname'] == 'pg_database_size')
{
$sql = "SELECT oid
FROM pg_database
WHERE datname = '" . $db->dbname . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$oid = $row['oid'];
$sql = 'SELECT pg_database_size(' . $oid . ') as size';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$dbsize = $row['size'];
}
else
{
$dbsize = $user->lang['NOT_AVAILABLE'];
}
break;
default:
$dbsize = $user->lang['NOT_AVAILABLE'];
}
}
else if (preg_match('#^mssql#', SQL_LAYER))
{
$sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize
FROM sysfiles';
$result = $db->sql_query($sql);
$dbsize = ($row = $db->sql_fetchrow($result)) ? intval($row['dbsize']) : $user->lang['NOT_AVAILABLE'];
$db->sql_freeresult($result);
}
else
{
$dbsize = $user->lang['NOT_AVAILABLE'];
}
if (is_int($dbsize))

View file

@ -31,7 +31,7 @@ if (empty($lang) || !is_array($lang))
// BBCodes
// Note to translators: you can translate everything but what's between { and }
$lang = array_merge($lang, array(
'ACP_BBCODES_EXPLAIN' => 'BBCode is a special implementation of HTML offering greater control over what and how something is displayed. Additionnally, you can save users from typing sometimes very long HTML code by providing them a single BBCode as replacement. From this page you can add, remove and edit custom BBCodes',
'ACP_BBCODES_EXPLAIN' => 'BBCode is a special implementation of HTML offering greater control over what and how something is displayed. From this page you can add, remove and edit custom BBCodes',
'ADD_BBCODE' => 'Add a new BBCode',
'BBCODE_ADDED' => 'BBCode added successfully',