This is an automated email from the git hooks/post-receive script. s k u n n y k p u s h e d a c o m m i t t o b r a n c h o l d f o r u m in repository www/forum.xfce.org.
commit ce720bfa9b9139a22a0facc0687207188f0bc5d1 Author: Nick Schermer <n...@xfce.org> Date: Sat Jan 7 21:24:01 2012 +0100 Upgrade to Fluxbb 1.4.8. --- admin_bans.php | 2 +- admin_categories.php | 2 +- admin_censoring.php | 2 +- admin_forums.php | 2 +- admin_groups.php | 2 +- admin_index.php | 2 +- admin_loader.php | 2 +- admin_maintenance.php | 2 +- admin_options.php | 2 +- admin_permissions.php | 2 +- admin_ranks.php | 2 +- admin_reports.php | 2 +- admin_users.php | 2 +- common.js | 8 +- db_update.php | 6 +- delete.php | 2 +- edit.php | 5 +- extern.php | 2 +- footer.php | 2 +- header.php | 15 +- help.php | 4 +- include/cache.php | 4 +- include/common.php | 14 +- include/common_admin.php | 2 +- include/dblayer/common_db.php | 2 +- include/dblayer/mysql.php | 2 +- include/dblayer/mysql_innodb.php | 2 +- include/dblayer/mysqli.php | 2 +- include/dblayer/mysqli_innodb.php | 2 +- include/dblayer/pgsql.php | 2 +- include/dblayer/sqlite.php | 16 +- include/email.php | 288 ++++++++++++------------- include/functions.php | 67 +++++- include/parser.php | 135 +++++++----- include/search_idx.php | 11 +- include/utf8/utf8.php | 2 +- include/utf8/utils/bad.php | 93 ++++---- index.php | 2 +- lang/English/admin_options.php | 22 +- lang/English/mail_templates/new_reply_full.tpl | 4 +- lang/English/mail_templates/new_topic_full.tpl | 4 +- lang/English/post.php | 2 +- lang/English/prof_reg.php | 22 +- login.php | 2 +- misc.php | 2 +- moderate.php | 2 +- post.php | 10 +- profile.php | 2 +- register.php | 2 +- search.php | 4 +- style/imports/minmax.js | 12 +- userlist.php | 2 +- viewforum.php | 2 +- viewtopic.php | 2 +- 54 files changed, 455 insertions(+), 357 deletions(-) diff --git a/admin_bans.php b/admin_bans.php index d141889..ec5aa96 100644 --- a/admin_bans.php +++ b/admin_bans.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_categories.php b/admin_categories.php index 7f5ec0f..5baf447 100644 --- a/admin_categories.php +++ b/admin_categories.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_censoring.php b/admin_censoring.php index 06d2a85..de2c844 100644 --- a/admin_censoring.php +++ b/admin_censoring.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_forums.php b/admin_forums.php index 1d15a2a..c069392 100644 --- a/admin_forums.php +++ b/admin_forums.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_groups.php b/admin_groups.php index 7852e79..fa00b4f 100644 --- a/admin_groups.php +++ b/admin_groups.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_index.php b/admin_index.php index e4f6023..3515e13 100644 --- a/admin_index.php +++ b/admin_index.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_loader.php b/admin_loader.php index 7e753cd..4891f72 100644 --- a/admin_loader.php +++ b/admin_loader.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_maintenance.php b/admin_maintenance.php index 60cb957..600d434 100644 --- a/admin_maintenance.php +++ b/admin_maintenance.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_options.php b/admin_options.php index fdabe2b..3e8581e 100644 --- a/admin_options.php +++ b/admin_options.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_permissions.php b/admin_permissions.php index c92e01d..6abf977 100644 --- a/admin_permissions.php +++ b/admin_permissions.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_ranks.php b/admin_ranks.php index fb5f7c1..37e7e18 100644 --- a/admin_ranks.php +++ b/admin_ranks.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_reports.php b/admin_reports.php index 4f7d091..58aa976 100644 --- a/admin_reports.php +++ b/admin_reports.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/admin_users.php b/admin_users.php index d393d24..063b0b8 100644 --- a/admin_users.php +++ b/admin_users.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/common.js b/common.js index b7ff12f..47a7155 100644 --- a/common.js +++ b/common.js @@ -1,4 +1,10 @@ +/** + * Copyright (C) 2008-2012 FluxBB + * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB + * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher + */ + function select_checkboxes(curFormId, link, new_string) { var curForm = document.getElementById(curFormId); @@ -29,4 +35,4 @@ function unselect_checkboxes(curFormId, link, new_string) link.innerHTML = new_string; return false; -} \ No newline at end of file +} diff --git a/db_update.php b/db_update.php index 20a00af..7706230 100644 --- a/db_update.php +++ b/db_update.php @@ -1,13 +1,13 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ // The FluxBB version this script updates to -define('UPDATE_TO', '1.4.7'); +define('UPDATE_TO', '1.4.8'); define('UPDATE_TO_DB_REVISION', 15); define('UPDATE_TO_SI_REVISION', 2); @@ -1905,4 +1905,4 @@ $db->end_transaction(); $db->close(); if ($query_str != '') - exit('<script type="text/javascript">window.location="db_update.php'.$query_str.'&uid='.$uid.'"</script><noscript><meta http-equiv="refresh" content="0;url=db_update.php'.$query_str.'&uid='.$uid.'" /></noscript>'); \ No newline at end of file + exit('<script type="text/javascript">window.location="db_update.php'.$query_str.'&uid='.$uid.'"</script><noscript><meta http-equiv="refresh" content="0;url=db_update.php'.$query_str.'&uid='.$uid.'" /></noscript>'); diff --git a/delete.php b/delete.php index 7844c4b..ba92f19 100644 --- a/delete.php +++ b/delete.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/edit.php b/edit.php index 1f35edd..58f8be3 100644 --- a/edit.php +++ b/edit.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -108,6 +108,9 @@ if (isset($_POST['form_sent'])) $stick_topic = isset($_POST['stick_topic']) ? '1' : '0'; if (!$is_admmod) $stick_topic = $cur_post['sticky']; + + // Replace four-byte characters (MySQL cannot handle them) + $message = strip_bad_multibyte_chars($message); // Did everything go according to plan? if (empty($errors) && !isset($_POST['preview'])) diff --git a/extern.php b/extern.php index 364229e..eb4bc94 100644 --- a/extern.php +++ b/extern.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/footer.php b/footer.php index 6c92e00..b6b8a7a 100644 --- a/footer.php +++ b/footer.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/header.php b/header.php index b3a15a1..b4905aa 100644 --- a/header.php +++ b/header.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -104,7 +104,7 @@ if (isset($required_fields)) /* <![CDATA[ */ function process_form(the_form) { - var element_names = { + var required_fields = { <?php // Output a JavaScript object with localised field names $tpl_temp = count($required_fields); @@ -120,14 +120,11 @@ function process_form(the_form) for (var i = 0; i < the_form.length; ++i) { var elem = the_form.elements[i]; - if (elem.name && (/^req_/.test(elem.name))) + if (elem.name && required_fields[elem.name] && !elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type))) { - if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type))) - { - alert('"' + element_names[elem.name] + '" <?php echo $lang_common['required field'] ?>'); - elem.focus(); - return false; - } + alert('"' + required_fields[elem.name] + '" <?php echo $lang_common['required field'] ?>'); + elem.focus(); + return false; } } } diff --git a/help.php b/help.php index 0820794..39e5d07 100644 --- a/help.php +++ b/help.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -55,7 +55,7 @@ require PUN_ROOT.'header.php'; <p><?php echo $lang_help['Links info'] ?></p> <p><code>[url=<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>]<?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>"><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?></a></samp></p> <p><code>[url]<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>"><?php echo pun_htmlspecialchars(get_base_url(true).'/') ?></a></samp></p> - <p><code>[url=/help.php]<?php echo $lang_help['This help page'] ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo get_base_url(true).'/help.php' ?>"><?php echo $lang_help['This help page'] ?></a></samp></p> + <p><code>[url=/help.php]<?php echo $lang_help['This help page'] ?>[/url]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/help.php') ?>"><?php echo $lang_help['This help page'] ?></a></samp></p> <p><code>[email]myn...@mydomain.com[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myn...@mydomain.com">myn...@mydomain.com</a></samp></p> <p><code>[email=myn...@mydomain.com]<?php echo $lang_help['My email address'] ?>[/email]</code> <?php echo $lang_help['produces'] ?> <samp><a href="mailto:myn...@mydomain.com"><?php echo $lang_help['My email address'] ?></a></samp></p> <p><code>[topic=1]<?php echo $lang_help['Test topic'] ?>[/topic]</code> <?php echo $lang_help['produces'] ?> <samp><a href="<?php echo pun_htmlspecialchars(get_base_url(true).'/viewtopic.php?id=1') ?>"><?php echo $lang_help['Test topic'] ?></a></samp></p> diff --git a/include/cache.php b/include/cache.php index 2070fb4..e4b9112 100644 --- a/include/cache.php +++ b/include/cache.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -20,6 +20,8 @@ function generate_config_cache() // Get the forum config from the DB $result = $db->query('SELECT * FROM '.$db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error()); + + $output = array(); while ($cur_config_item = $db->fetch_row($result)) $output[$cur_config_item[0]] = $cur_config_item[1]; diff --git a/include/common.php b/include/common.php index 59d21e6..6b9319e 100644 --- a/include/common.php +++ b/include/common.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -10,7 +10,7 @@ if (!defined('PUN_ROOT')) exit('The constant PUN_ROOT must be defined and point to a valid FluxBB installation root directory.'); // Define the version and database revision that this code was written for -define('FORUM_VERSION', '1.4.7'); +define('FORUM_VERSION', '1.4.8'); define('FORUM_DB_REVISION', 15); define('FORUM_SI_REVISION', 2); @@ -71,7 +71,7 @@ if (get_magic_quotes_runtime()) set_magic_quotes_runtime(0); // Strip slashes from GET/POST/COOKIE/REQUEST/FILES (if magic_quotes_gpc is enabled) -if (get_magic_quotes_gpc()) +if (!defined('FORUM_DISABLE_STRIPSLASHES') && get_magic_quotes_gpc()) { function stripslashes_array($array) { @@ -82,7 +82,13 @@ if (get_magic_quotes_gpc()) $_POST = stripslashes_array($_POST); $_COOKIE = stripslashes_array($_COOKIE); $_REQUEST = stripslashes_array($_REQUEST); - $_FILES = stripslashes_array($_FILES); + if (is_array($_FILES)) + { + // Don't strip valid slashes from tmp_name path on Windows + foreach ($_FILES AS $key => $value) + $_FILES[$key]['tmp_name'] = str_replace('\\', '\\\\', $value['tmp_name']); + $_FILES = stripslashes_array($_FILES); + } } // If a cookie name is not specified in config.php, we use the default (pun_cookie) diff --git a/include/common_admin.php b/include/common_admin.php index bc353ac..594b401 100644 --- a/include/common_admin.php +++ b/include/common_admin.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/common_db.php b/include/dblayer/common_db.php index be48607..5b9e67e 100644 --- a/include/dblayer/common_db.php +++ b/include/dblayer/common_db.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/mysql.php b/include/dblayer/mysql.php index 53b37b2..6f0e3af 100644 --- a/include/dblayer/mysql.php +++ b/include/dblayer/mysql.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/mysql_innodb.php b/include/dblayer/mysql_innodb.php index 6851309..2b14ab2 100644 --- a/include/dblayer/mysql_innodb.php +++ b/include/dblayer/mysql_innodb.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/mysqli.php b/include/dblayer/mysqli.php index c17294d..9da4cf1 100644 --- a/include/dblayer/mysqli.php +++ b/include/dblayer/mysqli.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/mysqli_innodb.php b/include/dblayer/mysqli_innodb.php index b9f43db..1538c71 100644 --- a/include/dblayer/mysqli_innodb.php +++ b/include/dblayer/mysqli_innodb.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/pgsql.php b/include/dblayer/pgsql.php index 66b81ca..577b5a0 100644 --- a/include/dblayer/pgsql.php +++ b/include/dblayer/pgsql.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/include/dblayer/sqlite.php b/include/dblayer/sqlite.php index e934dc4..f634d5e 100644 --- a/include/dblayer/sqlite.php +++ b/include/dblayer/sqlite.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -49,7 +49,7 @@ class DBLayer if (!is_readable($db_name)) error('Unable to open database \''.$db_name.'\' for reading. Permission denied', __FILE__, __LINE__); - if (!is_writable($db_name)) + if (!forum_is_writable($db_name)) error('Unable to open database \''.$db_name.'\' for writing. Permission denied', __FILE__, __LINE__); if ($p_connect) @@ -345,7 +345,7 @@ class DBLayer if (!$this->table_exists($table_name, $no_prefix)) return true; - return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; + return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name)) ? true : false; } @@ -372,7 +372,7 @@ class DBLayer $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($new_name).' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($old_name)) ? true : false; // Drop old table - $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name)); + $result &= $this->drop_table($table_name, $no_prefix); return $result; } @@ -460,7 +460,7 @@ class DBLayer $new_table = trim($new_table, ',')."\n".');'; // Drop old table - $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name)); + $result &= $this->drop_table($table_name, $no_prefix); // Create new table $result &= $this->query($new_table) ? true : false; @@ -476,7 +476,7 @@ class DBLayer $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' ('.implode(', ', $old_columns).') SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now) ? true : false; // Drop temp table - $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now); + $result &= $this->drop_table($table_name.'_t'.$now, $no_prefix); return $result; } @@ -520,7 +520,7 @@ class DBLayer $new_table = trim($new_table, ',')."\n".');'; // Drop old table - $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name)); + $result &= $this->drop_table($table_name, $no_prefix); // Create new table $result &= $this->query($new_table) ? true : false; @@ -537,7 +537,7 @@ class DBLayer $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' SELECT '.implode(', ', $new_columns).' FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now) ? true : false; // Drop temp table - $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now); + $result &= $this->drop_table($table_name.'_t'.$now, $no_prefix); return $result; } diff --git a/include/email.php b/include/email.php index 94058d0..85543d1 100644 --- a/include/email.php +++ b/include/email.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -60,149 +60,149 @@ function encode_mail_text($str) // function bbcode2email($text, $wrap_length = 72) { - static $base_url; - - if (!isset($base_url)) - $base_url = get_base_url(); - - $text = pun_trim($text, "\t\n "); - - $shortcut_urls = array( - 'topic' => '/viewtopic.php?id=$1', - 'post' => '/viewtopic.php?pid=$1#p$1', - 'forum' => '/viewforum.php?id=$1', - 'user' => '/profile.php?id=$1', - ); - - // Split code blocks and text so BBcode in codeblocks won't be touched - list($code, $text) = extract_blocks($text, '[code]', '[/code]'); - - // Strip all bbcodes, except the quote, url, img, email, code and list items bbcodes - $text = preg_replace(array( - '%\[/?(?!(?:quote|url|topic|post|user|forum|img|email|code|list|\*))[a-z]+(?:=[^\]]+)?\]%i', - '%\n\[/?list(?:=[^\]]+)?\]%i' // A separate regex for the list tags to get rid of some whitespace - ), '', $text); - - // Match the deepest nested bbcode - // An adapted example from Mastering Regular Expressions - $match_quote_regex = '% - \[(quote|\*|url|img|email|topic|post|user|forum)(?:=([^\]]+))?\] - ( - (?>[^\[]*) - (?> - (?!\[/?\1(?:=[^\]]+)?\]) - \[ - [^\[]* - )* - ) - \[/\1\] - %ix'; - - $url_index = 1; - $url_stack = array(); - while (preg_match($match_quote_regex, $text, $matches)) - { - // Quotes - if ($matches[1] == 'quote') - { - // Put '>' or '> ' at the start of a line - $replacement = preg_replace( - array('%^(?=\>)%m', '%^(?!\>)%m'), - array('>', '> '), - $matches[2]." said:\n".$matches[3]); - } - - // List items - elseif ($matches[1] == '*') - { - $replacement = ' * '.$matches[3]; - } - - // URLs and emails - elseif (in_array($matches[1], array('url', 'email'))) - { - if (!empty($matches[2])) - { - $replacement = '['.$matches[3].']['.$url_index.']'; - $url_stack[$url_index] = $matches[2]; - $url_index++; - } - else - $replacement = '['.$matches[3].']'; - } - - // Images - elseif ($matches[1] == 'img') - { - if (!empty($matches[2])) - $replacement = '['.$matches[2].']['.$url_index.']'; - else - $replacement = '['.basename($matches[3]).']['.$url_index.']'; - - $url_stack[$url_index] = $matches[3]; - $url_index++; - } - - // Topic, post, forum and user URLs - elseif (in_array($matches[1], array('topic', 'post', 'forum', 'user'))) - { - $url = isset($shortcut_urls[$matches[1]]) ? $base_url.$shortcut_urls[$matches[1]] : ''; - - if (!empty($matches[2])) - { - $replacement = '['.$matches[3].']['.$url_index.']'; - $url_stack[$url_index] = str_replace('$1', $matches[2], $url); - $url_index++; - } - else - $replacement = '['.str_replace('$1', $matches[3], $url).']'; - } - - // Update the main text if there is a replacment - if (!is_null($replacement)) - { - $text = str_replace($matches[0], $replacement, $text); - $replacement = null; - } - } - - // Put code blocks and text together - if (isset($code)) - { - $parts = explode("\1", $text); - $text = ''; - foreach ($parts as $i => $part) - { - $text .= $part; - if (isset($code[$i])) - $text .= trim($code[$i], "\n\r"); - } - } - - // Put URLs at the bottom - if ($url_stack) - { - $text .= "\n\n"; - foreach ($url_stack as $i => $url) - $text .= "\n".' ['.$i.']: '.$url; - } - - // Wrap lines if $wrap_length is higher than -1 - if ($wrap_length > -1) - { - // Split all lines and wrap them individually - $parts = explode("\n", $text); - foreach ($parts as $k => $part) - { - preg_match('%^(>+ )?(.*)%', $part, $matches); - $parts[$k] = wordwrap($matches[1].$matches[2], $wrap_length - - strlen($matches[1]), "\n".$matches[1]); - } - - return implode("\n", $parts); - } - else - return $text; + static $base_url; + + if (!isset($base_url)) + $base_url = get_base_url(); + + $text = pun_trim($text, "\t\n "); + + $shortcut_urls = array( + 'topic' => '/viewtopic.php?id=$1', + 'post' => '/viewtopic.php?pid=$1#p$1', + 'forum' => '/viewforum.php?id=$1', + 'user' => '/profile.php?id=$1', + ); + + // Split code blocks and text so BBcode in codeblocks won't be touched + list($code, $text) = extract_blocks($text, '[code]', '[/code]'); + + // Strip all bbcodes, except the quote, url, img, email, code and list items bbcodes + $text = preg_replace(array( + '%\[/?(?!(?:quote|url|topic|post|user|forum|img|email|code|list|\*))[a-z]+(?:=[^\]]+)?\]%i', + '%\n\[/?list(?:=[^\]]+)?\]%i' // A separate regex for the list tags to get rid of some whitespace + ), '', $text); + + // Match the deepest nested bbcode + // An adapted example from Mastering Regular Expressions + $match_quote_regex = '% + \[(quote|\*|url|img|email|topic|post|user|forum)(?:=([^\]]+))?\] + ( + (?>[^\[]*) + (?> + (?!\[/?\1(?:=[^\]]+)?\]) + \[ + [^\[]* + )* + ) + \[/\1\] + %ix'; + + $url_index = 1; + $url_stack = array(); + while (preg_match($match_quote_regex, $text, $matches)) + { + // Quotes + if ($matches[1] == 'quote') + { + // Put '>' or '> ' at the start of a line + $replacement = preg_replace( + array('%^(?=\>)%m', '%^(?!\>)%m'), + array('>', '> '), + $matches[2]." said:\n".$matches[3]); + } + + // List items + elseif ($matches[1] == '*') + { + $replacement = ' * '.$matches[3]; + } + + // URLs and emails + elseif (in_array($matches[1], array('url', 'email'))) + { + if (!empty($matches[2])) + { + $replacement = '['.$matches[3].']['.$url_index.']'; + $url_stack[$url_index] = $matches[2]; + $url_index++; + } + else + $replacement = '['.$matches[3].']'; + } + + // Images + elseif ($matches[1] == 'img') + { + if (!empty($matches[2])) + $replacement = '['.$matches[2].']['.$url_index.']'; + else + $replacement = '['.basename($matches[3]).']['.$url_index.']'; + + $url_stack[$url_index] = $matches[3]; + $url_index++; + } + + // Topic, post, forum and user URLs + elseif (in_array($matches[1], array('topic', 'post', 'forum', 'user'))) + { + $url = isset($shortcut_urls[$matches[1]]) ? $base_url.$shortcut_urls[$matches[1]] : ''; + + if (!empty($matches[2])) + { + $replacement = '['.$matches[3].']['.$url_index.']'; + $url_stack[$url_index] = str_replace('$1', $matches[2], $url); + $url_index++; + } + else + $replacement = '['.str_replace('$1', $matches[3], $url).']'; + } + + // Update the main text if there is a replacment + if (!is_null($replacement)) + { + $text = str_replace($matches[0], $replacement, $text); + $replacement = null; + } + } + + // Put code blocks and text together + if (isset($code)) + { + $parts = explode("\1", $text); + $text = ''; + foreach ($parts as $i => $part) + { + $text .= $part; + if (isset($code[$i])) + $text .= trim($code[$i], "\n\r"); + } + } + + // Put URLs at the bottom + if ($url_stack) + { + $text .= "\n\n"; + foreach ($url_stack as $i => $url) + $text .= "\n".' ['.$i.']: '.$url; + } + + // Wrap lines if $wrap_length is higher than -1 + if ($wrap_length > -1) + { + // Split all lines and wrap them individually + $parts = explode("\n", $text); + foreach ($parts as $k => $part) + { + preg_match('%^(>+ )?(.*)%', $part, $matches); + $parts[$k] = wordwrap($matches[1].$matches[2], $wrap_length - + strlen($matches[1]), "\n".$matches[1]); + } + + return implode("\n", $parts); + } + else + return $text; } diff --git a/include/functions.php b/include/functions.php index 7f10be3..e430b29 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -1653,7 +1653,7 @@ function remove_bad_characters($array) $array = utf8_bad_strip($array); // Remove control characters - $array = preg_replace('%[\x{00}-\x{08}\x{0b}-\x{0c}\x{0e}-\x{1f}]%', '', $array); + $array = preg_replace('%[\x00-\x08\x0b-\x0c\x0e-\x1f]%', '', $array); // Replace some "bad" characters $array = str_replace(array_keys($bad_utf8_chars), array_values($bad_utf8_chars), $array); @@ -1777,7 +1777,7 @@ function forum_list_plugins($is_admin) // // Split text into chunks ($inside contains all text inside $start and $end, and $outside contains all text outside) // -function split_text($text, $start, $end, &$errors, $retab = true) +function split_text($text, $start, $end, $retab = true) { global $pun_config, $lang_common; @@ -1805,7 +1805,7 @@ function split_text($text, $start, $end, &$errors, $retab = true) // Extract blocks from a text with a starting and ending string // This function always matches the most outer block so nesting is possible // -function extract_blocks($text, $start, $end, &$errors = array(), $retab = true) +function extract_blocks($text, $start, $end, $retab = true) { global $pun_config; @@ -1995,6 +1995,65 @@ function ucp_preg_replace($pattern, $replace, $subject) return $replaced; } +// +// Replace four-byte characters with a question mark +// +// As MySQL cannot properly handle four-byte characters with the default utf-8 +// charset up until version 5.5.3 (where a special charset has to be used), they +// need to be replaced, by question marks in this case. +// +function strip_bad_multibyte_chars($str) +{ + $result = ''; + $length = strlen($str); + + for ($i = 0; $i < $length; $i++) + { + // Replace four-byte characters (11110www 10zzzzzz 10yyyyyy 10xxxxxx) + $ord = ord($str[$i]); + if ($ord >= 240 && $ord <= 244) + { + $result .= '?'; + $i += 3; + } + else + { + $result .= $str[$i]; + } + } + + return $result; +} + +// +// Check whether a file/folder is writable. +// +// This function also works on Windows Server where ACLs seem to be ignored. +// +function forum_is_writable($path) +{ + if (is_dir($path)) + { + $path = rtrim($path, '/').'/'; + return forum_is_writable($path.uniqid(mt_rand()).'.tmp'); + } + + // Check temporary file for read/write capabilities + $rm = file_exists($path); + $f = @fopen($path, 'a'); + + if ($f === false) + return false; + + fclose($f); + + if (!$rm) + @unlink($path); + + return true; +} + + // DEBUG FUNCTIONS BELOW // diff --git a/include/parser.php b/include/parser.php index 0aba148..5bb208a 100644 --- a/include/parser.php +++ b/include/parser.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -76,10 +76,10 @@ function preparse_bbcode($text, &$errors, $is_signature = false) // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched) if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) - list($inside, $text) = extract_blocks($text, '[code]', '[/code]', $errors); + list($inside, $text) = extract_blocks($text, '[code]', '[/code]'); // Tidy up lists - $temp = preg_replace($re_list, 'preparse_list_tag(\'$2\', \'$1\', $errors)', $text); + $temp = preg_replace($re_list, 'preparse_list_tag(\'$2\', \'$1\')', $text); // If the regex failed if ($temp === null) @@ -115,7 +115,7 @@ function preparse_bbcode($text, &$errors, $is_signature = false) $text = $temp_text; // Remove empty tags - while (($new_text = strip_empty_bbcode($text, $errors)) !== false) + while (($new_text = strip_empty_bbcode($text)) !== false) { if ($new_text != $text) { @@ -137,11 +137,11 @@ function preparse_bbcode($text, &$errors, $is_signature = false) // // Strip empty bbcode tags from some text // -function strip_empty_bbcode($text, &$errors) +function strip_empty_bbcode($text) { // If the message contains a code tag we have to split it up (empty tags within [code][/code] are fine) if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) - list($inside, $text) = extract_blocks($text, '[code]', '[/code]', $errors); + list($inside, $text) = extract_blocks($text, '[code]', '[/code]'); // Remove empty tags while (($new_text = preg_replace('%\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)) !== NULL) @@ -153,16 +153,17 @@ function strip_empty_bbcode($text, &$errors) } // If we split up the message before we have to concatenate it together again (code tags) - if (isset($inside)) { - $parts = explode("\1", $text); - $text = ''; - foreach ($parts as $i => $part) - { - $text .= $part; - if (isset($inside[$i])) - $text .= '[code]'.$inside[$i].'[/code]'; - } - } + if (isset($inside)) + { + $parts = explode("\1", $text); + $text = ''; + foreach ($parts as $i => $part) + { + $text .= $part; + if (isset($inside[$i])) + $text .= '[code]'.$inside[$i].'[/code]'; + } + } // Remove empty code tags while (($new_text = preg_replace('%\[(code)\]\s*\[/\1\]%', '', $text)) !== NULL) @@ -352,18 +353,13 @@ function preparse_tags($text, &$errors, $is_signature = false) $current = strtolower($current); // This is if we are currently in a tag which escapes other bbcode such as code - // We keep a cound of ignored bbcodes (code tags) so we can nest them, but + // We keep a count of ignored bbcodes (code tags) so we can nest them, but // only balanced sets of tags can be nested if ($current_ignore) { // Increase the current ignored tags counter if ('['.$current_ignore.']' == $current) - { - if (!isset($count_ignored[$current_tag])) - $count_ignored[$current_tag] = 2; - else - $count_ignored[$current_tag]++; - } + $count_ignored[$current_tag]++; // Decrease the current ignored tags counter if ('[/'.$current_ignore.']' == $current) @@ -531,6 +527,7 @@ function preparse_tags($text, &$errors, $is_signature = false) { // It's an ignore tag so we don't need to worry about what's inside it $current_ignore = $current_tag; + $count_ignored[$current_tag] = 1; $new_text .= $current; continue; } @@ -601,7 +598,7 @@ function preparse_tags($text, &$errors, $is_signature = false) // // Preparse the contents of [list] bbcode // -function preparse_list_tag($content, $type = '*', &$errors) +function preparse_list_tag($content, $type = '*') { global $lang_common, $re_list; @@ -610,7 +607,7 @@ function preparse_list_tag($content, $type = '*', &$errors) if (strpos($content,'[list') !== false) { - $content = preg_replace($re_list, 'preparse_list_tag(\'$2\', \'$1\', $errors)', $content); + $content = preg_replace($re_list, 'preparse_list_tag(\'$2\', \'$1\')', $content); } $items = explode('[*]', str_replace('\"', '"', $content)); @@ -632,6 +629,11 @@ function preparse_list_tag($content, $type = '*', &$errors) function handle_url_tag($url, $link = '', $bbcode = false) { $url = pun_trim($url); + + // Deal with [url][img]http://example.com/test.png[/img][/url] + if (preg_match('%<img src=\\\\"(.*?)\\\\"%', $url, $matches)) + return handle_url_tag($matches[1], $url, $bbcode); + $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url); if (strpos($url, 'www.') === 0) // If it starts with www, we add http:// $full_url = 'http://'.$full_url; @@ -776,14 +778,14 @@ function do_bbcode($text, $is_signature = false) $pattern[] = '%\[url=([^\[]+?)\](.*?)\[/url\]%e'; $pattern[] = '%\[email\]([^\[]*?)\[/email\]%'; $pattern[] = '%\[email=([^\[]+?)\](.*?)\[/email\]%'; - $pattern[] = '%\[topic\]([^\[]*?)\[/topic\]%e'; - $pattern[] = '%\[topic=([^\[]+?)\](.*?)\[/topic\]%e'; - $pattern[] = '%\[post\]([^\[]*?)\[/post\]%e'; - $pattern[] = '%\[post=([^\[]+?)\](.*?)\[/post\]%e'; - $pattern[] = '%\[forum\]([^\[]*?)\[/forum\]%e'; - $pattern[] = '%\[forum=([^\[]+?)\](.*?)\[/forum\]%e'; - $pattern[] = '%\[user\]([^\[]*?)\[/user\]%e'; - $pattern[] = '%\[user=([^\[]+?)\](.*?)\[/user\]%e'; + $pattern[] = '%\[topic\]([1-9]\d*)\[/topic\]%e'; + $pattern[] = '%\[topic=([1-9]\d*)\](.*?)\[/topic\]%e'; + $pattern[] = '%\[post\]([1-9]\d*)\[/post\]%e'; + $pattern[] = '%\[post=([1-9]\d*)\](.*?)\[/post\]%e'; + $pattern[] = '%\[forum\]([1-9]\d*)\[/forum\]%e'; + $pattern[] = '%\[forum=([1-9]\d*)\](.*?)\[/forum\]%e'; + $pattern[] = '%\[user\]([1-9]\d*)\[/user\]%e'; + $pattern[] = '%\[user=([1-9]\d*)\](.*?)\[/user\]%e'; $replace[] = 'handle_url_tag(\'$1\')'; $replace[] = 'handle_url_tag(\'$1\', \'$2\')'; @@ -812,8 +814,8 @@ function do_clickable($text) { $text = ' '.$text; - $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(https?|ftp|news){1}://([\p{L}\p{N}\-]+\.([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5://$6\', \'$5://$6\', true).stripslashes(\'$4$10$11$12\')', $text); - $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(www|ftp)\.(([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/[^\s\[]*[^\s.,?!\[;:-])?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5.$6\', \'$5.$6\', true).stripslashes(\'$4$10$11$12\')', $text); + $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(https?|ftp|news){1}://([\p{L}\p{N}\-]+\.([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/(?:[^\s\[]*[^\s.,?!\[;:-])?)?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5://$6\', \'$5://$6\', true).stripslashes(\'$4$10$11$12\')', $text); + $text = ucp_preg_replace('%(?<=[\s\]\)])(<)?(\[)?(\()?([\'"]?)(www|ftp)\.(([\p{L}\p{N}\-]+\.)*[\p{L}\p{N}]+(:[0-9]+)?(/(?:[^\s\[]*[^\s.,?!\[;:-])?)?)\4(?(3)(\)))(?(2)(\]))(?(1)(>))(?![^\s]*\[/(?:url|img)\])%uie', 'stripslashes(\'$1$2$3$4\').handle_url_tag(\'$5.$6\', \'$5.$6\', true).stripslashes(\'$4$10$11$12\')', $text); return substr($text, 1); } @@ -853,7 +855,7 @@ function parse_message($text, $hide_smilies) // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched) if (strpos($text, '[code]') !== false && strpos($text, '[/code]') !== false) - list($inside, $text) = extract_blocks($text, '[code]', '[/code]', $errors); + list($inside, $text) = extract_blocks($text, '[code]', '[/code]'); if ($pun_config['p_message_bbcode'] == '1' && strpos($text, '[') !== false && strpos($text, ']') !== false) $text = do_bbcode($text); @@ -867,24 +869,46 @@ function parse_message($text, $hide_smilies) $text = str_replace($pattern, $replace, $text); // If we split up the message before we have to concatenate it together again (code tags) - if (isset($inside)) { - $parts = explode("\1", $text); - $text = ''; - foreach ($parts as $i => $part) - { - $text .= $part; - if (isset($inside[$i])) - { - $num_lines = (substr_count($inside[$i], "\n")); - $text .= '</p><div class="codebox"><pre'.(($num_lines > 28) ? ' class="vscroll"' : '').'><code>'.pun_trim($inside[$i], "\n\r").'</code></pre></div><p>'; - } - } - } + if (isset($inside)) + { + $parts = explode("\1", $text); + $text = ''; + foreach ($parts as $i => $part) + { + $text .= $part; + if (isset($inside[$i])) + { + $num_lines = (substr_count($inside[$i], "\n")); + $text .= '</p><div class="codebox"><pre'.(($num_lines > 28) ? ' class="vscroll"' : '').'><code>'.pun_trim($inside[$i], "\n\r").'</code></pre></div><p>'; + } + } + } + return clean_paragraphs($text); +} + + +// +// Clean up paragraphs and line breaks +// +function clean_paragraphs($text) +{ // Add paragraph tag around post, but make sure there are no empty paragraphs - $text = preg_replace('%<br />\s*?<br />((\s*<br />)*)%i', "</p>$1<p>", $text); - $text = str_replace('<p><br />', '<p>', $text); - $text = str_replace('<p></p>', '', '<p>'.$text.'</p>'); + + $text = '<p>'.$text.'</p>'; + + // Replace any breaks next to paragraphs so our replace below catches them + $text = preg_replace('%(</?p>)(?:\s*?<br />){1,2}%i', '$1', $text); + $text = preg_replace('%(?:<br />\s*?){1,2}(</?p>)%i', '$1', $text); + + // Remove any empty paragraph tags (inserted via quotes/lists/code/etc) which should be stripped + $text = str_replace('<p></p>', '', $text); + + $text = preg_replace('%<br />\s*?<br />%i', '</p><p>', $text); + + $text = str_replace('<p><br />', '<br /><p>', $text); + $text = str_replace('<br /></p>', '</p><br />', $text); + $text = str_replace('<p></p>', '<br /><br />', $text); return $text; } @@ -915,10 +939,5 @@ function parse_signature($text) $replace = array('<br />', '    ', '  ', '  '); $text = str_replace($pattern, $replace, $text); - // Add paragraph tag around post, but make sure there are no empty paragraphs - $text = preg_replace('%<br />\s*?<br />((\s*<br />)*)%i', "</p>$1<p>", $text); - $text = str_replace('<p><br />', '<p>', $text); - $text = str_replace('<p></p>', '', '<p>'.$text.'</p>'); - - return $text; + return clean_paragraphs($text); } diff --git a/include/search_idx.php b/include/search_idx.php index 210b268..0a886f4 100644 --- a/include/search_idx.php +++ b/include/search_idx.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -47,9 +47,6 @@ define('PUN_CJK_HANGUL_REGEX', '['. // function split_words($text, $idx) { - // Remove BBCode - $text = preg_replace('%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list)(?:\=[^\]]*)?\]%', ' ', $text); - // Remove any apostrophes or dashes which aren't part of words $text = substr(ucp_preg_replace('%((?<=[^\p{L}\p{N}])[\'\-]|[\'\-](?=[^\p{L}\p{N}]))%u', '', ' '.$text.' '), 1, -1); @@ -108,6 +105,9 @@ function validate_search_word($word, $idx) if (is_cjk($word)) return !$idx; + // Exclude % and * when checking whether current word is valid + $word = str_replace(array('%', '*'), '', $word); + // Check the word is within the min/max length $num_chars = pun_strlen($word); return $num_chars >= PUN_SEARCH_MIN_WORD && $num_chars <= PUN_SEARCH_MAX_WORD; @@ -144,7 +144,8 @@ function strip_bbcode($text) $patterns = array( '%\[img=([^\]]*+)\]([^[]*+)\[/img\]%' => '$2 $1', // Keep the url and description '%\[(url|email)=([^\]]*+)\]([^[]*+(?:(?!\[/\1\])\[[^[]*+)*)\[/\1\]%' => '$2 $3', // Keep the url and text - '%\[(img|url|email)\]([^[]*+(?:(?!\[/\1\])\[[^[]*+)*)\[/\1\]%' => '$2', // Keep the url + '%\[(topic|post|forum|user)\][1-9]\d*\[/\1\]%' => ' ', // Do not index topic/post/forum/user ID + '%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]%' => ' ' // Remove BBCode ); } diff --git a/include/utf8/utf8.php b/include/utf8/utf8.php index 281f18c..661b2d7 100644 --- a/include/utf8/utf8.php +++ b/include/utf8/utf8.php @@ -34,7 +34,7 @@ if (!defined('UTF8')) if (extension_loaded('mbstring') && !defined('UTF8_USE_MBSTRING') && !defined('UTF8_USE_NATIVE')) define('UTF8_USE_MBSTRING', true); -else +else if (!defined('UTF8_USE_NATIVE')) define('UTF8_USE_NATIVE', true); // utf8_strpos() and utf8_strrpos() need utf8_bad_strip() to strip invalid diff --git a/include/utf8/utils/bad.php b/include/utf8/utils/bad.php index 78e9d17..2704294 100644 --- a/include/utf8/utils/bad.php +++ b/include/utf8/utils/bad.php @@ -114,33 +114,9 @@ function utf8_bad_findall($str) * @package utf8 * @subpackage bad */ -function utf8_bad_strip($str) +function utf8_bad_strip($original) { - $UTF8_BAD = - '([\x00-\x7F]'. # ASCII (including control chars) - '|[\xC2-\xDF][\x80-\xBF]'. # Non-overlong 2-byte - '|\xE0[\xA0-\xBF][\x80-\xBF]'. # Excluding overlongs - '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # Straight 3-byte - '|\xED[\x80-\x9F][\x80-\xBF]'. # Excluding surrogates - '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # Planes 1-3 - '|[\xF1-\xF3][\x80-\xBF]{3}'. # Planes 4-15 - '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # Plane 16 - '|(.{1}))'; # Invalid byte - - ob_start(); - - while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) - { - if (!isset($matches[2])) - echo $matches[0]; - - $str = substr($str, strlen($matches[0])); - } - - $result = ob_get_contents(); - ob_end_clean(); - - return $result; + return utf8_bad_replace($original, ''); } /** @@ -156,33 +132,52 @@ function utf8_bad_strip($str) * @package utf8 * @subpackage bad */ -function utf8_bad_replace($str, $replace='?') -{ - $UTF8_BAD = - '([\x00-\x7F]'. # ASCII (including control chars) - '|[\xC2-\xDF][\x80-\xBF]'. # Non-overlong 2-byte - '|\xE0[\xA0-\xBF][\x80-\xBF]'. # Excluding overlongs - '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'. # Straight 3-byte - '|\xED[\x80-\x9F][\x80-\xBF]'. # Excluding surrogates - '|\xF0[\x90-\xBF][\x80-\xBF]{2}'. # Planes 1-3 - '|[\xF1-\xF3][\x80-\xBF]{3}'. # Planes 4-15 - '|\xF4[\x80-\x8F][\x80-\xBF]{2}'. # Plane 16 - '|(.{1}))'; # Invalid byte +function utf8_bad_replace($original, $replace = '?') { + $result = ''; + + $strlen = strlen($original); + for ($i = 0; $i < $strlen;) { + $char = $original[$i++]; + $byte = ord($char); + + if ($byte < 0x80) $bytes = 0; // 1-bytes (00000000 - 01111111) + else if ($byte < 0xC0) { // 1-bytes (10000000 - 10111111) + $result .= $replace; + continue; + } + else if ($byte < 0xE0) $bytes = 1; // 2-bytes (11000000 - 11011111) + else if ($byte < 0xF0) $bytes = 2; // 3-bytes (11100000 - 11101111) + else if ($byte < 0xF8) $bytes = 3; // 4-bytes (11110000 - 11110111) + else if ($byte < 0xFC) $bytes = 4; // 5-bytes (11111000 - 11111011) + else if ($byte < 0xFE) $bytes = 5; // 6-bytes (11111100 - 11111101) + else { // Otherwise it's something invalid + $result .= $replace; + continue; + } - ob_start(); + // Check our input actually has enough data + if ($i + $bytes > $strlen) { + $result .= $replace; + continue; + } - while (preg_match('/'.$UTF8_BAD.'/S', $str, $matches)) - { - if (!isset($matches[2])) - echo $matches[0]; - else - echo $replace; + // If we've got this far then we have a multiple-byte character + for ($j = 0; $j < $bytes; $j++) { + $byte = $original[$i + $j]; - $str = substr($str, strlen($matches[0])); - } + $char .= $byte; + $byte = ord($byte); - $result = ob_get_contents(); - ob_end_clean(); + // Every following byte must be 10000000 - 10111111 + if ($byte < 0x80 || $byte > 0xBF) { + $result .= $replace; + continue 2; + } + } + + $i += $bytes; + $result .= $char; + } return $result; } diff --git a/index.php b/index.php index e80e73b..4cfbe71 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/lang/English/admin_options.php b/lang/English/admin_options.php index 00923ce..0274bdf 100644 --- a/lang/English/admin_options.php +++ b/lang/English/admin_options.php @@ -51,27 +51,27 @@ $lang_admin_options = array( 'UTC' => '(UTC) Western European, Greenwich', 'UTC+01:00' => '(UTC+01:00) Central European, West African', 'UTC+02:00' => '(UTC+02:00) Eastern European, Central African', -'UTC+03:00' => '(UTC+03:00) Moscow, Eastern African', +'UTC+03:00' => '(UTC+03:00) Eastern African', 'UTC+03:30' => '(UTC+03:30) Iran', -'UTC+04:00' => '(UTC+04:00) Gulf, Samara', +'UTC+04:00' => '(UTC+04:00) Moscow, Gulf, Samara', 'UTC+04:30' => '(UTC+04:30) Afghanistan', -'UTC+05:00' => '(UTC+05:00) Pakistan, Yekaterinburg', +'UTC+05:00' => '(UTC+05:00) Pakistan', 'UTC+05:30' => '(UTC+05:30) India, Sri Lanka', 'UTC+05:45' => '(UTC+05:45) Nepal', -'UTC+06:00' => '(UTC+06:00) Bangladesh, Bhutan, Novosibirsk', +'UTC+06:00' => '(UTC+06:00) Bangladesh, Bhutan, Yekaterinburg', 'UTC+06:30' => '(UTC+06:30) Cocos Islands, Myanmar', -'UTC+07:00' => '(UTC+07:00) Indochina, Krasnoyarsk', -'UTC+08:00' => '(UTC+08:00) Greater China, Australian Western, Irkutsk', +'UTC+07:00' => '(UTC+07:00) Indochina, Novosibirsk', +'UTC+08:00' => '(UTC+08:00) Greater China, Australian Western, Krasnoyarsk', 'UTC+08:45' => '(UTC+08:45) Southeastern Western Australia', -'UTC+09:00' => '(UTC+09:00) Japan, Korea, Chita', +'UTC+09:00' => '(UTC+09:00) Japan, Korea, Chita, Irkutsk', 'UTC+09:30' => '(UTC+09:30) Australian Central', -'UTC+10:00' => '(UTC+10:00) Australian Eastern, Vladivostok', +'UTC+10:00' => '(UTC+10:00) Australian Eastern', 'UTC+10:30' => '(UTC+10:30) Lord Howe', -'UTC+11:00' => '(UTC+11:00) Solomon Island, Magadan', +'UTC+11:00' => '(UTC+11:00) Solomon Island, Vladivostok', 'UTC+11:30' => '(UTC+11:30) Norfolk Island', -'UTC+12:00' => '(UTC+12:00) New Zealand, Fiji, Kamchatka', +'UTC+12:00' => '(UTC+12:00) New Zealand, Fiji, Magadan', 'UTC+12:45' => '(UTC+12:45) Chatham Islands', -'UTC+13:00' => '(UTC+13:00) Tonga, Phoenix Islands', +'UTC+13:00' => '(UTC+13:00) Tonga, Phoenix Islands, Kamchatka', 'UTC+14:00' => '(UTC+14:00) Line Islands', // Timeout Section diff --git a/lang/English/mail_templates/new_reply_full.tpl b/lang/English/mail_templates/new_reply_full.tpl index 73363ea..4fbc777 100644 --- a/lang/English/mail_templates/new_reply_full.tpl +++ b/lang/English/mail_templates/new_reply_full.tpl @@ -2,6 +2,8 @@ Subject: Reply to topic: '<topic_subject>' <replier> has replied to the topic '<topic_subject>' to which you are subscribed. There may be more new replies, but this is the only notification you will receive until you visit the board again. +The post is located at <post_url> + The message reads as follows: ----------------------------------------------------------------------- @@ -9,8 +11,6 @@ The message reads as follows: ----------------------------------------------------------------------- -The post is located at <post_url> - You can unsubscribe by going to <unsubscribe_url> -- diff --git a/lang/English/mail_templates/new_topic_full.tpl b/lang/English/mail_templates/new_topic_full.tpl index 2ea6b0f..f70c726 100644 --- a/lang/English/mail_templates/new_topic_full.tpl +++ b/lang/English/mail_templates/new_topic_full.tpl @@ -2,6 +2,8 @@ Subject: New topic in forum: '<forum_name>' <poster> has posted a new topic '<topic_subject>' in the forum '<forum_name>', to which you are subscribed. +The topic is located at <topic_url> + The message reads as follows: ----------------------------------------------------------------------- @@ -9,8 +11,6 @@ The message reads as follows: ----------------------------------------------------------------------- -The topic is located at <topic_url> - You can unsubscribe by going to <unsubscribe_url> -- diff --git a/lang/English/post.php b/lang/English/post.php index 2b3c678..b89804b 100644 --- a/lang/English/post.php +++ b/lang/English/post.php @@ -9,7 +9,7 @@ $lang_post = array( 'Too long subject' => 'Subjects cannot be longer than 70 characters.', 'No message' => 'You must enter a message.', 'No message after censoring' => 'You must enter a message. After applying censoring filters, your message was empty.', -'Too long message' => 'Posts cannot be longer that %s bytes.', +'Too long message' => 'Posts cannot be longer than %s bytes.', 'All caps subject' => 'Subjects cannot contain only capital letters.', 'All caps message' => 'Posts cannot contain only capital letters.', 'Empty after strip' => 'It seems your post consisted of empty BBCodes only. It is possible that this happened because e.g. the innermost quote was discarded because of the maximum quote depth level.', diff --git a/lang/English/prof_reg.php b/lang/English/prof_reg.php index 1cbbec6..7a0a6f6 100644 --- a/lang/English/prof_reg.php +++ b/lang/English/prof_reg.php @@ -53,27 +53,27 @@ $lang_prof_reg = array( 'UTC' => '(UTC) Western European, Greenwich', 'UTC+01:00' => '(UTC+01:00) Central European, West African', 'UTC+02:00' => '(UTC+02:00) Eastern European, Central African', -'UTC+03:00' => '(UTC+03:00) Moscow, Eastern African', +'UTC+03:00' => '(UTC+03:00) Eastern African', 'UTC+03:30' => '(UTC+03:30) Iran', -'UTC+04:00' => '(UTC+04:00) Gulf, Samara', +'UTC+04:00' => '(UTC+04:00) Moscow, Gulf, Samara', 'UTC+04:30' => '(UTC+04:30) Afghanistan', -'UTC+05:00' => '(UTC+05:00) Pakistan, Yekaterinburg', +'UTC+05:00' => '(UTC+05:00) Pakistan', 'UTC+05:30' => '(UTC+05:30) India, Sri Lanka', 'UTC+05:45' => '(UTC+05:45) Nepal', -'UTC+06:00' => '(UTC+06:00) Bangladesh, Bhutan, Novosibirsk', +'UTC+06:00' => '(UTC+06:00) Bangladesh, Bhutan, Yekaterinburg', 'UTC+06:30' => '(UTC+06:30) Cocos Islands, Myanmar', -'UTC+07:00' => '(UTC+07:00) Indochina, Krasnoyarsk', -'UTC+08:00' => '(UTC+08:00) Greater China, Australian Western, Irkutsk', +'UTC+07:00' => '(UTC+07:00) Indochina, Novosibirsk', +'UTC+08:00' => '(UTC+08:00) Greater China, Australian Western, Krasnoyarsk', 'UTC+08:45' => '(UTC+08:45) Southeastern Western Australia', -'UTC+09:00' => '(UTC+09:00) Japan, Korea, Chita', +'UTC+09:00' => '(UTC+09:00) Japan, Korea, Chita, Irkutsk', 'UTC+09:30' => '(UTC+09:30) Australian Central', -'UTC+10:00' => '(UTC+10:00) Australian Eastern, Vladivostok', +'UTC+10:00' => '(UTC+10:00) Australian Eastern', 'UTC+10:30' => '(UTC+10:30) Lord Howe', -'UTC+11:00' => '(UTC+11:00) Solomon Island, Magadan', +'UTC+11:00' => '(UTC+11:00) Solomon Island, Vladivostok', 'UTC+11:30' => '(UTC+11:30) Norfolk Island', -'UTC+12:00' => '(UTC+12:00) New Zealand, Fiji, Kamchatka', +'UTC+12:00' => '(UTC+12:00) New Zealand, Fiji, Magadan', 'UTC+12:45' => '(UTC+12:45) Chatham Islands', -'UTC+13:00' => '(UTC+13:00) Tonga, Phoenix Islands', +'UTC+13:00' => '(UTC+13:00) Tonga, Phoenix Islands, Kamchatka', 'UTC+14:00' => '(UTC+14:00) Line Islands' ); diff --git a/login.php b/login.php index 97c66b1..35f8673 100644 --- a/login.php +++ b/login.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/misc.php b/misc.php index 6f7755b..06a661b 100644 --- a/misc.php +++ b/misc.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/moderate.php b/moderate.php index 7f27d66..b4dad37 100644 --- a/moderate.php +++ b/moderate.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/post.php b/post.php index 9d09f10..e0b7192 100644 --- a/post.php +++ b/post.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -152,6 +152,9 @@ if (isset($_POST['form_sent'])) $hide_smilies = isset($_POST['hide_smilies']) ? '1' : '0'; $subscribe = isset($_POST['subscribe']) ? '1' : '0'; $stick_topic = isset($_POST['stick_topic']) && $is_admmod ? '1' : '0'; + + // Replace four-byte characters (MySQL cannot handle them) + $message = strip_bad_multibyte_chars($message); $now = time(); @@ -451,10 +454,7 @@ if ($tid) // If the message contains a code tag we have to split it up (text within [code][/code] shouldn't be touched) if (strpos($q_message, '[code]') !== false && strpos($q_message, '[/code]') !== false) { - $errors = array(); - list($inside, $outside) = split_text($q_message, '[code]', '[/code]', $errors); - if (!empty($errors)) // Technically this shouldn't happen, since $q_message is an existing post it should only exist if it previously passed validation - message($errors[0]); + list($inside, $outside) = split_text($q_message, '[code]', '[/code]'); $q_message = implode("\1", $outside); } diff --git a/profile.php b/profile.php index b735305..3bf2385 100644 --- a/profile.php +++ b/profile.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/register.php b/register.php index 0ef9832..8e7bceb 100644 --- a/register.php +++ b/register.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/search.php b/search.php index 12e1bbc..5174c61 100644 --- a/search.php +++ b/search.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ @@ -28,7 +28,7 @@ require PUN_ROOT.'include/search_idx.php'; if (isset($_GET['action']) || isset($_GET['search_id'])) { $action = (isset($_GET['action'])) ? $_GET['action'] : null; - $forums = isset($_GET['forums']) ? (is_array($_GET['forums']) ? $_GET['forums'] : explode(',', $_GET['forums'])) : (isset($_GET['forum']) ? array($_GET['forum']) : array()); + $forums = isset($_GET['forums']) ? (is_array($_GET['forums']) ? $_GET['forums'] : array_filter(explode(',', $_GET['forums']))) : (isset($_GET['forum']) ? array($_GET['forum']) : array()); $sort_dir = (isset($_GET['sort_dir']) && $_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC'; $forums = array_map('intval', $forums); diff --git a/style/imports/minmax.js b/style/imports/minmax.js index 65fddca..c8cb073 100644 --- a/style/imports/minmax.js +++ b/style/imports/minmax.js @@ -25,6 +25,16 @@ function minmax_bind(el) { minmax_elements[minmax_elements.length]= el; minmax_delayout(); } + + if (cs['min-width']) + st['minWidth']= cs['min-width']; + + ms= cs['minWidth']; + if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') { + st.minmaxWidth= cs.width; + minmax_elements[minmax_elements.length]= el; + minmax_delayout(); + } } var minmax_delaying= false; @@ -81,4 +91,4 @@ minmax_scan(); minmax_scanner= window.setInterval(minmax_scan, minmax_SCANDELAY); window.attachEvent('onload', minmax_stop); -@end @*/ +@end @*/ \ No newline at end of file diff --git a/userlist.php b/userlist.php index 73d448d..4b2473b 100644 --- a/userlist.php +++ b/userlist.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/viewforum.php b/viewforum.php index 32c3201..d9fe7a1 100644 --- a/viewforum.php +++ b/viewforum.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ diff --git a/viewtopic.php b/viewtopic.php index 68ad091..7d1eab6 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -1,7 +1,7 @@ <?php /** - * Copyright (C) 2008-2011 FluxBB + * Copyright (C) 2008-2012 FluxBB * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits