00001 <?php
00002
00003
00004
00005 function PMA_EscapeShellArg($string, $prepend = '\'') {
00006 return $prepend . ereg_replace("'", "'\\''", $string) . $prepend;
00007 }
00008
00009 function PMA_transformation_text_plain__external_nowrap($options = array()) {
00010 if (!isset($options[3]) || $options[3] == '') {
00011 $nowrap = true;
00012 } elseif ($options[3] == '1' || $options[3] == 1) {
00013 $nowrap = true;
00014 } else {
00015 $nowrap = false;
00016 }
00017
00018 return $nowrap;
00019 }
00020
00021 function PMA_transformation_text_plain__external($buffer, $options = array(), $meta = '') {
00022
00023
00024
00025
00026
00027 $allowed_programs = array();
00028 $allowed_programs[0] = '/usr/local/bin/tidy';
00029 $allowed_programs[1] = '/usr/local/bin/validate';
00030
00031 if (!isset($options[0]) || $options[0] == '') {
00032 $program = $allowed_programs[0];
00033 } else {
00034 $program = $allowed_programs[$options[0]];
00035 }
00036
00037 if (!isset($options[1]) || $options[1] == '') {
00038 $poptions = '-f /dev/null -i -wrap -q';
00039 } else {
00040 $poptions = $options[1];
00041 }
00042
00043 if (!isset($options[2]) || $options[2] == '') {
00044 $options[2] = 1;
00045 }
00046
00047 if (!isset($options[3]) || $options[3] == '') {
00048 $options[3] = 1;
00049 }
00050
00051 $cmdline = 'echo ' . PMA_EscapeShellArg($buffer) . ' | ' . $program . ' ' . PMA_EscapeShellArg($poptions, '');
00052 $newstring = `$cmdline`;
00053
00054 if ($options[2] == 1 || $options[2] == '2') {
00055 $retstring = htmlspecialchars($newstring);
00056 } else {
00057 $retstring = $newstring;
00058 }
00059
00060 return $retstring;
00061 }
00062
00063 ?>