Ensure searchindex table is created as MyISAM
[lhc/web/wiklou.git] / includes / memcached-client.php
1 <?php
2 //
3 // +---------------------------------------------------------------------------+
4 // | memcached client, PHP |
5 // +---------------------------------------------------------------------------+
6 // | Copyright (c) 2003 Ryan T. Dean <rtdean@cytherianage.net> |
7 // | All rights reserved. |
8 // | |
9 // | Redistribution and use in source and binary forms, with or without |
10 // | modification, are permitted provided that the following conditions |
11 // | are met: |
12 // | |
13 // | 1. Redistributions of source code must retain the above copyright |
14 // | notice, this list of conditions and the following disclaimer. |
15 // | 2. Redistributions in binary form must reproduce the above copyright |
16 // | notice, this list of conditions and the following disclaimer in the |
17 // | documentation and/or other materials provided with the distribution. |
18 // | |
19 // | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
20 // | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
21 // | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
22 // | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
24 // | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 // | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 // | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 // | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 // +---------------------------------------------------------------------------+
30 // | Author: Ryan T. Dean <rtdean@cytherianage.net> |
31 // | Heavily influenced by the Perl memcached client by Brad Fitzpatrick. |
32 // | Permission granted by Brad Fitzpatrick for relicense of ported Perl |
33 // | client logic under 2-clause BSD license. |
34 // +---------------------------------------------------------------------------+
35 //
36 // $TCAnet$
37 //
38
39 /**
40 * This is the PHP client for memcached - a distributed memory cache daemon.
41 * More information is available at http://www.danga.com/memcached/
42 *
43 * Usage example:
44 *
45 * require_once 'memcached.php';
46 *
47 * $mc = new memcached(array(
48 * 'servers' => array('127.0.0.1:10000',
49 * array('192.0.0.1:10010', 2),
50 * '127.0.0.1:10020'),
51 * 'debug' => false,
52 * 'compress_threshold' => 10240,
53 * 'persistant' => true));
54 *
55 * $mc->add('key', array('some', 'array'));
56 * $mc->replace('key', 'some random string');
57 * $val = $mc->get('key');
58 *
59 * @author Ryan T. Dean <rtdean@cytherianage.net>
60 * @package memcached-client
61 * @version 0.1.2
62 */
63
64 // {{{ requirements
65 // }}}
66
67 // {{{ constants
68 // {{{ flags
69
70 /**
71 * Flag: indicates data is serialized
72 */
73 define("MEMCACHE_SERIALIZED", 1<<0);
74
75 /**
76 * Flag: indicates data is compressed
77 */
78 define("MEMCACHE_COMPRESSED", 1<<1);
79
80 // }}}
81
82 /**
83 * Minimum savings to store data compressed
84 */
85 define("COMPRESSION_SAVINGS", 0.20);
86
87 // }}}
88
89 // {{{ class memcached
90 /**
91 * memcached client class implemented using (p)fsockopen()
92 *
93 * @author Ryan T. Dean <rtdean@cytherianage.net>
94 * @package memcached-client
95 */
96 class memcached
97 {
98 // {{{ properties
99 // {{{ public
100
101 /**
102 * Command statistics
103 *
104 * @var array
105 * @access public
106 */
107 var $stats;
108
109 // }}}
110 // {{{ private
111
112 /**
113 * Cached Sockets that are connected
114 *
115 * @var array
116 * @access private
117 */
118 var $_cache_sock;
119
120 /**
121 * Current debug status; 0 - none to 9 - profiling
122 *
123 * @var boolean
124 * @access private
125 */
126 var $_debug;
127
128 /**
129 * Dead hosts, assoc array, 'host'=>'unixtime when ok to check again'
130 *
131 * @var array
132 * @access private
133 */
134 var $_host_dead;
135
136 /**
137 * Is compression available?
138 *
139 * @var boolean
140 * @access private
141 */
142 var $_have_zlib;
143
144 /**
145 * Do we want to use compression?
146 *
147 * @var boolean
148 * @access private
149 */
150 var $_compress_enable;
151
152 /**
153 * At how many bytes should we compress?
154 *
155 * @var interger
156 * @access private
157 */
158 var $_compress_threshold;
159
160 /**
161 * Are we using persistant links?
162 *
163 * @var boolean
164 * @access private
165 */
166 var $_persistant;
167
168 /**
169 * If only using one server; contains ip:port to connect to
170 *
171 * @var string
172 * @access private
173 */
174 var $_single_sock;
175
176 /**
177 * Array containing ip:port or array(ip:port, weight)
178 *
179 * @var array
180 * @access private
181 */
182 var $_servers;
183
184 /**
185 * Our bit buckets
186 *
187 * @var array
188 * @access private
189 */
190 var $_buckets;
191
192 /**
193 * Total # of bit buckets we have
194 *
195 * @var interger
196 * @access private
197 */
198 var $_bucketcount;
199
200 /**
201 * # of total servers we have
202 *
203 * @var interger
204 * @access private
205 */
206 var $_active;
207
208 // }}}
209 // }}}
210 // {{{ methods
211 // {{{ public functions
212 // {{{ memcached()
213
214 /**
215 * Memcache initializer
216 *
217 * @param array $args Associative array of settings
218 *
219 * @return mixed
220 * @access public
221 */
222 function memcached ($args)
223 {
224 $this->set_servers(@$args['servers']);
225 $this->_debug = @$args['debug'];
226 $this->stats = array();
227 $this->_compress_threshold = @$args['compress_threshold'];
228 $this->_persistant = array_key_exists('persistant', $args) ? (@$args['persistant']) : false;
229 $this->_compress_enable = true;
230 $this->_have_zlib = function_exists("gzcompress");
231
232 $this->_cache_sock = array();
233 $this->_host_dead = array();
234 }
235
236 // }}}
237 // {{{ add()
238
239 /**
240 * Adds a key/value to the memcache server if one isn't already set with
241 * that key
242 *
243 * @param string $key Key to set with data
244 * @param mixed $val Value to store
245 * @param interger $exp (optional) Time to expire data at
246 *
247 * @return boolean
248 * @access public
249 */
250 function add ($key, $val, $exp = 0)
251 {
252 return $this->_set('add', $key, $val, $exp);
253 }
254
255 // }}}
256 // {{{ decr()
257
258 /**
259 * Decriment a value stored on the memcache server
260 *
261 * @param string $key Key to decriment
262 * @param interger $amt (optional) Amount to decriment
263 *
264 * @return mixed FALSE on failure, value on success
265 * @access public
266 */
267 function decr ($key, $amt=1)
268 {
269 return $this->_incrdecr('decr', $key, $amt);
270 }
271
272 // }}}
273 // {{{ delete()
274
275 /**
276 * Deletes a key from the server, optionally after $time
277 *
278 * @param string $key Key to delete
279 * @param interger $time (optional) How long to wait before deleting
280 *
281 * @return boolean TRUE on success, FALSE on failure
282 * @access public
283 */
284 function delete ($key, $time = 0)
285 {
286 if (!$this->_active)
287 return false;
288
289 $sock = $this->get_sock($key);
290 if (!is_resource($sock))
291 return false;
292
293 $key = is_array($key) ? $key[1] : $key;
294
295 @$this->stats['delete']++;
296 $cmd = "delete $key $time\r\n";
297 if(!fwrite($sock, $cmd, strlen($cmd)))
298 {
299 $this->_dead_sock($sock);
300 return false;
301 }
302 $res = trim(fgets($sock));
303
304 if ($this->_debug)
305 $this->_debugprint(sprintf("MemCache: delete %s (%s)\n", $key, $res));
306
307 if ($res == "DELETED")
308 return true;
309 return false;
310 }
311
312 // }}}
313 // {{{ disconnect_all()
314
315 /**
316 * Disconnects all connected sockets
317 *
318 * @access public
319 */
320 function disconnect_all ()
321 {
322 foreach ($this->_cache_sock as $sock)
323 fclose($sock);
324
325 $this->_cache_sock = array();
326 }
327
328 // }}}
329 // {{{ enable_compress()
330
331 /**
332 * Enable / Disable compression
333 *
334 * @param boolean $enable TRUE to enable, FALSE to disable
335 *
336 * @access public
337 */
338 function enable_compress ($enable)
339 {
340 $this->_compress_enable = $enable;
341 }
342
343 // }}}
344 // {{{ forget_dead_hosts()
345
346 /**
347 * Forget about all of the dead hosts
348 *
349 * @access public
350 */
351 function forget_dead_hosts ()
352 {
353 $this->_host_dead = array();
354 }
355
356 // }}}
357 // {{{ get()
358
359 /**
360 * Retrieves the value associated with the key from the memcache server
361 *
362 * @param string $key Key to retrieve
363 *
364 * @return mixed
365 * @access public
366 */
367 function get ($key)
368 {
369 if (!$this->_active)
370 return false;
371
372 $sock = $this->get_sock($key);
373
374 if (!is_resource($sock))
375 return false;
376
377 @$this->stats['get']++;
378
379 $cmd = "get $key\r\n";
380 if (!fwrite($sock, $cmd, strlen($cmd)))
381 {
382 $this->_dead_sock($sock);
383 return false;
384 }
385
386 $val = array();
387 $this->_load_items($sock, $val);
388
389 if ($this->_debug)
390 foreach ($val as $k => $v)
391 $this->_debugprint(@sprintf("MemCache: sock %s got %s => %s\r\n", serialize($sock), $k, $v));
392
393 return @$val[$key];
394 }
395
396 // }}}
397 // {{{ get_multi()
398
399 /**
400 * Get multiple keys from the server(s)
401 *
402 * @param array $keys Keys to retrieve
403 *
404 * @return array
405 * @access public
406 */
407 function get_multi ($keys)
408 {
409 if (!$this->_active)
410 return false;
411
412 $this->stats['get_multi']++;
413
414 foreach ($keys as $key)
415 {
416 $sock = $this->get_sock($key);
417 if (!is_resource($sock)) continue;
418 $key = is_array($key) ? $key[1] : $key;
419 if (!isset($sock_keys[$sock]))
420 {
421 $sock_keys[$sock] = array();
422 $socks[] = $sock;
423 }
424 $sock_keys[$sock][] = $key;
425 }
426
427 // Send out the requests
428 foreach ($socks as $sock)
429 {
430 $cmd = "get";
431 foreach ($sock_keys[$sock] as $key)
432 {
433 $cmd .= " ". $key;
434 }
435 $cmd .= "\r\n";
436
437 if (fwrite($sock, $cmd, strlen($cmd)))
438 {
439 $gather[] = $sock;
440 } else
441 {
442 $this->_dead_sock($sock);
443 }
444 }
445
446 // Parse responses
447 $val = array();
448 foreach ($gather as $sock)
449 {
450 $this->_load_items($sock, $val);
451 }
452
453 if ($this->_debug)
454 foreach ($val as $k => $v)
455 $this->_debugprint(sprintf("MemCache: got %s => %s\r\n", $k, $v));
456
457 return $val;
458 }
459
460 // }}}
461 // {{{ incr()
462
463 /**
464 * Increments $key (optionally) by $amt
465 *
466 * @param string $key Key to increment
467 * @param interger $amt (optional) amount to increment
468 *
469 * @return interger New key value?
470 * @access public
471 */
472 function incr ($key, $amt=1)
473 {
474 return $this->_incrdecr('incr', $key, $amt);
475 }
476
477 // }}}
478 // {{{ replace()
479
480 /**
481 * Overwrites an existing value for key; only works if key is already set
482 *
483 * @param string $key Key to set value as
484 * @param mixed $value Value to store
485 * @param interger $exp (optional) Experiation time
486 *
487 * @return boolean
488 * @access public
489 */
490 function replace ($key, $value, $exp=0)
491 {
492 return $this->_set('replace', $key, $value, $exp);
493 }
494
495 // }}}
496 // {{{ run_command()
497
498 /**
499 * Passes through $cmd to the memcache server connected by $sock; returns
500 * output as an array (null array if no output)
501 *
502 * NOTE: due to a possible bug in how PHP reads while using fgets(), each
503 * line may not be terminated by a \r\n. More specifically, my testing
504 * has shown that, on FreeBSD at least, each line is terminated only
505 * with a \n. This is with the PHP flag auto_detect_line_endings set
506 * to falase (the default).
507 *
508 * @param resource $sock Socket to send command on
509 * @param string $cmd Command to run
510 *
511 * @return array Output array
512 * @access public
513 */
514 function run_command ($sock, $cmd)
515 {
516 if (!is_resource($sock))
517 return array();
518
519 if (!fwrite($sock, $cmd, strlen($cmd)))
520 return array();
521
522 while (true)
523 {
524 $res = fgets($sock);
525 $ret[] = $res;
526 if (preg_match('/^END/', $res))
527 break;
528 if (strlen($res) == 0)
529 break;
530 }
531 return $ret;
532 }
533
534 // }}}
535 // {{{ set()
536
537 /**
538 * Unconditionally sets a key to a given value in the memcache. Returns true
539 * if set successfully.
540 *
541 * @param string $key Key to set value as
542 * @param mixed $value Value to set
543 * @param interger $exp (optional) Experiation time
544 *
545 * @return boolean TRUE on success
546 * @access public
547 */
548 function set ($key, $value, $exp=0)
549 {
550 return $this->_set('set', $key, $value, $exp);
551 }
552
553 // }}}
554 // {{{ set_compress_threshold()
555
556 /**
557 * Sets the compression threshold
558 *
559 * @param interger $thresh Threshold to compress if larger than
560 *
561 * @access public
562 */
563 function set_compress_threshold ($thresh)
564 {
565 $this->_compress_threshold = $thresh;
566 }
567
568 // }}}
569 // {{{ set_debug()
570
571 /**
572 * Sets the debug flag
573 *
574 * @param boolean $dbg TRUE for debugging, FALSE otherwise
575 *
576 * @access public
577 *
578 * @see memcahced::memcached
579 */
580 function set_debug ($dbg)
581 {
582 $this->_debug = $dbg;
583 }
584
585 // }}}
586 // {{{ set_servers()
587
588 /**
589 * Sets the server list to distribute key gets and puts between
590 *
591 * @param array $list Array of servers to connect to
592 *
593 * @access public
594 *
595 * @see memcached::memcached()
596 */
597 function set_servers ($list)
598 {
599 $this->_servers = $list;
600 $this->_active = count($list);
601 $this->_buckets = null;
602 $this->_bucketcount = 0;
603
604 $this->_single_sock = null;
605 if ($this->_active == 1)
606 $this->_single_sock = $this->_servers[0];
607 }
608
609 // }}}
610 // }}}
611 // {{{ private methods
612 // {{{ _close_sock()
613
614 /**
615 * Close the specified socket
616 *
617 * @param string $sock Socket to close
618 *
619 * @access private
620 */
621 function _close_sock ($sock)
622 {
623 $host = array_search($sock, $this->_cache_sock);
624 fclose($this->_cache_sock[$host]);
625 unset($this->_cache_sock[$host]);
626 }
627
628 // }}}
629 // {{{ _connect_sock()
630
631 /**
632 * Connects $sock to $host, timing out after $timeout
633 *
634 * @param interger $sock Socket to connect
635 * @param string $host Host:IP to connect to
636 * @param float $timeout (optional) Timeout value, defaults to 0.25s
637 *
638 * @return boolean
639 * @access private
640 */
641 function _connect_sock (&$sock, $host, $timeout = 0.25)
642 {
643 list ($ip, $port) = explode(":", $host);
644 if ($this->_persistant == 1)
645 {
646 $sock = @pfsockopen($ip, $port, $errno, $errstr, $timeout);
647 } else
648 {
649 $sock = @fsockopen($ip, $port, $errno, $errstr, $timeout);
650 }
651
652 if (!$sock)
653 return false;
654 return true;
655 }
656
657 // }}}
658 // {{{ _dead_sock()
659
660 /**
661 * Marks a host as dead until 30-40 seconds in the future
662 *
663 * @param string $sock Socket to mark as dead
664 *
665 * @access private
666 */
667 function _dead_sock ($sock)
668 {
669 $host = array_search($sock, $this->_cache_sock);
670 list ($ip, $port) = explode(":", $host);
671 $this->_host_dead[$ip] = time() + 30 + intval(rand(0, 10));
672 $this->_host_dead[$host] = $this->_host_dead[$ip];
673 unset($this->_cache_sock[$host]);
674 }
675
676 // }}}
677 // {{{ get_sock()
678
679 /**
680 * get_sock
681 *
682 * @param string $key Key to retrieve value for;
683 *
684 * @return mixed resource on success, false on failure
685 * @access private
686 */
687 function get_sock ($key)
688 {
689 if (!$this->_active)
690 return false;
691
692 if ($this->_single_sock !== null)
693 return $this->sock_to_host($this->_single_sock);
694
695 $hv = is_array($key) ? intval($key[0]) : $this->_hashfunc($key);
696
697 if ($this->_buckets === null)
698 {
699 foreach ($this->_servers as $v)
700 {
701 if (is_array($v))
702 {
703 for ($i=0; $i<$v[1]; $i++)
704 $bu[] = $v[0];
705 } else
706 {
707 $bu[] = $v;
708 }
709 }
710 $this->_buckets = $bu;
711 $this->_bucketcount = count($bu);
712 }
713
714 $realkey = is_array($key) ? $key[1] : $key;
715 for ($tries = 0; $tries<20; $tries++)
716 {
717 $host = $this->_buckets[$hv % $this->_bucketcount];
718 $sock = $this->sock_to_host($host);
719 if (is_resource($sock))
720 return $sock;
721 $hv += $this->_hashfunc($tries . $realkey);
722 }
723
724 return false;
725 }
726
727 // }}}
728 // {{{ _hashfunc()
729
730 /**
731 * Creates a hash interger based on the $key
732 *
733 * @param string $key Key to hash
734 *
735 * @return interger Hash value
736 * @access private
737 */
738 function _hashfunc ($key)
739 {
740 $hash = 0;
741 for ($i=0; $i<strlen($key); $i++)
742 {
743 $hash = $hash*33 + ord($key[$i]);
744 }
745
746 return $hash;
747 }
748
749 // }}}
750 // {{{ _incrdecr()
751
752 /**
753 * Perform increment/decriment on $key
754 *
755 * @param string $cmd Command to perform
756 * @param string $key Key to perform it on
757 * @param interger $amt Amount to adjust
758 *
759 * @return interger New value of $key
760 * @access private
761 */
762 function _incrdecr ($cmd, $key, $amt=1)
763 {
764 if (!$this->_active)
765 return null;
766
767 $sock = $this->get_sock($key);
768 if (!is_resource($sock))
769 return null;
770
771 $key = is_array($key) ? $key[1] : $key;
772 $this->stats[$cmd]++;
773 if (!fwrite($sock, "$cmd $key $amt\r\n"))
774 return $this->_dead_sock($sock);
775
776 stream_set_timeout($sock, 1, 0);
777 $line = fgets($sock);
778 if (!preg_match('/^(\d+)/', $line, $match))
779 return null;
780 return $match[1];
781 }
782
783 // }}}
784 // {{{ _load_items()
785
786 /**
787 * Load items into $ret from $sock
788 *
789 * @param resource $sock Socket to read from
790 * @param array $ret Returned values
791 *
792 * @access private
793 */
794 function _load_items ($sock, &$ret)
795 {
796 while (1)
797 {
798 $decl = fgets($sock);
799 if ($decl == "END\r\n")
800 {
801 return true;
802 } elseif (preg_match('/^VALUE (\S+) (\d+) (\d+)\r\n$/', $decl, $match))
803 {
804 list($rkey, $flags, $len) = array($match[1], $match[2], $match[3]);
805 $bneed = $len+2;
806 $offset = 0;
807
808 while ($bneed > 0)
809 {
810 $data = fread($sock, $bneed);
811 $n = strlen($data);
812 if ($n == 0)
813 break;
814 $offset += $n;
815 $bneed -= $n;
816 @$ret[$rkey] .= $data;
817 }
818
819 if ($offset != $len+2)
820 {
821 // Something is borked!
822 if ($this->_debug)
823 $this->_debugprint(sprintf("Something is borked! key %s expecting %d got %d length\n", $rkey, $len+2, $offset));
824
825 unset($ret[$rkey]);
826 $this->_close_sock($sock);
827 return false;
828 }
829
830 $ret[$rkey] = rtrim($ret[$rkey]);
831
832 if ($this->_have_zlib && $flags & MEMCACHE_COMPRESSED)
833 $ret[$rkey] = gzuncompress($ret[$rkey]);
834
835 if ($flags & MEMCACHE_SERIALIZED)
836 $ret[$rkey] = unserialize($ret[$rkey]);
837
838 } else
839 {
840 $this->_debugprint("Error parsing memcached response\n");
841 return 0;
842 }
843 }
844 }
845
846 // }}}
847 // {{{ _set()
848
849 /**
850 * Performs the requested storage operation to the memcache server
851 *
852 * @param string $cmd Command to perform
853 * @param string $key Key to act on
854 * @param mixed $val What we need to store
855 * @param interger $exp When it should expire
856 *
857 * @return boolean
858 * @access private
859 */
860 function _set ($cmd, $key, $val, $exp)
861 {
862 if (!$this->_active)
863 return false;
864
865 $sock = $this->get_sock($key);
866 if (!is_resource($sock))
867 return false;
868
869 @$this->stats[$cmd]++;
870
871 $flags = 0;
872
873 if (!is_scalar($val))
874 {
875 $val = serialize($val);
876 $flags |= MEMCACHE_SERIALIZED;
877 if ($this->_debug)
878 $this->_debugprint(sprintf("client: serializing data as it is not scalar\n"));
879 }
880
881 $len = strlen($val);
882
883 if ($this->_have_zlib && $this->_compress_enable &&
884 $this->_compress_threshold && $len >= $this->_compress_threshold)
885 {
886 $c_val = gzcompress($val, 9);
887 $c_len = strlen($c_val);
888
889 if ($c_len < $len*(1 - COMPRESS_SAVINGS))
890 {
891 if ($this->_debug)
892 $this->_debugprint(sprintf("client: compressing data; was %d bytes is now %d bytes\n", $len, $c_len));
893 $val = $c_val;
894 $len = $c_len;
895 $flags |= MEMCACHE_COMPRESSED;
896 }
897 }
898 if (!fwrite($sock, "$cmd $key $flags $exp $len\r\n$val\r\n"))
899 return $this->_dead_sock($sock);
900
901 $line = trim(fgets($sock));
902
903 if ($this->_debug)
904 {
905 if ($flags & MEMCACHE_COMPRESSED)
906 $val = 'compressed data';
907 $this->_debugprint(sprintf("MemCache: %s %s => %s (%s)\n", $cmd, $key, $val, $line));
908 }
909 if ($line == "STORED")
910 return true;
911 return false;
912 }
913
914 // }}}
915 // {{{ sock_to_host()
916
917 /**
918 * Returns the socket for the host
919 *
920 * @param string $host Host:IP to get socket for
921 *
922 * @return mixed IO Stream or false
923 * @access private
924 */
925 function sock_to_host ($host)
926 {
927 if (isset($this->_cache_sock[$host]))
928 return $this->_cache_sock[$host];
929
930 $now = time();
931 list ($ip, $port) = explode (":", $host);
932 if (isset($this->_host_dead[$host]) && $this->_host_dead[$host] > $now ||
933 isset($this->_host_dead[$ip]) && $this->_host_dead[$ip] > $now)
934 return null;
935
936 if (!$this->_connect_sock($sock, $host))
937 return $this->_dead_sock($host);
938
939 // Do not buffer writes
940 stream_set_write_buffer($sock, 0);
941
942 $this->_cache_sock[$host] = $sock;
943
944 return $this->_cache_sock[$host];
945 }
946
947 function _debugprint($str){
948 print($str);
949 }
950
951 // }}}
952 // }}}
953 // }}}
954 }
955
956 // }}}
957 ?>