Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2006, 03:45 PM   PM User | #16
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
I love PHP because its always simpler than you might expect ...
PHP Code:
<?php
if(!function_exists('glob')){
    function 
glob($pattern){
       
//write your own glob routine here//
    
}
}
?>
does not cause the errors you may at first expect!

the recursive cleaner I use... (GPC_ON is set in config if the server has magic_quotes runtime or GPC turned on)
PHP Code:
<?php
function clean(&$arr){
    foreach(
$arr as $k=>$v){
        if(!
is_array($v)){
                        if(
defined('GPC_ON')){
                            
$arr[$k]=stripslashes($v);
                         }
            
$arr[$k]=mysql_real_escape_string($v);
        }else{
            
clean($arr[$k]);
        }
    }
}
clean($_POST);
?>
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 01-04-2006, 11:24 PM   PM User | #17
Velox Letum
Senior Coder

 
Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
Velox Letum is an unknown quantity at this point
Quote:
Originally Posted by firepages
the recursive cleaner I use... (GPC_ON is set in config if the server has magic_quotes runtime or GPC turned on)
This a nice, simple function. I like it...much more simple than my wrapper. I never knew there was a constant I could use to detect runtime or gpc either.
__________________
"$question = ( to() ) ? be() : ~be();"

Last edited by Velox Letum; 01-05-2006 at 12:22 AM..
Velox Letum is offline   Reply With Quote
Old 01-05-2006, 02:39 AM   PM User | #18
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
Quote:
Originally Posted by Velox Letum
I never knew there was a constant I could use to detect runtime or gpc either.
sorry I was not clear AFAIK there isn't , its one I set myself in a global config file with calls to get_magic_quotes_runtime() and get_magic_quotes_gpc()
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 01-05-2006, 03:50 AM   PM User | #19
Velox Letum
Senior Coder

 
Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
Velox Letum is an unknown quantity at this point
Quote:
Originally Posted by firepages
sorry I was not clear AFAIK there isn't , its one I set myself in a global config file with calls to get_magic_quotes_runtime() and get_magic_quotes_gpc()
Ahh okay. Smart, that. =)
__________________
"$question = ( to() ) ? be() : ~be();"
Velox Letum is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 12:43 PM.


Advertisement
Log in to turn off these ads.