Created
November 8, 2018 01:08
-
-
Save CyberT33N/6c3a29a2090fb2f1f9f873c453a79c3f to your computer and use it in GitHub Desktop.
PHP - Multi OS EXEC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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