cvs: phpdoc /en/functions mcrypt.xml mhash.xml ming.xml misc.xml mnogosearch.xml msql.xml mssql.xml mysql.xml network.xml nis.xml oci8.xml openssl.xml
| From: | Hartmut Holzgraefe | Date: | Tue, 20 Nov 2001 23:58:48 +0000 |
| Subject: | cvs: phpdoc /en/functions mcrypt.xml mhash.xml ming.xml misc.xml mnogosearch.xml msql.xml mssql.xml mysql.xml network.xml nis.xml oci8.xml openssl.xml | ||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969339078@lists.php.net to get a copy of this message | ||
hholzgra Tue Nov 20 18:58:48 2001 EDT
Modified files:
/phpdoc/en/functions mcrypt.xml mhash.xml ming.xml misc.xml
mnogosearch.xml msql.xml mssql.xml mysql.xml
network.xml nis.xml oci8.xml openssl.xml
Log:
more CDATA additions to examples
Index: phpdoc/en/functions/mcrypt.xml diff -u phpdoc/en/functions/mcrypt.xml:1.23 phpdoc/en/functions/mcrypt.xml:1.24 --- phpdoc/en/functions/mcrypt.xml:1.23 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/mcrypt.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.mcrypt"> <title>Mcrypt Encryption Functions</title> <titleabbrev>mcrypt</titleabbrev> @@ -41,12 +41,14 @@ <example> <title>Encrypt an input value with TripleDES under 2.2.x in ECB mode</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $key = "this is a very secret key"; $input = "Let us meet at 9 o'clock at the secret place."; $encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT); -?> +?> +]]> </programlisting> </example> This example will give you the encrypted data as a string in @@ -58,7 +60,8 @@ <example> <title>Encrypt an input value with TripleDES under 2.4.x in ECB mode</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $key = "this is a very secret key"; $input = "Let us meet at 9 o'clock at the secret place."; @@ -67,7 +70,8 @@ mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); mcrypt_generic_end ($td); -?> +?> +]]> </programlisting> </example> This example will give you the encrypted data as a string in @@ -397,19 +401,23 @@ <example> <title><function>mcrypt_get_cipher_name</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $cipher = MCRYPT_TripleDES; print mcrypt_get_cipher_name ($cipher); -?> +?> +]]> </programlisting> - </example> - </para> - <para> - The above example will produce: - <programlisting> + <para> + The above example will produce: + <screen> +<![CDATA[ 3DES - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -524,11 +532,13 @@ <example> <title><function>mcrypt_create_iv</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $cipher = MCRYPT_TripleDES; $block_size = mcrypt_get_block_size ($cipher); $iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM); -?> +?> +]]> </programlisting> </example> </para> @@ -744,7 +754,7 @@ <paramdef>int <parameter>mode</parameter></paramdef> <paramdef>string <parameter>iv</parameter></paramdef> </funcprototype> - </funcsynopsis> + </funcsynopsis> <funcsynopsis> <funcprototype> <funcdef>string <function>mcrypt_ofb</function></funcdef> @@ -804,10 +814,10 @@ <funcprototype> <funcdef>array <function>mcrypt_list_algorithms</function></funcdef> <paramdef>string - <parameter> - <optional>lib_dir</optional> - </parameter> - </paramdef> + <parameter> + <optional>lib_dir</optional> + </parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> @@ -819,26 +829,28 @@ <function>mcrypt_list_algorithms</function> takes as optional parameter a directory which specifies the directory where all algorithms are located. If not specifies, the value of the - mcrypt.algorithms_dir php.ini directive is used. + mcrypt.algorithms_dir php.ini directive is used. </para> <para> <example> <title><function>mcrypt_list_algorithms</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); foreach ($algorithms as $cipher) { - echo $cipher."/n"; + echo $cipher."/n"; } -?> +?> +]]> </programlisting> + <para> + The above example will produce a list with all supported + algorithms in the "/usr/local/lib/libmcrypt" directory. + </para> </example> </para> - <para> - The above example will produce a list with all supported - algorithms in the "/usr/local/lib/libmcrypt" directory. - </para> </refsect1> </refentry> @@ -853,10 +865,10 @@ <funcprototype> <funcdef>array <function>mcrypt_list_modes</function></funcdef> <paramdef>string - <parameter> - <optional>lib_dir</optional> - </parameter> - </paramdef> + <parameter> + <optional>lib_dir</optional> + </parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> @@ -868,28 +880,30 @@ <function>mcrypt_list_modes</function> takes as optional parameter a directory which specifies the directory where all modes are located. If not specifies, the value of the - mcrypt.modes_dir php.ini directive is used. + mcrypt.modes_dir php.ini directive is used. </para> <para> <example> <title><function>mcrypt_list_modes</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $modes = mcrypt_list_modes (); foreach ($modes as $mode) { - echo "$mode </br>"; + echo "$mode <br/>"; } -?> +?> +]]> </programlisting> + <para> + The above example will produce a list with all supported + algorithms in the default mode directory. If it is not set + with the ini directive mcrypt.modes_dir, the default directory + of mcrypt is used (which is /usr/local/lib/libmcrypt). + </para> </example> </para> - <para> - The above example will produce a list with all supported - algorithms in the default mode directory. If it is not set - with the ini directive mcrypt.modes_dir, the default directory - of mcrypt is used (which is /usr/local/lib/libmcrypt). - </para> </refsect1> </refentry> @@ -995,7 +1009,8 @@ <example> <title><function>mcrypt_encrypt</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $key = "This is a very secret key"; $text = "Meet me at 11 o'clock behind the monument."; @@ -1003,14 +1018,19 @@ $crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); echo strlen ($crypttext)."\n"; -?> +?> +]]> </programlisting> - </example> - The above example will print out: - <programlisting> + <para> + The above example will print out: + <screen> +<![CDATA[ 42 64 - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -1109,13 +1129,18 @@ <example> <title><function>mcrypt_module_open</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $td = mcrypt_module_open (MCRYPT_DES, "", MCRYPT_MODE_ECB, "/usr/lib/mcrypt-modes"); -?> +?> +]]> </programlisting> + <para> + The above example will try to open the DES cipher + from the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. + </para> </example> - The above example will try to open the DES cipher from the default - directory and the EBC mode from the directory /usr/lib/mcrypt-modes. </para> </refsect1> </refentry> @@ -1202,7 +1227,8 @@ <example> <title><function>mdecrypt_generic</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $iv_size = mcrypt_enc_get_iv_size ($td)); $iv = @mcrypt_create_iv ($iv_size, MCRYPT_RAND); @@ -1216,11 +1242,14 @@ echo "ok"; else echo "error"; -?> +?> +]]> </programlisting> + <para> + The above example shows how to check if the data before the + encryption is the same as the data after the decryption. + </para> </example> - The above example shows how to check if the data before the - encryption is the same as the data after the decryption. </para> </refsect1> </refentry> Index: phpdoc/en/functions/mhash.xml diff -u phpdoc/en/functions/mhash.xml:1.18 phpdoc/en/functions/mhash.xml:1.19 --- phpdoc/en/functions/mhash.xml:1.18 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/mhash.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.mhash"> <title>Mhash Functions</title> <titleabbrev>mhash</titleabbrev> @@ -28,20 +28,26 @@ <example> <title>Compute the MD5 digest and hmac and print it out as hex</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $input = "what do ya want for nothing?"; $hash = mhash (MHASH_MD5, $input); print "The hash is ".bin2hex ($hash)."\n<br>"; $hash = mhash (MHASH_MD5, $input, "Jefe"); print "The hmac is ".bin2hex ($hash)."\n<br>"; -?> +?> +]]> </programlisting> - </example> - This will produce: - <programlisting> + <para> + This will produce: + <screen> +<![CDATA[ The hash is d03cb659cbf9192dcd066272249f8412 The hmac is 750c783e6ab0b503eaa86e310a5db738 - </programlisting> +]]> + </screen> + </para> + </example> For a complete list of supported hashes, refer to the documentation of mhash. The general rule is that you can access the hash algorithm from PHP with MHASH_HASHNAME. For example, to @@ -137,17 +143,23 @@ <example> <title><function>mhash_get_hash_name</function> Example</title> <programlisting> -<?php +<![CDATA[ +<?php $hash = MHASH_MD5; print mhash_get_hash_name ($hash); -?> +?> +]]> </programlisting> + <para> + The above example will print out: + <screen> +<![CDATA[ + MD5 +]]> + </screen> + </para> </example> - The above example will print out: - <programlisting> -MD5 - </programlisting> </para> </refsect1> </refentry> @@ -198,16 +210,18 @@ <example> <title>Traversing all hashes</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $nr = mhash_count(); -for ($i = 0; $i <= $nr; $i++) { +for ($i = 0; $i <= $nr; $i++) { echo sprintf ("The blocksize of %s is %d\n", mhash_get_hash_name ($i), mhash_get_block_size ($i)); } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/ming.xml diff -u phpdoc/en/functions/ming.xml:1.26 phpdoc/en/functions/ming.xml:1.27 --- phpdoc/en/functions/ming.xml:1.26 Sat Nov 10 18:46:30 2001 +++ phpdoc/en/functions/ming.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.26 $ --> +<!-- $Revision: 1.27 $ --> <reference id="ref.ming"> <title>Ming functions for Flash</title> <titleabbrev>Ming (flash)</titleabbrev> @@ -60,13 +60,17 @@ <sect2 id="ming.install.php.unix"> <title>built into php (unix)</title> <para> + <informalexample> <literallayout> - mkdir <phpdir>/ext/ming - cp php_ext/* <phpdir>/ext/ming - cd <phpdir> +<![CDATA[ + mkdir <phpdir>/ext/ming + cp php_ext/* <phpdir>/ext/ming + cd <phpdir> ./buildconf - ./configure --with-ming <other config options> - </literallayout> + ./configure --with-ming <other config options> +]]> + </literallayout> + </informalexample> Build and install php as usual, Restart web server if necessary </para> @@ -217,9 +221,11 @@ <function>swfmovie->output</function> dumps your lovingly prepared movie out. In PHP, preceding this with the command <programlisting role="php"> -<?php +<![CDATA[ +<?php header('Content-type: application/x-shockwave-flash'); -?> +?> +]]> </programlisting> convinces the browser to display this as a flash movie. </para> @@ -473,18 +479,20 @@ <example> <title><function>swfmovie->streammp3</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setRate(12.0); - $m->streamMp3("distortobass.mp3"); -// use your own MP3 + $m->setRate(12.0); + $m->streamMp3("distortobass.mp3"); + // use your own MP3 // 11.85 seconds at 12.0 fps = 142 frames - $m->setFrames(142); + $m->setFrames(142); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -689,15 +697,16 @@ <example> <title><function>swfdisplayitem->rotateto</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $thetext = "ming!"; $f = new SWFFont("Bauhaus 93.fdb"); $m = new SWFMovie(); - $m->setRate(24.0); - $m->setDimension(2400, 1600); - $m->setBackground(0xff, 0xff, 0xff); + $m->setRate(24.0); + $m->setDimension(2400, 1600); + $m->setBackground(0xff, 0xff, 0xff); // functions with huge numbers of arbitrary // arguments are always a good idea! Really! @@ -707,23 +716,23 @@ global $f, $m; $t = new SWFText(); - $t->setFont($f); - $t->setColor($r, $g, $b, $a); - $t->setHeight(960); - $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); - $t->addString($string); + $t->setFont($f); + $t->setColor($r, $g, $b, $a); + $t->setHeight(960); + $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); + $t->addString($string); // we can add properties just like a normal php var, // as long as the names aren't already used. - // e.g., we can't set $i->scale, because that's a function + // e.g., we can't set $i->scale, because that's a function - $i = $m->add($t); - $i->x = $x; - $i->y = $y; - $i->rot = $rot; - $i->s = $scale; - $i->rotateTo($rot); - $i->scale($scale, $scale); + $i = $m->add($t); + $i->x = $x; + $i->y = $y; + $i->rot = $rot; + $i->s = $scale; + $i->rotateTo($rot); + $i->scale($scale, $scale); // but the changes are local to the function, so we have to // return the changed object. kinda weird.. @@ -733,15 +742,15 @@ function step($i) { - $oldrot = $i->rot; - $i->rot = 19*$i->rot/20; - $i->x = (19*$i->x + 1200)/20; - $i->y = (19*$i->y + 800)/20; - $i->s = (19*$i->s + 1.0)/20; - - $i->rotateTo($i->rot); - $i->scaleTo($i->s, $i->s); - $i->moveTo($i->x, $i->y); + $oldrot = $i->rot; + $i->rot = 19*$i->rot/20; + $i->x = (19*$i->x + 1200)/20; + $i->y = (19*$i->y + 800)/20; + $i->s = (19*$i->s + 1.0)/20; + + $i->rotateTo($i->rot); + $i->scaleTo($i->s, $i->s); + $i->moveTo($i->x, $i->y); return $i; } @@ -752,18 +761,19 @@ $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext); $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext); - for($i=1; $i<=100; ++$i) + for($i=1; $i<=100; ++$i) { $i1 = step($i1); $i2 = step($i2); $i3 = step($i3); - $m->nextFrame(); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1059,63 +1069,65 @@ <example> <title><function>swfdisplayitem->setname</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0xff, 0xff); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0xff, 0xff, 0xff); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0xff, 0xff, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape1(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(0.16, 0xff, 0xff, 0xff); + $g->addEntry(0.32, 0, 0, 0); + $g->addEntry(0.48, 0xff, 0xff, 0xff); + $g->addEntry(0.64, 0, 0, 0); + $g->addEntry(0.80, 0xff, 0xff, 0xff); + $g->addEntry(1.00, 0, 0, 0); + + $s = $p->getShape1(); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.05); + $s->setLeftFill($f); + $s->movePenTo(-160, -120); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0, 0); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0, 0xff, 0); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0, 0, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape2(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $f->skewXTo(1.0); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(0.16, 0xff, 0, 0); + $g->addEntry(0.32, 0, 0, 0); + $g->addEntry(0.48, 0, 0xff, 0); + $g->addEntry(0.64, 0, 0, 0); + $g->addEntry(0.80, 0, 0, 0xff); + $g->addEntry(1.00, 0, 0, 0); + + $s = $p->getShape2(); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.05); + $f->skewXTo(1.0); + $s->setLeftFill($f); + $s->movePenTo(-160, -120); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); $m = new SWFMovie(); - $m->setDimension(320, 240); - $i = $m->add($p); - $i->moveTo(160, 120); + $m->setDimension(320, 240); + $i = $m->add($p); + $i->moveTo(160, 120); - for($n=0; $n<=1.001; $n+=0.01) + for($n=0; $n<=1.001; $n+=0.01) { - $i->setRatio($n); - $m->nextFrame(); + $i->setRatio($n); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1185,32 +1197,34 @@ <example> <title><function>swfdisplayitem->multcolor</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $b = new SWFBitmap("backyard.jpg"); // note use your own picture :-) $s = new SWFShape(); - $s->setRightFill($s->addFill($b)); - $s->drawLine($b->getWidth(), 0); - $s->drawLine(0, $b->getHeight()); - $s->drawLine(-$b->getWidth(), 0); - $s->drawLine(0, -$b->getHeight()); + $s->setRightFill($s->addFill($b)); + $s->drawLine($b->getWidth(), 0); + $s->drawLine(0, $b->getHeight()); + $s->drawLine(-$b->getWidth(), 0); + $s->drawLine(0, -$b->getHeight()); $m = new SWFMovie(); - $m->setDimension($b->getWidth(), $b->getHeight()); + $m->setDimension($b->getWidth(), $b->getHeight()); - $i = $m->add($s); + $i = $m->add($s); - for($n=0; $n<=20; ++$n) + for($n=0; $n<=20; ++$n) { - $i->multColor(1.0-$n/10, 1.0, 1.0); - $i->addColor(0xff*$n/20, 0, 0); - $m->nextFrame(); + $i->multColor(1.0-$n/10, 1.0, 1.0); + $i->addColor(0xff*$n/20, 0, 0); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1249,24 +1263,26 @@ <example> <title><function>swfshape</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setLine(40, 0x7f, 0, 0); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(200, 200); - $s->drawLineTo(6200, 200); - $s->drawLineTo(6200, 4600); - $s->drawCurveTo(200, 4600, 200, 200); + $s->setLine(40, 0x7f, 0, 0); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(200, 200); + $s->drawLineTo(6200, 200); + $s->drawLineTo(6200, 4600); + $s->drawCurveTo(200, 4600, 200, 200); $m = new SWFMovie(); - $m->setDimension(6400, 4800); - $m->setRate(12.0); - $m->add($s); - $m->nextFrame(); + $m->setDimension(6400, 4800); + $m->setRate(12.0); + $m->add($s); + $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1312,56 +1328,58 @@ <example> <title><function>swfshape->setline</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f1 = $s->addFill(0xff, 0, 0); - $f2 = $s->addFill(0xff, 0x7f, 0); - $f3 = $s->addFill(0xff, 0xff, 0); - $f4 = $s->addFill(0, 0xff, 0); - $f5 = $s->addFill(0, 0, 0xff); + $f1 = $s->addFill(0xff, 0, 0); + $f2 = $s->addFill(0xff, 0x7f, 0); + $f3 = $s->addFill(0xff, 0xff, 0); + $f4 = $s->addFill(0, 0xff, 0); + $f5 = $s->addFill(0, 0, 0xff); // bug: have to declare all line styles before you use them - $s->setLine(40, 0x7f, 0, 0); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->setLine(40, 0, 0x7f, 0); - $s->setLine(40, 0, 0, 0x7f); + $s->setLine(40, 0x7f, 0, 0); + $s->setLine(40, 0x7f, 0x3f, 0); + $s->setLine(40, 0x7f, 0x7f, 0); + $s->setLine(40, 0, 0x7f, 0); + $s->setLine(40, 0, 0, 0x7f); $f = new SWFFont('Techno.fdb'); - $s->setRightFill($f1); - $s->setLine(40, 0x7f, 0, 0); - $s->drawGlyph($f, '!'); - $s->movePen($f->getWidth('!'), 0); - - $s->setRightFill($f2); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->drawGlyph($f, '#'); - $s->movePen($f->getWidth('#'), 0); - - $s->setRightFill($f3); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->drawGlyph($f, '%'); - $s->movePen($f->getWidth('%'), 0); - - $s->setRightFill($f4); - $s->setLine(40, 0, 0x7f, 0); - $s->drawGlyph($f, '*'); - $s->movePen($f->getWidth('*'), 0); - - $s->setRightFill($f5); - $s->setLine(40, 0, 0, 0x7f); - $s->drawGlyph($f, '@'); + $s->setRightFill($f1); + $s->setLine(40, 0x7f, 0, 0); + $s->drawGlyph($f, '!'); + $s->movePen($f->getWidth('!'), 0); + + $s->setRightFill($f2); + $s->setLine(40, 0x7f, 0x3f, 0); + $s->drawGlyph($f, '#'); + $s->movePen($f->getWidth('#'), 0); + + $s->setRightFill($f3); + $s->setLine(40, 0x7f, 0x7f, 0); + $s->drawGlyph($f, '%'); + $s->movePen($f->getWidth('%'), 0); + + $s->setRightFill($f4); + $s->setLine(40, 0, 0x7f, 0); + $s->drawGlyph($f, '*'); + $s->movePen($f->getWidth('*'), 0); + + $s->setRightFill($f5); + $s->setLine(40, 0, 0, 0x7f); + $s->drawGlyph($f, '@'); $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setRate(12.0); - $i = $m->add($s); - $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); + $m->setDimension(3000,2000); + $m->setRate(12.0); + $i = $m->add($s); + $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1441,54 +1459,56 @@ <example> <title><function>swfshape->addfill</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); $b = new SWFBitmap("alphafill.jpg"); // use your own bitmap - $width = $b->getWidth(); - $height = $b->getHeight(); + $width = $b->getWidth(); + $height = $b->getHeight(); - $s = $p->getShape1(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); - $f->moveTo(-$width/2, -$height/4); - $f->scaleTo(1.0, 0.5); - $s->setLeftFill($f); - $s->movePenTo(-$width/2, -$height/4); - $s->drawLine($width, 0); - $s->drawLine(0, $height/2); - $s->drawLine(-$width, 0); - $s->drawLine(0, -$height/2); + $s = $p->getShape1(); + $f = $s->addFill($b, SWFFILL_TILED_BITMAP); + $f->moveTo(-$width/2, -$height/4); + $f->scaleTo(1.0, 0.5); + $s->setLeftFill($f); + $s->movePenTo(-$width/2, -$height/4); + $s->drawLine($width, 0); + $s->drawLine(0, $height/2); + $s->drawLine(-$width, 0); + $s->drawLine(0, -$height/2); - $s = $p->getShape2(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); + $s = $p->getShape2(); + $f = $s->addFill($b, SWFFILL_TILED_BITMAP); // these two have no effect! - $f->moveTo(-$width/4, -$height/2); - $f->scaleTo(0.5, 1.0); + $f->moveTo(-$width/4, -$height/2); + $f->scaleTo(0.5, 1.0); - $s->setLeftFill($f); - $s->movePenTo(-$width/4, -$height/2); - $s->drawLine($width/2, 0); - $s->drawLine(0, $height); - $s->drawLine(-$width/2, 0); - $s->drawLine(0, -$height); + $s->setLeftFill($f); + $s->movePenTo(-$width/4, -$height/2); + $s->drawLine($width/2, 0); + $s->drawLine(0, $height); + $s->drawLine(-$width/2, 0); + $s->drawLine(0, -$height); $m = new SWFMovie(); - $m->setDimension($width, $height); - $i = $m->add($p); - $i->moveTo($width/2, $height/2); + $m->setDimension($width, $height); + $i = $m->add($p); + $i->moveTo($width/2, $height/2); - for($n=0; $n<1.001; $n+=0.03) + for($n=0; $n<1.001; $n+=0.03) { - $i->setRatio($n); - $m->nextFrame(); + $i->setRatio($n); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1804,50 +1824,52 @@ <example> <title><function>swfgradient</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setDimension(320, 240); + $m->setDimension(320, 240); $s = new SWFShape(); // first gradient- black to white $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(1.0, 0xff, 0xff, 0xff); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(1.0, 0xff, 0xff, 0xff); - $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); - $f->scaleTo(0.01); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); + $f->scaleTo(0.01); + $f->moveTo(160, 120); + $s->setRightFill($f); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); - $m->add($s); + $m->add($s); $s = new SWFShape(); // second gradient- radial gradient from red to transparent $g = new SWFGradient(); - $g->addEntry(0.0, 0xff, 0, 0, 0xff); - $g->addEntry(1.0, 0xff, 0, 0, 0); + $g->addEntry(0.0, 0xff, 0, 0, 0xff); + $g->addEntry(1.0, 0xff, 0, 0, 0); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.005); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.005); + $f->moveTo(160, 120); + $s->setRightFill($f); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); - $m->add($s); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1925,23 +1947,25 @@ <example> <title>Import PNG files</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f = $s->addFill(new SWFBitmap("png.dbl")); - $s->setRightFill($f); + $f = $s->addFill(new SWFBitmap("png.dbl")); + $s->setRightFill($f); - $s->drawLine(32, 0); - $s->drawLine(0, 32); - $s->drawLine(-32, 0); - $s->drawLine(0, -32); + $s->drawLine(32, 0); + $s->drawLine(0, 32); + $s->drawLine(-32, 0); + $s->drawLine(0, -32); $m = new SWFMovie(); - $m->setDimension(32, 32); - $m->add($s); + $m->setDimension(32, 32); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1950,53 +1974,55 @@ <example> <title><function>swfbitmap</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); // .msk file generated with "gif2mask" utility - $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); - $s->setRightFill($f); + $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); + $s->setRightFill($f); - $s->drawLine(640, 0); - $s->drawLine(0, 480); - $s->drawLine(-640, 0); - $s->drawLine(0, -480); + $s->drawLine(640, 0); + $s->drawLine(0, 480); + $s->drawLine(-640, 0); + $s->drawLine(0, -480); $c = new SWFShape(); - $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); - $c->drawLine(40, 0); - $c->drawLine(0, 40); - $c->drawLine(-40, 0); - $c->drawLine(0, -40); + $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); + $c->drawLine(40, 0); + $c->drawLine(0, 40); + $c->drawLine(-40, 0); + $c->drawLine(0, -40); $m = new SWFMovie(); - $m->setDimension(640, 480); - $m->setBackground(0xcc, 0xcc, 0xcc); + $m->setDimension(640, 480); + $m->setBackground(0xcc, 0xcc, 0xcc); // draw checkerboard background - for($y=0; $y<480; $y+=40) + for($y=0; $y<480; $y+=40) { - for($x=0; $x<640; $x+=80) + for($x=0; $x<640; $x+=80) { - $i = $m->add($c); - $i->moveTo($x, $y); + $i = $m->add($c); + $i->moveTo($x, $y); } $y+=40; - for($x=40; $x<640; $x+=80) + for($x=40; $x<640; $x+=80) { - $i = $m->add($c); - $i->moveTo($x, $y); + $i = $m->add($c); + $i->moveTo($x, $y); } } - $m->add($s); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2224,47 +2250,49 @@ <example> <title><function>swfmorph</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); - $s = $p->getShape1(); - $s->setLine(0,0,0,0); + $s = $p->getShape1(); + $s->setLine(0,0,0,0); /* Note that this is backwards from normal shapes (left instead of right). I have no idea why, but this seems to work.. */ - $s->setLeftFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(-1000,-1000); - $s->drawLine(2000,0); - $s->drawLine(0,2000); - $s->drawLine(-2000,0); - $s->drawLine(0,-2000); - - $s = $p->getShape2(); - $s->setLine(60,0,0,0); - $s->setLeftFill($s->addFill(0, 0, 0xff)); - $s->movePenTo(0,-1000); - $s->drawLine(1000,1000); - $s->drawLine(-1000,1000); - $s->drawLine(-1000,-1000); - $s->drawLine(1000,-1000); + $s->setLeftFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(-1000,-1000); + $s->drawLine(2000,0); + $s->drawLine(0,2000); + $s->drawLine(-2000,0); + $s->drawLine(0,-2000); + + $s = $p->getShape2(); + $s->setLine(60,0,0,0); + $s->setLeftFill($s->addFill(0, 0, 0xff)); + $s->movePenTo(0,-1000); + $s->drawLine(1000,1000); + $s->drawLine(-1000,1000); + $s->drawLine(-1000,-1000); + $s->drawLine(1000,-1000); $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(3000,2000); + $m->setBackground(0xff, 0xff, 0xff); - $i = $m->add($p); - $i->moveTo(1500,1000); + $i = $m->add($p); + $i->moveTo(1500,1000); - for($r=0.0; $r<=1.0; $r+=0.1) + for($r=0.0; $r<=1.0; $r+=0.1) { - $i->setRatio($r); - $m->nextFrame(); + $i->setRatio($r); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2347,23 +2375,25 @@ <example> <title><function>swftext</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = new SWFFont("Techno.fdb"); $t = new SWFText(); - $t->setFont($f); - $t->moveTo(200, 2400); - $t->setColor(0xff, 0xff, 0); - $t->setHeight(1200); - $t->addString("PHP generates Flash with Ming!!"); + $t->setFont($f); + $t->moveTo(200, 2400); + $t->setColor(0xff, 0xff, 0); + $t->setHeight(1200); + $t->addString("PHP generates Flash with Ming!!"); $m = new SWFMovie(); - $m->setDimension(5400, 3600); + $m->setDimension(5400, 3600); - $m->add($t); + $m->add($t); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2564,9 +2594,11 @@ the movie player. The fonts _serif, _sans, and _typewriter should always be available. For example: <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = newSWFFont("_sans"); -?> +?> +]]> </programlisting> will give you the standard sans-serif font, probably the same as what you'd get with <literal><font name="sans-serif"></literal> in HTML. @@ -2665,9 +2697,11 @@ Flags are combined with the bitwise <link linkend="language.operators.bitwise">OR</link> operation. For example, <programlisting role="php"> -<?php +<![CDATA[ +<?php $t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT); -?> +?> +]]> </programlisting> creates a totally useless non-editable password field. </para> @@ -2978,40 +3012,42 @@ <example> <title><function>swfsprite</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(-500,-500); - $s->drawLineTo(500,-500); - $s->drawLineTo(500,500); - $s->drawLineTo(-500,500); - $s->drawLineTo(-500,-500); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(-500,-500); + $s->drawLineTo(500,-500); + $s->drawLineTo(500,500); + $s->drawLineTo(-500,500); + $s->drawLineTo(-500,-500); $p = new SWFSprite(); - $i = $p->add($s); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); + $i = $p->add($s); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); $m = new SWFMovie(); - $i = $m->add($p); - $i->moveTo(1500,1000); - $i->setName("blah"); + $i = $m->add($p); + $i->moveTo(1500,1000); + $i->setName("blah"); - $m->setBackground(0xff, 0xff, 0xff); - $m->setDimension(3000,2000); + $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(3000,2000); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3144,7 +3180,8 @@ <example> <title><function>swfbutton</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = new SWFFont("_serif"); @@ -3155,22 +3192,22 @@ global $f; $t = new SWFTextField(); - $t->setFont($f); - $t->addString($string); - $t->setHeight(200); - $t->setBounds(3200,200); + $t->setFont($f); + $t->addString($string); + $t->setHeight(200); + $t->setBounds(3200,200); return $t; } function addLabel($string) { global $p; - $i = $p->add(label($string)); - $p->nextFrame(); - $p->remove($i); + $i = $p->add(label($string)); + $p->nextFrame(); + $p->remove($i); } - $p->add(new SWFAction("stop();")); + $p->add(new SWFAction("stop();")); addLabel("NO ACTION"); addLabel("SWFBUTTON_MOUSEUP"); addLabel("SWFBUTTON_MOUSEDOWN"); @@ -3183,54 +3220,55 @@ function rect($r, $g, $b) { $s = new SWFShape(); - $s->setRightFill($s->addFill($r, $g, $b)); - $s->drawLine(600,0); - $s->drawLine(0,600); - $s->drawLine(-600,0); - $s->drawLine(0,-600); + $s->setRightFill($s->addFill($r, $g, $b)); + $s->drawLine(600,0); + $s->drawLine(0,600); + $s->drawLine(-600,0); + $s->drawLine(0,-600); return $s; } $b = new SWFButton(); - $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT); - $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER); - $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN); + $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT); + $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER); + $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"), SWFBUTTON_MOUSEUP); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"), SWFBUTTON_MOUSEDOWN); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"), SWFBUTTON_MOUSEOVER); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"), SWFBUTTON_MOUSEOUT); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"), SWFBUTTON_MOUSEUPOUTSIDE); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"), SWFBUTTON_DRAGOVER); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"), SWFBUTTON_DRAGOUT); $m = new SWFMovie(); - $m->setDimension(4000,3000); + $m->setDimension(4000,3000); - $i = $m->add($p); - $i->setName("label"); - $i->moveTo(400,1900); + $i = $m->add($p); + $i->setName("label"); + $i->moveTo(400,1900); - $i = $m->add($b); - $i->moveTo(400,900); + $i = $m->add($b); + $i->moveTo(400,900); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3240,36 +3278,38 @@ <example> <title><function>swfbutton->addaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->drawLine(1000,0); - $s->drawLine(0,1000); - $s->drawLine(-1000,0); - $s->drawLine(0,-1000); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->drawLine(1000,0); + $s->drawLine(0,1000); + $s->drawLine(-1000,0); + $s->drawLine(0,-1000); $b = new SWFButton(); - $b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); + $b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); - $b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse + $b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse SWFBUTTON_MOUSEDOWN); - $b->addAction(new SWFAction("stopDrag();"), + $b->addAction(new SWFAction("stopDrag();"), SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE); $p = new SWFSprite(); - $p->add($b); - $p->nextFrame(); + $p->add($b); + $p->nextFrame(); $m = new SWFMovie(); - $i = $m->add($p); - $i->setName('test'); - $i->moveTo(1000,1000); + $i = $m->add($p); + $i->setName('test'); + $i->moveTo(1000,1000); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3870,45 +3910,47 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f = $s->addFill(0xff, 0, 0); - $s->setRightFill($f); + $f = $s->addFill(0xff, 0, 0); + $s->setRightFill($f); - $s->movePenTo(-500,-500); - $s->drawLineTo(500,-500); - $s->drawLineTo(500,500); - $s->drawLineTo(-500,500); - $s->drawLineTo(-500,-500); + $s->movePenTo(-500,-500); + $s->drawLineTo(500,-500); + $s->drawLineTo(500,500); + $s->drawLineTo(-500,500); + $s->drawLineTo(-500,-500); $p = new SWFSprite(); - $i = $p->add($s); - $i->setDepth(1); - $p->nextFrame(); + $i = $p->add($s); + $i->setDepth(1); + $p->nextFrame(); - for($n=0; $n<5; ++$n) + for($n=0; $n<5; ++$n) { - $i->rotate(-15); - $p->nextFrame(); + $i->rotate(-15); + $p->nextFrame(); } $m = new SWFMovie(); - $m->setBackground(0xff, 0xff, 0xff); - $m->setDimension(6000,4000); + $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(6000,4000); - $i = $m->add($p); - $i->setDepth(1); - $i->moveTo(-500,2000); - $i->setName("box"); - - $m->add(new SWFAction("/box.x += 3;")); - $m->nextFrame(); - $m->add(new SWFAction("gotoFrame(0); play();")); - $m->nextFrame(); + $i = $m->add($p); + $i->setDepth(1); + $i->moveTo(-500,2000); + $i->setName("box"); + + $m->add(new SWFAction("/box.x += 3;")); + $m->nextFrame(); + $m->add(new SWFAction("gotoFrame(0); play();")); + $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3917,75 +3959,76 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setRate(36.0); - $m->setDimension(1200, 800); - $m->setBackground(0, 0, 0); + $m->setRate(36.0); + $m->setDimension(1200, 800); + $m->setBackground(0, 0, 0); /* mouse tracking sprite - empty, but follows mouse so we can get its x and y coordinates */ - $i = $m->add(new SWFSprite()); - $i->setName('mouse'); + $i = $m->add(new SWFSprite()); + $i->setName('mouse'); - $m->add(new SWFAction(" + $m->add(new SWFAction(" startDrag('/mouse', 1); /* '1' means lock sprite to the mouse */ ")); /* might as well turn off antialiasing, since these are just squares. */ - $m->add(new SWFAction(" + $m->add(new SWFAction(" this.quality = 0; ")); /* morphing box */ $r = new SWFMorph(); - $s = $r->getShape1(); + $s = $r->getShape1(); /* Note this is backwards from normal shapes. No idea why. */ - $s->setLeftFill($s->addFill(0xff, 0xff, 0xff)); - $s->movePenTo(-40, -40); - $s->drawLine(80, 0); - $s->drawLine(0, 80); - $s->drawLine(-80, 0); - $s->drawLine(0, -80); - - $s = $r->getShape2(); - - $s->setLeftFill($s->addFill(0x00, 0x00, 0x00)); - $s->movePenTo(-1, -1); - $s->drawLine(2, 0); - $s->drawLine(0, 2); - $s->drawLine(-2, 0); - $s->drawLine(0, -2); + $s->setLeftFill($s->addFill(0xff, 0xff, 0xff)); + $s->movePenTo(-40, -40); + $s->drawLine(80, 0); + $s->drawLine(0, 80); + $s->drawLine(-80, 0); + $s->drawLine(0, -80); + + $s = $r->getShape2(); + + $s->setLeftFill($s->addFill(0x00, 0x00, 0x00)); + $s->movePenTo(-1, -1); + $s->drawLine(2, 0); + $s->drawLine(0, 2); + $s->drawLine(-2, 0); + $s->drawLine(0, -2); /* sprite container for morphing box - this is just a timeline w/ the box morphing */ $box = new SWFSprite(); - $box->add(new SWFAction(" + $box->add(new SWFAction(" stop(); ")); - $i = $box->add($r); + $i = $box->add($r); - for($n=0; $n<=20; ++$n) + for($n=0; $n<=20; ++$n) { - $i->setRatio($n/20); - $box->nextFrame(); + $i->setRatio($n/20); + $box->nextFrame(); } /* this container sprite allows us to use the same action code many times */ $cell = new SWFSprite(); - $i = $cell->add($box); - $i->setName('box'); + $i = $cell->add($box); + $i->setName('box'); - $cell->add(new SWFAction(" + $cell->add(new SWFAction(" setTarget('box'); @@ -3996,31 +4039,31 @@ ")); - $cell->nextFrame(); - $cell->add(new SWFAction(" + $cell->nextFrame(); + $cell->add(new SWFAction(" gotoFrame(0); play(); ")); - $cell->nextFrame(); + $cell->nextFrame(); /* finally, add a bunch of the cells to the movie */ - for($x=0; $x<12; ++$x) + for($x=0; $x<12; ++$x) { - for($y=0; $y<8; ++$y) + for($y=0; $y<8; ++$y) { - $i = $m->add($cell); - $i->moveTo(100*$x+50, 100*$y+50); + $i = $m->add($cell); + $i->moveTo(100*$x+50, 100*$y+50); } } - $m->nextFrame(); + $m->nextFrame(); - $m->add(new SWFAction(" + $m->add(new SWFAction(" gotoFrame(1); play(); @@ -4028,8 +4071,9 @@ ")); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -4038,13 +4082,14 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setDimension(11000, 8000); - $m->setBackground(0x00, 0x00, 0x00); + $m->setDimension(11000, 8000); + $m->setBackground(0x00, 0x00, 0x00); - $m->add(new SWFAction(" + $m->add(new SWFAction(" this.quality = 0; /frames.visible = 0; @@ -4054,56 +4099,56 @@ // mouse tracking sprite $t = new SWFSprite(); - $i = $m->add($t); - $i->setName('mouse'); + $i = $m->add($t); + $i->setName('mouse'); $g = new SWFGradient(); - $g->addEntry(0, 0xff, 0xff, 0xff, 0xff); - $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff); - $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f); - $g->addEntry(1.0, 0xff, 0xff, 0xff, 0); + $g->addEntry(0, 0xff, 0xff, 0xff, 0xff); + $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff); + $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f); + $g->addEntry(1.0, 0xff, 0xff, 0xff, 0); // gradient shape thing $s = new SWFShape(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.03); - $s->setRightFill($f); - $s->movePenTo(-600, -600); - $s->drawLine(1200, 0); - $s->drawLine(0, 1200); - $s->drawLine(-1200, 0); - $s->drawLine(0, -1200); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.03); + $s->setRightFill($f); + $s->movePenTo(-600, -600); + $s->drawLine(1200, 0); + $s->drawLine(0, 1200); + $s->drawLine(-1200, 0); + $s->drawLine(0, -1200); // need to make this a sprite so we can multColor it $p = new SWFSprite(); - $p->add($s); - $p->nextFrame(); + $p->add($s); + $p->nextFrame(); // put the shape in here, each frame a different color $q = new SWFSprite(); - $q->add(new SWFAction("gotoFrame(random(7)+1); stop();")); - $i = $q->add($p); + $q->add(new SWFAction("gotoFrame(random(7)+1); stop();")); + $i = $q->add($p); - $i->multColor(1.0, 1.0, 1.0); - $q->nextFrame(); - $i->multColor(1.0, 0.5, 0.5); - $q->nextFrame(); - $i->multColor(1.0, 0.75, 0.5); - $q->nextFrame(); - $i->multColor(1.0, 1.0, 0.5); - $q->nextFrame(); - $i->multColor(0.5, 1.0, 0.5); - $q->nextFrame(); - $i->multColor(0.5, 0.5, 1.0); - $q->nextFrame(); - $i->multColor(1.0, 0.5, 1.0); - $q->nextFrame(); + $i->multColor(1.0, 1.0, 1.0); + $q->nextFrame(); + $i->multColor(1.0, 0.5, 0.5); + $q->nextFrame(); + $i->multColor(1.0, 0.75, 0.5); + $q->nextFrame(); + $i->multColor(1.0, 1.0, 0.5); + $q->nextFrame(); + $i->multColor(0.5, 1.0, 0.5); + $q->nextFrame(); + $i->multColor(0.5, 0.5, 1.0); + $q->nextFrame(); + $i->multColor(1.0, 0.5, 1.0); + $q->nextFrame(); // finally, this one contains the action code $p = new SWFSprite(); - $i = $p->add($q); - $i->setName('frames'); - $p->add(new SWFAction(" + $i = $p->add($q); + $i->setName('frames'); + $p->add(new SWFAction(" dx = (/:mousex-/:lastx)/3 + random(10)-5; dy = (/:mousey-/:lasty)/3; @@ -4112,9 +4157,9 @@ alpha = 100; ")); - $p->nextFrame(); + $p->nextFrame(); - $p->add(new SWFAction(" + $p->add(new SWFAction(" this.x = x; this.y = y; @@ -4125,16 +4170,16 @@ alpha -= 8; ")); - $p->nextFrame(); + $p->nextFrame(); - $p->add(new SWFAction("prevFrame(); play();")); - $p->nextFrame(); + $p->add(new SWFAction("prevFrame(); play();")); + $p->nextFrame(); - $i = $m->add($p); - $i->setName('frames'); - $m->nextFrame(); + $i = $m->add($p); + $i->setName('frames'); + $m->nextFrame(); - $m->add(new SWFAction(" + $m->add(new SWFAction(" lastx = mousex; lasty = mousey; @@ -4146,17 +4191,18 @@ if(num == 11) num = 1; -removeClip('char' & num); -duplicateClip(/frames, 'char' & num, num); +removeClip('char' & num); +duplicateClip(/frames, 'char' & num, num); ")); - $m->nextFrame(); - $m->add(new SWFAction("prevFrame(); play();")); + $m->nextFrame(); + $m->add(new SWFAction("prevFrame(); play();")); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -4169,46 +4215,47 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php /* sprite has one letter per frame */ $p = new SWFSprite(); - $p->add(new SWFAction("stop();")); + $p->add(new SWFAction("stop();")); $chars = "abcdefghijklmnopqrstuvwxyz". "ABCDEFGHIJKLMNOPQRSTUVWXYZ". - "1234567890!@#$%^&*()_+-=/[]{}|;:,.<>?`~"; + "1234567890!@#$%^&/*()_+-=/[]{}|;:,.<>?`~"; $f = new SWFFont("_sans"); for($n=0; $nremove($i); $t = new SWFTextField(); - $t->setFont($f); - $t->setHeight(240); - $t->setBounds(600,240); - $t->align(SWFTEXTFIELD_ALIGN_CENTER); - $t->addString($c); - $i = $p->add($t); - $p->labelFrame($c); - $p->nextFrame(); + $t->setFont($f); + $t->setHeight(240); + $t->setBounds(600,240); + $t->align(SWFTEXTFIELD_ALIGN_CENTER); + $t->addString($c); + $i = $p->add($t); + $p->labelFrame($c); + $p->nextFrame(); } /* hit region for button - the entire frame */ $s = new SWFShape(); - $s->setFillStyle0($s->addSolidFill(0, 0, 0, 0)); - $s->drawLine(600, 0); - $s->drawLine(0, 400); - $s->drawLine(-600, 0); - $s->drawLine(0, -400); + $s->setFillStyle0($s->addSolidFill(0, 0, 0, 0)); + $s->drawLine(600, 0); + $s->drawLine(0, 400); + $s->drawLine(-600, 0); + $s->drawLine(0, -400); /* button checks for pressed key, sends sprite to the right frame */ $b = new SWFButton(); - $b->addShape($s, SWFBUTTON_HIT); + $b->addShape($s, SWFBUTTON_HIT); for($n=0; $naddAction(new SWFAction(" @@ -4219,17 +4266,18 @@ } $m = new SWFMovie(); - $m->setDimension(600,400); - $i = $m->add($p); - $i->setName('char'); - $i->moveTo(0,80); + $m->setDimension(600,400); + $i = $m->add($p); + $i->setName('char'); + $i->moveTo(0,80); - $m->add($b); + $m->add($b); header('Content-type: application/x-shockwave-flash'); - $m->output(); + $m->output(); -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/misc.xml diff -u phpdoc/en/functions/misc.xml:1.59 phpdoc/en/functions/misc.xml:1.60 --- phpdoc/en/functions/misc.xml:1.59 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/misc.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.59 $ --> +<!-- $Revision: 1.60 $ --> <reference id="ref.misc"> <title>Miscellaneous functions</title> <titleabbrev>Misc.</titleabbrev> @@ -117,14 +117,16 @@ <example> <title><function>constant</function> example</title> <programlisting role="php"> -<php +<![CDATA[ +<php define ("MAXSIZE", 100); echo MAXSIZE; echo constant("MAXSIZE"); // same thing as the previous line -?> +?> +]]> </programlisting> </example> </para> @@ -175,7 +177,8 @@ <example> <title>Defining Constants</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php define ("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. @@ -184,7 +187,8 @@ echo GREETING; // outputs "Hello you." echo Greeting; // outputs "Hello you." -?> +?> +]]> </programlisting> </example> </para> @@ -223,11 +227,13 @@ <example> <title>Checking Constants</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (defined("CONSTANT")){ // Note that it should be quoted echo CONSTANT; // } -?> +?> +]]> </programlisting> </example> </para> @@ -298,23 +304,27 @@ <function>eval</function> example - simple text merge </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $string = 'cup'; $name = 'coffee'; -$str = 'This is a $string with my $name in it.<br>'; +$str = 'This is a $string with my $name in it.<br>'; echo $str; eval ("\$str = \"$str\";"); echo $str; -?> +?> +]]> </programlisting> - </example> - </para> <para> The above example will show: - <programlisting> + <screen> +<![CDATA[ This is a $string with my $name in it. This is a cup with my coffee in it. - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -359,13 +369,15 @@ <example> <title><function>exit</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $filename = '/path/to/data-file'; $file = fopen ($filename, 'r') or exit("unable to open file ($filename)"); -?> +?> +]]> </programlisting> <!-- TODO: example with integer exit-statis --> </example> @@ -418,17 +430,19 @@ <example> <title><function>get_browser</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function list_array ($array) { while (list ($key, $value) = each ($array)) { - $str .= "<b>$key:</b> $value<br>\n"; + $str .= "<b>$key:</b> $value<br>\n"; } return $str; } -echo "$HTTP_USER_AGENT<hr>\n"; +echo "$HTTP_USER_AGENT<hr>\n"; $browser = get_browser(); echo list_array ((array) $browser); -?> +?> +]]> </programlisting> </example> </para> @@ -436,26 +450,28 @@ The output of the above script would look something like this: </simpara> <programlisting> -Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr> -<b>browser_name_pattern:</b> Mozilla/4\.5.*<br> -<b>parent:</b> Netscape 4.0<br> -<b>platform:</b> Unknown<br> -<b>majorver:</b> 4<br> -<b>minorver:</b> 5<br> -<b>browser:</b> Netscape<br> -<b>version:</b> 4<br> -<b>frames:</b> 1<br> -<b>tables:</b> 1<br> -<b>cookies:</b> 1<br> -<b>backgroundsounds:</b> <br> -<b>vbscript:</b> <br> -<b>javascript:</b> 1<br> -<b>javaapplets:</b> 1<br> -<b>activexcontrols:</b> <br> -<b>beta:</b> <br> -<b>crawler:</b> <br> -<b>authenticodeupdate:</b> <br> -<b>msn:</b> <br> +<![CDATA[ +Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr> +<b>browser_name_pattern:</b> Mozilla/4\.5.*<br> +<b>parent:</b> Netscape 4.0<br> +<b>platform:</b> Unknown<br> +<b>majorver:</b> 4<br> +<b>minorver:</b> 5<br> +<b>browser:</b> Netscape<br> +<b>version:</b> 4<br> +<b>frames:</b> 1<br> +<b>tables:</b> 1<br> +<b>cookies:</b> 1<br> +<b>backgroundsounds:</b> <br> +<b>vbscript:</b> <br> +<b>javascript:</b> 1<br> +<b>javaapplets:</b> 1<br> +<b>activexcontrols:</b> <br> +<b>beta:</b> <br> +<b>crawler:</b> <br> +<b>authenticodeupdate:</b> <br> +<b>msn:</b> <br> +]]> </programlisting> <simpara> In order for this to work, your <link @@ -506,7 +522,7 @@ <title>Creating a source highlighting URL</title> <simpara> To setup a URL that can code hightlight any script that you pass to - it, we will make use of the "ForceType" directive in + it, we will make use of the "ForceType" directive in Apache to generate a nice URL pattern, and use the function <function>highlight_file</function> to show a nice looking code list. @@ -516,50 +532,57 @@ </simpara> <para> <informalexample> - <programlisting> -<Location /source> + <programlisting> +<![CDATA[ +<Location /source> ForceType application/x-httpd-php -</Location> - </programlisting></informalexample> +</Location> +]]> + </programlisting> + </informalexample> </para> <simpara> - And then make a file named "source" and put it in your + And then make a file named "source" and put it in your web root directory. </simpara> <para> <programlisting role="php"> -<HTML> -<HEAD> -<TITLE>Source Display</TITLE> -</HEAD> -<BODY BGCOLOR="white"> -<?php - $script = getenv ("PATH_TRANSLATED"); +<![CDATA[ +<HTML> +<HEAD> +<TITLE>Source Display</TITLE> +</HEAD> +<BODY BGCOLOR="white"> +<?php + $script = getenv ("PATH_TRANSLATED"); if(!$script) { - echo "<BR><B>ERROR: Script Name needed</B><BR>"; + echo "<BR><B>ERROR: Script Name needed</B><BR>"; } else { - if (ereg("(\.php|\.inc)$",$script)) { - echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n"; + if (ereg("(\.php|\.inc)$",$script)) { + echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n"; highlight_file($script); } else { - echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; + echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; } } - echo "<HR>Processed: ".date("Y/M/d H:i:s",time()); -?> -</BODY> -</HTML> + echo "<HR>Processed: ".date("Y/M/d H:i:s",time()); +?> +</BODY> +</HTML> +]]> </programlisting> </para> <simpara> Then you can use an URL like the one below to display a colorized - version of a script located in "/path/to/script.php" + version of a script located in "/path/to/script.php" in your web site. </simpara> <para> <informalexample> <programlisting> +<![CDATA[ http://your.server.com/source/path/to/script.php +]]> </programlisting> </informalexample> </para> @@ -821,7 +844,9 @@ <example> <title><function>pack</function> format string</title> <programlisting role="php"> +<![CDATA[ $binarydata = pack ("nvc*", 0x1234, 0x5678, 65, 66); +]]> </programlisting> <para> The resulting binary string will be 6 bytes long and contain @@ -954,8 +979,10 @@ it is recommended that you use something along the lines of <informalexample> <programlisting role="php"> +<![CDATA[ $token = md5 (uniqid ("")); // no random portion $better_token = md5 (uniqid (rand())); // better, difficult to guess +]]> </programlisting> </informalexample> </para> @@ -993,7 +1020,9 @@ <example> <title><function>unpack</function> format string</title> <programlisting role="php"> +<![CDATA[ $array = unpack ("c2chars/nint", $binarydata); +]]> </programlisting> <para> The resulting array will contain the entries "chars1", Index: phpdoc/en/functions/mnogosearch.xml diff -u phpdoc/en/functions/mnogosearch.xml:1.28 phpdoc/en/functions/mnogosearch.xml:1.29 --- phpdoc/en/functions/mnogosearch.xml:1.28 Sun Nov 11 13:55:39 2001 +++ phpdoc/en/functions/mnogosearch.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.28 $ --> +<!-- $Revision: 1.29 $ --> <reference id="ref.mnogo"> <title>mnoGoSearch Functions</title> <titleabbrev>mnoGoSearch</titleabbrev> @@ -228,9 +228,11 @@ <simpara>Example:</simpara> <informalexample> <programlisting role="C"> - if (Udm_Api_Version() >= 30111) { - print "Total number of urls in database: ".Udm_Get_Doc_Count($udm)."<br>\n"; +<![CDATA[ + if (Udm_Api_Version() >= 30111) { + print "Total number of urls in database: ".Udm_Get_Doc_Count($udm)."<br>\n"; } +]]> </programlisting> </informalexample> </refsect1> Index: phpdoc/en/functions/msql.xml diff -u phpdoc/en/functions/msql.xml:1.18 phpdoc/en/functions/msql.xml:1.19 --- phpdoc/en/functions/msql.xml:1.18 Fri Nov 16 17:29:07 2001 +++ phpdoc/en/functions/msql.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.msql"> <title>mSQL functions</title> <titleabbrev>mSQL</titleabbrev> @@ -1125,16 +1125,18 @@ <example> <title><function>msql_tablename</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php msql_connect ("localhost"); $result = msql_list_tables ("wisconsin"); $i = 0; -while ($i < msql_numrows ($result)) { +while ($i < msql_numrows ($result)) { $tb_names[$i] = msql_tablename ($result, $i); - echo $tb_names[$i] . "<BR>"; + echo $tb_names[$i] . "<BR>"; $i++; } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/mssql.xml diff -u phpdoc/en/functions/mssql.xml:1.21 phpdoc/en/functions/mssql.xml:1.22 --- phpdoc/en/functions/mssql.xml:1.21 Wed Nov 14 14:05:26 2001 +++ phpdoc/en/functions/mssql.xml Tue Nov 20 18:58:46 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.21 $ --> +<!-- $Revision: 1.22 $ --> <reference id="ref.mssql"> <title>Microsoft SQL Server functions</title> <titleabbrev>MS SQL Server</titleabbrev> @@ -497,7 +497,8 @@ <example> <title><function>mssql_next_result</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mssql_connect ("localhost", "userid", "secret"); mssql_select_db("MyDB", $link); $SQL = "Select * from table1 select * from table2"; @@ -508,7 +509,8 @@ } while (mssql_next_result($rs)); mssql_free_result($rs); mssql_close ($link); -?> +?> +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/mysql.xml diff -u phpdoc/en/functions/mysql.xml:1.75 phpdoc/en/functions/mysql.xml:1.76 --- phpdoc/en/functions/mysql.xml:1.75 Mon Nov 19 12:10:35 2001 +++ phpdoc/en/functions/mysql.xml Tue Nov 20 18:58:46 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.75 $ --> +<!-- $Revision: 1.76 $ --> <reference id="ref.mysql"> <title>MySQL Functions</title> <titleabbrev>MySQL</titleabbrev> @@ -215,12 +215,14 @@ <example> <title>MySQL close example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect ("kraemer", "marliesle", "secret") or die ("Could not connect"); print ("Connected successfully"); mysql_close ($link); -?> +?> +]]> </programlisting> </example> <para> @@ -300,12 +302,14 @@ <example> <title>MySQL connect example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect ("localhost", "username", "secret") or die ("Could not connect"); print ("Connected successfully"); mysql_close ($link); -?> +?> +]]> </programlisting> </example> <para> See also @@ -344,7 +348,8 @@ <example> <title>MySQL create database example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_pconnect ("kron", "jutta", "geheim") or die ("Could not connect"); if (mysql_create_db ("my_db")) { @@ -352,7 +357,8 @@ } else { printf ("Error creating database: %s\n", mysql_error ()); } -?> +?> +]]> </programlisting> </example> <para> @@ -394,7 +400,8 @@ <example> <title>MySQL data seek example</title> <programlisting role="php"> -<?php +<![CDATA[ +&<?php $link = mysql_pconnect ("kron", "jutta", "geheim") or die ("Could not connect"); @@ -416,11 +423,12 @@ if(!($row = mysql_fetch_object ($result))) continue; - echo ("$row->last_name $row->first_name<BR>\n"; + echo "$row->last_name $row->first_name<br />\n"; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -461,7 +469,8 @@ <example> <title><function>mysql_db_name</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php error_reporting(E_ALL); mysql_connect('dbhost', 'username', 'password'); @@ -469,11 +478,12 @@ $i = 0; $cnt = mysql_num_rows($db_list); -while ($i < $cnt) { +while ($i < $cnt) { echo mysql_db_name($db_list, $i) . "\n"; $i++; } -?> +?> +]]> </programlisting> </example> <para> @@ -597,18 +607,20 @@ error code from the most recently executed MySQL function (not including <function>mysql_error</function> and <function>mysql_errno</function>), so if you want to use it, - make sure you check the value before calling another mySQL - function. + make sure you check the value before calling another mySQL + function. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect("marliesle"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; $conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."<BR>"; -?> +echo mysql_errno().": ".mysql_error()."<BR>"; +?> +]]> </programlisting> </informalexample> </para> @@ -652,14 +664,16 @@ sure you check the value before calling another MySQL function. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect("marliesle"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; $conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."<BR>"; -?> +echo mysql_errno().": ".mysql_error()."<BR>"; +?> +]]> </programlisting> </informalexample> </para> @@ -734,8 +748,10 @@ access the contents with the original column name (by using <literal>'field'</literal> in this example). <informalexample> - <programlisting> + <programlisting role="sql"> +<![CDATA[ select tone.field as foo ttwo.field as bar from tone, ttwo +]]> </programlisting> </informalexample> </para> @@ -768,17 +784,19 @@ <example> <title><function>mysql_fetch_array</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database","select user_id, fullname from table"); while ($row = mysql_fetch_array ($result)) { - echo "user_id: ".$row["user_id"]."<br>\n"; - echo "user_id: ".$row[0]."<br>\n"; - echo "fullname: ".$row["fullname"]."<br>\n"; - echo "fullname: ".$row[1]."<br>\n"; + echo "user_id: ".$row["user_id"]."<br>\n"; + echo "user_id: ".$row[0]."<br>\n"; + echo "fullname: ".$row["fullname"]."<br>\n"; + echo "fullname: ".$row[1]."<br>\n"; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -834,7 +852,8 @@ <example> <title><function>mysql_fetch_assoc</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database","select * from table"); while ($row = mysql_fetch_assoc ($result)) { @@ -842,7 +861,8 @@ echo $row["fullname"]; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -945,20 +965,21 @@ <example> <title><function>mysql_fetch_field</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password) or die ("Could not connect"); $result = mysql_db_query ("database", "select * from table") or die ("Query failed"); # get column metadata $i = 0; -while ($i < mysql_num_fields ($result)) { - echo "Information for column $i:<BR>\n"; +while ($i < mysql_num_fields ($result)) { + echo "Information for column $i:<BR>\n"; $meta = mysql_fetch_field ($result); if (!$meta) { - echo "No information available<BR>\n"; + echo "No information available<BR>\n"; } - echo "<PRE> + echo "<PRE> blob: $meta->blob max_length: $meta->max_length multiple_key: $meta->multiple_key @@ -971,11 +992,12 @@ unique_key: $meta->unique_key unsigned: $meta->unsigned zerofill: $meta->zerofill -</PRE>"; +</PRE>"; $i++; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> @@ -1062,7 +1084,8 @@ <example> <title><function>mysql_fetch_object</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database", "select * from table"); while ($row = mysql_fetch_object ($result)) { @@ -1070,7 +1093,8 @@ echo $row->fullname; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </para> @@ -1188,6 +1212,7 @@ <example> <title><function>mysql_field_name</function> example</title> <programlisting role="php"> +<![CDATA[ // The users table consists of three fields: // user_id // username @@ -1197,17 +1222,18 @@ echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ user_id password - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <para> For downwards compatibility <function>mysql_fieldname</function> @@ -1324,7 +1350,8 @@ <example> <title>MySQL field types</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ("localhost:3306"); mysql_select_db ("wisconsin"); @@ -1333,19 +1360,20 @@ $rows = mysql_num_rows ($result); $i = 0; $table = mysql_field_table ($result, $i); -echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>"; -echo "The table has the following fields <BR>"; -while ($i < $fields) { +echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>"; +echo "The table has the following fields <BR>"; +while ($i < $fields) { $type = mysql_field_type ($result, $i); $name = mysql_field_name ($result, $i); $len = mysql_field_len ($result, $i); $flags = mysql_field_flags ($result, $i); - echo $type." ".$name." ".$len." ".$flags."<BR>"; + echo $type." ".$name." ".$len." ".$flags."<BR>"; $i++; } mysql_close(); -?> +?> +]]> </programlisting> </example> </para> @@ -1475,25 +1503,29 @@ <example> <title><function>mysql_list_dbs</function> example</title> <programlisting role="php"> +<![CDATA[ +<?php $link = mysql_connect('localhost', 'myname', 'secret'); $db_list = mysql_list_dbs($link); while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } +?> +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ database1 database2 database3 ... - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <note> <para> @@ -1543,27 +1575,30 @@ <example> <title><function>mysql_list_fields</function> example</title> <programlisting role="php"> +<![CDATA[ +<?php $link = mysql_connect('localhost', 'myname', 'secret'); $fields = mysql_list_fields("database1", "table1", $link); $columns = mysql_num_fields($fields); -for ($i = 0; $i < $columns; $i++) { +for ($i = 0; $i < $columns; $i++) { echo mysql_field_name($fields, $i) . "\n";; } +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ field1 field2 field3 ... - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <para> For downward compatibility <function>mysql_listfields</function> @@ -1660,7 +1695,8 @@ <example> <title><function>mysql_num_rows</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect("localhost", "username", "password"); mysql_select_db("database", $link); @@ -1670,7 +1706,8 @@ echo "$num_rows Rows\n"; -?> +?> +]]> </programlisting> </example> </para> @@ -1818,10 +1855,12 @@ <example> <title><function>mysql_query</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<php $result = mysql_query ("SELECT * WHERE 1=1") or die ("Invalid query"); -?> +?> +]]> </programlisting> </example> </para> @@ -1833,10 +1872,12 @@ <example> <title><function>mysql_query</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $result = mysql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); -?> +?> +]]> </programlisting> </example> </para> @@ -2044,16 +2085,18 @@ <example> <title><function>mysql_tablename</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ("localhost:3306"); $result = mysql_list_tables ("wisconsin"); $i = 0; -while ($i < mysql_num_rows ($result)) { +while ($i < mysql_num_rows ($result)) { $tb_names[$i] = mysql_tablename ($result, $i); - echo $tb_names[$i] . "<BR>"; + echo $tb_names[$i] . "<BR>"; $i++; } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/network.xml diff -u phpdoc/en/functions/network.xml:1.44 phpdoc/en/functions/network.xml:1.45 --- phpdoc/en/functions/network.xml:1.44 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/network.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.44 $ --> +<!-- $Revision: 1.45 $ --> <reference id="ref.network"> <title>Network Functions</title> <titleabbrev>Network</titleabbrev> @@ -214,9 +214,11 @@ <example> <title><function>fsockopen</function> Example</title> <programlisting role="php"> +<![CDATA[ +<?php $fp = fsockopen ("www.php.net", 80, $errno, $errstr, 30); if (!$fp) { - echo "$errstr ($errno)<br>\n"; + echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { @@ -224,6 +226,8 @@ } fclose ($fp); } +?> +]]> </programlisting> </example> The example below shows how to retrieve the day and time @@ -231,16 +235,18 @@ <example> <title>Using UDP connection</title> <programlisting role="php"> +<![CDATA[ <?php $fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr); if (!$fp) { - echo "ERROR: $errno - $errstr<br>\n"; + echo "ERROR: $errno - $errstr<br>\n"; } else { fwrite($fp,"\n"); echo fread($fp, 26); fclose($fp); } -?> +?> +]]> </programlisting> </example> <note> @@ -512,12 +518,14 @@ <example> <title><function>ip2long</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $ip = gethostbyname("www.php.net"); -$out = "The following URLs are equivalent:<br>\n"; -$out .= "http://www.php.net/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n"; +$out = "The following URLs are equivalent:<br>\n"; +$out .= "http://www.php.net/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n"; echo $out; -?> +?> +]]> </programlisting> </example> <note> @@ -533,11 +541,13 @@ <example> <title>Displaying an IP address</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $ip = gethostbyname("www.php.net"); printf("%u\n", ip2long($ip)); echo $out; -?> +?> +]]> </programlisting> </example> </para> @@ -868,7 +878,8 @@ <example> <title><function>socket_set_timeout</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $fp = fsockopen("www.php.net", 80); if(!$fp) { echo "Unable to open\n"; @@ -881,7 +892,8 @@ fclose($fp); print $res; } -?> +?> +]]> </programlisting> </example> </para> @@ -970,12 +982,13 @@ <example> <title>Using <function>syslog</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php define_syslog_variables(); // open syslog, include the process ID and also send // the log to standard error, and use a user defined // logging mechanism -openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); +openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); // some code @@ -984,12 +997,13 @@ } else { // unauthorized client! // log the attempt - $access = date("Y/m/d H:i:s"); - syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)"); + $access = date("Y/m/d H:i:s"); + syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)"); } closelog(); -?> +?> +]]> </programlisting> </example> For information on setting up a user defined log handler, see the Index: phpdoc/en/functions/nis.xml diff -u phpdoc/en/functions/nis.xml:1.17 phpdoc/en/functions/nis.xml:1.18 --- phpdoc/en/functions/nis.xml:1.17 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/nis.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.17 $ --> +<!-- $Revision: 1.18 $ --> <reference id="ref.nis"> <title>YP/NIS Functions</title> <titleabbrev>YP/NIS</titleabbrev> @@ -47,10 +47,12 @@ <example> <title>Example for the default domain</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $domain = yp_get_default_domain(); echo "Default NIS domain is: " . $domain; ?> +]]> </programlisting> </example> </para> @@ -85,10 +87,12 @@ <example> <title>Example for the NIS order</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $number = yp_order($domain,$mapname); echo "Order number for this map is: " . $number; ?> +]]> </programlisting> </example> </para> @@ -126,10 +130,12 @@ <example> <title>Example for the NIS master</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $number = yp_master ($domain, $mapname); echo "Master for this map is: " . $master; ?> +]]> </programlisting> </example> </para> @@ -166,10 +172,12 @@ <example> <title>Example for NIS match</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_match ($domain, "passwd.byname", "joe"); echo "Matched entry is: " . $entry; ?> +]]> </programlisting> </example> </para> @@ -211,12 +219,14 @@ <example> <title>Example for the NIS first</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_first($domain, "passwd.byname"); $key = $entry ["key"]; $value = $entry ["value"]; echo "First entry in this map has key " . $key . " and value " . $value; ?> +]]> </programlisting> </example> </para> @@ -254,7 +264,8 @@ <example> <title>Example for NIS next</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_next ($domain, "passwd.byname", "joe"); if (!$entry) { @@ -267,6 +278,7 @@ echo "The next entry after joe has key " . $key . " and value " . $entry[$key]; ?> +]]> </programlisting> </example> </para> @@ -358,9 +370,11 @@ <example> <title>Example for NIS errors</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php echo "Error: " . yp_err_string(); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/oci8.xml diff -u phpdoc/en/functions/oci8.xml:1.34 phpdoc/en/functions/oci8.xml:1.35 --- phpdoc/en/functions/oci8.xml:1.34 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/oci8.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.34 $ --> +<!-- $Revision: 1.35 $ --> <reference id="ref.oci8"> <title>Oracle 8 functions</title> <titleabbrev>OCI8</titleabbrev> @@ -65,7 +65,8 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ # ldd /www/apache/bin/httpd libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000) libm.so.6 => /lib/libm.so.6 (0x4002f000) @@ -73,7 +74,8 @@ libdl.so.2 => /lib/libdl.so.2 (0x4007a000) libc.so.6 => /lib/libc.so.6 (0x4007e000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -81,13 +83,15 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ # cd /usr/src/apache_1.3.xx # make clean # LIBS=-lpthread ./config.status # make # make install - </programlisting> +]]> + </screen> </informalexample> </para> </note> @@ -95,7 +99,8 @@ <example> <title>OCI Hints</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // by sergo@bacup.ru // Use option: OCI_DEFAULT for execute command to delay execution @@ -104,7 +109,7 @@ // for retrieve data use (after fetch): $result = OCIResult($stmt, $n); -if (is_object ($result)) $result = $result->load(); +if (is_object ($result)) $result = $result->load(); // For INSERT or UPDATE statement use: @@ -112,12 +117,12 @@ field2 = empty_clob()) returning field2 into :field2"; OCIParse($conn, $sql); $clob = OCINewDescriptor($conn, OCI_D_LOB); -OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); +OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); OCIExecute($stmt, OCI_DEFAULT); -$clob->save ("some text"); +$clob->save ("some text"); OCICommit($conn); -?> +?> </programlisting> </example> </para> @@ -127,7 +132,8 @@ <example> <title>Using Stored Procedures</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // by webmaster@remoterealty.com $sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname', '$lastname', '$company', '$address1', '$address2', '$city', '$state', @@ -141,7 +147,8 @@ OCIBindByName ( $sth, ":error_code", $errorcode, 10 ); OCIExecute ( $sth ); -?> +?> +]]> </programlisting> </example> </para> @@ -184,7 +191,8 @@ <example> <title>OCIDefineByName</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIDefineByPos example thies@thieso.net (980219) */ $conn = OCILogon("scott","tiger"); @@ -206,6 +214,7 @@ OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </refsect1> @@ -256,7 +265,8 @@ <example> <title>OCIDefineByName</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIBindByPos example thies@thieso.net (980221) inserts 3 records into emp, and uses the ROWID for updating the records just after the insert. @@ -306,6 +316,7 @@ OCILogoff($conn); ?> +]]> </programlisting> </example> <warning> @@ -357,8 +368,9 @@ <example> <title>OCILogon</title> <programlisting> -<?php -print "<HTML><PRE>"; +<![CDATA[ +<?php +print "<HTML><PRE>"; $db = ""; $c1 = ocilogon("scott","tiger",$db); @@ -404,7 +416,7 @@ ociexecute($stmt,OCI_DEFAULT); echo $conn."----selecting\n\n"; while (ocifetch($stmt)) - echo $conn." <".ociresult($stmt,"TEST").">\n\n"; + echo $conn." <".ociresult($stmt,"TEST").">\n\n"; echo $conn."----done\n\n"; } @@ -435,8 +447,12 @@ drop_table($c1); -print "</PRE></HTML>"; -?></programlisting></example></para> +print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> + </para> <simpara> See also <function>OCIPLogon</function> and <function>OCINLogon</function>.</simpara> @@ -518,8 +534,9 @@ <example> <title>OCINLogon</title> <programlisting> -<?php -print "<HTML><PRE>"; +<![CDATA[ +<?php +print "<HTML><PRE>"; $db = ""; $c1 = ocilogon("scott","tiger",$db); @@ -566,7 +583,7 @@ ociexecute($stmt,OCI_DEFAULT); echo $conn."----selecting\n\n"; while (ocifetch($stmt)) - echo $conn." <".ociresult($stmt,"TEST").">\n\n"; + echo $conn." <".ociresult($stmt,"TEST").">\n\n"; echo $conn."----done\n\n"; } @@ -596,8 +613,11 @@ drop_table($c1); -print "</PRE></HTML>"; -?></programlisting></example> +print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> </para> <simpara> See also <function>OCILogon</function> and @@ -721,7 +741,8 @@ <example> <title>OCINewDescriptor</title> <programlisting> -<?php +<![CDATA[ +<?php /* This script is designed to be called from a HTML form. * It expects $user, $password, $table, $where, and $commitsize * to be passed in from the form. The script then deletes @@ -731,12 +752,12 @@ $conn = OCILogon($user, $password); $stmt = OCIParse($conn,"select rowid from $table $where"); $rowid = OCINewDescriptor($conn,OCI_D_ROWID); - OCIDefineByName($stmt,"ROWID",&$rowid); + OCIDefineByName($stmt,"ROWID",&$rowid); OCIExecute($stmt); while ( OCIFetch($stmt) ) { $nrows = OCIRowCount($stmt); $delete = OCIParse($conn,"delete from $table where ROWID = :rid"); - OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID); + OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID); OCIExecute($delete); print "$nrows\n"; if ( ($nrows % $commitsize) == 0 ) { @@ -748,29 +769,31 @@ OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> <programlisting> -<?php +<![CDATA[ +<?php /* This script demonstrates file upload to LOB columns * The formfield used for this example looks like this - * <form action="upload.php3" method="post" enctype="multipart/form-data"> - * <input type="file" name="lob_upload"> + * <form action="upload.php3" method="post" enctype="multipart/form-data"> + * <input type="file" name="lob_upload"> * ... */ if(!isset($lob_upload) || $lob_upload == 'none'){ ?> -<form action="upload.php3" method="post" enctype="multipart/form-data"> -Upload file: <input type="file" name="lob_upload"><br> -<input type="submit" value="Upload"> - <input type="reset"> -</form> -<?php +<form action="upload.php3" method="post" enctype="multipart/form-data"> +Upload file: <input type="file" name="lob_upload"><br> +<input type="submit" value="Upload"> - <input type="reset"> +</form> +<?php } else { // $lob_upload contains the temporary filename of the uploaded file $conn = OCILogon($user, $password); $lob = OCINewDescriptor($conn, OCI_D_LOB); $stmt = OCIParse($conn,"insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); - OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); + OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); OCIExecute($stmt, OCI_DEFAULT); if($lob->savefile($lob_upload)){ OCICommit($conn); @@ -783,12 +806,14 @@ OCILogoff($conn); } ?> +]]> </programlisting> </example> <example> <title>OCINewDescriptor</title> <programlisting> -<?php +<![CDATA[ +<?php /* Calling PL/SQL stored procedures which contain clobs as input * parameters (PHP 4 >= 4.0.6). * Example PL/SQL stored procedure signature is: @@ -813,6 +838,7 @@ $clob->free(); OCIFreeStatement($stmt); ?> +]]> </programlisting> </example> </refsect1> @@ -839,24 +865,28 @@ <example> <title>OCIRowCount</title> <programlisting> -<?php - print "<HTML><PRE>"; +<![CDATA[ +<?php + print "<HTML><PRE>"; $conn = OCILogon("scott","tiger"); $stmt = OCIParse($conn,"create table emp2 as select * from emp"); OCIExecute($stmt); - print OCIRowCount($stmt) . " rows inserted.<BR>"; + print OCIRowCount($stmt) . " rows inserted.<BR>"; OCIFreeStatement($stmt); $stmt = OCIParse($conn,"delete from emp2"); OCIExecute($stmt); - print OCIRowCount($stmt) . " rows deleted.<BR>"; + print OCIRowCount($stmt) . " rows deleted.<BR>"; OCICommit($conn); OCIFreeStatement($stmt); $stmt = OCIParse($conn,"drop table emp2"); OCIExecute($stmt); OCIFreeStatement($stmt); OCILogOff($conn); - print "</PRE></HTML>"; -?> </programlisting></example> + print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> </para> </refsect1> </refentry> @@ -883,15 +913,16 @@ <example> <title>OCINumCols</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); while ( OCIFetch($stmt) ) { print "\n"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_value = OCIResult($stmt,$i); print $column_name . ': ' . $column_value . "\n"; @@ -900,9 +931,10 @@ } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </refsect1> @@ -1025,7 +1057,8 @@ <example> <title>OCIFetchStatement</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIFetchStatement example mbritton@verinet.com (990624) */ $conn = OCILogon("scott","tiger"); @@ -1036,31 +1069,32 @@ $nrows = OCIFetchStatement($stmt,$results); if ( $nrows > 0 ) { - print "<TABLE BORDER=\"1\">\n"; - print "<TR>\n"; + print "<TABLE BORDER=\"1\">\n"; + print "<TR>\n"; while ( list( $key, $val ) = each( $results ) ) { - print "<TH>$key</TH>\n"; + print "<TH>$key</TH>\n"; } - print "</TR>\n"; + print "</TR>\n"; - for ( $i = 0; $i < $nrows; $i++ ) { + for ( $i = 0; $i < $nrows; $i++ ) { reset($results); - print "<TR>\n"; + print "<TR>\n"; while ( $column = each($results) ) { $data = $column['value']; - print "<TD>$data[$i]</TD>\n"; + print "<TD>$data[$i]</TD>\n"; } - print "</TR>\n"; + print "</TR>\n"; } - print "</TABLE>\n"; + print "</TABLE>\n"; } else { - echo "No data found<BR>\n"; + echo "No data found<BR>\n"; } -print "$nrows Records Selected<BR>\n"; +print "$nrows Records Selected<BR>\n"; OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </refsect1> @@ -1112,33 +1146,35 @@ <example> <title>OCIColumnName</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1174,34 +1210,36 @@ <example> <title>OCIColumnSize</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } - print "</TABLE>"; + print "</TABLE>"; OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1236,33 +1274,35 @@ <example> <title>OCIColumnType</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1292,11 +1332,13 @@ <example> <title>OCIServerVersion</title> <programlisting> -<?php +<![CDATA[ +<?php $conn = OCILogon("scott","tiger"); print "Server Version: " . OCIServerVersion($conn); OCILogOff($conn); ?> +]]> </programlisting> </example> </para> @@ -1335,19 +1377,21 @@ <example> <title>Code examples</title> <programlisting> -<?php - print "<HTML><PRE>"; +<![CDATA[ +<?php + print "<HTML><PRE>"; $conn = OCILogon("scott","tiger"); $sql = "delete from emp where deptno = 10"; $stmt = OCIParse($conn,$sql); if ( OCIStatementType($stmt) == "DELETE" ) { - die "You are not allowed to delete from this table<BR>"; + die "You are not allowed to delete from this table<BR>"; } OCILogoff($conn); - print "</PRE></HTML>"; + print "</PRE></HTML>"; ?> +]]> </programlisting> </example> </para> @@ -1377,18 +1421,19 @@ <example> <title>Using a REF CURSOR from a stored procedure</title> <programlisting> -<?php +<![CDATA[ +<?php // suppose your stored procedure info.output returns a ref cursor in :data $conn = OCILogon("scott","tiger"); $curs = OCINewCursor($conn); $stmt = OCIParse($conn,"begin info.output(:data); end;"); -ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR); +ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR); ociexecute($stmt); ociexecute($curs); -while (OCIFetchInto($curs,&$data)) { +while (OCIFetchInto($curs,&$data)) { var_dump($data); } @@ -1396,6 +1441,7 @@ OCIFreeCursor($curs); OCILogoff($conn); ?> +]]> </programlisting> </example> </para> @@ -1403,39 +1449,41 @@ <example> <title>Using a REF CURSOR in a select statement</title> <programlisting> -<?php -print "<HTML><BODY>"; +<![CDATA[ +<?php +print "<HTML><BODY>"; $conn = OCILogon("scott","tiger"); $count_cursor = "CURSOR(select count(empno) num_emps from emp " . "where emp.deptno = dept.deptno) as EMPCNT from dept"; $stmt = OCIParse($conn,"select deptno,dname,$count_cursor"); ociexecute($stmt); -print "<TABLE BORDER=\"1\">"; -print "<TR>"; -print "<TH>DEPT NAME</TH>"; -print "<TH>DEPT #</TH>"; -print "<TH># EMPLOYEES</TH>"; -print "</TR>"; +print "<TABLE BORDER=\"1\">"; +print "<TR>"; +print "<TH>DEPT NAME</TH>"; +print "<TH>DEPT #</TH>"; +print "<TH># EMPLOYEES</TH>"; +print "</TR>"; while (OCIFetchInto($stmt,&$data,OCI_ASSOC)) { - print "<TR>"; + print "<TR>"; $dname = $data["DNAME"]; $deptno = $data["DEPTNO"]; - print "<TD>$dname</TD>"; - print "<TD>$deptno</TD>"; + print "<TD>$dname</TD>"; + print "<TD>$deptno</TD>"; ociexecute($data[ "EMPCNT" ]); while (OCIFetchInto($data[ "EMPCNT" ],&$subdata,OCI_ASSOC)) { $num_emps = $subdata["NUM_EMPS"]; - print "<TD>$num_emps</TD>"; + print "<TD>$num_emps</TD>"; } - print "</TR>"; + print "</TR>"; } -print "</TABLE>"; -print "</BODY></HTML>"; +print "</TABLE>"; +print "</BODY></HTML>"; OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/openssl.xml diff -u phpdoc/en/functions/openssl.xml:1.15 phpdoc/en/functions/openssl.xml:1.16 --- phpdoc/en/functions/openssl.xml:1.15 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/openssl.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <reference id="ref.openssl"> <title>OpenSSL functions</title> <titleabbrev>OpenSSL</titleabbrev> @@ -206,9 +206,11 @@ <example> <title><function>openssl_error_string</function> example</title> <programlisting role="php"> +<![CDATA[ // lets assume you just called an openssl function that failed while($msg = openssl_error_string) echo $msg . "<br>"; +]]> </programlisting> </example> </para> @@ -330,6 +332,7 @@ <example> <title><function>openssl_open</function> example</title> <programlisting role="php"> +<![CDATA[ // $sealed and $env_key are assumed to contain the sealed data // and our envelope key, both given to us by the sealer. @@ -347,6 +350,7 @@ // free the private key from memory openssl_free_key($pkeyid); +]]> </programlisting> </example> </para> @@ -395,6 +399,7 @@ <example> <title><function>openssl_seal</function> example</title> <programlisting role="php"> +<![CDATA[ // $data is assumed to contain the data to be sealed // fetch public keys for our recipients, and ready them @@ -415,6 +420,7 @@ // free the keys from memory openssl_free_key($pk1); openssl_free_key($pk2); +]]> </programlisting> </example> </para> @@ -456,6 +462,7 @@ <example> <title><function>openssl_sign</function> example</title> <programlisting role="php"> +<![CDATA[ // $data is assumed to contain the data to be signed // fetch private key from file and ready it @@ -469,6 +476,7 @@ // free the key from memory openssl_free_key($pkeyid); +]]> </programlisting> </example> </para> @@ -510,6 +518,7 @@ <example> <title><function>openssl_verify</function> example</title> <programlisting role="php"> +<![CDATA[ // $data and $signature are assumed to contain the data and the signature // fetch public key from certificate and ready it @@ -529,6 +538,7 @@ // free the key from memory openssl_free_key($pubkeyid); +]]> </programlisting> </example> </para> @@ -568,6 +578,7 @@ <example> <title><function>openssl_pkcs7_decrypt</function> example</title> <programlisting role="php"> +<![CDATA[ // $cert and $key are assumed to contain your personal certificate and private // key pair, and that you are the recipient of an S/MIME message $infilename = "encrypted.msg"; // this file holds your encrypted message @@ -577,7 +588,7 @@ echo "decrypted!"; else echo "failed to decrypt!"; - +]]> </programlisting> </example> </para> @@ -625,10 +636,11 @@ <example> <title><function>openssl_pkcs7_encrypt</function> example</title> <programlisting role="php"> +<![CDATA[ // the message you want to encrypt and send to your secret agent // in the field, known as nighthawk. You have his certificate // in the file nighthawk.pem -$data = <<<EOD +$data = <<<EOD Nighthawk, Top secret, for your eyes only! @@ -644,13 +656,14 @@ fclose($fp); // encrypt it if (openssl_pkcs7_encrypt("msg.txt", "enc.txt", "nighthawk.pem", - array("To" => "nighthawk@agent.com", // keyed syntax - "From: HQ <hq@cia.com>", // indexed syntax - "Subject" => "Eyes only"))) + array("To" => "nighthawk@agent.com", // keyed syntax + "From: HQ <hq@cia.com>", // indexed syntax + "Subject" => "Eyes only"))) { // message encrypted - send it! - exec(ini_get("sendmail_path") . " < enc.txt"); + exec(ini_get("sendmail_path") . " < enc.txt"); } +]]> </programlisting> </example> </para> @@ -710,9 +723,10 @@ <example> <title><function>openssl_pkcs7_sign</function> example</title> <programlisting role="php"> +<![CDATA[ // the message you want to sign so that recipient can be sure it was you that // sent it -$data = <<<EOD +$data = <<<EOD You have my authorization to spend $10,000 on dinner expenses. @@ -725,13 +739,14 @@ // encrypt it if (openssl_pkcs7_sign("msg.txt", "signed.txt", "mycert.pem", array("mycert.pem", "mypassphrase"), - array("To" => "joes@sales.com", // keyed syntax - "From: HQ <ceo@sales.com>", // indexed syntax - "Subject" => "Eyes only")) + array("To" => "joes@sales.com", // keyed syntax + "From: HQ <ceo@sales.com>", // indexed syntax + "Subject" => "Eyes only")) { // message signed - send it! exec(ini_get("sendmail_path") . " < signed.txt"); } +]]> </programlisting> </example> </para>
Index: phpdoc/en/functions/mcrypt.xml diff -u phpdoc/en/functions/mcrypt.xml:1.23 phpdoc/en/functions/mcrypt.xml:1.24 --- phpdoc/en/functions/mcrypt.xml:1.23 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/mcrypt.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <reference id="ref.mcrypt"> <title>Mcrypt Encryption Functions</title> <titleabbrev>mcrypt</titleabbrev> @@ -41,12 +41,14 @@ <example> <title>Encrypt an input value with TripleDES under 2.2.x in ECB mode</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $key = "this is a very secret key"; $input = "Let us meet at 9 o'clock at the secret place."; $encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT); -?> +?> +]]> </programlisting> </example> This example will give you the encrypted data as a string in @@ -58,7 +60,8 @@ <example> <title>Encrypt an input value with TripleDES under 2.4.x in ECB mode</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $key = "this is a very secret key"; $input = "Let us meet at 9 o'clock at the secret place."; @@ -67,7 +70,8 @@ mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); mcrypt_generic_end ($td); -?> +?> +]]> </programlisting> </example> This example will give you the encrypted data as a string in @@ -397,19 +401,23 @@ <example> <title><function>mcrypt_get_cipher_name</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $cipher = MCRYPT_TripleDES; print mcrypt_get_cipher_name ($cipher); -?> +?> +]]> </programlisting> - </example> - </para> - <para> - The above example will produce: - <programlisting> + <para> + The above example will produce: + <screen> +<![CDATA[ 3DES - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -524,11 +532,13 @@ <example> <title><function>mcrypt_create_iv</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $cipher = MCRYPT_TripleDES; $block_size = mcrypt_get_block_size ($cipher); $iv = mcrypt_create_iv ($block_size, MCRYPT_DEV_RANDOM); -?> +?> +]]> </programlisting> </example> </para> @@ -744,7 +754,7 @@ <paramdef>int <parameter>mode</parameter></paramdef> <paramdef>string <parameter>iv</parameter></paramdef> </funcprototype> - </funcsynopsis> + </funcsynopsis> <funcsynopsis> <funcprototype> <funcdef>string <function>mcrypt_ofb</function></funcdef> @@ -804,10 +814,10 @@ <funcprototype> <funcdef>array <function>mcrypt_list_algorithms</function></funcdef> <paramdef>string - <parameter> - <optional>lib_dir</optional> - </parameter> - </paramdef> + <parameter> + <optional>lib_dir</optional> + </parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> @@ -819,26 +829,28 @@ <function>mcrypt_list_algorithms</function> takes as optional parameter a directory which specifies the directory where all algorithms are located. If not specifies, the value of the - mcrypt.algorithms_dir php.ini directive is used. + mcrypt.algorithms_dir php.ini directive is used. </para> <para> <example> <title><function>mcrypt_list_algorithms</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $algorithms = mcrypt_list_algorithms ("/usr/local/lib/libmcrypt"); foreach ($algorithms as $cipher) { - echo $cipher."/n"; + echo $cipher."/n"; } -?> +?> +]]> </programlisting> + <para> + The above example will produce a list with all supported + algorithms in the "/usr/local/lib/libmcrypt" directory. + </para> </example> </para> - <para> - The above example will produce a list with all supported - algorithms in the "/usr/local/lib/libmcrypt" directory. - </para> </refsect1> </refentry> @@ -853,10 +865,10 @@ <funcprototype> <funcdef>array <function>mcrypt_list_modes</function></funcdef> <paramdef>string - <parameter> - <optional>lib_dir</optional> - </parameter> - </paramdef> + <parameter> + <optional>lib_dir</optional> + </parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> @@ -868,28 +880,30 @@ <function>mcrypt_list_modes</function> takes as optional parameter a directory which specifies the directory where all modes are located. If not specifies, the value of the - mcrypt.modes_dir php.ini directive is used. + mcrypt.modes_dir php.ini directive is used. </para> <para> <example> <title><function>mcrypt_list_modes</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $modes = mcrypt_list_modes (); foreach ($modes as $mode) { - echo "$mode </br>"; + echo "$mode <br/>"; } -?> +?> +]]> </programlisting> + <para> + The above example will produce a list with all supported + algorithms in the default mode directory. If it is not set + with the ini directive mcrypt.modes_dir, the default directory + of mcrypt is used (which is /usr/local/lib/libmcrypt). + </para> </example> </para> - <para> - The above example will produce a list with all supported - algorithms in the default mode directory. If it is not set - with the ini directive mcrypt.modes_dir, the default directory - of mcrypt is used (which is /usr/local/lib/libmcrypt). - </para> </refsect1> </refentry> @@ -995,7 +1009,8 @@ <example> <title><function>mcrypt_encrypt</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND); $key = "This is a very secret key"; $text = "Meet me at 11 o'clock behind the monument."; @@ -1003,14 +1018,19 @@ $crypttext = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv); echo strlen ($crypttext)."\n"; -?> +?> +]]> </programlisting> - </example> - The above example will print out: - <programlisting> + <para> + The above example will print out: + <screen> +<![CDATA[ 42 64 - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -1109,13 +1129,18 @@ <example> <title><function>mcrypt_module_open</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $td = mcrypt_module_open (MCRYPT_DES, "", MCRYPT_MODE_ECB, "/usr/lib/mcrypt-modes"); -?> +?> +]]> </programlisting> + <para> + The above example will try to open the DES cipher + from the default directory and the EBC mode from the directory + <filename>/usr/lib/mcrypt-modes</filename>. + </para> </example> - The above example will try to open the DES cipher from the default - directory and the EBC mode from the directory /usr/lib/mcrypt-modes. </para> </refsect1> </refentry> @@ -1202,7 +1227,8 @@ <example> <title><function>mdecrypt_generic</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $iv_size = mcrypt_enc_get_iv_size ($td)); $iv = @mcrypt_create_iv ($iv_size, MCRYPT_RAND); @@ -1216,11 +1242,14 @@ echo "ok"; else echo "error"; -?> +?> +]]> </programlisting> + <para> + The above example shows how to check if the data before the + encryption is the same as the data after the decryption. + </para> </example> - The above example shows how to check if the data before the - encryption is the same as the data after the decryption. </para> </refsect1> </refentry> Index: phpdoc/en/functions/mhash.xml diff -u phpdoc/en/functions/mhash.xml:1.18 phpdoc/en/functions/mhash.xml:1.19 --- phpdoc/en/functions/mhash.xml:1.18 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/mhash.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.mhash"> <title>Mhash Functions</title> <titleabbrev>mhash</titleabbrev> @@ -28,20 +28,26 @@ <example> <title>Compute the MD5 digest and hmac and print it out as hex</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $input = "what do ya want for nothing?"; $hash = mhash (MHASH_MD5, $input); print "The hash is ".bin2hex ($hash)."\n<br>"; $hash = mhash (MHASH_MD5, $input, "Jefe"); print "The hmac is ".bin2hex ($hash)."\n<br>"; -?> +?> +]]> </programlisting> - </example> - This will produce: - <programlisting> + <para> + This will produce: + <screen> +<![CDATA[ The hash is d03cb659cbf9192dcd066272249f8412 The hmac is 750c783e6ab0b503eaa86e310a5db738 - </programlisting> +]]> + </screen> + </para> + </example> For a complete list of supported hashes, refer to the documentation of mhash. The general rule is that you can access the hash algorithm from PHP with MHASH_HASHNAME. For example, to @@ -137,17 +143,23 @@ <example> <title><function>mhash_get_hash_name</function> Example</title> <programlisting> -<?php +<![CDATA[ +<?php $hash = MHASH_MD5; print mhash_get_hash_name ($hash); -?> +?> +]]> </programlisting> + <para> + The above example will print out: + <screen> +<![CDATA[ + MD5 +]]> + </screen> + </para> </example> - The above example will print out: - <programlisting> -MD5 - </programlisting> </para> </refsect1> </refentry> @@ -198,16 +210,18 @@ <example> <title>Traversing all hashes</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $nr = mhash_count(); -for ($i = 0; $i <= $nr; $i++) { +for ($i = 0; $i <= $nr; $i++) { echo sprintf ("The blocksize of %s is %d\n", mhash_get_hash_name ($i), mhash_get_block_size ($i)); } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/ming.xml diff -u phpdoc/en/functions/ming.xml:1.26 phpdoc/en/functions/ming.xml:1.27 --- phpdoc/en/functions/ming.xml:1.26 Sat Nov 10 18:46:30 2001 +++ phpdoc/en/functions/ming.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.26 $ --> +<!-- $Revision: 1.27 $ --> <reference id="ref.ming"> <title>Ming functions for Flash</title> <titleabbrev>Ming (flash)</titleabbrev> @@ -60,13 +60,17 @@ <sect2 id="ming.install.php.unix"> <title>built into php (unix)</title> <para> + <informalexample> <literallayout> - mkdir <phpdir>/ext/ming - cp php_ext/* <phpdir>/ext/ming - cd <phpdir> +<![CDATA[ + mkdir <phpdir>/ext/ming + cp php_ext/* <phpdir>/ext/ming + cd <phpdir> ./buildconf - ./configure --with-ming <other config options> - </literallayout> + ./configure --with-ming <other config options> +]]> + </literallayout> + </informalexample> Build and install php as usual, Restart web server if necessary </para> @@ -217,9 +221,11 @@ <function>swfmovie->output</function> dumps your lovingly prepared movie out. In PHP, preceding this with the command <programlisting role="php"> -<?php +<![CDATA[ +<?php header('Content-type: application/x-shockwave-flash'); -?> +?> +]]> </programlisting> convinces the browser to display this as a flash movie. </para> @@ -473,18 +479,20 @@ <example> <title><function>swfmovie->streammp3</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setRate(12.0); - $m->streamMp3("distortobass.mp3"); -// use your own MP3 + $m->setRate(12.0); + $m->streamMp3("distortobass.mp3"); + // use your own MP3 // 11.85 seconds at 12.0 fps = 142 frames - $m->setFrames(142); + $m->setFrames(142); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -689,15 +697,16 @@ <example> <title><function>swfdisplayitem->rotateto</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $thetext = "ming!"; $f = new SWFFont("Bauhaus 93.fdb"); $m = new SWFMovie(); - $m->setRate(24.0); - $m->setDimension(2400, 1600); - $m->setBackground(0xff, 0xff, 0xff); + $m->setRate(24.0); + $m->setDimension(2400, 1600); + $m->setBackground(0xff, 0xff, 0xff); // functions with huge numbers of arbitrary // arguments are always a good idea! Really! @@ -707,23 +716,23 @@ global $f, $m; $t = new SWFText(); - $t->setFont($f); - $t->setColor($r, $g, $b, $a); - $t->setHeight(960); - $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); - $t->addString($string); + $t->setFont($f); + $t->setColor($r, $g, $b, $a); + $t->setHeight(960); + $t->moveTo(-($f->getWidth($string))/2, $f->getAscent()/2); + $t->addString($string); // we can add properties just like a normal php var, // as long as the names aren't already used. - // e.g., we can't set $i->scale, because that's a function + // e.g., we can't set $i->scale, because that's a function - $i = $m->add($t); - $i->x = $x; - $i->y = $y; - $i->rot = $rot; - $i->s = $scale; - $i->rotateTo($rot); - $i->scale($scale, $scale); + $i = $m->add($t); + $i->x = $x; + $i->y = $y; + $i->rot = $rot; + $i->s = $scale; + $i->rotateTo($rot); + $i->scale($scale, $scale); // but the changes are local to the function, so we have to // return the changed object. kinda weird.. @@ -733,15 +742,15 @@ function step($i) { - $oldrot = $i->rot; - $i->rot = 19*$i->rot/20; - $i->x = (19*$i->x + 1200)/20; - $i->y = (19*$i->y + 800)/20; - $i->s = (19*$i->s + 1.0)/20; - - $i->rotateTo($i->rot); - $i->scaleTo($i->s, $i->s); - $i->moveTo($i->x, $i->y); + $oldrot = $i->rot; + $i->rot = 19*$i->rot/20; + $i->x = (19*$i->x + 1200)/20; + $i->y = (19*$i->y + 800)/20; + $i->s = (19*$i->s + 1.0)/20; + + $i->rotateTo($i->rot); + $i->scaleTo($i->s, $i->s); + $i->moveTo($i->x, $i->y); return $i; } @@ -752,18 +761,19 @@ $i2 = text(0x00, 0x33, 0xff, 0x7f, -560, 1200, 800, 0.04, $thetext); $i3 = text(0xff, 0xff, 0xff, 0x9f, 180, 1200, 800, 0.001, $thetext); - for($i=1; $i<=100; ++$i) + for($i=1; $i<=100; ++$i) { $i1 = step($i1); $i2 = step($i2); $i3 = step($i3); - $m->nextFrame(); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1059,63 +1069,65 @@ <example> <title><function>swfdisplayitem->setname</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0xff, 0xff); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0xff, 0xff, 0xff); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0xff, 0xff, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape1(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(0.16, 0xff, 0xff, 0xff); + $g->addEntry(0.32, 0, 0, 0); + $g->addEntry(0.48, 0xff, 0xff, 0xff); + $g->addEntry(0.64, 0, 0, 0); + $g->addEntry(0.80, 0xff, 0xff, 0xff); + $g->addEntry(1.00, 0, 0, 0); + + $s = $p->getShape1(); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.05); + $s->setLeftFill($f); + $s->movePenTo(-160, -120); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(0.16, 0xff, 0, 0); - $g->addEntry(0.32, 0, 0, 0); - $g->addEntry(0.48, 0, 0xff, 0); - $g->addEntry(0.64, 0, 0, 0); - $g->addEntry(0.80, 0, 0, 0xff); - $g->addEntry(1.00, 0, 0, 0); - - $s = $p->getShape2(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.05); - $f->skewXTo(1.0); - $s->setLeftFill($f); - $s->movePenTo(-160, -120); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(0.16, 0xff, 0, 0); + $g->addEntry(0.32, 0, 0, 0); + $g->addEntry(0.48, 0, 0xff, 0); + $g->addEntry(0.64, 0, 0, 0); + $g->addEntry(0.80, 0, 0, 0xff); + $g->addEntry(1.00, 0, 0, 0); + + $s = $p->getShape2(); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.05); + $f->skewXTo(1.0); + $s->setLeftFill($f); + $s->movePenTo(-160, -120); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); $m = new SWFMovie(); - $m->setDimension(320, 240); - $i = $m->add($p); - $i->moveTo(160, 120); + $m->setDimension(320, 240); + $i = $m->add($p); + $i->moveTo(160, 120); - for($n=0; $n<=1.001; $n+=0.01) + for($n=0; $n<=1.001; $n+=0.01) { - $i->setRatio($n); - $m->nextFrame(); + $i->setRatio($n); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1185,32 +1197,34 @@ <example> <title><function>swfdisplayitem->multcolor</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $b = new SWFBitmap("backyard.jpg"); // note use your own picture :-) $s = new SWFShape(); - $s->setRightFill($s->addFill($b)); - $s->drawLine($b->getWidth(), 0); - $s->drawLine(0, $b->getHeight()); - $s->drawLine(-$b->getWidth(), 0); - $s->drawLine(0, -$b->getHeight()); + $s->setRightFill($s->addFill($b)); + $s->drawLine($b->getWidth(), 0); + $s->drawLine(0, $b->getHeight()); + $s->drawLine(-$b->getWidth(), 0); + $s->drawLine(0, -$b->getHeight()); $m = new SWFMovie(); - $m->setDimension($b->getWidth(), $b->getHeight()); + $m->setDimension($b->getWidth(), $b->getHeight()); - $i = $m->add($s); + $i = $m->add($s); - for($n=0; $n<=20; ++$n) + for($n=0; $n<=20; ++$n) { - $i->multColor(1.0-$n/10, 1.0, 1.0); - $i->addColor(0xff*$n/20, 0, 0); - $m->nextFrame(); + $i->multColor(1.0-$n/10, 1.0, 1.0); + $i->addColor(0xff*$n/20, 0, 0); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1249,24 +1263,26 @@ <example> <title><function>swfshape</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setLine(40, 0x7f, 0, 0); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(200, 200); - $s->drawLineTo(6200, 200); - $s->drawLineTo(6200, 4600); - $s->drawCurveTo(200, 4600, 200, 200); + $s->setLine(40, 0x7f, 0, 0); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(200, 200); + $s->drawLineTo(6200, 200); + $s->drawLineTo(6200, 4600); + $s->drawCurveTo(200, 4600, 200, 200); $m = new SWFMovie(); - $m->setDimension(6400, 4800); - $m->setRate(12.0); - $m->add($s); - $m->nextFrame(); + $m->setDimension(6400, 4800); + $m->setRate(12.0); + $m->add($s); + $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1312,56 +1328,58 @@ <example> <title><function>swfshape->setline</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f1 = $s->addFill(0xff, 0, 0); - $f2 = $s->addFill(0xff, 0x7f, 0); - $f3 = $s->addFill(0xff, 0xff, 0); - $f4 = $s->addFill(0, 0xff, 0); - $f5 = $s->addFill(0, 0, 0xff); + $f1 = $s->addFill(0xff, 0, 0); + $f2 = $s->addFill(0xff, 0x7f, 0); + $f3 = $s->addFill(0xff, 0xff, 0); + $f4 = $s->addFill(0, 0xff, 0); + $f5 = $s->addFill(0, 0, 0xff); // bug: have to declare all line styles before you use them - $s->setLine(40, 0x7f, 0, 0); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->setLine(40, 0, 0x7f, 0); - $s->setLine(40, 0, 0, 0x7f); + $s->setLine(40, 0x7f, 0, 0); + $s->setLine(40, 0x7f, 0x3f, 0); + $s->setLine(40, 0x7f, 0x7f, 0); + $s->setLine(40, 0, 0x7f, 0); + $s->setLine(40, 0, 0, 0x7f); $f = new SWFFont('Techno.fdb'); - $s->setRightFill($f1); - $s->setLine(40, 0x7f, 0, 0); - $s->drawGlyph($f, '!'); - $s->movePen($f->getWidth('!'), 0); - - $s->setRightFill($f2); - $s->setLine(40, 0x7f, 0x3f, 0); - $s->drawGlyph($f, '#'); - $s->movePen($f->getWidth('#'), 0); - - $s->setRightFill($f3); - $s->setLine(40, 0x7f, 0x7f, 0); - $s->drawGlyph($f, '%'); - $s->movePen($f->getWidth('%'), 0); - - $s->setRightFill($f4); - $s->setLine(40, 0, 0x7f, 0); - $s->drawGlyph($f, '*'); - $s->movePen($f->getWidth('*'), 0); - - $s->setRightFill($f5); - $s->setLine(40, 0, 0, 0x7f); - $s->drawGlyph($f, '@'); + $s->setRightFill($f1); + $s->setLine(40, 0x7f, 0, 0); + $s->drawGlyph($f, '!'); + $s->movePen($f->getWidth('!'), 0); + + $s->setRightFill($f2); + $s->setLine(40, 0x7f, 0x3f, 0); + $s->drawGlyph($f, '#'); + $s->movePen($f->getWidth('#'), 0); + + $s->setRightFill($f3); + $s->setLine(40, 0x7f, 0x7f, 0); + $s->drawGlyph($f, '%'); + $s->movePen($f->getWidth('%'), 0); + + $s->setRightFill($f4); + $s->setLine(40, 0, 0x7f, 0); + $s->drawGlyph($f, '*'); + $s->movePen($f->getWidth('*'), 0); + + $s->setRightFill($f5); + $s->setLine(40, 0, 0, 0x7f); + $s->drawGlyph($f, '@'); $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setRate(12.0); - $i = $m->add($s); - $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); + $m->setDimension(3000,2000); + $m->setRate(12.0); + $i = $m->add($s); + $i->moveTo(1500-$f->getWidth("!#%*@")/2, 1000+$f->getAscent()/2); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1441,54 +1459,56 @@ <example> <title><function>swfshape->addfill</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); $b = new SWFBitmap("alphafill.jpg"); // use your own bitmap - $width = $b->getWidth(); - $height = $b->getHeight(); + $width = $b->getWidth(); + $height = $b->getHeight(); - $s = $p->getShape1(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); - $f->moveTo(-$width/2, -$height/4); - $f->scaleTo(1.0, 0.5); - $s->setLeftFill($f); - $s->movePenTo(-$width/2, -$height/4); - $s->drawLine($width, 0); - $s->drawLine(0, $height/2); - $s->drawLine(-$width, 0); - $s->drawLine(0, -$height/2); + $s = $p->getShape1(); + $f = $s->addFill($b, SWFFILL_TILED_BITMAP); + $f->moveTo(-$width/2, -$height/4); + $f->scaleTo(1.0, 0.5); + $s->setLeftFill($f); + $s->movePenTo(-$width/2, -$height/4); + $s->drawLine($width, 0); + $s->drawLine(0, $height/2); + $s->drawLine(-$width, 0); + $s->drawLine(0, -$height/2); - $s = $p->getShape2(); - $f = $s->addFill($b, SWFFILL_TILED_BITMAP); + $s = $p->getShape2(); + $f = $s->addFill($b, SWFFILL_TILED_BITMAP); // these two have no effect! - $f->moveTo(-$width/4, -$height/2); - $f->scaleTo(0.5, 1.0); + $f->moveTo(-$width/4, -$height/2); + $f->scaleTo(0.5, 1.0); - $s->setLeftFill($f); - $s->movePenTo(-$width/4, -$height/2); - $s->drawLine($width/2, 0); - $s->drawLine(0, $height); - $s->drawLine(-$width/2, 0); - $s->drawLine(0, -$height); + $s->setLeftFill($f); + $s->movePenTo(-$width/4, -$height/2); + $s->drawLine($width/2, 0); + $s->drawLine(0, $height); + $s->drawLine(-$width/2, 0); + $s->drawLine(0, -$height); $m = new SWFMovie(); - $m->setDimension($width, $height); - $i = $m->add($p); - $i->moveTo($width/2, $height/2); + $m->setDimension($width, $height); + $i = $m->add($p); + $i->moveTo($width/2, $height/2); - for($n=0; $n<1.001; $n+=0.03) + for($n=0; $n<1.001; $n+=0.03) { - $i->setRatio($n); - $m->nextFrame(); + $i->setRatio($n); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1804,50 +1824,52 @@ <example> <title><function>swfgradient</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setDimension(320, 240); + $m->setDimension(320, 240); $s = new SWFShape(); // first gradient- black to white $g = new SWFGradient(); - $g->addEntry(0.0, 0, 0, 0); - $g->addEntry(1.0, 0xff, 0xff, 0xff); + $g->addEntry(0.0, 0, 0, 0); + $g->addEntry(1.0, 0xff, 0xff, 0xff); - $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); - $f->scaleTo(0.01); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $f = $s->addFill($g, SWFFILL_LINEAR_GRADIENT); + $f->scaleTo(0.01); + $f->moveTo(160, 120); + $s->setRightFill($f); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); - $m->add($s); + $m->add($s); $s = new SWFShape(); // second gradient- radial gradient from red to transparent $g = new SWFGradient(); - $g->addEntry(0.0, 0xff, 0, 0, 0xff); - $g->addEntry(1.0, 0xff, 0, 0, 0); + $g->addEntry(0.0, 0xff, 0, 0, 0xff); + $g->addEntry(1.0, 0xff, 0, 0, 0); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.005); - $f->moveTo(160, 120); - $s->setRightFill($f); - $s->drawLine(320, 0); - $s->drawLine(0, 240); - $s->drawLine(-320, 0); - $s->drawLine(0, -240); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.005); + $f->moveTo(160, 120); + $s->setRightFill($f); + $s->drawLine(320, 0); + $s->drawLine(0, 240); + $s->drawLine(-320, 0); + $s->drawLine(0, -240); - $m->add($s); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1925,23 +1947,25 @@ <example> <title>Import PNG files</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f = $s->addFill(new SWFBitmap("png.dbl")); - $s->setRightFill($f); + $f = $s->addFill(new SWFBitmap("png.dbl")); + $s->setRightFill($f); - $s->drawLine(32, 0); - $s->drawLine(0, 32); - $s->drawLine(-32, 0); - $s->drawLine(0, -32); + $s->drawLine(32, 0); + $s->drawLine(0, 32); + $s->drawLine(-32, 0); + $s->drawLine(0, -32); $m = new SWFMovie(); - $m->setDimension(32, 32); - $m->add($s); + $m->setDimension(32, 32); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -1950,53 +1974,55 @@ <example> <title><function>swfbitmap</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); // .msk file generated with "gif2mask" utility - $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); - $s->setRightFill($f); + $f = $s->addFill(new SWFBitmap("alphafill.jpg", "alphafill.msk")); + $s->setRightFill($f); - $s->drawLine(640, 0); - $s->drawLine(0, 480); - $s->drawLine(-640, 0); - $s->drawLine(0, -480); + $s->drawLine(640, 0); + $s->drawLine(0, 480); + $s->drawLine(-640, 0); + $s->drawLine(0, -480); $c = new SWFShape(); - $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); - $c->drawLine(40, 0); - $c->drawLine(0, 40); - $c->drawLine(-40, 0); - $c->drawLine(0, -40); + $c->setRightFill($c->addFill(0x99, 0x99, 0x99)); + $c->drawLine(40, 0); + $c->drawLine(0, 40); + $c->drawLine(-40, 0); + $c->drawLine(0, -40); $m = new SWFMovie(); - $m->setDimension(640, 480); - $m->setBackground(0xcc, 0xcc, 0xcc); + $m->setDimension(640, 480); + $m->setBackground(0xcc, 0xcc, 0xcc); // draw checkerboard background - for($y=0; $y<480; $y+=40) + for($y=0; $y<480; $y+=40) { - for($x=0; $x<640; $x+=80) + for($x=0; $x<640; $x+=80) { - $i = $m->add($c); - $i->moveTo($x, $y); + $i = $m->add($c); + $i->moveTo($x, $y); } $y+=40; - for($x=40; $x<640; $x+=80) + for($x=40; $x<640; $x+=80) { - $i = $m->add($c); - $i->moveTo($x, $y); + $i = $m->add($c); + $i->moveTo($x, $y); } } - $m->add($s); + $m->add($s); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2224,47 +2250,49 @@ <example> <title><function>swfmorph</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $p = new SWFMorph(); - $s = $p->getShape1(); - $s->setLine(0,0,0,0); + $s = $p->getShape1(); + $s->setLine(0,0,0,0); /* Note that this is backwards from normal shapes (left instead of right). I have no idea why, but this seems to work.. */ - $s->setLeftFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(-1000,-1000); - $s->drawLine(2000,0); - $s->drawLine(0,2000); - $s->drawLine(-2000,0); - $s->drawLine(0,-2000); - - $s = $p->getShape2(); - $s->setLine(60,0,0,0); - $s->setLeftFill($s->addFill(0, 0, 0xff)); - $s->movePenTo(0,-1000); - $s->drawLine(1000,1000); - $s->drawLine(-1000,1000); - $s->drawLine(-1000,-1000); - $s->drawLine(1000,-1000); + $s->setLeftFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(-1000,-1000); + $s->drawLine(2000,0); + $s->drawLine(0,2000); + $s->drawLine(-2000,0); + $s->drawLine(0,-2000); + + $s = $p->getShape2(); + $s->setLine(60,0,0,0); + $s->setLeftFill($s->addFill(0, 0, 0xff)); + $s->movePenTo(0,-1000); + $s->drawLine(1000,1000); + $s->drawLine(-1000,1000); + $s->drawLine(-1000,-1000); + $s->drawLine(1000,-1000); $m = new SWFMovie(); - $m->setDimension(3000,2000); - $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(3000,2000); + $m->setBackground(0xff, 0xff, 0xff); - $i = $m->add($p); - $i->moveTo(1500,1000); + $i = $m->add($p); + $i->moveTo(1500,1000); - for($r=0.0; $r<=1.0; $r+=0.1) + for($r=0.0; $r<=1.0; $r+=0.1) { - $i->setRatio($r); - $m->nextFrame(); + $i->setRatio($r); + $m->nextFrame(); } header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2347,23 +2375,25 @@ <example> <title><function>swftext</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = new SWFFont("Techno.fdb"); $t = new SWFText(); - $t->setFont($f); - $t->moveTo(200, 2400); - $t->setColor(0xff, 0xff, 0); - $t->setHeight(1200); - $t->addString("PHP generates Flash with Ming!!"); + $t->setFont($f); + $t->moveTo(200, 2400); + $t->setColor(0xff, 0xff, 0); + $t->setHeight(1200); + $t->addString("PHP generates Flash with Ming!!"); $m = new SWFMovie(); - $m->setDimension(5400, 3600); + $m->setDimension(5400, 3600); - $m->add($t); + $m->add($t); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -2564,9 +2594,11 @@ the movie player. The fonts _serif, _sans, and _typewriter should always be available. For example: <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = newSWFFont("_sans"); -?> +?> +]]> </programlisting> will give you the standard sans-serif font, probably the same as what you'd get with <literal><font name="sans-serif"></literal> in HTML. @@ -2665,9 +2697,11 @@ Flags are combined with the bitwise <link linkend="language.operators.bitwise">OR</link> operation. For example, <programlisting role="php"> -<?php +<![CDATA[ +<?php $t = newSWFTextField(SWFTEXTFIELD_PASSWORD | SWFTEXTFIELD_NOEDIT); -?> +?> +]]> </programlisting> creates a totally useless non-editable password field. </para> @@ -2978,40 +3012,42 @@ <example> <title><function>swfsprite</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->movePenTo(-500,-500); - $s->drawLineTo(500,-500); - $s->drawLineTo(500,500); - $s->drawLineTo(-500,500); - $s->drawLineTo(-500,-500); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->movePenTo(-500,-500); + $s->drawLineTo(500,-500); + $s->drawLineTo(500,500); + $s->drawLineTo(-500,500); + $s->drawLineTo(-500,-500); $p = new SWFSprite(); - $i = $p->add($s); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); - $i->rotate(15); - $p->nextFrame(); + $i = $p->add($s); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); + $i->rotate(15); + $p->nextFrame(); $m = new SWFMovie(); - $i = $m->add($p); - $i->moveTo(1500,1000); - $i->setName("blah"); + $i = $m->add($p); + $i->moveTo(1500,1000); + $i->setName("blah"); - $m->setBackground(0xff, 0xff, 0xff); - $m->setDimension(3000,2000); + $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(3000,2000); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3144,7 +3180,8 @@ <example> <title><function>swfbutton</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $f = new SWFFont("_serif"); @@ -3155,22 +3192,22 @@ global $f; $t = new SWFTextField(); - $t->setFont($f); - $t->addString($string); - $t->setHeight(200); - $t->setBounds(3200,200); + $t->setFont($f); + $t->addString($string); + $t->setHeight(200); + $t->setBounds(3200,200); return $t; } function addLabel($string) { global $p; - $i = $p->add(label($string)); - $p->nextFrame(); - $p->remove($i); + $i = $p->add(label($string)); + $p->nextFrame(); + $p->remove($i); } - $p->add(new SWFAction("stop();")); + $p->add(new SWFAction("stop();")); addLabel("NO ACTION"); addLabel("SWFBUTTON_MOUSEUP"); addLabel("SWFBUTTON_MOUSEDOWN"); @@ -3183,54 +3220,55 @@ function rect($r, $g, $b) { $s = new SWFShape(); - $s->setRightFill($s->addFill($r, $g, $b)); - $s->drawLine(600,0); - $s->drawLine(0,600); - $s->drawLine(-600,0); - $s->drawLine(0,-600); + $s->setRightFill($s->addFill($r, $g, $b)); + $s->drawLine(600,0); + $s->drawLine(0,600); + $s->drawLine(-600,0); + $s->drawLine(0,-600); return $s; } $b = new SWFButton(); - $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT); - $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER); - $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN); + $b->addShape(rect(0xff, 0, 0), SWFBUTTON_UP | SWFBUTTON_HIT); + $b->addShape(rect(0, 0xff, 0), SWFBUTTON_OVER); + $b->addShape(rect(0, 0, 0xff), SWFBUTTON_DOWN); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(1);"), SWFBUTTON_MOUSEUP); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(2);"), SWFBUTTON_MOUSEDOWN); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(3);"), SWFBUTTON_MOUSEOVER); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(4);"), SWFBUTTON_MOUSEOUT); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(5);"), SWFBUTTON_MOUSEUPOUTSIDE); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(6);"), SWFBUTTON_DRAGOVER); - $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"), + $b->addAction(new SWFAction("setTarget('/label'); gotoFrame(7);"), SWFBUTTON_DRAGOUT); $m = new SWFMovie(); - $m->setDimension(4000,3000); + $m->setDimension(4000,3000); - $i = $m->add($p); - $i->setName("label"); - $i->moveTo(400,1900); + $i = $m->add($p); + $i->setName("label"); + $i->moveTo(400,1900); - $i = $m->add($b); - $i->moveTo(400,900); + $i = $m->add($b); + $i->moveTo(400,900); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3240,36 +3278,38 @@ <example> <title><function>swfbutton->addaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $s->setRightFill($s->addFill(0xff, 0, 0)); - $s->drawLine(1000,0); - $s->drawLine(0,1000); - $s->drawLine(-1000,0); - $s->drawLine(0,-1000); + $s->setRightFill($s->addFill(0xff, 0, 0)); + $s->drawLine(1000,0); + $s->drawLine(0,1000); + $s->drawLine(-1000,0); + $s->drawLine(0,-1000); $b = new SWFButton(); - $b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); + $b->addShape($s, SWFBUTTON_HIT | SWFBUTTON_UP | SWFBUTTON_DOWN | SWFBUTTON_OVER); - $b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse + $b->addAction(new SWFAction("startDrag('/test', 0);"), // '0' means don't lock to mouse SWFBUTTON_MOUSEDOWN); - $b->addAction(new SWFAction("stopDrag();"), + $b->addAction(new SWFAction("stopDrag();"), SWFBUTTON_MOUSEUP | SWFBUTTON_MOUSEUPOUTSIDE); $p = new SWFSprite(); - $p->add($b); - $p->nextFrame(); + $p->add($b); + $p->nextFrame(); $m = new SWFMovie(); - $i = $m->add($p); - $i->setName('test'); - $i->moveTo(1000,1000); + $i = $m->add($p); + $i->setName('test'); + $i->moveTo(1000,1000); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3870,45 +3910,47 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $s = new SWFShape(); - $f = $s->addFill(0xff, 0, 0); - $s->setRightFill($f); + $f = $s->addFill(0xff, 0, 0); + $s->setRightFill($f); - $s->movePenTo(-500,-500); - $s->drawLineTo(500,-500); - $s->drawLineTo(500,500); - $s->drawLineTo(-500,500); - $s->drawLineTo(-500,-500); + $s->movePenTo(-500,-500); + $s->drawLineTo(500,-500); + $s->drawLineTo(500,500); + $s->drawLineTo(-500,500); + $s->drawLineTo(-500,-500); $p = new SWFSprite(); - $i = $p->add($s); - $i->setDepth(1); - $p->nextFrame(); + $i = $p->add($s); + $i->setDepth(1); + $p->nextFrame(); - for($n=0; $n<5; ++$n) + for($n=0; $n<5; ++$n) { - $i->rotate(-15); - $p->nextFrame(); + $i->rotate(-15); + $p->nextFrame(); } $m = new SWFMovie(); - $m->setBackground(0xff, 0xff, 0xff); - $m->setDimension(6000,4000); + $m->setBackground(0xff, 0xff, 0xff); + $m->setDimension(6000,4000); - $i = $m->add($p); - $i->setDepth(1); - $i->moveTo(-500,2000); - $i->setName("box"); - - $m->add(new SWFAction("/box.x += 3;")); - $m->nextFrame(); - $m->add(new SWFAction("gotoFrame(0); play();")); - $m->nextFrame(); + $i = $m->add($p); + $i->setDepth(1); + $i->moveTo(-500,2000); + $i->setName("box"); + + $m->add(new SWFAction("/box.x += 3;")); + $m->nextFrame(); + $m->add(new SWFAction("gotoFrame(0); play();")); + $m->nextFrame(); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -3917,75 +3959,76 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setRate(36.0); - $m->setDimension(1200, 800); - $m->setBackground(0, 0, 0); + $m->setRate(36.0); + $m->setDimension(1200, 800); + $m->setBackground(0, 0, 0); /* mouse tracking sprite - empty, but follows mouse so we can get its x and y coordinates */ - $i = $m->add(new SWFSprite()); - $i->setName('mouse'); + $i = $m->add(new SWFSprite()); + $i->setName('mouse'); - $m->add(new SWFAction(" + $m->add(new SWFAction(" startDrag('/mouse', 1); /* '1' means lock sprite to the mouse */ ")); /* might as well turn off antialiasing, since these are just squares. */ - $m->add(new SWFAction(" + $m->add(new SWFAction(" this.quality = 0; ")); /* morphing box */ $r = new SWFMorph(); - $s = $r->getShape1(); + $s = $r->getShape1(); /* Note this is backwards from normal shapes. No idea why. */ - $s->setLeftFill($s->addFill(0xff, 0xff, 0xff)); - $s->movePenTo(-40, -40); - $s->drawLine(80, 0); - $s->drawLine(0, 80); - $s->drawLine(-80, 0); - $s->drawLine(0, -80); - - $s = $r->getShape2(); - - $s->setLeftFill($s->addFill(0x00, 0x00, 0x00)); - $s->movePenTo(-1, -1); - $s->drawLine(2, 0); - $s->drawLine(0, 2); - $s->drawLine(-2, 0); - $s->drawLine(0, -2); + $s->setLeftFill($s->addFill(0xff, 0xff, 0xff)); + $s->movePenTo(-40, -40); + $s->drawLine(80, 0); + $s->drawLine(0, 80); + $s->drawLine(-80, 0); + $s->drawLine(0, -80); + + $s = $r->getShape2(); + + $s->setLeftFill($s->addFill(0x00, 0x00, 0x00)); + $s->movePenTo(-1, -1); + $s->drawLine(2, 0); + $s->drawLine(0, 2); + $s->drawLine(-2, 0); + $s->drawLine(0, -2); /* sprite container for morphing box - this is just a timeline w/ the box morphing */ $box = new SWFSprite(); - $box->add(new SWFAction(" + $box->add(new SWFAction(" stop(); ")); - $i = $box->add($r); + $i = $box->add($r); - for($n=0; $n<=20; ++$n) + for($n=0; $n<=20; ++$n) { - $i->setRatio($n/20); - $box->nextFrame(); + $i->setRatio($n/20); + $box->nextFrame(); } /* this container sprite allows us to use the same action code many times */ $cell = new SWFSprite(); - $i = $cell->add($box); - $i->setName('box'); + $i = $cell->add($box); + $i->setName('box'); - $cell->add(new SWFAction(" + $cell->add(new SWFAction(" setTarget('box'); @@ -3996,31 +4039,31 @@ ")); - $cell->nextFrame(); - $cell->add(new SWFAction(" + $cell->nextFrame(); + $cell->add(new SWFAction(" gotoFrame(0); play(); ")); - $cell->nextFrame(); + $cell->nextFrame(); /* finally, add a bunch of the cells to the movie */ - for($x=0; $x<12; ++$x) + for($x=0; $x<12; ++$x) { - for($y=0; $y<8; ++$y) + for($y=0; $y<8; ++$y) { - $i = $m->add($cell); - $i->moveTo(100*$x+50, 100*$y+50); + $i = $m->add($cell); + $i->moveTo(100*$x+50, 100*$y+50); } } - $m->nextFrame(); + $m->nextFrame(); - $m->add(new SWFAction(" + $m->add(new SWFAction(" gotoFrame(1); play(); @@ -4028,8 +4071,9 @@ ")); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -4038,13 +4082,14 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $m = new SWFMovie(); - $m->setDimension(11000, 8000); - $m->setBackground(0x00, 0x00, 0x00); + $m->setDimension(11000, 8000); + $m->setBackground(0x00, 0x00, 0x00); - $m->add(new SWFAction(" + $m->add(new SWFAction(" this.quality = 0; /frames.visible = 0; @@ -4054,56 +4099,56 @@ // mouse tracking sprite $t = new SWFSprite(); - $i = $m->add($t); - $i->setName('mouse'); + $i = $m->add($t); + $i->setName('mouse'); $g = new SWFGradient(); - $g->addEntry(0, 0xff, 0xff, 0xff, 0xff); - $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff); - $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f); - $g->addEntry(1.0, 0xff, 0xff, 0xff, 0); + $g->addEntry(0, 0xff, 0xff, 0xff, 0xff); + $g->addEntry(0.1, 0xff, 0xff, 0xff, 0xff); + $g->addEntry(0.5, 0xff, 0xff, 0xff, 0x5f); + $g->addEntry(1.0, 0xff, 0xff, 0xff, 0); // gradient shape thing $s = new SWFShape(); - $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); - $f->scaleTo(0.03); - $s->setRightFill($f); - $s->movePenTo(-600, -600); - $s->drawLine(1200, 0); - $s->drawLine(0, 1200); - $s->drawLine(-1200, 0); - $s->drawLine(0, -1200); + $f = $s->addFill($g, SWFFILL_RADIAL_GRADIENT); + $f->scaleTo(0.03); + $s->setRightFill($f); + $s->movePenTo(-600, -600); + $s->drawLine(1200, 0); + $s->drawLine(0, 1200); + $s->drawLine(-1200, 0); + $s->drawLine(0, -1200); // need to make this a sprite so we can multColor it $p = new SWFSprite(); - $p->add($s); - $p->nextFrame(); + $p->add($s); + $p->nextFrame(); // put the shape in here, each frame a different color $q = new SWFSprite(); - $q->add(new SWFAction("gotoFrame(random(7)+1); stop();")); - $i = $q->add($p); + $q->add(new SWFAction("gotoFrame(random(7)+1); stop();")); + $i = $q->add($p); - $i->multColor(1.0, 1.0, 1.0); - $q->nextFrame(); - $i->multColor(1.0, 0.5, 0.5); - $q->nextFrame(); - $i->multColor(1.0, 0.75, 0.5); - $q->nextFrame(); - $i->multColor(1.0, 1.0, 0.5); - $q->nextFrame(); - $i->multColor(0.5, 1.0, 0.5); - $q->nextFrame(); - $i->multColor(0.5, 0.5, 1.0); - $q->nextFrame(); - $i->multColor(1.0, 0.5, 1.0); - $q->nextFrame(); + $i->multColor(1.0, 1.0, 1.0); + $q->nextFrame(); + $i->multColor(1.0, 0.5, 0.5); + $q->nextFrame(); + $i->multColor(1.0, 0.75, 0.5); + $q->nextFrame(); + $i->multColor(1.0, 1.0, 0.5); + $q->nextFrame(); + $i->multColor(0.5, 1.0, 0.5); + $q->nextFrame(); + $i->multColor(0.5, 0.5, 1.0); + $q->nextFrame(); + $i->multColor(1.0, 0.5, 1.0); + $q->nextFrame(); // finally, this one contains the action code $p = new SWFSprite(); - $i = $p->add($q); - $i->setName('frames'); - $p->add(new SWFAction(" + $i = $p->add($q); + $i->setName('frames'); + $p->add(new SWFAction(" dx = (/:mousex-/:lastx)/3 + random(10)-5; dy = (/:mousey-/:lasty)/3; @@ -4112,9 +4157,9 @@ alpha = 100; ")); - $p->nextFrame(); + $p->nextFrame(); - $p->add(new SWFAction(" + $p->add(new SWFAction(" this.x = x; this.y = y; @@ -4125,16 +4170,16 @@ alpha -= 8; ")); - $p->nextFrame(); + $p->nextFrame(); - $p->add(new SWFAction("prevFrame(); play();")); - $p->nextFrame(); + $p->add(new SWFAction("prevFrame(); play();")); + $p->nextFrame(); - $i = $m->add($p); - $i->setName('frames'); - $m->nextFrame(); + $i = $m->add($p); + $i->setName('frames'); + $m->nextFrame(); - $m->add(new SWFAction(" + $m->add(new SWFAction(" lastx = mousex; lasty = mousey; @@ -4146,17 +4191,18 @@ if(num == 11) num = 1; -removeClip('char' & num); -duplicateClip(/frames, 'char' & num, num); +removeClip('char' & num); +duplicateClip(/frames, 'char' & num, num); ")); - $m->nextFrame(); - $m->add(new SWFAction("prevFrame(); play();")); + $m->nextFrame(); + $m->add(new SWFAction("prevFrame(); play();")); header('Content-type: application/x-shockwave-flash'); - $m->output(); -?> + $m->output(); +?> +]]> </programlisting> </example> </para> @@ -4169,46 +4215,47 @@ <example> <title><function>swfaction</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php /* sprite has one letter per frame */ $p = new SWFSprite(); - $p->add(new SWFAction("stop();")); + $p->add(new SWFAction("stop();")); $chars = "abcdefghijklmnopqrstuvwxyz". "ABCDEFGHIJKLMNOPQRSTUVWXYZ". - "1234567890!@#$%^&*()_+-=/[]{}|;:,.<>?`~"; + "1234567890!@#$%^&/*()_+-=/[]{}|;:,.<>?`~"; $f = new SWFFont("_sans"); for($n=0; $nremove($i); $t = new SWFTextField(); - $t->setFont($f); - $t->setHeight(240); - $t->setBounds(600,240); - $t->align(SWFTEXTFIELD_ALIGN_CENTER); - $t->addString($c); - $i = $p->add($t); - $p->labelFrame($c); - $p->nextFrame(); + $t->setFont($f); + $t->setHeight(240); + $t->setBounds(600,240); + $t->align(SWFTEXTFIELD_ALIGN_CENTER); + $t->addString($c); + $i = $p->add($t); + $p->labelFrame($c); + $p->nextFrame(); } /* hit region for button - the entire frame */ $s = new SWFShape(); - $s->setFillStyle0($s->addSolidFill(0, 0, 0, 0)); - $s->drawLine(600, 0); - $s->drawLine(0, 400); - $s->drawLine(-600, 0); - $s->drawLine(0, -400); + $s->setFillStyle0($s->addSolidFill(0, 0, 0, 0)); + $s->drawLine(600, 0); + $s->drawLine(0, 400); + $s->drawLine(-600, 0); + $s->drawLine(0, -400); /* button checks for pressed key, sends sprite to the right frame */ $b = new SWFButton(); - $b->addShape($s, SWFBUTTON_HIT); + $b->addShape($s, SWFBUTTON_HIT); for($n=0; $naddAction(new SWFAction(" @@ -4219,17 +4266,18 @@ } $m = new SWFMovie(); - $m->setDimension(600,400); - $i = $m->add($p); - $i->setName('char'); - $i->moveTo(0,80); + $m->setDimension(600,400); + $i = $m->add($p); + $i->setName('char'); + $i->moveTo(0,80); - $m->add($b); + $m->add($b); header('Content-type: application/x-shockwave-flash'); - $m->output(); + $m->output(); -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/misc.xml diff -u phpdoc/en/functions/misc.xml:1.59 phpdoc/en/functions/misc.xml:1.60 --- phpdoc/en/functions/misc.xml:1.59 Sat Nov 10 16:49:38 2001 +++ phpdoc/en/functions/misc.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.59 $ --> +<!-- $Revision: 1.60 $ --> <reference id="ref.misc"> <title>Miscellaneous functions</title> <titleabbrev>Misc.</titleabbrev> @@ -117,14 +117,16 @@ <example> <title><function>constant</function> example</title> <programlisting role="php"> -<php +<![CDATA[ +<php define ("MAXSIZE", 100); echo MAXSIZE; echo constant("MAXSIZE"); // same thing as the previous line -?> +?> +]]> </programlisting> </example> </para> @@ -175,7 +177,8 @@ <example> <title>Defining Constants</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php define ("CONSTANT", "Hello world."); echo CONSTANT; // outputs "Hello world." echo Constant; // outputs "Constant" and issues a notice. @@ -184,7 +187,8 @@ echo GREETING; // outputs "Hello you." echo Greeting; // outputs "Hello you." -?> +?> +]]> </programlisting> </example> </para> @@ -223,11 +227,13 @@ <example> <title>Checking Constants</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (defined("CONSTANT")){ // Note that it should be quoted echo CONSTANT; // } -?> +?> +]]> </programlisting> </example> </para> @@ -298,23 +304,27 @@ <function>eval</function> example - simple text merge </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $string = 'cup'; $name = 'coffee'; -$str = 'This is a $string with my $name in it.<br>'; +$str = 'This is a $string with my $name in it.<br>'; echo $str; eval ("\$str = \"$str\";"); echo $str; -?> +?> +]]> </programlisting> - </example> - </para> <para> The above example will show: - <programlisting> + <screen> +<![CDATA[ This is a $string with my $name in it. This is a cup with my coffee in it. - </programlisting> +]]> + </screen> + </para> + </example> </para> </refsect1> </refentry> @@ -359,13 +369,15 @@ <example> <title><function>exit</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $filename = '/path/to/data-file'; $file = fopen ($filename, 'r') or exit("unable to open file ($filename)"); -?> +?> +]]> </programlisting> <!-- TODO: example with integer exit-statis --> </example> @@ -418,17 +430,19 @@ <example> <title><function>get_browser</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function list_array ($array) { while (list ($key, $value) = each ($array)) { - $str .= "<b>$key:</b> $value<br>\n"; + $str .= "<b>$key:</b> $value<br>\n"; } return $str; } -echo "$HTTP_USER_AGENT<hr>\n"; +echo "$HTTP_USER_AGENT<hr>\n"; $browser = get_browser(); echo list_array ((array) $browser); -?> +?> +]]> </programlisting> </example> </para> @@ -436,26 +450,28 @@ The output of the above script would look something like this: </simpara> <programlisting> -Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr> -<b>browser_name_pattern:</b> Mozilla/4\.5.*<br> -<b>parent:</b> Netscape 4.0<br> -<b>platform:</b> Unknown<br> -<b>majorver:</b> 4<br> -<b>minorver:</b> 5<br> -<b>browser:</b> Netscape<br> -<b>version:</b> 4<br> -<b>frames:</b> 1<br> -<b>tables:</b> 1<br> -<b>cookies:</b> 1<br> -<b>backgroundsounds:</b> <br> -<b>vbscript:</b> <br> -<b>javascript:</b> 1<br> -<b>javaapplets:</b> 1<br> -<b>activexcontrols:</b> <br> -<b>beta:</b> <br> -<b>crawler:</b> <br> -<b>authenticodeupdate:</b> <br> -<b>msn:</b> <br> +<![CDATA[ +Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr> +<b>browser_name_pattern:</b> Mozilla/4\.5.*<br> +<b>parent:</b> Netscape 4.0<br> +<b>platform:</b> Unknown<br> +<b>majorver:</b> 4<br> +<b>minorver:</b> 5<br> +<b>browser:</b> Netscape<br> +<b>version:</b> 4<br> +<b>frames:</b> 1<br> +<b>tables:</b> 1<br> +<b>cookies:</b> 1<br> +<b>backgroundsounds:</b> <br> +<b>vbscript:</b> <br> +<b>javascript:</b> 1<br> +<b>javaapplets:</b> 1<br> +<b>activexcontrols:</b> <br> +<b>beta:</b> <br> +<b>crawler:</b> <br> +<b>authenticodeupdate:</b> <br> +<b>msn:</b> <br> +]]> </programlisting> <simpara> In order for this to work, your <link @@ -506,7 +522,7 @@ <title>Creating a source highlighting URL</title> <simpara> To setup a URL that can code hightlight any script that you pass to - it, we will make use of the "ForceType" directive in + it, we will make use of the "ForceType" directive in Apache to generate a nice URL pattern, and use the function <function>highlight_file</function> to show a nice looking code list. @@ -516,50 +532,57 @@ </simpara> <para> <informalexample> - <programlisting> -<Location /source> + <programlisting> +<![CDATA[ +<Location /source> ForceType application/x-httpd-php -</Location> - </programlisting></informalexample> +</Location> +]]> + </programlisting> + </informalexample> </para> <simpara> - And then make a file named "source" and put it in your + And then make a file named "source" and put it in your web root directory. </simpara> <para> <programlisting role="php"> -<HTML> -<HEAD> -<TITLE>Source Display</TITLE> -</HEAD> -<BODY BGCOLOR="white"> -<?php - $script = getenv ("PATH_TRANSLATED"); +<![CDATA[ +<HTML> +<HEAD> +<TITLE>Source Display</TITLE> +</HEAD> +<BODY BGCOLOR="white"> +<?php + $script = getenv ("PATH_TRANSLATED"); if(!$script) { - echo "<BR><B>ERROR: Script Name needed</B><BR>"; + echo "<BR><B>ERROR: Script Name needed</B><BR>"; } else { - if (ereg("(\.php|\.inc)$",$script)) { - echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n"; + if (ereg("(\.php|\.inc)$",$script)) { + echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n"; highlight_file($script); } else { - echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; + echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; } } - echo "<HR>Processed: ".date("Y/M/d H:i:s",time()); -?> -</BODY> -</HTML> + echo "<HR>Processed: ".date("Y/M/d H:i:s",time()); +?> +</BODY> +</HTML> +]]> </programlisting> </para> <simpara> Then you can use an URL like the one below to display a colorized - version of a script located in "/path/to/script.php" + version of a script located in "/path/to/script.php" in your web site. </simpara> <para> <informalexample> <programlisting> +<![CDATA[ http://your.server.com/source/path/to/script.php +]]> </programlisting> </informalexample> </para> @@ -821,7 +844,9 @@ <example> <title><function>pack</function> format string</title> <programlisting role="php"> +<![CDATA[ $binarydata = pack ("nvc*", 0x1234, 0x5678, 65, 66); +]]> </programlisting> <para> The resulting binary string will be 6 bytes long and contain @@ -954,8 +979,10 @@ it is recommended that you use something along the lines of <informalexample> <programlisting role="php"> +<![CDATA[ $token = md5 (uniqid ("")); // no random portion $better_token = md5 (uniqid (rand())); // better, difficult to guess +]]> </programlisting> </informalexample> </para> @@ -993,7 +1020,9 @@ <example> <title><function>unpack</function> format string</title> <programlisting role="php"> +<![CDATA[ $array = unpack ("c2chars/nint", $binarydata); +]]> </programlisting> <para> The resulting array will contain the entries "chars1", Index: phpdoc/en/functions/mnogosearch.xml diff -u phpdoc/en/functions/mnogosearch.xml:1.28 phpdoc/en/functions/mnogosearch.xml:1.29 --- phpdoc/en/functions/mnogosearch.xml:1.28 Sun Nov 11 13:55:39 2001 +++ phpdoc/en/functions/mnogosearch.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.28 $ --> +<!-- $Revision: 1.29 $ --> <reference id="ref.mnogo"> <title>mnoGoSearch Functions</title> <titleabbrev>mnoGoSearch</titleabbrev> @@ -228,9 +228,11 @@ <simpara>Example:</simpara> <informalexample> <programlisting role="C"> - if (Udm_Api_Version() >= 30111) { - print "Total number of urls in database: ".Udm_Get_Doc_Count($udm)."<br>\n"; +<![CDATA[ + if (Udm_Api_Version() >= 30111) { + print "Total number of urls in database: ".Udm_Get_Doc_Count($udm)."<br>\n"; } +]]> </programlisting> </informalexample> </refsect1> Index: phpdoc/en/functions/msql.xml diff -u phpdoc/en/functions/msql.xml:1.18 phpdoc/en/functions/msql.xml:1.19 --- phpdoc/en/functions/msql.xml:1.18 Fri Nov 16 17:29:07 2001 +++ phpdoc/en/functions/msql.xml Tue Nov 20 18:58:45 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.18 $ --> +<!-- $Revision: 1.19 $ --> <reference id="ref.msql"> <title>mSQL functions</title> <titleabbrev>mSQL</titleabbrev> @@ -1125,16 +1125,18 @@ <example> <title><function>msql_tablename</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php msql_connect ("localhost"); $result = msql_list_tables ("wisconsin"); $i = 0; -while ($i < msql_numrows ($result)) { +while ($i < msql_numrows ($result)) { $tb_names[$i] = msql_tablename ($result, $i); - echo $tb_names[$i] . "<BR>"; + echo $tb_names[$i] . "<BR>"; $i++; } ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/mssql.xml diff -u phpdoc/en/functions/mssql.xml:1.21 phpdoc/en/functions/mssql.xml:1.22 --- phpdoc/en/functions/mssql.xml:1.21 Wed Nov 14 14:05:26 2001 +++ phpdoc/en/functions/mssql.xml Tue Nov 20 18:58:46 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.21 $ --> +<!-- $Revision: 1.22 $ --> <reference id="ref.mssql"> <title>Microsoft SQL Server functions</title> <titleabbrev>MS SQL Server</titleabbrev> @@ -497,7 +497,8 @@ <example> <title><function>mssql_next_result</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mssql_connect ("localhost", "userid", "secret"); mssql_select_db("MyDB", $link); $SQL = "Select * from table1 select * from table2"; @@ -508,7 +509,8 @@ } while (mssql_next_result($rs)); mssql_free_result($rs); mssql_close ($link); -?> +?> +]]> </programlisting> </example> </refsect1> Index: phpdoc/en/functions/mysql.xml diff -u phpdoc/en/functions/mysql.xml:1.75 phpdoc/en/functions/mysql.xml:1.76 --- phpdoc/en/functions/mysql.xml:1.75 Mon Nov 19 12:10:35 2001 +++ phpdoc/en/functions/mysql.xml Tue Nov 20 18:58:46 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.75 $ --> +<!-- $Revision: 1.76 $ --> <reference id="ref.mysql"> <title>MySQL Functions</title> <titleabbrev>MySQL</titleabbrev> @@ -215,12 +215,14 @@ <example> <title>MySQL close example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect ("kraemer", "marliesle", "secret") or die ("Could not connect"); print ("Connected successfully"); mysql_close ($link); -?> +?> +]]> </programlisting> </example> <para> @@ -300,12 +302,14 @@ <example> <title>MySQL connect example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect ("localhost", "username", "secret") or die ("Could not connect"); print ("Connected successfully"); mysql_close ($link); -?> +?> +]]> </programlisting> </example> <para> See also @@ -344,7 +348,8 @@ <example> <title>MySQL create database example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_pconnect ("kron", "jutta", "geheim") or die ("Could not connect"); if (mysql_create_db ("my_db")) { @@ -352,7 +357,8 @@ } else { printf ("Error creating database: %s\n", mysql_error ()); } -?> +?> +]]> </programlisting> </example> <para> @@ -394,7 +400,8 @@ <example> <title>MySQL data seek example</title> <programlisting role="php"> -<?php +<![CDATA[ +&<?php $link = mysql_pconnect ("kron", "jutta", "geheim") or die ("Could not connect"); @@ -416,11 +423,12 @@ if(!($row = mysql_fetch_object ($result))) continue; - echo ("$row->last_name $row->first_name<BR>\n"; + echo "$row->last_name $row->first_name<br />\n"; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -461,7 +469,8 @@ <example> <title><function>mysql_db_name</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php error_reporting(E_ALL); mysql_connect('dbhost', 'username', 'password'); @@ -469,11 +478,12 @@ $i = 0; $cnt = mysql_num_rows($db_list); -while ($i < $cnt) { +while ($i < $cnt) { echo mysql_db_name($db_list, $i) . "\n"; $i++; } -?> +?> +]]> </programlisting> </example> <para> @@ -597,18 +607,20 @@ error code from the most recently executed MySQL function (not including <function>mysql_error</function> and <function>mysql_errno</function>), so if you want to use it, - make sure you check the value before calling another mySQL - function. + make sure you check the value before calling another mySQL + function. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect("marliesle"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; $conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."<BR>"; -?> +echo mysql_errno().": ".mysql_error()."<BR>"; +?> +]]> </programlisting> </informalexample> </para> @@ -652,14 +664,16 @@ sure you check the value before calling another MySQL function. <informalexample> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect("marliesle"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; mysql_select_db("nonexistentdb"); -echo mysql_errno().": ".mysql_error()."<BR>"; +echo mysql_errno().": ".mysql_error()."<BR>"; $conn = mysql_query("SELECT * FROM nonexistenttable"); -echo mysql_errno().": ".mysql_error()."<BR>"; -?> +echo mysql_errno().": ".mysql_error()."<BR>"; +?> +]]> </programlisting> </informalexample> </para> @@ -734,8 +748,10 @@ access the contents with the original column name (by using <literal>'field'</literal> in this example). <informalexample> - <programlisting> + <programlisting role="sql"> +<![CDATA[ select tone.field as foo ttwo.field as bar from tone, ttwo +]]> </programlisting> </informalexample> </para> @@ -768,17 +784,19 @@ <example> <title><function>mysql_fetch_array</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database","select user_id, fullname from table"); while ($row = mysql_fetch_array ($result)) { - echo "user_id: ".$row["user_id"]."<br>\n"; - echo "user_id: ".$row[0]."<br>\n"; - echo "fullname: ".$row["fullname"]."<br>\n"; - echo "fullname: ".$row[1]."<br>\n"; + echo "user_id: ".$row["user_id"]."<br>\n"; + echo "user_id: ".$row[0]."<br>\n"; + echo "fullname: ".$row["fullname"]."<br>\n"; + echo "fullname: ".$row[1]."<br>\n"; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -834,7 +852,8 @@ <example> <title><function>mysql_fetch_assoc</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database","select * from table"); while ($row = mysql_fetch_assoc ($result)) { @@ -842,7 +861,8 @@ echo $row["fullname"]; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </refsect1> @@ -945,20 +965,21 @@ <example> <title><function>mysql_fetch_field</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password) or die ("Could not connect"); $result = mysql_db_query ("database", "select * from table") or die ("Query failed"); # get column metadata $i = 0; -while ($i < mysql_num_fields ($result)) { - echo "Information for column $i:<BR>\n"; +while ($i < mysql_num_fields ($result)) { + echo "Information for column $i:<BR>\n"; $meta = mysql_fetch_field ($result); if (!$meta) { - echo "No information available<BR>\n"; + echo "No information available<BR>\n"; } - echo "<PRE> + echo "<PRE> blob: $meta->blob max_length: $meta->max_length multiple_key: $meta->multiple_key @@ -971,11 +992,12 @@ unique_key: $meta->unique_key unsigned: $meta->unsigned zerofill: $meta->zerofill -</PRE>"; +</PRE>"; $i++; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> <para> @@ -1062,7 +1084,8 @@ <example> <title><function>mysql_fetch_object</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database", "select * from table"); while ($row = mysql_fetch_object ($result)) { @@ -1070,7 +1093,8 @@ echo $row->fullname; } mysql_free_result ($result); -?> +?> +]]> </programlisting> </example> </para> @@ -1188,6 +1212,7 @@ <example> <title><function>mysql_field_name</function> example</title> <programlisting role="php"> +<![CDATA[ // The users table consists of three fields: // user_id // username @@ -1197,17 +1222,18 @@ echo mysql_field_name($res, 0) . "\n"; echo mysql_field_name($res, 2); +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ user_id password - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <para> For downwards compatibility <function>mysql_fieldname</function> @@ -1324,7 +1350,8 @@ <example> <title>MySQL field types</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ("localhost:3306"); mysql_select_db ("wisconsin"); @@ -1333,19 +1360,20 @@ $rows = mysql_num_rows ($result); $i = 0; $table = mysql_field_table ($result, $i); -echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>"; -echo "The table has the following fields <BR>"; -while ($i < $fields) { +echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>"; +echo "The table has the following fields <BR>"; +while ($i < $fields) { $type = mysql_field_type ($result, $i); $name = mysql_field_name ($result, $i); $len = mysql_field_len ($result, $i); $flags = mysql_field_flags ($result, $i); - echo $type." ".$name." ".$len." ".$flags."<BR>"; + echo $type." ".$name." ".$len." ".$flags."<BR>"; $i++; } mysql_close(); -?> +?> +]]> </programlisting> </example> </para> @@ -1475,25 +1503,29 @@ <example> <title><function>mysql_list_dbs</function> example</title> <programlisting role="php"> +<![CDATA[ +<?php $link = mysql_connect('localhost', 'myname', 'secret'); $db_list = mysql_list_dbs($link); while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } +?> +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ database1 database2 database3 ... - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <note> <para> @@ -1543,27 +1575,30 @@ <example> <title><function>mysql_list_fields</function> example</title> <programlisting role="php"> +<![CDATA[ +<?php $link = mysql_connect('localhost', 'myname', 'secret'); $fields = mysql_list_fields("database1", "table1", $link); $columns = mysql_num_fields($fields); -for ($i = 0; $i < $columns; $i++) { +for ($i = 0; $i < $columns; $i++) { echo mysql_field_name($fields, $i) . "\n";; } +]]> </programlisting> - </example> - </para> - <para> - The above example would produce the following output: - <informalexample> - <programlisting> + <para> + The above example would produce the following output: + <screen> +<![CDATA[ field1 field2 field3 ... - </programlisting> - </informalexample> +]]> + </screen> + </para> + </example> </para> <para> For downward compatibility <function>mysql_listfields</function> @@ -1660,7 +1695,8 @@ <example> <title><function>mysql_num_rows</function> example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $link = mysql_connect("localhost", "username", "password"); mysql_select_db("database", $link); @@ -1670,7 +1706,8 @@ echo "$num_rows Rows\n"; -?> +?> +]]> </programlisting> </example> </para> @@ -1818,10 +1855,12 @@ <example> <title><function>mysql_query</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<php $result = mysql_query ("SELECT * WHERE 1=1") or die ("Invalid query"); -?> +?> +]]> </programlisting> </example> </para> @@ -1833,10 +1872,12 @@ <example> <title><function>mysql_query</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $result = mysql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); -?> +?> +]]> </programlisting> </example> </para> @@ -2044,16 +2085,18 @@ <example> <title><function>mysql_tablename</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php mysql_connect ("localhost:3306"); $result = mysql_list_tables ("wisconsin"); $i = 0; -while ($i < mysql_num_rows ($result)) { +while ($i < mysql_num_rows ($result)) { $tb_names[$i] = mysql_tablename ($result, $i); - echo $tb_names[$i] . "<BR>"; + echo $tb_names[$i] . "<BR>"; $i++; } -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/network.xml diff -u phpdoc/en/functions/network.xml:1.44 phpdoc/en/functions/network.xml:1.45 --- phpdoc/en/functions/network.xml:1.44 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/network.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.44 $ --> +<!-- $Revision: 1.45 $ --> <reference id="ref.network"> <title>Network Functions</title> <titleabbrev>Network</titleabbrev> @@ -214,9 +214,11 @@ <example> <title><function>fsockopen</function> Example</title> <programlisting role="php"> +<![CDATA[ +<?php $fp = fsockopen ("www.php.net", 80, $errno, $errstr, 30); if (!$fp) { - echo "$errstr ($errno)<br>\n"; + echo "$errstr ($errno)<br>\n"; } else { fputs ($fp, "GET / HTTP/1.0\r\n\r\n"); while (!feof($fp)) { @@ -224,6 +226,8 @@ } fclose ($fp); } +?> +]]> </programlisting> </example> The example below shows how to retrieve the day and time @@ -231,16 +235,18 @@ <example> <title>Using UDP connection</title> <programlisting role="php"> +<![CDATA[ <?php $fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr); if (!$fp) { - echo "ERROR: $errno - $errstr<br>\n"; + echo "ERROR: $errno - $errstr<br>\n"; } else { fwrite($fp,"\n"); echo fread($fp, 26); fclose($fp); } -?> +?> +]]> </programlisting> </example> <note> @@ -512,12 +518,14 @@ <example> <title><function>ip2long</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $ip = gethostbyname("www.php.net"); -$out = "The following URLs are equivalent:<br>\n"; -$out .= "http://www.php.net/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n"; +$out = "The following URLs are equivalent:<br>\n"; +$out .= "http://www.php.net/, http://".$ip."/, and http://".sprintf("%u",ip2long($ip))."/<br>\n"; echo $out; -?> +?> +]]> </programlisting> </example> <note> @@ -533,11 +541,13 @@ <example> <title>Displaying an IP address</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $ip = gethostbyname("www.php.net"); printf("%u\n", ip2long($ip)); echo $out; -?> +?> +]]> </programlisting> </example> </para> @@ -868,7 +878,8 @@ <example> <title><function>socket_set_timeout</function> Example</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $fp = fsockopen("www.php.net", 80); if(!$fp) { echo "Unable to open\n"; @@ -881,7 +892,8 @@ fclose($fp); print $res; } -?> +?> +]]> </programlisting> </example> </para> @@ -970,12 +982,13 @@ <example> <title>Using <function>syslog</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php define_syslog_variables(); // open syslog, include the process ID and also send // the log to standard error, and use a user defined // logging mechanism -openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); +openlog("myScripLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); // some code @@ -984,12 +997,13 @@ } else { // unauthorized client! // log the attempt - $access = date("Y/m/d H:i:s"); - syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)"); + $access = date("Y/m/d H:i:s"); + syslog(LOG_WARNING,"Unauthorized client: $access $REMOTE_ADDR ($HTTP_USER_AGENT)"); } closelog(); -?> +?> +]]> </programlisting> </example> For information on setting up a user defined log handler, see the Index: phpdoc/en/functions/nis.xml diff -u phpdoc/en/functions/nis.xml:1.17 phpdoc/en/functions/nis.xml:1.18 --- phpdoc/en/functions/nis.xml:1.17 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/nis.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.17 $ --> +<!-- $Revision: 1.18 $ --> <reference id="ref.nis"> <title>YP/NIS Functions</title> <titleabbrev>YP/NIS</titleabbrev> @@ -47,10 +47,12 @@ <example> <title>Example for the default domain</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $domain = yp_get_default_domain(); echo "Default NIS domain is: " . $domain; ?> +]]> </programlisting> </example> </para> @@ -85,10 +87,12 @@ <example> <title>Example for the NIS order</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $number = yp_order($domain,$mapname); echo "Order number for this map is: " . $number; ?> +]]> </programlisting> </example> </para> @@ -126,10 +130,12 @@ <example> <title>Example for the NIS master</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $number = yp_master ($domain, $mapname); echo "Master for this map is: " . $master; ?> +]]> </programlisting> </example> </para> @@ -166,10 +172,12 @@ <example> <title>Example for NIS match</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_match ($domain, "passwd.byname", "joe"); echo "Matched entry is: " . $entry; ?> +]]> </programlisting> </example> </para> @@ -211,12 +219,14 @@ <example> <title>Example for the NIS first</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_first($domain, "passwd.byname"); $key = $entry ["key"]; $value = $entry ["value"]; echo "First entry in this map has key " . $key . " and value " . $value; ?> +]]> </programlisting> </example> </para> @@ -254,7 +264,8 @@ <example> <title>Example for NIS next</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $entry = yp_next ($domain, "passwd.byname", "joe"); if (!$entry) { @@ -267,6 +278,7 @@ echo "The next entry after joe has key " . $key . " and value " . $entry[$key]; ?> +]]> </programlisting> </example> </para> @@ -358,9 +370,11 @@ <example> <title>Example for NIS errors</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php echo "Error: " . yp_err_string(); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/oci8.xml diff -u phpdoc/en/functions/oci8.xml:1.34 phpdoc/en/functions/oci8.xml:1.35 --- phpdoc/en/functions/oci8.xml:1.34 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/oci8.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.34 $ --> +<!-- $Revision: 1.35 $ --> <reference id="ref.oci8"> <title>Oracle 8 functions</title> <titleabbrev>OCI8</titleabbrev> @@ -65,7 +65,8 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ # ldd /www/apache/bin/httpd libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000) libm.so.6 => /lib/libm.so.6 (0x4002f000) @@ -73,7 +74,8 @@ libdl.so.2 => /lib/libdl.so.2 (0x4007a000) libc.so.6 => /lib/libc.so.6 (0x4007e000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) - </programlisting> +]]> + </screen> </informalexample> </para> <para> @@ -81,13 +83,15 @@ </para> <para> <informalexample> - <programlisting> + <screen> +<![CDATA[ # cd /usr/src/apache_1.3.xx # make clean # LIBS=-lpthread ./config.status # make # make install - </programlisting> +]]> + </screen> </informalexample> </para> </note> @@ -95,7 +99,8 @@ <example> <title>OCI Hints</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // by sergo@bacup.ru // Use option: OCI_DEFAULT for execute command to delay execution @@ -104,7 +109,7 @@ // for retrieve data use (after fetch): $result = OCIResult($stmt, $n); -if (is_object ($result)) $result = $result->load(); +if (is_object ($result)) $result = $result->load(); // For INSERT or UPDATE statement use: @@ -112,12 +117,12 @@ field2 = empty_clob()) returning field2 into :field2"; OCIParse($conn, $sql); $clob = OCINewDescriptor($conn, OCI_D_LOB); -OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); +OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB); OCIExecute($stmt, OCI_DEFAULT); -$clob->save ("some text"); +$clob->save ("some text"); OCICommit($conn); -?> +?> </programlisting> </example> </para> @@ -127,7 +132,8 @@ <example> <title>Using Stored Procedures</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php // by webmaster@remoterealty.com $sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname', '$lastname', '$company', '$address1', '$address2', '$city', '$state', @@ -141,7 +147,8 @@ OCIBindByName ( $sth, ":error_code", $errorcode, 10 ); OCIExecute ( $sth ); -?> +?> +]]> </programlisting> </example> </para> @@ -184,7 +191,8 @@ <example> <title>OCIDefineByName</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIDefineByPos example thies@thieso.net (980219) */ $conn = OCILogon("scott","tiger"); @@ -206,6 +214,7 @@ OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </refsect1> @@ -256,7 +265,8 @@ <example> <title>OCIDefineByName</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIBindByPos example thies@thieso.net (980221) inserts 3 records into emp, and uses the ROWID for updating the records just after the insert. @@ -306,6 +316,7 @@ OCILogoff($conn); ?> +]]> </programlisting> </example> <warning> @@ -357,8 +368,9 @@ <example> <title>OCILogon</title> <programlisting> -<?php -print "<HTML><PRE>"; +<![CDATA[ +<?php +print "<HTML><PRE>"; $db = ""; $c1 = ocilogon("scott","tiger",$db); @@ -404,7 +416,7 @@ ociexecute($stmt,OCI_DEFAULT); echo $conn."----selecting\n\n"; while (ocifetch($stmt)) - echo $conn." <".ociresult($stmt,"TEST").">\n\n"; + echo $conn." <".ociresult($stmt,"TEST").">\n\n"; echo $conn."----done\n\n"; } @@ -435,8 +447,12 @@ drop_table($c1); -print "</PRE></HTML>"; -?></programlisting></example></para> +print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> + </para> <simpara> See also <function>OCIPLogon</function> and <function>OCINLogon</function>.</simpara> @@ -518,8 +534,9 @@ <example> <title>OCINLogon</title> <programlisting> -<?php -print "<HTML><PRE>"; +<![CDATA[ +<?php +print "<HTML><PRE>"; $db = ""; $c1 = ocilogon("scott","tiger",$db); @@ -566,7 +583,7 @@ ociexecute($stmt,OCI_DEFAULT); echo $conn."----selecting\n\n"; while (ocifetch($stmt)) - echo $conn." <".ociresult($stmt,"TEST").">\n\n"; + echo $conn." <".ociresult($stmt,"TEST").">\n\n"; echo $conn."----done\n\n"; } @@ -596,8 +613,11 @@ drop_table($c1); -print "</PRE></HTML>"; -?></programlisting></example> +print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> </para> <simpara> See also <function>OCILogon</function> and @@ -721,7 +741,8 @@ <example> <title>OCINewDescriptor</title> <programlisting> -<?php +<![CDATA[ +<?php /* This script is designed to be called from a HTML form. * It expects $user, $password, $table, $where, and $commitsize * to be passed in from the form. The script then deletes @@ -731,12 +752,12 @@ $conn = OCILogon($user, $password); $stmt = OCIParse($conn,"select rowid from $table $where"); $rowid = OCINewDescriptor($conn,OCI_D_ROWID); - OCIDefineByName($stmt,"ROWID",&$rowid); + OCIDefineByName($stmt,"ROWID",&$rowid); OCIExecute($stmt); while ( OCIFetch($stmt) ) { $nrows = OCIRowCount($stmt); $delete = OCIParse($conn,"delete from $table where ROWID = :rid"); - OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID); + OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID); OCIExecute($delete); print "$nrows\n"; if ( ($nrows % $commitsize) == 0 ) { @@ -748,29 +769,31 @@ OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> <programlisting> -<?php +<![CDATA[ +<?php /* This script demonstrates file upload to LOB columns * The formfield used for this example looks like this - * <form action="upload.php3" method="post" enctype="multipart/form-data"> - * <input type="file" name="lob_upload"> + * <form action="upload.php3" method="post" enctype="multipart/form-data"> + * <input type="file" name="lob_upload"> * ... */ if(!isset($lob_upload) || $lob_upload == 'none'){ ?> -<form action="upload.php3" method="post" enctype="multipart/form-data"> -Upload file: <input type="file" name="lob_upload"><br> -<input type="submit" value="Upload"> - <input type="reset"> -</form> -<?php +<form action="upload.php3" method="post" enctype="multipart/form-data"> +Upload file: <input type="file" name="lob_upload"><br> +<input type="submit" value="Upload"> - <input type="reset"> +</form> +<?php } else { // $lob_upload contains the temporary filename of the uploaded file $conn = OCILogon($user, $password); $lob = OCINewDescriptor($conn, OCI_D_LOB); $stmt = OCIParse($conn,"insert into $table (id, the_blob) values(my_seq.NEXTVAL, EMPTY_BLOB()) returning the_blob into :the_blob"); - OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); + OCIBindByName($stmt, ':the_blob', &$lob, -1, OCI_B_BLOB); OCIExecute($stmt, OCI_DEFAULT); if($lob->savefile($lob_upload)){ OCICommit($conn); @@ -783,12 +806,14 @@ OCILogoff($conn); } ?> +]]> </programlisting> </example> <example> <title>OCINewDescriptor</title> <programlisting> -<?php +<![CDATA[ +<?php /* Calling PL/SQL stored procedures which contain clobs as input * parameters (PHP 4 >= 4.0.6). * Example PL/SQL stored procedure signature is: @@ -813,6 +838,7 @@ $clob->free(); OCIFreeStatement($stmt); ?> +]]> </programlisting> </example> </refsect1> @@ -839,24 +865,28 @@ <example> <title>OCIRowCount</title> <programlisting> -<?php - print "<HTML><PRE>"; +<![CDATA[ +<?php + print "<HTML><PRE>"; $conn = OCILogon("scott","tiger"); $stmt = OCIParse($conn,"create table emp2 as select * from emp"); OCIExecute($stmt); - print OCIRowCount($stmt) . " rows inserted.<BR>"; + print OCIRowCount($stmt) . " rows inserted.<BR>"; OCIFreeStatement($stmt); $stmt = OCIParse($conn,"delete from emp2"); OCIExecute($stmt); - print OCIRowCount($stmt) . " rows deleted.<BR>"; + print OCIRowCount($stmt) . " rows deleted.<BR>"; OCICommit($conn); OCIFreeStatement($stmt); $stmt = OCIParse($conn,"drop table emp2"); OCIExecute($stmt); OCIFreeStatement($stmt); OCILogOff($conn); - print "</PRE></HTML>"; -?> </programlisting></example> + print "</PRE></HTML>"; +?> +]]> + </programlisting> + </example> </para> </refsect1> </refentry> @@ -883,15 +913,16 @@ <example> <title>OCINumCols</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); while ( OCIFetch($stmt) ) { print "\n"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_value = OCIResult($stmt,$i); print $column_name . ': ' . $column_value . "\n"; @@ -900,9 +931,10 @@ } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </refsect1> @@ -1025,7 +1057,8 @@ <example> <title>OCIFetchStatement</title> <programlisting> -<?php +<![CDATA[ +<?php /* OCIFetchStatement example mbritton@verinet.com (990624) */ $conn = OCILogon("scott","tiger"); @@ -1036,31 +1069,32 @@ $nrows = OCIFetchStatement($stmt,$results); if ( $nrows > 0 ) { - print "<TABLE BORDER=\"1\">\n"; - print "<TR>\n"; + print "<TABLE BORDER=\"1\">\n"; + print "<TR>\n"; while ( list( $key, $val ) = each( $results ) ) { - print "<TH>$key</TH>\n"; + print "<TH>$key</TH>\n"; } - print "</TR>\n"; + print "</TR>\n"; - for ( $i = 0; $i < $nrows; $i++ ) { + for ( $i = 0; $i < $nrows; $i++ ) { reset($results); - print "<TR>\n"; + print "<TR>\n"; while ( $column = each($results) ) { $data = $column['value']; - print "<TD>$data[$i]</TD>\n"; + print "<TD>$data[$i]</TD>\n"; } - print "</TR>\n"; + print "</TR>\n"; } - print "</TABLE>\n"; + print "</TABLE>\n"; } else { - echo "No data found<BR>\n"; + echo "No data found<BR>\n"; } -print "$nrows Records Selected<BR>\n"; +print "$nrows Records Selected<BR>\n"; OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </refsect1> @@ -1112,33 +1146,35 @@ <example> <title>OCIColumnName</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1174,34 +1210,36 @@ <example> <title>OCIColumnSize</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } - print "</TABLE>"; + print "</TABLE>"; OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1236,33 +1274,35 @@ <example> <title>OCIColumnType</title> <programlisting> -<?php - print "<HTML><PRE>\n"; +<![CDATA[ +<?php + print "<HTML><PRE>\n"; $conn = OCILogon("scott", "tiger"); $stmt = OCIParse($conn,"select * from emp"); OCIExecute($stmt); - print "<TABLE BORDER=\"1\">"; - print "<TR>"; - print "<TH>Name</TH>"; - print "<TH>Type</TH>"; - print "<TH>Length</TH>"; - print "</TR>"; + print "<TABLE BORDER=\"1\">"; + print "<TR>"; + print "<TH>Name</TH>"; + print "<TH>Type</TH>"; + print "<TH>Length</TH>"; + print "</TR>"; $ncols = OCINumCols($stmt); - for ( $i = 1; $i <= $ncols; $i++ ) { + for ( $i = 1; $i <= $ncols; $i++ ) { $column_name = OCIColumnName($stmt,$i); $column_type = OCIColumnType($stmt,$i); $column_size = OCIColumnSize($stmt,$i); - print "<TR>"; - print "<TD>$column_name</TD>"; - print "<TD>$column_type</TD>"; - print "<TD>$column_size</TD>"; - print "</TR>"; + print "<TR>"; + print "<TD>$column_name</TD>"; + print "<TD>$column_type</TD>"; + print "<TD>$column_size</TD>"; + print "</TR>"; } OCIFreeStatement($stmt); OCILogoff($conn); - print "</PRE>"; - print "</HTML>\n"; + print "</PRE>"; + print "</HTML>\n"; ?> +]]> </programlisting> </example> </para> @@ -1292,11 +1332,13 @@ <example> <title>OCIServerVersion</title> <programlisting> -<?php +<![CDATA[ +<?php $conn = OCILogon("scott","tiger"); print "Server Version: " . OCIServerVersion($conn); OCILogOff($conn); ?> +]]> </programlisting> </example> </para> @@ -1335,19 +1377,21 @@ <example> <title>Code examples</title> <programlisting> -<?php - print "<HTML><PRE>"; +<![CDATA[ +<?php + print "<HTML><PRE>"; $conn = OCILogon("scott","tiger"); $sql = "delete from emp where deptno = 10"; $stmt = OCIParse($conn,$sql); if ( OCIStatementType($stmt) == "DELETE" ) { - die "You are not allowed to delete from this table<BR>"; + die "You are not allowed to delete from this table<BR>"; } OCILogoff($conn); - print "</PRE></HTML>"; + print "</PRE></HTML>"; ?> +]]> </programlisting> </example> </para> @@ -1377,18 +1421,19 @@ <example> <title>Using a REF CURSOR from a stored procedure</title> <programlisting> -<?php +<![CDATA[ +<?php // suppose your stored procedure info.output returns a ref cursor in :data $conn = OCILogon("scott","tiger"); $curs = OCINewCursor($conn); $stmt = OCIParse($conn,"begin info.output(:data); end;"); -ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR); +ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR); ociexecute($stmt); ociexecute($curs); -while (OCIFetchInto($curs,&$data)) { +while (OCIFetchInto($curs,&$data)) { var_dump($data); } @@ -1396,6 +1441,7 @@ OCIFreeCursor($curs); OCILogoff($conn); ?> +]]> </programlisting> </example> </para> @@ -1403,39 +1449,41 @@ <example> <title>Using a REF CURSOR in a select statement</title> <programlisting> -<?php -print "<HTML><BODY>"; +<![CDATA[ +<?php +print "<HTML><BODY>"; $conn = OCILogon("scott","tiger"); $count_cursor = "CURSOR(select count(empno) num_emps from emp " . "where emp.deptno = dept.deptno) as EMPCNT from dept"; $stmt = OCIParse($conn,"select deptno,dname,$count_cursor"); ociexecute($stmt); -print "<TABLE BORDER=\"1\">"; -print "<TR>"; -print "<TH>DEPT NAME</TH>"; -print "<TH>DEPT #</TH>"; -print "<TH># EMPLOYEES</TH>"; -print "</TR>"; +print "<TABLE BORDER=\"1\">"; +print "<TR>"; +print "<TH>DEPT NAME</TH>"; +print "<TH>DEPT #</TH>"; +print "<TH># EMPLOYEES</TH>"; +print "</TR>"; while (OCIFetchInto($stmt,&$data,OCI_ASSOC)) { - print "<TR>"; + print "<TR>"; $dname = $data["DNAME"]; $deptno = $data["DEPTNO"]; - print "<TD>$dname</TD>"; - print "<TD>$deptno</TD>"; + print "<TD>$dname</TD>"; + print "<TD>$deptno</TD>"; ociexecute($data[ "EMPCNT" ]); while (OCIFetchInto($data[ "EMPCNT" ],&$subdata,OCI_ASSOC)) { $num_emps = $subdata["NUM_EMPS"]; - print "<TD>$num_emps</TD>"; + print "<TD>$num_emps</TD>"; } - print "</TR>"; + print "</TR>"; } -print "</TABLE>"; -print "</BODY></HTML>"; +print "</TABLE>"; +print "</BODY></HTML>"; OCIFreeStatement($stmt); OCILogoff($conn); ?> +]]> </programlisting> </example> </para> Index: phpdoc/en/functions/openssl.xml diff -u phpdoc/en/functions/openssl.xml:1.15 phpdoc/en/functions/openssl.xml:1.16 --- phpdoc/en/functions/openssl.xml:1.15 Sat Nov 10 16:49:39 2001 +++ phpdoc/en/functions/openssl.xml Tue Nov 20 18:58:47 2001 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.15 $ --> +<!-- $Revision: 1.16 $ --> <reference id="ref.openssl"> <title>OpenSSL functions</title> <titleabbrev>OpenSSL</titleabbrev> @@ -206,9 +206,11 @@ <example> <title><function>openssl_error_string</function> example</title> <programlisting role="php"> +<![CDATA[ // lets assume you just called an openssl function that failed while($msg = openssl_error_string) echo $msg . "<br>"; +]]> </programlisting> </example> </para> @@ -330,6 +332,7 @@ <example> <title><function>openssl_open</function> example</title> <programlisting role="php"> +<![CDATA[ // $sealed and $env_key are assumed to contain the sealed data // and our envelope key, both given to us by the sealer. @@ -347,6 +350,7 @@ // free the private key from memory openssl_free_key($pkeyid); +]]> </programlisting> </example> </para> @@ -395,6 +399,7 @@ <example> <title><function>openssl_seal</function> example</title> <programlisting role="php"> +<![CDATA[ // $data is assumed to contain the data to be sealed // fetch public keys for our recipients, and ready them @@ -415,6 +420,7 @@ // free the keys from memory openssl_free_key($pk1); openssl_free_key($pk2); +]]> </programlisting> </example> </para> @@ -456,6 +462,7 @@ <example> <title><function>openssl_sign</function> example</title> <programlisting role="php"> +<![CDATA[ // $data is assumed to contain the data to be signed // fetch private key from file and ready it @@ -469,6 +476,7 @@ // free the key from memory openssl_free_key($pkeyid); +]]> </programlisting> </example> </para> @@ -510,6 +518,7 @@ <example> <title><function>openssl_verify</function> example</title> <programlisting role="php"> +<![CDATA[ // $data and $signature are assumed to contain the data and the signature // fetch public key from certificate and ready it @@ -529,6 +538,7 @@ // free the key from memory openssl_free_key($pubkeyid); +]]> </programlisting> </example> </para> @@ -568,6 +578,7 @@ <example> <title><function>openssl_pkcs7_decrypt</function> example</title> <programlisting role="php"> +<![CDATA[ // $cert and $key are assumed to contain your personal certificate and private // key pair, and that you are the recipient of an S/MIME message $infilename = "encrypted.msg"; // this file holds your encrypted message @@ -577,7 +588,7 @@ echo "decrypted!"; else echo "failed to decrypt!"; - +]]> </programlisting> </example> </para> @@ -625,10 +636,11 @@ <example> <title><function>openssl_pkcs7_encrypt</function> example</title> <programlisting role="php"> +<![CDATA[ // the message you want to encrypt and send to your secret agent // in the field, known as nighthawk. You have his certificate // in the file nighthawk.pem -$data = <<<EOD +$data = <<<EOD Nighthawk, Top secret, for your eyes only! @@ -644,13 +656,14 @@ fclose($fp); // encrypt it if (openssl_pkcs7_encrypt("msg.txt", "enc.txt", "nighthawk.pem", - array("To" => "nighthawk@agent.com", // keyed syntax - "From: HQ <hq@cia.com>", // indexed syntax - "Subject" => "Eyes only"))) + array("To" => "nighthawk@agent.com", // keyed syntax + "From: HQ <hq@cia.com>", // indexed syntax + "Subject" => "Eyes only"))) { // message encrypted - send it! - exec(ini_get("sendmail_path") . " < enc.txt"); + exec(ini_get("sendmail_path") . " < enc.txt"); } +]]> </programlisting> </example> </para> @@ -710,9 +723,10 @@ <example> <title><function>openssl_pkcs7_sign</function> example</title> <programlisting role="php"> +<![CDATA[ // the message you want to sign so that recipient can be sure it was you that // sent it -$data = <<<EOD +$data = <<<EOD You have my authorization to spend $10,000 on dinner expenses. @@ -725,13 +739,14 @@ // encrypt it if (openssl_pkcs7_sign("msg.txt", "signed.txt", "mycert.pem", array("mycert.pem", "mypassphrase"), - array("To" => "joes@sales.com", // keyed syntax - "From: HQ <ceo@sales.com>", // indexed syntax - "Subject" => "Eyes only")) + array("To" => "joes@sales.com", // keyed syntax + "From: HQ <ceo@sales.com>", // indexed syntax + "Subject" => "Eyes only")) { // message signed - send it! exec(ini_get("sendmail_path") . " < signed.txt"); } +]]> </programlisting> </example> </para>