- more updates, mostly bugfixes to the bbcode parser

- changed current_user in sessions (please review)
- give more flexibility to style authors in regard to the pagination elements
- profile fields updates (included a sample constuct into viewtopic_body.html - have to be documented extensivly)
- code optimizations (use of strpos, sizeof, loops not iterating functions on every call, memory savings...)
- and last but not least --- hopefully not introduced more bugs than healthy (*cough*)


git-svn-id: file:///svn/phpbb/trunk@4984 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2004-09-16 18:33:22 +00:00
parent d80f8d577e
commit 2fa463cdeb
42 changed files with 945 additions and 505 deletions

View file

@ -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 . '">';

View file

@ -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);

View file

@ -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');
}
$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));
$field_id = $db->sql_nextid();
$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;
$profile_fields += array(
'field_type' => $field_type,
'field_ident' => $field_ident,
'field_order' => $new_field_order + 1,
'field_active' => 1
);
case FIELD_DATE:
$sql .= "VARCHAR(10) DEFAULT NULL NULL";
break;
$db->sql_query('INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields));
case FIELD_TEXT:
$sql .= "TEXT NULL";
break;
case FIELD_BOOL:
$sql .= "TINYINT(2) 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;
$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");
}
if ($mode == 'create')
{
// 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_TEXT:
$sql .= 'TEXT NULL';
break;
case FIELD_BOOL:
$sql .= 'TINYINT(2) DEFAULT NULL NULL';
break;
case FIELD_DROPDOWN:
$sql .= 'MEDIUMINT(8) 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;
}

View file

@ -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

View file

@ -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';
}

View file

@ -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'],

View file

@ -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');

View file

@ -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>';
}
}

View file

@ -81,7 +81,7 @@ function size_select($select_name, $size_compare)
$select_field = '<select name="' . $select_name . '">';
for ($i = 0; $i < count($size_types_text); $i++)
for ($i = 0, $size = sizeof($size_types_text); $i < $size; $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
@ -1479,9 +1479,9 @@ function remove_comments(&$output)
}
// remove_remarks will strip the sql comment lines out of an uploaded sql file
function remove_remarks($sql)
function remove_remarks(&$sql)
{
return preg_replace('/(\n){2,}/', "\n", preg_replace('/^#.*/m', "\n", $sql));
preg_replace('/(\n){2,}/', "\n", preg_replace('/^#.*/m', "\n", $sql));
}
// split_sql_file will split an uploaded sql file into single sql statements.

View file

@ -66,7 +66,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
while ($row = $db->sql_fetchrow($result))
{
if ($mark_read == 'forums' && $userdata['user_id'] != ANONYMOUS)
if ($mark_read == 'forums' && $user->data['user_id'] != ANONYMOUS)
{
if ($auth->acl_get('f_list', $row['forum_id']))
{
@ -172,7 +172,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
$redirect = (!empty($_SERVER['REQUEST_URI'])) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : "index.$phpEx$SID";
meta_refresh(3, $redirect);
$message = (strstr($redirect, 'viewforum')) ? 'RETURN_FORUM' : 'RETURN_INDEX';
$message = (strpos($redirect, 'viewforum') !== false) ? 'RETURN_FORUM' : 'RETURN_INDEX';
$message = $user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang[$message], '<a href="' . $redirect . '">', '</a> ');
trigger_error($message);
}
@ -341,7 +341,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
}
// Display Attachments
function display_attachments($forum_id, $blockname, $attachment_data, &$update_count, $force_physical = false, $return = false)
function display_attachments($forum_id, $blockname, &$attachment_data, &$update_count, $force_physical = false, $return = false)
{
global $extensions, $template, $cache, $attachment_tpl;
global $config, $user, $phpbb_root_path, $phpEx, $SID;
@ -350,7 +350,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
// $starttime = $starttime[1] + $starttime[0];
$return_tpl = array();
$blocks = array(WM_CAT => 'WM_STREAM', RM_CAT => 'RM_STREAM', THUMB_CAT => 'THUMBNAIL', IMAGE_CAT => 'IMAGE');
$blocks = array(ATTACHMENT_CATEGORY_WM => 'WM_STREAM', ATTACHMENT_CATEGORY_RM => 'RM_STREAM', ATTACHMENT_CATEGORY_THUMB => 'THUMBNAIL', ATTACHMENT_CATEGORY_IMAGE => 'IMAGE');
if (!isset($attachment_tpl))
{
@ -454,11 +454,11 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
$display_cat = $extensions[$attachment['extension']]['display_cat'];
if ($display_cat == IMAGE_CAT)
if ($display_cat == ATTACHMENT_CATEGORY_IMAGE)
{
if ($attachment['thumbnail'])
{
$display_cat = THUMB_CAT;
$display_cat = ATTACHMENT_CATEGORY_THUMB;
}
else
{
@ -468,12 +468,12 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
{
list($width, $height) = getimagesize($filename);
$display_cat = (!$width && !$height) ? IMAGE_CAT : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? IMAGE_CAT : NONE_CAT);
$display_cat = (!$width && !$height) ? ATTACHMENT_CATEGORY_IMAGE : (($width <= $config['img_link_width'] && $height <= $config['img_link_height']) ? ATTACHMENT_CATEGORY_IMAGE : ATTACHMENT_CATEGORY_NONE);
}
}
else
{
$display_cat = NONE_CAT;
$display_cat = ATTACHMENT_CATEGORY_NONE;
}
}
}
@ -481,7 +481,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
switch ($display_cat)
{
// Images
case IMAGE_CAT:
case ATTACHMENT_CATEGORY_IMAGE:
$img_source = $filename;
$update_count[] = $attachment['attach_id'];
@ -490,7 +490,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
break;
// Images, but display Thumbnail
case THUMB_CAT:
case ATTACHMENT_CATEGORY_THUMB:
$thumb_source = $thumbnail_filename;
$l_downloaded_viewed = $user->lang['VIEWED'];
@ -501,7 +501,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
break;
// Windows Media Streams
case WM_CAT:
case ATTACHMENT_CATEGORY_WM:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
@ -510,7 +510,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
break;
// Real Media Streams
case RM_CAT:
case ATTACHMENT_CATEGORY_RM:
$l_downloaded_viewed = $user->lang['VIEWED'];
$download_link = $filename;
@ -545,7 +545,7 @@ function display_attachments($forum_id, $blockname, $attachment_data, &$update_c
break;
}
$l_download_count = ($attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count']));
$l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang['DOWNLOAD_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang['DOWNLOAD_COUNT'], $attachment['download_count']) : sprintf($user->lang['DOWNLOAD_COUNTS'], $attachment['download_count']));
$current_block = ($display_cat) ? $blocks[$display_cat] : 'FILE';

View file

@ -149,9 +149,9 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
// Opera adds the name to the mime type
$filedata['mimetype'] = (strstr($filedata['mimetype'], '; name')) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
$filedata['mimetype'] = (strpos($filedata['mimetype'], '; name') !== false) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
$filedata['extension'] = array_pop(explode('.', strtolower($filename)));
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
$filedata['filesize'] = (!@filesize($file)) ? (int) $_FILES['size'] : @filesize($file);
$extensions = array();
obtain_attach_extensions($extensions);
@ -187,7 +187,7 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
}
// Check Image Size, if it is an image
if (!$auth->acl_gets('m_', 'a_') && $cat_id == IMAGE_CAT)
if (!$auth->acl_gets('m_', 'a_') && $cat_id == ATTACHMENT_CATEGORY_IMAGE)
{
list($width, $height) = getimagesize($file);
@ -248,7 +248,7 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
$filedata['filename'] = str_replace("'", "\'", $filedata['filename']);
// Do we have to create a thumbnail ?
if ($cat_id == IMAGE_CAT && $config['img_create_thumbnail'])
if ($cat_id == ATTACHMENT_CATEGORY_IMAGE && $config['img_create_thumbnail'])
{
$filedata['thumbnail'] = 1;
}
@ -491,44 +491,22 @@ function decode_message(&$message, $bbcode_uid = '')
{
global $config;
$server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/';
$match = array('<br />', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid");
$replace = array("\n", '', '', '', '');
$message = ($bbcode_uid) ? str_replace($match, $replace, $message) : str_replace('<br />', "\n", $message);
// HTML
if ($config['allow_html_tags'])
{
// If $html is true then "allowed_tags" are converted back from entity
// form, others remain
$allowed_tags = split(',', $config['allow_html_tags']);
if (sizeof($allowed_tags))
{
$message = preg_replace('#\<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')\>#is', '&lt;$1$2&gt;', $message);
}
}
$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 \-\->#',
'#<!\-\- h \-\-><(.*?)><!\-\- h \-\->#',
'#<.*?>#s'
);
$replace = array(
'\1',
'\1',
'\1',
$server_protocol . trim($config['server_name']) . $server_port . preg_replace('#^\/?(.*?)(\/)?$#', '\1', trim($config['script_path'])) . '/\1',
'\1',
''
);
$replace = array('\1', '\1', '\1', '\1', '\1', '&lt;\1&gt;', '');
$message = preg_replace($match, $replace, $message);
@ -595,7 +573,7 @@ function posting_gen_topic_icons($mode, $icon_id)
}
// Assign Inline attachments (build option fields)
function posting_gen_inline_attachments($attachment_data)
function posting_gen_inline_attachments(&$attachment_data)
{
global $template;
@ -672,7 +650,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
return $toggle;
}
function posting_gen_attachment_entry($attachment_data, $filename_data)
function posting_gen_attachment_entry(&$attachment_data, &$filename_data)
{
global $template, $config, $phpbb_root_path, $SID, $phpEx;

View file

@ -204,7 +204,7 @@ function clean_sentbox($num_sentbox_messages)
}
// Check Rule against Message Informations
function check_rule($rules, $rule_row, $message_row, $user_id)
function check_rule(&$rules, &$rule_row, &$message_row, $user_id)
{
global $user, $config;
@ -249,7 +249,7 @@ function check_rule($rules, $rule_row, $message_row, $user_id)
}
// Place new messages into appropiate folder
function place_pm_into_folder($global_privmsgs_rules, $release = false)
function place_pm_into_folder(&$global_privmsgs_rules, $release = false)
{
global $db, $user, $config;
@ -900,7 +900,7 @@ function rebuild_header($check_ary)
}
// Print out/Assign recipient informations
function write_pm_addresses($check_ary, $author, $plaintext = false)
function write_pm_addresses($check_ary, $author_id, $plaintext = false)
{
global $db, $user, $template, $phpbb_root_path, $SID, $phpEx;
@ -927,7 +927,7 @@ function write_pm_addresses($check_ary, $author, $plaintext = false)
while ($row = $db->sql_fetchrow($result))
{
if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
{
if ($plaintext)
{
@ -953,7 +953,7 @@ function write_pm_addresses($check_ary, $author, $plaintext = false)
while ($row = $db->sql_fetchrow($result))
{
if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
{
$address[] = $row['group_name'];
}
@ -973,7 +973,7 @@ function write_pm_addresses($check_ary, $author, $plaintext = false)
{
if (!isset($address['group'][$row['group_id']]))
{
if ($check_type == 'to' || $author == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
if ($check_type == 'to' || $author_id == $user->data['user_id'] || $row['user_id'] == $user->data['user_id'])
{
$address['group'][$row['group_id']] = array('name' => $row['group_name'], 'colour' => $row['group_colour']);
}
@ -1049,7 +1049,7 @@ function get_folder_status($folder_id, $folder)
//
// Submit PM
function submit_pm($mode, $subject, $data, $update_message, $put_in_outbox = true)
function submit_pm($mode, $subject, &$data, $update_message, $put_in_outbox = true)
{
global $db, $auth, $user, $config, $phpEx, $SID, $template;

View file

@ -11,13 +11,10 @@
//
// -------------------------------------------------------------
// TODO for M-3:
//
// * simplify the class (logical seperation between display and insert/update)
class custom_profile
{
var $profile_types = array(1 => 'int', 2 => 'string', 3 => 'text', 4 => 'bool', 5 => 'dropdown', 6 => 'date');
var $profile_cache = array();
var $options_lang = array();
// Build language options cache, useful for viewtopic display
@ -25,7 +22,7 @@ class custom_profile
{
global $db, $user;
$this->cache = array();
$this->profile_cache = array();
$sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
@ -39,130 +36,11 @@ class custom_profile
while ($row = $db->sql_fetchrow($result))
{
$this->cache[$row['field_ident']] = $row;
$this->profile_cache[$row['field_ident']] = $row;
}
$db->sql_freeresult($result);
}
// Functions performing operations on register/profile/profile admin
function submit_cp_field($mode, &$cp_data, &$cp_error)
{
global $auth, $db;
$sql = 'SELECT *
FROM ' . PROFILE_FIELDS_TABLE . '
WHERE field_active = 1
' . (($mode == 'register') ? ' AND field_show_on_reg = 1' : '') .
(($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND field_hide = 0') . '
ORDER BY field_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$cp_data[$row['field_ident']] = $this->get_profile_field($row);
if (($cp_result = $this->validate_profile_field($row['field_type'], $cp_data[$row['field_ident']], $row)) !== false)
{
$cp_error[] = strtoupper($row['field_ident']) . "_$cp_result";
}
}
$db->sql_freeresult($result);
}
// Assign fields to template, mode can be profile (for profile change) or register (for registration)
function generate_profile_fields($mode, $lang_id, $cp_error)
{
global $db, $template, $auth, $user;
$sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
WHERE l.lang_id = $lang_id
AND f.field_active = 1
" . (($mode == 'register') ? ' AND f.field_show_on_reg = 1' : '') .
(($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND f.field_hide = 0') . '
AND l.field_id = f.field_id
GROUP BY f.field_id
ORDER BY f.field_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('profile_fields', array(
'LANG_NAME' => $row['lang_name'],
'LANG_EXPLAIN' => $row['lang_explain'],
'FIELD' => $this->process_field_row('change', $row),
'ERROR' => (isset($cp_error[$row['field_ident']])) ? $cp_error[$row['field_ident']] : '')
);
}
$db->sql_freeresult($result);
}
// Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled)
// This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template
function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
{
global $db;
if ($mode == 'grab')
{
if (!is_array($user_id))
{
$user_id = array($user_id);
}
if (!$this->cache)
{
$this->build_cache();
}
if (!implode(', ', $user_id))
{
return array();
}
$sql = 'SELECT *
FROM ' . PROFILE_DATA_TABLE . '
WHERE user_id IN (' . implode(', ', array_map('intval', $user_id)) . ')';
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result)))
{
return array();
}
$user_fields = array();
do
{
foreach ($row as $ident => $value)
{
if ($ident != 'user_id')
{
$user_fields[$row['user_id']][$ident]['value'] = $value;
$user_fields[$row['user_id']][$ident]['data'] = $this->cache[$ident];
}
}
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
return $user_fields;
}
else if ($mode == 'show')
{
// $profile_row == $user_fields[$row['user_id']]
$tpl_fields = array();
foreach ($profile_row as $ident => $ident_ary)
{
$tpl_fields['PF_' . strtoupper($ident) . '_VALUE'] = $this->get_profile_value($ident_ary['data']['field_id'], $ident_ary['data']['lang_id'], $ident_ary['data']['field_type'], $ident_ary['value']);
$tpl_fields['PF_' . strtoupper($ident) . '_TITLE'] = $ident_ary['data']['lang_name'];
}
return $tpl_fields;
}
}
// Get language entries for options and store them here for later use
function get_option_lang($field_id, $lang_id, $field_type, $preview)
{
@ -194,6 +72,167 @@ class custom_profile
$db->sql_freeresult($result);
}
}
// Functions performing operations on register/profile/profile admin
function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error)
{
global $auth, $db, $user;
$sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
WHERE l.lang_id = $lang_id
AND f.field_active = 1
" . (($mode == 'register') ? ' AND f.field_show_on_reg = 1' : '') .
(($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND f.field_hide = 0') . '
AND l.field_id = f.field_id
GROUP BY f.field_id
ORDER BY f.field_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$cp_data[$row['field_ident']] = $this->get_profile_field($row);
if (($cp_result = $this->validate_profile_field($row['field_type'], $cp_data[$row['field_ident']], $row)) !== false)
{
// If not and only showing common error messages, use this one
$error = '';
switch ($cp_result)
{
case 'FIELD_INVALID_DATE':
case 'FIELD_REQUIRED':
$error = sprintf($user->lang[$cp_result], $row['lang_name']);
break;
case 'FIELD_TOO_SHORT':
case 'FIELD_TOO_SMALL':
$error = sprintf($user->lang[$cp_result], $row['lang_name'], $field_data['field_minlen']);
break;
case 'FIELD_TOO_LONG':
case 'FIELD_TOO_LARGE':
$error = sprintf($user->lang[$cp_result], $row['lang_name'], $field_data['field_maxlen']);
break;
case 'FIELD_INVALID_CHARS':
switch ($field_data['field_validation'])
{
case '[0-9]+':
$error = sprintf($user->lang[$cp_result . '_NUMBERS_ONLY'], $row['lang_name']);
break;
case '[\w]+':
$error = sprintf($user->lang[$cp_result . '_ALPHA_ONLY'], $row['lang_name']);
break;
case '[\w_\+\. \-\[\]]+':
$error = sprintf($user->lang[$cp_result . '_SPACERS_ONLY'], $row['lang_name']);
break;
}
break;
}
$cp_error[] = $error;
}
}
$db->sql_freeresult($result);
}
// Assign fields to template, mode can be profile (for profile change) or register (for registration)
// function generate_profile_fields($mode, $lang_id, $cp_error)
function generate_profile_fields($mode, $lang_id)
{
global $db, $template, $auth;
$sql = 'SELECT l.*, f.*
FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . " f
WHERE l.lang_id = $lang_id
AND f.field_active = 1
" . (($mode == 'register') ? ' AND f.field_show_on_reg = 1' : '') .
(($auth->acl_gets('a_', 'm_') && $mode == 'profile') ? '' : ' AND f.field_hide = 0') . '
AND l.field_id = f.field_id
GROUP BY f.field_id
ORDER BY f.field_order';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('profile_fields', array(
'LANG_NAME' => $row['lang_name'],
'LANG_EXPLAIN' => $row['lang_explain'],
'FIELD' => $this->process_field_row('change', $row))
// 'ERROR' => $error)
);
}
$db->sql_freeresult($result);
}
// Assign fields to template, used for viewprofile, viewtopic and memberlist (if load setting is enabled)
// This is directly connected to the user -> mode == grab is to grab the user specific fields, mode == show is for assigning the row to the template
function generate_profile_fields_template($mode, $user_id = 0, $profile_row = false)
{
global $db;
if ($mode == 'grab')
{
if (!is_array($user_id))
{
$user_id = array($user_id);
}
if (!sizeof($this->profile_cache))
{
$this->build_cache();
}
if (!implode(', ', $user_id))
{
return array();
}
$sql = 'SELECT *
FROM ' . PROFILE_DATA_TABLE . '
WHERE user_id IN (' . implode(', ', array_map('intval', $user_id)) . ')';
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result)))
{
return array();
}
$user_fields = array();
do
{
foreach ($row as $ident => $value)
{
if ($ident != 'user_id')
{
$user_fields[$row['user_id']][$ident]['value'] = $value;
$user_fields[$row['user_id']][$ident]['data'] = $this->profile_cache[$ident];
}
}
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
return $user_fields;
}
else if ($mode == 'show')
{
// $profile_row == $user_fields[$row['user_id']]
$tpl_fields = array();
foreach ($profile_row as $ident => $ident_ary)
{
$tpl_fields += array(
'PROFILE_' . strtoupper($ident) . '_VALUE' => $this->get_profile_value($ident_ary['data']['field_id'], $ident_ary['data']['lang_id'], $ident_ary['data']['field_type'], $ident_ary['value']),
'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
'PROFILE_' . strtoupper($ident) . '_NAME' => $ident_ary['data']['lang_name'],
'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $ident_ary['data']['lang_explain'],
'S_PROFILE_' . strtoupper($ident) => true
);
}
return $tpl_fields;
}
}
// VALIDATE Function - validate entered data
function validate_profile_field($field_type, &$field_value, $field_data)
@ -231,7 +270,7 @@ class custom_profile
if ($day < 0 || $day > 31 || $month < 0 || $month > 12 || ($year < 1901 && $year > 0) || $year > gmdate('Y', time()))
{
return 'INVALID_DATE';
return 'FIELD_INVALID_DATE';
}
break;
@ -243,11 +282,11 @@ class custom_profile
if ($field_value < $field_data['field_minlen'])
{
return 'TOO_SMALL';
return 'FIELD_TOO_SMALL';
}
else if ($field_value > $field_data['field_maxlen'])
{
return 'TOO_LARGE';
return 'FIELD_TOO_LARGE';
}
break;
@ -264,22 +303,26 @@ class custom_profile
{
return false;
}
else if (empty($field_value) && $field_data['field_required'])
{
return 'FIELD_REQUIRED';
}
if ($field_data['field_minlen'] && strlen($field_value) < $field_data['field_minlen'])
{
return 'TOO_SHORT';
return 'FIELD_TOO_SHORT';
}
else if ($field_data['field_maxlen'] && strlen($field_value) > $field_data['field_maxlen'])
{
return 'TOO_LONG';
return 'FIELD_TOO_LONG';
}
if (!empty($field_data['field_validation']))
if (!empty($field_data['field_validation']) && $field_data['field_validation'] != '.*')
{
$field_validate = ($field_type == FIELD_STRING) ? $field_value : str_replace("\n", ' ', $field_value);
if (!preg_match('#^' . str_replace('\\\\', '\\', $field_data['field_validation']) . '$#i', $field_validate))
{
return 'INVALID_CHARS';
return 'FIELD_INVALID_CHARS';
}
}
break;
@ -323,7 +366,15 @@ class custom_profile
$profile_row['field_name'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
$value = (isset($_REQUEST[$profile_row['field_name']])) ? request_var($profile_row['field_name'], $default_value) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
// checkbox - only testing for isset
if ($profile_row['field_type'] == FIELD_BOOL && $profile_row['field_length'] == 2)
{
$value = (isset($_REQUEST[$profile_row['field_name']])) ? true : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
}
else
{
$value = (isset($_REQUEST[$profile_row['field_name']])) ? request_var($profile_row['field_name'], $default_value) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
}
switch ($field_validation)
{
@ -395,7 +446,7 @@ class custom_profile
}
unset($now);
$this->set_tpl_vars($profile_row, $value);
$this->set_tpl_vars($profile_row, 0);
return $this->get_cp_html();
}
@ -404,12 +455,12 @@ class custom_profile
global $template;
$value = $this->get_var('int', $profile_row, $profile_row['field_default_value'], $preview);
$this->set_tpl_vars($profile_row, $value);
if ($profile_row['field_length'] == 1)
{
if (!sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
if (!isset($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]) || !sizeof($this->options_lang[$profile_row['field_id']][$profile_row['lang_id']]))
{
$this->get_option_lang($profile_row['field_id'], $profile_row['lang_id'], FIELD_BOOL, $preview);
}
@ -668,6 +719,7 @@ class custom_profile_admin extends custom_profile
$profile_row = array(
'var_name' => 'field_default_value',
'field_id' => 1,
'lang_name' => $this->vars['lang_name'],
'lang_explain' => $this->vars['lang_explain'],
'lang_id' => $default_lang_id,
@ -705,8 +757,10 @@ class custom_profile_admin extends custom_profile
);
$profile_row[1] = $profile_row[0];
$profile_row[1]['var_name'] = 'field_no_value';
$profile_row[1]['field_ident'] = 'field_no_value';
$profile_row[1]['var_name'] = 'field_novalue';
$profile_row[1]['field_ident'] = 'field_novalue';
$profile_row[1]['field_default_value'] = $this->vars['field_novalue'];
$options = array(
0 => array('TITLE' => $user->lang['DEFAULT_VALUE'], 'FIELD' => $this->generate_dropdown($profile_row[0], true)),

View file

@ -155,6 +155,19 @@ class bbcode_firstpass extends bbcode
// 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('\"', '"', $in));
// 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 a [code] blocks
$htm_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 \-\->#',
'#<!\-\- h \-\-><(.*?)><!\-\- h \-\->#',
);
$htm_replace = array('\1', '\1', '\1', '\1', '\1', '&lt;\1&gt;');
$out = '';
do
@ -162,7 +175,7 @@ class bbcode_firstpass extends bbcode
$pos = stripos($in, '[/code]') + 7;
$code = substr($in, 0, $pos);
$in = substr($in, $pos);
// $code contains everything that was between code tags (including the ending tag) but we're trying to grab as much extra text as possible, as long as it does not contain open [code] tags
while ($in)
{
@ -182,6 +195,7 @@ class bbcode_firstpass extends bbcode
$code = substr($code, 0, -7);
// $code = preg_replace('#^[\r\n]*(.*?)[\n\r\s\t]*$#s', '$1', $code);
$code = preg_replace($htm_match, $htm_replace, $code);
switch (strtolower($stx))
{
@ -213,9 +227,9 @@ class bbcode_firstpass extends bbcode
if ($remove_tags)
{
$str_from[] = '<span class="syntaxdefault">&lt;?php&nbsp;</span>';
$str_from[] = '<span class="syntaxdefault">&lt;?php </span>';
$str_to[] = '';
$str_from[] = '<span class="syntaxdefault">&lt;?php&nbsp;';
$str_from[] = '<span class="syntaxdefault">&lt;?php ';
$str_to[] = '<span class="syntaxdefault">';
}
@ -240,10 +254,11 @@ class bbcode_firstpass extends bbcode
$out .= '[code:' . $this->bbcode_uid . ']' . str_replace($str_from, $str_to, $code) . '[/code:' . $this->bbcode_uid . ']';
}
if (preg_match('#(.*?)\[code(?:=[a-z]+)?\](.+)#is', $in, $m))
if (preg_match('#(.*?)\[code(?:=([a-z]+))?\](.+)#is', $in, $m))
{
$out .= $m[1];
$in = $m[2];
$stx = $m[2];
$in = $m[3];
}
}
while ($in);
@ -282,10 +297,10 @@ class bbcode_firstpass extends bbcode
{
// if $tok is ']' the buffer holds a tag
if ($buffer == '/list' && count($list_end_tags))
if ($buffer == '/list' && sizeof($list_end_tags))
{
// valid [/list] tag
if (count($item_end_tags))
if (sizeof($item_end_tags))
{
// current li tag has not been closed
$out = preg_replace('/(\n)?\[$/', '[', $out) . array_pop($item_end_tags) . '][';
@ -310,10 +325,10 @@ class bbcode_firstpass extends bbcode
}
else
{
if ($buffer == '*' && count($list_end_tags))
if ($buffer == '*' && sizeof($list_end_tags))
{
// the buffer holds a bullet tag and we have a [list] tag open
if (count($item_end_tags) >= count($list_end_tags))
if (sizeof($item_end_tags) >= sizeof($list_end_tags))
{
// current li tag has not been closed
if (preg_match('/\n\[$/', $out, $m))
@ -354,11 +369,11 @@ class bbcode_firstpass extends bbcode
while ($in);
// do we have some tags open? close them now
if (count($item_end_tags))
if (sizeof($item_end_tags))
{
$out .= '[' . implode('][', $item_end_tags) . ']';
}
if (count($list_end_tags))
if (sizeof($list_end_tags))
{
$out .= '[' . implode('][', $list_end_tags) . ']';
}
@ -374,6 +389,9 @@ class bbcode_firstpass extends bbcode
$tok = ']';
$out = '[';
// Add newline at the end of each quote block to prevent parsing errors (urls, smilies, etc.)
$in = preg_replace('#([^\n])\[\/quote\]#is', "\\1\n[/quote]", $in);
$in = substr(str_replace('\"', '"', $in), 1);
$close_tags = $error_ary = array();
$buffer = '';
@ -396,7 +414,7 @@ class bbcode_firstpass extends bbcode
if ($tok == ']')
{
if ($buffer == '/quote' && count($close_tags))
if ($buffer == '/quote' && sizeof($close_tags))
{
// we have found a closing tag
@ -407,7 +425,7 @@ class bbcode_firstpass extends bbcode
elseif (preg_match('#^quote(?:=&quot;(.*?)&quot;)?$#is', $buffer, $m))
{
// the buffer holds a valid opening tag
if ($config['max_quote_depth'] && count($close_tags) >= $config['max_quote_depth'])
if ($config['max_quote_depth'] && sizeof($close_tags) >= $config['max_quote_depth'])
{
// there are too many nested quotes
$error_ary['quote_depth'] = sprintf($user->lang['QUOTE_DEPTH_EXCEEDED'], $config['max_quote_depth']);
@ -483,7 +501,7 @@ class bbcode_firstpass extends bbcode
}
while ($in);
if (count($close_tags))
if (sizeof($close_tags))
{
$out .= '[' . implode('][', $close_tags) . ']';
}
@ -626,6 +644,18 @@ class parse_message extends bbcode_firstpass
$this->html($config['allow_html_tags']);
}
// Parse Emoticons
if ($allow_smilies)
{
$this->emoticons($config['max_post_smilies']);
}
// Parse URL's
if ($allow_magic_url)
{
$this->magic_url((($config['cookie_secure']) ? 'https://' : 'http://'), $config['server_name'], $config['server_port'], $config['script_path']);
}
// Parse BBCode
if ($allow_bbcode && strpos($this->message, '[') !== false)
{
@ -641,18 +671,6 @@ class parse_message extends bbcode_firstpass
$this->parse_bbcode();
}
// Parse Emoticons
if ($allow_smilies)
{
$this->emoticons($config['max_post_smilies']);
}
// Parse URL's
if ($allow_magic_url)
{
$this->magic_url((($config['cookie_secure']) ? 'https://' : 'http://'), $config['server_name'], $config['server_port'], $config['script_path']);
}
if (!$update_this_message)
{
unset($this->message);
@ -737,7 +755,7 @@ class parse_message extends bbcode_firstpass
if (sizeof($allowed_tags))
{
$this->message = preg_replace('#&lt;(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')&gt;#is', '<$1$2>', $this->message);
$this->message = preg_replace('#&lt;(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')&gt;#is', '<!-- h --><$1$2><!-- h -->', $this->message);
}
}
@ -786,9 +804,24 @@ class parse_message extends bbcode_firstpass
global $db, $user, $phpbb_root_path;
// NOTE: obtain_* function? chaching the table contents?
// For now setting the ttl to 10 minutes
$sql = 'SELECT *
FROM ' . SMILIES_TABLE;
switch (SQL_LAYER)
{
case 'mssql':
case 'mssql-odbc':
$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
ORDER BY LEN(code) DESC';
break;
// LENGTH supported by MySQL, IBM DB2, Oracle and Access for sure...
default:
$sql = 'SELECT *
FROM ' . SMILIES_TABLE . '
ORDER BY LENGTH(code) DESC';
break;
}
$result = $db->sql_query($sql, 600);
if ($row = $db->sql_fetchrow($result))
@ -884,7 +917,7 @@ class parse_message extends bbcode_firstpass
}
}
if ($preview || $refresh || count($error))
if ($preview || $refresh || sizeof($error))
{
// Perform actions on temporary attachments
if ($delete_file)
@ -932,7 +965,7 @@ class parse_message extends bbcode_firstpass
$error = array_merge($error, $filedata['error']);
if (!count($error))
if (!sizeof($error))
{
$new_entry = array(
'physical_filename' => $filedata['destination_filename'],

View file

@ -132,7 +132,7 @@ class session
$sessiondata = array();
$current_time = time();
$current_user = $this->data['user_id'];
$current_user = $user_id;
$bot = false;
// Pull bot information from DB and loop through it
@ -568,9 +568,6 @@ class user extends session
unset($row);
unset($row2);
// Set theme info
$theme_info = array();
// Add to template database
foreach (array_keys($this->theme) as $style_priority)
{
@ -1000,7 +997,7 @@ class auth
{
foreach ($this->acl_options['global'] as $opt => $id)
{
if (strstr($opt, 'a_'))
if (strpos($opt, 'a_') !== false)
{
$hold_ary[0][$opt] = 1;
}

View file

@ -350,7 +350,7 @@ class template
}
$compile_blocks = array();
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++)
for ($curr_tb = 0, $tb_size = sizeof($text_blocks); $curr_tb < $tb_size; $curr_tb++)
{
switch ($blocks[1][$curr_tb])
{
@ -427,7 +427,7 @@ class template
}
$template_php = '';
for ($i = 0; $i < count($text_blocks); $i++)
for ($i = 0, $size = sizeof($text_blocks); $i < $size; $i++)
{
$trim_check_text = trim($text_blocks[$i]);
$trim_check_block = trim($compile_blocks[$i]);
@ -450,7 +450,7 @@ class template
// This one will handle varrefs WITH namespaces
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)(\$)?([A-Z0-9\-_]+?)\}#', $text_blocks, $varrefs);
for ($j = 0; $j < sizeof($varrefs[1]); $j++)
for ($j = 0, $size = sizeof($varrefs[1]); $j < $size; $j++)
{
$namespace = $varrefs[1][$j];
$varname = $varrefs[4][$j];
@ -541,7 +541,7 @@ class template
$tokens = $match[0];
$is_arg_stack = array();
for ($i = 0; $i < count($tokens); $i++)
for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
{
$token = &$tokens[$i];

View file

@ -71,7 +71,6 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
$recipient_list = $address_list = $address = array();
if ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX)
{
foreach ($folder_info['rowset'] as $message_id => $row)
{
$address[$message_id] = rebuild_header(array('to' => $row['to_address'], 'bcc' => $row['bcc_address']));
@ -122,8 +121,8 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
foreach ($folder_info['pm_list'] as $message_id)
{
$row =& $folder_info['rowset'][$message_id];
$row = &$folder_info['rowset'][$message_id];
$folder_img = ($row['unread']) ? 'folder_new' : 'folder';
$folder_alt = ($row['unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES';
@ -167,8 +166,8 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
// 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&amp;mode=mod_queue&amp;t=$topic_id")
);
unset($folder_info['rowset'][$message_id]);
}
unset($folder_info['rowset']);
$template->assign_vars(array(
'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false,

View file

@ -252,9 +252,14 @@ class ucp_profile extends module
unset($data);
// validate custom profile fields
$cp->submit_cp_field('profile', $cp_data, $cp_error);
$cp->submit_cp_field('profile', $user->get_iso_lang_id(), $cp_data, $cp_error);
if (!sizeof($error) && !sizeof($cp_error))
if (sizeof($cp_error))
{
$error = array_merge($error, $cp_error);
}
if (!sizeof($error))
{
$sql_ary = array(
'user_icq' => $icq,
@ -351,7 +356,7 @@ class ucp_profile extends module
// Get additional profile fields and assign them to the template block var 'profile_fields'
$user->get_profile_fields($user->data['user_id']);
$cp->generate_profile_fields('profile', $user->get_iso_lang_id(), $cp_error);
$cp->generate_profile_fields('profile', $user->get_iso_lang_id());
break;

View file

@ -111,7 +111,7 @@ class ucp_register extends module
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
// validate custom profile fields
$cp->submit_cp_field('register', $cp_data, $error);
$cp->submit_cp_field('register', $user->get_iso_lang_id(), $cp_data, $error);
// Visual Confirmation handling
$wrong_confirm = false;
@ -438,7 +438,7 @@ class ucp_register extends module
$user->profile_fields = array();
// Generate profile fields -> Template Block Variable profile_fields
$cp->generate_profile_fields('register', $user->get_iso_lang_id(), $cp_error);
$cp->generate_profile_fields('register', $user->get_iso_lang_id());
//
$this->display($user->lang['REGISTER'], 'ucp_register.html');

View file

@ -1054,13 +1054,13 @@ if ($stage == 3)
$dbms_schema = 'schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
// How should we treat this schema?
$remove_remarks = $available_dbms[$dbms]['COMMENTS'];;
$remove_remarks = $available_dbms[$dbms]['COMMENTS'];
$delimiter = $available_dbms[$dbms]['DELIM'];
$sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema));
$sql_query = preg_replace('#phpbb_#is', $table_prefix, $sql_query);
$sql_query = $remove_remarks($sql_query);
$remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);
foreach ($sql_query as $sql)
@ -1092,7 +1092,7 @@ if ($stage == 3)
$sql_query = preg_replace('#phpbb_#', $table_prefix, $sql_query);
$sql_query = remove_remarks($sql_query);
remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, ';');
foreach ($sql_query as $sql)

View file

@ -74,6 +74,9 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread',
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_onlinetrack', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('search_gc', '7200');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cache_gc', '7200');

View file

@ -2036,15 +2036,29 @@ $lang += array(
'SECOND_OPTION' => 'Second Option',
'EMPTY_FIELD_NAME' => 'Empty field name',
'EMPTY_USER_FIELD_NAME' => 'Empty Field Name presented to the user',
'FIELD_IDENT_ALREADY_EXIST' => 'Field identifier %s already exist, please choose another Field Name.',
'NEXT_PAGE' => 'Next Page',
'PREVIOUS_PAGE' => 'Previous Page',
'STEP_1_TITLE' => 'Add Profile Field',
'STEP_1_EXPLAIN' => 'Here you can enter the first basic parameters of your new profile field. These informations are needed for the second step where you are able to set remaining options and where you are able to preview and tweak your profile field further.',
'STEP_2_TITLE' => 'Profile type specific options',
'STEP_2_EXPLAIN' => 'Here you are able to define some common options. Further you are able to preview the field you generated, as the user will see it. Play around with it until you are satisfied as how the field behaves.',
'STEP_3_TITLE' => 'Remaining Language Definitions',
'STEP_3_EXPLAIN' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. The profile field will work with the default language enabled, you are able to fill out the remaining language items later too.',
'PROFILE_BASIC_OPTIONS' => 'Basic Options',
'PROFILE_TYPE_OPTIONS' => 'Profile type specific options',
'PROFILE_LANG_OPTIONS' => 'Language specific options',
'STEP_1_TITLE_CREATE' => 'Add Profile Field',
'STEP_1_TITLE_EDIT' => 'Edit Profile Field',
'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. These informations are needed for the second step where you are able to set remaining options and where you are able to preview and tweak your profile field further.',
'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step, where you are able to preview and test the changed settings.',
'STEP_2_TITLE_CREATE' => 'Profile type specific options',
'STEP_2_TITLE_EDIT' => 'Profile type specific options',
'STEP_2_EXPLAIN_CREATE' => 'Here you are able to define some common options. Further you are able to preview the field you generated, as the user will see it. Play around with it until you are satisfied as how the field behaves.',
'STEP_2_EXPLAIN_EDIT' => 'Here you are able to change some common options. Further you are able to preview the changed field, as the user will see it. Play around with it until you are satisfied as how the field behaves.<br /><b>Please note that changes to profile fields will not affect existing profile fields entered by your users.</b>',
'STEP_3_TITLE_CREATE' => 'Remaining Language Definitions',
'STEP_3_TITLE_EDIT' => 'Language Definitions',
'STEP_3_EXPLAIN_CREATE' => 'Since you have more than one board language installed, you have to fill out the remaining language items too. The profile field will work with the default language enabled, you are able to fill out the remaining language items later too.',
'STEP_3_EXPLAIN_EDIT' => 'Since you have more than one board language installed, you now can change or add the remaining language items too. The profile field will work with the default language enabled.',
'ROWS' => 'Rows',
'COLUMNS' => 'Columns',
'UPDATE_PREVIEW' => 'Update Preview',
@ -2077,7 +2091,7 @@ $lang += array(
'FIELD_TYPE' => 'Field Type',
'FIELD_TYPE_EXPLAIN' => 'You are not able to change the field type later.',
'FIELD_NAME' => 'Field Name',
'FIELD_NAME_EXPLAIN' => 'The Field Name is a name for you to identify the profile field, it is not displayed to the user. You are able to use this name as template variable later.',
'FIELD_NAME_EXPLAIN' => 'The Field Name is a name for you to identify the profile field, it is not displayed to the user.',
'LANG_SPECIFIC_OPTIONS' => 'Language specific options [<b>%s</b>]',
'USER_FIELD_NAME' => 'Field Name presented to the user',
'FIELD_DESCRIPTION' => 'Field Description',

View file

@ -504,7 +504,7 @@ $lang += array(
),
);
// Pool of unused or currently not assignable language variables
/* Pool of unused or currently not assignable language variables
$unused = array(
'ALREADY_VOTED' => 'You have already voted in this poll and may not change your selection.',
'AM' => 'AM',
@ -614,6 +614,6 @@ $unused = array(
'VIEWING_MESSAGES' => 'Viewing Private Messages',
'View_Information' => 'View Information'
);
*/
?>

View file

@ -127,6 +127,16 @@ $lang += array(
'EXPORT_AS_TXT' => 'Export as TXT',
'EXPORT_AS_MSG' => 'Export as MSG',
'FIELD_REQUIRED' => 'The field "%s" must be completed.',
'FIELD_TOO_SHORT' => 'The field "%1$s" is too short, a minimum of %2$d characters is required.',
'FIELD_TOO_LONG' => 'The field "%1$s" is too long, a maximum of %2$d characters is allowed.',
'FIELD_TOO_SMALL' => 'The value of "%1$s" is too small, a minimum value of %2$d is required.',
'FIELD_TOO_LARGE' => 'The value of "%1$s" is too large, a maximum value of %2$d is allowed.',
'FIELD_INVALID_CHARS_NUMBERS_ONLY' => 'The field "%s" has invalid characters, only numbers are allowed.',
'FIELD_INVALID_CHARS_ALPHA_ONLY' => 'The field "%s" has invalid characters, only alphanumeric characters are allowed.',
'FIELD_INVALID_CHARS_SPACERS_ONLY' => 'The field "%s" has invalid characters, only alphanumeric, space or -+_[] characters are allowed.',
'FIELD_INVALID_DATE' => 'The field "%s" has an invalid date.',
'FOE_MESSAGE' => 'Message from foe',
'FOES_EXPLAIN' => 'Foes are users which will be ignored by default. Posts by these users will not be fully visible and personal messages will not be permitted. Please note that you cannot ignore moderators or administrators.',
'FOES_UPDATED' => 'Your foes list has been updated successfully',

View file

@ -380,6 +380,23 @@ switch ($mode)
$template->assign_vars(show_profile($member));
// Custom Profile Fields
$profile_fields = array();
if ($config['load_cpf_viewprofile'])
{
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$cp = new custom_profile();
$profile_fields = $cp->generate_profile_fields_template('grab', $user_id);
$profile_fields = (isset($profile_fields[$user_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields[$user_id]) : array();
if (sizeof($profile_fields))
{
$template->assign_vars($profile_fields);
}
}
$template->assign_vars(array(
'POSTS_DAY' => sprintf($user->lang['POST_DAY'], $posts_per_day),
'POSTS_PCT' => sprintf($user->lang['POST_PCT'], $percentage),
@ -407,6 +424,7 @@ switch ($mode)
'S_PROFILE_ACTION' => "memberlist.$phpEx$SID&amp;mode=group",
'S_GROUP_OPTIONS' => $group_options,
'S_CUSTOM_FIELDS' => (sizeof($profile_fields)) ? true : false,
'U_ADD_FRIEND' => "ucp.$phpEx$SID&amp;i=zebra&amp;add=" . urlencode($member['username']),
'U_ACTIVE_FORUM' => "viewforum.$phpEx$SID&amp;f=$active_f_id",

View file

@ -908,7 +908,22 @@ if (!sizeof($error) && $preview)
$extensions = $update_count = array();
$template->assign_var('S_HAS_ATTACHMENTS', true);
display_attachments($forum_id, 'attachment', $message_parser->attachment_data, $update_count, true);
$attachment_data = $message_parser->attachment_data;
$unset_attachments = parse_inline_attachments($preview_message, $attachment_data, $update_count, $forum_id);
foreach ($unset_attachments as $index)
{
unset($attachment_data[$index]);
}
foreach ($attachment_data as $i => $attachment)
{
$template->assign_block_vars('attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
unset($attachment_data, $attachment);
}
if (!sizeof($error))
@ -955,7 +970,6 @@ if (sizeof($poll_options) && $poll_title)
$message_parser->decode_message();
$poll_options = explode("\n", $message_parser->message);
}
unset($message_parser);
// MAIN POSTING PAGE BEGINS HERE
@ -1153,7 +1167,7 @@ page_footer();
//
// Delete Post
function delete_post($mode, $post_id, $topic_id, $forum_id, $data)
function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
{
global $db, $user, $config, $auth, $phpEx, $SID;
@ -1290,7 +1304,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, $data)
// Submit Post
function submit_post($mode, $subject, $username, $topic_type, $poll, $data, $update_message = true)
function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true)
{
global $db, $auth, $user, $config, $phpEx, $SID, $template, $phpbb_root_path;
@ -1600,7 +1614,7 @@ function submit_post($mode, $subject, $username, $topic_type, $poll, $data, $upd
$db->sql_freeresult($result);
}
for ($i = 0; $i < sizeof($poll['poll_options']); $i++)
for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++)
{
if (trim($poll['poll_options'][$i]))
{

View file

@ -9,7 +9,7 @@
<tr>
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>
<br />

View file

@ -36,7 +36,7 @@
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav" align="left" valign="middle">{PAGE_NUMBER}</td>
<td align="right" valign="top" nowrap="nowrap"><span class="nav">{PAGINATION}</span></td>
<td align="right" valign="top" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>

View file

@ -44,7 +44,7 @@
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td class="nav" align="left" valign="middle">{PAGE_NUMBER}</td>
<td align="right" valign="top" nowrap="nowrap"><span class="nav">{PAGINATION}</span></td>
<td align="right" valign="top" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>

View file

@ -70,7 +70,7 @@
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="pagination">{PAGE_NUMBER} [ {TOTAL_USERS} ]</td>
<td align="right"><!-- IF S_SEARCH_USER --><b class="nav"><a href="javascript:marklist(true);">{L_MARK_ALL}</a> :: <a href="javascript:marklist(false);">{L_UNMARK_ALL}</a></b><br /><!-- ENDIF --><span class="pagination">{PAGINATION}</span></td>
<td align="right"><!-- IF S_SEARCH_USER --><b class="nav"><a href="javascript:marklist(true);">{L_MARK_ALL}</a> :: <a href="javascript:marklist(false);">{L_UNMARK_ALL}</a></b><br /><!-- ENDIF --><span class="pagination"><!-- IF PAGINATION --><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --><!-- ENDIF --></span></td>
</tr>
</table>

View file

@ -120,6 +120,12 @@
<td class="gen" align="right" nowrap="nowrap">{L_WEBSITE}: </td>
<td><b><!-- IF U_WWW --><a class="genmed" href="{U_WWW}" target="_userwww">{U_WWW}</a><!-- ENDIF --></b></td>
</tr>
<!-- IF S_PROFILE_FIELD_1 -->
<tr>
<td class="gen" align="right" nowrap="nowrap">{PROFILE_FIELD_1_NAME}: </td>
<td><b class="genmed">{PROFILE_FIELD_1_VALUE}</b></td>
</tr>
<!-- ENDIF -->
</table></td>
</tr>
<tr>

View file

@ -42,7 +42,7 @@
<tr>
<td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><span class="postbody">{PREVIEW_MESSAGE}</span>
<td><div class="postbody">{PREVIEW_MESSAGE}</div>
<!-- IF S_HAS_ATTACHMENTS -->
<br clear="all" /><br />

View file

@ -55,7 +55,7 @@
</tr>
</table></form>
<div class="nav" style="float:left">{PAGE_NUMBER}&nbsp;[ {TOTAL_TOPICS} ]</div><div class="nav" style="float:right">{PAGINATION}</div>
<div class="nav" style="float:left">{PAGE_NUMBER}&nbsp;[ {TOTAL_TOPICS} ]</div><div class="nav" style="float:right"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></div>
<br clear="all" /><br />

View file

@ -49,7 +49,7 @@
</tr>
</table></form>
<div class="nav" style="float:left">{PAGE_NUMBER}&nbsp;[ {TOTAL_TOPICS} ]</div><div class="nav" style="float:right">{PAGINATION}</div>
<div class="nav" style="float:left">{PAGE_NUMBER}&nbsp;[ {TOTAL_TOPICS} ]</div><div class="nav" style="float:right"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></div>
<br clear="all" /><br />

View file

@ -32,7 +32,7 @@
</tr>
</table>
<div class="nav" style="float:left">{PAGE_NUMBER}</div><div style="float:right"><b class="gensmall"><a href="javascript:marklist('ucp', true);">{L_MARK_ALL}</a> :: <a href="javascript:marklist('ucp', false);">{L_UNMARK_ALL}</a></b><!-- IF PAGINATION --><br /><span class="nav">{PAGINATION}</span><!-- ENDIF --></div>
<div class="nav" style="float:left">{PAGE_NUMBER}</div><div style="float:right"><b class="gensmall"><a href="javascript:marklist('ucp', true);">{L_MARK_ALL}</a> :: <a href="javascript:marklist('ucp', false);">{L_UNMARK_ALL}</a></b><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></div>
<!-- ELSE -->

View file

@ -9,7 +9,7 @@
<tr>
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_MESSAGES} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>
<!-- ENDIF -->

View file

@ -29,7 +29,7 @@ function marklist(form_name, status)
<tr>
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_MESSAGES} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>
<!-- ENDIF -->

View file

@ -47,7 +47,11 @@
<!-- IF topicrow.S_TOPIC_REPORTED -->
<a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
<p class="topictitle">{topicrow.NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p><p class="gensmall">{topicrow.GOTO_PAGE}</p></td>
<p class="topictitle">{topicrow.NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p>
<!-- IF topicrow.PAGINATION -->
<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
<!-- ENDIF -->
</td>
<td class="row2" width="100" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR}</p></td>
<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>
<td class="row2" width="50" align="center"><p class="topicdetails">{topicrow.VIEWS}</p></td>
@ -109,7 +113,7 @@
<!-- IF TOTAL_TOPICS -->
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_TOPICS} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
<!-- ENDIF -->
</tr>
</table>
@ -162,7 +166,11 @@
<!-- IF topicrow.S_TOPIC_REPORTED -->
<a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
<p class="topictitle">{topicrow.NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p><p class="gensmall">{topicrow.GOTO_PAGE}</p></td>
<p class="topictitle">{topicrow.NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p>
<!-- IF topicrow.PAGINATION -->
<p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
<!-- ENDIF -->
</td>
<td class="row2" width="100" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR}</p></td>
<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td>
<td class="row2" width="50" align="center"><p class="topicdetails">{topicrow.VIEWS}</p></td>
@ -200,7 +208,7 @@
<td align="left" valign="middle"><a href="{U_POST_NEW_TOPIC}">{POST_IMG}</a></td>
<td class="nav" nowrap="nowrap">&nbsp;{PAGE_NUMBER}</td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_TOPICS} ]</td>
<td class="nav" width="100%" align="right" nowrap="nowrap">{PAGINATION}</td>
<td class="nav" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
</tr>
</table>

View file

@ -36,7 +36,7 @@
<!-- IF TOTAL_POSTS -->
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_POSTS} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
<!-- ENDIF -->
</tr>
</table>
@ -171,6 +171,7 @@
<!-- IF postrow.POSTER_POSTS --><br /><b>{L_JOINED}:</b> {postrow.POSTER_JOINED}<!-- ENDIF -->
<!-- IF postrow.POSTER_POSTS --><br /><b>{L_POSTS}:</b> {postrow.POSTER_POSTS}<!-- ENDIF -->
<!-- IF postrow.POSTER_FROM --><br /><b>{L_LOCATION}:</b> {postrow.POSTER_FROM}<!-- ENDIF -->
<!-- IF postrow.S_PROFILE_FIELD_1 --><br /><b>{postrow.PROFILE_FIELD_1_NAME}:</b> {postrow.PROFILE_FIELD_1_VALUE}<!-- ENDIF -->
</span>
</div>
@ -275,7 +276,7 @@
<!-- IF TOTAL_POSTS -->
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
<td class="gensmall" nowrap="nowrap">&nbsp;[ {TOTAL_POSTS} ]&nbsp;</td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><b>{PAGINATION}</b></td>
<td class="gensmall" width="100%" align="right" nowrap="nowrap"><!-- IF PAGINATION --><b><a href="javascript:jumpto();">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF --></td>
<!-- ENDIF -->
</tr>
</table>

View file

@ -312,7 +312,7 @@ switch ($mode)
foreach ($_COOKIE as $cookie_name => $cookie_data)
{
$cookie_name = str_replace($config['cookie_name'] . '_', '', $cookie_name);
if (!strstr($cookie_name, '_poll'))
if (strpos($cookie_name, '_poll') === false)
{
$user->set_cookie($cookie_name, '', $set_time);
}

View file

@ -277,6 +277,8 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
'REPORTED_IMG' => $user->img('icon_reported', 'TOPIC_REPORTED'),
'UNAPPROVED_IMG' => $user->img('icon_unapproved', 'TOPIC_UNAPPROVED'),
'GOTO_PAGE_IMG' => $user->img('icon_post', 'GOTO_PAGE'),
'L_NO_TOPICS' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['POST_FORUM_LOCKED'] : $user->lang['NO_TOPICS'],
'S_IS_POSTABLE' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
@ -503,29 +505,28 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
if (($replies + 1) > $config['posts_per_page'])
{
$total_pages = ceil(($replies + 1) / $config['posts_per_page']);
$goto_page = ' [ ' . $user->img('icon_post', 'GOTO_PAGE') . $user->lang['GOTO_PAGE'] . ': ';
$pagination = '';
$times = 1;
for($j = 0; $j < $replies + 1; $j += $config['posts_per_page'])
{
$goto_page .= "<a href=\"viewtopic.$phpEx$SID&amp;f=" . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&amp;t=$topic_id&amp;start=$j\">$times</a>";
$pagination .= "<a href=\"viewtopic.$phpEx$SID&amp;f=" . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . "&amp;t=$topic_id&amp;start=$j\">$times</a>";
if ($times == 1 && $total_pages > 4)
{
$goto_page .= ' ... ';
$pagination .= ' ... ';
$times = $total_pages - 3;
$j += ($total_pages - 4) * $config['posts_per_page'];
}
else if ($times < $total_pages)
{
$goto_page .= $user->theme['primary']['pagination_sep'];
$pagination .= $user->theme['primary']['pagination_sep'];
}
$times++;
}
$goto_page .= ' ] ';
}
else
{
$goto_page = '';
$pagination = '';
}
// Generate all the URIs ...
@ -549,7 +550,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
'LAST_VIEW_TIME' => $user->format_date($row['topic_last_view_time']),
'LAST_POST_AUTHOR' => ($row['topic_last_poster_name'] != '') ? $row['topic_last_poster_name'] : $user->lang['GUEST'],
'GOTO_PAGE' => $goto_page,
'PAGINATION' => $pagination,
'REPLIES' => ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'],
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => censor_text($row['topic_title']),

View file

@ -639,7 +639,7 @@ if (!empty($poll_start))
include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx);
$poll_bbcode = new bbcode();
for ($i = 0, $j = sizeof($poll_info); $i < $j; $i++)
for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
{
$poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);
$poll_info[$i]['poll_option_text'] = smilie_text($poll_info[$i]['poll_option_text']);
@ -953,14 +953,15 @@ while ($row = $db->sql_fetchrow($result))
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
/*
if ($config['load_cp_viewtopic'])
// Load custom profile fields
if ($config['load_cpf_viewtopic'])
{
include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx);
$cp = new custom_profile();
// Grab all profile fields from users in id cache for later use - similar to the poster cache
$profile_fields_cache = $cp->generate_profile_fields_template('grab', $id_cache);
}
*/
// Generate online information for user
if ($config['load_onlinetrack'] && sizeof($id_cache))
@ -1119,12 +1120,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$message = $row['post_text'];
// If the board has HTML off but the post has HTML on then we process it, else leave it alone
if (!$auth->acl_get('f_html', $forum_id))
if (!$auth->acl_get('f_html', $forum_id) && $row['enable_html'])
{
if ($row['enable_html'] && $auth->acl_get('f_bbcode', $forum_id))
{
$message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
}
$message = preg_replace('#(<!\-\- h \-\-><)([\/]?.*?)(><!\-\- h \-\->)#is', "&lt;\\2&gt;", $message);
}
// Second parse bbcode here
@ -1136,6 +1134,17 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
// Always process smilies after parsing bbcodes
$message = smilie_text($message);
if (isset($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]))
{
$unset_attachments = parse_inline_attachments($message, $attachments[$row['post_id']], $update_count, $forum_id);
// Needed to let not display the inlined attachments at the end of the post again
foreach ($unset_attachments as $index)
{
unset($attachments[$row['post_id']][$index]);
}
}
// Highlight active words (primarily for search)
if ($highlight_match)
{
@ -1144,6 +1153,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $message . '<'), 1, -1));
}
if ($row['enable_html'] && $auth->acl_get('f_html', $forum_id))
{
// Remove Comments from post content?
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message);
}
// Replace naughty words such as farty pants
$row['post_subject'] = censor_text($row['post_subject']);
$message = str_replace("\n", '<br />', censor_text($message));
@ -1196,47 +1211,15 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$l_bumped_by = '';
}
if (isset($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]))
{
$tpl = &$attachments[$row['post_id']];
$tpl = display_attachments($forum_id, NULL, $tpl, $update_count, false, true);
$tpl_size = sizeof($tpl);
$cp_row = array();
$unset_tpl = array();
preg_match_all('#<!\-\- ia([0-9]+) \-\->(.*?)<!\-\- ia\1 \-\->#', $message, $matches);
$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][$index];
$replace['to'][] = (isset($tpl[$index])) ? $tpl[$index] : sprintf($user->lang['MISSING_INLINE_ATTACHMENT'], $matches[2][$num]);
$unset_tpl[] = $index;
}
unset($tpl, $tpl_size);
if (isset($replace['from']))
{
$message = str_replace($replace['from'], $replace['to'], $message);
foreach (array_unique($unset_tpl) as $index)
{
unset($attachments[$row['post_id']][$index]);
}
}
}
/* Dump vars into template
if ($config['load_cp_viewtopic'])
//
if ($config['load_cpf_viewtopic'])
{
$cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
}
*/
//
$postrow = array(
'POSTER_NAME' => $row['poster'],
'POSTER_RANK' => $user_cache[$poster_id]['rank_title'],
@ -1290,14 +1273,16 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
'S_FRIEND' => ($row['friend']) ? true : false,
'S_UNREAD' => ($user->data['user_id'] != ANONYMOUS && $row['post_time'] > $user->data['user_lastvisit'] && $row['post_time'] > $topic_last_read) ? true : false,
'S_FIRST_UNREAD' => ($unread_post_id == $row['post_id']) ? true : false
'S_FIRST_UNREAD' => ($unread_post_id == $row['post_id']) ? true : false,
'S_CUSTOM_FIELDS' => (sizeof($cp_row)) ? true : false
);
/* if (sizeof($cp_row))
if (sizeof($cp_row))
{
$postrow = array_merge($postrow, $cp_row);
}*/
}
// Dump vars into template
$template->assign_block_vars('postrow', $postrow);
// Display not already displayed Attachments for this post, we already parsed them. ;)