diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index cc7b5f6c1b..cf04f53991 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -172,11 +172,7 @@ function adm_page_footer($copyright_html = true) } } - $explain_url = $phpbb_root_path . str_replace('&', '&', $user->page['page']); - $explain_url = (strpos($explain_url, '?') !== false) ? str_replace('?', $SID . '&', $explain_url) : $explain_url . '?' . str_replace('?', '', $SID); - $explain_url .= ((strpos($explain_url, '?') === false) ? '?' : '&') . 'explain=1'; - - $debug_output .= ' | Explain'; + $debug_output .= ' | Explain'; } } diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index e0f2c08813..63283795fb 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -33,87 +33,29 @@ -
-
- {L_ACP_ATTACHMENT_SETTINGS} -
-
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
-
-
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
-
-

{L_UPLOAD_DIR_EXPLAIN}
-
-
-
-

{L_DISPLAY_ORDER_EXPLAIN}
-
checked="checked" /> {L_DESCENDING}   checked="checked" class="radio" /> {L_ASCENDING}
-
-
-

{L_ATTACH_QUOTA_EXPLAIN}
-
-
-
-

{L_ATTACH_MAX_FILESIZE_EXPLAIN}
-
-
-
-

{L_ATTACH_MAX_PM_FILESIZE_EXPLAIN}
-
-
-
-
-
-
-
-
-
-
-
-

{L_SECURE_DOWNLOADS_EXPLAIN}
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
-
-

{L_SECURE_ALLOW_DENY_EXPLAIN}
-
checked="checked" class="radio" /> {L_ORDER_ALLOW_DENY}   checked="checked" class="radio" /> {L_ORDER_DENY_ALLOW}
-
-
-

{L_SECURE_EMPTY_REFERER_EXPLAIN}
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
-
- -
- {L_SETTINGS_CAT_IMAGES} [{L_ASSIGNED_GROUP}: {ASSIGNED_GROUPS}] -
-

{L_DISPLAY_INLINED_EXPLAIN}
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
- -
-

{L_CREATE_THUMBNAIL_EXPLAIN}
-
checked="checked" class="radio" /> {L_YES}   checked="checked" class="radio" /> {L_NO}
-
-
-

{L_MIN_THUMB_FILESIZE_EXPLAIN}
-
{L_BYTES}
-
+ +
+

{L_NO_THUMBNAIL_SUPPORT}

+
-
-

{L_IMAGICK_PATH_EXPLAIN}
-
  [ {L_SEARCH_IMAGICK} ]
-
-
-

{L_MAX_IMAGE_SIZE_EXPLAIN}
-
px X px
-
-
-

{L_IMAGE_LINK_SIZE_EXPLAIN}
-
px X px
-
+ + + + + +
+ +
+ {options.LEGEND} + + +
+

{options.TITLE_EXPLAIN}
+
{options.CONTENT}
+
+ + +
diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index 41d3991810..6d3e412347 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -80,7 +80,7 @@ function trace(link) function swatch() { - window.open('{UA_SWATCH}', '_swatch', 'height=115, resizable=yes, scrollbars=no, width=636'); + window.open('{UA_SWATCH}', '_swatch', 'height=150, resizable=yes, scrollbars=no, width=636'); return false; } diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index f6bf579ee5..e61fa26988 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -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' => '  [ ' . $user->lang['SEARCH_IMAGICK'] . ' ]'), + '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 . '&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 ' '; + } + + /** + * 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); + } + } ?> \ No newline at end of file diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 3942a1b726..9de5d66b11 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -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 ''; + return ''; } function captcha_pixel_noise_select($value, $key = '') diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 1059629863..c794c159b9 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -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' )); diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 77e834821c..55efad44ad 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -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; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cae41e8d25..66fdf40701 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -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 = ''; diff --git a/phpBB/includes/captcha/captcha_gd.php b/phpBB/includes/captcha/captcha_gd.php index d49505442c..a1b9325895 100644 --- a/phpBB/includes/captcha/captcha_gd.php +++ b/phpBB/includes/captcha/captcha_gd.php @@ -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) diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 1a8b8a4ddf..a7e582d396 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -266,7 +266,9 @@ class dbal $message = 'SQL ERROR [ ' . SQL_LAYER . ' ]

' . $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
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index e1082d282c..5d6095e502 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -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'] .= '
' . $row['message']; + } @mssql_free_result($result_id); } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e2844246b0..d46d78a5d0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -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('&', '&', $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]+(&|&)?/', $SID . '\1', $redirect); + $redirect = preg_replace('/\?sid=[a-z0-9]+(&|&)?/', $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('&', '&', $user->page['page']); - $explain_url = (strpos($explain_url, '?') !== false) ? str_replace('?', $SID . '&', $explain_url) : $explain_url . '?' . str_replace('?', '', $SID); - $explain_url .= ((strpos($explain_url, '?') === false) ? '?' : '&') . 'explain=1'; - - $debug_output .= ' | Explain'; + $debug_output .= ' | Explain'; } } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3292e9a43f..ad3b7a4897 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -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']) ? '' . $user->lang['folder_alt'] . '' : $user->img($folder_image, $folder_alt), + 'FORUM_FOLDER_IMG' => ($row['forum_image']) ? '' . $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, diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 6fdf9a0cc2..558620c3cf 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -98,8 +98,11 @@ function generate_smilies($mode, $forum_id) /** * Update Post Informations (First/Last Post in topic/forum) * Should be used instead of sync() if only the last post informations are out of sync... faster +* +* @param string $type Can be forum|topic +* @param mixed $ids topic/forum ids */ -function update_post_information($type, $ids) +function update_post_information($type, $ids, $return_update_sql = false) { global $db; @@ -161,9 +164,9 @@ function update_post_information($type, $ids) } unset($empty_forums, $ids, $last_post_ids); - if (!sizeof($update_sql)) + if ($return_update_sql || !sizeof($update_sql)) { - return array(); + return $update_sql; } $table = ($type == 'forum') ? FORUMS_TABLE : TOPICS_TABLE; @@ -177,6 +180,108 @@ function update_post_information($type, $ids) } } +/** +* Generate Topic Icons for display +*/ +function posting_gen_topic_icons($mode, $icon_id) +{ + global $phpbb_root_path, $config, $template, $cache; + + // Grab icons + $icons = array(); + $cache->obtain_icons($icons); + + if (!$icon_id) + { + $template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"'); + } + + if (sizeof($icons)) + { + foreach ($icons as $id => $data) + { + if ($data['display']) + { + $template->assign_block_vars('topic_icon', array( + 'ICON_ID' => $id, + 'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'], + 'ICON_WIDTH' => $data['width'], + 'ICON_HEIGHT' => $data['height'], + + 'S_CHECKED' => ($id == $icon_id) ? true : false, + 'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '') + ); + } + } + + return true; + } + + return false; +} + +/** +* Build topic types able to be selected +*/ +function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) +{ + global $auth, $user, $template, $topic_type; + + $toggle = false; + + $topic_types = array( + 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), + 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), + 'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') + ); + + $topic_type_array = array(); + + foreach ($topic_types as $auth_key => $topic_value) + { + // We do not have a special post global announcement permission + $auth_key = ($auth_key == 'global') ? 'announce' : $auth_key; + + if ($auth->acl_get('f_' . $auth_key, $forum_id)) + { + $toggle = true; + + $topic_type_array[] = array( + 'VALUE' => $topic_value['const'], + 'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '', + 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] + ); + } + } + + if ($toggle) + { + $topic_type_array = array_merge(array(0 => array( + 'VALUE' => POST_NORMAL, + 'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '', + 'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])), + + $topic_type_array + ); + + foreach ($topic_type_array as $array) + { + $template->assign_block_vars('topic_type', $array); + } + + $template->assign_vars(array( + 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), + 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id))) + ); + } + + return $toggle; +} + +// +// Attachment related functions +// + /** * Upload Attachment - filedata is generated here * Uses upload class @@ -186,8 +291,9 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage global $auth, $user, $config, $db, $cache; global $phpbb_root_path; - $filedata = array(); - $filedata['error'] = array(); + $filedata = array( + 'error' => array() + ); include_once($phpbb_root_path . 'includes/functions_upload.php'); $upload = new fileupload(); @@ -339,21 +445,24 @@ function get_supported_image_types($type = false) { case 1: $new_type = ($format & IMG_GIF) ? IMG_GIF : 0; - break; + break; + case 2: case 9: case 10: case 11: case 12: $new_type = ($format & IMG_JPG) ? IMG_JPG : 0; - break; + break; + case 3: $new_type = ($format & IMG_PNG) ? IMG_PNG : 0; - break; + break; + case 6: case 15: $new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0; - break; + break; } } else @@ -394,7 +503,7 @@ function create_thumbnail($source, $destination, $mimetype) { return false; } - + list($width, $height, $type, ) = getimagesize($source); if (!$width || !$height) @@ -413,28 +522,31 @@ function create_thumbnail($source, $destination, $mimetype) { $used_imagick = true; } - } + } if (!$used_imagick) { $type = get_supported_image_types($type); - + if ($type['gd']) { switch ($type['format']) { case IMG_GIF: $image = imagecreatefromgif($source); - break; + break; + case IMG_JPG: $image = imagecreatefromjpeg($source); - break; + break; + case IMG_PNG: $image = imagecreatefrompng($source); - break; + break; + case IMG_WBMP: $image = imagecreatefromwbmp($source); - break; + break; } if ($type['version'] == 1) @@ -452,16 +564,19 @@ function create_thumbnail($source, $destination, $mimetype) { case IMG_GIF: imagegif($new_image, $destination); - break; + break; + case IMG_JPG: imagejpeg($new_image, $destination, 90); - break; + break; + case IMG_PNG: imagepng($new_image, $destination); - break; + break; + case IMG_WBMP: imagewbmp($new_image, $destination); - break; + break; } imagedestroy($new_image); @@ -478,46 +593,6 @@ function create_thumbnail($source, $destination, $mimetype) return true; } -/** -* Generate Topic Icons for display -*/ -function posting_gen_topic_icons($mode, $icon_id) -{ - global $phpbb_root_path, $config, $template, $cache; - - // Grab icons - $icons = array(); - $cache->obtain_icons($icons); - - if (!$icon_id) - { - $template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"'); - } - - if (sizeof($icons)) - { - foreach ($icons as $id => $data) - { - if ($data['display']) - { - $template->assign_block_vars('topic_icon', array( - 'ICON_ID' => $id, - 'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'], - 'ICON_WIDTH' => $data['width'], - 'ICON_HEIGHT' => $data['height'], - - 'S_CHECKED' => ($id == $icon_id) ? true : false, - 'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '') - ); - } - } - - return true; - } - - return false; -} - /** * Assign Inline attachments (build option fields) */ @@ -542,64 +617,6 @@ function posting_gen_inline_attachments(&$attachment_data) return false; } -/** -* Build topic types able to be selected -*/ -function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) -{ - global $auth, $user, $template, $topic_type; - - $toggle = false; - - $topic_types = array( - 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), - 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), - 'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') - ); - - $topic_type_array = array(); - - foreach ($topic_types as $auth_key => $topic_value) - { - // Temp - we do not have a special post global announcement permission - $auth_key = ($auth_key == 'global') ? 'announce' : $auth_key; - - if ($auth->acl_get('f_' . $auth_key, $forum_id)) - { - $toggle = true; - - $topic_type_array[] = array( - 'VALUE' => $topic_value['const'], - 'S_CHECKED' => ($cur_topic_type == $topic_value['const'] || ($forum_id == 0 && $topic_value['const'] == POST_GLOBAL)) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang[$topic_value['lang']] - ); - } - } - - if ($toggle) - { - $topic_type_array = array_merge(array(0 => array( - 'VALUE' => POST_NORMAL, - 'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '', - 'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])), - - $topic_type_array - ); - - foreach ($topic_type_array as $array) - { - $template->assign_block_vars('topic_type', $array); - } - - $template->assign_vars(array( - 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), - 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id))) - ); - } - - return $toggle; -} - /** * Generate inline attachment entry */ @@ -637,7 +654,7 @@ function posting_gen_attachment_entry(&$attachment_data, &$filename_data) 'ATTACH_ID' => $attach_row['attach_id'], 'ASSOC_INDEX' => $count, - 'U_VIEW_ATTACHMENT' => $download_link, + 'U_VIEW_ATTACHMENT' => $download_link, 'S_HIDDEN' => $hidden) ); @@ -653,12 +670,19 @@ function posting_gen_attachment_entry(&$attachment_data, &$filename_data) return sizeof($attachment_data); } +// +// General Post functions +// + /** * Load Drafts */ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) { - global $user, $db, $template, $phpEx, $SID, $auth; + global $user, $db, $template, $auth; + global $phpbb_root_path, $phpEx, $SID; + + $topic_ids = $draft_rows = array(); // Load those drafts not connected to forums/topics $sql = 'SELECT * @@ -675,7 +699,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) { $topic_ids[] = (int) $row['topic_id']; } - $draftrows[] = $row; + $draft_rows[] = $row; } $db->sql_freeresult($result); @@ -696,16 +720,18 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) { $topic_ids[] = (int) $row['topic_id']; } - $draftrows[] = $row; + $draft_rows[] = $row; } $db->sql_freeresult($result); } - if (!sizeof($draftrows)) + if (!sizeof($draft_rows)) { return; } + $topic_rows = array(); + if (sizeof($topic_ids)) { $sql = 'SELECT topic_id, forum_id, topic_title @@ -723,7 +749,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) $template->assign_var('S_SHOW_DRAFTS', true); - foreach ($draftrows as $draft) + foreach ($draft_rows as $draft) { $link_topic = $link_forum = $link_pm = false; $insert_url = $view_url = $title = ''; @@ -731,25 +757,25 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) if (isset($topic_rows[$draft['topic_id']]) && $auth->acl_get('f_read', $topic_rows[$draft['topic_id']]['forum_id'])) { $link_topic = true; - $view_url = "viewtopic.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&t=" . $draft['topic_id']; + $view_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . "&t=" . $draft['topic_id']; $title = $topic_rows[$draft['topic_id']]['topic_title']; - $insert_url = "posting.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']; + $insert_url = "{$phpbb_root_path}posting.$phpEx$SID&f=" . $topic_rows[$draft['topic_id']]['forum_id'] . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']; } else if ($auth->acl_get('f_read', $draft['forum_id'])) { $link_forum = true; - $view_url = "viewforum.$phpEx$SID&f=" . $draft['forum_id']; + $view_url = "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $draft['forum_id']; $title = $draft['forum_name']; - $insert_url = "posting.$phpEx$SID&f=" . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']; + $insert_url = "{$phpbb_root_path}posting.$phpEx$SID&f=" . $draft['forum_id'] . '&mode=post&d=' . $draft['draft_id']; } else { $link_pm = true; - $insert_url = "ucp.$phpEx$SID&i=$id&mode=compose&d=" . $draft['draft_id']; + $insert_url = "{$phpbb_root_path}ucp.$phpEx$SID&i=$id&mode=compose&d=" . $draft['draft_id']; } - + $template->assign_block_vars('draftrow', array( 'DRAFT_ID' => $draft['draft_id'], 'DATE' => $user->format_date($draft['save_time']), @@ -771,11 +797,11 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0) */ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { - global $user, $auth, $db, $template, $bbcode, $template; + global $user, $auth, $db, $template, $bbcode; global $config, $phpbb_root_path, $phpEx, $SID; // Go ahead and pull all data for this topic - $sql = 'SELECT u.username, u.user_id, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time + $sql = 'SELECT u.username, u.user_id, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id @@ -786,6 +812,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id if (!$row = $db->sql_fetchrow($result)) { + $db->sql_freeresult($result); return false; } @@ -914,8 +941,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id } $db->sql_freeresult($result); - // forum notification is sent to those not receiving post notification - if ($forum_notification) + // forum notification is sent to those not already receiving topic notifications + if ($topic_notification) { if (sizeof($notify_rows)) { @@ -953,6 +980,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id return; } + // Make sure users are allowed to read the forum foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) { foreach ($forum_ary as $auth_option => $user_ary) @@ -1038,7 +1066,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id // Handle the DB updates $db->sql_transaction(); - if (isset($update_notification['topic']) && sizeof($update_notification['topic'])) + if (!empty($update_notification['topic'])) { $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " SET notify_status = 1 @@ -1046,7 +1074,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"); } - if (isset($update_notification['forum']) && sizeof($update_notification['forum'])) + if (!empty($update_notification['forum'])) { $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " SET notify_status = 1 @@ -1055,14 +1083,14 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id } // Now delete the user_ids not authorized to receive notifications on this topic/forum - if (isset($delete_ids['topic']) && sizeof($delete_ids['topic'])) + if (!empty($delete_ids['topic'])) { $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " WHERE topic_id = $topic_id AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); } - if (isset($delete_ids['forum']) && sizeof($delete_ids['forum'])) + if (!empty($delete_ids['forum'])) { $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " WHERE forum_id = $forum_id @@ -1072,4 +1100,752 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id $db->sql_transaction('commit'); } +// +// Post handling functions +// + +/** +* Delete Post +*/ +function delete_post($forum_id, $topic_id, $post_id, &$data) +{ + global $db, $user, $auth; + global $config, $phpEx, $SID, $phpbb_root_path; + + // Specify our post mode + $post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'delete_topic' : (($data['topic_first_post_id'] == $post_id) ? 'delete_first_post' : (($data['topic_last_post_id'] == $post_id) ? 'delete_last_post' : 'delete')); + $sql_data = array(); + $next_post_id = 0; + + include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + + $db->sql_transaction(); + + if (!delete_posts('post_id', array($post_id), false)) + { + // Try to delete topic, we may had an previous error causing inconsistency + if ($post_mode = 'delete_topic') + { + delete_topics('topic_id', array($topic_id), false); + } + trigger_error('ALREADY_DELETED'); + } + + $db->sql_transaction('commit'); + + // Collect the necessary informations for updating the tables + $sql_data[FORUMS_TABLE] = ''; + switch ($post_mode) + { + case 'delete_topic': + delete_topics('topic_id', array($topic_id), false); + set_config('num_topics', $config['num_topics'] - 1, true); + + if ($data['topic_type'] != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE] .= 'forum_posts = forum_posts - 1, forum_topics_real = forum_topics_real - 1'; + $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''; + } + + $update_sql = update_post_information('forum', $forum_id, true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; + $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + } + + $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + break; + + case 'delete_first_post': + $sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username + FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u + WHERE p.topic_id = $topic_id + AND p.poster_id = u.user_id + ORDER BY p.post_time ASC"; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($data['topic_type'] != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; + } + + $sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; + $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + + $next_post_id = (int) $row['post_id']; + break; + + case 'delete_last_post': + if ($data['topic_type'] != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; + } + + $update_sql = update_post_information('forum', $forum_id, true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; + $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + } + + $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + + $update_sql = update_post_information('topic', $topic_id, true); + if (sizeof($update_sql)) + { + $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]); + $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]); + } + else + { + $sql = 'SELECT MAX(post_id) as last_post_id + FROM ' . POSTS_TABLE . " + WHERE topic_id = $topic_id " . + ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : ''); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $next_post_id = (int) $row['last_post_id']; + } + break; + + case 'delete': + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . " + WHERE topic_id = $topic_id " . + ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . ' + AND post_time > ' . $data['post_time'] . ' + ORDER BY post_time ASC'; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($data['topic_type'] != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; + } + + $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + $next_post_id = (int) $row['post_id']; + break; + } + + $sql_data[USERS_TABLE] = ($auth->acl_get('f_postcount', $forum_id)) ? 'user_posts = user_posts - 1' : ''; + set_config('num_posts', $config['num_posts'] - 1, true); + + $db->sql_transaction(); + + $where_sql = array( + FORUMS_TABLE => "forum_id = $forum_id", + TOPICS_TABLE => "topic_id = $topic_id", + USERS_TABLE => 'user_id = ' . $data['poster_id'] + ); + + foreach ($sql_data as $table => $update_sql) + { + if ($update_sql) + { + $db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]); + } + } + + $db->sql_transaction('commit'); + + return $next_post_id; +} + +/** +* Submit Post +*/ +function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true) +{ + global $db, $auth, $user, $config, $phpEx, $SID, $template, $phpbb_root_path; + + // We do not handle erasing posts here + if ($mode == 'delete') + { + return; + } + + $current_time = time(); + + if ($mode == 'post') + { + $post_mode = 'post'; + $update_message = true; + } + else if ($mode != 'edit') + { + $post_mode = 'reply'; + $update_message = true; + } + else if ($mode == 'edit') + { + $post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit')); + } + + // Collect some basic informations about which tables and which rows to update/insert + $sql_data = array(); + $poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id']; + + // Collect Informations + switch ($post_mode) + { + case 'post': + case 'reply': + $sql_data[POSTS_TABLE]['sql'] = array( + 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'poster_id' => (int) $user->data['user_id'], + 'icon_id' => $data['icon_id'], + 'poster_ip' => $user->ip, + 'post_time' => $current_time, + 'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, + 'enable_bbcode' => $data['enable_bbcode'], + 'enable_smilies' => $data['enable_smilies'], + 'enable_magic_url' => $data['enable_urls'], + 'enable_sig' => $data['enable_sig'], + 'post_username' => (!$user->data['is_registered']) ? $username : '', + 'post_subject' => $subject, + 'post_text' => $data['message'], + 'post_checksum' => $data['message_md5'], + 'post_encoding' => $user->lang['ENCODING'], + 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0, + 'bbcode_bitfield' => $data['bbcode_bitfield'], + 'bbcode_uid' => $data['bbcode_uid'], + 'post_edit_locked' => $data['post_edit_locked'] + ); + break; + + case 'edit_first_post': + case 'edit': + + if (!$auth->acl_gets('m_', 'a_') || $data['post_edit_reason']) + { + $sql_data[POSTS_TABLE]['sql'] = array( + 'post_edit_time' => $current_time + ); + + $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; + } + + // no break + + case 'edit_last_post': + case 'edit_topic': + + if (($post_mode == 'edit_last_post' || $post_mode == 'edit_topic') && $data['post_edit_reason']) + { + $sql_data[POSTS_TABLE]['sql'] = array( + 'post_edit_time' => $current_time + ); + + $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; + } + + if (!isset($sql_data[POSTS_TABLE]['sql'])) + { + $sql_data[POSTS_TABLE]['sql'] = array(); + } + + $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( + 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'poster_id' => $data['poster_id'], + 'icon_id' => $data['icon_id'], + 'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, + 'enable_bbcode' => $data['enable_bbcode'], + 'enable_smilies' => $data['enable_smilies'], + 'enable_magic_url' => $data['enable_urls'], + 'enable_sig' => $data['enable_sig'], + 'post_username' => ($username && $data['poster_id'] == ANONYMOUS) ? $username : '', + 'post_subject' => $subject, + 'post_edit_reason' => $data['post_edit_reason'], + 'post_edit_user' => (int) $data['post_edit_user'], + 'post_checksum' => $data['message_md5'], + 'post_encoding' => $user->lang['ENCODING'], + 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0, + 'bbcode_bitfield' => $data['bbcode_bitfield'], + 'bbcode_uid' => $data['bbcode_uid'], + 'post_edit_locked' => $data['post_edit_locked']) + ); + + if ($update_message) + { + $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message']; + } + + break; + } + + // And the topic ladies and gentlemen + switch ($post_mode) + { + case 'post': + $sql_data[TOPICS_TABLE]['sql'] = array( + 'topic_poster' => (int) $user->data['user_id'], + 'topic_time' => $current_time, + 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'icon_id' => $data['icon_id'], + 'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, + 'topic_title' => $subject, + 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), + 'topic_type' => $topic_type, + 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, + 'topic_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0 + ); + + if (isset($poll['poll_options']) && !empty($poll['poll_options'])) + { + $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( + 'poll_title' => $poll['poll_title'], + 'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time, + 'poll_max_options' => $poll['poll_max_options'], + 'poll_length' => ($poll['poll_length'] * 86400), + 'poll_vote_change' => $poll['poll_vote_change']) + ); + } + + $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : ''); + + if ($topic_type != POST_GLOBAL) + { + if (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) + { + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; + } + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? ', forum_topics = forum_topics + 1' : ''); + } + break; + + case 'reply': + $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? ', topic_replies = topic_replies + 1' : ''); + $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : ''); + + if ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) && $topic_type != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; + } + break; + + case 'edit_topic': + case 'edit_first_post': + + $sql_data[TOPICS_TABLE]['sql'] = array( + 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], + 'icon_id' => $data['icon_id'], + 'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, + 'topic_title' => $subject, + 'topic_first_poster_name' => $username, + 'topic_type' => $topic_type, + 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, + 'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '', + 'poll_start' => (isset($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time) : 0, + 'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1, + 'poll_length' => (isset($poll['poll_options'])) ? ($poll['poll_length'] * 86400) : 0, + 'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0, + + 'topic_attachment' => ($post_mode == 'edit_topic') ? ((isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0) : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0) + ); + break; + } + + $db->sql_transaction(); + + // Submit new topic + if ($post_mode == 'post') + { + $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . + $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); + $db->sql_query($sql); + + $data['topic_id'] = $db->sql_nextid(); + + $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( + 'topic_id' => $data['topic_id']) + ); + unset($sql_data[TOPICS_TABLE]['sql']); + } + + // Submit new post + if ($post_mode == 'post' || $post_mode == 'reply') + { + if ($post_mode == 'reply') + { + $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( + 'topic_id' => $data['topic_id']) + ); + } + + $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . + $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); + $db->sql_query($sql); + $data['post_id'] = $db->sql_nextid(); + + if ($post_mode == 'post') + { + $sql_data[TOPICS_TABLE]['sql'] = array( + 'topic_first_post_id' => $data['post_id'], + 'topic_last_post_id' => $data['post_id'], + 'topic_last_post_time' => $current_time, + 'topic_last_poster_id' => (int) $user->data['user_id'], + 'topic_last_poster_name'=> (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '') + ); + } + + unset($sql_data[POSTS_TABLE]['sql']); + } + + $make_global = false; + + // Are we globalising or unglobalising? + if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic') + { + $sql = 'SELECT topic_type, topic_replies_real, topic_approved + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $data['topic_id']; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + // globalise + if ($row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) + { + // Decrement topic/post count + $make_global = true; + $sql_data[FORUMS_TABLE]['stat'] = array(); + + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($row['topic_replies_real'] + 1); + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''); + + // Update forum_ids for all posts + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET forum_id = 0 + WHERE topic_id = ' . $data['topic_id']; + $db->sql_query($sql); + } + // unglobalise + else if ($row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) + { + // Increment topic/post count + $make_global = true; + $sql_data[FORUMS_TABLE]['stat'] = array(); + + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($row['topic_replies_real'] + 1); + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics + 1' : ''); + + // Update forum_ids for all posts + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET forum_id = ' . $data['forum_id'] . ' + WHERE topic_id = ' . $data['topic_id']; + $db->sql_query($sql); + } + } + + // Update the topics table + if (isset($sql_data[TOPICS_TABLE]['sql'])) + { + $db->sql_query('UPDATE ' . TOPICS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' + WHERE topic_id = ' . $data['topic_id']); + } + + // Update the posts table + if (isset($sql_data[POSTS_TABLE]['sql'])) + { + $db->sql_query('UPDATE ' . POSTS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' + WHERE post_id = ' . $data['post_id']); + } + + // Update Poll Tables + if (isset($poll['poll_options']) && !empty($poll['poll_options'])) + { + $cur_poll_options = array(); + + if ($poll['poll_start'] && $mode == 'edit') + { + $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' + WHERE topic_id = ' . $data['topic_id'] . ' + ORDER BY poll_option_id'; + $result = $db->sql_query($sql); + + $cur_poll_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $cur_poll_options[] = $row; + } + $db->sql_freeresult($result); + } + + $sql_insert_ary = array(); + for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++) + { + if (trim($poll['poll_options'][$i])) + { + if (!$cur_poll_options[$i]) + { + $sql_insert_ary[] = array( + 'poll_option_id' => (int) $i, + 'topic_id' => (int) $data['topic_id'], + 'poll_option_text' => (string) $poll['poll_options'][$i] + ); + } + else if ($poll['poll_options'][$i] != $cur_poll_options[$i]) + { + $sql = "UPDATE " . POLL_OPTIONS_TABLE . " + SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "' + WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . " + AND topic_id = " . $data['topic_id']; + $db->sql_query($sql); + } + } + } + + if (sizeof($sql_insert_ary)) + { + switch (SQL_LAYER) + { + case 'mysql': + case 'mysql4': + case 'mysqli': + $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_insert_ary)); + break; + + default: + foreach ($sql_insert_ary as $ary) + { + $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary)); + } + break; + } + } + + if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) + { + $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' + WHERE poll_option_id >= ' . sizeof($poll['poll_options']) . ' + AND topic_id = ' . $data['topic_id']; + $db->sql_query($sql); + } + } + + // Submit Attachments + if (sizeof($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) + { + $space_taken = $files_added = 0; + + foreach ($data['attachment_data'] as $pos => $attach_row) + { + if ($attach_row['attach_id']) + { + // update entry in db if attachment already stored in db and filespace + $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " + SET comment = '" . $db->sql_escape($attach_row['comment']) . "' + WHERE attach_id = " . (int) $attach_row['attach_id']; + $db->sql_query($sql); + } + else + { + // insert attachment into db + if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($attach_row['physical_filename']))) + { + continue; + } + + $attach_sql = array( + 'post_msg_id' => $data['post_id'], + 'topic_id' => $data['topic_id'], + 'in_message' => 0, + 'poster_id' => $poster_id, + 'physical_filename' => basename($attach_row['physical_filename']), + 'real_filename' => basename($attach_row['real_filename']), + 'comment' => $attach_row['comment'], + 'extension' => $attach_row['extension'], + 'mimetype' => $attach_row['mimetype'], + 'filesize' => $attach_row['filesize'], + 'filetime' => $attach_row['filetime'], + 'thumbnail' => $attach_row['thumbnail'] + ); + + $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . + $db->sql_build_array('INSERT', $attach_sql); + $db->sql_query($sql); + + $space_taken += $attach_row['filesize']; + $files_added++; + } + } + + if (sizeof($data['attachment_data'])) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_attachment = 1 + WHERE post_id = ' . $data['post_id']; + $db->sql_query($sql); + + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_attachment = 1 + WHERE topic_id = ' . $data['topic_id']; + $db->sql_query($sql); + } + + set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true); + set_config('num_files', $config['num_files'] + $files_added, true); + } + + $db->sql_transaction('commit'); + + if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post') + { + if ($topic_type != POST_GLOBAL) + { + $update_sql = update_post_information('forum', $data['forum_id'], true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]); + } + } + + $update_sql = update_post_information('topic', $data['topic_id'], true); + if (sizeof($update_sql)) + { + $sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]); + } + } + + if ($make_global) + { + $update_sql = update_post_information('forum', $data['forum_id'], true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]); + } + } + + if ($post_mode == 'edit_topic') + { + $update_sql = update_post_information('topic', $data['topic_id'], true); + if (sizeof($update_sql)) + { + $sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]); + } + } + + // Update total post count, do not consider moderated posts/topics + if (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) + { + if ($post_mode == 'post') + { + set_config('num_topics', $config['num_topics'] + 1, true); + set_config('num_posts', $config['num_posts'] + 1, true); + } + + if ($post_mode == 'reply') + { + set_config('num_posts', $config['num_posts'] + 1, true); + } + } + + // Update forum stats + $db->sql_transaction(); + + $where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $user->data['user_id']); + + foreach ($sql_data as $table => $update_ary) + { + if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) + { + $db->sql_query("UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]); + } + } + + // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement + if ($make_global) + { + $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' + WHERE topic_moved_id = ' . $data['topic_id']); + } + + // Index message contents + if ($update_message && $data['enable_indexing']) + { + // Select the search method and do some additional checks to ensure it can actually be utilised + $search_type = $config['search_type']; + + if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + { + trigger_error('NO_SUCH_SEARCH_MODULE'); + } + + require("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + + $error = false; + $search = new $search_type($error); + + if ($error) + { + trigger_error($error); + } + + $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id); + } + + $db->sql_transaction('commit'); + + // Delete draft if post was loaded... + $draft_id = request_var('draft_loaded', 0); + if ($draft_id) + { + $db->sql_query('DELETE FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id AND user_id = " . $user->data['user_id']); + } + + // Topic Notification, do not change if moderator is changing other users posts... + if ($user->data['user_id'] == $poster_id) + { + if (!$data['notify_set'] && $data['notify']) + { + $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) + VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')'; + $db->sql_query($sql); + } + else if ($data['notify_set'] && !$data['notify']) + { + $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' + WHERE user_id = ' . $user->data['user_id'] . ' + AND topic_id = ' . $data['topic_id']; + $db->sql_query($sql); + } + } + + if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') + { + // Mark this topic as posted to + markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']); + } + + // Mark this topic as read + // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) + markread('topic', $data['forum_id'], $data['topic_id'], time()); + + // Send Notifications + if ($mode != 'edit' && $mode != 'delete' && (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id']))) + { + user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']); + } + + if ($mode == 'post') + { + $url = (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $data['forum_id'] . '&t=' . $data['topic_id'] : "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $data['forum_id']; + } + else + { + $url = (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f={$data['forum_id']}&t={$data['topic_id']}&p={$data['post_id']}#p{$data['post_id']}" : "{$phpbb_root_path}viewtopic.$phpEx$SID&f={$data['forum_id']}&t={$data['topic_id']}"; + } + + return $url; +} + ?> \ No newline at end of file diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 8d1ed1f41d..073d434839 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -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']; diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index b722549720..533f7b9ef7 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -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]; } diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 2c40e07e64..948d345ea5 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -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'])) ); diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index ddb783e4b7..4d940b749e 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -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(=".*?")?\]([^\n])#is', '#([^\n])\[\/quote\]#is'), array("[quote\\1]\n\\2", "\\1\n[/quote]"), $in); $in = preg_replace(array('#\[quote(=".*?")?\]([^\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(']', '['), $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(']', '['), $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]'; } } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 6571ff1433..73d9c83374 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -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 diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 3ca3a8acbd..9ba7086913 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -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) diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index b8642ca69d..1806fc4d94 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -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': diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 45cd22a13c..7c06895494 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -512,7 +512,7 @@ function compose_pm($id, $mode, $action) trigger_error($message); } - $message_subject = stripslashes($subject); + $message_subject = $subject; } // Preview diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 9e04caf41f..40d530f808 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -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); diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index dc6ef0f423..f0cf9a21dc 100755 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -929,30 +929,24 @@ class install_install extends module { case 'mssql': case 'mssql_odbc': - $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2', $sql_query); + $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query); break; case 'postgres': $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query); - // Some versions of PGSQL don't like remarks, lets remove them. - remove_remarks($sql_query); break; case 'firebird': $sql_query = str_replace('module_name', '"module_name"', $sql_query); break; - case 'oracle': - remove_remarks($sql_query); - break; - default: - //$sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', '', $sql_query); } $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); - $remove_remarks($sql_query); + // Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks + remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $sql) @@ -1131,6 +1125,9 @@ class install_install extends module 'module_langname' => $cat_name, 'module_mode' => '', 'module_auth' => '', + + 'left_id' => 0, + 'right_id' => 0, ); $sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $module_data); @@ -1155,6 +1152,9 @@ class install_install extends module 'module_langname' => $level2_name, 'module_mode' => '', 'module_auth' => '', + + 'left_id' => 0, + 'right_id' => 0, ); $sql = 'INSERT INTO ' . MODULES_TABLE . ' ' . $db->sql_build_array('INSERT', $module_data); @@ -1189,6 +1189,9 @@ class install_install extends module 'module_langname' => $row['title'], 'module_mode' => $module_mode, 'module_auth' => $row['auth'], + + 'left_id' => 0, + 'right_id' => 0, ); // $_module->update_module_data($module_data); diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 9872d96d00..c7121d8a6d 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -616,19 +616,19 @@ CREATE TABLE phpbb_posts ( enable_smilies INTEGER DEFAULT 1 NOT NULL, enable_magic_url INTEGER DEFAULT 1 NOT NULL, enable_sig INTEGER DEFAULT 1 NOT NULL, - post_username VARCHAR(255), - post_subject BLOB SUB_TYPE TEXT, - post_text BLOB SUB_TYPE TEXT, + post_username VARCHAR(255) NULL, + post_subject BLOB SUB_TYPE TEXT NOT NULL, + post_text BLOB SUB_TYPE TEXT NOT NULL, post_checksum VARCHAR(32) NOT NULL, post_encoding VARCHAR(20) DEFAULT 'iso-8859-1' NOT NULL, post_attachment INTEGER DEFAULT 0 NOT NULL, bbcode_bitfield INTEGER DEFAULT 0 NOT NULL, bbcode_uid VARCHAR(5) NOT NULL, - post_edit_time INTEGER DEFAULT 0 NOT NULL, - post_edit_reason BLOB SUB_TYPE TEXT, - post_edit_user INTEGER DEFAULT 0 NOT NULL, - post_edit_count INTEGER DEFAULT 0 NOT NULL, - post_edit_locked INTEGER DEFAULT 0 NOT NULL + post_edit_time INTEGER DEFAULT 0 NULL, + post_edit_reason BLOB SUB_TYPE TEXT NULL, + post_edit_user INTEGER DEFAULT 0 NULL, + post_edit_count INTEGER DEFAULT 0 NULL, + post_edit_locked INTEGER DEFAULT 0 NULL );; ALTER TABLE phpbb_posts ADD PRIMARY KEY (post_id);; @@ -999,7 +999,7 @@ END;; # phpbb_smilies CREATE TABLE phpbb_smilies ( smiley_id INTEGER NOT NULL, - code VARCHAR(10), + code VARCHAR(50), emotion VARCHAR(50), smiley_url VARCHAR(50), smiley_width INTEGER DEFAULT 0 NOT NULL, @@ -1156,7 +1156,7 @@ CREATE TABLE phpbb_styles_template ( template_name VARCHAR(252) NOT NULL, template_copyright VARCHAR(255) NOT NULL, template_path VARCHAR(100) NOT NULL, - bbcode_bitfield INTEGER DEFAULT 0 NOT NULL, + bbcode_bitfield INTEGER DEFAULT 6921 NOT NULL, template_storedb INTEGER DEFAULT 0 NOT NULL );; @@ -1319,24 +1319,24 @@ CREATE TABLE phpbb_users ( user_id INTEGER NOT NULL, user_type INTEGER DEFAULT 0 NOT NULL, group_id INTEGER DEFAULT 3 NOT NULL, - user_permissions BLOB SUB_TYPE TEXT, - user_perm_from INTEGER DEFAULT 0 NOT NULL, + user_permissions BLOB SUB_TYPE TEXT NULL, + user_perm_from INTEGER DEFAULT 0 NULL, user_ip VARCHAR(40) NOT NULL, user_regdate INTEGER DEFAULT 0 NOT NULL, username VARCHAR(252) NOT NULL, user_password VARCHAR(40) NOT NULL, - user_passchg INTEGER DEFAULT 0 NOT NULL, + user_passchg INTEGER DEFAULT 0 NULL, user_email VARCHAR(100) NOT NULL, user_email_hash DOUBLE PRECISION DEFAULT 0 NOT NULL, - user_birthday VARCHAR(10) NOT NULL, + user_birthday VARCHAR(10) NULL, user_lastvisit INTEGER DEFAULT 0 NOT NULL, user_lastmark INTEGER DEFAULT 0 NOT NULL, user_lastpost_time INTEGER DEFAULT 0 NOT NULL, user_lastpage VARCHAR(200) NOT NULL, - user_last_confirm_key VARCHAR(10) NOT NULL, - user_warnings INTEGER DEFAULT 0 NOT NULL, - user_last_warning INTEGER DEFAULT 0 NOT NULL, - user_login_attempts INTEGER DEFAULT 0 NOT NULL, + user_last_confirm_key VARCHAR(10) NULL, + user_warnings INTEGER DEFAULT 0 NULL, + user_last_warning INTEGER DEFAULT 0 NULL, + user_login_attempts INTEGER DEFAULT 0 NULL, user_posts INTEGER DEFAULT 0 NOT NULL, user_lang VARCHAR(30) NOT NULL, user_timezone DOUBLE PRECISION DEFAULT 0 NOT NULL, @@ -1370,20 +1370,20 @@ CREATE TABLE phpbb_users ( user_avatar_type INTEGER DEFAULT 0 NOT NULL, user_avatar_width INTEGER DEFAULT 0 NOT NULL, user_avatar_height INTEGER DEFAULT 0 NOT NULL, - user_sig BLOB SUB_TYPE TEXT, - user_sig_bbcode_uid VARCHAR(5) NOT NULL, - user_sig_bbcode_bitfield INTEGER DEFAULT 0 NOT NULL, - user_from VARCHAR(100) NOT NULL, - user_icq VARCHAR(15) NOT NULL, - user_aim VARCHAR(255) NOT NULL, - user_yim VARCHAR(255) NOT NULL, - user_msnm VARCHAR(255) NOT NULL, - user_jabber VARCHAR(255) NOT NULL, - user_website VARCHAR(200) NOT NULL, - user_occ VARCHAR(255) NOT NULL, - user_interests VARCHAR(255) NOT NULL, + user_sig BLOB SUB_TYPE TEXT NULL, + user_sig_bbcode_uid VARCHAR(5) NULL, + user_sig_bbcode_bitfield INTEGER DEFAULT 0 NULL, + user_from VARCHAR(100) NULL, + user_icq VARCHAR(15) NULL, + user_aim VARCHAR(255) NULL, + user_yim VARCHAR(255) NULL, + user_msnm VARCHAR(255) NULL, + user_jabber VARCHAR(255) NULL, + user_website VARCHAR(200) NULL, + user_occ VARCHAR(255) NULL, + user_interests VARCHAR(255) NULL, user_actkey VARCHAR(32) NOT NULL, - user_newpasswd VARCHAR(32) NOT NULL + user_newpasswd VARCHAR(32) NULL );; ALTER TABLE phpbb_users ADD PRIMARY KEY (user_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 66f2261b57..a1308f1c5a 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -934,18 +934,18 @@ CREATE TABLE [phpbb_posts] ( [enable_magic_url] [int] NOT NULL , [enable_sig] [int] NOT NULL , [post_username] [varchar] (255) NULL , - [post_subject] [text] , - [post_text] [text] , + [post_subject] [text] NOT NULL , + [post_text] [text] NOT NULL , [post_checksum] [varchar] (32) NOT NULL , [post_encoding] [varchar] (20) NOT NULL , [post_attachment] [int] NOT NULL , [bbcode_bitfield] [int] NOT NULL , [bbcode_uid] [varchar] (5) NOT NULL , - [post_edit_time] [int] NOT NULL , - [post_edit_reason] [text] , - [post_edit_user] [int] NOT NULL , - [post_edit_count] [int] NOT NULL , - [post_edit_locked] [int] NOT NULL + [post_edit_time] [int] NULL , + [post_edit_reason] [text] NULL, + [post_edit_user] [int] NULL , + [post_edit_count] [int] NULL , + [post_edit_locked] [int] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO @@ -1533,7 +1533,7 @@ GO */ CREATE TABLE [phpbb_smilies] ( [smiley_id] [int] IDENTITY (1, 1) NOT NULL , - [code] [varchar] (10) NULL , + [code] [varchar] (50) NULL , [emotion] [varchar] (50) NULL , [smiley_url] [varchar] (50) NULL , [smiley_width] [int] NOT NULL , @@ -1719,7 +1719,7 @@ ALTER TABLE [phpbb_styles_template] WITH NOCHECK ADD GO ALTER TABLE [phpbb_styles_template] WITH NOCHECK ADD - CONSTRAINT [DF_phpbb_templa_bbcode_bitfield] DEFAULT (0) FOR [bbcode_bitfield], + CONSTRAINT [DF_phpbb_templa_bbcode_bitfield] DEFAULT (6921) FOR [bbcode_bitfield], CONSTRAINT [DF_phpbb_templa_template_storedb] DEFAULT (0) FOR [template_storedb] GO @@ -1981,24 +1981,24 @@ CREATE TABLE [phpbb_users] ( [user_id] [int] IDENTITY (1, 1) NOT NULL , [user_type] [int] NOT NULL , [group_id] [int] NOT NULL , - [user_permissions] [text] , - [user_perm_from] [int] NOT NULL , + [user_permissions] [text] NULL , + [user_perm_from] [int] NULL , [user_ip] [varchar] (40) NOT NULL , [user_regdate] [int] NOT NULL , [username] [varchar] (255) NOT NULL , [user_password] [varchar] (32) NOT NULL , - [user_passchg] [int] NOT NULL , + [user_passchg] [int] NULL , [user_email] [varchar] (100) NOT NULL , [user_email_hash] [float] NOT NULL , - [user_birthday] [varchar] (10) NOT NULL , + [user_birthday] [varchar] (10) NULL , [user_lastvisit] [int] NOT NULL , [user_lastmark] [int] NOT NULL , [user_lastpost_time] [int] NOT NULL , [user_lastpage] [varchar] (200) NOT NULL , - [user_last_confirm_key] [varchar] (10) NOT NULL , - [user_warnings] [int] NOT NULL , - [user_last_warning] [int] NOT NULL , - [user_login_attempts] [int] NOT NULL , + [user_last_confirm_key] [varchar] (10) NULL , + [user_warnings] [int] NULL , + [user_last_warning] [int] NULL , + [user_login_attempts] [int] NULL , [user_posts] [int] NOT NULL , [user_lang] [varchar] (30) NOT NULL , [user_timezone] [float] NOT NULL , @@ -2032,20 +2032,20 @@ CREATE TABLE [phpbb_users] ( [user_avatar_type] [int] NOT NULL , [user_avatar_width] [int] NOT NULL , [user_avatar_height] [int] NOT NULL , - [user_sig] [text] , - [user_sig_bbcode_uid] [varchar] (5) NOT NULL , - [user_sig_bbcode_bitfield] [int] NOT NULL , - [user_from] [varchar] (100) NOT NULL , - [user_icq] [varchar] (15) NOT NULL , - [user_aim] [varchar] (255) NOT NULL , - [user_yim] [varchar] (255) NOT NULL , - [user_msnm] [varchar] (255) NOT NULL , - [user_jabber] [varchar] (255) NOT NULL , - [user_website] [varchar] (200) NOT NULL , - [user_occ] [varchar] (255) NOT NULL , - [user_interests] [varchar] (255) NOT NULL , + [user_sig] [text] NULL , + [user_sig_bbcode_uid] [varchar] (5) NULL , + [user_sig_bbcode_bitfield] [int] NULL , + [user_from] [varchar] (100) NULL , + [user_icq] [varchar] (15) NULL , + [user_aim] [varchar] (255) NULL , + [user_yim] [varchar] (255) NULL , + [user_msnm] [varchar] (255) NULL , + [user_jabber] [varchar] (255) NULL , + [user_website] [varchar] (200) NULL , + [user_occ] [varchar] (255) NULL , + [user_interests] [varchar] (255) NULL , [user_actkey] [varchar] (32) NOT NULL , - [user_newpasswd] [varchar] (32) NOT NULL + [user_newpasswd] [varchar] (32) NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index 1e02aea031..ce43ba56ad 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -401,19 +401,19 @@ CREATE TABLE phpbb_posts ( enable_smilies tinyint(1) DEFAULT '1' NOT NULL, enable_magic_url tinyint(1) DEFAULT '1' NOT NULL, enable_sig tinyint(1) DEFAULT '1' NOT NULL, - post_username varchar(255), - post_subject text, - post_text mediumtext, + post_username varchar(255) NULL, + post_subject text NOT NULL, + post_text mediumtext NOT NULL, post_checksum varchar(32) NOT NULL, post_encoding varchar(20) DEFAULT 'iso-8859-1' NOT NULL, post_attachment tinyint(1) DEFAULT '0' NOT NULL, bbcode_bitfield int(11) UNSIGNED DEFAULT '0' NOT NULL, bbcode_uid varchar(5) DEFAULT '' NOT NULL, - post_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_reason text, - post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_count smallint(5) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_time int(11) UNSIGNED DEFAULT '0' NULL, + post_edit_reason text NULL, + post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NULL, + post_edit_count smallint(5) UNSIGNED DEFAULT '0' NULL, + post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NULL, PRIMARY KEY (post_id), KEY forum_id (forum_id), KEY topic_id (topic_id), @@ -642,7 +642,7 @@ CREATE TABLE phpbb_sitelist ( # Table: 'phpbb_smilies' CREATE TABLE phpbb_smilies ( smiley_id tinyint(4) UNSIGNED NOT NULL auto_increment, - code varchar(10), + code varchar(50), emotion varchar(50), smiley_url varchar(50), smiley_width tinyint(4) UNSIGNED NOT NULL, @@ -674,7 +674,7 @@ CREATE TABLE phpbb_styles_template ( template_name varchar(255) NOT NULL, template_copyright varchar(255) NOT NULL, template_path varchar(100) NOT NULL, - bbcode_bitfield int(11) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_bitfield int(11) UNSIGNED DEFAULT '6921' NOT NULL, template_storedb tinyint(1) DEFAULT '0' NOT NULL, PRIMARY KEY (template_id), UNIQUE template_name (template_name) @@ -874,31 +874,31 @@ CREATE TABLE phpbb_users ( user_id mediumint(8) UNSIGNED NOT NULL auto_increment, user_type tinyint(1) DEFAULT '0' NOT NULL, group_id mediumint(8) DEFAULT '3' NOT NULL, - user_permissions text, + user_permissions text NULL, user_perm_from mediumint(8) DEFAULT '0' NOT NULL, user_ip varchar(40) DEFAULT '' NOT NULL, user_regdate int(11) DEFAULT '0' NOT NULL, username varchar(255) DEFAULT '' NOT NULL, user_password varchar(40) DEFAULT '' NOT NULL, - user_passchg int(11) DEFAULT '0' NOT NULL, + user_passchg int(11) DEFAULT '0' NULL, user_email varchar(100) DEFAULT '' NOT NULL, user_email_hash bigint(20) DEFAULT '0' NOT NULL, - user_birthday varchar(10) DEFAULT '' NOT NULL, + user_birthday varchar(10) DEFAULT '' NULL, user_lastvisit int(11) DEFAULT '0' NOT NULL, user_lastmark int(11) DEFAULT '0' NOT NULL, user_lastpost_time int(11) DEFAULT '0' NOT NULL, user_lastpage varchar(200) DEFAULT '' NOT NULL, - user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, - user_warnings tinyint(4) DEFAULT '0' NOT NULL, - user_last_warning int(11) DEFAULT '0' NOT NULL, - user_login_attempts smallint(4) DEFAULT '0' NOT NULL, + user_last_confirm_key varchar(10) DEFAULT '' NULL, + user_warnings tinyint(4) DEFAULT '0' NULL, + user_last_warning int(11) DEFAULT '0' NULL, + user_login_attempts smallint(4) DEFAULT '0' NULL, user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_lang varchar(30) DEFAULT '' NOT NULL, user_timezone decimal(5,2) DEFAULT '0.0' NOT NULL, user_dst tinyint(1) DEFAULT '0' NOT NULL, user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, user_style tinyint(4) DEFAULT '0' NOT NULL, - user_rank int(11) DEFAULT '0', + user_rank int(11) DEFAULT '0' NULL, user_colour varchar(6) DEFAULT '' NOT NULL, user_new_privmsg tinyint(4) UNSIGNED DEFAULT '0' NOT NULL, user_unread_privmsg tinyint(4) UNSIGNED DEFAULT '0' NOT NULL, @@ -925,20 +925,20 @@ CREATE TABLE phpbb_users ( user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, user_avatar_width tinyint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height tinyint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_sig text, - user_sig_bbcode_uid varchar(5) DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield int(11) DEFAULT '0' NOT NULL, - user_from varchar(100) DEFAULT '' NOT NULL, - user_icq varchar(15) DEFAULT '' NOT NULL, - user_aim varchar(255) DEFAULT '' NOT NULL, - user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, - user_jabber varchar(255) DEFAULT '' NOT NULL, - user_website varchar(200) DEFAULT '' NOT NULL, - user_occ varchar(255) DEFAULT '' NOT NULL, - user_interests varchar(255) DEFAULT '' NOT NULL, + user_sig text NULL, + user_sig_bbcode_uid varchar(5) DEFAULT '' NULL, + user_sig_bbcode_bitfield int(11) DEFAULT '0' NULL, + user_from varchar(100) DEFAULT '' NULL, + user_icq varchar(15) DEFAULT '' NULL, + user_aim varchar(255) DEFAULT '' NULL, + user_yim varchar(255) DEFAULT '' NULL, + user_msnm varchar(255) DEFAULT '' NULL, + user_jabber varchar(255) DEFAULT '' NULL, + user_website varchar(200) DEFAULT '' NULL, + user_occ varchar(255) DEFAULT '' NULL, + user_interests varchar(255) DEFAULT '' NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, - user_newpasswd varchar(32) DEFAULT '' NOT NULL, + user_newpasswd varchar(32) DEFAULT '' NULL, PRIMARY KEY (user_id), KEY user_birthday (user_birthday(6)), KEY user_email_hash (user_email_hash), diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 12d194c555..aafe403405 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -828,7 +828,7 @@ CREATE TABLE phpbb_posts ( forum_id number(5) DEFAULT '0' NOT NULL, poster_id number(8) DEFAULT '0' NOT NULL, icon_id number(4) DEFAULT '0' NOT NULL, - poster_ip varchar2(40), + poster_ip varchar2(40) NOT NULL, post_time number(11) DEFAULT '0' NOT NULL, post_approved number(1) DEFAULT '1' NOT NULL, post_reported number(1) DEFAULT '0' NOT NULL, @@ -836,19 +836,19 @@ CREATE TABLE phpbb_posts ( enable_smilies number(1) DEFAULT '1' NOT NULL, enable_magic_url number(1) DEFAULT '1' NOT NULL, enable_sig number(1) DEFAULT '1' NOT NULL, - post_username varchar2(255), - post_subject varchar2(1000), - post_text clob, - post_checksum varchar2(32), - post_encoding varchar2(20) DEFAULT 'iso-8859-1', + post_username varchar2(255) NULL, + post_subject varchar2(1000) NOT NULL, + post_text clob NOT NULL, + post_checksum varchar2(32) NOT NULL, + post_encoding varchar2(20) DEFAULT 'iso-8859-1' NOT NULL, post_attachment number(1) DEFAULT '0' NOT NULL, bbcode_bitfield number(11) DEFAULT '0' NOT NULL, - bbcode_uid varchar2(5) DEFAULT '', - post_edit_time number(11) DEFAULT '0' NOT NULL, - post_edit_reason varchar2(1000), - post_edit_user number(8) DEFAULT '0' NOT NULL, - post_edit_count number(5) DEFAULT '0' NOT NULL, - post_edit_locked number(1) DEFAULT '0' NOT NULL, + bbcode_uid varchar2(5) DEFAULT '' NOT NULL, + post_edit_time number(11) DEFAULT '0' NULL, + post_edit_reason varchar2(1000) NULL, + post_edit_user number(8) DEFAULT '0' NULL, + post_edit_count number(5) DEFAULT '0' NULL, + post_edit_locked number(1) DEFAULT '0' NULL, CONSTRAINT pk_phpbb_posts PRIMARY KEY (post_id) ) / @@ -1328,7 +1328,7 @@ END; */ CREATE TABLE phpbb_smilies ( smiley_id number(4) NOT NULL, - code varchar2(10), + code varchar2(50), emotion varchar2(50), smiley_url varchar2(50), smiley_width number(4) NOT NULL, @@ -1402,7 +1402,7 @@ CREATE TABLE phpbb_styles_template ( template_name varchar2(255), template_copyright varchar2(255), template_path varchar2(100), - bbcode_bitfield number(11) DEFAULT '0' NOT NULL, + bbcode_bitfield number(11) DEFAULT '6921' NOT NULL, template_storedb number(1) DEFAULT '0' NOT NULL, CONSTRAINT pk_phpbb_styles_template PRIMARY KEY (template_id), CONSTRAINT u_template_name UNIQUE (template_name) @@ -1715,32 +1715,32 @@ CREATE TABLE phpbb_users ( user_id number(8) NOT NULL, user_type number(1) DEFAULT '0' NOT NULL, group_id number(8) DEFAULT '3' NOT NULL, - user_permissions clob, - user_perm_from number(8) DEFAULT '0' NOT NULL, - user_ip varchar2(40) DEFAULT '', + user_permissions clob NULL, + user_perm_from number(8) DEFAULT '0' NULL, + user_ip varchar2(40) DEFAULT '' NOT NULL, user_regdate number(11) DEFAULT '0' NOT NULL, - username varchar2(255) DEFAULT '', - user_password varchar2(40) DEFAULT '', - user_passchg number(11) DEFAULT '0' NOT NULL, - user_email varchar2(100) DEFAULT '', + username varchar2(255) DEFAULT '' NOT NULL, + user_password varchar2(40) DEFAULT '' NOT NULL, + user_passchg number(11) DEFAULT '0' NULL, + user_email varchar2(100) DEFAULT '' NOT NULL, user_email_hash number(20) DEFAULT '0' NOT NULL, - user_birthday varchar2(10) DEFAULT '', + user_birthday varchar2(10) DEFAULT '' NULL, user_lastvisit number(11) DEFAULT '0' NOT NULL, user_lastmark number(11) DEFAULT '0' NOT NULL, user_lastpost_time number(11) DEFAULT '0' NOT NULL, user_lastpage varchar2(200) DEFAULT '', - user_last_confirm_key varchar2(10) DEFAULT '', - user_warnings number(4) DEFAULT '0' NOT NULL, - user_last_warning number(11) DEFAULT '0' NOT NULL, - user_login_attempts number(4) DEFAULT '0' NOT NULL, + user_last_confirm_key varchar2(10) DEFAULT '' NULL, + user_warnings number(4) DEFAULT '0' NULL, + user_last_warning number(11) DEFAULT '0' NULL, + user_login_attempts number(4) DEFAULT '0' NULL, user_posts number(8) DEFAULT '0' NOT NULL, - user_lang varchar2(30) DEFAULT '', + user_lang varchar2(30) DEFAULT '' NOT NULL, user_timezone number(5, 2) DEFAULT '1' NOT NULL, user_dst number(1) DEFAULT '0' NOT NULL, - user_dateformat varchar2(30) DEFAULT 'd M Y H:i', + user_dateformat varchar2(30) DEFAULT 'd M Y H:i' NOT NULL, user_style number(4) DEFAULT '0' NOT NULL, - user_rank number(11) DEFAULT '0', - user_colour varchar2(6) DEFAULT '', + user_rank number(11) DEFAULT '0' NULL, + user_colour varchar2(6) DEFAULT '' NOT NULL, user_new_privmsg number(4) DEFAULT '0' NOT NULL, user_unread_privmsg number(4) DEFAULT '0' NOT NULL, user_last_privmsg number(11) DEFAULT '0' NOT NULL, @@ -1748,11 +1748,11 @@ CREATE TABLE phpbb_users ( user_full_folder number(11) DEFAULT '-3' NOT NULL, user_emailtime number(11) DEFAULT '0' NOT NULL, user_topic_show_days number(4) DEFAULT '0' NOT NULL, - user_topic_sortby_type varchar2(1) DEFAULT 't', - user_topic_sortby_dir varchar2(1) DEFAULT 'd', + user_topic_sortby_type varchar2(1) DEFAULT 't' NOT NULL, + user_topic_sortby_dir varchar2(1) DEFAULT 'd' NOT NULL, user_post_show_days number(4) DEFAULT '0' NOT NULL, - user_post_sortby_type varchar2(1) DEFAULT 't', - user_post_sortby_dir varchar2(1) DEFAULT 'a', + user_post_sortby_type varchar2(1) DEFAULT 't' NOT NULL, + user_post_sortby_dir varchar2(1) DEFAULT 'a' NOT NULL, user_notify number(1) DEFAULT '0' NOT NULL, user_notify_pm number(1) DEFAULT '1' NOT NULL, user_notify_type number(4) DEFAULT '0' NOT NULL, @@ -1762,24 +1762,24 @@ CREATE TABLE phpbb_users ( user_allow_viewemail number(1) DEFAULT '1' NOT NULL, user_allow_massemail number(1) DEFAULT '1' NOT NULL, user_options number(11) DEFAULT '893' NOT NULL, - user_avatar varchar2(255) DEFAULT '', + user_avatar varchar2(255) DEFAULT '' NOT NULL, user_avatar_type number(2) DEFAULT '0' NOT NULL, user_avatar_width number(4) DEFAULT '0' NOT NULL, user_avatar_height number(4) DEFAULT '0' NOT NULL, - user_sig clob, - user_sig_bbcode_uid varchar2(5) DEFAULT '', - user_sig_bbcode_bitfield number(11) DEFAULT '0' NOT NULL, - user_from varchar2(100) DEFAULT '', - user_icq varchar2(15) DEFAULT '', - user_aim varchar2(255) DEFAULT '', - user_yim varchar2(255) DEFAULT '', - user_msnm varchar2(255) DEFAULT '', - user_jabber varchar2(255) DEFAULT '', - user_website varchar2(200) DEFAULT '', - user_occ varchar2(255) DEFAULT '', - user_interests varchar2(255) DEFAULT '', - user_actkey varchar2(32) DEFAULT '', - user_newpasswd varchar2(32) DEFAULT '', + user_sig clob NULL, + user_sig_bbcode_uid varchar2(5) DEFAULT '' NULLL, + user_sig_bbcode_bitfield number(11) DEFAULT '0' NULL, + user_from varchar2(100) DEFAULT '' NULL, + user_icq varchar2(15) DEFAULT '' NULL, + user_aim varchar2(255) DEFAULT '' NULL, + user_yim varchar2(255) DEFAULT '' NULL, + user_msnm varchar2(255) DEFAULT '' NULL, + user_jabber varchar2(255) DEFAULT '' NULL, + user_website varchar2(200) DEFAULT '' NULL, + user_occ varchar2(255) DEFAULT '' NULL, + user_interests varchar2(255) DEFAULT '' NULL, + user_actkey varchar2(32) DEFAULT '' NOT NULL, + user_newpasswd varchar2(32) DEFAULT '' NULL, CONSTRAINT pk_phpbb_users PRIMARY KEY (user_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 7c00b86203..7c59dd2100 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -563,19 +563,19 @@ CREATE TABLE phpbb_posts ( enable_smilies INT2 DEFAULT '1' NOT NULL, enable_magic_url INT2 DEFAULT '1' NOT NULL, enable_sig INT2 DEFAULT '1' NOT NULL, - post_username varchar(255), - post_subject TEXT, - post_text TEXT, + post_username varchar(255) NULL, + post_subject TEXT NOT NULL, + post_text TEXT NOT NULL, post_checksum varchar(32) NOT NULL, post_encoding varchar(20) DEFAULT 'iso-8859-1' NOT NULL, post_attachment INT2 DEFAULT '0' NOT NULL, bbcode_bitfield INT4 DEFAULT '0' NOT NULL, bbcode_uid varchar(5) DEFAULT '' NOT NULL, - post_edit_time INT4 DEFAULT '0' NOT NULL, - post_edit_reason TEXT, - post_edit_user INT4 DEFAULT '0' NOT NULL, - post_edit_count INT2 DEFAULT '0' NOT NULL, - post_edit_locked INT2 DEFAULT '0' NOT NULL, + post_edit_time INT4 DEFAULT '0' NULL, + post_edit_reason TEXT NULL, + post_edit_user INT4 DEFAULT '0' NULL, + post_edit_count INT2 DEFAULT '0' NULL, + post_edit_locked INT2 DEFAULT '0' NULL, PRIMARY KEY (post_id), CHECK (topic_id>=0), CHECK (forum_id>=0), @@ -915,7 +915,7 @@ CREATE SEQUENCE phpbb_smilies_seq; CREATE TABLE phpbb_smilies ( smiley_id INT2 DEFAULT nextval('phpbb_smilies_seq'), - code varchar(10), + code varchar(50), emotion varchar(50), smiley_url varchar(50), smiley_width INT2 NOT NULL, @@ -962,7 +962,7 @@ CREATE TABLE phpbb_styles_template ( template_name varchar(255) NOT NULL, template_copyright varchar(255) NOT NULL, template_path varchar(100) NOT NULL, - bbcode_bitfield INT4 DEFAULT '0' NOT NULL, + bbcode_bitfield INT4 DEFAULT '6921' NOT NULL, template_storedb INT2 DEFAULT '0' NOT NULL, PRIMARY KEY (template_id), CHECK (bbcode_bitfield>=0) @@ -1217,31 +1217,31 @@ CREATE TABLE phpbb_users ( user_id INT4 DEFAULT nextval('phpbb_users_seq'), user_type INT2 DEFAULT '0' NOT NULL, group_id INT4 DEFAULT '3' NOT NULL, - user_permissions TEXT, - user_perm_from INT4 DEFAULT '0' NOT NULL, + user_permissions TEXT NULL, + user_perm_from INT4 DEFAULT '0' NULL, user_ip varchar(40) DEFAULT '' NOT NULL, user_regdate INT4 DEFAULT '0' NOT NULL, username varchar(255) DEFAULT '' NOT NULL, user_password varchar(40) DEFAULT '' NOT NULL, - user_passchg INT4 DEFAULT '0' NOT NULL, + user_passchg INT4 DEFAULT '0' NULL, user_email varchar(100) DEFAULT '' NOT NULL, user_email_hash INT8 DEFAULT '0' NOT NULL, - user_birthday varchar(10) DEFAULT '' NOT NULL, + user_birthday varchar(10) DEFAULT '' NULL, user_lastvisit INT4 DEFAULT '0' NOT NULL, user_lastmark INT4 DEFAULT '0' NOT NULL, user_lastpost_time INT4 DEFAULT '0' NOT NULL, user_lastpage varchar(200) DEFAULT '' NOT NULL, - user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, - user_warnings INT2 DEFAULT '0' NOT NULL, - user_last_warning INT4 DEFAULT '0' NOT NULL, - user_login_attempts INT4 DEFAULT '0' NOT NULL, + user_last_confirm_key varchar(10) DEFAULT '' NULL, + user_warnings INT2 DEFAULT '0' NULL, + user_last_warning INT4 DEFAULT '0' NULL, + user_login_attempts INT4 DEFAULT '0' NULL, user_posts INT4 DEFAULT '0' NOT NULL, user_lang varchar(30) DEFAULT '' NOT NULL, user_timezone decimal(5,2) DEFAULT '0.0' NOT NULL, user_dst INT2 DEFAULT '0' NOT NULL, user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, user_style INT2 DEFAULT '0' NOT NULL, - user_rank INT4 DEFAULT '0', + user_rank INT4 DEFAULT '0' NULL, user_colour varchar(6) DEFAULT '' NOT NULL, user_new_privmsg INT2 DEFAULT '0' NOT NULL, user_unread_privmsg INT2 DEFAULT '0' NOT NULL, @@ -1268,20 +1268,20 @@ CREATE TABLE phpbb_users ( user_avatar_type INT2 DEFAULT '0' NOT NULL, user_avatar_width INT2 DEFAULT '0' NOT NULL, user_avatar_height INT2 DEFAULT '0' NOT NULL, - user_sig TEXT, - user_sig_bbcode_uid varchar(5) DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield INT4 DEFAULT '0' NOT NULL, - user_from varchar(100) DEFAULT '' NOT NULL, - user_icq varchar(15) DEFAULT '' NOT NULL, - user_aim varchar(255) DEFAULT '' NOT NULL, - user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, - user_jabber varchar(255) DEFAULT '' NOT NULL, - user_website varchar(200) DEFAULT '' NOT NULL, - user_occ varchar(255) DEFAULT '' NOT NULL, - user_interests varchar(255) DEFAULT '' NOT NULL, + user_sig TEXT NULL, + user_sig_bbcode_uid varchar(5) DEFAULT '' NULL, + user_sig_bbcode_bitfield INT4 DEFAULT '0' NULL, + user_from varchar(100) DEFAULT '' NULL, + user_icq varchar(15) DEFAULT '' NULL, + user_aim varchar(255) DEFAULT '' NULL, + user_yim varchar(255) DEFAULT '' NULL, + user_msnm varchar(255) DEFAULT '' NULL, + user_jabber varchar(255) DEFAULT '' NULL, + user_website varchar(200) DEFAULT '' NULL, + user_occ varchar(255) DEFAULT '' NULL, + user_interests varchar(255) DEFAULT '' NULL, user_actkey varchar(32) DEFAULT '' NOT NULL, - user_newpasswd varchar(32) DEFAULT '' NOT NULL, + user_newpasswd varchar(32) DEFAULT '' NULL, PRIMARY KEY (user_id), CHECK (user_posts>=0), CHECK (user_new_privmsg>=0), diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 8891b012bd..6752a9812c 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -221,8 +221,6 @@ INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('sessio INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('upload_dir_size', '0', 1); INSERT INTO phpbb_config (config_name, config_value, is_dynamic) VALUES ('warnings_last_gc', '0', 1); -# MSSQL IDENTITY phpbb_auth_options ON # - # -- Forum related auth options INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_', 1); INSERT INTO phpbb_auth_options (auth_option, is_local) VALUES ('f_list', 1); @@ -349,10 +347,6 @@ INSERT INTO phpbb_auth_options (auth_option, is_global) VALUES ('u_pm_delete', 1 INSERT INTO phpbb_auth_options (auth_option, is_global) VALUES ('u_pm_img', 1); INSERT INTO phpbb_auth_options (auth_option, is_global) VALUES ('u_pm_flash', 1); -# MSSQL IDENTITY phpbb_auth_options OFF # - - -# MSSQL IDENTITY phpbb_auth_roles ON # # -- standard auth roles INSERT INTO phpbb_auth_roles (role_name, role_description, role_type, role_order) VALUES ('Standard Admin', 'ROLE_DESCRIPTION_ADMIN_STANDARD', 'a_', 1); @@ -377,66 +371,32 @@ INSERT INTO phpbb_auth_roles (role_name, role_description, role_type, role_order INSERT INTO phpbb_auth_roles (role_name, role_description, role_type, role_order) VALUES ('On Moderation Queue', 'ROLE_DESCRIPTION_FORUM_ONQUEUE', 'f_', 7); INSERT INTO phpbb_auth_roles (role_name, role_description, role_type, role_order) VALUES ('Standard Access + Polls', 'ROLE_DESCRIPTION_FORUM_POLLS', 'f_', 5); -# MSSQL IDENTITY phpbb_auth_roles OFF # - - -# MSSQL IDENTITY phpbb_styles ON # # -- phpbb_styles INSERT INTO phpbb_styles (style_name, style_copyright, template_id, theme_id, imageset_id) VALUES ('subSilver', '© phpBB Group', 1, 1, 1); -# MSSQL IDENTITY phpbb_styles OFF # - - -# MSSQL IDENTITY phpbb_styles_imageset ON # - # -- phpbb_styles_imageset INSERT INTO phpbb_styles_imageset (imageset_name, imageset_copyright, imageset_path, site_logo, btn_post, btn_post_pm, btn_reply, btn_reply_pm, btn_locked, btn_profile, btn_pm, btn_delete, btn_info, btn_quote, btn_search, btn_edit, btn_report, btn_email, btn_www, btn_icq, btn_aim, btn_yim, btn_msnm, btn_jabber, btn_online, btn_offline, btn_friend, btn_foe, icon_unapproved, icon_reported, icon_attach, icon_post, icon_post_new, icon_post_latest, icon_post_newest, forum, forum_new, forum_locked, forum_link, sub_forum, sub_forum_new, folder, folder_moved, folder_posted, folder_new, folder_new_posted, folder_hot, folder_hot_posted, folder_hot_new, folder_hot_new_posted, folder_locked, folder_locked_posted, folder_locked_new, folder_locked_new_posted, folder_sticky, folder_sticky_posted, folder_sticky_new, folder_sticky_new_posted, folder_announce, folder_announce_posted, folder_announce_new, folder_announce_new_posted, folder_global, folder_global_posted, folder_global_new, folder_global_new_posted, poll_left, poll_center, poll_right, attach_progress_bar, user_icon1, user_icon2, user_icon3, user_icon4, user_icon5, user_icon6, user_icon7, user_icon8, user_icon9, user_icon10) VALUES ('subSilver', '© phpBB Group', 'subSilver', 'sitelogo.gif*94*170', '{LANG}/btn_post.gif*27*97', '{LANG}/btn_post_pm.gif*27*97', '{LANG}/btn_reply.gif*27*97', '{LANG}/btn_reply_pm.gif*20*90', '{LANG}/btn_locked.gif*27*97', '{LANG}/btn_profile.gif*20*72', '{LANG}/btn_pm.gif*20*72', '{LANG}/btn_delete.gif*20*20', '{LANG}/btn_info.gif*20*20', '{LANG}/btn_quote.gif*20*90', '{LANG}/btn_search.gif*20*72', '{LANG}/btn_edit.gif*20*90', '{LANG}/btn_report.gif*20*20', '{LANG}/btn_email.gif*20*72', '{LANG}/btn_www.gif*20*72', '{LANG}/btn_icq.gif*20*72', '{LANG}/btn_aim.gif*20*72', '{LANG}/btn_yim.gif*20*72', '{LANG}/btn_msnm.gif*20*72', '{LANG}/btn_jabber.gif*20*72', '{LANG}/btn_online.gif*20*72', '{LANG}/btn_offline.gif*20*72', '', '', 'icon_unapproved.gif*18*19', 'icon_reported.gif*18*19', 'icon_attach.gif*18*14', 'icon_minipost.gif*9*12', 'icon_minipost_new.gif*9*12', 'icon_latest_reply.gif*9*18', 'icon_newest_reply.gif*9*18', 'folder_big.gif*25*46', 'folder_new_big.gif*25*46', 'folder_locked_big.gif*25*46', 'folder_link_big.gif*25*46', 'subfolder_big.gif*25*46', 'subfolder_new_big.gif*25*46', 'folder.gif*18*19', 'folder_moved.gif*18*19', 'folder_posted.gif*18*19', 'folder_new.gif*18*19', 'folder_new_posted.gif*18*19', 'folder_hot.gif*18*19', 'folder_hot_posted.gif*18*19', 'folder_new_hot.gif*18*19', 'folder_new_hot_posted.gif*18*19', 'folder_lock.gif*18*19', 'folder_lock_posted.gif*18*19', 'folder_lock_new.gif*18*19', 'folder_lock_new_posted.gif*18*19', 'folder_sticky.gif*18*19', 'folder_sticky_posted.gif*18*19', 'folder_sticky_new.gif*18*19', 'folder_sticky_new_posted.gif*18*19', 'folder_announce.gif*18*19', 'folder_announce_posted.gif*18*19', 'folder_announce_new.gif*18*19', 'folder_announce_new_posted.gif*18*19', '', '', '', '', 'vote_lcap.gif*12*4', 'voting_bar.gif*12', 'vote_rcap.gif*12*4', 'progress_bar.gif*16*280', '', '', '', '', '', '', '', '', '', ''); -# MSSQL IDENTITY phpbb_styles_imageset OFF # - - -# MSSQL IDENTITY phpbb_styles_template ON # - # -- phpbb_styles_template INSERT INTO phpbb_styles_template (template_name, template_copyright, template_path, bbcode_bitfield) VALUES ('subSilver', '© phpBB Group', 'subSilver', 6921); -# MSSQL IDENTITY phpbb_styles_template OFF # - - -# MSSQL IDENTITY phpbb_styles_theme ON # - # -- phpbb_styles_theme INSERT INTO phpbb_styles_theme (theme_name, theme_copyright, theme_path, theme_data) VALUES ('subSilver', '© phpBB Group', 'subSilver', ''); -# MSSQL IDENTITY phpbb_styles_theme OFF # - - -# MSSQL IDENTITY phpbb_lang ON # - # -- Language INSERT INTO phpbb_lang (lang_iso, lang_dir, lang_english_name, lang_local_name, lang_author) VALUES ('en', 'en', 'English [ UK ]', 'English [ UK ]', 'phpBB Group'); -# MSSQL IDENTITY phpbb_lang OFF # - - -# MSSQL IDENTITY phpbb_forums ON # - # -- Forums INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed) VALUES ('My first Category', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 972086460, '', '', '', '', '', '', '', 0, 0); INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed) VALUES ('Test Forum 1', 'This is just a test forum.', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 972086460, '', '', '', '', '', '', '', 0, 0); -# MSSQL IDENTITY phpbb_forums OFF # - - -# MSSQL IDENTITY phpbb_users ON # - # -- Users / Anonymous user INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_email, user_lang, user_style, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_colour, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (2, 1, 'Anonymous', 0, '', '', 'en', 1, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- username: Admin password: admin (change this or remove it ON #ce everything is working!) -INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 7, 'Admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); +INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) VALUES (3, 7, 'Admin', 0, '21232f297a57a5a743894a0e4a801fc3', 'admin@yourdomain.com', 'en', 1, 1, 'AA0000', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); # -- bots INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_lang, user_style, user_rank, user_colour, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_email) VALUES (2, 8, 'Googlebot', 0, '', 'en', 1, 1, '9E8DA7', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); @@ -444,11 +404,6 @@ INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_passw INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_lang, user_style, user_rank, user_colour, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_email) VALUES (2, 8, 'Alexa', 0, '', 'en', 1, 1, '9E8DA7', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); INSERT INTO phpbb_users (user_type, group_id, username, user_regdate, user_password, user_lang, user_style, user_rank, user_colour, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_email) VALUES (2, 8, 'Inktomi', 0, '', 'en', 1, 1, '9E8DA7', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); -# MSSQL IDENTITY phpbb_users OFF # - - -# MSSQL IDENTITY phpbb_groups ON # - # -- Groups INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('GUESTS', 3, '', 0, '', '', ''); INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('INACTIVE', 3, '', 0, '', '', ''); @@ -459,9 +414,6 @@ INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, gr INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('ADMINISTRATORS', 3, 'AA0000', 1, '', '', ''); INSERT INTO phpbb_groups (group_name, group_type, group_colour, group_legend, group_avatar, group_desc, group_desc_uid) VALUES ('BOTS', 3, '9E8DA7', 1, '', '', ''); -# MSSQL IDENTITY phpbb_groups OFF # - - # -- User -> Group INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (1, 1, 0, 0); INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (4, 2, 0, 0); @@ -471,26 +423,15 @@ INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VAL INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (8, 5, 0, 0); INSERT INTO phpbb_user_group (group_id, user_id, user_pending, group_leader) VALUES (8, 6, 0, 0); - -# MSSQL IDENTITY phpbb_ranks ON # - # -- Ranks INSERT INTO phpbb_ranks (rank_title, rank_min, rank_special, rank_image) VALUES ('Site Admin', -1, 1, NULL); -# MSSQL IDENTITY phpbb_ranks OFF # - - -# MSSQL IDENTITY phpbb_bots ON # - # -- Bots INSERT INTO phpbb_bots (bot_active, bot_name, user_id, bot_agent, bot_ip) VALUES (1, 'Googlebot', 3, 'Googlebot/', '216.239.46.,64.68.8'); INSERT INTO phpbb_bots (bot_active, bot_name, user_id, bot_agent, bot_ip) VALUES (1, 'Fastcrawler', 4, 'FAST MetaWeb Crawler', '66.151.181.'); INSERT INTO phpbb_bots (bot_active, bot_name, user_id, bot_agent, bot_ip) VALUES (1, 'Alexa', 5, 'ia_archiver', '66.28.250.,209.237.238.'); INSERT INTO phpbb_bots (bot_active, bot_name, user_id, bot_agent, bot_ip) VALUES (1, 'Inktomi', 6, 'Slurp/', '216.35.116.,66.196.'); -# MSSQL IDENTITY phpbb_bots OFF # - - # -- Roles data # Standard Admin (a_) @@ -614,22 +555,12 @@ INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_role_id, INSERT INTO phpbb_auth_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (8, 2, 0, 19, 0); -# MSSQL IDENTITY phpbb_topics ON # - # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('Welcome to phpBB 3', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 1, 2, 'Admin', 972086460, 972086460, ''); -# MSSQL IDENTITY phpbb_topics OFF # - - -# MSSQL IDENTITY phpbb_posts ON # - # -- Demo Post INSERT INTO phpbb_posts (topic_id, forum_id, poster_id, icon_id, post_time, post_username, poster_ip, post_subject, post_text, post_checksum, bbcode_uid) VALUES (1, 2, 2, 1, 972086460, NULL, '127.0.0.1', 'Welcome to phpBB 3', 'This is an example post in your phpBB 3.0 installation. You may delete this post, this topic and even this forum if you like since everything seems to be working!', '', ''); -# MSSQL IDENTITY phpbb_posts OFF # - - # -- Smilies INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':D', 'icon_biggrin.gif', 'Very Happy', 15, 15, 1); INSERT INTO phpbb_smilies (code, smiley_url, emotion, smiley_width, smiley_height, smiley_order) VALUES (':)', 'icon_smile.gif', 'Smile', 15, 15, 2); @@ -669,8 +600,6 @@ INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, disp INSERT INTO phpbb_icons (icons_url, icons_width, icons_height, icons_order, display_on_posting) VALUES ('smile/exclaim.gif', 19, 19, 7, 1); -# MSSQL IDENTITY phpbb_search_wordlist ON # - # -- wordlist INSERT INTO phpbb_search_wordlist (word_text, word_common) VALUES ('example', 0); INSERT INTO phpbb_search_wordlist (word_text, word_common) VALUES ('post', 0); @@ -685,9 +614,6 @@ INSERT INTO phpbb_search_wordlist (word_text, word_common) VALUES ('seems', 0); INSERT INTO phpbb_search_wordlist (word_text, word_common) VALUES ('working', 0); INSERT INTO phpbb_search_wordlist (word_text, word_common) VALUES ('welcome', 0); -# MSSQL IDENTITY phpbb_search_wordlist OFF # - - # -- wordmatch INSERT INTO phpbb_search_wordmatch (word_id, post_id, title_match) VALUES (1, 1, 0); INSERT INTO phpbb_search_wordmatch (word_id, post_id, title_match) VALUES (2, 1, 0); @@ -704,18 +630,12 @@ INSERT INTO phpbb_search_wordmatch (word_id, post_id, title_match) VALUES (12, 1 INSERT INTO phpbb_search_wordmatch (word_id, post_id, title_match) VALUES (3, 1, 1); -# MSSQL IDENTITY phpbb_reports_reasons ON # - # -- reasons INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('warez', 'The reported post contains links to pirated or illegal software', 1); INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('spam', 'The reported post has for only purpose to advertise for a website or another product', 2); INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('off_topic', 'The reported post is off topic', 3); INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', 'The reported post does not fit into any other category (please use the description field)', 4); -# MSSQL IDENTITY phpbb_reports_reasons OFF # - -# MSSQL IDENTITY phpbb_extension_groups ON # - # -- extension_groups INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('Images', 1, 1, 1, '', 0, ''); INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('Archives', 0, 1, 1, '', 0, ''); @@ -724,11 +644,6 @@ INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mo INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('Real Media', 3, 0, 2, '', 0, ''); INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('Windows Media', 2, 0, 1, '', 0, ''); -# MSSQL IDENTITY phpbb_extension_groups OFF # - - -# MSSQL IDENTITY phpbb_extensions ON # - # -- extensions INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'png'); @@ -759,6 +674,4 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (5, 'rm'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wma'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (6, 'wmv'); -# MSSQL IDENTITY phpbb_extensions OFF # - # POSTGRES COMMIT # \ No newline at end of file diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index a78186fb64..f3c9bd4204 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -434,19 +434,19 @@ CREATE TABLE phpbb_posts ( enable_smilies tinyint(1) NOT NULL DEFAULT '1', enable_magic_url tinyint(1) NOT NULL DEFAULT '1', enable_sig tinyint(1) NOT NULL DEFAULT '1', - post_username varchar(255), - post_subject text(65535), - post_text mediumtext(16777215), + post_username varchar(255) NULL, + post_subject text(65535) NOT NULL, + post_text mediumtext(16777215) NOT NULL, post_checksum varchar(32) NOT NULL, post_encoding varchar(20) NOT NULL DEFAULT 'iso-8859-1', post_attachment tinyint(1) NOT NULL DEFAULT '0', bbcode_bitfield int(11) NOT NULL DEFAULT '0', bbcode_uid varchar(5) NOT NULL DEFAULT '', - post_edit_time int(11) NOT NULL DEFAULT '0', - post_edit_reason text(65535), - post_edit_user mediumint(8) NOT NULL DEFAULT '0', - post_edit_count smallint(5) NOT NULL DEFAULT '0', - post_edit_locked tinyint(1) NOT NULL DEFAULT '0' + post_edit_time int(11) NULL DEFAULT '0', + post_edit_reason text(65535) NULL, + post_edit_user mediumint(8) NULL DEFAULT '0', + post_edit_count smallint(5) NULL DEFAULT '0', + post_edit_locked tinyint(1) NULL DEFAULT '0' ); CREATE INDEX phpbb_posts_forum_id on phpbb_posts (forum_id); @@ -692,7 +692,7 @@ CREATE TABLE phpbb_sitelist ( # Table: phpbb_smilies CREATE TABLE phpbb_smilies ( smiley_id INTEGER PRIMARY KEY NOT NULL, - code varchar(10), + code varchar(50), emotion varchar(50), smiley_url varchar(50), smiley_width tinyint(4) NOT NULL, @@ -725,7 +725,7 @@ CREATE TABLE phpbb_styles_template ( template_name varchar(255) NOT NULL, template_copyright varchar(255) NOT NULL, template_path varchar(100) NOT NULL, - bbcode_bitfield int(11) NOT NULL DEFAULT '0', + bbcode_bitfield int(11) NOT NULL DEFAULT '6921', template_storedb tinyint(1) NOT NULL DEFAULT '0' ); @@ -936,31 +936,31 @@ CREATE TABLE phpbb_users ( user_id INTEGER PRIMARY KEY NOT NULL, user_type tinyint(1) NOT NULL DEFAULT '0', group_id mediumint(8) NOT NULL DEFAULT '3', - user_permissions text(65535), - user_perm_from mediumint(8) NOT NULL DEFAULT '0', + user_permissions text(65535) NULL, + user_perm_from mediumint(8) NULL DEFAULT '0', user_ip varchar(40) NOT NULL DEFAULT '', user_regdate int(11) NOT NULL DEFAULT '0', username varchar(255) NOT NULL DEFAULT '', user_password varchar(40) NOT NULL DEFAULT '', - user_passchg int(11) NOT NULL DEFAULT '0', + user_passchg int(11) NULL DEFAULT '0', user_email varchar(100) NOT NULL DEFAULT '', user_email_hash bigint(20) NOT NULL DEFAULT '0', - user_birthday varchar(10) NOT NULL DEFAULT '', + user_birthday varchar(10) NULL DEFAULT '', user_lastvisit int(11) NOT NULL DEFAULT '0', user_lastmark int(11) NOT NULL DEFAULT '0', user_lastpost_time int(11) NOT NULL DEFAULT '0', user_lastpage varchar(200) NOT NULL DEFAULT '', - user_last_confirm_key varchar(10) NOT NULL DEFAULT '', - user_warnings tinyint(4) NOT NULL DEFAULT '0', - user_last_warning int(11) NOT NULL DEFAULT '0', - user_login_attempts smallint(4) NOT NULL DEFAULT '0', + user_last_confirm_key varchar(10) NULL DEFAULT '', + user_warnings tinyint(4) NULL DEFAULT '0', + user_last_warning int(11) NULL DEFAULT '0', + user_login_attempts smallint(4) NULL DEFAULT '0', user_posts mediumint(8) NOT NULL DEFAULT '0', user_lang varchar(30) NOT NULL DEFAULT '', user_timezone decimal(5,2) NOT NULL DEFAULT '0.0', user_dst tinyint(1) NOT NULL DEFAULT '0', user_dateformat varchar(30) NOT NULL DEFAULT 'd M Y H:i', user_style tinyint(4) NOT NULL DEFAULT '0', - user_rank int(11) DEFAULT '0', + user_rank int(11) NULL DEFAULT '0', user_colour varchar(6) NOT NULL DEFAULT '', user_new_privmsg tinyint(4) NOT NULL DEFAULT '0', user_unread_privmsg tinyint(4) NOT NULL DEFAULT '0', @@ -987,20 +987,20 @@ CREATE TABLE phpbb_users ( user_avatar_type tinyint(2) NOT NULL DEFAULT '0', user_avatar_width tinyint(4) NOT NULL DEFAULT '0', user_avatar_height tinyint(4) NOT NULL DEFAULT '0', - user_sig text(65535), - user_sig_bbcode_uid varchar(5) NOT NULL DEFAULT '', - user_sig_bbcode_bitfield int(11) NOT NULL DEFAULT '0', - user_from varchar(100) NOT NULL DEFAULT '', - user_icq varchar(15) NOT NULL DEFAULT '', - user_aim varchar(255) NOT NULL DEFAULT '', - user_yim varchar(255) NOT NULL DEFAULT '', - user_msnm varchar(255) NOT NULL DEFAULT '', - user_jabber varchar(255) NOT NULL DEFAULT '', - user_website varchar(200) NOT NULL DEFAULT '', - user_occ varchar(255) NOT NULL DEFAULT '', - user_interests varchar(255) NOT NULL DEFAULT '', + user_sig text(65535) NULL, + user_sig_bbcode_uid varchar(5) NULL DEFAULT '', + user_sig_bbcode_bitfield int(11) NULL DEFAULT '0', + user_from varchar(100) NULL DEFAULT '', + user_icq varchar(15) NULL DEFAULT '', + user_aim varchar(255) NULL DEFAULT '', + user_yim varchar(255) NULL DEFAULT '', + user_msnm varchar(255) NULL DEFAULT '', + user_jabber varchar(255) NULL DEFAULT '', + user_website varchar(200) NULL DEFAULT '', + user_occ varchar(255) NULL DEFAULT '', + user_interests varchar(255) NULL DEFAULT '', user_actkey varchar(32) NOT NULL DEFAULT '', - user_newpasswd varchar(32) NOT NULL DEFAULT '' + user_newpasswd varchar(32) NULL DEFAULT '' ); CREATE INDEX phpbb_users_user_birthday on phpbb_users (user_birthday); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index bd56a25b83..defb89e77d 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -109,6 +109,7 @@ $lang = array_merge($lang, array( 'NO_EXT_GROUP_NAME' => 'No Group Name entered', 'NO_EXT_GROUP_SPECIFIED' => 'No Extension Group specified', 'NO_IMAGE' => 'No Image', + 'NO_THUMBNAIL_SUPPORT' => 'Thumbnail support has been disabled because there is no supported GD library available and the imagemagick executable could not be found.', 'NO_UPLOAD_DIR' => 'The upload directory you specified does not exist.', 'NO_WRITE_UPLOAD' => 'The upload directory you specified cannot be written to. Please alter the permissions to allow the webserver to write to it.', diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 99fbd0c28b..186b531dca 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -375,6 +375,7 @@ $lang = array_merge($lang, array( 'ALLOW_NO_CENSORS_EXPLAIN' => 'User can disable word censoring.', 'ALLOW_BOOKMARKS' => 'Allow bookmarking topics', 'ALLOW_BOOKMARKS_EXPLAIN' => 'User is able to store personal bookmarks', + )); ?> \ No newline at end of file diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 83bd7ceaa2..1f0aed9597 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -384,18 +384,22 @@ $lang = array_merge($lang, array( 'LOG_CLEAR_USER' => 'Cleared user log
» %s', 'LOG_CLEAR_USERS' => 'Cleared user logs', - 'LOG_CONFIG_ATTACH' => 'Altered attachment settings', - 'LOG_CONFIG_AUTH' => 'Altered authentication settings', - 'LOG_CONFIG_AVATAR' => 'Altered avatar settings', - 'LOG_CONFIG_COOKIE' => 'Altered cookie settings', - 'LOG_CONFIG_DEFAULT' => 'Altered board defaults', - 'LOG_CONFIG_EMAIL' => 'Altered email settings', - 'LOG_CONFIG_LOAD' => 'Altered load settings', - 'LOG_CONFIG_MESSAGE' => 'Altered private message settings', - 'LOG_CONFIG_SEARCH' => 'Altered search settings', - 'LOG_CONFIG_SERVER' => 'Altered server settings', - 'LOG_CONFIG_SETTINGS' => 'Altered board settings', - 'LOG_CONFIG_VISUAL' => 'Altered visual confirmation settings', + 'LOG_CONFIG_ATTACH' => 'Altered attachment settings', + 'LOG_CONFIG_AUTH' => 'Altered authentication settings', + 'LOG_CONFIG_AVATAR' => 'Altered avatar settings', + 'LOG_CONFIG_COOKIE' => 'Altered cookie settings', + 'LOG_CONFIG_EMAIL' => 'Altered email settings', + 'LOG_CONFIG_FEATURES' => 'Altered board features', + 'LOG_CONFIG_LOAD' => 'Altered load settings', + 'LOG_CONFIG_MESSAGE' => 'Altered private message settings', + 'LOG_CONFIG_POST' => 'Altered post settings', + 'LOG_CONFIG_REGISTRATION' => 'Altered user registration settings', + 'LOG_CONFIG_SEARCH' => 'Altered search settings', + 'LOG_CONFIG_SECURITY' => 'Altered security settings', + 'LOG_CONFIG_SERVER' => 'Altered server settings', + 'LOG_CONFIG_SETTINGS' => 'Altered board settings', + 'LOG_CONFIG_SIGNATURE' => 'Altered signature settings', + 'LOG_CONFIG_VISUAL' => 'Altered visual confirmation settings', 'LOG_DISALLOW_ADD' => 'Added disallowed username
» %s', 'LOG_DISALLOW_DELETE' => 'Deleted disallowed username', diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php index 5ab9bacfd5..cbaf75abe6 100644 --- a/phpBB/language/en/mcp.php +++ b/phpBB/language/en/mcp.php @@ -130,6 +130,7 @@ $lang = array_merge($lang, array( 'LOG_USER_LOCK' => 'User locked own topic
» %s', 'LOG_USER_MOVE_POSTS_USER' => 'Moved all posts to forum "%s"', 'LOG_USER_REACTIVATE_USER' => 'Forced user account re-activation', + 'LOG_USER_UNLOCK' => 'User unlocked own topic
» %s', 'LOGIN_EXPLAIN_MCP' => 'To moderate this forum you must login.', 'LOGVIEW_VIEWTOPIC' => 'View Topic', 'LOGVIEW_VIEWLOGS' => 'View Topic Log', diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index 692c43a3fe..d17ffebd2a 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -188,6 +188,7 @@ $lang = array_merge($lang, array( 'USER_CANNOT_DELETE' => 'You cannot delete posts in this forum', 'USER_CANNOT_EDIT' => 'You cannot edit posts in this forum', 'USER_CANNOT_REPLY' => 'You cannot reply in this forum', + 'USER_CANNOT_FORUM_POST' => 'You are not able to do posting operations on this forum due to the forum type not supporting it.', 'USERNAME_DISALLOWED' => 'The username you entered has been banned.', 'USERNAME_TAKEN' => 'The username you entered is already in use, please select an alternative.', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 20976a3875..085c478158 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -202,6 +202,7 @@ $lang = array_merge($lang, array( 'HIDE_ONLINE' => 'Hide my online status', 'HOLD_NEW_MESSAGES' => 'Do not accept new messages (New messages will be held back until enough space is available)', + 'HOLD_NEW_MESSAGES_SHORT' => 'New messages will be held back', 'IF_FOLDER_FULL' => 'If Folder Full', 'IMPORTANT_NEWS' => 'Important announcements', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index a748436bc1..ffb10ee10c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -190,7 +190,7 @@ switch ($mode) $db->sql_freeresult($result); $template->assign_vars(array( - 'PM_IMG' => $user->img('btn_pm', $user->lang['MESSAGE'])) + 'PM_IMG' => $user->img('btn_pm', $user->lang['SEND_PRIVATE_MESSAGE'])) ); break; @@ -411,7 +411,7 @@ switch ($mode) 'SIGNATURE' => (!empty($member['user_sig'])) ? str_replace("\n", '
', $member['user_sig']) : '', 'AVATAR_IMG' => $poster_avatar, - 'PM_IMG' => $user->img('btn_pm', $user->lang['MESSAGE']), + 'PM_IMG' => $user->img('btn_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('btn_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('btn_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('btn_icq', $user->lang['ICQ']), @@ -1099,7 +1099,7 @@ switch ($mode) 'TOTAL_USERS' => ($total_users == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $total_users), 'PROFILE_IMG' => $user->img('btn_profile', $user->lang['PROFILE']), - 'PM_IMG' => $user->img('btn_pm', $user->lang['MESSAGE']), + 'PM_IMG' => $user->img('btn_pm', $user->lang['SEND_PRIVATE_MESSAGE']), 'EMAIL_IMG' => $user->img('btn_email', $user->lang['EMAIL']), 'WWW_IMG' => $user->img('btn_www', $user->lang['WWW']), 'ICQ_IMG' => $user->img('btn_icq', $user->lang['ICQ']), diff --git a/phpBB/posting.php b/phpBB/posting.php index 7d0b2892b4..a357e565c6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -32,19 +32,18 @@ $forum_id = request_var('f', 0); $draft_id = request_var('d', 0); $lastclick = request_var('lastclick', 0); -$submit = (isset($_POST['post'])); -$preview = (isset($_POST['preview'])); -$save = (isset($_POST['save'])); -$load = (isset($_POST['load'])); -$cancel = (isset($_POST['cancel'])); -$confirm = (isset($_POST['confirm'])); -$delete = (isset($_POST['delete'])); - -$refresh = isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || isset($_POST['cancel_unglobalise']) || $save || $load; +$submit = (isset($_POST['post'])) ? true : false; +$preview = (isset($_POST['preview'])) ? true : false; +$save = (isset($_POST['save'])) ? true : false; +$load = (isset($_POST['load'])) ? true : false; +$delete = (isset($_POST['delete'])) ? true : false; +$cancel = (isset($_POST['cancel'])) ? true : false; +$confirm = (isset($_POST['confirm'])) ? true : false; +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['edit_comment']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); -$error = array(); +$error = $post_data = array(); $current_time = time(); // Was cancel pressed? If so then redirect to the appropriate page @@ -122,172 +121,44 @@ switch ($mode) default: $sql = ''; trigger_error('NO_POST_MODE'); + break; } -if ($sql) +if (!$sql) { - $result = $db->sql_query($sql); - - extract($db->sql_fetchrow($result)); - $db->sql_freeresult($result); - - if ($mode == 'popup') - { - upload_popup($forum_style); - exit; - } - - $quote_username = (isset($username)) ? $username : ((isset($post_username)) ? $post_username : ''); - - $forum_id = (int) $forum_id; - $topic_id = (int) $topic_id; - $post_id = (int) $post_id; - - // Global Topic? - Adjust forum id - if (!$forum_id && $topic_type == POST_GLOBAL) - { - $forum_id = request_var('f', 0); - } - - $post_edit_locked = (isset($post_edit_locked)) ? (int) $post_edit_locked : 0; - - $user->setup(array('posting', 'mcp', 'viewtopic'), $forum_style); - - if ($forum_password) - { - $forum_info = array( - 'forum_id' => $forum_id, - 'forum_password'=> $forum_password - ); - - login_forum_box($forum_info); - unset($forum_info); - } - - $post_subject = (in_array($mode, array('quote', 'edit', 'delete'))) ? $post_subject : ((isset($topic_title)) ? $topic_title : ''); - - $topic_time_limit = (isset($topic_time_limit)) ? (($topic_time_limit) ? (int) $topic_time_limit / 86400 : (int) $topic_time_limit) : 0; - - $poll_length = (isset($poll_length)) ? (($poll_length) ? (int) $poll_length / 86400 : (int) $poll_length) : 0; - $poll_start = (isset($poll_start)) ? (int) $poll_start : 0; - $poll_options = array(); - - if (!isset($icon_id) || in_array($mode, array('quote', 'reply'))) - { - $icon_id = 0; - } - - // Get Poll Data - if ($poll_start) - { - $sql = 'SELECT poll_option_text - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY poll_option_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $poll_options[] = trim($row['poll_option_text']); - } - $db->sql_freeresult($result); - } - - $orig_poll_options_size = sizeof($poll_options); - $message_parser = new parse_message(); - - if (isset($post_text)) - { - $message_parser->message = $post_text; - unset($post_text); - } - - $message_parser->get_submitted_attachment_data(); - - // Set uninitialized variables - $uninit = array('post_attachment' => 0, 'poster_id' => 0, 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => ''); - foreach ($uninit as $var_name => $default_value) - { - if (!isset($$var_name)) - { - $$var_name = $default_value; - } - } - unset($uninit, $var_name, $default_value); - - if ($post_attachment && !$submit && !$refresh && !$preview && $mode == 'edit') - { - $sql = 'SELECT attach_id, physical_filename, comment, real_filename, extension, mimetype, filesize, filetime, thumbnail - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $post_id - AND in_message = 0 - ORDER BY filetime " . ((!$config['display_order']) ? 'DESC' : 'ASC'); - $result = $db->sql_query($sql); - - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - - $db->sql_freeresult($result); - } - - if ($poster_id == ANONYMOUS || !$poster_id) - { - $username = (in_array($mode, array('quote', 'edit', 'delete'))) ? trim($post_username) : ''; - } - else - { - $username = (in_array($mode, array('quote', 'edit', 'delete'))) ? trim($username) : ''; - } - - $enable_urls = $enable_magic_url; - - if (!in_array($mode, array('quote', 'edit', 'delete'))) - { - $enable_sig = ($config['allow_sig'] && $user->optionget('attachsig')); - $enable_smilies = ($config['allow_smilies'] && $user->optionget('smilies')); - $enable_bbcode = ($config['allow_bbcode'] && $user->optionget('bbcode')); - $enable_urls = true; - } - - $enable_magic_url = $drafts = false; - - // User own some drafts? - if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && $mode != 'delete') - { - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE (forum_id IN (' . $forum_id . ', 0)' . (($topic_id) ? " OR topic_id = $topic_id" : '') . ') - AND user_id = ' . $user->data['user_id'] . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); - - if ($db->sql_fetchrow($result)) - { - $drafts = true; - } - $db->sql_freeresult($result); - } - - $check_value = (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1); + trigger_error('NO_POST_MODE'); } -// Notify user checkbox -if ($mode != 'post' && $user->data['is_registered']) +$result = $db->sql_query($sql); +$post_data = $db->sql_fetchrow($result); +$db->sql_freeresult($result); + +$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); + +if ($mode == 'popup') { - $sql = 'SELECT topic_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - $notify_set = ($db->sql_fetchrow($result)) ? 1 : 0; - $db->sql_freeresult($result); + upload_popup($post_data['forum_style']); + exit; } -else + +// Use post_row values in favor of submitted ones... +$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; +$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; +$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; + +// Need to login to passworded forum first? +if ($post_data['forum_password']) { - $notify_set = 0; + login_forum_box(array( + 'forum_id' => $forum_id, + 'forum_password' => $post_data['forum_password']) + ); } // Check permissions -if ($forum_type != FORUM_POST && !$auth->acl_get('f_read', $forum_id)) + +// Is the user able to read within this forum? +if (!$auth->acl_get('f_read', $forum_id)) { if ($user->data['is_registered']) { @@ -297,9 +168,9 @@ if ($forum_type != FORUM_POST && !$auth->acl_get('f_read', $forum_id)) login_box('', $user->lang['LOGIN_EXPLAIN_POST']); } +// Permission to do the action asked? $check_auth = ($mode == 'quote') ? 'reply' : $mode; - -if (!$auth->acl_get('f_' . $check_auth, $forum_id) && $forum_type == FORUM_POST) +if (!$auth->acl_get('f_' . $check_auth, $forum_id)) { if ($user->data['is_registered']) { @@ -309,187 +180,248 @@ if (!$auth->acl_get('f_' . $check_auth, $forum_id) && $forum_type == FORUM_POST) login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); } -// Forum/Topic locked? -if (($forum_status == ITEM_LOCKED || $topic_status == ITEM_LOCKED) && !$auth->acl_get('m_edit', $forum_id)) +// Is the user able to post within this forum? +if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) { - $message = ($forum_status == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'; - trigger_error($message); + trigger_error('USER_CANNOT_FORUM_POST'); +} + +// Forum/Topic locked? +if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) +{ + trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); } // Can we edit this post ... if we're a moderator with rights then always yes // else it depends on editing times, lock status and if we're the correct user -// !$preview && !$refresh && !$submit && -if ($mode == 'edit' && !$preview && !$refresh && !$submit && !$auth->acl_get('m_edit', $forum_id)) +if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) { - if ($user->data['user_id'] != $poster_id) + if ($user->data['user_id'] != $post_data['poster_id']) { trigger_error('USER_CANNOT_EDIT'); } - if (!($post_time > time() - $config['edit_time'] || !$config['edit_time'])) + if (!($post_data['post_time'] > time() - $config['edit_time'] || !$config['edit_time'])) { trigger_error('CANNOT_EDIT_TIME'); } - if ($post_edit_locked) + if ($post_data['post_edit_locked']) { trigger_error('CANNOT_EDIT_POST_LOCKED'); } } -// Do we want to edit our post ? - -if ($mode == 'edit') -{ - $message_parser->bbcode_uid = $bbcode_uid; -} - - -// Delete triggered ? -if ($mode == 'delete' && (($poster_id == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $topic_last_post_id) || $auth->acl_get('m_delete', $forum_id))) -{ - $s_hidden_fields = build_hidden_fields(array( - 'p' => $post_id, - 'f' => $forum_id, - 'mode' => 'delete') - ); - - if (confirm_box(true)) - { - $data = array( - 'topic_first_post_id' => $topic_first_post_id, - 'topic_last_post_id' => $topic_last_post_id, - 'topic_approved' => $topic_approved, - 'topic_type' => $topic_type, - 'post_approved' => $post_approved, - 'post_time' => $post_time, - 'poster_id' => $poster_id - ); - - $next_post_id = delete_post($mode, $post_id, $topic_id, $forum_id, $data); - - if ($topic_first_post_id == $topic_last_post_id) - { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $topic_title); - - $meta_info = "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id"; - $message = $user->lang['POST_DELETED']; - } - else - { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_subject); - - $meta_info = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$next_post_id#p$next_post_id"; - $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], "", ''); - } - - meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], "", ''); - trigger_error($message); - } - else - { - confirm_box(false, 'DELETE_MESSAGE', $s_hidden_fields); - } -} - - -if ($mode == 'delete' && $poster_id != $user->data['user_id'] && !$auth->acl_get('f_delete', $forum_id)) -{ - trigger_error('DELETE_OWN_POSTS'); -} - -if ($mode == 'delete' && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $topic_last_post_id) -{ - trigger_error('CANNOT_DELETE_REPLIED'); -} - +// Handle delete mode... if ($mode == 'delete') { - trigger_error('USER_CANNOT_DELETE'); + handle_post_delete($forum_id, $topic_id, $post_id, $post_data); + exit; } - -// HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)); -$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)); -$img_status = ($auth->acl_get('f_img', $forum_id)); -$flash_status = ($auth->acl_get('f_flash', $forum_id)); -$quote_status = ($auth->acl_get('f_reply', $forum_id)); - -// Bump Topic -if ($mode == 'bump' && ($bump_time = bump_topic_allowed($forum_id, $topic_bumped, $topic_last_post_time, $topic_poster, $topic_last_poster_id))) +// Handle bump mode... +if ($mode == 'bump') { - $db->sql_transaction(); + if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id'])) + { + $db->sql_transaction(); - $db->sql_query('UPDATE ' . POSTS_TABLE . " - SET post_time = $current_time - WHERE post_id = $topic_last_post_id - AND topic_id = $topic_id"); + $db->sql_query('UPDATE ' . POSTS_TABLE . " + SET post_time = $current_time + WHERE post_id = {$post_data['topic_last_post_id']} + AND topic_id = $topic_id"); - $db->sql_query('UPDATE ' . TOPICS_TABLE . " - SET topic_last_post_time = $current_time, - topic_bumped = 1, - topic_bumper = " . $user->data['user_id'] . " - WHERE topic_id = $topic_id"); + $db->sql_query('UPDATE ' . TOPICS_TABLE . " + SET topic_last_post_time = $current_time, + topic_bumped = 1, + topic_bumper = " . $user->data['user_id'] . " + WHERE topic_id = $topic_id"); - update_post_information('forum', $forum_id); + update_post_information('forum', $forum_id); - $db->sql_query('UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $current_time - WHERE user_id = " . $user->data['user_id']); + $db->sql_query('UPDATE ' . USERS_TABLE . " + SET user_lastpost_time = $current_time + WHERE user_id = " . $user->data['user_id']); - $db->sql_transaction('commit'); + $db->sql_transaction('commit'); - markread('post', $forum_id, $topic_id, $current_time); + markread('post', $forum_id, $topic_id, $current_time); - add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_BUMP'], $topic_title)); + add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_BUMP'], $post_data['topic_title'])); - meta_refresh(3, "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$topic_last_post_id#p$topic_last_post_id"); + $meta_url = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}#p{$post_data['topic_last_post_id']}"; + meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '", '') . '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); -} -else if ($mode == 'bump') -{ + trigger_error($message); + } + trigger_error('BUMP_ERROR'); } + +// Determine some vars +$post_data['quote_username'] = (!empty($post_data['username'])) ? $post_data['username'] : ((!empty($post_data['post_username'])) ? $post_data['post_username'] : ''); +$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; +$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); +$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; +$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; +$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; +$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; +$post_data['poll_options'] = array(); + +// Get Poll Data +if ($post_data['poll_start']) +{ + $sql = 'SELECT poll_option_text + FROM ' . POLL_OPTIONS_TABLE . " + WHERE topic_id = $topic_id + ORDER BY poll_option_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $post_data['poll_options'][] = trim($row['poll_option_text']); + } + $db->sql_freeresult($result); +} + +$orig_poll_options_size = sizeof($post_data['poll_options']); + +$message_parser = new parse_message(); + +if (isset($post_data['post_text'])) +{ + $message_parser->message = &$post_data['post_text']; + unset($post_data['post_text']); +} + +$message_parser->get_submitted_attachment_data(); + +// Set some default variables +$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); +foreach ($uninit as $var_name => $default_value) +{ + if (!isset($post_data[$var_name])) + { + $post_data[$var_name] = $default_value; + } +} +unset($uninit); + +if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') +{ + $sql = 'SELECT attach_id, physical_filename, comment, real_filename, extension, mimetype, filesize, filetime, thumbnail + FROM ' . ATTACHMENTS_TABLE . " + WHERE post_msg_id = $post_id + AND in_message = 0 + ORDER BY filetime " . ((!$config['display_order']) ? 'DESC' : 'ASC'); + $result = $db->sql_query($sql); + $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); +} + +if ($post_data['poster_id'] == ANONYMOUS) +{ + $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; +} +else +{ + $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; +} + +$post_data['enable_urls'] = $post_data['enable_magic_url']; + +if ($mode != 'edit') +{ + $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; + $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; + $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; + $post_data['enable_urls'] = true; +} + +$post_data['enable_magic_url'] = $post_data['drafts'] = false; + +// User own some drafts? +if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts')) +{ + $sql = 'SELECT draft_id + FROM ' . DRAFTS_TABLE . ' + WHERE (forum_id IN (' . $forum_id . ', 0)' . (($topic_id) ? " OR topic_id = $topic_id" : '') . ') + AND user_id = ' . $user->data['user_id'] . + (($draft_id) ? " AND draft_id <> $draft_id" : ''); + $result = $db->sql_query_limit($sql, 1); + + if ($db->sql_fetchrow($result)) + { + $post_data['drafts'] = true; + } + $db->sql_freeresult($result); +} + +$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); + +// Check if user is watching this topic +if ($mode != 'post') +{ + $sql = 'SELECT topic_id + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . $topic_id . ' + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); + $db->sql_freeresult($result); +} + +// Do we want to edit our post ? +if ($mode == 'edit') +{ + $message_parser->bbcode_uid = $post_data['bbcode_uid']; +} + +// HTML, BBCode, Smilies, Images and Flash status +$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; +$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; +$img_status = ($auth->acl_get('f_img', $forum_id)) ? true : false; +$flash_status = ($auth->acl_get('f_flash', $forum_id)) ? true : false; +$quote_status = ($auth->acl_get('f_reply', $forum_id)) ? true : false; + // Save Draft if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) { $subject = request_var('subject', '', true); - $subject = (!$subject && $mode != 'post') ? $topic_title : $subject; + $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; $message = request_var('message', '', true); if ($subject && $message) { $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => $user->data['user_id'], - 'topic_id' => $topic_id, - 'forum_id' => $forum_id, - 'save_time' => $current_time, - 'draft_subject' => $subject, - 'draft_message' => $message)); + 'user_id' => $user->data['user_id'], + 'topic_id' => $topic_id, + 'forum_id' => $forum_id, + 'save_time' => $current_time, + 'draft_subject' => $subject, + 'draft_message' => $message) + ); $db->sql_query($sql); - $meta_info = ($mode == 'post') ? "viewforum.$phpEx$SID&f=$forum_id" : "viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id"; + $meta_info = ($mode == 'post') ? "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id" : "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id"; meta_refresh(3, $meta_info); $message = $user->lang['DRAFT_SAVED'] . '

'; $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } - unset($subject); - unset($message); + unset($subject, $message); } -// Load Draft +// Load requested Draft if ($draft_id && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) { $sql = 'SELECT draft_subject, draft_message @@ -497,8 +429,10 @@ if ($draft_id && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) WHERE draft_id = $draft_id AND user_id = " . $user->data['user_id']; $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - if ($row = $db->sql_fetchrow($result)) + if ($row) { $_REQUEST['subject'] = html_entity_decode($row['draft_subject']); $_REQUEST['message'] = html_entity_decode($row['draft_message']); @@ -511,45 +445,45 @@ if ($draft_id && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) } } -// Load Drafts -if ($load && $drafts) +// Load draft overview +if ($load && $post_data['drafts']) { load_drafts($topic_id, $forum_id); } if ($submit || $preview || $refresh) { - $topic_cur_post_id = request_var('topic_cur_post_id', 0); - $subject = request_var('subject', '', true); + $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); + $post_data['subject'] = request_var('subject', '', true); - if (strcmp($subject, strtoupper($subject)) == 0 && $subject) + // If subject is all-uppercase then we make all lowercase (we do not want to be yelled at too :P) + if ($post_data['subject'] && strcmp($post_data['subject'], strtoupper($post_data['subject'])) == 0) { - $subject = strtolower($subject); + $post_data['subject'] = strtolower($post_data['subject']); } $message_parser->message = request_var('message', '', true); - $username = (isset($_POST['username'])) ? request_var('username', '', true) : $username; - $post_edit_reason = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? request_var('edit_reason', '', true) : ''; + $post_data['username'] = request_var('username', $post_data['username'], true); + $post_data['post_edit_reason'] = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? request_var('edit_reason', '', true) : ''; - $topic_type = (isset($_POST['topic_type'])) ? (int) $_POST['topic_type'] : (($mode != 'post') ? $topic_type : POST_NORMAL); - $topic_time_limit = (isset($_POST['topic_time_limit'])) ? (int) $_POST['topic_time_limit'] : (($mode != 'post') ? $topic_time_limit : 0); - $icon_id = request_var('icon', 0); + $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); + $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); + $post_data['icon_id'] = request_var('icon', 0); - $enable_bbcode = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $enable_smilies = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $enable_sig = (!$config['allow_sig']) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); + $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; + $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; + $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; + $post_data['enable_sig'] = (!$config['allow_sig']) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); - $notify = (isset($_POST['notify'])); - $topic_lock = (isset($_POST['lock_topic'])); - $post_lock = (isset($_POST['lock_post'])); - - $poll_delete = (isset($_POST['poll_delete'])); + $notify = (isset($_POST['notify'])) ? true : false; + $topic_lock = (isset($_POST['lock_topic'])) ? true : false; + $post_lock = (isset($_POST['lock_post'])) ? true : false; + $poll_delete = (isset($_POST['poll_delete'])) ? true : false; if ($submit) { - $status_switch = (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1); + $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); $status_switch = ($status_switch != $check_value); } else @@ -558,8 +492,8 @@ if ($submit || $preview || $refresh) } // Delete Poll - if ($poll_delete && $mode == 'edit' && $poll_options && - ((!$poll_last_vote && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) + if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && + ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) { switch (SQL_LAYER) { @@ -578,6 +512,7 @@ if ($submit || $preview || $refresh) $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " WHERE topic_id = $topic_id"; $db->sql_query($sql); + break; } $topic_sql = array( @@ -594,27 +529,28 @@ if ($submit || $preview || $refresh) WHERE topic_id = $topic_id"; $db->sql_query($sql); - $poll_title = $poll_option_text = ''; - $poll_vote_change = $poll_max_options = $poll_length = 0; + $post_data['poll_title'] = $post_data['poll_option_text'] = ''; + $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; } else { - $poll_title = request_var('poll_title', '', true); - $poll_length = request_var('poll_length', 0); - $poll_option_text = request_var('poll_option_text', '', true); - $poll_max_options = request_var('poll_max_options', 1); - $poll_vote_change = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; + $post_data['poll_title'] = request_var('poll_title', '', true); + $post_data['poll_length'] = request_var('poll_length', 0); + $post_data['poll_option_text'] = request_var('poll_option_text', '', true); + $post_data['poll_max_options'] = request_var('poll_max_options', 1); + $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; } // If replying/quoting and last post id has changed // give user option to continue submit or return to post // notify and show user the post made between his request and the final submit - if (($mode == 'reply' || $mode == 'quote') && $topic_cur_post_id && $topic_cur_post_id != $topic_last_post_id) + if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) { - if (topic_review($topic_id, $forum_id, 'post_review', $topic_cur_post_id)) + if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) { $template->assign_var('S_POST_REVIEW', true); } + $submit = false; $refresh = true; } @@ -626,16 +562,16 @@ if ($submit || $preview || $refresh) $message_md5 = md5($message_parser->message); // Check checksum ... don't re-parse message if the same - $update_message = ($mode != 'edit' || $message_md5 != $post_checksum || $status_switch) ? true : false; + $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch) ? true : false; // Parse message if ($update_message) { - $message_parser->parse($enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $quote_status); + $message_parser->parse($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], $img_status, $flash_status, $quote_status); } else { - $message_parser->bbcode_bitfield = $bbcode_bitfield; + $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) @@ -661,27 +597,24 @@ if ($submit || $preview || $refresh) $db->sql_freeresult($result); } - if ($last_post_time) + if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) { - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) - { - $error[] = $user->lang['FLOOD_ERROR']; - } + $error[] = $user->lang['FLOOD_ERROR']; } } // Validate username - if (($username && !$user->data['is_registered']) || ($mode == 'edit' && $post_username)) + if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['post_username'])) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - if (($result = validate_username(($mode == 'edit' && $post_username) ? $post_username : $username)) != false) + if (($result = validate_username(($mode == 'edit' && $post_data['post_username']) ? $post_data['post_username'] : $post_data['username'])) != false) { $error[] = $result; } } - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && ($mode == 'post' || $mode == 'reply')) + if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) { $confirm_id = request_var('confirm_id', ''); $confirm_code = request_var('confirm_code', ''); @@ -702,37 +635,37 @@ if ($submit || $preview || $refresh) } // Parse subject - if (!$subject && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) + if (!$post_data['subject'] && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) { $error[] = $user->lang['EMPTY_SUBJECT']; } - $poll_last_vote = (isset($poll_last_vote)) ? $poll_last_vote : 0; + $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; - if ($poll_option_text && - ($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && (!$poll_last_vote || $auth->acl_get('m_edit', $forum_id)))) + if ($post_data['poll_option_text'] && + ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id)))) && $auth->acl_get('f_poll', $forum_id)) { $poll = array( - 'poll_title' => $poll_title, - 'poll_length' => $poll_length, - 'poll_max_options' => $poll_max_options, - 'poll_option_text' => $poll_option_text, - 'poll_start' => $poll_start, - 'poll_last_vote' => $poll_last_vote, - 'poll_vote_change' => $poll_vote_change, - 'enable_bbcode' => $enable_bbcode, - 'enable_urls' => $enable_urls, - 'enable_smilies' => $enable_smilies, + 'poll_title' => $post_data['poll_title'], + 'poll_length' => $post_data['poll_length'], + 'poll_max_options' => $post_data['poll_max_options'], + 'poll_option_text' => $post_data['poll_option_text'], + 'poll_start' => $post_data['poll_start'], + 'poll_last_vote' => $post_data['poll_last_vote'], + 'poll_vote_change' => $post_data['poll_vote_change'], + 'enable_bbcode' => $post_data['enable_bbcode'], + 'enable_urls' => $post_data['enable_urls'], + 'enable_smilies' => $post_data['enable_smilies'], 'img_status' => $img_status ); $message_parser->parse_poll($poll); - $poll_options = isset($poll['poll_options']) ? $poll['poll_options'] : ''; - $poll_title = isset($poll['poll_title']) ? $poll['poll_title'] : ''; + $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : ''; + $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - if ($poll_last_vote && ($poll['poll_options_size'] < $orig_poll_options_size)) + if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) { $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; } @@ -743,9 +676,9 @@ if ($submit || $preview || $refresh) } // Check topic type - if ($topic_type != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) + if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) { - switch ($topic_type) + switch ($post_data['topic_type']) { case POST_GLOBAL: case POST_ANNOUNCE: @@ -758,6 +691,7 @@ if ($submit || $preview || $refresh) default: $auth_option = ''; + break; } if (!$auth->acl_get($auth_option, $forum_id)) @@ -775,14 +709,14 @@ if ($submit || $preview || $refresh) if (!sizeof($error) && $submit) { // Check if we want to de-globalize the topic... and ask for new forum - if ($topic_type != POST_GLOBAL) + if ($post_data['topic_type'] != POST_GLOBAL) { $sql = 'SELECT topic_type, forum_id FROM ' . TOPICS_TABLE . " WHERE topic_id = $topic_id"; $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) { @@ -810,19 +744,19 @@ if ($submit || $preview || $refresh) if ($submit) { // Lock/Unlock Topic - $change_topic_status = $topic_status; - $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_poster)); + $change_topic_status = $post_data['topic_status']; + $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'])); - if ($topic_status == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) + if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) { $change_topic_status = ITEM_UNLOCKED; } - else if ($topic_status == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) + else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) { $change_topic_status = ITEM_LOCKED; } - if ($change_topic_status != $topic_status) + if ($change_topic_status != $post_data['topic_status']) { $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_status = $change_topic_status @@ -830,47 +764,47 @@ if ($submit || $preview || $refresh) AND topic_moved_id = 0"; $db->sql_query($sql); - $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_poster) ? 'USER_' : ''; + $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; - add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $topic_title); + add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); } // Lock/Unlock Post Edit - if ($mode == 'edit' && $post_edit_locked == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) + if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) { - $post_edit_locked = ITEM_UNLOCKED; + $post_data['post_edit_locked'] = ITEM_UNLOCKED; } - else if ($mode == 'edit' && $post_edit_locked == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) + else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) { - $post_edit_locked = ITEM_LOCKED; + $post_data['post_edit_locked'] = ITEM_LOCKED; } - $post_data = array( - 'topic_title' => (!$topic_title) ? $subject : $topic_title, - 'topic_first_post_id' => (isset($topic_first_post_id)) ? (int) $topic_first_post_id : 0, - 'topic_last_post_id' => (isset($topic_last_post_id)) ? (int) $topic_last_post_id : 0, - 'topic_time_limit' => (int) $topic_time_limit, + $data = array( + 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['subject'] : $post_data['topic_title'], + 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, + 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, + 'topic_time_limit' => (int) $post_data['topic_time_limit'], 'post_id' => (int) $post_id, 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, - 'icon_id' => (int) $icon_id, - 'poster_id' => (int) $poster_id, - 'enable_sig' => (bool) $enable_sig, - 'enable_bbcode' => (bool) $enable_bbcode, - 'enable_smilies' => (bool) $enable_smilies, - 'enable_urls' => (bool) $enable_urls, - 'enable_indexing' => (bool) $enable_indexing, + 'icon_id' => (int) $post_data['icon_id'], + 'poster_id' => (int) $post_data['poster_id'], + 'enable_sig' => (bool) $post_data['enable_sig'], + 'enable_bbcode' => (bool) $post_data['enable_bbcode'], + 'enable_smilies' => (bool) $post_data['enable_smilies'], + 'enable_urls' => (bool) $post_data['enable_urls'], + 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, - 'post_time' => (isset($post_time)) ? (int) $post_time : $current_time, - 'post_checksum' => (isset($post_checksum)) ? (string) $post_checksum : '', - 'post_edit_reason' => $post_edit_reason, - 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_edit_user)) ? (int) $post_edit_user : 0), - 'forum_parents' => $forum_parents, - 'forum_name' => $forum_name, + 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, + 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', + 'post_edit_reason' => $post_data['post_edit_reason'], + 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), + 'forum_parents' => $post_data['forum_parents'], + 'forum_name' => $post_data['forum_name'], 'notify' => $notify, - 'notify_set' => $notify_set, - 'poster_ip' => (isset($poster_ip)) ? (int) $poster_ip : $user->ip, - 'post_edit_locked' => (int) $post_edit_locked, + 'notify_set' => $post_data['notify_set'], + 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, + 'post_edit_locked' => (int) $post_data['post_edit_locked'], 'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, @@ -879,33 +813,40 @@ if ($submit || $preview || $refresh) ); unset($message_parser); - submit_post($mode, $subject, $username, $topic_type, $poll, $post_data, $update_message); + $redirect_url = submit_post($mode, $post_data['subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); + + meta_refresh(3, $redirect_url); + + $message = ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? (($mode == 'edit') ? 'POST_EDITED_MOD' : 'POST_STORED_MOD') : (($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'); + $message = $user->lang[$message] . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? '

' . sprintf($user->lang['VIEW_MESSAGE'], '', '') : ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); } } - $post_subject = stripslashes($subject); + $post_data['post_subject'] = $post_data['subject']; } // Preview if (!sizeof($error) && $preview) { - $post_time = ($mode == 'edit') ? $post_time : $current_time; + $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; - $preview_message = $message_parser->format_display($enable_bbcode, $enable_urls, $enable_smilies, false); + $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); - $preview_signature = ($mode == 'edit') ? $user_sig : $user->data['user_sig']; - $preview_signature_uid = ($mode == 'edit') ? $user_sig_bbcode_uid : $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = ($mode == 'edit') ? $user_sig_bbcode_bitfield : $user->data['user_sig_bbcode_bitfield']; + $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; + $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; + $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; // Signature - if ($enable_sig && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) + if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) { $parse_sig = new parse_message($preview_signature); $parse_sig->bbcode_uid = $preview_signature_uid; $parse_sig->bbcode_bitfield = $preview_signature_bitfield; // Not sure about parameters for bbcode/smilies/urls... in signatures - $parse_sig->format_display($config['allow_bbcode'], true, $config['allow_smilies']); + $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']); $preview_signature = $parse_sig->message; unset($parse_sig); } @@ -914,30 +855,30 @@ if (!sizeof($error) && $preview) $preview_signature = ''; } - $preview_subject = censor_text($subject); + $preview_subject = censor_text($post_data['subject']); // Poll Preview - if (($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && (!$poll_last_vote || $auth->acl_get('m_edit', $forum_id)))) + if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id)))) && $auth->acl_get('f_poll', $forum_id)) { - $parse_poll = new parse_message($poll_title); + $parse_poll = new parse_message($post_data['poll_title']); $parse_poll->bbcode_uid = $message_parser->bbcode_uid; $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; - $parse_poll->format_display($enable_bbcode, $enable_urls, $enable_smilies); + $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); $template->assign_vars(array( - 'S_HAS_POLL_OPTIONS'=> (sizeof($poll_options)), - 'S_IS_MULTI_CHOICE' => ($poll_max_options > 1) ? true : false, + 'S_HAS_POLL_OPTIONS'=> (sizeof($post_data['poll_options'])), + 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, 'POLL_QUESTION' => $parse_poll->message, - 'L_POLL_LENGTH' => ($poll_length) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_length + $poll_start)) : '', - 'L_MAX_VOTES' => ($poll_max_options == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $poll_max_options)) + 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($post_data['poll_length'] + $post_data['poll_start'])) : '', + 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) ); - $parse_poll->message = implode("\n", $poll_options); - $parse_poll->format_display($enable_bbcode, $enable_urls, $enable_smilies); + $parse_poll->message = implode("\n", $post_data['poll_options']); + $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); $preview_poll_options = explode('
', $parse_poll->message); unset($parse_poll); @@ -982,45 +923,44 @@ if (!sizeof($error) && $preview) 'S_DISPLAY_PREVIEW' => true) ); } - - unset($post_text); } // Decode text for message display -$bbcode_uid = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid; -$message_parser->decode_message($bbcode_uid); +$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; +$message_parser->decode_message($post_data['bbcode_uid']); if ($mode == 'quote' && !$preview && !$refresh) { - $message_parser->message = '[quote="' . $quote_username . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; + $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; } if (($mode == 'reply' || $mode == 'quote') && !$preview && !$refresh) { - $post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . censor_text($post_subject); + $post_data['post_subject'] = ((!preg_match('/^Re:/', $post_data['post_subject'])) ? 'Re: ' : '') . censor_text($post_data['post_subject']); } $attachment_data = $message_parser->attachment_data; $filename_data = $message_parser->filename_data; -$post_text = $message_parser->message; +$post_data['post_text'] = $message_parser->message; -if (sizeof($poll_options) && $poll_title) +if (sizeof($post_data['poll_options']) && $post_data['poll_title']) { - $message_parser->message = $poll_title; - $message_parser->bbcode_uid = $bbcode_uid; + $message_parser->message = $post_data['poll_title']; + $message_parser->bbcode_uid = $post_data['bbcode_uid']; $message_parser->decode_message(); - $poll_title = $message_parser->message; + $post_data['poll_title'] = $message_parser->message; - $message_parser->message = implode("\n", $poll_options); + $message_parser->message = implode("\n", $post_data['poll_options']); $message_parser->decode_message(); - $poll_options = explode("\n", $message_parser->message); + $post_data['poll_options'] = explode("\n", $message_parser->message); } unset($message_parser); // MAIN POSTING PAGE BEGINS HERE // Forum moderators? +$moderators = array(); get_moderators($moderators, $forum_id); // Generate smiley listing @@ -1029,28 +969,29 @@ generate_smilies('inline', $forum_id); // Generate inline attachment select box posting_gen_inline_attachments($attachment_data); - // Do show topic type selection only in first post. $topic_type_toggle = false; -if ($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id)) +if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) { - $topic_type_toggle = posting_gen_topic_types($forum_id, $topic_type); + $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); } $s_topic_icons = false; -if ($enable_icons) +if ($post_data['enable_icons']) { - $s_topic_icons = posting_gen_topic_icons($mode, $icon_id); + $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); } -$bbcode_checked = (isset($enable_bbcode)) ? !$enable_bbcode : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); -$smilies_checked = (isset($enable_smilies)) ? !$enable_smilies : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); -$urls_checked = (isset($enable_urls)) ? !$enable_urls : 0; -$sig_checked = $enable_sig; -$notify_checked = (isset($notify)) ? $notify : ((!$notify_set) ? (($user->data['is_registered']) ? $user->data['user_notify'] : 0) : 1); -$lock_topic_checked = (isset($topic_lock)) ? $topic_lock : (($topic_status == ITEM_LOCKED) ? 1 : 0); -$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_edit_locked; +$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); +$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); +$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; +$sig_checked = $post_data['enable_sig']; +$lock_topic_checked = (isset($topic_lock)) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); +$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; + +// If in edit mode, and the user is not the poster, we do not take the notification into account +$notify_checked = (isset($notify)) ? $notify : (($mode != 'edit') ? $user->data['user_notify'] : $post_data['notify_set']); // Page title & action URL, include session_id for security purpose $s_action = "posting.$phpEx?sid=" . $user->session_id . "&mode=$mode&f=$forum_id"; @@ -1071,32 +1012,16 @@ switch ($mode) case 'delete': case 'edit': $page_title = $user->lang['EDIT_POST']; + break; } -$forum_data = array( - 'parent_id' => $parent_id, - 'left_id' => $left_id, - 'right_id' => $right_id, - 'forum_parents' => $forum_parents, - 'forum_name' => $forum_name, - 'forum_id' => $forum_id, - 'forum_type' => $forum_type, - 'forum_desc' => $forum_desc, - 'forum_desc_uid' => $forum_desc_uid, - 'forum_desc_bitfield' => $forum_desc_bitfield, - 'forum_rules' => $forum_rules, - 'forum_rules_uid' => $forum_rules_uid, - 'forum_rules_bitfield' => $forum_rules_bitfield, - 'forum_rules_link' => $forum_rules_link -); - // Build Navigation Links -generate_forum_nav($forum_data); +generate_forum_nav($post_data); // Build Forum Rules -generate_forum_rules($forum_data); +generate_forum_rules($post_data); -if ($config['enable_post_confirm'] && !$user->data['is_registered'] && ($mode == 'post' || $mode == 'reply')) +if ($config['enable_post_confirm'] && !$user->data['is_registered'] && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { // Show confirm image $sql = 'DELETE FROM ' . CONFIRM_TABLE . " @@ -1120,68 +1045,67 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && ($mode == 'S_CONFIRM_CODE' => true, 'CONFIRM_ID' => $confirm_id, 'CONFIRM_IMAGE' => '', - 'L_POST_CONFIRM_EXPLAIN' => sprintf($user->lang['POST_CONFIRM_EXPLAIN'], '', ''), + 'L_POST_CONFIRM_EXPLAIN' => sprintf($user->lang['POST_CONFIRM_EXPLAIN'], '', ''), )); } -$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; +$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; $s_hidden_fields .= ''; -$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; +$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_gets('f_attach', 'u_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; // Start assigning vars for main posting page ... $template->assign_vars(array( 'L_POST_A' => $page_title, - 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $topic_first_post_id)) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], + 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN'=> (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', - 'FORUM_NAME' => $forum_name, - 'FORUM_DESC' => ($forum_desc) ? generate_text_for_display($forum_desc, $forum_desc_uid, $forum_desc_bitfield) : '', - 'TOPIC_TITLE' => $topic_title, + 'FORUM_NAME' => $post_data['forum_name'], + 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield']) : '', + 'TOPIC_TITLE' => $post_data['topic_title'], 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '', - 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? stripslashes($username) : '', - 'SUBJECT' => $post_subject, - 'MESSAGE' => $post_text, - 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''), + 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', + 'SUBJECT' => $post_data['post_subject'], + 'MESSAGE' => $post_data['post_text'], + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''), 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], 'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']), - 'POST_DATE' => ($post_time) ? $user->format_date($post_time) : '', + 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', - 'TOPIC_TIME_LIMIT' => (int) $topic_time_limit, - 'EDIT_REASON' => $post_edit_reason, - - 'U_VIEW_FORUM' => "viewforum.$phpEx$SID&f=" . $forum_id, - 'U_VIEWTOPIC' => ($mode != 'post') ? "viewtopic.$phpEx$SID&$forum_id&t=$topic_id" : '', - 'U_PROGRESS_BAR' => "posting.$phpEx$SID&f=$forum_id&mode=popup", - 'UA_PROGRESS_BAR' => "posting.$phpEx$SID&f=$forum_id&mode=popup", + 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], + 'EDIT_REASON' => $post_data['post_edit_reason'], + 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id", + 'U_VIEWTOPIC' => ($mode != 'post') ? "{$phpbb_root_path}viewtopic.$phpEx$SID&$forum_id&t=$topic_id" : '', + 'U_PROGRESS_BAR' => "{$phpbb_root_path}posting.$phpEx$SID&f=$forum_id&mode=popup", + 'UA_PROGRESS_BAR' => "{$phpbb_root_path}posting.$phpEx$SID&f=$forum_id&mode=popup", 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, 'S_EDIT_POST' => ($mode == 'edit') ? true : false, 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_username)) ? true : false, - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $topic_last_post_id && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), - 'S_BBCODE_ALLOWED' => $bbcode_status, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']), - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => ($user->data['is_registered']), - 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_poster))), - 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', - 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)), - 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered']), - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $drafts), - 'S_FORM_ENCTYPE' => $form_enctype, + 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['post_username'])) ? true : false, + 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_BBCODE_ALLOWED' => $bbcode_status, + 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', + 'S_SMILIES_ALLOWED' => $smilies_status, + 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', + 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, + 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', + 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id'])) ? false : true, + 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', + 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster']))) ? true : false, + 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', + 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, + 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', + 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', + 'S_TYPE_TOGGLE' => $topic_type_toggle, + 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered']) ? true : false, + 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, + 'S_FORM_ENCTYPE' => $form_enctype, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_FLASH' => $flash_status, @@ -1211,21 +1135,21 @@ while ($row = $db->sql_fetchrow($result)) $db->sql_freeresult($result); // Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && (!$poll_last_vote || $auth->acl_get('m_edit', $forum_id)))) +if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'] && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id)))) && $auth->acl_get('f_poll', $forum_id)) { $template->assign_vars(array( 'S_SHOW_POLL_BOX' => true, 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && $poll_options && ((!$poll_last_vote && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), 'L_POLL_OPTIONS_EXPLAIN'=> sprintf($user->lang['POLL_OPTIONS_EXPLAIN'], $config['max_poll_options']), - 'VOTE_CHANGE_CHECKED' => (isset($poll_vote_change) && $poll_vote_change) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($poll_title)) ? $poll_title : '', - 'POLL_OPTIONS' => (isset($poll_options) && $poll_options) ? implode("\n", $poll_options) : '', - 'POLL_MAX_OPTIONS' => (isset($poll_max_options)) ? (int) $poll_max_options : 1, - 'POLL_LENGTH' => $poll_length) + 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', + 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', + 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', + 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, + 'POLL_LENGTH' => $post_data['poll_length']) ); } @@ -1243,7 +1167,7 @@ $template->set_filenames(array( 'body' => 'posting_body.html') ); -make_jumpbox('viewforum.'.$phpEx); +make_jumpbox('viewforum.' . $phpEx); // Topic review if ($mode == 'reply' || $mode == 'quote') @@ -1256,744 +1180,9 @@ if ($mode == 'reply' || $mode == 'quote') page_footer(); - /** -* Delete Post +* Show upload popup (progress bar) */ -function delete_post($mode, $post_id, $topic_id, $forum_id, &$data) -{ - global $db, $user, $config, $auth, $phpEx, $SID, $phpbb_root_path; - - // Specify our post mode - $post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'delete_topic' : (($data['topic_first_post_id'] == $post_id) ? 'delete_first_post' : (($data['topic_last_post_id'] == $post_id) ? 'delete_last_post' : 'delete')); - $sql_data = array(); - $next_post_id = 0; - - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $db->sql_transaction(); - - if (!delete_posts('post_id', array($post_id), false)) - { - // Try to delete topic, we may had an previous error causing inconsistency - if ($post_mode = 'delete_topic') - { - delete_topics('topic_id', array($topic_id), false); - } - trigger_error('ALREADY_DELETED'); - } - - $db->sql_transaction('commit'); - - // Collect the necessary informations for updating the tables - $sql_data[FORUMS_TABLE] = ''; - switch ($post_mode) - { - case 'delete_topic': - delete_topics('topic_id', array($topic_id), false); - set_config('num_topics', $config['num_topics'] - 1, true); - - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] .= 'forum_posts = forum_posts - 1, forum_topics_real = forum_topics_real - 1'; - $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''; - } - - $update_sql = update_post_information('forum', $forum_id, true); - if (sizeof($update_sql)) - { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); - } - - $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); - break; - - case 'delete_first_post': - $sql = 'SELECT p.post_id, p.poster_id, p.post_username, u.username - FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u - WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - ORDER BY p.post_time ASC"; - $result = $db->sql_query_limit($sql, 1); - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; - } - - $sql_data[TOPICS_TABLE] = 'topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; - $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); - - $next_post_id = (int) $row['post_id']; - break; - - case 'delete_last_post': - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; - } - - $update_sql = update_post_information('forum', $forum_id, true); - if (sizeof($update_sql)) - { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); - } - - $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); - - $update_sql = update_post_information('topic', $topic_id, true); - if (sizeof($update_sql)) - { - $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]); - $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]); - } - else - { - $sql = 'SELECT MAX(post_id) as last_post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id " . - ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : ''); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $next_post_id = (int) $row['last_post_id']; - } - break; - - case 'delete': - $sql = 'SELECT post_id - FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id " . - ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . ' - AND post_time > ' . $data['post_time'] . ' - ORDER BY post_time ASC'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($data['topic_type'] != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; - } - - $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); - $next_post_id = (int) $row['post_id']; - break; - } - - $sql_data[USERS_TABLE] = ($auth->acl_get('f_postcount', $forum_id)) ? 'user_posts = user_posts - 1' : ''; - set_config('num_posts', $config['num_posts'] - 1, true); - - $db->sql_transaction(); - - $where_sql = array(FORUMS_TABLE => "forum_id = $forum_id", TOPICS_TABLE => "topic_id = $topic_id", USERS_TABLE => 'user_id = ' . $data['poster_id']); - - foreach ($sql_data as $table => $update_sql) - { - if ($update_sql) - { - $db->sql_query("UPDATE $table SET $update_sql WHERE " . $where_sql[$table]); - } - } - - $db->sql_transaction('commit'); - - return $next_post_id; -} - - -/** -* Submit Post -*/ -function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true) -{ - global $db, $auth, $user, $config, $phpEx, $SID, $template, $phpbb_root_path; - - // We do not handle erasing posts here - if ($mode == 'delete') - { - return; - } - - $current_time = time(); - - if ($mode == 'post') - { - $post_mode = 'post'; - $update_message = true; - } - else if ($mode != 'edit') - { - $post_mode = 'reply'; - $update_message = true; - } - else if ($mode == 'edit') - { - $post_mode = ($data['topic_first_post_id'] == $data['topic_last_post_id']) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit')); - } - - - // Collect some basic informations about which tables and which rows to update/insert - $sql_data = array(); - $poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id']; - - // Collect Informations - switch ($post_mode) - { - case 'post': - case 'reply': - $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], - 'poster_id' => (int) $user->data['user_id'], - 'icon_id' => $data['icon_id'], - 'poster_ip' => $user->ip, - 'post_time' => $current_time, - 'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, - 'enable_bbcode' => $data['enable_bbcode'], - 'enable_smilies' => $data['enable_smilies'], - 'enable_magic_url' => $data['enable_urls'], - 'enable_sig' => $data['enable_sig'], - 'post_username' => (!$user->data['is_registered']) ? stripslashes($username) : '', - 'post_subject' => $subject, - 'post_text' => $data['message'], - 'post_checksum' => $data['message_md5'], - 'post_encoding' => $user->lang['ENCODING'], - 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data['bbcode_bitfield'], - 'bbcode_uid' => $data['bbcode_uid'], - 'post_edit_locked' => $data['post_edit_locked'] - ); - break; - - case 'edit_first_post': - case 'edit': - - if (!$auth->acl_gets('m_', 'a_') || $data['post_edit_reason']) - { - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_time' => $current_time - ); - - $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; - } - - case 'edit_last_post': - case 'edit_topic': - - if (($post_mode == 'edit_last_post' || $post_mode == 'edit_topic') && $data['post_edit_reason']) - { - $sql_data[POSTS_TABLE]['sql'] = array( - 'post_edit_time' => $current_time - ); - - $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; - } - - if (!isset($sql_data[POSTS_TABLE]['sql'])) - { - $sql_data[POSTS_TABLE]['sql'] = array(); - } - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], - 'poster_id' => $data['poster_id'], - 'icon_id' => $data['icon_id'], - 'post_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, - 'enable_bbcode' => $data['enable_bbcode'], - 'enable_smilies' => $data['enable_smilies'], - 'enable_magic_url' => $data['enable_urls'], - 'enable_sig' => $data['enable_sig'], - 'post_username' => ($username && $data['poster_id'] == ANONYMOUS) ? stripslashes($username) : '', - 'post_subject' => $subject, - 'post_edit_reason' => $data['post_edit_reason'], - 'post_edit_user' => (int) $data['post_edit_user'], - 'post_checksum' => $data['message_md5'], - 'post_encoding' => $user->lang['ENCODING'], - 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data['bbcode_bitfield'], - 'bbcode_uid' => $data['bbcode_uid'], - 'post_edit_locked' => $data['post_edit_locked']) - ); - - if ($update_message) - { - $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message']; - } - - break; - } - - // And the topic ladies and gentlemen - switch ($post_mode) - { - case 'post': - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_poster' => (int) $user->data['user_id'], - 'topic_time' => $current_time, - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], - 'icon_id' => $data['icon_id'], - 'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, - 'topic_title' => $subject, - 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? stripslashes($username) : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), - 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, - 'topic_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0 - ); - - if (isset($poll['poll_options']) && !empty($poll['poll_options'])) - { - $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( - 'poll_title' => $poll['poll_title'], - 'poll_start' => ($poll['poll_start']) ? $poll['poll_start'] : $current_time, - 'poll_max_options' => $poll['poll_max_options'], - 'poll_length' => ($poll['poll_length'] * 86400), - 'poll_vote_change' => $poll['poll_vote_change']) - ); - } - - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : ''); - - if ($topic_type != POST_GLOBAL) - { - if (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; - } - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? ', forum_topics = forum_topics + 1' : ''); - } - break; - - case 'reply': - $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies_real = topic_replies_real + 1, topic_bumped = 0, topic_bumper = 0' . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? ', topic_replies = topic_replies + 1' : ''); - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : ''); - - if ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) && $topic_type != POST_GLOBAL) - { - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + 1'; - } - break; - - case 'edit_topic': - case 'edit_first_post': - - $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id'], - 'icon_id' => $data['icon_id'], - 'topic_approved' => ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1, - 'topic_title' => $subject, - 'topic_first_poster_name' => stripslashes($username), - 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, - 'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '', - 'poll_start' => (isset($poll['poll_options'])) ? (($poll['poll_start']) ? $poll['poll_start'] : $current_time) : 0, - 'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1, - 'poll_length' => (isset($poll['poll_options'])) ? ($poll['poll_length'] * 86400) : 0, - 'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0, - - 'topic_attachment' => ($post_mode == 'edit_topic') ? ((isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data'])) ? 1 : 0) : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0) - ); - break; - } - - $db->sql_transaction(); - - // Submit new topic - if ($post_mode == 'post') - { - $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . - $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); - $db->sql_query($sql); - - $data['topic_id'] = $db->sql_nextid(); - - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data['topic_id']) - ); - unset($sql_data[TOPICS_TABLE]['sql']); - } - - // Submit new post - if ($post_mode == 'post' || $post_mode == 'reply') - { - if ($post_mode == 'reply') - { - $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data['topic_id']) - ); - } - - $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . - $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); - $db->sql_query($sql); - $data['post_id'] = $db->sql_nextid(); - - if ($post_mode == 'post') - { - $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_first_post_id' => $data['post_id'], - 'topic_last_post_id' => $data['post_id'], - 'topic_last_post_time' => $current_time, - 'topic_last_poster_id' => (int) $user->data['user_id'], - 'topic_last_poster_name'=> (!$user->data['is_registered'] && $username) ? stripslashes($username) : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : '') - ); - } - - unset($sql_data[POSTS_TABLE]['sql']); - } - - $make_global = false; - - // Are we globalising or unglobalising? - if ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic') - { - $sql = 'SELECT topic_type, topic_replies_real, topic_approved - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $data['topic_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // globalise - if ($row['topic_type'] != POST_GLOBAL && $topic_type == POST_GLOBAL) - { - // Decrement topic/post count - $make_global = true; - $sql_data[FORUMS_TABLE]['stat'] = array(); - - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real - 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics - 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = 0 - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - // unglobalise - else if ($row['topic_type'] == POST_GLOBAL && $topic_type != POST_GLOBAL) - { - // Increment topic/post count - $make_global = true; - $sql_data[FORUMS_TABLE]['stat'] = array(); - - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts + ' . ($row['topic_replies_real'] + 1); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics_real = forum_topics_real + 1' . (($row['topic_approved']) ? ', forum_topics = forum_topics + 1' : ''); - - // Update forum_ids for all posts - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . $data['forum_id'] . ' - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - } - - // Update the topics table - if (isset($sql_data[TOPICS_TABLE]['sql'])) - { - $db->sql_query('UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' - WHERE topic_id = ' . $data['topic_id']); - } - - // Update the posts table - if (isset($sql_data[POSTS_TABLE]['sql'])) - { - $db->sql_query('UPDATE ' . POSTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' - WHERE post_id = ' . $data['post_id']); - } - - // Update Poll Tables - if (isset($poll['poll_options']) && !empty($poll['poll_options'])) - { - $cur_poll_options = array(); - - if ($poll['poll_start'] && $mode == 'edit') - { - $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' - WHERE topic_id = ' . $data['topic_id'] . ' - ORDER BY poll_option_id'; - $result = $db->sql_query($sql); - - while ($cur_poll_options[] = $db->sql_fetchrow($result)); - $db->sql_freeresult($result); - } - - $sql_insert_ary = array(); - for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++) - { - if (trim($poll['poll_options'][$i])) - { - if (!$cur_poll_options[$i]) - { - $sql_insert_ary[] = array( - 'poll_option_id' => (int) $i, - 'topic_id' => (int) $data['topic_id'], - 'poll_option_text' => (string) $poll['poll_options'][$i] - ); - } - else if ($poll['poll_options'][$i] != $cur_poll_options[$i]) - { - $sql = "UPDATE " . POLL_OPTIONS_TABLE . " - SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "' - WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . " - AND topic_id = " . $data['topic_id']; - $db->sql_query($sql); - } - } - } - - if (sizeof($sql_insert_ary)) - { - switch (SQL_LAYER) - { - case 'mysql': - case 'mysql4': - case 'mysqli': - $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('MULTI_INSERT', $sql_insert_ary)); - break; - - default: - foreach ($sql_insert_ary as $ary) - { - $db->sql_query('INSERT INTO ' . POLL_OPTIONS_TABLE . ' ' . $db->sql_build_array('INSERT', $ary)); - } - break; - } - } - - if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' - WHERE poll_option_id >= ' . sizeof($poll['poll_options']) . ' - AND topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - } - - // Submit Attachments - if (sizeof($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) - { - $space_taken = $files_added = 0; - - foreach ($data['attachment_data'] as $pos => $attach_row) - { - if ($attach_row['attach_id']) - { - // update entry in db if attachment already stored in db and filespace - $sql = 'UPDATE ' . ATTACHMENTS_TABLE . " - SET comment = '" . $db->sql_escape($attach_row['comment']) . "' - WHERE attach_id = " . (int) $attach_row['attach_id']; - $db->sql_query($sql); - } - else - { - // insert attachment into db - if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . basename($attach_row['physical_filename']))) - { - continue; - } - - $attach_sql = array( - 'post_msg_id' => $data['post_id'], - 'topic_id' => $data['topic_id'], - 'in_message' => 0, - 'poster_id' => $poster_id, - 'physical_filename' => basename($attach_row['physical_filename']), - 'real_filename' => basename($attach_row['real_filename']), - 'comment' => $attach_row['comment'], - 'extension' => $attach_row['extension'], - 'mimetype' => $attach_row['mimetype'], - 'filesize' => $attach_row['filesize'], - 'filetime' => $attach_row['filetime'], - 'thumbnail' => $attach_row['thumbnail'] - ); - - $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' . - $db->sql_build_array('INSERT', $attach_sql); - $db->sql_query($sql); - - $space_taken += $attach_row['filesize']; - $files_added++; - } - } - - if (sizeof($data['attachment_data'])) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_attachment = 1 - WHERE post_id = ' . $data['post_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_attachment = 1 - WHERE topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - - set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true); - set_config('num_files', $config['num_files'] + $files_added, true); - } - - $db->sql_transaction('commit'); - - if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post') - { - if ($topic_type != POST_GLOBAL) - { - $update_sql = update_post_information('forum', $data['forum_id'], true); - if (sizeof($update_sql)) - { - $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]); - } - } - - $update_sql = update_post_information('topic', $data['topic_id'], true); - if (sizeof($update_sql)) - { - $sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]); - } - } - - if ($make_global) - { - $update_sql = update_post_information('forum', $data['forum_id'], true); - if (sizeof($update_sql)) - { - $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', $update_sql[$data['forum_id']]); - } - } - - if ($post_mode == 'edit_topic') - { - $update_sql = update_post_information('topic', $data['topic_id'], true); - if (sizeof($update_sql)) - { - $sql_data[TOPICS_TABLE]['stat'][] = implode(', ', $update_sql[$data['topic_id']]); - } - } - - // Update total post count, do not consider moderated posts/topics - if (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) - { - if ($post_mode == 'post') - { - set_config('num_topics', $config['num_topics'] + 1, true); - set_config('num_posts', $config['num_posts'] + 1, true); - } - - if ($post_mode == 'reply') - { - set_config('num_posts', $config['num_posts'] + 1, true); - } - } - - // Update forum stats - $db->sql_transaction(); - - $where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $user->data['user_id']); - - foreach ($sql_data as $table => $update_ary) - { - if (isset($update_ary['stat']) && implode('', $update_ary['stat'])) - { - $db->sql_query("UPDATE $table SET " . implode(', ', $update_ary['stat']) . ' WHERE ' . $where_sql[$table]); - } - } - - // Delete topic shadows (if any exist). We do not need a shadow topic for an global announcement - if ($make_global) - { - $db->sql_query('DELETE FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = ' . $data['topic_id']); - } - - // Index message contents - if ($update_message && $data['enable_indexing']) - { - // Select the search method and do some additional checks to ensure it can actually be utilised - $search_type = $config['search_type']; - - if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) - { - trigger_error('NO_SUCH_SEARCH_MODULE'); - } - - require("{$phpbb_root_path}includes/search/$search_type.$phpEx"); - - $error = false; - $search = new $search_type($error); - - if ($error) - { - trigger_error($error); - } - - $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id); - } - - $db->sql_transaction('commit'); - - // Delete draft if post was loaded... - $draft_id = request_var('draft_loaded', 0); - if ($draft_id) - { - $db->sql_query('DELETE FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id AND user_id = " . $user->data['user_id']); - } - - // Topic Notification - if (!$data['notify_set'] && $data['notify']) - { - $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) - VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')'; - $db->sql_query($sql); - } - else if ($data['notify_set'] && !$data['notify']) - { - $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . ' - AND topic_id = ' . $data['topic_id']; - $db->sql_query($sql); - } - - if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') - { - // Mark this topic as posted to - markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']); - } - - // Mark this topic as read - // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', $data['forum_id'], $data['topic_id'], time()); - - // Send Notifications - if ($mode != 'edit' && $mode != 'delete' && (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id']))) - { - user_notification($mode, stripslashes($subject), stripslashes($data['topic_title']), stripslashes($data['forum_name']), $data['forum_id'], $data['topic_id'], $data['post_id']); - } - - if ($mode == 'post') - { - $url = (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f=" . $data['forum_id'] . '&t=' . $data['topic_id'] : "{$phpbb_root_path}viewforum.$phpEx$SID&f=" . $data['forum_id']; - } - else - { - $url = (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&f={$data['forum_id']}&t={$data['topic_id']}&p={$data['post_id']}#p{$data['post_id']}" : "{$phpbb_root_path}viewtopic.$phpEx$SID&f={$data['forum_id']}&t={$data['topic_id']}"; - } - - meta_refresh(3, $url); - - $message = ($auth->acl_get('f_moderate', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? (($mode == 'edit') ? 'POST_EDITED_MOD' : 'POST_STORED_MOD') : (($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'); - $message = $user->lang[$message] . ((!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve', $data['forum_id'])) ? '

' . sprintf($user->lang['VIEW_MESSAGE'], '', '') : '') . '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); -} - function upload_popup($forum_style = 0) { global $template, $user; @@ -2013,4 +1202,74 @@ function upload_popup($forum_style = 0) $template->display('popup'); } +/** +* Do the various checks required for removing posts as well as removing it +*/ +function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) +{ + global $user, $db, $auth; + global $phpbb_root_path, $phpEx, $SID; + + // If moderator removing post or user itself removing post, present a confirmation screen + if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'])) + { + $s_hidden_fields = build_hidden_fields(array( + 'p' => $post_id, + 'f' => $forum_id, + 'mode' => 'delete') + ); + + if (confirm_box(true)) + { + $data = array( + 'topic_first_post_id' => $post_data['topic_first_post_id'], + 'topic_last_post_id' => $post_data['topic_last_post_id'], + 'topic_approved' => $post_data['topic_approved'], + 'topic_type' => $post_data['topic_type'], + 'post_approved' => $post_data['post_approved'], + 'post_time' => $post_data['post_time'], + 'poster_id' => $post_data['poster_id'] + ); + + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); + + if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id']) + { + add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']); + + $meta_info = "{$phpbb_root_path}viewforum.$phpEx$SID&f=$forum_id"; + $message = $user->lang['POST_DELETED']; + } + else + { + add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject']); + + $meta_info = "{$phpbb_root_path}viewtopic.$phpEx$SID&f=$forum_id&t=$topic_id&p=$next_post_id#p$next_post_id"; + $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + } + + meta_refresh(3, $meta_info); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); + } + else + { + confirm_box(false, 'DELETE_MESSAGE', $s_hidden_fields); + } + } + + // If we are here the user is not able to delete - present the correct error message + if ($post_data['poster_id'] != $user->data['user_id'] && !$auth->acl_get('f_delete', $forum_id)) + { + trigger_error('DELETE_OWN_POSTS'); + } + + if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) + { + trigger_error('CANNOT_DELETE_REPLIED'); + } + + trigger_error('USER_CANNOT_DELETE'); +} + ?> \ No newline at end of file diff --git a/phpBB/styles/subSilver/template/overall_header.html b/phpBB/styles/subSilver/template/overall_header.html index ca3a06c871..238e688d6f 100644 --- a/phpBB/styles/subSilver/template/overall_header.html +++ b/phpBB/styles/subSilver/template/overall_header.html @@ -95,7 +95,7 @@ function marklist(id, name, state) {L_LOGIN_LOGOUT} {L_LOGIN_LOGOUT}  -  {L_LOGIN_LOGOUT} {L_RESTORE_PERMISSIONS} +  {L_RESTORE_PERMISSIONS} {L_RESTORE_PERMISSIONS}  {L_PRIVATE_MESSAGES} {PRIVATE_MESSAGE_INFO}, {PRIVATE_MESSAGE_INFO_UNREAD}  {L_REGISTER} {L_REGISTER} diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_faq.gif b/phpBB/styles/subSilver/theme/images/icon_mini_faq.gif index b8b873d159..fc50e7ca30 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_faq.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_faq.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_groups.gif b/phpBB/styles/subSilver/theme/images/icon_mini_groups.gif index be5c2018ce..a4d1c7bb70 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_groups.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_groups.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_login.gif b/phpBB/styles/subSilver/theme/images/icon_mini_login.gif index 30b309b26c..c7590a423f 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_login.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_login.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_members.gif b/phpBB/styles/subSilver/theme/images/icon_mini_members.gif index a79a5a74b2..d636089b38 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_members.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_members.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_message.gif b/phpBB/styles/subSilver/theme/images/icon_mini_message.gif index 57071d6e8f..b8aea1eafb 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_message.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_message.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_profile.gif b/phpBB/styles/subSilver/theme/images/icon_mini_profile.gif index 3dc0871896..1ec7c649e9 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_profile.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_profile.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_register.gif b/phpBB/styles/subSilver/theme/images/icon_mini_register.gif index 11b8f31718..b49ac31ec9 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_register.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_register.gif differ diff --git a/phpBB/styles/subSilver/theme/images/icon_mini_search.gif b/phpBB/styles/subSilver/theme/images/icon_mini_search.gif index 1295e9f1db..2bd1a648c0 100644 Binary files a/phpBB/styles/subSilver/theme/images/icon_mini_search.gif and b/phpBB/styles/subSilver/theme/images/icon_mini_search.gif differ