aidan Tue Jul 6 03:10:07 2004 EDT
Modified files:
/phpdoc/en/reference/info/functions get-magic-quotes-gpc.xml
Log:
Added a second example
http://cvs.php.net/diff.php/phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml
diff -u phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml:1.7
phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml:1.8
--- phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml:1.7 Mon Jun 16
15:33:51 2003
+++ phpdoc/en/reference/info/functions/get-magic-quotes-gpc.xml Tue Jul 6 03:10:06
2004
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/info.xml, last change in rev 1.2 -->
<refentry id="function.get-magic-quotes-gpc">
<refnamediv>
<refname>get_magic_quotes_gpc</refname>
<refpurpose>
- Gets the current active configuration setting of magic quotes gpc
+ Gets the current configuration setting of magic quotes gpc
</refpurpose>
</refnamediv>
<refsect1>
@@ -15,7 +15,7 @@
<void/>
</methodsynopsis>
<simpara>
- Returns the current active configuration setting of <link
+ Returns the current configuration setting of <link
linkend="ini.magic-quotes-gpc">magic_quotes_gpc</link> (0 for
off, 1 for on).
</simpara>
@@ -31,8 +31,8 @@
</para>
</note>
<simpara>
- Keep in mind that <link linkend="ini.magic-quotes-gpc">
- magic_quotes_gpc</link> can not be set at runtime.
+ Keep in mind that the setting <link linkend="ini.magic-quotes-gpc">
+ magic_quotes_gpc</link> will not work at runtime. See example 2.
</simpara>
<para>
<example>
@@ -56,6 +56,30 @@
]]>
</programlisting>
</example>
+ </para>
+ <para>
+ In the interests of writing portable code (code that works
+ in any enviroment), or, if you do not have access to change
+ php.ini, you may wish to disable the effects of magic quotes
+ on a per-script basis. This can be done in two ways, with a
+ directive in a .htaccess file (php_value magic_quotes_gpc 0),
+ or by adding the below code to the top of your scripts.
+ <example>
+ <title>Disabling magic quotes at runtime</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+if (get_magic_quotes_gpc()) {
+ $_POST = array_map('stripslashes', $_POST);
+ $_GET = array_map('stripslashes', $_GET);
+ $_COOKIE = array_map('stripslashes', $_COOKIE);
+}
+]]>
+ </programlisting>
+ </example>
+ Magic-quotes was added to reduce code written by beginners from being dangerous.
+ If you disable magic quotes, you must be very careful to protect yourself from
+ SQL injection attacks.
</para>
<simpara>
See also <function>addslashes</function>,