Skip to content

Instantly share code, notes, and snippets.

@XVicarious
Last active January 30, 2019 04:38
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 XVicarious/5f043a22ce20ed445cb0d9a6cf3afce4 to your computer and use it in GitHub Desktop.
Save XVicarious/5f043a22ce20ed445cb0d9a6cf3afce4 to your computer and use it in GitHub Desktop.
<?php
$aid = $_GET['aid'];
try {
$aid = intval($aid);
} catch (Exception $e) {
die('aid needs to be an integer');
}
$clientstr = 'metamaster';
$clientver = 1;
$can_request = false;
if (file_exists("$aid.anime")) {
$ctime = filectime("$aid.anime");
$diff = date_diff(time(), $ctime);
$can_request = $diff->d >= 1;
} else {
$can_request = true;
}
if ($can_request) {
$xml = file_get_contents("http://api.anidb.net:9001/httpapi?client=$clientstr&clientver=$clientver&protover=1&request=anime&aid=$aid");
file_put_contents("$aid.anime", $xml);
echo $xml;
} elseif (file_exists("$aid.anime")) {
$xml = file_get_contents("$aid.anime");
echo $xml;
} else {
echo 'something went uhoh';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment