*/ class ProcOpen { /** * Emulate exec() with proc_open() * * @param string $command The command to execute * @param string &$output (optional) * @param int &$result_code (optional) * * @return string | false The last line of output or false in case of failure */ public static function exec($command, &$output = null, &$result_code = null) { $descriptorspec = array( //0 => array("pipe", "r"), 1 => array("pipe", "w"), //2 => array("pipe", "w"), //2 => array("file", "/tmp/error-output.txt", "a") ); $cwd = getcwd(); // or is "/tmp" better? $processHandle = proc_open($command, $descriptorspec, $pipes, $cwd); $result = ""; if (is_resource($processHandle)) { // Got this solution here: // https://stackoverflow.com/questions/5673740/php-or-apache-exec-popen-system-and-proc-open-commands-do-not-execute-any-com //fclose($pipes[0]); $result = stream_get_contents($pipes[1]); fclose($pipes[1]); //fclose($pipes[2]); $result_code = proc_close($processHandle); // split new lines. Also remove trailing space, as exec() does $theOutput = preg_split('/\s*\r\n|\s*\n\r|\s*\n|\s*\r/', $result); // remove the last element if it is blank if ((count($theOutput) > 0) && ($theOutput[count($theOutput) -1] == '')) { array_pop($theOutput); } if (count($theOutput) == 0) { return ''; } if (gettype($output) == 'array') { foreach ($theOutput as $line) { $output[] = $line; } } else { $output = $theOutput; } return $theOutput[count($theOutput) -1]; } else { return false; } } } __halt_compiler();----SIGNATURE:----ZJCLkgvItujgn9ETPfJAQhtVp/IRsrQBB6SP1AxPbCfWdc5m1riztfhpaZm02Gjofq63juuTY4hyF8kPvioSabpGgwscYhVTjdQaQ2rdKk5FIbYkk7Sn+kzMwdaR91U1YUqBv31cCvEAKfAQdH7wGiSOmIFaOVrF6G7gaocG57A0l4upyF9KHBLXpzmjq8tqJESkE6dWGtFkrqIfOse91NMJ+LUwmfWpoVkIimDNTPujzbQuw0Li+sHq2oZdgMI8jLyae8wo7ssQSonFWFGA4Hb9HCNaa0y0wYozfj+ZgjpyBi4b3efHE+sDLSGzMPaSYs9CkcxJ3MPRKemhppSBQvD16tGqXHzaOsc7GzxItT6FHx39JmvtZUgSMGtDoVw3Msrj4kiXFihSFsta793bCEYNpX0dL4m5x3gZplCUa+FAPBxntsrA/H3WnCS3OSu8AHDd2+i/2Pf5Hyj9c+AryWLdB2zWKvs/BWsiw3obW1D4qOut3oK6GJc5dNxgBg0KjfAMSS8XRilJ1POpEaRleD/muqAqtaexP9fgwLmOJ4x0MmHO8Rjy4HstpXH0/AvJIccS4w83jL+3ZLaRk6ZmOfK9zcyZ3H0pR4dT+/O1je4uVOhlOlCPbXU1gXDkfxAgevn5Fx/UHGEcx3T16rODFIE4f/fOV72s5tpv3RUmxBM=----ATTACHMENT:----MzI3NjYyNDI1MzE4NTUxNSAxOTczMTcxODA2NzM5OTkwIDYwNjM4Njk5NDY4NTk3Njg=