Documentation TYPO3 par Ameos

text_plain__external.inc.php

00001 <?php
00002 /* $Id: text_plain__external.inc.php,v 2.7 2005/08/14 21:34:01 lem9 Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 function PMA_transformation_text_plain__external_nowrap($options = array()) {
00006     if (!isset($options[3]) || $options[3] == '') {
00007         $nowrap = true;
00008     } elseif ($options[3] == '1' || $options[3] == 1) {
00009         $nowrap = true;
00010     } else {
00011         $nowrap = false;
00012     }
00013 
00014     return $nowrap;
00015 }
00016 
00017 function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
00018     // possibly use a global transform and feed it with special options:
00019     // include('./libraries/transformations/global.inc.php');
00020 
00021     // further operations on $buffer using the $options[] array.
00022 
00023     $allowed_programs = array();
00024 
00025     //
00026     // WARNING:
00027     //
00028     // It's up to administrator to allow anything here. Note that users may
00029     // specify any parameters, so when programs allow output redirection or
00030     // any other possibly dangerous operations, you should write wrapper
00031     // script that will publish only functions you really want.
00032     //
00033     // Add here program definitions like (note that these are NOT safe
00034     // programs):
00035     //
00036     //$allowed_programs[0] = '/usr/local/bin/tidy';
00037     //$allowed_programs[1] = '/usr/local/bin/validate';
00038 
00039     // no-op when no allowed programs
00040     if (count($allowed_programs) == 0) {
00041         return $buffer;
00042     }
00043 
00044     if (!isset($options[0]) ||  $options[0] == '' || !isset($allowed_programs[$options[0]])) {
00045         $program = $allowed_programs[0];
00046     } else {
00047         $program = $allowed_programs[$options[0]];
00048     }
00049 
00050     if (!isset($options[1]) || $options[1] == '') {
00051         $poptions = '-f /dev/null -i -wrap -q';
00052     } else {
00053         $poptions = $options[1];
00054     }
00055 
00056     if (!isset($options[2]) || $options[2] == '') {
00057         $options[2] = 1;
00058     }
00059 
00060     if (!isset($options[3]) || $options[3] == '') {
00061         $options[3] = 1;
00062     }
00063 
00064     // needs PHP >= 4.3.0
00065     $newstring = '';
00066     $descriptorspec = array(
00067         0 => array("pipe", "r"),
00068         1 => array("pipe", "w")
00069     );
00070     $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes = array());
00071     if (is_resource($process)) {
00072         fwrite($pipes[0], $buffer);
00073         fclose($pipes[0]);
00074 
00075         while (!feof($pipes[1])) {
00076             $newstring .= fgets($pipes[1], 1024);
00077         }
00078         fclose($pipes[1]);
00079         // we don't currently use the return value 
00080         $return_value = proc_close($process);
00081     }
00082 
00083     if ($options[2] == 1 || $options[2] == '2') {
00084         $retstring = htmlspecialchars($newstring);
00085     } else {
00086         $retstring = $newstring;
00087     }
00088 
00089     return $retstring;
00090 }
00091 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6