Block PHP Tag

This is a discussion on "Block PHP Tag" within the PHP Forum section. This forum, and the thread "Block PHP Tag are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 13th, 2008, 18:17
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Block PHP Tag

In the comments form on my blog, it allows any text to be displayed. Now, there must be a way to say 'If the text contains any PHP code, dont allow it'. Otherwise, people can enter PHP code which is not great!
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote

  #2 (permalink)  
Old Feb 13th, 2008, 18:19
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Block PHP Tag

Look into the addslashes() function
Reply With Quote
  #3 (permalink)  
Old Feb 13th, 2008, 18:21
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Block PHP Tag

That wont block PHP code though?
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #4 (permalink)  
Old Feb 13th, 2008, 18:23
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Block PHP Tag

And they can't really execute and PHP code unless your are stupid enough to use eval() on the comment string. They can however try to print out variables such as DB passwords and also use malicious HTML and JS. addslashes() and htmlentities() can counter this.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)

Last edited by alexgeek; Feb 13th, 2008 at 18:27.
Reply With Quote
  #5 (permalink)  
Old Feb 13th, 2008, 18:33
saltedm8's Avatar
Lead Administrator

SuperMember
Join Date: Nov 2005
Location: Always About
Age: 27
Posts: 1,299
Blog Entries: 1
Thanks: 1
Thanked 6 Times in 6 Posts
Re: Block PHP Tag

i have no idea, but i did do this, might work

PHP: Select all

<?php $forbiden="<";
if(
$_POST['submit'] && $_POST['<?php']);
{
if(
strpos($forbiden$_POST['<?php'])==$forbiden);
{
echo 
'php not allowed'?>
my attempt at forbidding a certain word or text, maybe someone could improve on the idea
__________________
My Recipe forum...don't click here
Last Blog Entry: Basic Advice for newbies (Feb 1st, 2008)
Reply With Quote
  #6 (permalink)  
Old Feb 13th, 2008, 23:12
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Block PHP Tag

If you want, you may use regular expressions.
PHP: Select all

<?php
$string
="967<php?PHPknn";
if((
ereg('^[^.]+<[?][^.]+$',$string)) || (ereg('^<[?][^.]+$',$string)))
{echo 
"TAG FOUND";}else{echo "TAG NOT FOUND";}
?>
I have written a more exhaustive tutorial at http://www.w3hobbyist.com/index.php?...field-PHP.html
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)

Last edited by RohanShenoy; Feb 14th, 2008 at 05:35.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Block Architecture sameer Free Web Site Critique 9 Nov 14th, 2007 12:42
new kid on the block lozfromaus Introduce Yourself 16 Jul 13th, 2007 12:02
New Kid on the Block:) carib Introduce Yourself 8 Apr 25th, 2007 00:54
New Man on the Block phillyphreak Introduce Yourself 6 Jul 1st, 2005 16:55
New guy on the block Anonymous User Introduce Yourself 3 Jan 31st, 2005 13:04


All times are GMT. The time now is 05:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43