diff --git a/lib/copy_this/misc/update_scripts/import.php b/lib/copy_this/misc/update_scripts/import.php index e78bc7154..e20c861c1 100644 --- a/lib/copy_this/misc/update_scripts/import.php +++ b/lib/copy_this/misc/update_scripts/import.php @@ -40,14 +40,14 @@ echo "\nUsage: php import.php [path(string)] [usefilename(true/false)] [dupechec $filestoprocess = glob($path . "*.{nzb,nzb.gz}", GLOB_BRACE); $items = count($filestoprocess); -$matches = array(); +$matches = []; $digits = preg_match_all("/[0-9]/", count($filestoprocess), $matches); $dupepath = $path . "dupe/"; $nogrouppath = $path . "nogroup/"; $importedpath = $path . "imported/"; $noregexpath = $path . "noregex/"; $errorpath = $path . "error/"; -$missinggroups = array(); +$missinggroups = []; echo "[Importing " . $items . " *.nzb file" . ($items != 1 ? "s" : "") . " from " . $path . ($usefilename ? " U" : " Not u") . "sing filename, " . ($dupecheck ? "C" : "Not c") . "hecking for duplicates" . ($categoryoverride != -1 ? ", Forcing category to " . $categoryoverride : "") . "]\n\n"; foreach ($filestoprocess as $nzbFile) { @@ -124,7 +124,7 @@ foreach ($filestoprocess as $nzbFile) { $binaryId = 0; $groupRegexes = $releaseRegex->getForGroup($groupName); foreach ($nzbInfo->nzb as $postFile) { - $regexMatches = array(); + $regexMatches = []; foreach ($groupRegexes as $groupRegex) { $regexCheck = $releaseRegex->performMatch($groupRegex, $postFile["subject"]); diff --git a/lib/copy_this/newznab/controllers/Konsole.php b/lib/copy_this/newznab/controllers/Konsole.php index 290954a5f..fca3d60cd 100644 --- a/lib/copy_this/newznab/controllers/Konsole.php +++ b/lib/copy_this/newznab/controllers/Konsole.php @@ -1,5 +1,4 @@ (string) $file->attributes()->subject, "From" => (string) $file->attributes()->poster, "Message-ID" => ""); + $msg = ["Subject" => (string) $file->attributes()->subject, "From" => (string) $file->attributes()->poster, "Message-ID" => ""]; // Get the group names, groupid, check if it's blacklisted. - $groupArr = array(); + $groupArr = []; foreach ($file->groups->group as $group) { $group = (string) $group; @@ -329,7 +329,7 @@ class NZBImport // Try to insert the NZB details into the DB. return $this->insertNZB( - array( + [ 'subject' => $firstName, 'useFName' => $useNzbName, 'postDate' => (empty($postDate) ? date("Y-m-d H:i:s") : $postDate), @@ -338,7 +338,7 @@ class NZBImport 'groupName' => $groupName, 'totalFiles' => $totalFiles, 'totalSize' => $totalSize - ) + ] ); } diff --git a/lib/copy_this/newznab/controllers/RottenTomato.php b/lib/copy_this/newznab/controllers/RottenTomato.php index aa20c74d8..809c721e9 100644 --- a/lib/copy_this/newznab/controllers/RottenTomato.php +++ b/lib/copy_this/newznab/controllers/RottenTomato.php @@ -77,15 +77,12 @@ class RottenTomato * Movie search * @throws Exception * @param string $query search term - * @param int $pageLimit results per page * @param int $page current page * @return array results */ - public function movieSearch($query, $pageLimit = 20, $page = 0) { - $params = array(); + public function movieSearch($query, $page = 0) { + $params = []; $params['q'] = $query; - if ($pageLimit) - $params['page_limit'] .= $pageLimit; if ($page) $params['page'] = $page; $result = $this->getResource(self::ROTTEN_TOMATOES_API_MOVIE_SEARCH, $params); @@ -98,16 +95,13 @@ class RottenTomato * @throws Exception * @param int $id rotten tomatoes id * @param string $reviewType review type - * @param int $pageLimit results per page * @param int $page current page * @return array results */ - public function getMovieReviews($id, $reviewType = self::REVIEW_TYPE_ALL, $pageLimit = 20, $page = 0) { + public function getMovieReviews($id, $reviewType = self::REVIEW_TYPE_ALL, $page = 0) { $url = sprintf(self::ROTTEN_TOMATOES_API_MOVIE_REVIEWS, $id); - $params = array(); + $params = []; $params['review_type'] = $reviewType; - if ($pageLimit) - $params['page_limit'] .= $pageLimit; if ($page) $params['page'] = $page; $result = $this->getResource($url, $params); @@ -144,14 +138,11 @@ class RottenTomato /** * Get new DVD releases * @throws Exception - * @param int $pageLimit results per page * @param int $page current page * @return array results */ - public function getNewDvdReleases($pageLimit = 20, $page = 0) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; + public function getNewDvdReleases($page = 0) { + $params = []; if ($page) $params['page'] = $page; $result = $this->getResource(self::ROTTEN_TOMATOES_API_NEW_RELEASE_DVDS, $params); @@ -162,14 +153,11 @@ class RottenTomato /** * Get movies that are coming soon * @throws Exception - * @param int $pageLimit results per page * @param int $page current page * @return array results */ - public function getUpcomingMovies($pageLimit = 20, $page = 0) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; + public function getUpcomingMovies($page = 0) { + $params = []; if ($page) $params['page'] = $page; $result = $this->getResource(self::ROTTEN_TOMATOES_API_UPCOMING_MOVIES, $params); @@ -180,14 +168,11 @@ class RottenTomato /** * Get movies currently in theaters * @throws Exception - * @param int $pageLimit results per page * @param int $page current page * @return array results */ - public function getMoviesInTheaters($pageLimit = 5, $page = 0) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; + public function getMoviesInTheaters($page = 0) { + $params = []; if ($page) $params['page'] = $page; $result = $this->getResource(self::ROTTEN_TOMATOES_API_IN_THEATERS, $params); @@ -198,14 +183,10 @@ class RottenTomato /** * Get movies opening * @throws Exception - * @param int $pageLimit number of results * @return array results */ - public function getOpeningMovies($pageLimit = 20) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; - $result = $this->getResource(self::ROTTEN_TOMATOES_API_OPENING_MOVIES, $params); + public function getOpeningMovies() { + $result = $this->getResource(self::ROTTEN_TOMATOES_API_OPENING_MOVIES); if(!isset($result['movies']) && !empty($result['movies'])) throw new Exception("No results"); return $result; @@ -213,14 +194,10 @@ class RottenTomato /** * Get top box office results * @throws Exception - * @param int $pageLimit number of results * @return array results */ - public function getMoviesBoxOffice($pageLimit = 20) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; - $result = $this->getResource(self::ROTTEN_TOMATOES_API_BOX_OFFICE, $params); + public function getMoviesBoxOffice() { + $result = $this->getResource(self::ROTTEN_TOMATOES_API_BOX_OFFICE); if(!isset($result['movies']) && !empty($result['movies'])) throw new Exception("No results"); return $result; @@ -228,14 +205,10 @@ class RottenTomato /** * Get top DVD rentals * @throws Exception - * @param int $pageLimit number of results * @return array results */ - public function getDvdTopRentals($pageLimit = 20) { - $params = array(); - if ($pageLimit) - $params['page_limit'] .= $pageLimit; - $result = $this->getResource(self::ROTTEN_TOMATOES_API_DVD_TOP_RENTALS, $params); + public function getDvdTopRentals() { + $result = $this->getResource(self::ROTTEN_TOMATOES_API_DVD_TOP_RENTALS); if(!isset($result['movies']) && !empty($result['movies'])) throw new Exception("No results"); return $result; @@ -279,7 +252,7 @@ class RottenTomato * @param array $params parameters (key/value pairs) for query string * @return array decoded json response */ - protected function getResource($url, $params = array()) { + protected function getResource($url, $params = []) { $params['apikey'] = $this->apiKey; $params['country'] = $this->country; $queryString = http_build_query($params); @@ -316,10 +289,10 @@ class RottenTomato * @return string|boolean result */ protected function httpRequestFopen($url){ - $http = array(); + $http = []; $http['method'] = 'GET'; $http['timeout'] = $this->timeoutSeconds; - $response = @fopen($url, 'r', false, stream_context_create(array('http' => $http))); + $response = @fopen($url, 'r', false, stream_context_create(['http' => $http])); $result = false; if ($response) $result = $response; diff --git a/lib/copy_this/newznab/controllers/SpotNab.php b/lib/copy_this/newznab/controllers/SpotNab.php index 61fca20f9..ecd862414 100644 --- a/lib/copy_this/newznab/controllers/SpotNab.php +++ b/lib/copy_this/newznab/controllers/SpotNab.php @@ -582,9 +582,9 @@ class SpotNab { // Fetch some date ranges $last_month = date("Y-m-d",strtotime( - date("Y-m-d", mktime()) . " - 30 day")); + date("Y-m-d", time()) . " - 30 day")); $last_year = date('Y-m-d',strtotime( - date("Y-m-d", mktime()) . " - 365 day")); + date("Y-m-d", time()) . " - 365 day")); // Header $message = array( @@ -968,7 +968,7 @@ class SpotNab { } // Update DB With Global Identifer - $ures = $db->queryExec(sprintf("UPDATE releases SET gid = '%s' WHERE id = %d", $gid, $r['id'])); + $ures = $db->queryExec(sprintf("UPDATE releases SET gid = %s WHERE id = %d", $db->escapeString($gid), $r['id'])); if($ures->rowCount() == 0){ printf("\nPostPrc : Failed to update: %s\n", $r['name']); } diff --git a/lib/copy_this/newznab/libraries/ForkingImportNZB.php b/lib/copy_this/newznab/libraries/ForkingImportNZB.php index f9b754b34..888623d61 100644 --- a/lib/copy_this/newznab/libraries/ForkingImportNZB.php +++ b/lib/copy_this/newznab/libraries/ForkingImportNZB.php @@ -11,9 +11,9 @@ use newznab\db\DB; class ForkingImportNZB extends Forking { /** - * + * @param array $options */ - public function __construct(array $options = array()) + public function __construct(array $options = []) { $defaults = [ 'settings' => new DB(), diff --git a/lib/testing/nzb-import.php b/lib/testing/nzb-import.php index ae17ca582..d2644da27 100644 --- a/lib/testing/nzb-import.php +++ b/lib/testing/nzb-import.php @@ -23,13 +23,13 @@ if (count($argv) !== 6) { if (!is_dir($argv[1])) { exit('Error: arg1 must be a path (you might not have read access to this path)' . $n); } -if (!in_array($argv[2], array('true', 'false'))) { +if (!in_array($argv[2], ['true', 'false'])) { exit('Error: arg2 must be true or false' . $n); } -if (!in_array($argv[3], array('true', 'false'))) { +if (!in_array($argv[3], ['true', 'false'])) { exit('Error: arg3 must be true or false' . $n); } -if (!in_array($argv[4], array('true', 'false'))) { +if (!in_array($argv[4], ['true', 'false'])) { exit('Error: arg4 must be true or false' . $n); } if (!is_numeric($argv[5])) { @@ -54,7 +54,7 @@ $files = new \RegexIterator( ); $i = 1; -$nzbFiles = array(); +$nzbFiles = []; foreach ($files as $file) { $nzbFiles[] = $file[0]; if ($i++ >= $argv[5]) {