2
/* $Id: text_plain__external.inc.php 8340 2006-01-19 15:39:29Z cybot_tm $ */
3
// vim: expandtab sw=4 ts=4 sts=4:
5
function PMA_transformation_text_plain__external_nowrap($options = array()) {
6
if (!isset($options[3]) || $options[3] == '') {
8
} elseif ($options[3] == '1' || $options[3] == 1) {
17
function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
18
// possibly use a global transform and feed it with special options:
19
// include('./libraries/transformations/global.inc.php');
21
// further operations on $buffer using the $options[] array.
23
$allowed_programs = array();
28
// It's up to administrator to allow anything here. Note that users may
29
// specify any parameters, so when programs allow output redirection or
30
// any other possibly dangerous operations, you should write wrapper
31
// script that will publish only functions you really want.
33
// Add here program definitions like (note that these are NOT safe
36
//$allowed_programs[0] = '/usr/local/bin/tidy';
37
//$allowed_programs[1] = '/usr/local/bin/validate';
39
// no-op when no allowed programs
40
if (count($allowed_programs) == 0) {
44
if (!isset($options[0]) || $options[0] == '' || !isset($allowed_programs[$options[0]])) {
45
$program = $allowed_programs[0];
47
$program = $allowed_programs[$options[0]];
50
if (!isset($options[1]) || $options[1] == '') {
51
$poptions = '-f /dev/null -i -wrap -q';
53
$poptions = $options[1];
56
if (!isset($options[2]) || $options[2] == '') {
60
if (!isset($options[3]) || $options[3] == '') {
66
$descriptorspec = array(
67
0 => array("pipe", "r"),
68
1 => array("pipe", "w")
70
$process = proc_open($program . ' ' . $poptions, $descriptorspec, $pipes);
71
if (is_resource($process)) {
72
fwrite($pipes[0], $buffer);
75
while (!feof($pipes[1])) {
76
$newstring .= fgets($pipes[1], 1024);
79
// we don't currently use the return value
80
$return_value = proc_close($process);
83
if ($options[2] == 1 || $options[2] == '2') {
84
$retstring = htmlspecialchars($newstring);
86
$retstring = $newstring;