2
0
mirror of https://github.com/narkoz/hacker-scripts synced 2025-08-23 19:07:33 +00:00

keep things simple

This commit is contained in:
Ahmad Samiei 2015-11-30 14:14:35 +08:00
parent eb7f1d840c
commit 793c49a6df
2 changed files with 16 additions and 166 deletions

5
php/composer.json Normal file
View File

@ -0,0 +1,5 @@
{
"require": {
"bestnetwork/telnet": "^1.0"
}
}

View File

@ -1,170 +1,15 @@
#!/usr/bin/env php
<?php <?php
namespace HackerScripts;
/** require 'vendor/autoload.php';
* Class fucking_coffee
*
* @package HackerSripts
*
* Lewis Lancaster 2015
*/
use HackerScripts\Lib\Telnet; use Bestnetwork\Telnet\TelnetClient;
class fucking_coffee (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');
* The telnet class $con->execute('1234', 'Password: ');
* $con->execute('sys brew');
* @var HackerScripts\Lib\Telnet sleep(24);
*/ $con->execute('sys pour');
protected $telnet;
/**
* The password for this coffee machine
*
* @var string
*/
protected $password = "";
/**
* The host of this coffee machine
*
* @var string
*/
protected $host = "";
/**
* The port of this coffee machine
*
* @var string
*/
protected $port = "";
/**
* Delay for 24 seconds.
*
* @var int
*/
protected $delay = 24;
/**
* What we do when we construct this class
*/
public function __construct()
{
/**
* Lets not run this on the weekends
*/
if( $this->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;
}
}