[PHP] Forum Spam Check D:

Shadow121

Member
Messages
901
Reaction score
0
Points
16
Alright so heres my code:
PHP:
if (!$_POST['quickreply']) {
                                        $Functions->blockopen("Quick Reply", "form", site_link . "/forum/topic/$id/");
                                        print "<strong>Content</strong><br /.
                                    <textarea cols=\"5\" rows=\"25\" name=\"msg\"></textarea><br />
                                    <input type=\"submit\" name=\"quickreply\" value=\"Reply!\" class=\"button\" />";
                                        $Functions->blockclose("form");
                                    } else {
                                        $msg = strip_tags(addslashes($_POST['msg']), "<b><u><i><p><em><ol><ul>");
                                        $date = $datelol;
                                        if (empty($msg)) {
                                            $Functions->Errorz("You Must Enter a Message");
                                        } else {
                                            $get_forum_flood = $MySql->sqlQuery("SELECT * FROM `" . DB_PREFIX .
                                                "forum_flood` WHERE `username` = '$logged->username';");
                                            $arrflood = $MySql->fetchArray($get_forum_flood);
                                            $forumfloodmath = ($settings->forumfloodtime * 60);
                                            $forumfloodtime = ($currentonline + $forumfloodmath);
                                            print $forumfloodtime;
                                            if ($MySql->numRows($get_forum_flood) == 0) {
                                                $insert_reply = $MySql->sqlQuery("INSERT INTO `" . DB_PREFIX .
                                                    "forum_replies` (`author`,`content`,`postdate`,`tid`,`fid`) VALUES ('$logged->username','$msg','$date','$topicData->id','$topicData->fid');");
                                                $getNewestPost = $MySql->sqlQuery("SELECT *FROM `" . DB_PREFIX .
                                                    "forum_replies` WHERE `fid` = '$id' ORDER BY `id` DESC LIMIT 1;");
                                                $newarray = $MySql->fetchArray($getNewestPost);
                                                $update_forum = $MySql->sqlQuery("UPDATE `" . DB_PREFIX .
                                                    "forum_forums` SET `latest_id` = '$newarray->tid', `latest_author` = '$newarray->author', `latest_isstaff` = '$topicData->staffonly' WHERE `id` = '$newarray->fid';");
                                                $insert_flood = $MySql->sqlQuery("INSERT INTO `" . DB_PREFIX .
                                                    "forum_flood` (`ip`,`username`,`time`) VALUES ('$ip','$logged->username','$forumfloodtime');");                                                print "<h1>Reply Added</h1>
                            <p>
                            Your Reply Has Been Added.
                            </p>";
                                                require ("FileLibrary/footer.php");
                                                $Functions->redirect(site_link . "/forum/topic/$id/", 2);
                                            } else {
                                                if ($arrflood->time <= $currentonline) {
                                                    $insert_reply = $MySql->sqlQuery("INSERT INTO `" . DB_PREFIX .
                                                        "forum_replies` (`author`,`content`,`postdate`,`tid`,`fid`) VALUES ('$logged->username','$msg','$date','$topicData->id','$topicData->fid');");
                                                    $getNewestPost = $MySql->sqlQuery("SELECT *FROM `" . DB_PREFIX .
                                                        "forum_replies` WHERE `fid` = '$id' ORDER BY `id` DESC LIMIT 1;");
                                                    $newarray = $MySql->fetchArray($getNewestPost);
                                                    $getNewestPost = $MySql->sqlQuery("SELECT *FROM `" . DB_PREFIX .
                                                        "forum_replies` WHERE `fid` = '$id' ORDER BY `id` DESC LIMIT 1;");
                                                    $newarray = $MySql->fetchArray($getNewestPost);
                                                    $update_forum = $MySql->sqlQuery("UPDATE `" . DB_PREFIX .
                                                        "forum_forums` SET `latest_id` = '$newarray->tid', `latest_author` = '$newarray->author', `latest_isstaff` = '$topicData->staffonly' WHERE `id` = '$newarray->fid';");
                                                    $update_flood = $MySql->sqlQuery("UPDATE `" . DB_PREFIX .
                                                        "forum_flood` SET `time` = '$forumfloodtime' WHERE `ip` = '$ip';");
                                                    print "<h1>Reply Added</h1>
                            <p>
                            Your Reply Has Been Added.
                            </p>";
                                                    require ("FileLibrary/footer.php");
                                                    $Functions->redirect(site_link . "/forum/topic/$id/", 2);
                                                } else {
                                                    $Functions->Errorz("You Must Wait $settings->forumfloodtime Minutes Before Posting Again");
                                                }
                                            }
                                        }
                                    }

All my variables are right, other spam checkers work. This is the only one that gives me errors.
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
I'm not too sure about what the problem is. But I did notice a few things. For one, you've got a typo in your <br /> here:

print "<strong>Content</strong><br /.

Second, why do you call it fetchArray() and store the return value in variables with names like $arrflood or $newarray when the return value is an object not an array? Not really an error, I'm just saying that's a little confusing.

And lastly, you repeat code here:

PHP:
$getNewestPost = $MySql->sqlQuery("SELECT *FROM `" . DB_PREFIX .
"forum_replies` WHERE `fid` = '$id' ORDER BY `id` DESC LIMIT 1;");
$newarray = $MySql->fetchArray($getNewestPost);
$getNewestPost = $MySql->sqlQuery("SELECT *FROM `" . DB_PREFIX .
"forum_replies` WHERE `fid` = '$id' ORDER BY `id` DESC LIMIT 1;");
$newarray = $MySql->fetchArray($getNewestPost);

But as for what's causing the code to not function properly, I'm not entirely sure. It would help if you could narrow down where the problem is occurring. Is the wrong flood time getting insterted/updated when a post is made? Does $MySql->numRows($get_forum_flood) always return 0? Is $arrflood->time or $currentonline incorrect?
 
Top