Ejemplo n.º 1
0
 /**
  * showCmd
  * 
  * @param string $cmd
  * @return string
  */
 public function showCmd($cmd = '')
 {
     /*
         $h = popen($cmd, 'r');
         $buf = '';
         while (!feof($h)) {
             $buf .= fgets($h, 4096);
         }
         pclose($h);
     */
     if (Config::get('Gmanager', 'altEncoding') != 'UTF-8') {
         $cmd = mb_convert_encoding($cmd, Config::get('Gmanager', 'altEncoding'), 'UTF-8');
     }
     if ($h = proc_open($cmd, array(array('pipe', 'r'), array('pipe', 'w')), $pipes)) {
         //fwrite($pipes[0], '');
         fclose($pipes[0]);
         $buf = stream_get_contents($pipes[1]);
         fclose($pipes[1]);
         proc_close($h);
         if (Config::get('Gmanager', 'consoleEncoding') != 'UTF-8') {
             $buf = mb_convert_encoding($buf, 'UTF-8', Config::get('Gmanager', 'consoleEncoding'));
         }
     } else {
         return '<div class="red">' . Language::get('cmd_error') . '<br/></div>';
     }
     return '<div class="input">' . Language::get('result') . '<br/><textarea class="lines" cols="48" rows="' . Helper_View::getRows($buf) . '">' . htmlspecialchars($buf, ENT_NOQUOTES) . '</textarea></div>';
 }