SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with turning magic quotes off

    Hey, I am trying to turn magic quotes off. I can't seem to find my php.ini file, even though if i do phpinfo() is says its in usr/local/lib, (that path doesnt seem correct, the only lib directory i see is usr/lib, and then i see a php folder, but here is no php.ini file in there). I am using Mac os X, so it may have somethign to do with that.

    Now, I also see there is a way i can add an .htaccess file in the directory where the script is run from to turn magic quotes off. This may be a beter solution becasue i will be moving everything from this machine soon anyway.

    so i made a new file called ".htaccess" with this code:

    <IfModule mod_php4.c>
    php_flag magic_quotes_gpc off
    </IfModule>

    and put it into the same directory as this script:

    <?

    $test=get_magic_quotes_gpc();

    if ($test == 1){
    print ("it's on");
    }
    ?>

    but i still get "its on" returned when i run the script.

    Oviously i really don't know too much about this, can anyone help me out?
    From here on, it's instinctual...even straight roads meander.

  2. #2
    SitePoint Guru Husain's Avatar
    Join Date
    Sep 2001
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try adding this line at the top of every page:
    PHP Code:
    set_magic_quotes_runtime(0); 

  3. #3
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've read that the OSX installation does not create a php.ini file and if you want to change the default settings (like magic quotes), you can just create one and add the lines you need.

    On my computer (standard OS 10.1.3) there is a
    "/usr/local/lib/".

    I haven't bothered to change any defaults so that's as far as I can help without more reading/doing. Post again if you need more help and I'll look for the stuff I read.

  4. #4
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm see i have 10.1.3 installed too, and i get usr/local, thin inside local there is bin, mysql-3.23.47, and share.

    the set_magic_quotes runtome sems like a good idea, but i'm not sure that will right
    From here on, it's instinctual...even straight roads meander.

  5. #5
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Come to think of it, I recompiled php to add some features... that might have added the directory.

    Heh, sorry.. forgot.

  6. #6
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by husain
    You could try adding this line at the top of every page:
    PHP Code:
    set_magic_quotes_runtime(0); 
    that just turns off magic_quotes_runtime, which is most likely off anyway (the default). he wants to turn off magic_quotes_gpc.




    Roadie, can you search for a file called php.ini? maybe you don't have one, and PHP is just using the default settings?

    about your .htaccess file not working: do you have at least AllowOverride Options on in httpd.conf?
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  7. #7
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no there is no php.ini file...the module i had used to have one (http://www.entropy.ch/software/macosx/php/)...

    as far as the .htacess thing i will check.
    From here on, it's instinctual...even straight roads meander.

  8. #8
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i found this section in my httpd.conf file :

    # This controls which options the .htaccess files in directories can
    # override. Can also be "All", or any combination of "Options", "FileInfo",
    # "AuthConfig", and "Limit"
    #
    AllowOverride None



    im guessing i should change "None" to "All"?
    From here on, it's instinctual...even straight roads meander.

  9. #9
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep. or if not All, you need at least Options in order to change PHP settings in .htaccess.

    don't forget to restart Apache after making the httpd.conf change.

  10. #10
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for all your help, you really know your stuff.
    if i could just ask one more question for this subject, what do the settings (All, Options,...) actually mean?
    From here on, it's instinctual...even straight roads meander.

  11. #11
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there's a brief explanation in the Apache docs: http://httpd.apache.org/docs-2.0/mod...#allowoverride

    hope that helps.

  12. #12
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another crusader joins the war against magic_quotes

  13. #13
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by HarryF
    Another crusader joins the war against magic_quotes
    YESSS!

  14. #14
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question tangent, sort of

    Originally posted by HarryF
    Another crusader joins the war against magic_quotes
    War against magic_quotes? Would this be for double slash reasons or is there something else I should know about?

  15. #15
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  16. #16
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gotcha, thanks!

  17. #17
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i changed teh allow override option in the httpd.conf file, restarted apache, and ran this script:

    <?

    $test=get_magic_quotes_gpc();

    if ($test == 1){
    print ("it's on");
    }

    and i am still getting "it's on" returned.

    In my .htaccess file this is all it says:

    <IfModule mod_php4.c>
    php_flag magic_quotes_gpc off
    </IfModule>


    does there need to be anything else? I would really like to get this working...
    From here on, it's instinctual...even straight roads meander.

  18. #18
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try putting the function call in the if ():

    PHP Code:
    if (get_magic_quotes_gpc())
    {
        echo 
    "It's on";

    probably won't make a difference, but try it.

  19. #19
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope, same problem. I dont know what the problem is, i think i may go with the function you had listed in that other thread. I'd really like to be able to disable the magic quotes though.
    From here on, it's instinctual...even straight roads meander.

  20. #20
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, i'd like to get it turned off too. now that i think about it, before when you had the .htaccess file, but AllowOverride None, you should've gotten an Internal Server Error. that's what i get when i try to use something in .htaccess that's not allowed (because of AllowOverride None, etc.). so i'm thinking that Apache isn't seeing the .htaccess file maybe. where is the .htaccess? same directory as your PHP file? if not, put it there.

    instead of this in .htaccess

    Code:
    <IfModule mod_php4.c>
    	php_flag magic_quotes_gpc off
    </IfModule>
    put this part

    Code:
    php_flag magic_quotes_gpc off
    just to see what happens.


    if all else fails, you can put the code (with the <IfModule> parts) in your httpd.conf file instead. yep, just sticking it at the bottom of httpd.conf should be fine, i think.

    Code:
    <IfModule mod_php4.c>
    	php_flag magic_quotes_gpc off
    </IfModule>
    restart Apache after that and see what your script says then.

  21. #21
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Los Angeles
    Posts
    325
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i changed the .htaccess file to just that one line and that appears to work, i didnt get any response from the php script.

    thanks for all your hlep, you are the man.
    From here on, it's instinctual...even straight roads meander.

  22. #22
    SitePoint Addict
    Join Date
    Mar 2002
    Location
    Michigan
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what are magic quotes?

  23. #23
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,811
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    From Harry's post earlier, you can get a good explaination of both what they are and why they aren't always a good idea here.

    H
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  24. #24
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From the manual:
    Sets the magic_quotes state for GPC (Get/Post/Cookie) operations.
    When magic_quotes are on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically
    From Pink Goblin(by HarryF):
    PHP provides a configuration option "magic_quotes_gpc", which automatically adds slashes to any submitted HTML form data or cookies (gpc = GET/POST/COOKIE), before it gets passed onto your script.
    .

    Hope this explain.

    -Helge

  25. #25
    SitePoint Wizard
    Join Date
    Oct 2001
    Posts
    2,686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops, your faster than me TheOriginalH!

    -Helge


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
  •