punbb/admin_censoring.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
child 3 c0c445d4a13e
--- a/punbb/admin_censoring.php	Wed Jul 11 21:28:39 2007 -0400
+++ b/punbb/admin_censoring.php	Thu Jul 12 01:04:01 2007 -0400
@@ -26,12 +26,15 @@
 // Tell header.php to use the admin template
 define('PUN_ADMIN_CONSOLE', 1);
 
-define('PUN_ROOT', './');
-require PUN_ROOT.'include/common.php';
+//define('PUN_ROOT', './');
+//require PUN_ROOT.'include/common.php';
+
+global $pun_db, $pun_user, $pun_config, $lang_common;
+
 require PUN_ROOT.'include/common_admin.php';
 
 
-if ($pun_user['g_id'] > PUN_MOD)
+if ($pun_user['g_id'] < PUN_MOD)
 	message($lang_common['No permission']);
 
 
@@ -46,9 +49,9 @@
 	if ($search_for == '' || $replace_with == '')
 		message('You must enter both a word to censor and text to replace it with.');
 
-	$db->query('INSERT INTO '.$db->prefix.'censoring (search_for, replace_with) VALUES (\''.$db->escape($search_for).'\', \''.$db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $db->error());
+	$pun_db->query('INSERT INTO '.$pun_db->prefix.'censoring (search_for, replace_with) VALUES (\''.$pun_db->escape($search_for).'\', \''.$pun_db->escape($replace_with).'\')') or error('Unable to add censor word', __FILE__, __LINE__, $pun_db->error());
 
-	redirect('admin_censoring.php', 'Censor word added. Redirecting &hellip;');
+	pun_redirect('admin_censoring.php', 'Censor word added. Redirecting &hellip;');
 }
 
 
@@ -65,9 +68,9 @@
 	if ($search_for == '' || $replace_with == '')
 		message('You must enter both text to search for and text to replace with.');
 
-	$db->query('UPDATE '.$db->prefix.'censoring SET search_for=\''.$db->escape($search_for).'\', replace_with=\''.$db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $db->error());
+	$pun_db->query('UPDATE '.$pun_db->prefix.'censoring SET search_for=\''.$pun_db->escape($search_for).'\', replace_with=\''.$pun_db->escape($replace_with).'\' WHERE id='.$id) or error('Unable to update censor word', __FILE__, __LINE__, $pun_db->error());
 
-	redirect('admin_censoring.php', 'Censor word updated. Redirecting &hellip;');
+	pun_redirect('admin_censoring.php', 'Censor word updated. Redirecting &hellip;');
 }
 
 
@@ -78,9 +81,9 @@
 
 	$id = intval(key($_POST['remove']));
 
-	$db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error());
+	$pun_db->query('DELETE FROM '.$pun_db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $pun_db->error());
 
-	redirect('admin_censoring.php', 'Censor word removed. Redirecting &hellip;');
+	pun_redirect('admin_censoring.php', 'Censor word removed. Redirecting &hellip;');
 }
 
 
@@ -125,8 +128,8 @@
 						<div class="infldset">
 <?php
 
-$result = $db->query('SELECT id, search_for, replace_with FROM '.$db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $db->error());
-if ($db->num_rows($result))
+$result = $pun_db->query('SELECT id, search_for, replace_with FROM '.$pun_db->prefix.'censoring ORDER BY id') or error('Unable to fetch censor word list', __FILE__, __LINE__, $pun_db->error());
+if ($pun_db->num_rows($result))
 {
 
 ?>
@@ -141,7 +144,7 @@
 							<tbody>
 <?php
 
-	while ($cur_word = $db->fetch_assoc($result))
+	while ($cur_word = $pun_db->fetch_assoc($result))
 		echo "\t\t\t\t\t\t\t\t".'<tr><td><input type="text" name="search_for['.$cur_word['id'].']" value="'.pun_htmlspecialchars($cur_word['search_for']).'" size="24" maxlength="60" /></td><td><input type="text" name="replace_with['.$cur_word['id'].']" value="'.pun_htmlspecialchars($cur_word['replace_with']).'" size="24" maxlength="60" /></td><td><input type="submit" name="update['.$cur_word['id'].']" value="Update" />&nbsp;<input type="submit" name="remove['.$cur_word['id'].']" value="Remove" /></td></tr>'."\n";
 
 ?>