@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | abstract class Site_Model extends CI_Model { |
| 4 | 4 | public $site = ''; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | final protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE, bool $isPost = FALSE, array $postFields = []) { |
| 33 | 33 | $ch = curl_init(); |
| 34 | 34 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 35 | - curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
| 35 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
| 36 | 36 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
| 37 | 37 | curl_setopt($ch, CURLOPT_HEADER, 1); |
| 38 | 38 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | curl_setopt($ch, CURLOPT_URL, $url); |
| 51 | 51 | |
| 52 | 52 | if($isPost) { |
| 53 | - curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
| 54 | - curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
| 53 | + curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
| 54 | + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $response = curl_exec($ch); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $nodes_row = $xpath->query($node_row_string); |
| 119 | 119 | if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 120 | 120 | $firstRow = $nodes_row->item(0); |
| 121 | - $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
| 121 | + $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
| 122 | 122 | |
| 123 | 123 | if($node_chapter_string !== '') { |
| 124 | 124 | $nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | $link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 255 | 255 | $chapterURLSegments = explode('/', $link); |
| 256 | - $titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : ""); |
|
| 257 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 256 | + $titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : ""); |
|
| 257 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | return (!empty($titleData) ? $titleData : NULL); |
@@ -297,8 +297,8 @@ discard block |
||
| 297 | 297 | |
| 298 | 298 | $link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 299 | 299 | $chapterURLSegments = explode('/', $link); |
| 300 | - $titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : ""); |
|
| 301 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 300 | + $titleData['latest_chapter'] = $chapterURLSegments[5].(isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : ""); |
|
| 301 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | return (!empty($titleData) ? $titleData : NULL); |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | |
| 330 | 330 | $chapter_parts = explode(':--:', $chapter); |
| 331 | 331 | return [ |
| 332 | - 'url' => "http://bato.to/reader#" . $chapter_parts[0], |
|
| 332 | + 'url' => "http://bato.to/reader#".$chapter_parts[0], |
|
| 333 | 333 | 'number' => $chapter_parts[1] |
| 334 | 334 | ]; |
| 335 | 335 | } |
@@ -364,13 +364,13 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | ///^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/ |
| 366 | 366 | preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($data['nodes_chapter']->nodeValue), $text); |
| 367 | - $titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22) . ':--:' . ((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '') . 'c'.$text['chapter'] . (!empty($text['extra']) ? '-'.$text['extra'] : '')); |
|
| 367 | + $titleData['latest_chapter'] = substr($data['nodes_chapter']->getAttribute('href'), 22).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : '')); |
|
| 368 | 368 | |
| 369 | 369 | $dateString = $data['nodes_latest']->nodeValue; |
| 370 | 370 | if($dateString == 'An hour ago') { |
| 371 | 371 | $dateString = '1 hour ago'; |
| 372 | 372 | } |
| 373 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString))); |
|
| 373 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString))); |
|
| 374 | 374 | |
| 375 | 375 | if($firstGet && $lang == 'English') { |
| 376 | 376 | //FIXME: English is forced due for now. See #78. |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | $chapter = $nodes_chapter->item(0); |
| 473 | 473 | preg_match('/^(?:Vol\.(?<volume>\S+) )?(?:Ch.(?<chapter>[^\s:]+)(?:\s?-\s?(?<extra>[0-9]+))?):?.*/', trim($chapter->nodeValue), $text); |
| 474 | - $titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8) . ':--:' . ((!empty($text['volume']) ? 'v' . $text['volume'] . '/' : '') . 'c' . $text['chapter'] . (!empty($text['extra']) ? '-' . $text['extra'] : '')); |
|
| 474 | + $titleData['latest_chapter'] = substr($chapter->getAttribute('href'), 8).':--:'.((!empty($text['volume']) ? 'v'.$text['volume'].'/' : '').'c'.$text['chapter'].(!empty($text['extra']) ? '-'.$text['extra'] : '')); |
|
| 475 | 475 | |
| 476 | 476 | $dateString = $nodes_latest->item(0)->nodeValue; |
| 477 | 477 | if($dateString == 'An hour ago') { |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | */ |
| 521 | 521 | |
| 522 | 522 | $chapterData = [ |
| 523 | - 'url' => 'http://dynasty-scans.com/chapters/' . $title_parts[0].'_'.$chapter, |
|
| 523 | + 'url' => 'http://dynasty-scans.com/chapters/'.$title_parts[0].'_'.$chapter, |
|
| 524 | 524 | 'number' => '' |
| 525 | 525 | ]; |
| 526 | 526 | |
@@ -575,13 +575,13 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $chapterURLSegments = explode('/', (string) $data['nodes_chapter']->getAttribute('href')); |
| 578 | - if (strpos($chapterURLSegments[2], $title_parts[0]) !== false) { |
|
| 578 | + if(strpos($chapterURLSegments[2], $title_parts[0]) !== false) { |
|
| 579 | 579 | $titleData['latest_chapter'] = substr($chapterURLSegments[2], strlen($title_parts[0]) + 1); |
| 580 | 580 | } else { |
| 581 | 581 | $titleData['latest_chapter'] = $chapterURLSegments[2]; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9)))); |
|
| 584 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(str_replace("'", '', substr((string) $data['nodes_latest']->textContent, 9)))); |
|
| 585 | 585 | } |
| 586 | 586 | break; |
| 587 | 587 | |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | preg_match('/<b>.*<\/b>/', $data, $matchesT); |
| 593 | 593 | preg_match('/\/doujins\/[^"]+">(.+)?(?=<\/a>)<\/a>/', $data, $matchesD); |
| 594 | - $titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '') . substr($matchesT[0], 3, -4); |
|
| 594 | + $titleData['title'] = (!empty($matchesD) ? ($matchesD[1] !== 'Original' ? $matchesD[1].' - ' : '') : '').substr($matchesT[0], 3, -4); |
|
| 595 | 595 | |
| 596 | 596 | $titleData['latest_chapter'] = 'oneshot'; //This will never change |
| 597 | 597 | |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | $titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 648 | 648 | |
| 649 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 649 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | return (!empty($titleData) ? $titleData : NULL); |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | |
| 690 | 690 | $titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 691 | 691 | |
| 692 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 692 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | return (!empty($titleData) ? $titleData : NULL); |
@@ -748,8 +748,8 @@ discard block |
||
| 748 | 748 | $titleData['title'] = trim((string) $xml->{'channel'}->title); |
| 749 | 749 | |
| 750 | 750 | $chapterURLSegments = explode('/', ((string) $xml->{'channel'}->item[0]->link)); |
| 751 | - $titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]) . ':--:' . $chapterURLSegments[6]; |
|
| 752 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate)); |
|
| 751 | + $titleData['latest_chapter'] = preg_replace('/^.*?([0-9]+)$/', '$1', $chapterURLSegments[7]).':--:'.$chapterURLSegments[6]; |
|
| 752 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $xml->{'channel'}->item[0]->pubDate)); |
|
| 753 | 753 | } |
| 754 | 754 | } else { |
| 755 | 755 | log_message('error', "Series missing? (WebToons): {$title_url}"); |
@@ -820,13 +820,13 @@ discard block |
||
| 820 | 820 | $titleData['title'] = $nodes_title->item(0)->textContent; |
| 821 | 821 | |
| 822 | 822 | $firstRow = $nodes_row->item(0); |
| 823 | - $nodes_latest = $xpath->query("td[2]", $firstRow); |
|
| 823 | + $nodes_latest = $xpath->query("td[2]", $firstRow); |
|
| 824 | 824 | $nodes_chapter = $xpath->query("td[1]/a", $firstRow); |
| 825 | 825 | |
| 826 | 826 | $link = (string) $nodes_chapter->item(0)->getAttribute('href'); |
| 827 | 827 | $chapterURLSegments = explode('/', preg_replace('/\?.*$/', '', $link)); |
| 828 | - $titleData['latest_chapter'] = $chapterURLSegments[3] . ':--:' . preg_replace('/.*?([0-9]+)$/', '$1', $link); |
|
| 829 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent)); |
|
| 828 | + $titleData['latest_chapter'] = $chapterURLSegments[3].':--:'.preg_replace('/.*?([0-9]+)$/', '$1', $link); |
|
| 829 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->textContent)); |
|
| 830 | 830 | } |
| 831 | 831 | } else { |
| 832 | 832 | //TODO: Throw ERRORS; |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | The bad thing is these are interchangeable, despite them showing the exact same listing page. |
| 851 | 851 | Thankfully the title_url of manga which use /forums/ seem to be appended with ".%ID%" which means we can easily check them. */ |
| 852 | 852 | |
| 853 | - if (strpos($title_url, '.') !== FALSE) { |
|
| 853 | + if(strpos($title_url, '.') !== FALSE) { |
|
| 854 | 854 | $format = "https://gameofscanlation.moe/forums/{$title_url}/"; |
| 855 | 855 | } else { |
| 856 | 856 | $format = "https://gameofscanlation.moe/projects/{$title_url}/"; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | |
| 886 | 886 | $titleData['latest_chapter'] = preg_replace('/^projects\/.*?\/(.*?)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 887 | 887 | |
| 888 | - $titleData['last_updated'] = date("Y-m-d H:i:s",(int) $data['nodes_latest']->getAttribute('title')); |
|
| 888 | + $titleData['last_updated'] = date("Y-m-d H:i:s", (int) $data['nodes_latest']->getAttribute('title')); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | return (!empty($titleData) ? $titleData : NULL); |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | $titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
| 931 | 931 | |
| 932 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13))); |
|
| 932 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13))); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | return (!empty($titleData) ? $titleData : NULL); |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | $chapter_parts = explode('/', $chapter); |
| 953 | 953 | return [ |
| 954 | 954 | 'url' => "https://reader.kireicake.com/read/{$title_url}/{$chapter}/", |
| 955 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 955 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 956 | 956 | ]; |
| 957 | 957 | } |
| 958 | 958 | |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | $chapter_parts = explode('/', $chapter); |
| 977 | 977 | return [ |
| 978 | 978 | 'url' => "https://reader.seaotterscans.com/read/{$title_url}/{$chapter}/", |
| 979 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 979 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 980 | 980 | ]; |
| 981 | 981 | } |
| 982 | 982 | |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | $chapter_parts = explode('/', $chapter); |
| 1001 | 1001 | return [ |
| 1002 | 1002 | 'url' => "http://helveticascans.com/reader/read/{$title_url}/{$chapter}/", |
| 1003 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1003 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1004 | 1004 | ]; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | $chapter_parts = explode('/', $chapter); |
| 1025 | 1025 | return [ |
| 1026 | 1026 | 'url' => "http://reader.sensescans.com/read/{$title_url}/{$chapter}/", |
| 1027 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1027 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1028 | 1028 | ]; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | $chapter_parts = explode('/', $chapter); |
| 1049 | 1049 | return [ |
| 1050 | 1050 | 'url' => "https://jaiminisbox.com/reader/read/{$title_url}/{$chapter}/", |
| 1051 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1051 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
| 1052 | 1052 | ]; |
| 1053 | 1053 | } |
| 1054 | 1054 | |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function getSiteDataFromURL(string $site_url) { |
| 159 | 159 | $query = $this->db->select('id, site_class') |
| 160 | - ->from('tracker_sites') |
|
| 161 | - ->where('site', $site_url) |
|
| 162 | - ->get(); |
|
| 160 | + ->from('tracker_sites') |
|
| 161 | + ->where('site', $site_url) |
|
| 162 | + ->get(); |
|
| 163 | 163 | |
| 164 | 164 | if($query->num_rows() > 0) { |
| 165 | 165 | $siteData = $query->row(); |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | public function getTitleID(string $titleURL, int $siteID, bool $create = TRUE) { |
| 172 | 172 | $query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.status, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE) |
| 173 | - ->from('tracker_titles') |
|
| 174 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 175 | - ->where('tracker_titles.title_url', $titleURL) |
|
| 176 | - ->where('tracker_titles.site_id', $siteID) |
|
| 177 | - ->get(); |
|
| 173 | + ->from('tracker_titles') |
|
| 174 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 175 | + ->where('tracker_titles.title_url', $titleURL) |
|
| 176 | + ->where('tracker_titles.site_id', $siteID) |
|
| 177 | + ->get(); |
|
| 178 | 178 | |
| 179 | 179 | if($query->num_rows() > 0) { |
| 180 | 180 | $id = (int) $query->row('id'); |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | //Make sure last_checked is always updated on successful run. |
| 188 | 188 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 189 | 189 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 190 | - ->where('id', $id) |
|
| 191 | - ->update('tracker_titles'); |
|
| 190 | + ->where('id', $id) |
|
| 191 | + ->update('tracker_titles'); |
|
| 192 | 192 | } |
| 193 | 193 | } else { |
| 194 | 194 | log_message('error', "{$query->row('title')} failed to update successfully"); |
@@ -227,14 +227,14 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | $idQuery = $this->db->select('id') |
| 230 | - ->where('user_id', $userID) |
|
| 231 | - ->where('title_id', $titleID) |
|
| 232 | - ->get('tracker_chapters'); |
|
| 230 | + ->where('user_id', $userID) |
|
| 231 | + ->where('title_id', $titleID) |
|
| 232 | + ->get('tracker_chapters'); |
|
| 233 | 233 | if($idQuery->num_rows() > 0) { |
| 234 | 234 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 235 | - ->where('user_id', $userID) |
|
| 236 | - ->where('title_id', $titleID) |
|
| 237 | - ->update('tracker_chapters'); |
|
| 235 | + ->where('user_id', $userID) |
|
| 236 | + ->where('title_id', $titleID) |
|
| 237 | + ->update('tracker_chapters'); |
|
| 238 | 238 | |
| 239 | 239 | if($success) { |
| 240 | 240 | $idQueryRow = $idQuery->row(); |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | public function updateTrackerByID(int $userID, int $chapterID, string $chapter) : bool { |
| 261 | 261 | $success = (bool) $this->db->set(['current_chapter' => $chapter, 'active' => 'Y', 'last_updated' => NULL]) |
| 262 | - ->where('user_id', $userID) |
|
| 263 | - ->where('id', $chapterID) |
|
| 264 | - ->update('tracker_chapters'); |
|
| 262 | + ->where('user_id', $userID) |
|
| 263 | + ->where('id', $chapterID) |
|
| 264 | + ->update('tracker_chapters'); |
|
| 265 | 265 | |
| 266 | 266 | if($success) { |
| 267 | 267 | $this->History->userUpdateTitle($chapterID, $chapter); |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | //This is to allow user history to function properly. |
| 275 | 275 | |
| 276 | 276 | $success = $this->db->set(['active' => 'N', 'last_updated' => NULL]) |
| 277 | - ->where('user_id', $userID) |
|
| 278 | - ->where('id', $chapterID) |
|
| 279 | - ->update('tracker_chapters'); |
|
| 277 | + ->where('user_id', $userID) |
|
| 278 | + ->where('id', $chapterID) |
|
| 279 | + ->update('tracker_chapters'); |
|
| 280 | 280 | |
| 281 | 281 | return (bool) $success; |
| 282 | 282 | } |
| 283 | 283 | private function updateTitleById(int $id, string $latestChapter) { |
| 284 | 284 | //FIXME: Really not too happy with how we're doing history stuff here, it just feels messy. |
| 285 | 285 | $query = $this->db->select('latest_chapter AS current_chapter') |
| 286 | - ->from('tracker_titles') |
|
| 287 | - ->where('id', $id) |
|
| 288 | - ->get(); |
|
| 286 | + ->from('tracker_titles') |
|
| 287 | + ->where('id', $id) |
|
| 288 | + ->get(); |
|
| 289 | 289 | $row = $query->row(); |
| 290 | 290 | |
| 291 | 291 | $success = $this->db->set(['latest_chapter' => $latestChapter]) //last_updated gets updated via a trigger if something changes |
| 292 | - ->where('id', $id) |
|
| 293 | - ->update('tracker_titles'); |
|
| 292 | + ->where('id', $id) |
|
| 293 | + ->update('tracker_titles'); |
|
| 294 | 294 | |
| 295 | 295 | //Update History |
| 296 | 296 | //NOTE: To avoid doing another query to grab the last_updated time, we just use time() which <should> get the same thing. |
@@ -301,16 +301,16 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | private function updateTitleDataById(int $id, array $titleData) { |
| 303 | 303 | $success = $this->db->set($titleData) |
| 304 | - ->where('id', $id) |
|
| 305 | - ->update('tracker_titles'); |
|
| 304 | + ->where('id', $id) |
|
| 305 | + ->update('tracker_titles'); |
|
| 306 | 306 | |
| 307 | 307 | return (bool) $success; |
| 308 | 308 | } |
| 309 | 309 | private function addTitle(string $titleURL, int $siteID) { |
| 310 | 310 | $query = $this->db->select('site, site_class') |
| 311 | - ->from('tracker_sites') |
|
| 312 | - ->where('id', $siteID) |
|
| 313 | - ->get(); |
|
| 311 | + ->from('tracker_sites') |
|
| 312 | + ->where('id', $siteID) |
|
| 313 | + ->get(); |
|
| 314 | 314 | |
| 315 | 315 | $titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE); |
| 316 | 316 | |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | //Make sure last_checked is always updated on successful run. |
| 372 | 372 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 373 | 373 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 374 | - ->where('id', $row->id) |
|
| 375 | - ->update('tracker_titles'); |
|
| 374 | + ->where('id', $row->id) |
|
| 375 | + ->update('tracker_titles'); |
|
| 376 | 376 | |
| 377 | 377 | print " - ({$titleData['latest_chapter']})\n"; |
| 378 | 378 | } |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | //Make sure last_checked is always updated on successful run. |
| 397 | 397 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
| 398 | 398 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
| 399 | - ->where('id', $titleID) |
|
| 400 | - ->update('tracker_titles'); |
|
| 399 | + ->where('id', $titleID) |
|
| 400 | + ->update('tracker_titles'); |
|
| 401 | 401 | |
| 402 | 402 | print " - ({$titleData['latest_chapter']})\n"; |
| 403 | 403 | } |
@@ -518,9 +518,9 @@ discard block |
||
| 518 | 518 | } |
| 519 | 519 | public function setCategoryTrackerByID(int $userID, int $chapterID, string $category) : bool { |
| 520 | 520 | $success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL]) |
| 521 | - ->where('user_id', $userID) |
|
| 522 | - ->where('id', $chapterID) |
|
| 523 | - ->update('tracker_chapters'); |
|
| 521 | + ->where('user_id', $userID) |
|
| 522 | + ->where('id', $chapterID) |
|
| 523 | + ->update('tracker_chapters'); |
|
| 524 | 524 | |
| 525 | 525 | return (bool) $success; |
| 526 | 526 | } |
@@ -529,9 +529,9 @@ discard block |
||
| 529 | 529 | $success = FALSE; |
| 530 | 530 | if(preg_match("/^[a-z0-9\\-_,:]{0,255}$/", $tag_string)) { |
| 531 | 531 | $success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL]) |
| 532 | - ->where('user_id', $userID) |
|
| 533 | - ->where('id', $chapterID) |
|
| 534 | - ->update('tracker_chapters'); |
|
| 532 | + ->where('user_id', $userID) |
|
| 533 | + ->where('id', $chapterID) |
|
| 534 | + ->update('tracker_chapters'); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | if($success) { |
@@ -569,23 +569,23 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | //We need the series to be tracked |
| 571 | 571 | $idCQuery = $this->db->select('id') |
| 572 | - ->where('user_id', $userID) |
|
| 573 | - ->where('title_id', $titleID) |
|
| 574 | - ->get('tracker_chapters'); |
|
| 572 | + ->where('user_id', $userID) |
|
| 573 | + ->where('title_id', $titleID) |
|
| 574 | + ->get('tracker_chapters'); |
|
| 575 | 575 | if($idCQuery->num_rows() > 0) { |
| 576 | 576 | $idCQueryRow = $idCQuery->row(); |
| 577 | 577 | |
| 578 | 578 | //Check if it is already favourited |
| 579 | 579 | $idFQuery = $this->db->select('id') |
| 580 | - ->where('chapter_id', $idCQueryRow->id) |
|
| 581 | - ->where('chapter', $chapter) |
|
| 582 | - ->get('tracker_favourites'); |
|
| 580 | + ->where('chapter_id', $idCQueryRow->id) |
|
| 581 | + ->where('chapter', $chapter) |
|
| 582 | + ->get('tracker_favourites'); |
|
| 583 | 583 | if($idFQuery->num_rows() > 0) { |
| 584 | 584 | //Chapter is already favourited, so remove it from DB |
| 585 | 585 | $idFQueryRow = $idFQuery->row(); |
| 586 | 586 | |
| 587 | 587 | $isSuccess = (bool) $this->db->where('id', $idFQueryRow->id) |
| 588 | - ->delete('tracker_favourites'); |
|
| 588 | + ->delete('tracker_favourites'); |
|
| 589 | 589 | |
| 590 | 590 | if($isSuccess) { |
| 591 | 591 | $success = array( |
@@ -656,20 +656,20 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | public function getSites() : array { |
| 658 | 658 | $query = $this->db->select('*') |
| 659 | - ->from('tracker_sites') |
|
| 660 | - ->where('status', 'enabled') |
|
| 661 | - ->get(); |
|
| 659 | + ->from('tracker_sites') |
|
| 660 | + ->where('status', 'enabled') |
|
| 661 | + ->get(); |
|
| 662 | 662 | |
| 663 | 663 | return $query->result_array(); |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | public function getUsedCategories(int $userID) : array { |
| 667 | 667 | $query = $this->db->distinct() |
| 668 | - ->select('category') |
|
| 669 | - ->from('tracker_chapters') |
|
| 670 | - ->where('tracker_chapters.active', 'Y') |
|
| 671 | - ->where('user_id', $userID) |
|
| 672 | - ->get(); |
|
| 668 | + ->select('category') |
|
| 669 | + ->from('tracker_chapters') |
|
| 670 | + ->where('tracker_chapters.active', 'Y') |
|
| 671 | + ->where('user_id', $userID) |
|
| 672 | + ->get(); |
|
| 673 | 673 | |
| 674 | 674 | return array_column($query->result_array(), 'category'); |
| 675 | 675 | } |
@@ -680,51 +680,51 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | //CHECK: Is it possible to merge some of these queries? |
| 682 | 682 | $queryUsers = $this->db->select([ |
| 683 | - 'COUNT(*) AS total_users', |
|
| 684 | - 'SUM(CASE WHEN api_key IS NOT NULL THEN 1 ELSE 0 END) AS validated_users', |
|
| 685 | - 'SUM(CASE WHEN (api_key IS NOT NULL AND from_unixtime(last_login) > DATE_SUB(NOW(), INTERVAL 7 DAY)) THEN 1 ELSE 0 END) AS active_users' |
|
| 686 | - ], FALSE) |
|
| 687 | - ->from('auth_users') |
|
| 688 | - ->get(); |
|
| 683 | + 'COUNT(*) AS total_users', |
|
| 684 | + 'SUM(CASE WHEN api_key IS NOT NULL THEN 1 ELSE 0 END) AS validated_users', |
|
| 685 | + 'SUM(CASE WHEN (api_key IS NOT NULL AND from_unixtime(last_login) > DATE_SUB(NOW(), INTERVAL 7 DAY)) THEN 1 ELSE 0 END) AS active_users' |
|
| 686 | + ], FALSE) |
|
| 687 | + ->from('auth_users') |
|
| 688 | + ->get(); |
|
| 689 | 689 | $stats = array_merge($stats, $queryUsers->result_array()[0]); |
| 690 | 690 | |
| 691 | 691 | $queryCounts = $this->db->select([ |
| 692 | - 'tracker_titles.title', |
|
| 693 | - 'COUNT(tracker_chapters.title_id) AS count' |
|
| 694 | - ], FALSE) |
|
| 695 | - ->from('tracker_chapters') |
|
| 696 | - ->join('tracker_titles', 'tracker_titles.id = tracker_chapters.title_id', 'left') |
|
| 697 | - ->group_by('tracker_chapters.title_id') |
|
| 698 | - ->having('count > 1') |
|
| 699 | - ->order_by('count DESC') |
|
| 700 | - ->get(); |
|
| 692 | + 'tracker_titles.title', |
|
| 693 | + 'COUNT(tracker_chapters.title_id) AS count' |
|
| 694 | + ], FALSE) |
|
| 695 | + ->from('tracker_chapters') |
|
| 696 | + ->join('tracker_titles', 'tracker_titles.id = tracker_chapters.title_id', 'left') |
|
| 697 | + ->group_by('tracker_chapters.title_id') |
|
| 698 | + ->having('count > 1') |
|
| 699 | + ->order_by('count DESC') |
|
| 700 | + ->get(); |
|
| 701 | 701 | $stats['titles_tracked_more'] = count($queryCounts->result_array()); |
| 702 | 702 | $stats['top_title_name'] = $queryCounts->result_array()[0]['title'] ?? 'N/A'; |
| 703 | 703 | $stats['top_title_count'] = $queryCounts->result_array()[0]['count'] ?? 'N/A'; |
| 704 | 704 | |
| 705 | 705 | $queryTitles = $this->db->select([ |
| 706 | - 'COUNT(DISTINCT tracker_titles.id) AS total_titles', |
|
| 707 | - 'COUNT(DISTINCT tracker_titles.site_id) AS total_sites', |
|
| 708 | - 'SUM(CASE WHEN from_unixtime(auth_users.last_login) > DATE_SUB(NOW(), INTERVAL 120 HOUR) IS NOT NULL THEN 0 ELSE 1 END) AS inactive_titles', |
|
| 709 | - 'SUM(CASE WHEN (tracker_titles.last_updated > DATE_SUB(NOW(), INTERVAL 24 HOUR)) THEN 1 ELSE 0 END) AS updated_titles' |
|
| 710 | - ], FALSE) |
|
| 711 | - ->from('tracker_titles') |
|
| 712 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 713 | - ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left') |
|
| 714 | - ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left') |
|
| 715 | - ->get(); |
|
| 706 | + 'COUNT(DISTINCT tracker_titles.id) AS total_titles', |
|
| 707 | + 'COUNT(DISTINCT tracker_titles.site_id) AS total_sites', |
|
| 708 | + 'SUM(CASE WHEN from_unixtime(auth_users.last_login) > DATE_SUB(NOW(), INTERVAL 120 HOUR) IS NOT NULL THEN 0 ELSE 1 END) AS inactive_titles', |
|
| 709 | + 'SUM(CASE WHEN (tracker_titles.last_updated > DATE_SUB(NOW(), INTERVAL 24 HOUR)) THEN 1 ELSE 0 END) AS updated_titles' |
|
| 710 | + ], FALSE) |
|
| 711 | + ->from('tracker_titles') |
|
| 712 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 713 | + ->join('tracker_chapters', 'tracker_titles.id = tracker_chapters.title_id', 'left') |
|
| 714 | + ->join('auth_users', 'tracker_chapters.user_id = auth_users.id', 'left') |
|
| 715 | + ->get(); |
|
| 716 | 716 | $stats = array_merge($stats, $queryTitles->result_array()[0]); |
| 717 | 717 | |
| 718 | 718 | $querySites = $this->db->select([ |
| 719 | - 'tracker_sites.site', |
|
| 720 | - 'COUNT(*) AS count' |
|
| 721 | - ], FALSE) |
|
| 722 | - ->from('tracker_titles') |
|
| 723 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 724 | - ->group_by('tracker_titles.site_id') |
|
| 725 | - ->order_by('count DESC') |
|
| 726 | - ->limit(3) |
|
| 727 | - ->get(); |
|
| 719 | + 'tracker_sites.site', |
|
| 720 | + 'COUNT(*) AS count' |
|
| 721 | + ], FALSE) |
|
| 722 | + ->from('tracker_titles') |
|
| 723 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
| 724 | + ->group_by('tracker_titles.site_id') |
|
| 725 | + ->order_by('count DESC') |
|
| 726 | + ->limit(3) |
|
| 727 | + ->get(); |
|
| 728 | 728 | $querySitesResult = $querySites->result_array(); |
| 729 | 729 | $stats['rank1_site'] = $querySitesResult[0]['site']; |
| 730 | 730 | $stats['rank1_site_count'] = $querySitesResult[0]['count']; |
@@ -734,17 +734,17 @@ discard block |
||
| 734 | 734 | $stats['rank3_site_count'] = $querySitesResult[2]['count']; |
| 735 | 735 | |
| 736 | 736 | $queryTitlesU = $this->db->select([ |
| 737 | - 'COUNT(*) AS title_updated_count' |
|
| 738 | - ], FALSE) |
|
| 739 | - ->from('tracker_titles_history') |
|
| 740 | - ->get(); |
|
| 737 | + 'COUNT(*) AS title_updated_count' |
|
| 738 | + ], FALSE) |
|
| 739 | + ->from('tracker_titles_history') |
|
| 740 | + ->get(); |
|
| 741 | 741 | $stats = array_merge($stats, $queryTitlesU->result_array()[0]); |
| 742 | 742 | |
| 743 | 743 | $queryUsersU = $this->db->select([ |
| 744 | - 'COUNT(*) AS user_updated_count' |
|
| 745 | - ], FALSE) |
|
| 746 | - ->from('tracker_user_history') |
|
| 747 | - ->get(); |
|
| 744 | + 'COUNT(*) AS user_updated_count' |
|
| 745 | + ], FALSE) |
|
| 746 | + ->from('tracker_user_history') |
|
| 747 | + ->get(); |
|
| 748 | 748 | $stats = array_merge($stats, $queryUsersU->result_array()[0]); |
| 749 | 749 | |
| 750 | 750 | $stats['live_time'] = timespan(/*2016-09-10T03:17:19*/ 1473477439, time(), 2); |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
| 2 | 2 | |
| 3 | 3 | class Tracker_Model extends CI_Model { |
| 4 | 4 | public $sites; |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | ]; |
| 51 | 51 | } |
| 52 | 52 | if($query->num_rows() > 0) { |
| 53 | - foreach ($query->result() as $row) { |
|
| 54 | - $is_unread = intval($row->latest_chapter == $row->current_chapter ? '1' : '0'); |
|
| 53 | + foreach($query->result() as $row) { |
|
| 54 | + $is_unread = intval($row->latest_chapter == $row->current_chapter ? '1' : '0'); |
|
| 55 | 55 | $arr['series'][$row->category]['unread_count'] = (($arr['series'][$row->category]['unread_count'] ?? 0) + !$is_unread); |
| 56 | 56 | $data = [ |
| 57 | 57 | 'id' => $row->id, |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | //NOTE: This does not sort in the same way as tablesorter, but it works better. |
| 90 | 90 | switch($this->User_Options->get('list_sort_type')) { |
| 91 | 91 | case 'unread': |
| 92 | - foreach (array_keys($arr['series']) as $category) { |
|
| 93 | - usort($arr['series'][$category]['manga'], function ($a, $b) { |
|
| 92 | + foreach(array_keys($arr['series']) as $category) { |
|
| 93 | + usort($arr['series'][$category]['manga'], function($a, $b) { |
|
| 94 | 94 | $a_text = strtolower("{$a['new_chapter_exists']} - {$a['title_data']['title']}"); |
| 95 | 95 | $b_text = strtolower("{$b['new_chapter_exists']} - {$b['title_data']['title']}"); |
| 96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | break; |
| 105 | 105 | |
| 106 | 106 | case 'alphabetical': |
| 107 | - foreach (array_keys($arr['series']) as $category) { |
|
| 108 | - usort($arr['series'][$category]['manga'], function ($a, $b) { |
|
| 107 | + foreach(array_keys($arr['series']) as $category) { |
|
| 108 | + usort($arr['series'][$category]['manga'], function($a, $b) { |
|
| 109 | 109 | $a_text = strtolower("{$a['title_data']['title']}"); |
| 110 | 110 | $b_text = strtolower("{$b['title_data']['title']}"); |
| 111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | break; |
| 120 | 120 | |
| 121 | 121 | case 'my_status': |
| 122 | - foreach (array_keys($arr['series']) as $category) { |
|
| 123 | - usort($arr['series'][$category]['manga'], function ($a, $b) { |
|
| 122 | + foreach(array_keys($arr['series']) as $category) { |
|
| 123 | + usort($arr['series'][$category]['manga'], function($a, $b) { |
|
| 124 | 124 | $a_text = strtolower("{$a['generated_current_data']['number']}"); |
| 125 | 125 | $b_text = strtolower("{$b['generated_current_data']['number']}"); |
| 126 | 126 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | break; |
| 135 | 135 | |
| 136 | 136 | case 'latest': |
| 137 | - foreach (array_keys($arr['series']) as $category) { |
|
| 138 | - usort($arr['series'][$category]['manga'], function ($a, $b) { |
|
| 137 | + foreach(array_keys($arr['series']) as $category) { |
|
| 138 | + usort($arr['series'][$category]['manga'], function($a, $b) { |
|
| 139 | 139 | $a_text = strtolower("{$a['generated_latest_data']['number']}"); |
| 140 | 140 | $b_text = strtolower("{$b['generated_latest_data']['number']}"); |
| 141 | 141 | |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | ->get(); |
| 362 | 362 | |
| 363 | 363 | if($query->num_rows() > 0) { |
| 364 | - foreach ($query->result() as $row) { |
|
| 364 | + foreach($query->result() as $row) { |
|
| 365 | 365 | print "> {$row->title} <{$row->site_class}>"; //Print this prior to doing anything so we can more easily find out if something went wrong |
| 366 | 366 | $titleData = $this->sites->{$row->site_class}->getTitleData($row->title_url); |
| 367 | 367 | if(is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
@@ -386,9 +386,9 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | public function updateCustom() { |
| 388 | 388 | $sites = $this->getSites(); |
| 389 | - foreach ($sites as $site) { |
|
| 389 | + foreach($sites as $site) { |
|
| 390 | 390 | if($titleDataList = $this->sites->{$site['site_class']}->doCustomUpdate()) { |
| 391 | - foreach ($titleDataList as $titleURL => $titleData) { |
|
| 391 | + foreach($titleDataList as $titleURL => $titleData) { |
|
| 392 | 392 | print "> {$titleData['title']} <{$site['site_class']}>"; //Print this prior to doing anything so we can more easily find out if something went wrong |
| 393 | 393 | if(is_array($titleData) && !is_null($titleData['latest_chapter'])) { |
| 394 | 394 | if($titleID = $this->getTitleID($titleURL, (int) $site['id'], FALSE)) { |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | $arr = []; |
| 430 | 430 | if($query->num_rows() > 0) { |
| 431 | - foreach ($query->result() as $row) { |
|
| 431 | + foreach($query->result() as $row) { |
|
| 432 | 432 | $arr[$row->category][] = [ |
| 433 | 433 | 'site' => $row->site, |
| 434 | 434 | 'title_url' => $row->title_url, |
@@ -82,7 +82,9 @@ discard block |
||
| 82 | 82 | ]; |
| 83 | 83 | $arr['series'][$row->category]['manga'][] = $data; |
| 84 | 84 | |
| 85 | - if(!$arr['has_inactive']) $arr['has_inactive'] = !$data['title_data']['active']; |
|
| 85 | + if(!$arr['has_inactive']) { |
|
| 86 | + $arr['has_inactive'] = !$data['title_data']['active']; |
|
| 87 | + } |
|
| 86 | 88 | } |
| 87 | 89 | |
| 88 | 90 | //CHECK: Is this good for speed? |
@@ -198,9 +200,13 @@ discard block |
||
| 198 | 200 | $titleID = $id; |
| 199 | 201 | } else { |
| 200 | 202 | //TODO: Check if title is valid URL! |
| 201 | - if($create) $titleID = $this->addTitle($titleURL, $siteID); |
|
| 203 | + if($create) { |
|
| 204 | + $titleID = $this->addTitle($titleURL, $siteID); |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + if(!$titleID) { |
|
| 208 | + $titleID = 0; |
|
| 202 | 209 | } |
| 203 | - if(!$titleID) $titleID = 0; |
|
| 204 | 210 | |
| 205 | 211 | return $titleID; |
| 206 | 212 | } |