SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Magic_quotes

  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Magic_quotes

    Hello!

    Is there are more efficient way for dealing with magic quotes for every single $POST than checking to see if they're on and if they are then StripSlashing away? From searching on-line some hosts will allow you to change the config file while others won't.

    I'm hoping for something that I could do once and then absolutely forget about it, regardless of whether I keep my current host or have to change hosts 5 years down then line....

    Thank you,

    Eric

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    from the comments on the magicquotes page, I see this...
    PHP Code:
    foreach ($_POST as $key => &$val$val filter_input(INPUT_POST$key); 
    Cant say i've used that before personally, but there ya go.

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Either way, you're going to need a piece of code to do what you require. So, no not really.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    In terms of implementing this, am I correct in thinking that I can just put it at the top of any page for which I JUST $POSTed values in order for it to do its magic (so to speak)?

    In other words, something like this:

    foreach ($_POST as $key => &$val) $val = filter_input(INPUT_POST, $key);
    $var1 = $_POST['stuff_from_other_page_form'];
    $var2 = $_POST['more_stuff_from_other_page_form'];

    The foreach would then look for anything that was just posted and then convert it (if need be). My $var1 and $var2 would then be cleansed or not as appropriate to whether magicquotes is enabled?

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    magicquotes is deprecated and on the way out the door; that foreach loop will filter and update all values in $_POST.

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks! It can't be deprecated fast enough.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •