1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 02:36:38 +02:00

- introduce new function build_url to easily build a valid url from the user->page object as well as optionally removing certain keys

- changed attachment config to utilize the config build methods
- cleaned up posting.php
- the submit/delete_post functions are now usable (functions_posting.php)
- adjusted header icons (transparency)
- a bunch of fixes for mssql
- bug fixes


git-svn-id: file:///svn/phpbb/trunk@5902 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2006-05-12 20:52:58 +00:00
parent 7dd067bf5a
commit a8d99f2228
48 changed files with 2015 additions and 1957 deletions

View File

@@ -14,6 +14,7 @@
class acp_attachments
{
var $u_action;
var $new_config;
function main($id, $mode)
{
@@ -63,85 +64,6 @@ class acp_attachments
case 'attach':
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$config_sizes = array('max_filesize' => 'size', 'attachment_quota' => 'quota_size', 'max_filesize_pm' => 'pm_size');
foreach ($config_sizes as $cfg_key => $var)
{
$$var = request_var($var, '');
}
// Pull all config data
$sql = 'SELECT *
FROM ' . CONFIG_TABLE;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = request_var($config_name, $default_config[$config_name]);
foreach ($config_sizes as $cfg_key => $var)
{
if (empty($$var) && !$submit && $config_name == $cfg_key)
{
$$var = (intval($default_config[$config_name]) >= 1048576) ? 'mb' : ((intval($default_config[$config_name]) >= 1024) ? 'kb' : 'b');
}
if (!$submit && $config_name == $cfg_key)
{
$new[$config_name] = ($new[$config_name] >= 1048576) ? round($new[$config_name] / 1048576 * 100) / 100 : (($new[$config_name] >= 1024) ? round($new[$config_name] / 1024 * 100) / 100 : $new[$config_name]);
}
if ($submit && $config_name == $cfg_key)
{
$old = $new[$config_name];
$new[$config_name] = ($$var == 'kb') ? round($new[$config_name] * 1024) : (($$var == 'mb') ? round($new[$config_name] * 1048576) : $new[$config_name]);
}
}
if ($submit)
{
set_config($config_name, $new[$config_name]);
if (in_array($config_name, array('max_filesize', 'attachment_quota', 'max_filesize_pm')))
{
$new[$config_name] = $old;
}
}
}
$db->sql_freeresult($result);
$this->perform_site_list();
if ($submit)
{
add_log('admin', 'LOG_CONFIG_ATTACH');
// Check Settings
$this->test_upload($error, $new['upload_path'], false);
if (!sizeof($error))
{
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
}
$template->assign_var('S_ATTACHMENT_SETTINGS', true);
if ($action == 'imgmagick')
{
$new['img_imagick'] = $this->search_imagemagick();
}
// We strip eventually manual added convert program, we only want the patch
$new['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $new['img_imagick']);
$s_size_options = size_select_options($size);
$s_quota_size_options = size_select_options($quota_size);
$s_pm_size_options = size_select_options($pm_size);
$sql = 'SELECT group_name, cat_id
FROM ' . EXTENSION_GROUPS_TABLE . '
@@ -156,48 +78,103 @@ class acp_attachments
}
$db->sql_freeresult($result);
$l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((sizeof($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NONE']) . ']';
$display_vars = array(
'title' => 'ACP_ATTACHMENT_SETTINGS',
'vars' => array(
'img_max_width' => false, 'img_max_height' => false, 'img_link_width' => false, 'img_link_height' => false,
'legend1' => 'ACP_ATTACHMENT_SETTINGS',
'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'type' => 'radio:yes_no', 'explain' => false),
'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'type' => 'radio:yes_no', 'explain' => false),
'upload_path' => array('lang' => 'UPLOAD_DIR', 'type' => 'text:25:100', 'explain' => true),
'display_order' => array('lang' => 'DISPLAY_ORDER', 'type' => 'custom', 'method' => 'display_order', 'explain' => true),
'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE','type' => 'custom', 'method' => 'max_filesize', 'explain' => true),
'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'type' => 'text:3:3', 'explain' => false),
'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'type' => 'text:3:3', 'explain' => false),
'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'type' => 'radio:yes_no', 'explain' => true),
'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true),
'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERER', 'type' => 'radio:yes_no', 'explain' => true),
'legend2' => $l_legend_cat_images,
'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'type' => 'radio:yes_no', 'explain' => true),
'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'type' => 'radio:yes_no', 'explain' => true),
'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
'img_imagick' => array('lang' => 'IMAGICK_PATH', 'type' => 'text:20:200', 'explain' => true, 'append' => '&nbsp;&nbsp;<span>[ <a href="' . $this->u_action . '&amp;action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'),
'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'type' => 'dimension:3:4', 'explain' => true),
'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'type' => 'dimension:3:4', 'explain' => true),
)
);
$this->new_config = $config;
$cfg_array = (isset($_REQUEST['config'])) ? request_var('config', array('' => '')) : $this->new_config;
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null)
{
if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
{
continue;
}
$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
if ($config_name == 'attachment_quota')
{
$size_var = request_var($config_name, '');
$this->new_config[$config_name] = $config_value = ($size_var == 'kb') ? round($config_value * 1024) : (($size_var == 'mb') ? round($config_value * 1048576) : $config_value);
}
if ($submit)
{
set_config($config_name, $config_value);
}
}
$this->perform_site_list();
if ($submit)
{
add_log('admin', 'LOG_CONFIG_ATTACH');
// Check Settings
$this->test_upload($error, $this->new_config['upload_path'], false);
if (!sizeof($error))
{
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
}
$template->assign_var('S_ATTACHMENT_SETTINGS', true);
if ($action == 'imgmagick')
{
$this->new_config['img_imagick'] = $this->search_imagemagick();
}
// We strip eventually manual added convert program, we only want the patch
$this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']);
$supported_types = get_supported_image_types();
// Check Thumbnail Support
if (!$new['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format'])))
if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format'])))
{
$new['img_create_thumbnail'] = '0';
$this->new_config['img_create_thumbnail'] = 0;
}
$template->assign_vars(array(
'UPLOAD_PATH' => $new['upload_path'],
'DISPLAY_ORDER' => $new['display_order'],
'ATTACHMENT_QUOTA' => $new['attachment_quota'],
'ALLOW_ATTACHMENTS' => $new['allow_attachments'],
'ALLOW_PM_ATTACH' => $new['allow_pm_attach'],
'MAX_FILESIZE' => $new['max_filesize'],
'MAX_PM_FILESIZE' => $new['max_filesize_pm'],
'MAX_ATTACHMENTS' => $new['max_attachments'],
'MAX_ATTACHMENTS_PM' => $new['max_attachments_pm'],
'SECURE_DOWNLOADS' => $new['secure_downloads'],
'SECURE_ALLOW_DENY' => $new['secure_allow_deny'],
'ALLOW_EMPTY_REFERER' => $new['secure_allow_empty_referer'],
'ASSIGNED_GROUPS' => (sizeof($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NONE'],
'DISPLAY_INLINED' => $new['img_display_inlined'],
'CREATE_THUMBNAIL' => $new['img_create_thumbnail'],
'MIN_THUMB_FILESIZE' => $new['img_min_thumb_filesize'],
'IMG_IMAGICK' => $new['img_imagick'],
'MAX_WIDTH' => $new['img_max_width'],
'MAX_HEIGHT' => $new['img_max_height'],
'LINK_WIDTH' => $new['img_link_width'],
'LINK_HEIGHT' => $new['img_link_height'],
'U_SEARCH_IMAGICK' => $this->u_action . '&amp;action=imgmagick',
'S_QUOTA_SIZE_OPTIONS' => $s_quota_size_options,
'S_MAX_FILESIZE_OPTIONS' => $s_size_options,
'S_MAX_PM_FILESIZE_OPTIONS' => $s_pm_size_options,
'S_THUMBNAIL_SUPPORT' => (!$new['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true,
'S_THUMBNAIL_SUPPORT' => (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) ? false : true,
)
);
// Secure Download Options - Same procedure as with banning
$allow_deny = ($new['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED';
$allow_deny = ($this->new_config['secure_allow_deny']) ? 'ALLOWED' : 'DISALLOWED';
$sql = 'SELECT *
FROM ' . SITELIST_TABLE;
@@ -218,7 +195,7 @@ class acp_attachments
$db->sql_freeresult($result);
$template->assign_vars(array(
'S_SECURE_DOWNLOADS' => $new['secure_downloads'],
'S_SECURE_DOWNLOADS' => $this->new_config['secure_downloads'],
'S_DEFINED_IPS' => ($defined_ips != '') ? true : false,
'DEFINED_IPS' => $defined_ips,
@@ -229,6 +206,48 @@ class acp_attachments
)
);
// Output relevant options
foreach ($display_vars['vars'] as $config_key => $vars)
{
if (!is_array($vars) && strpos($config_key, 'legend') === false)
{
continue;
}
if (strpos($config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
);
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => $user->lang[$vars['lang']],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
)
);
unset($display_vars['vars'][$config_key]);
}
break;
case 'extensions':
@@ -1410,6 +1429,38 @@ class acp_attachments
$cache->put('_extensions', $extensions);
}
/**
* Write display_order config field
*/
function display_order($value, $key = '')
{
$radio_ary = array(0 => 'DESCENDING', 1 => 'ASCENDING');
return h_radio('config[display_order]', $radio_ary, $value, $key);
}
/**
* Adjust all three max_filesize config vars for display
*/
function max_filesize($value, $key = '')
{
// Determine size var and adjust the value accordingly
$size_var = ($value >= 1048576) ? 'mb' : (($value >= 1024) ? 'kb' : 'b');
$value = ($value >= 1048576) ? round($value / 1048576 * 100) / 100 : (($value >= 1024) ? round($value / 1024 * 100) / 100 : $value);
return '<input type="text" id="' . $key . '" size="8" maxlength="15" name="config[' . $key . ']" value="' . $value . '" /> <select name="' . $key . '">' . size_select_options($size_var) . '</select>';
}
/**
* Write secure_allow_deny config field
*/
function select_allow_deny($value, $key = '')
{
$radio_ary = array(1 => 'ORDER_ALLOW_DENY', 0 => 'ORDER_DENY_ALLOW');
return h_radio('config[' . $key . ']', $radio_ary, $value, $key);
}
}
?>

View File

@@ -369,13 +369,13 @@ class acp_board
continue;
}
$config_value = $cfg_array[$config_name];
$this->new_config[$config_name] = $config_value;
$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
if ($config_name == 'email_function_name')
{
$this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
$this->new_config['email_function_name'] = (empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name'])) ? 'mail' : $this->new_config['email_function_name'];
$config_value = $this->new_config['email_function_name'];
}
if ($submit)
@@ -499,7 +499,7 @@ class acp_board
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => $user->lang[$vars])
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars)
);
continue;
@@ -507,11 +507,21 @@ class acp_board
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => $user->lang[$vars['lang']],
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => ($vars['explain']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '',
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
)
);
@@ -591,7 +601,7 @@ class acp_board
{
global $user;
return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES'] . '</option>';
return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES_SHORT'] . '</option>';
}
function captcha_pixel_noise_select($value, $key = '')

View File

@@ -384,7 +384,7 @@ class acp_permissions
'FROM' => array(
GROUPS_TABLE => 'g',
ACL_OPTIONS_TABLE => 'o',
ACL_USERS_TABLE => 'a'
ACL_GROUPS_TABLE => 'a'
),
'LEFT_JOIN' => array(
@@ -395,9 +395,9 @@ class acp_permissions
),
'WHERE' => "(a.auth_option_id = o.auth_option_id OR r.auth_option_id = o.auth_option_id)
$sql_permission_option
$sql_forum_id
AND g.group_id = a.group_id",
$sql_permission_option
$sql_forum_id
AND g.group_id = a.group_id",
'ORDER_BY' => 'g.group_type DESC, g.group_name ASC'
));

View File

@@ -31,6 +31,9 @@ class acp_styles
global $db, $user, $auth, $template;
global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
// Hardcoded template bitfield to add for new templates
define('TEMPLATE_BITFIELD', 6921);
$user->add_lang('acp/styles');
$this->tpl_name = 'acp_styles';
@@ -2216,7 +2219,9 @@ pagination_sep = \'{PAGINATION_SEP}\'
switch ($mode)
{
case 'template':
// We set a pre-defined bitfield here which we may use further in 3.2
$sql_ary += array(
'bbcode_bitfield' => TEMPLATE_BITFIELD,
$mode . '_storedb' => (!is_writeable("{$phpbb_root_path}styles/$path/$mode")) ? 1 : 0
);
break;

View File

@@ -952,7 +952,14 @@ class acp_users
if (!isset($data['bday_day']))
{
list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
if ($user_row['user_birthday'])
{
list($data['bday_day'], $data['bday_month'], $data['bday_year']) = explode('-', $user_row['user_birthday']);
}
else
{
$data['bday_day'] = $data['bday_month'] = $data['bday_year'] = 0;
}
}
$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';

View File

@@ -14,6 +14,21 @@
* Main gd based captcha class
*
* Thanks to Robert Hetzler (Xore)
*
* @todo see notes in includes/captcha/captcha_gd.php
*
* Within the policy 'policy_occlude' the letters need to have more space in-between of them.
* At the moment it can happen that the letters get overlapped
*
* Completely remove the number 0
* Make it case-insensitive
*
* The policy_entropy seems to be the best readable, then follows policy_occlude and policy_3dbitmap not readable.
*
* Within the policy 'policy_3dbitmap':
* The 2 and the Z seem to be very similar
* The letters are not distinguishable(?) enough from the background, maybe related to the letters itself
* The colors are generally a bit off making it hard to read...
*/
class captcha
{
@@ -24,7 +39,7 @@ class captcha
{
global $config;
$policy_modules = array('policy_occlude', 'policy_entropy', 'policy_3dbitmap');
$policy_modules = array('policy_entropy', 'policy_occlude'); // 'policy_3dbitmap'
// Remove all disabled policy modules
foreach ($policy_modules as $key => $name)

View File

@@ -266,7 +266,9 @@ class dbal
$message = '<u>SQL ERROR</u> [ ' . SQL_LAYER . ' ]<br /><br />' . $error['message'] . ' [' . $error['code'] . ']';
// Show complete SQL error and path to administrators only
if ($auth->acl_get('a_') || defined('IN_INSTALL'))
// Additionally show complete error on installation or if extended debug mode is enabled
// The DEBUG_EXTRA constant is for development only!
if ($auth->acl_get('a_') || defined('IN_INSTALL') || defined('DEBUG_EXTRA'))
{
// Print out a nice backtrace...
$backtrace = get_backtrace();
@@ -314,7 +316,7 @@ class dbal
*/
function sql_report($mode, $query = '')
{
global $cache, $starttime, $phpbb_root_path, $user;
global $cache, $starttime, $phpbb_root_path, $user, $SID;
if (empty($_GET['explain']))
{
@@ -350,7 +352,7 @@ class dbal
<body id="errorpage">
<div id="wrap">
<div id="page-header">
<a href="' . htmlspecialchars(preg_replace('/&explain=([^&]*)/', '', $_SERVER['REQUEST_URI'])) . '">Return to previous page</a>
<a href="' . build_url('explain') . '">Return to previous page</a>
</div>
<div id="page-body">
<div class="panel">

View File

@@ -98,7 +98,6 @@ class dbal_mssql extends dbal
{
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG_EXTRA'))
{
@@ -315,17 +314,33 @@ class dbal_mssql extends dbal
*/
function _sql_error()
{
$error = array(
'message' => @mssql_get_last_message($this->db_connect_id),
'code' => ''
);
$result_id = @mssql_query('SELECT @@ERROR as errno', $this->db_connect_id);
// Get error code number
$result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id);
if ($result_id)
{
$row = @mssql_fetch_assoc($result_id);
$error['code'] = $row['errno'];
$error['code'] = $row['code'];
@mssql_free_result($result_id);
}
// Get full error message if possible
$sql = 'SELECT CAST(description as varchar(255)) as message
FROM master.dbo.sysmessages
WHERE error = ' . $error['code'];
$result_id = @mssql_query($sql);
if ($result_id)
{
$row = @mssql_fetch_assoc($result_id);
if (!empty($row['message']))
{
$error['message'] .= '<br />' . $row['message'];
}
@mssql_free_result($result_id);
}

View File

@@ -1228,6 +1228,36 @@ function redirect($url)
exit;
}
/**
* Returns url from the session/current page with an re-appended SID with optionally stripping vars from the url
*/
function build_url($strip_vars = false)
{
global $user, $phpbb_root_path, $SID;
// Append SID
$redirect = (($user->page['page_dir']) ? $user->page['page_dir'] . '/' : '') . $user->page['page_name'] . $SID . (($user->page['query_string']) ? "&{$user->page['query_string']}" : '');
// Strip vars...
if ($strip_vars !== false)
{
if (!is_array($strip_vars))
{
$strip_vars = array($strip_vars);
}
foreach ($strip_vars as $var)
{
if (strpos($redirect, $var) !== false)
{
$redirect = preg_replace('#^(.*?)&?' . preg_quote($var, '#') . '=.*(&?)(.*?)$#', '\1\3', $redirect);
}
}
}
return $phpbb_root_path . str_replace('&', '&amp;', $redirect);
}
/**
* Meta refresh assignment
*/
@@ -1427,7 +1457,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
// Remove previously added sid (should not happen)
if (strpos($redirect, '?sid='))
{
$redirect = preg_replace('/\?sid=[a-z0-9]+(&|&amp;)?/', $SID . '\1', $redirect);
$redirect = preg_replace('/\?sid=[a-z0-9]+(&amp;|&)?/', $SID . '\1', $redirect);
}
else
{
@@ -1495,7 +1525,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
if (!$redirect)
{
// We just use what the session code determined...
$redirect = htmlspecialchars($user->page['page_name'] . (($user->page['query_string']) ? '?' . $user->page['query_string'] : ''));
$redirect = $user->page['page_name'] . (($user->page['query_string']) ? '?' . $user->page['query_string'] : '');
}
$s_hidden_fields = build_hidden_fields(array('redirect' => $redirect, 'sid' => $user->session_id));
@@ -1530,7 +1560,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
/**
* Generate forum login box
*/
function login_forum_box(&$forum_data)
function login_forum_box($forum_data)
{
global $db, $config, $user, $template, $phpEx;
@@ -1540,15 +1570,15 @@ function login_forum_box(&$forum_data)
FROM ' . FORUMS_ACCESS_TABLE . '
WHERE forum_id = ' . $forum_data['forum_id'] . '
AND user_id = ' . $user->data['user_id'] . "
AND session_id = '$user->session_id'";
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row = $db->sql_fetchrow($result))
if ($row)
{
$db->sql_freeresult($result);
return true;
}
$db->sql_freeresult($result);
if ($password)
{
@@ -1575,9 +1605,13 @@ function login_forum_box(&$forum_data)
if ($password == $forum_data['forum_password'])
{
$sql = 'INSERT INTO ' . FORUMS_ACCESS_TABLE . ' (forum_id, user_id, session_id)
VALUES (' . $forum_data['forum_id'] . ', ' . $user->data['user_id'] . ", '" . $db->sql_escape($user->session_id) . "')";
$db->sql_query($sql);
$sql_ary = array(
'forum_id' => (int) $forum_data['forum_id'],
'user_id' => (int) $user->data['user_id'],
'session_id' => (string) $user->session_id,
);
$db->sql_query('INSERT INTO ' . FORUMS_ACCESS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
return true;
}
@@ -1586,9 +1620,11 @@ function login_forum_box(&$forum_data)
}
page_header();
$template->set_filenames(array(
'body' => 'login_forum.html')
);
page_footer();
}
@@ -2525,7 +2561,7 @@ function page_header($page_title = '')
'SITENAME' => $config['sitename'],
'SITE_DESCRIPTION' => $config['site_desc'],
'PAGE_TITLE' => $page_title,
'SCRIPT_NAME' => str_replace($phpEx, '', $user->page['page_name']),
'SCRIPT_NAME' => str_replace('.' . $phpEx, '', $user->page['page_name']),
'LAST_VISIT_DATE' => sprintf($user->lang['YOU_LAST_VISIT'], $s_last_visit),
'CURRENT_TIME' => sprintf($user->lang['CURRENT_TIME'], $user->format_date(time(), false, true)),
'TOTAL_USERS_ONLINE' => $l_online_users,
@@ -2640,11 +2676,7 @@ function page_footer()
}
}
$explain_url = $phpbb_root_path . str_replace('&', '&amp;', $user->page['page']);
$explain_url = (strpos($explain_url, '?') !== false) ? str_replace('?', $SID . '&amp;', $explain_url) : $explain_url . '?' . str_replace('?', '', $SID);
$explain_url .= ((strpos($explain_url, '?') === false) ? '?' : '&amp;') . 'explain=1';
$debug_output .= ' | <a href="' . $explain_url . '">Explain</a>';
$debug_output .= ' | <a href="' . build_url() . '&amp;explain=1">Explain</a>';
}
}

View File

@@ -193,7 +193,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
// Handle marking posts
if ($mark_read == 'forums' || $mark_read == 'all')
{
$redirect = (!empty($_SERVER['REQUEST_URI'])) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : "index.$phpEx$SID";
$redirect = build_url('mark');
if ($mark_read == 'all')
{
@@ -332,7 +332,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield']),
'TOPICS' => $row['forum_topics'],
$l_post_click_count => $post_click_count,
'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['folder_alt'] . '" />' : $user->img($folder_image, $folder_alt),
'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $folder_alt . '" />' : $user->img($folder_image, $folder_alt),
'FORUM_FOLDER_IMG_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : $user->img($folder_image, $folder_alt, false, '', 'src'),
'SUBFORUMS' => $subforums_list,
'LAST_POST_TIME' => $last_post_time,

File diff suppressed because it is too large Load Diff

View File

@@ -1382,7 +1382,7 @@ function submit_pm($mode, $subject, &$data, $update_message, $put_in_outbox = tr
// Send Notifications
if ($mode != 'edit')
{
pm_notification($mode, stripslashes($data['from_username']), $recipients, stripslashes($subject), stripslashes($data['message']));
pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message']);
}
return $data['msg_id'];

View File

@@ -139,6 +139,7 @@ function user_delete($mode, $user_id, $post_username = false)
GROUP BY topic_id";
$result = $db->sql_query($sql);
$topic_id_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$topic_id_ary[$row['topic_id']] = $row['total_posts'];
@@ -199,7 +200,7 @@ function user_delete($mode, $user_id, $post_username = false)
set_config('newest_user_id', $row['user_id']);
set_config('newest_username', $row['username']);
}
$db->freeresult($result);
$db->sql_freeresult($result);
}
set_config('num_users', $config['num_users'] - 1, true);
@@ -1226,6 +1227,12 @@ function group_create(&$group_id, $type, $name, $desc, $group_attributes, $allow
{
if (isset($group_attributes[$attribute]) && !in_array($attribute, $group_only_ary))
{
// If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set...
if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute])
{
continue;
}
$sql_ary[str_replace('group', 'user', $attribute)] = $group_attributes[$attribute];
}
}
@@ -1618,6 +1625,12 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
{
if (isset($group_attributes[$attribute]))
{
// If we are about to set an avatar, we will not overwrite user avatars if no group avatar is set...
if (strpos($attribute, 'group_avatar') === 0 && !$group_attributes[$attribute])
{
continue;
}
settype($group_attributes[$attribute], $type);
$sql_ary[str_replace('group_', 'user_', $attribute)] = $group_attributes[$attribute];
}

View File

@@ -676,7 +676,7 @@ function disapprove_post($post_id_list, $mode)
'EMAIL_SIG' => $email_sig,
'SITENAME' => $config['sitename'],
'USERNAME' => $post_data['username'],
'REASON' => stripslashes($disapprove_reason),
'REASON' => $disapprove_reason,
'POST_SUBJECT' => censor_text($post_data['post_subject']),
'TOPIC_TITLE' => censor_text($post_data['topic_title']))
);

View File

@@ -148,6 +148,8 @@ class bbcode_firstpass extends bbcode
function check_bbcode($bbcode, &$in)
{
// when using the /e modifier, preg_replace slashes double-quotes but does not
// seem to slash anything else
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
if (!$in)
@@ -266,16 +268,10 @@ class bbcode_firstpass extends bbcode
// Expects the argument to start right after the opening [code] tag and to end with [/code]
function bbcode_code($stx, $in)
{
// when using the /e modifier, preg_replace slashes double-quotes but does not
// seem to slash anything else
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
if (!$in)
if (!$this->check_bbcode('code', $in))
{
return '';
}
$this->parsed_items['code']++;
// We remove the hardcoded elements from the code block here because it is not used in code blocks
// Having it here saves us one preg_replace per message containing [code] blocks
@@ -399,7 +395,6 @@ class bbcode_firstpass extends bbcode
return '';
}
$in = str_replace('\"', '"', $in);
$out = '[';
// Grab item_start with no item_end
@@ -489,7 +484,7 @@ class bbcode_firstpass extends bbcode
{
global $config, $user;
$in = trim($in);
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
if (!$in)
{
@@ -503,7 +498,9 @@ class bbcode_firstpass extends bbcode
$in = preg_replace(array('#\[quote(=&quot;.*?&quot;)?\]([^\n])#is', '#([^\n])\[\/quote\]#is'), array("[quote\\1]\n\\2", "\\1\n[/quote]"), $in);
$in = preg_replace(array('#\[quote(=&quot;.*?&quot;)?\]([^\n])#is', '#([^\n])\[\/quote\]#is'), array("[quote\\1]\n\\2", "\\1\n[/quote]"), $in);
$in = substr(str_replace('\"', '"', $in), 1);
$in = str_replace("\r\n", "\n", str_replace('\"', '"', trim($in)));
$in = substr($in, 1);
$close_tags = $error_ary = array();
$buffer = '';
@@ -629,8 +626,11 @@ class bbcode_firstpass extends bbcode
function validate_email($var1, $var2)
{
$txt = stripslashes($var2);
$email = ($var1) ? stripslashes($var1) : stripslashes($var2);
$var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1)));
$var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2)));
$txt = $var2;
$email = ($var1) ? $var1 : $var2;
$validated = true;
@@ -662,10 +662,10 @@ class bbcode_firstpass extends bbcode
{
global $config;
$var1 = trim($var1);
$var2 = trim($var2);
$var1 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var1)));
$var2 = str_replace("\r\n", "\n", str_replace('\"', '"', trim($var2)));
$url = ($var1) ? stripslashes($var1) : stripslashes($var2);
$url = ($var1) ? $var1 : $var2;
$valid = false;
if (!$url || ($var1 && !$var2))
@@ -690,10 +690,10 @@ class bbcode_firstpass extends bbcode
$url = 'http://' . $url;
}
return ($var1) ? '[url=' . str_replace(array(']', '['), array('&#93;', '&#91;'), $url) . ':' . $this->bbcode_uid . ']' . stripslashes($var2) . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']';
return ($var1) ? '[url=' . str_replace(array(']', '['), array('&#93;', '&#91;'), $url) . ':' . $this->bbcode_uid . ']' . $var2 . '[/url:' . $this->bbcode_uid . ']' : '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']';
}
return '[url' . (($var1) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]';
return '[url' . (($var1) ? '=' . $var1 : '') . ']' . $var2 . '[/url]';
}
}

View File

@@ -139,7 +139,8 @@ class session
// Why no forwarded_for et al? Well, too easily spoofed. With the results of my recent requests
// it's pretty clear that in the majority of cases you'll at least be left with a proxy/cache ip.
$this->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
$this->load = false;
// Load limit check (if applicable)
if ($config['limit_load'])
{
@@ -149,11 +150,6 @@ class session
{
$this->load = array_slice(explode(' ', $load), 0, 1);
$this->load = floatval($this->load[0]);
if ($config['limit_load'] && $this->load > floatval($config['limit_load']))
{
trigger_error('BOARD_UNAVAILABLE');
}
}
else
{
@@ -1043,13 +1039,21 @@ class user extends session
$this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $config['default_lang'];
// Is board disabled and user not an admin or moderator?
// @todo new ACL enabling board access while offline?
if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_'))
{
$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
trigger_error($message);
}
// Is load exceeded?
if ($config['limit_load'] && $this->load !== false)
{
if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_'))
{
trigger_error('BOARD_UNAVAILABLE');
}
}
// Does the user need to change their password? If so, redirect to the
// ucp profile reg_details page ... of course do not redirect if we're
// already in the ucp

View File

@@ -126,7 +126,7 @@ class template
}
/**
* Display the handle and assign the output to a template variable
* Display the handle and assign the output to a template variable or return the content.
* @public
*/
function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)

View File

@@ -49,6 +49,7 @@ class ucp_groups
while ($row = $db->sql_fetchrow($result))
{
$row['group_name'] = ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'];
$group_row[$row['group_id']] = $row;
}
$db->sql_freeresult($result);
@@ -58,10 +59,6 @@ class ucp_groups
trigger_error('GROUP_NOT_EXIST');
}
$group_row[$group_id]['group_name'] = ($group_row[$group_id]['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row[$group_id]['group_name']] : $group_row[$group_id]['group_name'];
$group_row[$user->data['group_id']]['group_name'] = ($group_row[$user->data['group_id']]['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row[$user->data['group_id']]['group_name']] : $group_row[$user->data['group_id']]['group_name'];
switch ($action)
{
case 'change_default':

View File

@@ -512,7 +512,7 @@ function compose_pm($id, $mode, $action)
trigger_error($message);
}
$message_subject = stripslashes($subject);
$message_subject = $subject;
}
// Preview

View File

@@ -24,7 +24,7 @@ class ucp_register
{
trigger_error($user->lang['UCP_REGISTER_DISABLE']);
}
$config['max_reg_attempts'] = 0;
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$confirm_id = request_var('confirm_id', '');
@@ -236,6 +236,7 @@ class ucp_register
$sql_ary = array(
'username' => $username,
'user_permissions' => '',
'user_password' => md5($new_password),
'user_email' => $email,
'user_email_hash' => (int) crc32(strtolower($email)) . strlen($email),
@@ -248,7 +249,15 @@ class ucp_register
'user_actkey' => $user_actkey,
'user_ip' => $user->ip,
'user_regdate' => time(),
'user_lastmark' => time(),
'user_lastmark' => time(),
'user_lastvisit' => 0,
'user_lastpost_time' => 0,
'user_lastpage' => '',
'user_posts' => 0,
'user_dst' => 0,
'user_colour' => '',
'user_avatar' => '',
);
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);