/
check.php
58 lines (46 loc) · 1.32 KB
/
check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
include __DIR__ . "/_helper.php";
$opts = new Regitra\Util\Getopt();
$options = $opts->process($argv);
foreach (array('code', 'type') as $option)
{
if (!isset($options[$option]))
{
die('Please supply --' . $option);
}
}
$person = new \Regitra\Register\Person();
$person->setPersonCode($options['code']);
$run = new \Regitra\Runner();
while (true)
{
try
{
print '.';
switch ($options['type'])
{
case 'license':
if ($run->isDrivingLicenseReady($person) === true)
{
print Regitra\Util\Console::getBeep(5);
print PHP_EOL;
print '*** License is ready!';
$twitter = new \Regitra\Util\Twitter();
$twitter->setUser('juokazdev', 'juozasjuozas');
$twitter->sendDirectMessage('juokaz', 'License is ready');
// finish checking
die();
}
break;
default:
die('Invalid type supplied');
break;
}
}
catch (\Regitra\Exception $exception)
{
print PHP_EOL;
print 'Error (' . $exception->getMessage() . ')' . PHP_EOL;
}
sleep(isset($options['refresh']) ? $options['refresh'] : 5);
}