Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ////////////////////////////////////////////////////////////
- //////// script created by Shady on GNU/GPL license ////////
- //////// gg 15530223 | mail izzypjchamp@gmail.com ////////
- ////////////////////////////////////////////////////////////
- define("PATH", "/home/user_name/script_directory/");
- function read_input() {
- $stream = fopen("/dev/stdin", "r");
- $input = trim(fgets($stream, 255));
- $input = explode(' ', $input);
- fclose($stream);
- return $input;
- }
- echo "Hello I am a helper Shady, how can I help you? ";
- $src = read_input();
- switch($src[0]) {
- default:
- echo "I'm sorry, I do not know what you mean.\n(Type 'help' to get a list of functions)\n";
- break;
- case 'help':
- echo "List of functions: \ndelete_file [file] - removes the file from your PATH,\nrand [from] [to] [number] - draws a number from the interval\nabout - about me,\nauthor - my creator,\nexit - closes the script.\n";
- break;
- case 'delete_file':
- if(empty($src[1])) echo "Please enter the file name..\n";
- elseif(!file_exists(PATH.$src[1])) echo $src[1]." does not exist..\n";
- else {
- unlink(PATH.$src[1]);
- echo $src[1]." was removed!\n";
- }
- break;
- case 'rand':
- if(empty($src[1]) || empty($src[2])) echo "Enter the range of numbers.\n";
- elseif(empty($src[3])) echo "Enter the number of results.\n";
- elseif($src[1] >= $src[2]) echo "The first number must be less than the second.\n";
- else {
- echo "The drawn numbers it:\n";
- $i = 0;
- while ($i < $src[3]) {
- echo mt_rand($src[1], $src[2])." ";
- $i++;
- }
- echo "\n";
- }
- break;
- case 'today':
- echo "Today we ".date('l jS F Y, h:i A').".\n";
- break;
- case 'about':
- echo "I am a bot written in PHP, used to demonstrate PHP interaction with the Linux operating systems.\n";
- break;
- case 'author':
- echo "I was created by my Lord Shady, who did not put in me a lot of the source code, which explains why I'm so stupid. You can contact him by e-mail (izzypjchamp@gmail.com)\n";
- break;
- case 'exit':
- $farewell = array('Bye bye :)', 'See you!', 'Goodbye', 'It was nice to');
- shuffle($farewell);
- echo $farewell[0]."\n";
- break;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement