Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandresalome committed Jan 10, 2012
1 parent ea28c96 commit c5c7fd4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
cache
vendor

2 changes: 1 addition & 1 deletion composer.json
@@ -1,5 +1,5 @@
{
"require": {
"symfony/browser-kit": "2.1.0-dev"
"kriswallsmith/buzz": "master-dev"
}
}
45 changes: 45 additions & 0 deletions read-title.php
@@ -0,0 +1,45 @@
<?php
require_once __DIR__.'/vendor/.composer/autoload.php';

$dataDir = __DIR__.'/cache';

if (!is_dir($dataDir)) {
mkdir($dataDir);
}

if (!isset($argv[1])) {
echo "Usage: php read-title.php mon-url\n";
exit;
}

$url = $argv[1];
$hash = md5($url);

$file = $dataDir.'/'.md5($hash);

if (file_exists($file)) {
list($statusCode, $content) = unserialize(file_get_contents($file));
} else {
$statusCode = $content = null;
}

$browser = new Buzz\Browser();

$browser->call($url, 'GET');
$response = $browser->getLastResponse();

$newStatusCode = $response->getStatusCode();
$newContent = $response->getContent();

if ($statusCode !== null && $content !== null) {
if ($newStatusCode != $statusCode || $newContent != $content) {
echo 'The page has changed !'."\n";
echo 'Old status code: '.$statusCode."\n";
echo 'New status code: '.$newStatusCode."\n";
echo '------'."\n";
echo $newContent;
exec("notify-send 'FREE!!! FREE!!! FREE!!! FREE!!! FREE!!! FREE!!! FREE!!! FREE!!! FREE!!! FREE!!!'");
}
}

file_put_contents($file, serialize(array($newStatusCode, $newContent)));

0 comments on commit c5c7fd4

Please sign in to comment.