inputEnc); // // However, htmlentities is very limited in it's ability to process // character encodings. We have to rely on something more powerful. if (version_compare(phpversion(), "4.1.0", "<")) { // In this case, we can't do any better than assume that the // input encoding is ISO-8859-1. $str = htmlentities($str, ENT_COMPAT); } else { $str = toOutputEncoding($str, $rep->getContentEncoding()); // $str is now encoded as UTF-8. $str = htmlentities($str, ENT_COMPAT, $config->outputEnc); } return $str; } // }}} // {{{ toOutputEncoding function toOutputEncoding($str, $inputEncoding = "") { global $config; if (empty($inputEncoding)) { $inputEncoding = $config->inputEnc; } // Try to convert the messages based on the locale information if ($config->inputEnc && $config->outputEnc) { if (function_exists("iconv")) { $output = @iconv($inputEncoding, $config->outputEnc, $str); if (!empty($output)) { $str = $output; } } } return $str; } // }}} // {{{ quoteCommand function quoteCommand($cmd) { global $config; // On Windows machines, the whole line needs quotes round it so that it's // passed to cmd.exe correctly if ($config->serverIsWindows) { $cmd = "\"$cmd\""; } return $cmd; } // }}} // {{{ execCommand function execCommand($cmd, &$retcode) { global $config; // On Windows machines, the whole line needs quotes round it so that it's // passed to cmd.exe correctly // Since php 5.3.0 the quoting seems to be done internally if ($config->serverIsWindows && version_compare(PHP_VERSION, '5.3.0alpha') === -1) { $cmd = "\"$cmd\""; } return @exec($cmd, $tmp, $retcode); } // }}} // {{{ popenCommand function popenCommand($cmd, $mode) { global $config; // On Windows machines, the whole line needs quotes round it so that it's // passed to cmd.exe correctly // Since php 5.3.0 the quoting seems to be done internally if ($config->serverIsWindows && version_compare(PHP_VERSION, '5.3.0alpha') === -1) { $cmd = "\"$cmd\""; } return popen($cmd, $mode); } // }}} // {{{ passthruCommand function passthruCommand($cmd) { global $config; // On Windows machines, the whole line needs quotes round it so that it's // passed to cmd.exe correctly // Since php 5.3.0 the quoting seems to be done internally if ($config->serverIsWindows && version_compare(PHP_VERSION, '5.3.0alpha') === -1) { $cmd = "\"$cmd\""; } return passthru($cmd); } // }}} // {{{ runCommand function runCommand($cmd, $mayReturnNothing = false) { global $lang; $output = array(); $err = false; $c = quoteCommand($cmd); $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $resource = proc_open($c, $descriptorspec, $pipes); $error = ""; if (!is_resource($resource)) { echo"
".$lang['BADCMD'].": ".$cmd."
".$lang['BADCMD'].": ".$cmd."
".nl2br($error)."
"; } } // }}} // {{{ quote // // Quote a string to send to the command line function quote($str) { global $config; if ($config->serverIsWindows) { return "\"$str\""; } else { return escapeshellarg($str); } } // }}} inputEnc); // // However, htmlentities is very limited in it's ability to process // character encodings. We have to rely on something more powerful. if (version_compare(phpversion(), "4.1.0", "<")) { // In this case, we can't do any better than assume that the // input encoding is ISO-8859-1. $str = htmlentities($str, ENT_COMPAT); } else { $str = toOutputEncoding($str, $rep->getContentEncoding()); // $str is now encoded as UTF-8. $str = htmlentities($str, ENT_COMPAT, $config->outputEnc); } return $str; } // }}} // {{{ toOutputEncoding function toOutputEncoding($str, $inputEncoding = "") { global $config; if (empty($inputEncoding)) { $inputEncoding = $config->inputEnc; } // Try to convert the messages based on the locale information if ($config->inputEnc && $config->outputEnc) { if (function_exists("iconv")) { $output = @iconv($inputEncoding, $config->outputEnc, $str); if (!empty($output)) { $str = $output; } } } return $str; } // }}} // {{{ quoteCommand function quoteCommand($cmd) { global $config; // On Windows machines, the whole line needs quotes round it so that it's // passed to cmd.exe correctly if ($config->serverIsWindows) { $cmd = "\"$cmd\""; } return $cmd; } // }}} // {{{ runCommand function runCommand($cmd, $mayReturnNothing = false) { global $lang; $output = array(); $err = false; $c = quoteCommand($cmd); $descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')); $resource = proc_open($c, $descriptorspec, $pipes); $error = ""; if (!is_resource($resource)) { echo"".$lang['BADCMD'].": ".$cmd."
".$lang['BADCMD'].": ".$cmd."
".nl2br($error)."
"; } } // }}} // {{{ quote // // Quote a string to send to the command line function quote($str) { global $config; if ($config->serverIsWindows) { return "\"$str\""; } else { return escapeshellarg($str); } } // }}}![]() ![]() |
websvn |
Subversion Repositories: |
Rev 1 | Rev 3 |
---|