28, May 2012

terminate the query when html is found - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: terminate the query when html is found
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: terminate the query when html is found  (Read 876 times)
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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"];
}
?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Feb 15, 2007, 07:13:38 pm »

What is the error that you get?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #2 on: Feb 15, 2007, 09:00:16 pm »

that code isnt showing an error, i took out everything I have done except adding htmlspecialchars to

Code:
<?php
$sql 
.= "'" htmlspecialchars(dbSecure($description)) . "', ";
?>


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Feb 16, 2007, 07:38:11 am »

You can try something like :

if strip_tags($description) != $description ) return $phrase["submit_nodescription"]; ?>

That would work for html, but for bbcode you will need more

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
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:

Quote
thanks again Nik, anymore suggestions?


Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Feb 18, 2007, 01:52:29 am »

I guess this will work.

Now if you add a CAPTCHA verification you will be bullet proof but I guess it is not so necessary.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6028
Tags : htmlspecialchars Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: terminate the query when html is found
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 05:01:27 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.