Topic: terminate the query when html is found (Read 876 times)
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« on: Feb 15, 2007, 06:29:13 pm »
have played with this alot lately trying to modify it so that if html or bbcode, or some type of other malicious code is found in a submitted description, then it will terminate the submission and reject it automatically, have tried a few different ways and it ends up terminating all submissions regardless of if the description has any html in it.. any ideas?
Code:
<?php function suggestsite($topicid, $title, $url, $description, $email = ""){ global $db, $dbprefix, $config, $phrase; $topicid = intval($topicid); if ($title == ""){ return $phrase["submit_notitle"]; } if ($url == "" || $url == "http://"){ return $phrase["submit_nourl"]; } if ($config["requiredescription"] == "true"){ if ($description == ""){ return $phrase["submit_nodescription"]; } } // validate topic $sql = "SELECT * FROM " . $dbprefix . "topics WHERE topicid = " . dbSecure($topicid); $top = $db->execute($sql); if ($top->rows < 1){ return $phrase["submit_missingtopic"]; } // check for it being in the directory if ($config["allowduplicateurls"] <> "true"){ $sql = "SELECT * FROM " . $dbprefix . "links WHERE url = '" . dbSecure($url) . "'"; } else { $sql = "SELECT * FROM " . $dbprefix . "links WHERE url = '" . dbSecure($url) . "' AND topicid = " . $top->fields["topicid"]; } $chk = $db->execute($sql); // run the actual check if ($chk->rows > 0){ return $phrase["submit_urlindirectory"]; } // no double submissions $sql = "SELECT * FROM " . $dbprefix . "queue WHERE url = '" . dbSecure($url) . "'"; $chk = $db->execute($sql); if ($chk->rows > 0){ return $phrase["submit_urlinqueue"]; } // ok, insert into the queue $sql = "INSERT INTO " . $dbprefix . "queue (postdate, topicid, website, url, description, email, ip) VALUES ("; $sql .= time() . ", "; $sql .= dbSecure($topicid) . ", "; $sql .= "'" . dbSecure($title) . "', "; $sql .= "'" . dbSecure($url) . "', "; $sql .= "'" . htmlspecialchars(dbSecure($description)) . "', "; $sql .= "'" . dbSecure($email) . "', "; $sql .= "'" . dbSecure($_SERVER["REMOTE_ADDR"]) . "')"; $db->execute($sql); // and return return $phrase["submit_success"]; } ?>
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 886
1148 credits Members referred : 4
« Reply #4 on: Feb 17, 2007, 08:06:28 pm »
thanks man~! this does work in stopping them from sending submissions with html, showing that they have used "no description" in turn terminates the submission.. heres what my spammed submissions loook like below, but what you suggested does help in fighting against it: