2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * @package phpMyAdmin-Transformation
11 function PMA_transformation_text_plain__external_nowrap($options = array()) {
12 if (!isset($options[3]) ||
$options[3] == '') {
14 } elseif ($options[3] == '1' ||
$options[3] == 1) {
23 function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
24 // possibly use a global transform and feed it with special options:
25 // include './libraries/transformations/global.inc.php';
27 // further operations on $buffer using the $options[] array.
29 $allowed_programs = array();
34 // It's up to administrator to allow anything here. Note that users may
35 // specify any parameters, so when programs allow output redirection or
36 // any other possibly dangerous operations, you should write wrapper
37 // script that will publish only functions you really want.
39 // Add here program definitions like (note that these are NOT safe
42 //$allowed_programs[0] = '/usr/local/bin/tidy';
43 //$allowed_programs[1] = '/usr/local/bin/validate';
45 // no-op when no allowed programs
46 if (count($allowed_programs) == 0) {
50 if (!isset($options[0]) ||
$options[0] == '' ||
!isset($allowed_programs[$options[0]])) {
51 $program = $allowed_programs[0];
53 $program = $allowed_programs[$options[0]];
56 if (!isset($options[1]) ||
$options[1] == '') {
57 $poptions = '-f /dev/null -i -wrap -q';
59 $poptions = $options[1];
62 if (!isset($options[2]) ||
$options[2] == '') {
66 if (!isset($options[3]) ||
$options[3] == '') {
72 $descriptorspec = array(
73 0 => array("pipe", "r"),
74 1 => array("pipe", "w")
76 $process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes);
77 if (is_resource($process)) {
78 fwrite($pipes[0], $buffer);
81 while (!feof($pipes[1])) {
82 $newstring .= fgets($pipes[1], 1024);
85 // we don't currently use the return value
86 $return_value = proc_close($process);
89 if ($options[2] == 1 ||
$options[2] == '2') {
90 $retstring = htmlspecialchars($newstring);
92 $retstring = $newstring;