@@ -16,15 +16,21 @@ discard block |
||
| 16 | 16 | abstract public function isValidTitleURL(string $title_url) : bool; |
| 17 | 17 | abstract public function isValidChapter(string $chapter) : bool; |
| 18 | 18 | |
| 19 | - protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE){ |
|
| 19 | + protected function get_content(string $url, string $cookie_string = "", string $cookiejar_path = "", bool $follow_redirect = FALSE) { |
|
| 20 | 20 | $ch = curl_init(); |
| 21 | 21 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 22 | 22 | curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
| 23 | 23 | |
| 24 | - if($follow_redirect) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
| 24 | + if($follow_redirect) { |
|
| 25 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | - if(!empty($cookie_string)) curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
| 27 | - if(!empty($cookiejar_path)) curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
| 28 | + if(!empty($cookie_string)) { |
|
| 29 | + curl_setopt($ch, CURLOPT_COOKIE, $cookie_string); |
|
| 30 | + } |
|
| 31 | + if(!empty($cookiejar_path)) { |
|
| 32 | + curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar_path); |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | 35 | //Some sites check the useragent for stuff, use a pre-defined user-agent to avoid stuff. |
| 30 | 36 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2824.0 Safari/537.36'); |
@@ -78,12 +84,16 @@ discard block |
||
| 78 | 84 | |
| 79 | 85 | public function isValidTitleURL(string $title_url) : bool { |
| 80 | 86 | $success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url); |
| 81 | - if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}"); |
|
| 87 | + if(!$success) { |
|
| 88 | + log_message('error', "Invalid Title URL (MangaFox): {$title_url}"); |
|
| 89 | + } |
|
| 82 | 90 | return $success; |
| 83 | 91 | } |
| 84 | 92 | public function isValidChapter(string $chapter) : bool { |
| 85 | 93 | $success = (bool) preg_match('/^(?:v[0-9a-zA-Z]+\/)?c[0-9\.]+$/', $chapter); |
| 86 | - if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter); |
|
| 94 | + if(!$success) { |
|
| 95 | + log_message('error', 'Invalid Chapter (MangaFox): '.$chapter); |
|
| 96 | + } |
|
| 87 | 97 | return $success; |
| 88 | 98 | } |
| 89 | 99 | |
@@ -139,12 +149,16 @@ discard block |
||
| 139 | 149 | |
| 140 | 150 | public function isValidTitleURL(string $title_url) : bool { |
| 141 | 151 | $success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url); |
| 142 | - if(!$success) log_message('error', "Invalid Title URL (MangaFox): {$title_url}"); |
|
| 152 | + if(!$success) { |
|
| 153 | + log_message('error', "Invalid Title URL (MangaFox): {$title_url}"); |
|
| 154 | + } |
|
| 143 | 155 | return $success; |
| 144 | 156 | } |
| 145 | 157 | public function isValidChapter(string $chapter) : bool { |
| 146 | 158 | $success = (bool) preg_match('/^(?:v[0-9]+\/)?c[0-9]+(?:\.[0-9]+)?$/', $chapter); |
| 147 | - if(!$success) log_message('error', 'Invalid Chapter (MangaFox): '.$chapter); |
|
| 159 | + if(!$success) { |
|
| 160 | + log_message('error', 'Invalid Chapter (MangaFox): '.$chapter); |
|
| 161 | + } |
|
| 148 | 162 | return $success; |
| 149 | 163 | } |
| 150 | 164 | |
@@ -206,7 +220,9 @@ discard block |
||
| 206 | 220 | |
| 207 | 221 | public function isValidTitleURL(string $title_url) : bool { |
| 208 | 222 | $success = (bool) preg_match('/^[0-9]+:--:(?:English|Spanish|French|German|Portuguese|Turkish|Indonesian|Greek|Filipino|Italian|Polish|Thai|Malay|Hungarian|Romanian|Arabic|Hebrew|Russian|Vietnamese|Dutch)$/', $title_url); |
| 209 | - if(!$success) log_message('error', "Invalid Title URL (Batoto): {$title_url}"); |
|
| 223 | + if(!$success) { |
|
| 224 | + log_message('error', "Invalid Title URL (Batoto): {$title_url}"); |
|
| 225 | + } |
|
| 210 | 226 | return $success; |
| 211 | 227 | } |
| 212 | 228 | public function isValidChapter(string $chapter) : bool { |
@@ -214,7 +230,9 @@ discard block |
||
| 214 | 230 | // Preferably we'd just use /^[0-9a-z]+:--:(v[0-9]+\/)?c[0-9]+(\.[0-9]+)?$/ |
| 215 | 231 | |
| 216 | 232 | $success = (bool) preg_match('/^[0-9a-z]+:--:.+$/', $chapter); |
| 217 | - if(!$success) log_message('error', 'Invalid Chapter (Batoto): '.$chapter); |
|
| 233 | + if(!$success) { |
|
| 234 | + log_message('error', 'Invalid Chapter (Batoto): '.$chapter); |
|
| 235 | + } |
|
| 218 | 236 | return $success; |
| 219 | 237 | } |
| 220 | 238 | |
@@ -307,12 +325,16 @@ discard block |
||
| 307 | 325 | |
| 308 | 326 | public function isValidTitleURL(string $title_url) : bool { |
| 309 | 327 | $success = (bool) preg_match('/^[a-z0-9_]+:--:(?:0|1)$/', $title_url); |
| 310 | - if(!$success) log_message('error', "Invalid Title URL (DynastyScans): {$title_url}"); |
|
| 328 | + if(!$success) { |
|
| 329 | + log_message('error', "Invalid Title URL (DynastyScans): {$title_url}"); |
|
| 330 | + } |
|
| 311 | 331 | return $success; |
| 312 | 332 | } |
| 313 | 333 | public function isValidChapter(string $chapter) : bool { |
| 314 | 334 | $success = (bool) preg_match('/^[0-9a-z_]+$/', $chapter); |
| 315 | - if(!$success) log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter); |
|
| 335 | + if(!$success) { |
|
| 336 | + log_message('error', 'Invalid Chapter (DynastyScans): '.$chapter); |
|
| 337 | + } |
|
| 316 | 338 | return $success; |
| 317 | 339 | } |
| 318 | 340 | |
@@ -418,12 +440,16 @@ discard block |
||
| 418 | 440 | |
| 419 | 441 | public function isValidTitleURL(string $title_url) : bool { |
| 420 | 442 | $success = (bool) preg_match('/^[a-z0-9-]+$/', $title_url); |
| 421 | - if(!$success) log_message('error', "Invalid Title URL (MangaPanda): {$title_url}"); |
|
| 443 | + if(!$success) { |
|
| 444 | + log_message('error', "Invalid Title URL (MangaPanda): {$title_url}"); |
|
| 445 | + } |
|
| 422 | 446 | return $success; |
| 423 | 447 | } |
| 424 | 448 | public function isValidChapter(string $chapter) : bool { |
| 425 | 449 | $success = (bool) preg_match('/^[0-9]+$/', $chapter); |
| 426 | - if(!$success) log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter); |
|
| 450 | + if(!$success) { |
|
| 451 | + log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter); |
|
| 452 | + } |
|
| 427 | 453 | return $success; |
| 428 | 454 | } |
| 429 | 455 | |
@@ -470,12 +496,16 @@ discard block |
||
| 470 | 496 | |
| 471 | 497 | public function isValidTitleURL(string $title_url) : bool { |
| 472 | 498 | $success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url); |
| 473 | - if(!$success) log_message('error', "Invalid Title URL (MangaStream): {$title_url}"); |
|
| 499 | + if(!$success) { |
|
| 500 | + log_message('error', "Invalid Title URL (MangaStream): {$title_url}"); |
|
| 501 | + } |
|
| 474 | 502 | return $success; |
| 475 | 503 | } |
| 476 | 504 | public function isValidChapter(string $chapter) : bool { |
| 477 | 505 | $success = (bool) preg_match('/^(.*?)\/[0-9]+$/', $chapter); |
| 478 | - if(!$success) log_message('error', 'Invalid Chapter (MangaStream): '.$chapter); |
|
| 506 | + if(!$success) { |
|
| 507 | + log_message('error', 'Invalid Chapter (MangaStream): '.$chapter); |
|
| 508 | + } |
|
| 479 | 509 | return $success; |
| 480 | 510 | } |
| 481 | 511 | |
@@ -544,12 +574,16 @@ discard block |
||
| 544 | 574 | |
| 545 | 575 | public function isValidTitleURL(string $title_url) : bool { |
| 546 | 576 | $success = (bool) preg_match('/^[0-9]+:--:(?:en|zh-hant|zh-hans|th|id):--:[a-z0-9-]+:--:(?:drama|fantasy|comedy|action|slice-of-life|romance|superhero|thriller|sports|sci-fi)$/', $title_url); |
| 547 | - if(!$success) log_message('error', "Invalid Title URL (WebToons): {$title_url}"); |
|
| 577 | + if(!$success) { |
|
| 578 | + log_message('error', "Invalid Title URL (WebToons): {$title_url}"); |
|
| 579 | + } |
|
| 548 | 580 | return $success; |
| 549 | 581 | } |
| 550 | 582 | public function isValidChapter(string $chapter) : bool { |
| 551 | 583 | $success = (bool) preg_match('/^[0-9]+:--:.*$/', $chapter); |
| 552 | - if(!$success) log_message('error', 'Invalid Chapter (WebToons): '.$chapter); |
|
| 584 | + if(!$success) { |
|
| 585 | + log_message('error', 'Invalid Chapter (WebToons): '.$chapter); |
|
| 586 | + } |
|
| 553 | 587 | return $success; |
| 554 | 588 | } |
| 555 | 589 | |
@@ -606,12 +640,16 @@ discard block |
||
| 606 | 640 | |
| 607 | 641 | public function isValidTitleURL(string $title_url) : bool { |
| 608 | 642 | $success = (bool) preg_match('/^[A-Za-z0-9-]+/', $title_url); |
| 609 | - if(!$success) log_message('error', "Invalid Title URL (KissManga): {$title_url}"); |
|
| 643 | + if(!$success) { |
|
| 644 | + log_message('error', "Invalid Title URL (KissManga): {$title_url}"); |
|
| 645 | + } |
|
| 610 | 646 | return $success; |
| 611 | 647 | } |
| 612 | 648 | public function isValidChapter(string $chapter) : bool { |
| 613 | 649 | $success = (bool) preg_match('/^.*?:--:[0-9]+$/', $chapter); |
| 614 | - if(!$success) log_message('error', 'Invalid Chapter (KissManga): '.$chapter); |
|
| 650 | + if(!$success) { |
|
| 651 | + log_message('error', 'Invalid Chapter (KissManga): '.$chapter); |
|
| 652 | + } |
|
| 615 | 653 | return $success; |
| 616 | 654 | } |
| 617 | 655 | |
@@ -678,12 +716,16 @@ discard block |
||
| 678 | 716 | |
| 679 | 717 | public function isValidTitleURL(string $title_url) : bool { |
| 680 | 718 | $success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 681 | - if(!$success) log_message('error', "Invalid Title URL (KireiCake): {$title_url}"); |
|
| 719 | + if(!$success) { |
|
| 720 | + log_message('error', "Invalid Title URL (KireiCake): {$title_url}"); |
|
| 721 | + } |
|
| 682 | 722 | return $success; |
| 683 | 723 | } |
| 684 | 724 | public function isValidChapter(string $chapter) : bool { |
| 685 | 725 | $success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 686 | - if(!$success) log_message('error', 'Invalid Chapter (KireiCake): '.$chapter); |
|
| 726 | + if(!$success) { |
|
| 727 | + log_message('error', 'Invalid Chapter (KireiCake): '.$chapter); |
|
| 728 | + } |
|
| 687 | 729 | return $success; |
| 688 | 730 | } |
| 689 | 731 | |
@@ -740,12 +782,16 @@ discard block |
||
| 740 | 782 | |
| 741 | 783 | public function isValidTitleURL(string $title_url) : bool { |
| 742 | 784 | $success = (bool) preg_match('/^[a-z0-9-]+/', $title_url); |
| 743 | - if(!$success) log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}"); |
|
| 785 | + if(!$success) { |
|
| 786 | + log_message('error', "Invalid Title URL (GameOfScanlation): {$title_url}"); |
|
| 787 | + } |
|
| 744 | 788 | return $success; |
| 745 | 789 | } |
| 746 | 790 | public function isValidChapter(string $chapter) : bool { |
| 747 | 791 | $success = (bool) preg_match('/^[a-z0-9\.-]+$/', $chapter); |
| 748 | - if(!$success) log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter); |
|
| 792 | + if(!$success) { |
|
| 793 | + log_message('error', 'Invalid Chapter (GameOfScanlation): '.$chapter); |
|
| 794 | + } |
|
| 749 | 795 | return $success; |
| 750 | 796 | } |
| 751 | 797 | |
@@ -801,12 +847,16 @@ discard block |
||
| 801 | 847 | |
| 802 | 848 | public function isValidTitleURL(string $title_url) : bool { |
| 803 | 849 | $success = (bool) preg_match('/^[a-zA-Z0-9_]+/', $title_url); |
| 804 | - if(!$success) log_message('error', "Invalid Title URL (MangaCow): {$title_url}"); |
|
| 850 | + if(!$success) { |
|
| 851 | + log_message('error', "Invalid Title URL (MangaCow): {$title_url}"); |
|
| 852 | + } |
|
| 805 | 853 | return $success; |
| 806 | 854 | } |
| 807 | 855 | public function isValidChapter(string $chapter) : bool { |
| 808 | 856 | $success = (bool) preg_match('/^[0-9]+$/', $chapter); |
| 809 | - if(!$success) log_message('error', 'Invalid Chapter (MangaCow): '.$chapter); |
|
| 857 | + if(!$success) { |
|
| 858 | + log_message('error', 'Invalid Chapter (MangaCow): '.$chapter); |
|
| 859 | + } |
|
| 810 | 860 | return $success; |
| 811 | 861 | } |
| 812 | 862 | |
@@ -860,12 +910,16 @@ discard block |
||
| 860 | 910 | |
| 861 | 911 | public function isValidTitleURL(string $title_url) : bool { |
| 862 | 912 | $success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 863 | - if(!$success) log_message('error', "Invalid Title URL (SeaOtterScans): {$title_url}"); |
|
| 913 | + if(!$success) { |
|
| 914 | + log_message('error', "Invalid Title URL (SeaOtterScans): {$title_url}"); |
|
| 915 | + } |
|
| 864 | 916 | return $success; |
| 865 | 917 | } |
| 866 | 918 | public function isValidChapter(string $chapter) : bool { |
| 867 | 919 | $success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 868 | - if(!$success) log_message('error', 'Invalid Chapter (SeaOtterScans): '.$chapter); |
|
| 920 | + if(!$success) { |
|
| 921 | + log_message('error', 'Invalid Chapter (SeaOtterScans): '.$chapter); |
|
| 922 | + } |
|
| 869 | 923 | return $success; |
| 870 | 924 | } |
| 871 | 925 | |
@@ -927,12 +981,16 @@ discard block |
||
| 927 | 981 | |
| 928 | 982 | public function isValidTitleURL(string $title_url) : bool { |
| 929 | 983 | $success = (bool) preg_match('/^[a-z0-9_]+/', $title_url); |
| 930 | - if(!$success) log_message('error', "Invalid Title URL (HelveticaScans): {$title_url}"); |
|
| 984 | + if(!$success) { |
|
| 985 | + log_message('error', "Invalid Title URL (HelveticaScans): {$title_url}"); |
|
| 986 | + } |
|
| 931 | 987 | return $success; |
| 932 | 988 | } |
| 933 | 989 | public function isValidChapter(string $chapter) : bool { |
| 934 | 990 | $success = (bool) preg_match('/^en\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+(?:\/[0-9]+)?)?)?$/', $chapter); |
| 935 | - if(!$success) log_message('error', 'Invalid Chapter (HelveticaScans): '.$chapter); |
|
| 991 | + if(!$success) { |
|
| 992 | + log_message('error', 'Invalid Chapter (HelveticaScans): '.$chapter); |
|
| 993 | + } |
|
| 936 | 994 | return $success; |
| 937 | 995 | } |
| 938 | 996 | |