aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-04-03 10:27:46 +0200
committerMarc Alexander <admin@m-a-styles.de>2016-04-03 10:27:46 +0200
commit3281826a5155f50a38d8534de6956e07d9e1b72d (patch)
tree50919cc5a5b9f2a180ad1ce87448eeb75c029d5f /phpBB/phpbb
parent9dad16c5a6835102a1bc03f3df74abbe8aa9d4fa (diff)
parent2505aaa9d677e1cb86684500b5f1ae9b04aae0f6 (diff)
downloadforums-3281826a5155f50a38d8534de6956e07d9e1b72d.tar
forums-3281826a5155f50a38d8534de6956e07d9e1b72d.tar.gz
forums-3281826a5155f50a38d8534de6956e07d9e1b72d.tar.bz2
forums-3281826a5155f50a38d8534de6956e07d9e1b72d.tar.xz
forums-3281826a5155f50a38d8534de6956e07d9e1b72d.zip
Merge branch 'ticket/14426' into 3.2.x
Diffstat (limited to 'phpBB/phpbb')
0 files changed, 0 insertions, 0 deletions
h: 2.4%;'/> -rw-r--r--phpBB/adm/admin_database.php2
-rw-r--r--phpBB/adm/admin_profile.php497
-rw-r--r--phpBB/common.php19
-rw-r--r--phpBB/download.php2
-rw-r--r--phpBB/faq.php4
-rw-r--r--phpBB/includes/bbcode.php33
-rw-r--r--phpBB/includes/functions.php69
-rw-r--r--phpBB/includes/functions_admin.php6
-rw-r--r--phpBB/includes/functions_display.php26
-rw-r--r--phpBB/includes/functions_posting.php38
-rw-r--r--phpBB/includes/functions_privmsgs.php14
-rw-r--r--phpBB/includes/functions_profile_fields.php190
-rw-r--r--phpBB/includes/message_parser.php95
-rw-r--r--phpBB/includes/session.php7
-rw-r--r--phpBB/includes/template.php8
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php7
-rw-r--r--phpBB/includes/ucp/ucp_profile.php11
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/install/install.php6
-rw-r--r--phpBB/install/schemas/schema_data.sql3
-rw-r--r--phpBB/language/en/admin.php34
-rw-r--r--phpBB/language/en/common.php4
-rw-r--r--phpBB/language/en/ucp.php10
-rw-r--r--phpBB/memberlist.php18
-rw-r--r--phpBB/posting.php24
-rw-r--r--phpBB/styles/subSilver/template/mcp_footer.html2
-rw-r--r--phpBB/styles/subSilver/template/mcp_reports.html2
-rw-r--r--phpBB/styles/subSilver/template/mcp_viewlogs.html2
-rw-r--r--phpBB/styles/subSilver/template/memberlist_body.html2
-rw-r--r--phpBB/styles/subSilver/template/memberlist_view.html6
-rw-r--r--phpBB/styles/subSilver/template/posting_preview.html2
-rw-r--r--phpBB/styles/subSilver/template/search_results_posts.html2
-rw-r--r--phpBB/styles/subSilver/template/search_results_topics.html2
-rw-r--r--phpBB/styles/subSilver/template/ucp_attachments.html2
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_message_footer.html2
-rw-r--r--phpBB/styles/subSilver/template/ucp_pm_message_header.html2
-rw-r--r--phpBB/styles/subSilver/template/viewforum_body.html16
-rw-r--r--phpBB/styles/subSilver/template/viewtopic_body.html5
-rwxr-xr-xphpBB/ucp.php2
-rw-r--r--phpBB/viewforum.php15
-rw-r--r--phpBB/viewtopic.php81
42 files changed, 870 insertions, 430 deletions
diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php
index 0ffc556241..5bc7441978 100644
--- a/phpBB/adm/admin_attachments.php
+++ b/phpBB/adm/admin_attachments.php
@@ -302,7 +302,7 @@ if ($submit && $mode == 'ext_groups')
$group_ary = array(
'group_name' => $group_name,
- 'cat_id' => request_var('special_category', NONE_CAT),
+ 'cat_id' => request_var('special_category', ATTACHMENT_CATEGORY_NONE),
'allow_group' => (isset($_REQUEST['allow_group'])) ? 1 : 0,
'download_mode' => request_var('download_mode', INLINE_LINK),
'upload_icon' => ($upload_icon == 'no_image') ? '' : $upload_icon,
@@ -570,7 +570,7 @@ if ($mode == 'attach')
<th align="center" colspan="2"><?php echo $user->lang['SETTINGS_CAT_IMAGES']; ?></th>
</tr>
<tr>
- <td class="row3" colspan="2" align="center"><?php echo $user->lang['ASSIGNED_GROUP']; ?>: <?php echo ( (count($s_assigned_groups[IMAGE_CAT])) ? implode(', ', $s_assigned_groups[IMAGE_CAT]) : $user->lang['NONE']); ?></td>
+ <td class="row3" colspan="2" align="center"><?php echo $user->lang['ASSIGNED_GROUP']; ?>: <?php echo ((sizeof($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NONE']); ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['DISPLAY_INLINED']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['DISPLAY_INLINED_EXPLAIN']; ?></span></td>
@@ -710,10 +710,10 @@ if ($mode == 'attach')
if ($mode == 'ext_groups')
{
$cat_lang = array(
- NONE_CAT => $user->lang['NONE'],
- IMAGE_CAT => $user->lang['CAT_IMAGES'],
- WM_CAT => $user->lang['CAT_WM_FILES'],
- RM_CAT => $user->lang['CAT_RM_FILES']
+ ATTACHMENT_CATEGORY_NONE => $user->lang['NONE'],
+ ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'],
+ ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'],
+ ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES']
);
@@ -1281,10 +1281,10 @@ function category_select($select_name, $group_id = FALSE)
global $db, $user;
$types = array(
- NONE_CAT => $user->lang['NONE'],
- IMAGE_CAT => $user->lang['CAT_IMAGES'],
- WM_CAT => $user->lang['CAT_WM_FILES'],
- RM_CAT => $user->lang['CAT_RM_FILES']
+ ATTACHMENT_CATEGORY_NONE => $user->lang['NONE'],
+ ATTACHMENT_CATEGORY_IMAGE => $user->lang['CAT_IMAGES'],
+ ATTACHMENT_CATEGORY_WM => $user->lang['CAT_WM_FILES'],
+ ATTACHMENT_CATEGORY_RM => $user->lang['CAT_RM_FILES']
);
if ($group_id)
@@ -1294,13 +1294,13 @@ function category_select($select_name, $group_id = FALSE)
WHERE group_id = ' . intval($group_id);
$result = $db->sql_query($sql);
- $cat_type = (!($row = $db->sql_fetchrow($result))) ? NONE_CAT : $row['cat_id'];
+ $cat_type = (!($row = $db->sql_fetchrow($result))) ? ATTACHMENT_CATEGORY_NONE : $row['cat_id'];
$db->sql_freeresult($result);
}
else
{
- $cat_type = NONE_CAT;
+ $cat_type = ATTACHMENT_CATEGORY_NONE;
}
$group_select = '<select name="' . $select_name . '">';
diff --git a/phpBB/adm/admin_database.php b/phpBB/adm/admin_database.php
index e26997fb93..b6d7586242 100644
--- a/phpBB/adm/admin_database.php
+++ b/phpBB/adm/admin_database.php
@@ -346,7 +346,7 @@ switch($mode)
if ($sql_query != '')
{
// Strip out sql comments...
- $sql_query = remove_remarks($sql_query);
+ remove_remarks($sql_query);
$pieces = split_sql_file($sql_query, ';');
$sql_count = count($pieces);
diff --git a/phpBB/adm/admin_profile.php b/phpBB/adm/admin_profile.php
index 01261b39c8..c0f7cfff4a 100644
--- a/phpBB/adm/admin_profile.php
+++ b/phpBB/adm/admin_profile.php
@@ -26,12 +26,11 @@
If the default board language is changed, a check has to be made if the profile field language entries are
still valid.
- TODO M-3:
+ TODO:
* Show at profile view (yes/no)
* Viewtopic Integration (Load Switch, Able to show fields with additional template vars populated if enabled)
* Custom Validation (Regex) - not in 2.2
-
- * Try to build the edit screen with the existing create screen...
+ * Able to use bbcode/smilies/urls - not in 2.2
*/
@@ -57,6 +56,8 @@ if (!$auth->acl_get('a_user'))
trigger_error($user->lang['NO_ADMIN']);
}
+$user->add_lang('ucp');
+
$mode = (isset($_POST['add'])) ? 'create' : request_var('mode', '');
$submit = (isset($_POST['submit'])) ? TRUE : FALSE;
$create = (isset($_POST['create'])) ? TRUE : FALSE;
@@ -64,17 +65,14 @@ $error = $notify = array();
adm_page_header($user->lang['CUSTOM_PROFILE_FIELDS']);
+// Define some default values for each field type
$default_values = array(
- 'field_length' => array(FIELD_STRING => 10, FIELD_TEXT => '5|80', FIELD_INT => 5, FIELD_DATE => 10, FIELD_BOOL => 1, FIELD_DROPDOWN => 0),
- 'field_minlen' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 10, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
- 'field_maxlen' => array(FIELD_STRING => 20, FIELD_TEXT => 1000, FIELD_INT => 100, FIELD_DATE => 10, FIELD_BOOL => 0, FIELD_DROPDOWN => 5),
- 'field_validation' => array(FIELD_STRING => '.*', FIELD_TEXT => '.*', FIELD_INT => '', FIELD_DATE => '', FIELD_BOOL => '', FIELD_DROPDOWN => ''),
- 'field_novalue' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => 0, FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => 0, FIELD_DROPDOWN => 1),
- 'field_default_value' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => 0, FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => 0, FIELD_DROPDOWN => 1),
- 'field_required' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
- 'field_hide' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
- 'field_show_on_reg' => array(FIELD_STRING => 0, FIELD_TEXT => 0, FIELD_INT => 0, FIELD_DATE => 0, FIELD_BOOL => 0, FIELD_DROPDOWN => 0),
- 'pf_preview' => array(FIELD_STRING => '', FIELD_TEXT => '', FIELD_INT => '', FIELD_DATE => ' 0- 0- 0', FIELD_BOOL => '', FIELD_DROPDOWN => '')
+ FIELD_STRING => array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''),
+ FIELD_TEXT => array('field_length' => '5|80', 'field_minlen' => 0, 'field_maxlen' => 1000, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''),
+ FIELD_INT => array('field_length' => 5, 'field_minlen' => 0, 'field_maxlen' => 100, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
+ FIELD_DATE => array('field_length' => 10, 'field_minlen' => 10, 'field_maxlen' => 10, 'field_validation' => '', 'field_novalue' => ' 0- 0- 0', 'field_default_value' => ' 0- 0- 0'),
+ FIELD_BOOL => array('field_length' => 1, 'field_minlen' => 0, 'field_maxlen' => 0, 'field_validation' => '', 'field_novalue' => 0, 'field_default_value' => 0),
+ FIELD_DROPDOWN => array('field_length' => 0, 'field_minlen' => 0, 'field_maxlen' => 5, 'field_validation' => '', 'field_novalue' => 1, 'field_default_value' => 1),
);
$cp = new custom_profile_admin();
@@ -105,9 +103,12 @@ while ($row = $db->sql_fetchrow($result))
}
$db->sql_freeresult($result);
-foreach ($lang_defs['entry'] as $field_id => $field_ary)
+if (isset($lang_defs['entry']))
{
- $lang_defs['diff'][$field_id] = array_diff($lang_defs['id'], $field_ary);
+ foreach ($lang_defs['entry'] as $field_id => $field_ary)
+ {
+ $lang_defs['diff'][$field_id] = array_diff($lang_defs['id'], $field_ary);
+ }
}
if ($mode == '')
@@ -115,26 +116,85 @@ if ($mode == '')
trigger_error('INVALID_MODE');
}
-if ($mode == 'create')
+if ($mode == 'create' || $mode == 'edit')
{
- $field_type = request_var('field_type', 0);
- $cp->vars['field_name'] = request_var('field_name', '');
- $field_ident = strtolower(str_replace(array(' ', "'"), array('', ''), $cp->vars['field_name']));
-
+ $field_id = request_var('field_id', 0);
$step = request_var('step', 1);
- $s_hidden_fields = '<input type="hidden" name="field_type" value="' . $field_type . '" />';
-
+ $error = array();
+
$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false;
$update = (isset($_REQUEST['update'])) ? true : false;
$save = (isset($_REQUEST['save'])) ? true : false;
- if (!$field_type)
+ // We are editing... we need to grab basic things
+ if ($mode == 'edit')
{
- trigger_error('NO_FIELD_TYPE');
+ if (!$field_id)
+ {
+ trigger_error('No field id specified');
+ }
+
+ $sql = 'SELECT l.*, f.*
+ FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
+ WHERE l.lang_id = ' . $lang_defs['iso'][$config['default_lang']] . "
+ AND f.field_id = $field_id
+ AND l.field_id = f.field_id";
+ $result = $db->sql_query($sql);
+ $field_row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (!$field_row)
+ {
+ trigger_error('Profile field not found');
+ }
+ $field_type = $field_row['field_type'];
+
+ // Get language entries
+ $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . '
+ WHERE lang_id = ' . $lang_defs['iso'][$config['default_lang']] . "
+ AND field_id = $field_id
+ ORDER BY option_id ASC";
+ $result = $db->sql_query($sql);
+
+ $lang_options = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $lang_options[$row['option_id']] = $row['value'];
+ }
+ $db->sql_freeresult($result);
+
+ $field_row['pf_preview'] = '';
+
+ $s_hidden_fields = '<input type="hidden" name="field_id" value="' . $field_id . '" />';
}
+ else
+ {
+ // We are adding a new field, define basic params
+ $lang_options = array();
+ $field_row = array();
+
+ $field_type = request_var('field_type', 0);
+
+ if (!$field_type)
+ {
+ trigger_error('NO_FIELD_TYPE');
+ }
- // Get all relevant informations about entered values within all steps
+ $field_row = array_merge($default_values[$field_type], array(
+ 'field_name' => request_var('field_name', ''),
+ 'field_required' => 0,
+ 'field_hide' => 0,
+ 'field_show_on_reg' => 0,
+ 'lang_name' => '',
+ 'lang_explain' => '',
+ 'lang_default_value'=> '',
+ 'pf_preview' => '')
+ );
+
+ $s_hidden_fields = '<input type="hidden" name="field_type" value="' . $field_type . '" />';
+ }
+ // Get all relevant informations about entered values within all steps
$exclude = array(
1 => array('lang_name', 'lang_explain', 'field_name'),
2 => array('field_length', 'pf_preview', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value', 'field_required', 'field_show_on_reg', 'field_hide'),
@@ -153,16 +213,41 @@ if ($mode == 'create')
$exclude[1][] = 'lang_options';
}
- $cp->vars['lang_name'] = request_var('lang_name', '');
- $cp->vars['lang_explain'] = request_var('lang_explain', '');
- $cp->vars['lang_default_value'] = request_var('lang_default_value', '');
- $cp->vars['lang_options'] = request_var('lang_options', '');
+ $cp->vars['field_name'] = request_var('field_name', $field_row['field_name']);
+ $cp->vars['lang_name'] = request_var('lang_name', $field_row['lang_name']);
+ $cp->vars['lang_explain'] = request_var('lang_explain', $field_row['lang_explain']);
+ $cp->vars['lang_default_value'] = request_var('lang_default_value', $field_row['lang_default_value']);
+
+ $options = request_var('lang_options', '');
+ if ($options)
+ {
+ if (sizeof(explode("\n", $options)) == sizeof($lang_options))
+ {
+ $cp->vars['lang_options'] = explode("\n", $options);
+ }
+ else
+ {
+ $cp->vars['lang_options'] = $lang_options;
+ $error[] = 'You are not allowed to remove or add options within already existing profile fields';
+ }
+ }
+ else
+ {
+ $cp->vars['lang_options'] = $lang_options;
+ }
// step 2
foreach ($exclude[2] as $key)
{
- $var = request_var($key, $default_values[$key][$field_type]);
-
+ if ($key == 'field_required' || $key == 'field_hide' || $key == 'field_show_on_reg')
+ {
+ $var = (isset($_REQUEST[$key])) ? request_var($key, 0) : $field_row[$key];
+ }
+ else
+ {
+ $var = request_var($key, $field_row[$key]);
+ }
+
// Manipulate the intended variables a little bit if needed
if ($field_type == FIELD_DROPDOWN && $key == 'field_maxlen')
{
@@ -216,12 +301,56 @@ if ($mode == 'create')
}
// step 3 - all arrays
+ if ($mode == 'edit')
+ {
+ // Get language entries
+ $sql = 'SELECT * FROM ' . PROFILE_FIELDS_LANG_TABLE . '
+ WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . "
+ AND field_id = $field_id
+ ORDER BY option_id ASC";
+ $result = $db->sql_query($sql);
+
+ $l_lang_options = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $l_lang_options[$row['lang_id']][$row['option_id']] = $row['value'];
+ }
+ $db->sql_freeresult($result);
+
+
+ $sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value FROM ' . PROFILE_LANG_TABLE . '
+ WHERE lang_id <> ' . $lang_defs['iso'][$config['default_lang']] . "
+ AND field_id = $field_id
+ ORDER BY lang_id ASC";
+ $result = $db->sql_query($sql);
+
+ $l_lang_name = $l_lang_explain = $l_lang_default_value = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $l_lang_name[$row['lang_id']] = $row['lang_name'];
+ $l_lang_explain[$row['lang_id']] = $row['lang_explain'];
+ $l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
+ }
+ $db->sql_freeresult($result);
+ }
+
foreach ($exclude[3] as $key)
{
$cp->vars[$key] = request_var($key, '');
+
+ if (!$cp->vars[$key] && $mode == 'edit')
+ {
+ $cp->vars[$key] = $$key;
+ }
+ else if ($key == 'l_lang_options')
+ {
+ foreach ($cp->vars[$key] as $lang_id => $options)
+ {
+ $cp->vars[$key][$lang_id] = explode("\n", $options);
+ }
+ }
}
- $error = array();
if ($submit && $step == 1)
{
// Check values for step 1
@@ -233,16 +362,14 @@ if ($mode == 'create')
{
$error[] = $user->lang['EMPTY_USER_FIELD_NAME'];
}
-
- $sql = 'SELECT field_ident
- FROM ' . PROFILE_FIELDS_TABLE . "
- WHERE field_ident = '$field_ident'";
- $result = $db->sql_query($sql);
- if ($row = $db->sql_fetchrow($result))
+ if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
{
- $error[] = sprintf($user->lang['FIELD_IDENT_ALREADY_EXIST'], $field_ident);
- }
+ if (!sizeof($cp->vars['lang_options']))
+ {
+ $error[] = 'No Entries defined';
+ }
+ }
}
$user_error = false;
@@ -282,18 +409,18 @@ if ($mode == 'create')
{
if ($step == 3 && (sizeof($lang_defs['iso']) == 1 || $save))
{
- save_profile_field($field_type, $field_ident);
+ save_profile_field($field_type, $mode);
}
}
?>
- <p><?php echo $user->lang['STEP_' . $step . '_EXPLAIN']; ?></p>
+ <p><?php echo $user->lang['STEP_' . $step . '_EXPLAIN_' . strtoupper($mode)]; ?></p>
<form name="add_profile_field" method="post" action="admin_profile.<?php echo "$phpEx$SID&amp;mode=$mode&amp;step=$step"; ?>">
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center" width="99%">
<tr>
- <th align="center" colspan="2"><?php echo $user->lang['STEP_' . $step . '_TITLE']; ?></th>
+ <th align="center" colspan="2"><?php echo $user->lang['STEP_' . $step . '_TITLE_' . strtoupper($mode)]; ?></th>
</tr>
<?php
@@ -349,7 +476,7 @@ if ($mode == 'create')
if ($field_type == FIELD_BOOL || $field_type == FIELD_DROPDOWN)
{
- if ($field_type == FIELD_BOOL && !is_array($cp->vars['lang_options']))
+ if ($field_type == FIELD_BOOL && !sizeof($cp->vars['lang_options']))
{
$cp->vars['lang_options'][0] = '';
$cp->vars['lang_options'][1] = '';
@@ -357,13 +484,13 @@ if ($mode == 'create')
?>
<tr>
<td class="row1"><b><?php echo $user->lang['ENTRIES']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang[strtoupper($cp->profile_types[$field_type]) . '_ENTRIES_EXPLAIN']; ?></span></td>
- <td class="row2"><?php echo ($field_type == FIELD_DROPDOWN) ? '<textarea name="lang_options" rows="5" cols="80">' . $cp->vars['lang_options'] . '</textarea>' : '<table border=0><tr><td><input name="lang_options[0]" size="20" value="' . $cp->vars['lang_options'][0] . '" class="post" /></td><td>[ ' . $user->lang['FIRST_OPTION'] . ' ]</td></tr><tr><td><input name="lang_options[1]" size="20" value="' . $cp->vars['lang_options'][1] . '" class="post" /></td><td>[ ' . $user->lang['SECOND_OPTION'] . ' ]</td></tr></table>'; ?></td>
+ <td class="row2"><?php echo ($field_type == FIELD_DROPDOWN) ? '<textarea name="lang_options" rows="5" cols="80">' . implode("\n", $cp->vars['lang_options']) . '</textarea>' : '<table border=0><tr><td><input name="lang_options[0]" size="20" value="' . $cp->vars['lang_options'][0] . '" class="post" /></td><td>[ ' . $user->lang['FIRST_OPTION'] . ' ]</td></tr><tr><td><input name="lang_options[1]" size="20" value="' . $cp->vars['lang_options'][1] . '" class="post" /></td><td>[ ' . $user->lang['SECOND_OPTION'] . ' ]</td></tr></table>'; ?></td>
</tr>
<?php
}
?>
<tr>
- <td width="100%" colspan="2" class="cat" align="right"><input class="btnlite" type="submit" name="next" value="<?php echo $user->lang['NEXT_PAGE']; ?>" /></td>
+ <td width="100%" colspan="2" class="cat" align="right"><input class="btnlite" type="submit" name="next" value="<?php echo $user->lang['PROFILE_TYPE_OPTIONS']; ?>" /></td>
</tr>
<?php echo $s_hidden_fields; ?>
</table>
@@ -402,7 +529,7 @@ if ($mode == 'create')
}
?>
<tr>
- <td width="100%" colspan="2" class="cat"><table border="0" width="100%"><tr><td align="left"><input class="btnlite" type="submit" name="prev" value="<?php echo $user->lang['PREVIOUS_PAGE']; ?>" /></td><td align="right"><input class="btnlite" type="submit" name="update" value="<?php echo $user->lang['UPDATE_PREVIEW']; ?>" />&nbsp;<input class="btnmain" type="submit" name="next" value="<?php echo $user->lang['SAVE']; ?>" /></td></tr></table></td>
+ <td width="100%" colspan="2" class="cat"><table border="0" width="100%"><tr><td align="left"><input class="btnlite" type="submit" name="prev" value="<?php echo $user->lang['PROFILE_BASIC_OPTIONS']; ?>" /></td><td align="right"><input class="btnlite" type="submit" name="update" value="<?php echo $user->lang['UPDATE_PREVIEW']; ?>" />&nbsp;<input class="btnmain" type="submit" name="next" value="<?php echo (sizeof($lang_defs['iso']) == 1) ? $user->lang['SAVE'] : $user->lang['PROFILE_LANG_OPTIONS']; ?>" /></td></tr></table></td>
</tr>
<?php echo $s_hidden_fields; ?>
</table>
@@ -415,6 +542,39 @@ if ($mode == 'create')
<?php
if (!empty($user_error) || $update)
{
+ // If not and only showing common error messages, use this one
+ switch ($user_error)
+ {
+ case 'FIELD_INVALID_DATE':
+ case 'FIELD_REQUIRED':
+ $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name']);
+ break;
+ case 'FIELD_TOO_SHORT':
+ case 'FIELD_TOO_SMALL':
+ $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_minlen']);
+ break;
+ case 'FIELD_TOO_LONG':
+ case 'FIELD_TOO_LARGE':
+ $user_error = sprintf($user->lang[$user_error], $cp->vars['lang_name'], $cp->vars['field_maxlen']);
+ break;
+ case 'FIELD_INVALID_CHARS':
+ switch ($cp->vars['field_validation'])
+ {
+ case '[0-9]+':
+ $user_error = sprintf($user->lang[$user_error . '_NUMBERS_ONLY'], $cp->vars['lang_name']);
+ break;
+ case '[\w]+':
+ $user_error = sprintf($user->lang[$user_error . '_ALPHA_ONLY'], $cp->vars['lang_name']);
+ break;
+ case '[\w_\+\. \-\[\]]+':
+ $user_error = sprintf($user->lang[$user_error . '_SPACERS_ONLY'], $cp->vars['lang_name']);
+ break;
+ }
+
+ default:
+ $user_error = '';
+ }
+
?> <tr>
<td class="row3" colspan="2"><?php echo (!empty($user_error)) ? '<span style="color:red">' . $user_error . '</span>' : '<span style="color:green">' . $user->lang['EVERYTHING_OK'] . '</span>'; ?></td>
</tr>
@@ -449,7 +609,7 @@ if ($mode == 'create')
// Define remaining language variables
case 3:
- $options = build_language_options($field_type);
+ $options = build_language_options($field_type, $mode);
foreach ($options as $lang_id => $lang_ary)
{
@@ -470,7 +630,7 @@ if ($mode == 'create')
}
?>
<tr>
- <td width="100%" colspan="2" class="cat"><table border="0" width="100%"><tr><td align="left"><input class="btnlite" type="submit" name="prev" value="<?php echo $user->lang['PREVIOUS_PAGE']; ?>" /></td><td align="right"><div style="align:right"><input type="submit" name="save" class="btnmain" value="<?php echo $user->lang['SAVE']; ?>" /></td></tr></table></td>
+ <td width="100%" colspan="2" class="cat"><table border="0" width="100%"><tr><td align="left"><input class="btnlite" type="submit" name="prev" value="<?php echo $user->lang['PROFILE_TYPE_OPTIONS']; ?>" /></td><td align="right"><div style="align:right"><input type="submit" name="save" class="btnmain" value="<?php echo $user->lang['SAVE']; ?>" /></td></tr></table></td>
</tr>
<?php echo $s_hidden_fields; ?>
</table>
@@ -673,13 +833,13 @@ function preview_field($field_data)
}
// Build all Language specific options
-function build_language_options($field_type, $mode = 'new')
+function build_language_options($field_type, $mode = 'create')
{
global $user, $config, $db, $cp;
$sql = 'SELECT lang_id, lang_iso
- FROM ' . LANG_TABLE .
- (($mode == 'new') ? " WHERE lang_iso <> '" . $config['default_lang'] . "'" : '');
+ FROM ' . LANG_TABLE . "
+ WHERE lang_iso <> '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$languages = array();
@@ -715,20 +875,17 @@ function build_language_options($field_type, $mode = 'new')
$lang_options = array();
- if ($mode == 'new')
+ foreach ($options as $field => $field_type)
{
- foreach ($options as $field => $field_type)
- {
- $lang_options[1]['lang_iso'] = $config['default_lang'];
- $lang_options[1]['fields'][$field] = array(
- 'TITLE' => $user->lang['CP_' . strtoupper($field)],
- 'FIELD' => '<b>' . ((is_array($cp->vars[$field])) ? implode('<br />', $cp->vars[$field]) : str_replace("\n", '<br />', $cp->vars[$field])) . '</b>'
- );
+ $lang_options[1]['lang_iso'] = $config['default_lang'];
+ $lang_options[1]['fields'][$field] = array(
+ 'TITLE' => $user->lang['CP_' . strtoupper($field)],
+ 'FIELD' => '<b>' . ((is_array($cp->vars[$field])) ? implode('<br />', $cp->vars[$field]) : str_replace("\n", '<br />', $cp->vars[$field])) . '</b>'
+ );
- if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN']))
- {
- $lang_options[1]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN'];
- }
+ if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN']))
+ {
+ $lang_options[1]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN'];
}
}
@@ -737,11 +894,11 @@ function build_language_options($field_type, $mode = 'new')
$lang_options[$lang_id]['lang_iso'] = $lang_iso;
foreach ($options as $field => $field_type)
{
- $value = ($mode == 'new') ? request_var('l_' . $field, '') : $cp->vars['l_' . $field];
+ $value = ($mode == 'create') ? request_var('l_' . $field, '') : $cp->vars['l_' . $field];
if ($field == 'lang_options')
{
- $var = ($mode == 'new') ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id];
+ $var = ($mode == 'create') ? $cp->vars['lang_options'] : $cp->vars['lang_options'][$lang_id];
switch ($field_type)
{
@@ -757,7 +914,7 @@ function build_language_options($field_type, $mode = 'new')
$lang_options[$lang_id]['fields'][$field] = array(
'TITLE' => $user->lang['CP_' . strtoupper($field)],
- 'FIELD' => '<textarea name="l_' . $field . '[' . $lang_id . ']" rows="7" cols="80">' . ((isset($value[$lang_id])) ? $value[$lang_id] : $var) . '</textarea>'
+ 'FIELD' => '<textarea name="l_' . $field . '[' . $lang_id . ']" rows="7" cols="80">' . ((isset($value[$lang_id])) ? implode("\n", $value[$lang_id]) : implode("\n", $var)) . '</textarea>'
);
break;
}
@@ -769,7 +926,7 @@ function build_language_options($field_type, $mode = 'new')
}
else
{
- $var = ($mode == 'new') ? $cp->vars[$field] : $cp->vars[$field][$lang_id];
+ $var = ($mode == 'create') ? $cp->vars[$field] : $cp->vars[$field][$lang_id];
$lang_options[$lang_id]['fields'][$field] = array(
'TITLE' => $user->lang['CP_' . strtoupper($field)],
@@ -787,24 +944,30 @@ function build_language_options($field_type, $mode = 'new')
return $lang_options;
}
-function save_profile_field($field_type, $field_ident)
+function save_profile_field($field_type, $mode = 'create')
{
global $cp, $db, $config, $user, $lang_defs;
+ $field_id = request_var('field_id', 0);
+
// Collect all informations, if something is going wrong, abort the operation
$profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
$default_lang_id = $lang_defs['iso'][$config['default_lang']];
- $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM phpbb_profile_fields');
- $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result);
- $db->sql_freeresult($result);
+ if ($mode == 'create')
+ {
+ $result = $db->sql_query('SELECT MAX(field_order) as max_field_order FROM ' . PROFILE_FIELDS_TABLE);
+ $new_field_order = (int) $db->sql_fetchfield('max_field_order', 0, $result);
+ $db->sql_freeresult($result);
+
+ // We do not use a stripped down field name as identifier in order to retain sql compatibility, of course it would be nice to not have to look up the identifier and instead having a descriptive name, but this would produce more errors than needed, and do you want to have a totally crypted name just because of stripped characters? ;)
+ $field_ident = 'field_' . ($new_field_order + 1);
+ }
// Save the field
$profile_fields = array(
'field_name' => $cp->vars['field_name'],
- 'field_type' => $field_type,
- 'field_ident' => $field_ident,
'field_length' => $cp->vars['field_length'],
'field_minlen' => $cp->vars['field_minlen'],
'field_maxlen' => $cp->vars['field_maxlen'],
@@ -813,52 +976,78 @@ function save_profile_field($field_type, $field_ident)
'field_validation' => $cp->vars['field_validation'],
'field_required' => $cp->vars['field_required'],
'field_show_on_reg' => $cp->vars['field_show_on_reg'],
- 'field_hide' => $cp->vars['field_hide'],
- 'field_order' => $new_field_order + 1,
- 'field_active' => 1
+ 'field_hide' => $cp->vars['field_hide']
);
- $db->sql_query('INSERT INTO phpbb_profile_fields ' . $db->sql_build_array('INSERT', $profile_fields));
+ if ($mode == 'create')
+ {
+ $profile_fields += array(
+ 'field_type' => $field_type,
+ 'field_ident' => $field_ident,
+ 'field_order' => $new_field_order + 1,
+ 'field_active' => 1
+ );
+
+ $db->sql_query('INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields));
- $field_id = $db->sql_nextid();
+ $field_id = $db->sql_nextid();
+ }
+ else
+ {
+ $db->sql_query('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $profile_fields) . "
+ WHERE field_id = $field_id");
+ }
- $sql = 'ALTER TABLE ' . PROFILE_DATA_TABLE . " ADD $field_ident ";
- switch ($field_type)
+ if ($mode == 'create')
{
- case FIELD_STRING:
- $sql .= " VARCHAR(255) DEFAULT NULL NULL";
- break;
+ // We are defining the biggest common value, because of the possibility to edit the min/max values of each field.
+ $sql = 'ALTER TABLE ' . PROFILE_DATA_TABLE . " ADD $field_ident ";
+ switch ($field_type)
+ {
+ case FIELD_STRING:
+ $sql .= ' VARCHAR(255) DEFAULT NULL NULL';
+ break;
- case FIELD_DATE:
- $sql .= "VARCHAR(10) DEFAULT NULL NULL";
- break;
+ case FIELD_DATE:
+ $sql .= 'VARCHAR(10) DEFAULT NULL NULL';
+ break;
- case FIELD_TEXT:
- $sql .= "TEXT NULL";
- break;
+ case FIELD_TEXT:
+ $sql .= 'TEXT NULL';
+ break;
- case FIELD_BOOL:
- $sql .= "TINYINT(2) DEFAULT NULL NULL";
- break;
+ case FIELD_BOOL:
+ $sql .= 'TINYINT(2) DEFAULT NULL NULL';
+ break;
- case FIELD_DROPDOWN:
- $sql .= "MEDIUMINT(8) DEFAULT NULL NULL";
- break;
+ case FIELD_DROPDOWN:
+ $sql .= 'MEDIUMINT(8) DEFAULT NULL NULL';
+ break;
- case FIELD_INT:
- $sql .= (($cp->vars['field_maxlen'] > 60000) ? 'BIGINT(20)' : 'MEDIUMINT(8)') . (($cp->vars['field_minlen'] >= 0) ? ' UNSIGNED' : ' ') . " DEFAULT NULL NULL";
- break;
+ case FIELD_INT:
+ $sql .= 'BIGINT(20) DEFAULT NULL NULL';
+ break;
+ }
+ $profile_sql[] = $sql;
}
- $profile_sql[] = $sql;
$sql_ary = array(
- 'field_id' => $field_id,
- 'lang_id' => $default_lang_id,
'lang_name' => $cp->vars['lang_name'],
'lang_explain' => $cp->vars['lang_explain'],
'lang_default_value' => $cp->vars['lang_default_value']
);
- $profile_sql[] = 'INSERT INTO phpbb_profile_lang ' . $db->sql_build_array('INSERT', $sql_ary);
+
+ if ($mode == 'create')
+ {
+ $sql_ary['field_id'] = $field_id;
+ $sql_ary['lang_id'] = $default_lang_id;
+
+ $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ }
+ else
+ {
+ update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id));
+ }
if (sizeof($cp->vars['l_lang_name']))
{
@@ -900,13 +1089,26 @@ function save_profile_field($field_type, $field_ident)
foreach ($cp->vars['lang_options'] as $option_id => $value)
{
$sql_ary = array(
- 'field_id' => $field_id,
- 'lang_id' => $default_lang_id,
- 'option_id' => $option_id,
- 'field_type' => $field_type,
+ 'field_type' => (int) $field_type,
'value' => $value
);
- $profile_sql[] = 'INSERT INTO phpbb_profile_fields_lang ' . $db->sql_build_array('INSERT', $sql_ary);
+
+ if ($mode == 'create')
+ {
+ $sql_ary['field_id'] = $field_id;
+ $sql_ary['lang_id'] = $default_lang_id;
+ $sql_ary['option_id'] = (int) $option_id;
+
+ $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
+ }
+ else
+ {
+ update_insert(PROFILE_FIELDS_LANG_TABLE, $sql_ary, array(
+ 'field_id' => $field_id,
+ 'lang_id' => (int) $default_lang_id,
+ 'option_id' => (int) $option_id)
+ );
+ }
}
}
@@ -929,10 +1131,10 @@ function save_profile_field($field_type, $field_ident)
foreach ($lang_ary as $option_id => $value)
{
$profile_lang_fields[] = array(
- 'field_id' => $field_id,
- 'lang_id' => $lang_id,
- 'option_id' => $option_id,
- 'field_type' => $field_type,
+ 'field_id' => (int) $field_id,
+ 'lang_id' => (int) $lang_id,
+ 'option_id' => (int) $option_id,
+ 'field_type' => (int) $field_type,
'value' => $value
);
}
@@ -942,21 +1144,47 @@ function save_profile_field($field_type, $field_ident)
foreach ($profile_lang as $sql)
{
- $profile_sql[] = 'INSERT INTO phpbb_profile_lang ' . $db->sql_build_array('INSERT', $sql);
+ if ($mode == 'create')
+ {
+ $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql);
+ }
+ else
+ {
+ $lang_id = $sql['lang_id'];
+ unset($sql['lang_id'], $sql['field_id']);
+ update_insert(PROFILE_LANG_TABLE, $sql, array('lang_id' => (int) $lang_id, 'field_id' => $field_id));
+ }
}
if (sizeof($profile_lang_fields))
{
foreach ($profile_lang_fields as $sql)
{
- $profile_sql[] = 'INSERT INTO phpbb_profile_fields_lang ' . $db->sql_build_array('INSERT', $sql);
+ if ($mode == 'create')
+ {
+ $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql);
+ }
+ else
+ {
+ $lang_id = $sql['lang_id'];
+ $option_id = $sql['option_id'];
+ unset($sql['lang_id'], $sql['field_id'], $sql['option_id']);
+ update_insert(PROFILE_FIELDS_LANG_TABLE, $sql, array(
+ 'lang_id' => $lang_id,
+ 'field_id' => $field_id,
+ 'option_id' => $option_id)
+ );
+ }
}
}
// $db->sql_transaction();
- foreach ($profile_sql as $sql)
+ if ($mode == 'create')
{
- $db->sql_query($sql);
+ foreach ($profile_sql as $sql)
+ {
+ $db->sql_query($sql);
+ }
}
// $db->sql_transaction('commit');
@@ -964,6 +1192,33 @@ function save_profile_field($field_type, $field_ident)
trigger_error($user->lang['ADDED_PROFILE_FIELD']);
}
+// Update, then insert if not successfull
+function update_insert($table, $sql_ary, $where_fields)
+{
+ global $db;
+
+ $where_sql = array();
+ foreach ($where_fields as $key => $value)
+ {
+ $where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : $value);
+ }
+
+ $db->sql_return_on_error(true);
+
+ $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE ' . implode(' AND ', $where_sql);
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ if (!$result)
+ {
+ $sql_ary = array_merge($where_fields, $sql_ary);
+ $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary));
+ }
+
+}
+
function build_hidden_fields($key_ary)
{
$hidden_fields = '';
@@ -971,7 +1226,15 @@ function build_hidden_fields($key_ary)
foreach ($key_ary as $key)
{
$var = isset($_POST[$key]) ? $_POST[$key] : false;
- if (!$var)
+
+ if ($key == 'field_required' || $key == 'field_hide' || $key == 'field_show_on_reg')
+ {
+ if (!$var)
+ {
+ $var = 0;
+ }
+ }
+ else if (!$var)
{
continue;
}
diff --git a/phpBB/common.php b/phpBB/common.php
index 13ce9e45e2..efcb6eeb68 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -40,6 +40,15 @@ if (!defined('PHPBB_INSTALLED'))
exit;
}
+if (defined('DEBUG_EXTRA'))
+{
+ $base_memory_usage = 0;
+ if (function_exists('memory_get_usage'))
+ {
+ $base_memory_usage = memory_get_usage();
+ }
+}
+
// Load Extensions
if (!empty($load_extensions))
{
@@ -138,11 +147,11 @@ define('INLINE_LINK', 1);
define('PHYSICAL_LINK', 2);
// Categories - Attachments
-define('NONE_CAT', 0);
-define('IMAGE_CAT', 1); // Inline Images
-define('WM_CAT', 2); // Windows Media Files - Streaming
-define('RM_CAT', 3); // Real Media Files - Streaming
-define('THUMB_CAT', 4); // Not used within the database, only while displaying posts
+define('ATTACHMENT_CATEGORY_NONE', 0);
+define('ATTACHMENT_CATEGORY_IMAGE', 1); // Inline Images
+define('ATTACHMENT_CATEGORY_WM', 2); // Windows Media Files - Streaming
+define('ATTACHMENT_CATEGORY_RM', 3); // Real Media Files - Streaming
+define('ATTACHMENT_CATEGORY_THUMB', 4); // Not used within the database, only while displaying posts
//define('SWF_CAT', 5); // Replaced by [flash]? or an additional possibility?
// BBCode UID length
diff --git a/phpBB/download.php b/phpBB/download.php
index 4640098c27..eff6d0c603 100644
--- a/phpBB/download.php
+++ b/phpBB/download.php
@@ -186,7 +186,7 @@ function send_file_to_browser($attachment, $upload_dir, $category)
// Correct the mime type - we force application/octetstream for all files, except images
// Please do not change this, it is a security precaution
- if ($category == NONE_CAT && !strstr($attachment['mimetype'], 'image'))
+ if ($category == ATTACHMENT_CATEGORY_NONE && strpos($attachment['mimetype'], 'image') === false)
{
$attachment['mimetype'] = ($browser_agent == 'ie' || $browser_agent == 'opera') ? 'application/octetstream' : 'application/octet-stream';
}
diff --git a/phpBB/faq.php b/phpBB/faq.php
index 845c12b2ac..d1317663f5 100644
--- a/phpBB/faq.php
+++ b/phpBB/faq.php
@@ -72,7 +72,7 @@ $template->assign_vars(array(
'L_BACK_TO_TOP' => $user->lang['BACK_TO_TOP'])
);
-for ($i = 0; $i < count($help_block); $i++)
+for ($i = 0, $size = sizeof($help_block); $i < $size; $i++)
{
if (sizeof($help_block[$i]))
{
@@ -84,7 +84,7 @@ for ($i = 0; $i < count($help_block); $i++)
'BLOCK_TITLE' => $help_block_titles[$i])
);
- for ($j = 0; $j < count($help_block[$i]); $j++)
+ for ($j = 0, $_size = sizeof($help_block[$i]); $j < $_size; $j++)
{
$template->assign_block_vars('faq_block.faq_row', array(
'FAQ_QUESTION' => $help_block[$i][$j]['question'],
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index f9b8fcbce3..4e56a2be77 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -257,10 +257,12 @@ class bbcode
}
break;
case 12:
- $this->bbcode_cache[$bbcode_id] = array('preg' => array(
- '#\[attachment=([0-9]+):$uid\]#' => $this->bbcode_tpl('inline_attachment_open', $bbcode_id),
- '#\[\/attachment:$uid\]#' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id)
- ));
+ $this->bbcode_cache[$bbcode_id] = array(
+ 'str' => array(
+ '[/attachment:$uid]' => $this->bbcode_tpl('inline_attachment_close', $bbcode_id)),
+ 'preg' => array(
+ '#\[attachment=([0-9]+):$uid\]#' => $this->bbcode_tpl('inline_attachment_open', $bbcode_id))
+ );
break;
default:
if (isset($rowset[$bbcode_id]))
@@ -461,23 +463,22 @@ class bbcode
switch ($type)
{
case 'php':
+ // Not the english way, but valid because of hardcoded syntax highlighting
+ if (strpos($code, '<span class="syntaxdefault"><br /></span>') === 0)
+ {
+ $code = substr($code, 41);
+ }
+
default:
$code = str_replace("\t", '&nbsp; &nbsp;', $code);
$code = str_replace(' ', '&nbsp; ', $code);
$code = str_replace(' ', ' &nbsp;', $code);
- $match = array(
- '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
- '#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
- '#<!\-\- w \-\-><a href="http:\/\/(.*?)" target="_blank">.*?</a><!\-\- w \-\->#',
- '#<!\-\- l \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- l \-\->#',
- '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
- '#^[\n]#'
- );
-
- $replace = array('\1', '\1', '\1', '\1', '\1', '');
-
- $code = preg_replace($match, $replace, $code);
+ // remove newline at the beginning
+ if ($code{0} == "\n")
+ {
+ $code = substr($code, 1);
+ }
}
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 33dd4f2295..6589f804bd 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -118,7 +118,7 @@ function get_userdata($user)
}
// Create forum rules for given forum
-function generate_forum_rules($forum_data)
+function generate_forum_rules(&$forum_data)
{
if (!$forum_data['forum_rules'] && !$forum_data['forum_rules_link'])
{
@@ -750,7 +750,8 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false)
// Pagination routine, generates page number sequence
-function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
+// tpl_prefix is for using different pagination blocks at one page
+function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = true, $tpl_prefix = '')
{
global $template, $user;
@@ -765,7 +766,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
$on_page = floor($start_item / $per_page) + 1;
- $page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . "&amp;start=" . (($on_page - 2) * $per_page) . '">' . $user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;<a href="' . $base_url . '">1</a>';
+ $page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>';
if ($total_pages > 5)
{
@@ -799,13 +800,17 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
}
}
- $page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . '&amp;start=' . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a>&nbsp;&nbsp;<a href="' . $base_url . "&amp;start=" . ($on_page * $per_page) . '">' . $user->lang['NEXT'] . '</a>';
-
+ $page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . '&amp;start=' . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a>';
// $page_string = $user->lang['GOTO_PAGE'] . ' ' . $page_string;
- $page_string = '<a href="javascript:jumpto();">' . $user->lang['GOTO_PAGE'] . '</a> ' . $page_string;
+// $page_string = '<a href="javascript:jumpto();">' . $user->lang['GOTO_PAGE'] . '</a> ' . $page_string;
- $template->assign_var('BASE_URL', $base_url);
- $template->assign_var('PER_PAGE', $per_page);
+ $template->assign_vars(array(
+ $tpl_prefix . 'BASE_URL' => $base_url,
+ $tpl_prefix . 'PER_PAGE' => $per_page,
+
+ $tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . '&amp;start=' . (($on_page - 2) * $per_page),
+ $tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . '&amp;start=' . ($on_page * $per_page))
+ );
return $page_string;
}
@@ -1005,7 +1010,7 @@ function redirect($url)
$url = str_replace('&amp;', '&', $url);
// Local redirect? If not, prepend the boards url
- $url = (!strstr($url, '://')) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url;
+ $url = (strpos($url, '://') === false) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url;
// Redirect via an HTML form for PITA webservers
if (@preg_match('#Microsoft|WebSTAR|Xitami#', getenv('SERVER_SOFTWARE')))
@@ -1165,7 +1170,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
'U_PRIVACY' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;mode=privacy",
'S_DISPLAY_FULL_LOGIN' => ($s_display) ? true : false,
- 'S_LOGIN_ACTION' => $redirect_page,
+ 'S_LOGIN_ACTION' => (!$admin) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;mode=login" : "index.$phpEx$SID",
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
@@ -1303,6 +1308,38 @@ function smilie_text($text, $force_option = false)
return ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $text) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $text);
}
+// Inline Attachment processing
+function parse_inline_attachments(&$text, &$attachments, &$update_count, $forum_id = 0, $preview = false)
+{
+ global $config, $user;
+
+ $attachments = display_attachments($forum_id, NULL, $attachments, $update_count, $preview, true);
+ $tpl_size = sizeof($attachments);
+
+ $unset_tpl = array();
+
+ preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $text, $matches, PREG_PATTERN_ORDER);
+
+ $replace = array();
+ foreach ($matches[0] as $num => $capture)
+ {
+ // Flip index if we are displaying the reverse way
+ $index = ($config['display_order']) ? ($tpl_size-($matches[1][$num] + 1)) : $matches[1][$num];
+
+ $replace['from'][] = $matches[0][$num];
+ $replace['to'][] = (isset($attachments[$index])) ? $attachments[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][array_search($index, $matches[1])]);
+
+ $unset_tpl[] = $index;
+ }
+
+ if (isset($replace['from']))
+ {
+ $text = str_replace($replace['from'], $replace['to'], $text);
+ }
+
+ return array_unique($unset_tpl);
+}
+
// Check if extension is allowed to be posted within forum X (forum_id 0 == private messaging)
function extension_allowed($forum_id, $extension)
{
@@ -1351,6 +1388,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
case E_WARNING:
if (defined('DEBUG_EXTRA'))
{
+ // Remove me
if (!strstr($errfile, '/cache/') && !strstr($errfile, 'mysql.php') && !strstr($errfile, 'template.php'))
{
echo "<b>PHP Notice</b>: in file <b>$errfile</b> on line <b>$errline</b>: <b>$msg_text</b><br>";
@@ -1430,6 +1468,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
exit;
break;
+/* remove me
default:
if (defined('DEBUG_EXTRA'))
{
@@ -1438,7 +1477,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo "<b>Another Error</b>: in file <b>$errfile</b> on line <b>$errline</b>: <b>$msg_text</b><br>";
}
}
- break;
+ break;*/
}
}
@@ -1732,21 +1771,23 @@ function page_footer()
$db->sql_report('display');
}
- $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime);
+ $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off' ) . ' | Load : ' . (($user->load) ? $user->load : 'N/A'), $totaltime);
- if ($auth->acl_get('a_'))
+ if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
{
if (function_exists('memory_get_usage'))
{
if ($memory_usage = memory_get_usage())
{
+ global $base_memory_usage;
+ $memory_usage -= $base_memory_usage;
$memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
$debug_output .= ' | Memory Usage: ' . $memory_usage;
}
}
- $debug_output .= ' | <a href="' . (($_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['REQUEST_URI']) : "index.$phpEx$SID") . ((strstr($_SERVER['REQUEST_URI'], '?')) ? '&amp;' : '?') . 'explain=1">Explain</a>';
+ $debug_output .= ' | <a href="' . (($_SERVER['REQUEST_URI']) ? htmlspecialchars($_SERVER['REQUEST_URI']) : "index.$phpEx$SID") . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&amp;' : '?') . 'explain=1">Explain</a>';
}
}
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 097a7769fc..2ffda2ac72 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php