More case changing, hard coding of HTML, etc.

git-svn-id: file:///svn/phpbb/trunk@3391 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-01-28 20:21:34 +00:00
parent f522f21240
commit 69eb24394a
3 changed files with 133 additions and 134 deletions

View file

@ -319,7 +319,6 @@ function update_image_dimensions()
SET ' . $db->sql_build_array('UPDATE', $img_sql) . " SET ' . $db->sql_build_array('UPDATE', $img_sql) . "
WHERE " . $fields . "_id = $image_id"); WHERE " . $fields . "_id = $image_id");
$cache->destroy('icons'); $cache->destroy('icons');
$cache->put('icons');
trigger_error($user->lang[$lang . '_EDITED']); trigger_error($user->lang[$lang . '_EDITED']);
} }
@ -327,7 +326,6 @@ function update_image_dimensions()
{ {
$db->sql_query('INSERT INTO ' . $table . ' ' . $db->sql_build_array('INSERT', $img_sql)); $db->sql_query('INSERT INTO ' . $table . ' ' . $db->sql_build_array('INSERT', $img_sql));
$cache->destroy('icons'); $cache->destroy('icons');
$cache->put('icons');
trigger_error($user->lang[$lang . '_ADDED']); trigger_error($user->lang[$lang . '_ADDED']);
} }

View file

@ -44,9 +44,7 @@ if (!$auth->acl_get('a_prune'))
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
//
// Get the forum ID for pruning // Get the forum ID for pruning
//
if (isset($_REQUEST['f'])) if (isset($_REQUEST['f']))
{ {
$forum_id = intval($_REQUEST['f']); $forum_id = intval($_REQUEST['f']);
@ -57,24 +55,9 @@ else
$forum_id = ''; $forum_id = '';
$forum_sql = ''; $forum_sql = '';
} }
//
// Get a list of forum's or the data for the forum that we are pruning.
//
$sql = "SELECT forum_id, forum_name, left_id, right_id
FROM " . FORUMS_TABLE . "
ORDER BY left_id ASC";
$result = $db->sql_query($sql);
$forum_rows = array();
while($row = $db->sql_fetchrow($result))
{
$forum_rows[] = $row;
}
$db->sql_freeresult($result);
//
// Check for submit to be equal to Prune. If so then proceed with the pruning. // Check for submit to be equal to Prune. If so then proceed with the pruning.
//
if (isset($_POST['doprune'])) if (isset($_POST['doprune']))
{ {
$prunedays = (isset($_POST['prunedays'])) ? intval($_POST['prunedays']) : 0; $prunedays = (isset($_POST['prunedays'])) ? intval($_POST['prunedays']) : 0;
@ -82,84 +65,102 @@ if (isset($_POST['doprune']))
// Convert days to seconds for timestamp functions... // Convert days to seconds for timestamp functions...
$prunedate = time() - ($prunedays * 86400); $prunedate = time() - ($prunedays * 86400);
$template->set_filenames(array( page_header($user->lang['PRUNE']);
'body' => 'admin/forum_prune_result_body.tpl')
);
?>
<h1><?php echo $user->lang['PRUNE']; ?></h1>
<p><?php echo $user->lang['PRUNE_SUCCESS']; ?></p>
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang['FORUM']; ?></th>
<th><?php echo $user->lang['TOPICS_PRUNED']; ?></th>
<th><?php echo $user->lang['POSTS_PRUNED']; ?></th>
</tr>
<?php
// Get a list of forum's or the data for the forum that we are pruning.
$sql = "SELECT forum_id, forum_name
FROM " . FORUMS_TABLE . "
ORDER BY left_id ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$log_data = ''; $log_data = '';
for($i = 0; $i < count($forum_rows); $i++) do
{ {
$p_result = prune($forum_rows[$i]['forum_id'], $prunedate); $p_result = prune($forum_rows[$i]['forum_id'], $prunedate);
sync('forum', $forum_rows[$i]['forum_id']); sync('forum', $forum_rows[$i]['forum_id']);
$template->assign_block_vars('prune_results', array( $row_class = ($row_class == 'row1') ? 'row2' : 'row1';
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class, ?>
'FORUM_NAME' => $forum_rows[$i]['forum_name'], <tr>
'FORUM_TOPICS' => $p_result['topics'], <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['forum_name']; ?></td>
'FORUM_POSTS' => $p_result['posts']) <td class="<?php echo $row_class; ?>" align="center"><?php echo $p_result['topics']; ?></td>
); <td class="<?php echo $row_class; ?>" align="center"><?php echo $p_result['posts']; ?></td>
</tr>
<?php
$log_data .= (($log_data != '') ? ', ' : '') . $forum_rows[$i]['forum_name']; $log_data .= (($log_data != '') ? ', ' : '') . $forum_rows[$i]['forum_name'];
} }
while($row = $db->sql_fetchrow($result));
$template->assign_vars(array(
'L_FORUM_PRUNE' => $user->lang['Forum_Prune'],
'L_FORUM' => $user->lang['Forum'],
'L_TOPICS_PRUNED' => $user->lang['Topics_pruned'],
'L_POSTS_PRUNED' => $user->lang['Posts_pruned'],
'L_PRUNE_RESULT' => $user->lang['Prune_success'])
);
add_admin_log('log_prune', $log_data); add_admin_log('log_prune', $log_data);
} }
else else
{ {
page_header($user->lang['Prune']);
// ?>
// If they haven't selected a forum for pruning yet then <tr>
// display a select box to use for pruning. <td class="row1" align="center"><?php echo $user->lang['NO_PRUNE']; ?></td>
// </tr>
if (empty($forum_id)) <?php
{
//
// Output a selection table if no forum id has been specified.
//
$select_list = '<option value="-1">' . $user->lang['All_Forums'] . '</option>';
$right = 0;
$subforum = '';
$forum_list = '';
foreach ($forum_rows as $row)
{
if ($row['left_id'] < $right )
{
$subforum .= '&nbsp;&nbsp;&nbsp;';
} }
else if ($row['left_id'] > $right + 1) $db->sql_freeresult($result);
{
$subforum = substr($subforum, 0, -18 * ($row['left_id'] - $right + 1)); ?>
</table>
<br clear="all" />
<?php
page_footer();
} }
$select_list .= '<option value="' . $row['forum_id'] . '">' . $subforum . $row['forum_name'] . '</option>'; page_header($user->lang['PRUNE']);
$right = $row['right_id'];
}
?> ?>
<h1><?php echo $user->lang['Prune']; ?></h1> <h1><?php echo $user->lang['PRUNE']; ?></h1>
<p><?php echo $user->lang['Forum_Prune_explain']; ?></p> <p><?php echo $user->lang['FORUM_PRUNE_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <?php
// If they haven't selected a forum for pruning yet then
// display a select box to use for pruning.
if (empty($forum_id))
{
// Output a selection table if no forum id has been specified.
$select_list = '<option value="-1">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select(false, false, false);
?>
<form method="post" action="admin_prune.<?php echo $phpEx . $SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th align="center"><?php echo $user->lang['Select_a_Forum']; ?></th> <th align="center"><?php echo $user->lang['SELECT_FORUM']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1" align="center"><?php echo $s_hidden_fields; ?>&nbsp;<select name="f"><?php echo $select_list; ?></select>&nbsp;&nbsp;<input type="submit" value="<?php echo $user->lang['Look_up_Forum']; ?>" class="mainoption" />&nbsp;</td> <td class="row1" align="center">&nbsp;<select name="f"><?php echo $select_list; ?></select>&nbsp;&nbsp;<input type="submit" value="<?php echo $user->lang['LOOK_UP_FORUM']; ?>" class="mainoption" />&nbsp;</td>
</tr> </tr>
</table></form> </table></form>
@ -168,37 +169,35 @@ else
} }
else else
{ {
$forum_name = ($forum_id == -1) ? $user->lang['All_Forums'] : $forum_rows[0]['forum_name']; $sql = "SELECT forum_name
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
$result = $db->sql_query($sql);
$prune_data = $user->lang['Prune_topics_not_posted'] . " "; $row = $db->sql_fetchrow($result);
$prune_data .= '<input type="text" name="prunedays" size="4"> ' . $user->lang['Days']; $db->sql_freeresult($result);
$s_hidden_fields = '<input type="hidden" name="f" value="' . $forum_id . '">'; $forum_name = ($forum_id == -1) ? $user->lang['ALL_FORUMS'] : $row['forum_name'];
?> ?>
<h1><?php echo $user->lang['Prune']; ?></h1> <h2><?php echo $user->lang['FORUM'] . ': <i>' . $forum_name; ?></i></h2>
<p><?php echo $user->lang['Forum_Prune_explain']; ?></p> <form method="post" action="admin_prune.<?php echo $phpEx . $SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<h2><?php echo $user->lang['Forum'] . ': ' . $forum_name; ?></h2>
<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th class="th"><?php echo $user->lang['Forum_Prune']; ?></th> <th class="th"><?php echo $user->lang['FORUM_PRUNE']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $prune_data; ?></td> <td class="row1"><?php echo sprintf($user->lang['PRUNE_NOT_POSTED'], '<input type="text" name="prunedays" size="4" />'); ?></td>
</tr> </tr>
<tr> <tr>
<td class="cat" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="doprune" value="<?php echo $user->lang['Do_Prune']; ?>" class="mainoption"></td> <td class="cat" align="center"><input type="hidden" name="f" value="<?php echo $forum_id; ?>" /><input type="submit" name="doprune" value="<?php echo $user->lang['DO_PRUNE']; ?>" class="mainoption"></td>
</tr> </tr>
</table></form> </table></form>
<?php <?php
} }
}
page_footer(); page_footer();

View file

@ -78,7 +78,7 @@ if ($mode != '')
{ {
if (!$word_id) if (!$word_id)
{ {
trigger_error($user->lang['No_word_selected']); trigger_error($user->lang['NO_WORD']);
} }
$sql = "SELECT * $sql = "SELECT *
@ -87,27 +87,29 @@ if ($mode != '')
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$word_info = $db->sql_fetchrow($result); $word_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />'; $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
} }
page_header($user->lang['Words_title']); page_header($user->lang['WORDS_TITLE']);
?> ?>
<h1><?php echo $user->lang['Words_title']; ?></h1> <h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
<p><?php echo $user->lang['Words_explain']; ?></p> <p><?php echo $user->lang['WORDS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th colspan="2"><?php echo $user->lang['Edit_word_censor']; ?></th> <th colspan="2"><?php echo $user->lang['EDIT_WORD']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['Word']; ?></td> <td class="row1"><?php echo $user->lang['WORD']; ?></td>
<td class="row2"><input type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td> <td class="row2"><input type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['Replacement']; ?></td> <td class="row1"><?php echo $user->lang['REPLACEMENT']; ?></td>
<td class="row2"><input type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td> <td class="row2"><input type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td>
</tr> </tr>
<tr> <tr>
@ -127,17 +129,18 @@ if ($mode != '')
if ($word == '' || $replacement == '') if ($word == '' || $replacement == '')
{ {
trigger_error($user->lang['Must_enter_word']); trigger_error($user->lang['ENTER_WORD']);
} }
$sql = ($word_id) ? "UPDATE " . WORDS_TABLE . " SET word = '" . sql_quote($word) . "', replacement = '" . sql_quote($replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . sql_quote($word) . "', '" . sql_quote($replacement) . "')"; $sql = ($word_id) ? "UPDATE " . WORDS_TABLE . " SET word = '" . $db->sql_escape($word) . "', replacement = '" . $db->sql_escape($replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . $db->sql_escape($word) . "', '" . $db->sql_escape($replacement) . "')";
$db->sql_query($sql); $db->sql_query($sql);
$cache->destroy('word_censors'); $cache->destroy('word_censors');
$log_action = ($word_id) ? 'log_edit_word' : 'log_add_word'; $log_action = ($word_id) ? 'log_edit_word' : 'log_add_word';
add_admin_log($log_action, stripslashes($word)); add_admin_log($log_action, stripslashes($word));
$message = ($word_id) ? $user->lang['Word_updated'] : $user->lang['Word_added']; $message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED'];
break; break;
case 'delete': case 'delete':
@ -148,17 +151,18 @@ if ($mode != '')
} }
else else
{ {
trigger_error($user->lang['Must_specify_word']); trigger_error($user->lang['NO_WORD']);
} }
$sql = "DELETE FROM " . WORDS_TABLE . " $sql = "DELETE FROM " . WORDS_TABLE . "
WHERE word_id = $word_id"; WHERE word_id = $word_id";
$db->sql_query($sql); $db->sql_query($sql);
$cache->destroy('word_censors'); $cache->destroy('word_censors');
add_admin_log('log_delete_word'); add_admin_log('log_delete_word');
$message = $user->lang['Word_remove']; $message = $user->lang['WORD_REMOVE'];
break; break;
} }
@ -168,41 +172,39 @@ if ($mode != '')
ORDER BY word"; ORDER BY word";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$cache_str = "\$word_censors = array(\n";
$cache_str_match = $cache_str_replace = '';
if ($row = $db->sql_fetchrow($result)) if ($row = $db->sql_fetchrow($result))
{ {
$censors = array();
do do
{ {
$cache_str_match .= "\t\t'" . addslashes('#\b' . str_replace('\*', '.*?', preg_quote($row['word'], '#')) . '\b#i') . "',\n"; $censors['match'][] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
$cache_str_replace .= "\t\t'" . addslashes($row['replacement']) . "',\n"; $censors['replace'][] = $row['replacement'];
} }
while ($row = $db->sql_fetchrow($result)); while ($row = $db->sql_fetchrow($result));
$cache_str .= "\t'match' => array(\n$cache_str_match\t),\n\t'replace' => array(\n$cache_str_replace\t)\n);"; $cache->put('word_censors', $censors);
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
config_cache_write('\$word_censors = array\(.*?\);', $cache_str);
trigger_error($message); trigger_error($message);
} }
else else
{ {
page_header($user->lang['Words_title']); page_header($user->lang['WORDS_TITLE']);
?> ?>
<h1><?php echo $user->lang['Words_title']; ?></h1> <h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
<p><?php echo $user->lang['Words_explain']; ?></p> <p><?php echo $user->lang['WORDS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center"> <form method="post" action="admin_words.<?php echo $phpEx . $SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr> <tr>
<th><?php echo $user->lang['Word']; ?></th> <th><?php echo $user->lang['WORD']; ?></th>
<th><?php echo $user->lang['Replacement']; ?></th> <th><?php echo $user->lang['REPLACEMENT']; ?></th>
<th colspan="2"><?php echo $user->lang['Action']; ?></th> <th colspan="2"><?php echo $user->lang['ACTION']; ?></th>
</tr> </tr>
<?php <?php
@ -222,7 +224,7 @@ else
<tr> <tr>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['word']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['word']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['replacement']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['replacement']; ?></td>
<td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=edit&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['Edit']; ?></a>&nbsp;</td> <td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=edit&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['EDIT']; ?></a>&nbsp;</td>
<td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=delete&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['DELETE']; ?></a>&nbsp;</td> <td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=delete&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['DELETE']; ?></a>&nbsp;</td>
</tr> </tr>
<?php <?php
@ -234,7 +236,7 @@ else
?> ?>
<tr> <tr>
<td class="cat" colspan="5" height="28" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="add" value="<?php echo $user->lang['Add_new_word']; ?>" /></td> <td class="cat" colspan="5" height="28" align="center"><?php echo $s_hidden_fields; ?><input class="mainoption" type="submit" name="add" value="<?php echo $user->lang['ADD_WORD']; ?>" /></td>
</tr> </tr>
</table></form> </table></form>