diff --git a/Blacklight/AniDB.php b/Blacklight/AniDB.php index 7dbd6a965..c9874a347 100755 --- a/Blacklight/AniDB.php +++ b/Blacklight/AniDB.php @@ -2,15 +2,14 @@ namespace Blacklight; -use Blacklight\db\DB; use App\Models\Category; use App\Models\AnidbTitle; -use Illuminate\Support\Facades\DB as DBFacade; +use Illuminate\Support\Facades\DB; class AniDB { /** - * @var \Blacklight\db\DB + * @var \PDO */ public $pdo; @@ -26,7 +25,7 @@ class AniDB ]; $options += $defaults; - $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); + $this->pdo = DB::connection()->getPdo(); } /** @@ -50,7 +49,7 @@ class AniDB */ public function updateTitle($anidbID, $title, $type, $startdate, $enddate, $related, $similar, $creators, $description, $rating, $categories, $characters, $epnos, $airdates, $episodetitles): void { - $this->pdo->queryExec( + DB::update( sprintf( ' UPDATE anidb_titles at @@ -60,20 +59,20 @@ class AniDB related = %s, similar = %s, creators = %s, description = %s, rating = %s, categories = %s, characters = %s, epnos = %s, airdates = %s, episodetitles = %s WHERE anidbid = %d', - $this->pdo->escapeString($title), - $this->pdo->escapeString($type), - $this->pdo->escapeString($startdate), - $this->pdo->escapeString($enddate), - $this->pdo->escapeString($related), - $this->pdo->escapeString($similar), - $this->pdo->escapeString($creators), - $this->pdo->escapeString($description), - $this->pdo->escapeString($rating), - $this->pdo->escapeString($categories), - $this->pdo->escapeString($characters), - $this->pdo->escapeString($epnos), - $this->pdo->escapeString($airdates), - $this->pdo->escapeString($episodetitles), + $this->pdo->quote($title), + $this->pdo->quote($type), + $this->pdo->quote($startdate), + $this->pdo->quote($enddate), + $this->pdo->quote($related), + $this->pdo->quote($similar), + $this->pdo->quote($creators), + $this->pdo->quote($description), + $this->pdo->quote($rating), + $this->pdo->quote($categories), + $this->pdo->quote($characters), + $this->pdo->quote($epnos), + $this->pdo->quote($airdates), + $this->pdo->quote($episodetitles), $anidbID ) ); @@ -86,7 +85,7 @@ class AniDB */ public function deleteTitle($anidbID): void { - $this->pdo->queryExec( + DB::delete( sprintf( ' DELETE at, ai, ae @@ -115,14 +114,14 @@ class AniDB if ($letter === '0-9') { $letter = '[0-9]'; } - $rsql .= sprintf('AND at.title REGEXP %s', $this->pdo->escapeString('^'.$letter)); + $rsql .= sprintf('AND at.title REGEXP %s', $this->pdo->quote('^'.$letter)); } if ($animetitle !== '') { - $tsql .= sprintf('AND at.title %s', $this->pdo->likeString($animetitle, true, true)); + $tsql .= sprintf('AND at.title LIKE %s', $this->pdo->quote('%'.$animetitle.'%')); } - return $this->pdo->queryDirect( + return DB::select( sprintf( ' SELECT at.anidbid, at.title, @@ -156,7 +155,7 @@ class AniDB if ($animetitle !== '') { $query->where('at.title', 'like', '%'.$animetitle.'%'); } - $query->select(['at.anidbid', DBFacade::raw("GROUP_CONCAT(at.title SEPARATOR ', ') AS title"), 'ai.description']) + $query->select(['at.anidbid', DB::raw("GROUP_CONCAT(at.title SEPARATOR ', ') AS title"), 'ai.description']) ->from('anidb_titles as at') ->leftJoin('anidb_info as ai', 'ai.anidbid', '=', 'at.anidbid') ->groupBy('at.anidbid') @@ -168,12 +167,14 @@ class AniDB /** * Retrieves all info for a specific AniDB ID. * - * @param int $anidbID - * @return array|bool + * + * @param $anidbID + * + * @return mixed */ public function getAnimeInfo($anidbID) { - $animeInfo = $this->pdo->query( + $animeInfo = DB::select( sprintf( ' SELECT at.anidbid, at.lang, at.title, diff --git a/Changelog b/Changelog index 3beabf3e0..54a214cd2 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-07-10 DariusIII + * Chg: Update AniDB class and related Controller and view * Fix: Fix couple of errors in NameFixer class * Chg: Update NZBContents and NNTP classes * Chg: Update NZB class, remove usage of Blacklight\DB class diff --git a/app/Http/Controllers/AnimeController.php b/app/Http/Controllers/AnimeController.php index 628684dc3..76c0bd1d3 100644 --- a/app/Http/Controllers/AnimeController.php +++ b/app/Http/Controllers/AnimeController.php @@ -45,10 +45,10 @@ class AnimeController extends BasePageController // force the category to TV_ANIME as it should be for anime, as $catarray was NULL and we know the category for sure for anime $aniDbReleases = $this->releases->animeSearch($request->input('id'), 0, 1000, '', [Category::TV_ANIME], -1); $aniDbInfo = $this->aniDb->getAnimeInfo($request->input('id')); - $title = $aniDbInfo['title']; - $meta_title = 'View Anime '.$aniDbInfo['title']; + $title = $aniDbInfo->title; + $meta_title = 'View Anime '.$aniDbInfo->title; $meta_keywords = 'view,anime,anidb,description,details'; - $meta_description = 'View '.$aniDbInfo['title'].' Anime'; + $meta_description = 'View '.$aniDbInfo->title.' Anime'; if (! $this->releases && ! $aniDbInfo) { $this->show404(); @@ -57,22 +57,21 @@ class AnimeController extends BasePageController } elseif (! $aniDbReleases) { $this->smarty->assign('nodata', 'No releases for this series.'); } else { - $this->smarty->assign('anidb', $aniDbInfo); $this->smarty->assign('animeEpisodeTitles', $aniDbReleases); $this->smarty->assign([ - 'animeAnidbid' => $aniDbInfo['anidbid'], - 'animeTitle' => $aniDbInfo['title'], - 'animeType' => $aniDbInfo['type'], - 'animePicture' => $aniDbInfo['picture'], - 'animeStartDate' => $aniDbInfo['startdate'], - 'animeEndDate' => $aniDbInfo['enddate'], - 'animeDescription' => $aniDbInfo['description'], - 'animeRating' => $aniDbInfo['rating'], - 'animeRelated' => $aniDbInfo['related'], - 'animeSimilar' => $aniDbInfo['similar'], - 'animeCategories' => $aniDbInfo['categories'], - 'animeCreators' => $aniDbInfo['creators'], - 'animeCharacters' => $aniDbInfo['characters'], + 'animeAnidbid' => $aniDbInfo->anidbid, + 'animeTitle' => $aniDbInfo->title, + 'animeType' => $aniDbInfo->type, + 'animePicture' => $aniDbInfo->picture, + 'animeStartDate' => $aniDbInfo->startdate, + 'animeEndDate' => $aniDbInfo->enddate, + 'animeDescription' => $aniDbInfo->description, + 'animeRating' => $aniDbInfo->rating, + 'animeRelated' => $aniDbInfo->related, + 'animeSimilar' => $aniDbInfo->similar, + 'animeCategories' => $aniDbInfo->categories, + 'animeCreators' => $aniDbInfo->creators, + 'animeCharacters' => $aniDbInfo->characters, ]); $this->smarty->assign('nodata', ''); @@ -117,10 +116,10 @@ class AnimeController extends BasePageController $animelist = []; if ($masterserieslist instanceof \Traversable) { foreach ($masterserieslist as $s) { - if (preg_match('/^[0-9]/', $s['title'])) { + if (preg_match('/^[0-9]/', $s->title)) { $thisrange = '0-9'; } else { - preg_match('/([A-Z]).*/i', $s['title'], $matches); + preg_match('/([A-Z]).*/i', $s->title, $matches); $thisrange = strtoupper($matches[1]); } $animelist[$thisrange][] = $s; diff --git a/resources/views/themes/Gentele/viewanimelist.tpl b/resources/views/themes/Gentele/viewanimelist.tpl index 1a3862f29..3c836e689 100755 --- a/resources/views/themes/Gentele/viewanimelist.tpl +++ b/resources/views/themes/Gentele/viewanimelist.tpl @@ -42,14 +42,14 @@ {foreach $anime as $a} {$a.title|escape:"htmlall"}{if {$a.startdate} != ''} -
({$a.startdate|date_format} - - {/if}{if $a.enddate != ''}{$a.enddate|date_format}){/if} - {if {$a.type} != ''}{$a.type|escape:"htmlall"}{/if} - {if {$a.categories} != ''}{$a.categories|escape:"htmlall"|replace:'|':', '}{/if} - {if {$a.rating} != ''}{$a.rating}{/if} + href="{$smarty.const.WWW_TOP}/anime?id={$a->anidbid}">{$a->title|escape:"htmlall"}{if {$a->startdate} != ''} +
({$a->startdate|date_format} + - {/if}{if $a->enddate != ''}{$a->enddate|date_format}){/if} + {if {$a->type} != ''}{$a->type|escape:"htmlall"}{/if} + {if {$a->categories} != ''}{$a->categories|escape:"htmlall"|replace:'|':', '}{/if} + {if {$a->rating} != ''}{$a->rating}{/if} AniDB + href="{$site->dereferrer_link}http://anidb.net/perl-bin/animedb.pl?show=anime&aid={$a->anidbid}">AniDB {/foreach}