96 lines
2.9 KiB
PHP
Executable file
96 lines
2.9 KiB
PHP
Executable file
<?php
|
|
|
|
include "common.php";
|
|
|
|
printHeader("Add new show");
|
|
|
|
if(isset($_GET["aid"])){
|
|
$simple = isset($_GET["simple"]) ? $_GET["simple"] == 1 : false;
|
|
$clearAll = isset($_GET["clear"]) ? $_GET["clear"] == 1 : false;
|
|
$aid = intval($_GET["aid"]);
|
|
$info = $aniDB->getAnime($aid);
|
|
if($info === null){
|
|
header("Location: add.php");
|
|
die();
|
|
}
|
|
if($database->isTracking($aid) and !$simple){
|
|
if($clearAll){
|
|
$database->clearEpisodes($aid);
|
|
}
|
|
$database->clearTrackedEpisodes($aid);
|
|
}
|
|
|
|
$database->addTrack($aid);
|
|
$database->updateTrackEpisodes($aid, $simple ? 0 : -1); //Force
|
|
header("Location: show.php?aid=$aid");
|
|
die();
|
|
}
|
|
|
|
$showName = trim(isset($_GET["showName"]) ? $_GET["showName"] : ""); //XSS
|
|
|
|
$suggestions = [];
|
|
|
|
if($showName !== (string)((int)$showName) and $showName != ""){
|
|
$suggestions = $aniDB->getAllMatches($showName);
|
|
}else if($showName === (string)((int)$showName)){
|
|
$suggestions = [
|
|
(int)$showName => 0
|
|
];
|
|
/*$data = $aniDB->getAll();
|
|
ksort($data);
|
|
$start = (int) $showName;
|
|
foreach($data as $aid => $info){
|
|
if($aid >= $start){
|
|
|
|
$suggestions[$aid] = $aid - $start;
|
|
|
|
if($aid <= $aid - 100){
|
|
break;
|
|
}
|
|
}
|
|
}*/
|
|
}
|
|
|
|
|
|
?>
|
|
<form method="GET" action="add.php">
|
|
<div class="form-group">
|
|
<label for="shownName">Show name</label>
|
|
<input type="text" class="form-control" id="showName" name="showName" value="<?php echo $showName;?>"/>
|
|
<label for="matchType">Match Limit</label>
|
|
<select name="matchType" id="matchType">
|
|
<option value="100" <?php echo ((isset($_GET["matchType"]) and $_GET["matchType"] == 100) ? "selected" : "");?>>Any Match</option>
|
|
<option value="0" <?php echo ((isset($_GET["matchType"]) and $_GET["matchType"] == 0) ? "selected" : "");?>>Exact Match</option>
|
|
<option value="5" <?php echo ((isset($_GET["matchType"]) and $_GET["matchType"] == 5) ? "selected" : "");?>>Close Match</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-default">Search</button>
|
|
</form>
|
|
<?php
|
|
if(count($suggestions) > 0){
|
|
?>
|
|
<table class="table table-striped table-hover">
|
|
<tr><th>AniDB #</th><th>Show Info</th><th>Match value</th></tr>
|
|
|
|
<?php
|
|
foreach($suggestions as $aid => $lev){
|
|
if(isset($_GET["matchType"]) and $_GET["matchType"] < $lev){
|
|
continue;
|
|
}
|
|
$info = $aniDB->getAnime($aid);
|
|
$xml = new \SimpleXMLElement($aniDB->getAnimeAPI($aid));
|
|
$type = strval($xml->type);
|
|
if($type !== "" and $type !== "TV Series" and $type !== "ONA" and $type !== "OVA" and $type !== "Web"){
|
|
continue;
|
|
}
|
|
$imgUrl = "https://img7.anidb.net/pics/anime/" . strval($xml->picture);
|
|
echo "<tr><td><a href=\"https://anidb.net/perl-bin/animedb.pl?show=anime&aid=$aid\" target=\"_blank\"><img src=\"$imgUrl\" width=120/><br/>$aid</a></td><td><a href=\"add.php?aid=$aid\" style=\"font-size: 150%;\">".$info["title"]." [$type ".strval($xml->startdate)."] </a><br/>".strval($xml->description)."</td><td>$lev</td></tr>";
|
|
}
|
|
|
|
?>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
printFooter();
|