requestSong( $cmd[1] ); } catch ( RuntimeException $e ) { echo "An error occured while processing the download.\n"; echo $e->getMessage() . "\n"; } break; case 'downloadmusic': echo "This function has an old CLI! Opening CLI...\n-----------\n"; new AudioVideoHandler(); echo "CLI exited. Continue with new CLI...\n"; break; case 'setsid': if( !isset( $cmd[1] ) ) { echo "Wrong usage, please use help for help.\n"; break; } echo "Setting PHPSessionID..."; $file = file_get_contents( './config.inc.php' ); $file = str_ireplace( "define( 'CURL_PHPSESSID', '' );", "define( 'CURL_PHPSESSID', '$id' );", $file ); file_put_contents( './config.inc.php', $file ); echo "OK\n"; echo "Please use 'exit' and restart the script to apply the new session id!\n"; break; case 'exit': echo "Have a nice dayyyy!!\n"; exit(); default: echo "Unkown command. Use help for help.\n"; break; } return; } ### Global System while( true ) { try { main(); } catch( Exception $e ) { echo "\n\n\nWhoops! - An error occured."; echo "\n" . $e->getMessage(); exit(); } } ## Commands function help( $a_cmd ) { echo "--- Help ---\n"; if( isset( $a_cmd[1] ) ) { switch( $a_cmd[1] ) { case 'getfile': echo "getfile id(int)"; break; case 'downloadmusic': echo "downloadmusic [artist(string)] [title(title)]"; break; case 'setsid': echo "setsid id(string)"; break; default: echo "help for this command not found!"; break; } } else { echo " getfile - Download beatmap with an id downloadmusic - Download mp3 and mp4 for an beatmap help - Show this help setsid - Set the php session id "; } echo "\n--- Help ---\n"; }