K I would like if one of the PHP Gurus could have a look-see at this please:
Similar to badword or badnames, I wish to run 'bad subjects'. On
www.UtterAccess.com as with most any forum especially now that we've all found ways to get the pages read by the engines, a decent subject line is very helpful both to the forum users, and to improve the words which the engines pick up (the subject does become the page title).
Taken almost verbatim from some lines in addpost.php, and after creating a file in filters similar to badnames, I've come up with this:
//Subject
$badsubject = @file("{$config['path']}/filters/badsubject");
if (!is_array($badsubject)) {$badsubject = @file("{$config['phpurl']}/filters/badsubject");}
while (list($linenum,$line) = each($badsubject)) {
if (preg_match("/^#/",$line)) {continue;}
chop ($line);
if (strstr(strtolower($Subject),strtolower($line))) {$html -> not_right($ubbt_lang['BAD_SUBJECT'],$Cat);}
}
//Subject end
The code runs in addpost.php just after:
$Subject = rtrim($Subject);
if ( (preg_match("/^\s*$/",$Subject)) || ($Body == "") || ($Body == " ") || ($Body == " ") || ($postername == "") ) {
$html -> not_right($ubbt_lang['ALL_FIELDS'],$Cat);
}
The touch-ups to the admin panel to access this badsubject file are a piece of cake (add a line to the admin/menu.php) like:
<a href="{$config['phpurl']}/admin/editfilters.php?Cat=$Cat&filter=badsubject" target="mainFrame">Edit bad Subjects</a><br />
(spiffy that up with a language entry if you don't want the hard-coded "Edit bad Subjects"...if you so choose...)
in admin/editfilters.php, add:
elseif ($filter == "badsubject") {
echo "Edit bad Subjects. ";
}
just after:
elseif ($filter == "badwords") {
echo "{$ubbt_lang['BADWORDS']}";
}
The language/addpost.php gets an entry like:
$ubbt_lang['BAD_SUBJECT'] = "Please correct your subject line. Include words which pertain to your question or response. Do not include phrases such as "Please Help", which will not assist anyone in finding or understanding your post. Thank you.";
I have entries in badsubject (line by line) like: Please Help, Need Help, Help Me ... and so on.
The code works and will return the listed "bad subject response", but
only on the last 'bad subject'.
What am I missing to get out of the 'While' once the first instance is found? As this is virtually a mirror of BadNames, (which is not used at UA as it's a registration only forum), is BadNames ok - for those who do run with anonymous users?
Thanks,
Gord