24 |
24 |
25 |
25 |
26 // Tell header.php to use the admin template |
26 // Tell header.php to use the admin template |
27 define('PUN_ADMIN_CONSOLE', 1); |
27 define('PUN_ADMIN_CONSOLE', 1); |
28 |
28 |
29 define('PUN_ROOT', './'); |
29 //define('PUN_ROOT', './'); |
30 require PUN_ROOT.'include/common.php'; |
30 //require PUN_ROOT.'include/common.php'; |
|
31 |
|
32 global $pun_db, $pun_user, $pun_config, $lang_common; |
|
33 |
31 require PUN_ROOT.'include/common_admin.php'; |
34 require PUN_ROOT.'include/common_admin.php'; |
32 |
35 |
33 |
36 |
34 if ($pun_user['g_id'] > PUN_MOD) |
37 if ($pun_user['g_id'] < PUN_MOD) |
35 message($lang_common['No permission']); |
38 message($lang_common['No permission']); |
36 |
39 |
37 |
40 |
38 // Add a censor word |
41 // Add a censor word |
39 if (isset($_POST['add_word'])) |
42 if (isset($_POST['add_word'])) |
44 $replace_with = trim($_POST['new_replace_with']); |
47 $replace_with = trim($_POST['new_replace_with']); |
45 |
48 |
46 if ($search_for == '' || $replace_with == '') |
49 if ($search_for == '' || $replace_with == '') |
47 message('You must enter both a word to censor and text to replace it with.'); |
50 message('You must enter both a word to censor and text to replace it with.'); |
48 |
51 |
49 $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()); |
52 $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()); |
50 |
53 |
51 redirect('admin_censoring.php', 'Censor word added. Redirecting …'); |
54 pun_redirect('admin_censoring.php', 'Censor word added. Redirecting …'); |
52 } |
55 } |
53 |
56 |
54 |
57 |
55 // Update a censor word |
58 // Update a censor word |
56 else if (isset($_POST['update'])) |
59 else if (isset($_POST['update'])) |
63 $replace_with = trim($_POST['replace_with'][$id]); |
66 $replace_with = trim($_POST['replace_with'][$id]); |
64 |
67 |
65 if ($search_for == '' || $replace_with == '') |
68 if ($search_for == '' || $replace_with == '') |
66 message('You must enter both text to search for and text to replace with.'); |
69 message('You must enter both text to search for and text to replace with.'); |
67 |
70 |
68 $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()); |
71 $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()); |
69 |
72 |
70 redirect('admin_censoring.php', 'Censor word updated. Redirecting …'); |
73 pun_redirect('admin_censoring.php', 'Censor word updated. Redirecting …'); |
71 } |
74 } |
72 |
75 |
73 |
76 |
74 // Remove a censor word |
77 // Remove a censor word |
75 else if (isset($_POST['remove'])) |
78 else if (isset($_POST['remove'])) |
76 { |
79 { |
77 confirm_referrer('admin_censoring.php'); |
80 confirm_referrer('admin_censoring.php'); |
78 |
81 |
79 $id = intval(key($_POST['remove'])); |
82 $id = intval(key($_POST['remove'])); |
80 |
83 |
81 $db->query('DELETE FROM '.$db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $db->error()); |
84 $pun_db->query('DELETE FROM '.$pun_db->prefix.'censoring WHERE id='.$id) or error('Unable to delete censor word', __FILE__, __LINE__, $pun_db->error()); |
82 |
85 |
83 redirect('admin_censoring.php', 'Censor word removed. Redirecting …'); |
86 pun_redirect('admin_censoring.php', 'Censor word removed. Redirecting …'); |
84 } |
87 } |
85 |
88 |
86 |
89 |
87 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Censoring'; |
90 $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Censoring'; |
88 $focus_element = array('censoring', 'new_search_for'); |
91 $focus_element = array('censoring', 'new_search_for'); |
123 <fieldset> |
126 <fieldset> |
124 <legend>Edit/remove words</legend> |
127 <legend>Edit/remove words</legend> |
125 <div class="infldset"> |
128 <div class="infldset"> |
126 <?php |
129 <?php |
127 |
130 |
128 $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()); |
131 $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()); |
129 if ($db->num_rows($result)) |
132 if ($pun_db->num_rows($result)) |
130 { |
133 { |
131 |
134 |
132 ?> |
135 ?> |
133 <table cellspacing="0" > |
136 <table cellspacing="0" > |
134 <thead> |
137 <thead> |