cvs: phpdoc /it/functions dir.xml exec.xml

From: Date: Thu, 14 Dec 2000 00:29:39 +0000
Subject: cvs: phpdoc /it/functions dir.xml exec.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969333250@lists.php.net to get a copy of this message
perugini Wed Dec 13 16:29:39 2000 EDT Modified files: /phpdoc/it/functions exec.xml dir.xml Log: Sync with en tree. Index: phpdoc/it/functions/exec.xml diff -u phpdoc/it/functions/exec.xml:1.4 phpdoc/it/functions/exec.xml:1.5 --- phpdoc/it/functions/exec.xml:1.4 Thu Aug 31 09:32:26 2000 +++ phpdoc/it/functions/exec.xml Wed Dec 13 16:29:39 2000 @@ -2,6 +2,44 @@ <title>Program Execution functions</title> <titleabbrev>Program Execution</titleabbrev> + <refentry id="function.escapeshellarg"> + <refnamediv> + <refname>escapeshellarg</refname> + <refpurpose>escape a string to be used as a shell argument</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>escapeshellarg</function></funcdef> + <paramdef>string <parameter>arg</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>EscapeShellArg</function> adds single quotes around a string + and quotes/escapes any existing single quotes allowing you to pass a + string directly to a shell function and having it be treated as a single + safe argument. This function should be used to escape individual + arguments to shell functions coming from user input. The shell functions + include <function>exec</function>, <function>system</function> and the + <link linkend="language.operators.execution">backtick operator</link>. + A standard use would be:</para> + <para> + <informalexample> + <programlisting role="php"> +system("ls ".EscapeShellArg($dir)) + </programlisting> + </informalexample> + </para> + <para> + See also <function>exec</function>, <function>popen</function>, + <function>system</function>, and the <link + linkend="language.operators.execution">backtick operator</link>. + </para> + + </refsect1> + </refentry> + <refentry id="function.escapeshellcmd"> <refnamediv> <refname>escapeshellcmd</refname> @@ -27,13 +65,16 @@ <para> <informalexample> <programlisting role="php"> -system(EscapeShellCmd($cmd)) +$e = EscapeShellCmd($userinput); +system("echo $e"); // here we don't care if $e has spaces +$f = EscapeShellCmd($filename); +system("touch \"/tmp/$f\"; ls -l \"/tmp/$f\""); // and here we do, so we use quotes </programlisting> </informalexample> </para> <para> - See also <function>exec</function>, <function>popen</function>, - <function>system</function>, and the <link + See also <function>escapeshellarg</function>, <function>exec</function>, + <function>popen</function>, <function>system</function>, and the <link linkend="language.operators.execution">backtick operator</link>. </para> Index: phpdoc/it/functions/dir.xml diff -u phpdoc/it/functions/dir.xml:1.3 phpdoc/it/functions/dir.xml:1.4 --- phpdoc/it/functions/dir.xml:1.3 Thu Aug 31 09:29:56 2000 +++ phpdoc/it/functions/dir.xml Wed Dec 13 16:29:39 2000 @@ -141,6 +141,7 @@ <example> <title>List all files in the current directory</title> <programlisting role="php"> +// Note that !== did not exist until 4.0.0-RC2 &lt;?php $handle=opendir('.'); echo "Directory handle: $handle\n";

« previous php.doc (#969333250) next »