Previous Thread
Next Thread
Print Thread
Rate Thread
#262638 11/12/2003 11:52 AM
Joined: Apr 2001
Posts: 45
Power User
Power User
Offline
Joined: Apr 2001
Posts: 45
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

Sponsored Links
med2004 #262639 11/13/2003 1:54 PM
Joined: Apr 2001
Posts: 45
Power User
Power User
Offline
Joined: Apr 2001
Posts: 45
anyone?

med2004 #262640 11/13/2003 11:13 PM
Joined: Apr 2001
Posts: 45
Power User
Power User
Offline
Joined: Apr 2001
Posts: 45
The solution can be found right here.

Josh, Allen, perhaps you'd like to wrap this up as a nice hack to compliment the search engine work?

Enjoy,

Gord Hubbell
Webmaster, www.UtterAccess.com

med2004 #262641 11/20/2003 1:13 PM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
I added a tweak to this which allows spaces to be completely ignored when comparing a badsubject string with the actual subject string.

It's pretty useful for preventing swearing in the subject line when a poster tries to add his own random spaces in order to fool the system

ORIGINAL:

//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

TWEAK:

//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;}
$line = chop ($line);
if (strstr(strtolower(trim(eregi_replace(' ', '', $Subject))),strtolower($line))) {$html -> not_right($ubbt_lang['BAD_SUBJECT'],$Cat);}
}
//Subject end

smoknz28 #262642 11/20/2003 1:47 PM
Joined: Apr 2001
Posts: 45
Power User
Power User
Offline
Joined: Apr 2001
Posts: 45
Awesome! Even better as it's now able to do 'double duty' []http://www.utteraccess.com/forums/images/graemlins/cheers.gif[/]

Thanks very much,

Gord []http://www.utteraccess.com/forums/images/graemlins/thumbup.gif[/]
Webmaster, www.UtterAccess.com

Sponsored Links
med2004 #262643 11/20/2003 2:20 PM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Well thanks for the mod, I installed it on my board earlier on today. The regs are freaking out over how strict it is lol

med2004 #262644 11/20/2003 2:42 PM
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Btw Gord, I forget to mention...the exact same changes made to addpost.php & language/addpost.php also need to be included in modifypost.php and language/modifypost.php.

Or else a person could do a clean subject, then go back and edit in a badsubject

smoknz28 #262645 11/20/2003 3:05 PM
Joined: Apr 2001
Posts: 45
Power User
Power User
Offline
Joined: Apr 2001
Posts: 45
Great - thanks again. I'll see those get wrapped up too. Keeps everything all tidy like!

Cheers!

Gord


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)