Skip to content

Instantly share code, notes, and snippets.

@wschoot
Created August 18, 2016 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wschoot/aaa98abe161532f160d06ea713a960db to your computer and use it in GitHub Desktop.
Save wschoot/aaa98abe161532f160d06ea713a960db to your computer and use it in GitHub Desktop.
<?php
## If dir exists, maintain cache so that messages don't repeat themselves
if (is_dir(__DIR__ . '/cache')) {
$filename = __DIR__ . '/cache/' . hash('crc32b', $poke_id.$gone);
if(!file_exists($filename)) {
file_put_contents($filename, "$poke_id $poke $gone\n");
} else {
exit;
}
# Check if files are older than 15 minutes
if ($handle = opendir(__DIR__ . '/cache')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$leeftijd = (time() - filemtime(__DIR__ . '/cache/'.$entry));
if ($leeftijd > 900) {
unlink(__DIR__ . '/cache/'.$entry);
}
}
}
closedir($handle);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment