1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00
This commit should increase the total number of BBCodes from 31 to 2040. Some things to watch out for:

Each database likes to deal with binary data in its own, special way. They are, quite frankly, too cool for school.

MySQL, MSSQL and Oracle all allow me to send in a default value for their binary column using a hex number. However, MSSQL forces me to send the specific data as a hex number and thus we must CAST it.

PostgreSQL allows me to set a binary column, but with a twist. It demands that the default be in _octal_ and its datatype allows somewhere around a gigabyte's worth of BBCodes ( PGSQL users, we shut you down to 2040 for your own good! )

Firebird has no decent mechanism for allowing me to shuttle in binary data so I must force my way in. By virtue of triggers and a UDF, we ram in our default values.

SQLite is the most bizarre of them all. They have no mechanism for turning an ASCII code into a ASCII character. Because of this, we have a trigger and a UDF (just like Firebird!) but with a twist! The UDF is defined on the PHP side of things instead of SQL. SQLite also demands that it's data be encoded before being sent off.

Other notes:
- SQLite installs again :D
- Firebird nearly installs again :P
- Database backup is not screwed up :P

P.S.
I hope nothing broke :D


git-svn-id: file:///svn/phpbb/trunk@6209 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M
2006-07-24 10:08:36 +00:00
parent 48b2dc1277
commit 9532514c2a
26 changed files with 1526 additions and 616 deletions

View File

@@ -164,7 +164,7 @@ class acp_bbcodes
$bbcode_id = NUM_CORE_BBCODES + 1;
}
if ($bbcode_id > 31)
if ($bbcode_id > 2039)
{
trigger_error('TOO_MANY_BBCODES');
}

View File

@@ -210,11 +210,11 @@ class acp_database
case 'oracle':
case 'postgres':
case 'firebird':
$sql_data .= 'TRUNCATE TABLE ' . $table_name . "\n";
$sql_data .= 'TRUNCATE TABLE ' . $table_name . ";\n";
break;
case 'sqlite':
$sql_data .= 'DELETE FROM ' . $table_name . "\n";
$sql_data .= 'DELETE FROM ' . $table_name . ";\n";
break;
}
}
@@ -1686,7 +1686,7 @@ class acp_database
if ($row['COLUMN_DEFAULT'])
{
$line .= ' CONSTRAINT [DF_' . $table_name . '_' . $row['COLUMN_NAME'] . '] DEFAULT ' . $row['COLUMN_DEFAULT'];
$line .= ' DEFAULT ' . $row['COLUMN_DEFAULT'];
}
$rows[] = $line;

View File

@@ -104,7 +104,7 @@ class acp_forums
'forum_rules' => request_var('forum_rules', '', true),
'forum_rules_uid' => '',
'forum_rules_options' => 0,
'forum_rules_bitfield' => 0,
'forum_rules_bitfield' => '',
'forum_rules_link' => request_var('forum_rules_link', ''),
'forum_image' => request_var('forum_image', ''),
'forum_style' => request_var('forum_style', 0),
@@ -419,7 +419,7 @@ class acp_forums
{
// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...
$forum_data['forum_rules_uid'] = '';
$forum_data['forum_rules_bitfield'] = 0;
$forum_data['forum_rules_bitfield'] = '';
$forum_data['forum_rules_options'] = 0;
generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_allow_bbcode', false), request_var('rules_allow_urls', false), request_var('rules_allow_smiliess', false));
@@ -439,7 +439,7 @@ class acp_forums
{
// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...
$forum_data['forum_desc_uid'] = '';
$forum_data['forum_desc_bitfield'] = 0;
$forum_data['forum_desc_bitfield'] = '';
$forum_data['forum_desc_options'] = 0;
generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smiliess', false));
@@ -919,8 +919,72 @@ class acp_forums
$forum_id = $forum_data_sql['forum_id'];
unset($forum_data_sql['forum_id']);
$query = '';
switch (SQL_LAYER)
{
case 'mssql':
case 'mssql_odbc':
$values = array();
foreach ($forum_data_sql as $key => $var)
{
if (is_null($var))
{
$values[] = "$key = NULL";
}
else if (is_string($var))
{
if ($key !== 'forum_desc_bitfield' && $key != 'forum_rules_bitfield')
{
$values[] = "$key = '" . $db->sql_escape($var) . "'";
}
else
{
$values[] = "$key = CAST('" . $var . "' AS varbinary)";
}
}
else
{
$values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
}
}
$query = implode(', ', $values);
break;
case 'sqlite':
$values = array();
foreach ($forum_data_sql as $key => $var)
{
if (is_null($var))
{
$values[] = "$key = NULL";
}
else if (is_string($var))
{
if ($key !== 'forum_desc_bitfield' && $key != 'forum_rules_bitfield')
{
$values[] = "$key = '" . $db->sql_escape($var) . "'";
}
else
{
$values[] = "$key = '" . sqlite_udf_encode_binary($var) . "'";
}
}
else
{
$values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var";
}
}
$query = implode(', ', $values);
break;
default:
$query = $db->sql_build_array('UPDATE', $forum_data_sql);
break;
}
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . '
SET ' . $query . '
WHERE forum_id = ' . $forum_id;
$db->sql_query($sql);

View File

@@ -27,7 +27,14 @@ class acp_styles
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
// Hardcoded template bitfield to add for new templates
define('TEMPLATE_BITFIELD', 6921);
$bitfield = new bitfield();
$bitfield->set(0);
$bitfield->set(3);
$bitfield->set(8);
$bitfield->set(9);
$bitfield->set(11);
$bitfield->set(12);
define('TEMPLATE_BITFIELD', $bitfield->data);
$user->add_lang('acp/styles');
@@ -2917,10 +2924,78 @@ pagination_sep = \'{PAGINATION_SEP}\'
unset($cfg_data);
}
$query = '';
switch (SQL_LAYER)
{
case 'mssql':
case 'mssql_odbc':
$fields = array();
foreach ($sql_ary as $key => $var)
{
$fields[] = $key;
if (is_null($var))
{
$values[] = 'NULL';
}
else if (is_string($var))
{
if ($key !== 'bbcode_bitfield')
{
$values[] = "'" . $db->sql_escape($var) . "'";
}
else
{
$values[] = "CAST('" . $var . "' AS varbinary)";
}
}
else
{
$values[] = (is_bool($var)) ? intval($var) : $var;
}
}
$query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
break;
case 'sqlite':
$fields = array();
foreach ($sql_ary as $key => $var)
{
$fields[] = $key;
if (is_null($var))
{
$values[] = 'NULL';
}
else if (is_string($var))
{
if ($key !== 'bbcode_bitfield')
{
$values[] = "'" . $db->sql_escape($var) . "'";
}
else
{
$values[] = "'" . sqlite_udf_encode_binary($var) . "'";
}
}
else
{
$values[] = (is_bool($var)) ? intval($var) : $var;
}
}
$query = ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')';
break;
default:
$query = $db->sql_build_array('INSERT', $sql_ary);
break;
}
$db->sql_transaction('begin');
$sql = "INSERT INTO $sql_from
" . $db->sql_build_array('INSERT', $sql_ary);
" . $query;
$db->sql_query($sql);
$id = $db->sql_nextid();