Skip to content

Instantly share code, notes, and snippets.

@CyberT33N
Created November 8, 2018 01:08
Show Gist options
  • Save CyberT33N/6c3a29a2090fb2f1f9f873c453a79c3f to your computer and use it in GitHub Desktop.
Save CyberT33N/6c3a29a2090fb2f1f9f873c453a79c3f to your computer and use it in GitHub Desktop.
PHP - Multi OS EXEC
<?PHP
/*
PHP_OS:
CYGWIN_NT-5.1
Darwin
FreeBSD
HP-UX
IRIX64
Linux
NetBSD
OpenBSD
SunOS
Unix
WIN32
WINNT
Windows
*/
if ( PHP_OS === 'WIN32' || PHP_OS === 'WINNT' || PHP_OS === 'Windows' ) {
$ourOS = 'WIN';
}
if( PHP_OS === 'Darwin' ){
$ourOS = 'MAC';
}
if( PHP_OS === 'Linux' ) {
$ourOS = 'LINUX';
}
// ################ MAIN BOT ###################################
if(isset($_POST['startBot']) && !empty($_POST['startBot'])) {
$startBot = $_POST['startBot'];
echo "We will start now your Bot (start.js)! You can manually reproduce the process by executing this files:<BR>start.bat / .sh / .command<BR><BR>EXEC Response:<BR>";
if ( $ourOS === 'WIN' ) {
echo pclose(popen('start "" ..\..\..\start.bat', 'r')); die();
}
if ( $ourOS === 'LINUX' ) {
$output = shell_exec( 'sudo gnome-terminal -e ../../../start.command 2>&1' );
echo $output;
}
if ( $ourOS === 'MAC' ){
$output = shell_exec( 'open ../../../start.command 2>&1' );
echo $output;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment