Fix for the Open in New Window in Patient/Client->Patients search gui, take 2.
[openemr.git] / phpmyadmin / libraries / transformations / text_plain__external.inc.php
blob2342362b56affe90786b877c24019fe33bf3b474
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 function PMA_transformation_text_plain__external_nowrap($options = array()) {
12 if (!isset($options[3]) || $options[3] == '') {
13 $nowrap = true;
14 } elseif ($options[3] == '1' || $options[3] == 1) {
15 $nowrap = true;
16 } else {
17 $nowrap = false;
20 return $nowrap;
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();
32 // WARNING:
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
40 // programs):
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) {
47 return $buffer;
50 if (!isset($options[0]) || $options[0] == '' || !isset($allowed_programs[$options[0]])) {
51 $program = $allowed_programs[0];
52 } else {
53 $program = $allowed_programs[$options[0]];
56 if (!isset($options[1]) || $options[1] == '') {
57 $poptions = '-f /dev/null -i -wrap -q';
58 } else {
59 $poptions = $options[1];
62 if (!isset($options[2]) || $options[2] == '') {
63 $options[2] = 1;
66 if (!isset($options[3]) || $options[3] == '') {
67 $options[3] = 1;
70 // needs PHP >= 4.3.0
71 $newstring = '';
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);
79 fclose($pipes[0]);
81 while (!feof($pipes[1])) {
82 $newstring .= fgets($pipes[1], 1024);
84 fclose($pipes[1]);
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);
91 } else {
92 $retstring = $newstring;
95 return $retstring;