+ Reply to Thread
Results 1 to 7 of 7

Thread: Magic Quotes

  1. #1
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Magic Quotes

    I'm trying to make a pastebin, how do I disable magic quotes?

    I'm obviously on x10hosting shared hosting, so I dont have php.ini access. php.net says theres some code that can be added to htaccess, but that just made a 500 error. I don't want to have to remove the magic quotes in my PHP script, thats not really very efficient.

    What are my options?

    ~Callum
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Magic Quotes

    The topic has been covered many times before. The short version: you can't disable magic quotes on the free hosts (if that's where your site is), you can only undo them (which should have minimal impact on response times).

    PHP Code:
    <?php // normal_quotes.php. Include this once in any script that needs magic quotes undone
    function stripslashes_nested(&$v) {
        if (
    is_array($v)) {
            return 
    array_map('stripslashes_nested'$v);
        } else {
            return 
    $v stripslashes($v);
        }
    }

    if (
    get_magic_quotes_gpc()) {
        foreach (array(
    '_GET''_POST''_COOKIE''_REQUEST') as $k) {
            
    stripslashes_nested($GLOBALS[$k]);
        }
    }
    Last edited by misson; 01-02-2011 at 11:52 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Magic Quotes

    I'm on staffserv, but I still can't disable them XD

    I worked out that after I had disabled them, WordPress was adding them instead. WordPress has a function built in to remove them:

    Code:
    $_POST = stripslashes_deep($_POST);
    It's stupid enough that PHP does it, but even more stupid that WordPress does it, but I guess it's fixed now

    ~Callum
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Magic Quotes

    That sounds familiar. How do you feel about patching wp-settings.php?

  5. #5
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Magic Quotes

    Thanks, that's just what I was looking for :D Do you know why wordpress adds the quotes? I dont want to end up breaking something by editing the core.

    ~Callum
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Magic Quotes

    That's what everyone wants to know, and there isn't an answer, as far as I can tell. Others have removed magic quotes with no ill effect, though it's possible that some plugins (or even the core) rely on magic quotes to sanitize data. Only a code audit could tell for certain. You could run an automated tool against your site to test for vulnerabilities, though this might cause an HRU suspension.
    Last edited by misson; 01-03-2011 at 06:35 AM.

  7. #7
    callumacrae's Avatar
    callumacrae is offline not alex mac callumacrae is just really nice
    Join Date
    Dec 2007
    Location
    Wellesbourne, England
    Posts
    5,162

    Re: Magic Quotes

    I'm on staff server, I don't think we have them HRU suspensions.

    Thanks for your help, I'll experiment

    ~Callum
    I can customise your phpBB board. Send me a PM.
    lynxphp - info, tutorials and scripts
    "A forum post should be like a skirt; long enough to cover the subject but short enough to keep things interesting."

+ Reply to Thread

Similar Threads

  1. Magic Quotes. =(
    By sathanna in forum Free Hosting
    Replies: 12
    Last Post: 12-04-2009, 10:36 PM
  2. PHP Magic Quotes
    By examshared in forum Free Hosting
    Replies: 2
    Last Post: 03-03-2009, 04:41 PM
  3. Magic Quotes
    By wtractor in forum Free Hosting
    Replies: 3
    Last Post: 03-10-2008, 06:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers