aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_forums.php2
-rw-r--r--phpBB/includes/db/mysqli.php8
-rw-r--r--phpBB/includes/functions.php5
-rw-r--r--phpBB/includes/functions_display.php2
-rw-r--r--phpBB/includes/functions_privmsgs.php111
-rw-r--r--phpBB/includes/template/filter.php24
-rw-r--r--phpBB/includes/template/template.php27
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php2
8 files changed, 119 insertions, 62 deletions
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 4d605e1b82..854f262a0b 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -875,7 +875,7 @@ class acp_forums
$errors = array();
- if (!$forum_data['forum_name'])
+ if ($forum_data['forum_name'] == '')
{
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
}
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index db3846e7f7..d2781e96dd 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -249,7 +249,13 @@ class dbal_mysqli extends dbal
return $cache->sql_fetchrow($query_id);
}
- return ($query_id !== false) ? @mysqli_fetch_assoc($query_id) : false;
+ if ($query_id !== false)
+ {
+ $result = @mysqli_fetch_assoc($query_id);
+ return $result !== null ? $result : false;
+ }
+
+ return false;
}
/**
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 5ccb9edd07..8f41e18db6 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1901,7 +1901,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
$end_cnt = max(min($total_pages, $on_page + 4), 6);
- $page_string .= ($start_cnt > 1) ? ' ... ' : $separator;
+ $page_string .= ($start_cnt > 1) ? '<span class="page-dots"> ... </span>' : $separator;
for ($i = $start_cnt + 1; $i < $end_cnt; $i++)
{
@@ -1912,7 +1912,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
}
}
- $page_string .= ($end_cnt < $total_pages) ? ' ... ' : $separator;
+ $page_string .= ($end_cnt < $total_pages) ? '<span class="page-dots"> ... </span>' : $separator;
}
else
{
@@ -1951,6 +1951,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
$tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . "{$url_delim}start=" . (($on_page - 2) * $per_page),
$tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . "{$url_delim}start=" . ($on_page * $per_page),
$tpl_prefix . 'TOTAL_PAGES' => $total_pages,
+ $tpl_prefix . 'CURRENT_PAGE' => $on_page,
));
return $page_string;
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 08442f0913..4e8d8f7d34 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -655,7 +655,7 @@ function topic_generate_pagination($replies, $url)
$pagination .= '<a href="' . $url . ($j == 0 ? '' : '&amp;start=' . $j) . '">' . $times . '</a>';
if ($times == 1 && $total_pages > 5)
{
- $pagination .= ' ... ';
+ $pagination .= '<span class="page-dots"> ... </span>';
// Display the last three pages
$times = $total_pages - 3;
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 9787bdfbc4..32b57a9f2e 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -19,7 +19,8 @@ if (!defined('IN_PHPBB'))
Ability to simply add own rules by doing three things:
1) Add an appropriate constant
2) Add a new check array to the global_privmsgs_rules variable and the condition array (if one is required)
- 3) Add a new language variable to ucp.php
+ 3) Implement the rule logic in the check_rule() function
+ 4) Add a new language variable to ucp.php
The user is then able to select the new rule. It will be checked against and handled as specified.
To add new actions (yes, checks can be added here too) to the rule management, the core code has to be modified.
@@ -57,42 +58,42 @@ define('CHECK_TO', 5);
*/
$global_privmsgs_rules = array(
CHECK_SUBJECT => array(
- RULE_IS_LIKE => array('check0' => 'message_subject', 'function' => 'preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0})'),
- RULE_IS_NOT_LIKE => array('check0' => 'message_subject', 'function' => '!(preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0}))'),
- RULE_IS => array('check0' => 'message_subject', 'function' => '{CHECK0} == {STRING}'),
- RULE_IS_NOT => array('check0' => 'message_subject', 'function' => '{CHECK0} != {STRING}'),
- RULE_BEGINS_WITH => array('check0' => 'message_subject', 'function' => 'preg_match("/^" . preg_quote({STRING}, "/") . "/i", {CHECK0})'),
- RULE_ENDS_WITH => array('check0' => 'message_subject', 'function' => 'preg_match("/" . preg_quote({STRING}, "/") . "$/i", {CHECK0})'),
+ RULE_IS_LIKE => array('check0' => 'message_subject'),
+ RULE_IS_NOT_LIKE => array('check0' => 'message_subject'),
+ RULE_IS => array('check0' => 'message_subject'),
+ RULE_IS_NOT => array('check0' => 'message_subject'),
+ RULE_BEGINS_WITH => array('check0' => 'message_subject'),
+ RULE_ENDS_WITH => array('check0' => 'message_subject'),
),
CHECK_SENDER => array(
- RULE_IS_LIKE => array('check0' => 'username', 'function' => 'preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0})'),
- RULE_IS_NOT_LIKE => array('check0' => 'username', 'function' => '!(preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0}))'),
- RULE_IS => array('check0' => 'username', 'function' => '{CHECK0} == {STRING}'),
- RULE_IS_NOT => array('check0' => 'username', 'function' => '{CHECK0} != {STRING}'),
- RULE_BEGINS_WITH => array('check0' => 'username', 'function' => 'preg_match("/^" . preg_quote({STRING}, "/") . "/i", {CHECK0})'),
- RULE_ENDS_WITH => array('check0' => 'username', 'function' => 'preg_match("/" . preg_quote({STRING}, "/") . "$/i", {CHECK0})'),
- RULE_IS_FRIEND => array('check0' => 'friend', 'function' => '{CHECK0} == 1'),
- RULE_IS_FOE => array('check0' => 'foe', 'function' => '{CHECK0} == 1'),
- RULE_IS_USER => array('check0' => 'author_id', 'function' => '{CHECK0} == {USER_ID}'),
- RULE_IS_GROUP => array('check0' => 'author_in_group', 'function' => 'in_array({GROUP_ID}, {CHECK0})'),
+ RULE_IS_LIKE => array('check0' => 'username'),
+ RULE_IS_NOT_LIKE => array('check0' => 'username'),
+ RULE_IS => array('check0' => 'username'),
+ RULE_IS_NOT => array('check0' => 'username'),
+ RULE_BEGINS_WITH => array('check0' => 'username'),
+ RULE_ENDS_WITH => array('check0' => 'username'),
+ RULE_IS_FRIEND => array('check0' => 'friend'),
+ RULE_IS_FOE => array('check0' => 'foe'),
+ RULE_IS_USER => array('check0' => 'author_id'),
+ RULE_IS_GROUP => array('check0' => 'author_in_group'),
),
CHECK_MESSAGE => array(
- RULE_IS_LIKE => array('check0' => 'message_text', 'function' => 'preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0})'),
- RULE_IS_NOT_LIKE => array('check0' => 'message_text', 'function' => '!(preg_match("/" . preg_quote({STRING}, "/") . "/i", {CHECK0}))'),
- RULE_IS => array('check0' => 'message_text', 'function' => '{CHECK0} == {STRING}'),
- RULE_IS_NOT => array('check0' => 'message_text', 'function' => '{CHECK0} != {STRING}'),
+ RULE_IS_LIKE => array('check0' => 'message_text'),
+ RULE_IS_NOT_LIKE => array('check0' => 'message_text'),
+ RULE_IS => array('check0' => 'message_text'),
+ RULE_IS_NOT => array('check0' => 'message_text'),
),
CHECK_STATUS => array(
- RULE_ANSWERED => array('check0' => 'pm_replied', 'function' => '{CHECK0} == 1'),
- RULE_FORWARDED => array('check0' => 'pm_forwarded', 'function' => '{CHECK0} == 1'),
+ RULE_ANSWERED => array('check0' => 'pm_replied'),
+ RULE_FORWARDED => array('check0' => 'pm_forwarded'),
),
CHECK_TO => array(
- RULE_TO_GROUP => array('check0' => 'to', 'check1' => 'bcc', 'check2' => 'user_in_group', 'function' => 'in_array("g_" . {CHECK2}, {CHECK0}) || in_array("g_" . {CHECK2}, {CHECK1})'),
- RULE_TO_ME => array('check0' => 'to', 'check1' => 'bcc', 'function' => 'in_array("u_" . $user_id, {CHECK0}) || in_array("u_" . $user_id, {CHECK1})'),
+ RULE_TO_GROUP => array('check0' => 'to', 'check1' => 'bcc', 'check2' => 'user_in_group'),
+ RULE_TO_ME => array('check0' => 'to', 'check1' => 'bcc'),
)
);
@@ -260,16 +261,60 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
$check_ary = $rules[$rule_row['rule_check']][$rule_row['rule_connection']];
- // Replace Check Literals
- $evaluate = $check_ary['function'];
- $evaluate = preg_replace('/{(CHECK[0-9])}/', '$message_row[$check_ary[strtolower("\1")]]', $evaluate);
+ $result = false;
- // Replace Rule Literals
- $evaluate = preg_replace('/{(STRING|USER_ID|GROUP_ID)}/', '$rule_row["rule_" . strtolower("\1")]', $evaluate);
+ $check0 = $message_row[$check_ary['check0']];
+
+ switch ($rule_row['rule_connection'])
+ {
+ case RULE_IS_LIKE:
+ $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
+ break;
+
+ case RULE_IS_NOT_LIKE:
+ $result = !preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
+ break;
+
+ case RULE_IS:
+ $result = ($check0 == $rule_row['rule_string']);
+ break;
+
+ case RULE_IS_NOT:
+ $result = ($check0 != $rule_row['rule_string']);
+ break;
+
+ case RULE_BEGINS_WITH:
+ $result = preg_match("/^" . preg_quote($rule_row['rule_string'], '/') . '/i', $check0);
+ break;
+
+ case RULE_ENDS_WITH:
+ $result = preg_match("/" . preg_quote($rule_row['rule_string'], '/') . '$/i', $check0);
+ break;
+
+ case RULE_IS_FRIEND:
+ case RULE_IS_FOE:
+ case RULE_ANSWERED:
+ case RULE_FORWARDED:
+ $result = ($check0 == 1);
+ break;
+
+ case RULE_IS_USER:
+ $result = ($check0 == $rule_row['rule_user_id']);
+ break;
+
+ case RULE_IS_GROUP:
+ $result = in_array($rule_row['rule_group_id'], $check0);
+ break;
+
+ case RULE_TO_GROUP:
+ $result = (in_array('g_' . $message_row[$check_ary['check2']], $check0) || in_array('g_' . $message_row[$check_ary['check2']], $message_row[$check_ary['check1']]));
+ break;
+
+ case RULE_TO_ME:
+ $result = (in_array('u_' . $user_id, $check0) || in_array('u_' . $user_id, $message_row[$check_ary['check1']]));
+ break;
+ }
- // Evil Statement
- $result = false;
- eval('$result = (' . $evaluate . ') ? true : false;');
if (!$result)
{
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index f24c3f4d09..115fe21e35 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -40,6 +40,7 @@ class phpbb_template_filter extends php_user_filter
const REGEX_NS = '[a-z_][a-z_0-9]+';
const REGEX_VAR = '[A-Z_][A-Z_0-9]+';
+ const REGEX_VAR_SUFFIX = '[A-Z_0-9]+';
const REGEX_TAG = '<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->';
@@ -374,7 +375,7 @@ class phpbb_template_filter extends php_user_filter
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
if (strpos($text_blocks, '{L_') !== false)
{
- $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR_SUFFIX . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
@@ -382,7 +383,7 @@ class phpbb_template_filter extends php_user_filter
// If a template variable already exist, it will be used in favor of it...
if (strpos($text_blocks, '{LA_') !== false)
{
- $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR_SUFFIX . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
@@ -872,6 +873,15 @@ class phpbb_template_filter extends php_user_filter
// Strip the trailing period.
$namespace = substr($namespace, 0, -1);
+ if (($pos = strrpos($namespace, '.')) !== false)
+ {
+ $local_namespace = substr($namespace, $pos + 1);
+ }
+ else
+ {
+ $local_namespace = $namespace;
+ }
+
$expr = true;
// S_ROW_COUNT is deceptive, it returns the current row number now the number of rows
@@ -880,23 +890,23 @@ class phpbb_template_filter extends php_user_filter
{
case 'S_ROW_NUM':
case 'S_ROW_COUNT':
- $varref = "\$_${namespace}_i";
+ $varref = "\$_${local_namespace}_i";
break;
case 'S_NUM_ROWS':
- $varref = "\$_${namespace}_count";
+ $varref = "\$_${local_namespace}_count";
break;
case 'S_FIRST_ROW':
- $varref = "(\$_${namespace}_i == 0)";
+ $varref = "(\$_${local_namespace}_i == 0)";
break;
case 'S_LAST_ROW':
- $varref = "(\$_${namespace}_i == \$_${namespace}_count - 1)";
+ $varref = "(\$_${local_namespace}_i == \$_${local_namespace}_count - 1)";
break;
case 'S_BLOCK_NAME':
- $varref = "'$namespace'";
+ $varref = "'$local_namespace'";
break;
default:
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 0495ade9c5..ec5fbe2829 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -307,36 +307,31 @@ class phpbb_template
*/
private function _tpl_load($handle)
{
- $virtual_source_file = $this->locator->get_virtual_source_file_for_handle($handle);
- $source_file = null;
-
- $compiled_path = $this->cachepath . str_replace('/', '.', $virtual_source_file) . '.' . $this->phpEx;
+ $output_file = $this->_compiled_file_for_handle($handle);
$recompile = defined('DEBUG_EXTRA') ||
- !file_exists($compiled_path) ||
- @filesize($compiled_path) === 0 ||
- ($this->config['load_tplcompile'] && @filemtime($compiled_path) < @filemtime($source_file));
+ !file_exists($output_file) ||
+ @filesize($output_file) === 0;
- if (!$recompile && $this->config['load_tplcompile'])
+ if ($recompile || $this->config['load_tplcompile'])
{
+ // Set only if a recompile or an mtime check are required.
$source_file = $this->locator->get_source_file_for_handle($handle);
- $recompile = (@filemtime($compiled_path) < @filemtime($source_file)) ? true : false;
+
+ if (!$recompile && @filemtime($output_file) < @filemtime($source_file))
+ {
+ $recompile = true;
+ }
}
// Recompile page if the original template is newer, otherwise load the compiled version
if (!$recompile)
{
- return new phpbb_template_renderer_include($compiled_path, $this);
- }
-
- if ($source_file === null)
- {
- $source_file = $this->locator->get_source_file_for_handle($handle);
+ return new phpbb_template_renderer_include($output_file, $this);
}
$compile = new phpbb_template_compile($this->config['tpl_allow_php']);
- $output_file = $this->_compiled_file_for_handle($handle);
if ($compile->compile_file_to_file($source_file, $output_file) !== false)
{
$renderer = new phpbb_template_renderer_include($output_file, $this);
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index 8b288f5de1..c9451bd202 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -239,7 +239,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'U_PM' => ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_info['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;mode=compose&amp;u=' . $author_id) : '',
'U_WWW' => (!empty($user_info['user_website'])) ? $user_info['user_website'] : '',
- 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people' . urlencode($user_info['user_icq']) . '/' : '',
+ 'U_ICQ' => ($user_info['user_icq']) ? 'http://www.icq.com/people/' . urlencode($user_info['user_icq']) . '/' : '',
'U_AIM' => ($user_info['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=aim&amp;u=' . $author_id) : '',
'U_YIM' => ($user_info['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($user_info['user_yim']) . '&amp;.src=pg' : '',
'U_MSN' => ($user_info['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=contact&amp;action=msnm&amp;u=' . $author_id) : '',