-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.php
More file actions
46 lines (36 loc) · 836 Bytes
/
bash.php
File metadata and controls
46 lines (36 loc) · 836 Bytes
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
<?php
require "vendor/autoload.php";
use Joli\JoliNotif\Notification;
use Joli\JoliNotif\NotifierFactory;
use Symfony\Component\DomCrawler\Crawler;
$pid = pcntl_fork();
if ($pid == -1) {
echo "Something is wrong!";
}
elseif ($pid) {
exit;
}
posix_setsid();
$client = new GuzzleHttp\Client();
// Create a Notifier (or null if no notifier supported)
$notifier = NotifierFactory::create();
$stop_server = FALSE;
while (!$stop_server) {
$res = $client->get('http://bash.im/random');
$html = $res->getBody()->getContents();
$crawler = new Crawler($html);
if ($notifier) {
// Create your notification
$notification =
(new Notification())
->setTitle('bash.im')
->setBody($crawler->filter('div.text')->first()->html())
;
// Send it
$notifier->send($notification);
sleep(500);
}
else {
break;
}
}