1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 00:37:42 +02:00

- put consoring and smilie processing into functions (we use them all over the place) for better changing and consistency.

- changed docs/AUTHORS to reflect the recent code re-use in functions_messenger.php
- pleasing the users a little bit more by using table constants. :D
- login box if "mode" is not allowed -> posting (thought about trigger_error integration, but we do not need this that often).


git-svn-id: file:///svn/phpbb/trunk@4836 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2004-02-21 12:47:35 +00:00
parent 9c12fe83db
commit c74d2538ec
26 changed files with 211 additions and 254 deletions

View File

@@ -125,7 +125,7 @@ $cp = new custom_profile_admin();
// Based on this, we decide which elements need to be edited later and which language items are missing
$lang_ids = $lang_entry = $lang_diff = array();
$result = $db->sql_query('SELECT lang_id FROM phpbb_lang');
$result = $db->sql_query('SELECT lang_id FROM ' . LANG_TABLE);
while ($row = $db->sql_fetchrow($result))
{
@@ -592,7 +592,7 @@ if ($mode == 'delete')
$db->sql_query('DELETE FROM phpbb_profile_fields WHERE field_id = ' . $field_id);
$db->sql_query('DELETE FROM phpbb_profile_fields_lang WHERE field_id = ' . $field_id);
$db->sql_query('DELETE FROM phpbb_profile_lang WHERE field_id = ' . $field_id);
$db->sql_query('ALTER TABLE phpbb_profile_fields_data DROP ' . $field_ident);
$db->sql_query('ALTER TABLE ' . CUSTOM_PROFILE_DATA . ' DROP ' . $field_ident);
$order = 0;
@@ -633,7 +633,10 @@ if ($mode == 'activate')
trigger_error('INVALID_MODE');
}
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
WHERE lang_iso = '{$config['default_lang']}'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result);
@@ -754,7 +757,9 @@ function build_language_options($field_type, $mode = 'new')
{
global $user, $config, $db, $cp;
$sql = 'SELECT lang_id, lang_iso FROM phpbb_lang' . (($mode == 'new') ? " WHERE lang_iso <> '" . $config['default_lang'] . "'" : '');
$sql = 'SELECT lang_id, lang_iso
FROM ' . LANG_TABLE .
(($mode == 'new') ? " WHERE lang_iso <> '" . $config['default_lang'] . "'" : '');
$result = $db->sql_query($sql);
$languages = array();
@@ -858,7 +863,10 @@ function save_profile_field($field_type, $field_ident)
// Collect all informations, if something is going wrong, abort the operation
$profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'");
$sql = 'SELECT lang_id
FROM ' . LANG_TABLE . '
WHERE lang_iso = '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result);
@@ -888,7 +896,7 @@ function save_profile_field($field_type, $field_ident)
$field_id = $db->sql_nextid();
$sql = "ALTER TABLE phpbb_profile_fields_data ADD $field_ident ";
$sql = 'ALTER TABLE ' . CUSTOM_PROFILE_DATA . " ADD $field_ident ";
switch ($field_type)
{
case FIELD_STRING:

View File

@@ -614,7 +614,7 @@ if ($submit || $preview || $deleteall || $deletemark)
// Update Custom Fields
if (sizeof($cp_data))
{
$sql = 'UPDATE phpbb_profile_fields_data
$sql = 'UPDATE ' . CUSTOM_PROFILE_DATA . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . "
WHERE user_id = $user_id";
$db->sql_query($sql);
@@ -1557,15 +1557,15 @@ function marklist(match, status)
// If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here
$signature_preview = (empty($enable_smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature_preview) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature_preview);
$signature_preview = smilie_text($signature_preview, !$enable_smilies);
// Replace naughty words such as farty pants
if (sizeof($censors))
/* if (sizeof($censors))
{
$signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1));
}
}*/
$signature_preview = str_replace("\n", '<br />', $signature_preview);
$signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
}
decode_text($user_sig, $user_sig_bbcode_uid);

View File

@@ -1,23 +1,15 @@
<?php
/***************************************************************************
* admin_words.php
* -------------------
* begin : Thursday, Jul 12, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
// -------------------------------------------------------------
//
// $Id$
//
// FILENAME : admin_words.php
// STARTED : Thu Jul 12, 2001
// COPYRIGHT : <20> 2001, 2003 phpBB Group
// WWW : http://www.phpbb.com/
// LICENCE : GPL vs2.0 [ see /docs/COPYING ]
//
// -------------------------------------------------------------
if (!empty($setmodules))
{
@@ -32,7 +24,7 @@ if (!empty($setmodules))
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
@@ -42,57 +34,35 @@ if (!$auth->acl_get('a_words'))
trigger_error($user->lang['NO_ADMIN']);
}
// What do we want to do?
if (isset($_REQUEST['mode']))
$mode = request_var('mode', '');
$mode = (isset($_POST['add'])) ? 'add' : ((isset($_POST['save'])) ? 'save' : $mode);
$s_hidden_fields = '';
$word_info = array();
switch ($mode)
{
$mode = $_REQUEST['mode'];
}
else
{
// These could be entered via a form button
if (isset($_POST['add']))
{
$mode = 'add';
}
else if (isset($_POST['save']))
{
$mode = 'save';
}
else
{
$mode = '';
}
}
case 'edit':
$word_id = request_var('id', 0);
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
if ($mode != '')
{
switch ($mode)
{
case 'edit':
case 'add':
$word_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$sql = 'SELECT *
FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id";
$result = $db->sql_query_limit($sql, 1);
$s_hidden_fields = '';
if ($mode == 'edit')
{
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
$word_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$sql = "SELECT *
FROM " . WORDS_TABLE . "
WHERE word_id = $word_id";
$result = $db->sql_query($sql);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
$word_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
}
adm_page_header($user->lang['WORDS_TITLE']);
case 'add':
adm_page_header($user->lang['WORDS_TITLE']);
?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
@@ -104,11 +74,11 @@ if ($mode != '')
<th colspan="2"><?php echo $user->lang['EDIT_WORD']; ?></th>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['WORD']; ?></td>
<td class="row1"><b><?php echo $user->lang['WORD']; ?></b>:</td>
<td class="row2"><input class="post" type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['REPLACEMENT']; ?></td>
<td class="row1"><b><?php echo $user->lang['REPLACEMENT']; ?></b>:</td>
<td class="row2"><input class="post" type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td>
</tr>
<tr>
@@ -122,11 +92,11 @@ if ($mode != '')
break;
case 'save':
$word_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0;
$word = (isset($_POST['word'])) ? trim($_POST['word']) : '';
$replacement = (isset($_POST['replacement'])) ? trim($_POST['replacement']) : '';
$word_id = request_var('id', 0);
$word = request_var('word', '');
$replacement = request_var('replacement', '');
if ($word == '' || $replacement == '')
if (!$word || !$replacement)
{
trigger_error($user->lang['ENTER_WORD']);
}
@@ -140,20 +110,19 @@ if ($mode != '')
add_log('admin', $log_action, stripslashes($word));
$message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED'];
trigger_error($message);
break;
case 'delete':
if (isset($_POST['id']) || isset($_GET['id']))
{
$word_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']);
}
else
$word_id = request_var('id', 0);
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
$sql = "DELETE FROM " . WORDS_TABLE . "
$sql = 'DELETE FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id";
$db->sql_query($sql);
@@ -162,18 +131,13 @@ if ($mode != '')
add_log('admin', 'log_delete_word');
$message = $user->lang['WORD_REMOVE'];
trigger_error($message);
break;
}
trigger_error($message);
}
else
{
adm_page_header($user->lang['WORDS_TITLE']);
default:
adm_page_header($user->lang['WORDS_TITLE']);
?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
@@ -189,16 +153,16 @@ else
<?php
$sql = "SELECT *
FROM " . WORDS_TABLE . "
ORDER BY word";
$result = $db->sql_query($sql);
$sql = 'SELECT *
FROM ' . WORDS_TABLE . '
ORDER BY word';
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
if ($row = $db->sql_fetchrow($result))
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
do
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
@@ -209,10 +173,10 @@ else
</tr>
<?php
}
while ($row = $db->sql_fetchrow($result));
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$db->sql_freeresult($result);
?>
<tr>
@@ -222,8 +186,8 @@ else
<?php
adm_page_footer();
adm_page_footer();
break;
}
?>