diff --git a/php/composer.json b/php/composer.json new file mode 100644 index 0000000..fb10072 --- /dev/null +++ b/php/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "bestnetwork/telnet": "^1.0" + } +} diff --git a/php/fucking_coffee.php b/php/fucking_coffee.php index 5ab70c7..cbce398 100644 --- a/php/fucking_coffee.php +++ b/php/fucking_coffee.php @@ -1,170 +1,15 @@ +#!/usr/bin/env php IsWeekend( date('m.d.y') ) == false ) - { - - return false; - } - - /** - * Create a new telnet class - */ - - $this->telnet = new Telnet( $this->host, $this->port ); - - /** - * Once we have completed this, we can brew our coffee! - */ - - $this->BrewCoffee( function(){ - - /** - * Echo out a message - */ - - echo "coffee has been poured"; - - /** - * Unset - */ - - unset( $this->telnet ); - }); - - /** - * Return tue - */ - - return true; - } - - /** - * Brews our coffee - * - * @param $callback - */ - - public function BrewCoffee( $callback ) - { - - if( $this->telnet != null ) - { - - /** - * Execute and enter the password - */ - - $this->telnet->exec('Password: ' . $this->password); - - /** - * Brew the coffee - */ - - $this->telnet->exec('sys brew'); - - /** - * Wait - */ - - sleep( $this->delay ); - - /** - * Pour the coffee - */ - - $this->telnet->exec('sys pour'); - - /** - * Execute our callback - */ - - call_user_func( $callback ); - } - } - - /** - * Is this currently the weekend? - * - * @param $date - * - * @return bool - */ - - public function IsWeekend( $date ) - { - - if( date('N', strtotime( $date ) ) >= 6 ) - { - - return true; - } - - return false; - } - -} \ No newline at end of file +(date('N') < 6) or exit('weekend'); +(strpos(exec('who'), getenv('USER')) !== false) or exit('no session'); +sleep(17); +$con = new TelnetClient('10.10.42.42'); +$con->execute('1234', 'Password: '); +$con->execute('sys brew'); +sleep(24); +$con->execute('sys pour'); \ No newline at end of file