diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index 2dd9e9921..a71c6d51f 100755 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -316,7 +316,7 @@ class Binaries */ public function logIndexerStart(): void { - Settings::query()->where('setting', '=', 'last_run_time')->update(['value' => Carbon::now()]); + Settings::query()->where('setting', '=', 'last_run_time')->update(['value' => now()]); } /** @@ -518,7 +518,7 @@ class Binaries [ 'last_record' => $scanSummary['lastArticleNumber'], 'last_record_postdate' => Carbon::createFromTimestamp($scanSummary['lastArticleDate']), - 'last_updated' => Carbon::now(), + 'last_updated' => now(), ] ); } else { @@ -528,7 +528,7 @@ class Binaries ->update( [ 'last_record' => $last, - 'last_updated' => Carbon::now(), + 'last_updated' => now(), ] ); } @@ -862,7 +862,7 @@ class Binaries $this->header['Date'] = (is_numeric($this->header['Date']) ? $this->header['Date'] : strtotime($this->header['Date'])); // Get the current unixtime from PHP. - $now = Carbon::now()->timestamp; + $now = now()->timestamp; $xref = ($this->multiGroup === true ? sprintf('xref = CONCAT(xref, "\\n"%s ),', $this->_pdo->escapeString(substr($this->header['Xref'], 2, 255))) : ''); $date = $this->header['Date'] > $now ? $now : $this->header['Date']; @@ -1032,7 +1032,7 @@ class Binaries */ protected function updateBlacklistUsage(): void { - BinaryBlacklist::query()->whereIn('id', $this->_binaryBlacklistIdsToUpdate)->update(['last_activity' => Carbon::now()]); + BinaryBlacklist::query()->whereIn('id', $this->_binaryBlacklistIdsToUpdate)->update(['last_activity' => now()]); $this->_binaryBlacklistIdsToUpdate = []; } @@ -1330,7 +1330,7 @@ class Binaries */ public function daytopost($days, $data): string { - $goalTime = Carbon::now()->subDays($days)->timestamp; + $goalTime = now()->subDays($days)->timestamp; // The time we want = current unix time (ex. 1395699114) - minus 86400 (seconds in a day) // times days wanted. (ie 1395699114 - 2592000 (30days)) = 1393107114 @@ -1714,7 +1714,7 @@ class Binaries } $poster = MultigroupPoster::query()->get(['poster'])->toArray(); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_short')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_short')); Cache::put('mgrposter', $poster, $expiresAt); return $poster; diff --git a/Blacklight/Books.php b/Blacklight/Books.php index 92ccb872f..74d24ee8f 100755 --- a/Blacklight/Books.php +++ b/Blacklight/Books.php @@ -10,7 +10,6 @@ use App\Models\BookInfo; use App\Models\Category; use App\Models\Settings; use ApaiIO\Operations\Search; -use Illuminate\Support\Carbon; use ApaiIO\Configuration\Country; use ApaiIO\Request\GuzzleRequest; use Illuminate\Support\Facades\Cache; @@ -183,7 +182,7 @@ class Books $order[1], ($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start) ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $bookscache = Cache::get(md5($booksql.$page)); if ($bookscache !== null) { $books = $bookscache; @@ -636,8 +635,8 @@ class Books 'overview' =>$book['overview'], 'genre' => $book['genre'], 'cover' => $book['cover'], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); } else { diff --git a/Blacklight/Console.php b/Blacklight/Console.php index 63e8333c2..e4c4cce47 100755 --- a/Blacklight/Console.php +++ b/Blacklight/Console.php @@ -10,7 +10,6 @@ use App\Models\Category; use App\Models\Settings; use App\Models\ConsoleInfo; use ApaiIO\Operations\Search; -use Illuminate\Support\Carbon; use ApaiIO\Configuration\Country; use ApaiIO\Request\GuzzleRequest; use Illuminate\Support\Facades\DB; @@ -196,7 +195,7 @@ class Console } else { $data = DB::select($calcSql); $consoles = ['total' => DB::select('SELECT FOUND_ROWS() AS total'), 'result' => $data]; - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($calcSql.$page), $consoles, $expiresAt); } $consoleIDs = $releaseIDs = false; @@ -240,7 +239,7 @@ class Console if (\count($return) > 0) { $return[0]->_totalcount = $consoles[0]->total ?? 0; } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_long')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long')); Cache::put(md5($sql.$page), $return, $expiresAt); return $return; @@ -701,8 +700,8 @@ class Console 'esrb' => $con['esrb'], 'releasedate' => $con['releasedate'] !== '' ? $con['releasedate'] : 'null', 'review' => substr($con['review'], 0, 3000), - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); if ($con['cover'] === 1) { diff --git a/Blacklight/Games.php b/Blacklight/Games.php index ee755f10a..de5510dba 100755 --- a/Blacklight/Games.php +++ b/Blacklight/Games.php @@ -263,7 +263,7 @@ class Games $order[1], ($start === false ? '' : ' LIMIT '.$num.' OFFSET '.$start) ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $gamesCache = Cache::get(md5($gamesSql.$page)); if ($gamesCache !== null) { $games = $gamesCache; @@ -551,7 +551,7 @@ class Games if ($this->_gameResults->original_release_date !== '') { $dateReleased = $this->_gameResults->original_release_date; - $date = $dateReleased !== null ? Carbon::createFromFormat('Y-m-d H:i:s', $dateReleased) : Carbon::now(); + $date = $dateReleased !== null ? Carbon::createFromFormat('Y-m-d H:i:s', $dateReleased) : now(); if ($date instanceof \DateTime) { $game['releasedate'] = (string) $date->format('Y-m-d'); } @@ -640,8 +640,8 @@ class Games 'backdrop' => $game['backdrop'], 'trailer' => $game['trailer'], 'classused' => $game['classused'], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); } else { diff --git a/Blacklight/Genres.php b/Blacklight/Genres.php index fa6b5f29b..9878366b2 100755 --- a/Blacklight/Genres.php +++ b/Blacklight/Genres.php @@ -5,7 +5,6 @@ namespace Blacklight; use App\Models\Genre; use Blacklight\db\DB; use App\Models\Category; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; class Genres @@ -49,7 +48,7 @@ class Genres return $genres; } $genres = $this->pdo->query($sql); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_long')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long')); Cache::put(md5($sql), $genres, $expiresAt); return $genres; @@ -186,7 +185,7 @@ class Genres $disabled = $cats; } else { $disabled = Genre::query()->where('disabled', '=', 1)->get(['id']); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_long')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_long')); Cache::put('disabledcats', $disabled, $expiresAt); } diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 793a7e4bb..189cd3936 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -253,7 +253,7 @@ class Movie $catsrch = Category::getCategorySearch($cat); } $order = $this->getMovieOrder($orderBy); - $expiresAt = Carbon::now()->addSeconds(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addSeconds(config('nntmux.cache_expiry_medium')); $moviesSql = sprintf( " diff --git a/Blacklight/Music.php b/Blacklight/Music.php index c6ed525b8..eb432f1b0 100755 --- a/Blacklight/Music.php +++ b/Blacklight/Music.php @@ -10,7 +10,6 @@ use App\Models\Category; use App\Models\Settings; use App\Models\MusicInfo; use ApaiIO\Operations\Search; -use Illuminate\Support\Carbon; use ApaiIO\Request\GuzzleRequest; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Cache; @@ -155,7 +154,7 @@ class Music $exccatlist = ' AND r.categories_id NOT IN ('.implode(',', $excludedcats).')'; } $order = $this->getMusicOrder($orderby); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $musicSql = sprintf( " @@ -481,8 +480,8 @@ class Music 'genres_id' => (int) $mus['musicgenres_id'] === -1 ? 'null' : $mus['musicgenres_id'], 'tracks' => $mus['tracks'], 'cover' => $mus['cover'], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); } else { diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index 6b0bbb89f..557d12114 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -7,7 +7,6 @@ use App\Models\Predb; use Blacklight\db\DB; use App\Models\Release; use App\Models\Category; -use Illuminate\Support\Carbon; use Blacklight\utility\Utility; use Blacklight\processing\PostProcess; @@ -1153,7 +1152,7 @@ class NameFixer $limit = 'LIMIT 1000000'; } - ColorCLI::doEcho(ColorCLI::header(PHP_EOL.'Match PreFiles '.$args[1].' Started at '.Carbon::now()->format('Y-m-d')), true); + ColorCLI::doEcho(ColorCLI::header(PHP_EOL.'Match PreFiles '.$args[1].' Started at '.now()->format('Y-m-d')), true); ColorCLI::doEcho(ColorCLI::primary('Matching predb filename to cleaned release_files.name.'), true); $counter = $counted = 0; diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index bcecd1121..c694169d8 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -3,11 +3,9 @@ namespace Blacklight; use App\Models\Group; -use App\Models\Video; use App\Models\Release; use App\Models\Category; use App\Models\Settings; -use Illuminate\Support\Carbon; use Blacklight\utility\Utility; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Cache; @@ -132,7 +130,7 @@ class Releases $possibleRows = $this->getBrowseCount($cat, $maxAge, $excludedCats, $groupName); $sql[0]->_totalcount = $sql[0]->_totalrows = $possibleRows; } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($qry.$page), $sql, $expiresAt); return $sql; @@ -170,7 +168,7 @@ class Releases return $count; } $count = DB::select($sql); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_short')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_short')); Cache::put(md5($sql), $count[0]->count, $expiresAt); return $count[0]->count ?? 0; @@ -448,7 +446,7 @@ class Releases ($offset === false ? '' : (' LIMIT '.$limit.' OFFSET '.$offset)) ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $result = Cache::get(md5($sql)); if ($result !== null) { return $result; @@ -718,7 +716,7 @@ class Releases if (! empty($releases) && \count($releases) > 0) { $releases[0]->_totalrows = $this->getPagerCount($baseSql); } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($sql), $releases, $expiresAt); return $releases; @@ -856,7 +854,7 @@ class Releases ); } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($sql), $releases, $expiresAt); return $releases; @@ -920,7 +918,7 @@ class Releases if (! empty($releases) && \count($releases) > 0) { $releases[0]->_totalrows = $this->getPagerCount($baseSql); } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($sql), $releases, $expiresAt); return $releases; @@ -985,7 +983,7 @@ class Releases if (! empty($releases) && \count($releases) > 0) { $releases[0]->_totalrows = $this->getPagerCount($baseSql); } - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); Cache::put(md5($sql), $releases, $expiresAt); return $releases; @@ -1089,7 +1087,7 @@ class Releases return $count; } $count = DB::select($sql); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_short')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_short')); Cache::put(md5($sql), $count[0]->count, $expiresAt); return $count[0]->count ?? 0; diff --git a/Blacklight/SABnzbd.php b/Blacklight/SABnzbd.php index 889e59f70..6608b637e 100755 --- a/Blacklight/SABnzbd.php +++ b/Blacklight/SABnzbd.php @@ -4,7 +4,6 @@ namespace Blacklight; use GuzzleHttp\Client; use App\Models\Settings; -use Illuminate\Support\Carbon; /** * Class SABnzbd. @@ -319,10 +318,10 @@ class SABnzbd */ public function setCookie($host, $apikey, $priority, $apitype) { - setcookie('sabnzbd_'.$this->uid.'__host', $host, Carbon::now()->addDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__apikey', $apikey, Carbon::now()->addDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__priority', $priority, Carbon::now()->addDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__apitype', $apitype, Carbon::now()->addDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__host', $host, now()->addDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__apikey', $apikey, now()->addDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__priority', $priority, now()->addDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__apitype', $apitype, now()->addDays(30)->timestamp); } /** @@ -330,9 +329,9 @@ class SABnzbd */ public function unsetCookie() { - setcookie('sabnzbd_'.$this->uid.'__host', '', Carbon::now()->subDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__apikey', '', Carbon::now()->subDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__priority', '', Carbon::now()->subDays(30)->timestamp); - setcookie('sabnzbd_'.$this->uid.'__apitype', '', Carbon::now()->subDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__host', '', now()->subDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__apikey', '', now()->subDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__priority', '', now()->subDays(30)->timestamp); + setcookie('sabnzbd_'.$this->uid.'__apitype', '', now()->subDays(30)->timestamp); } } diff --git a/Blacklight/XXX.php b/Blacklight/XXX.php index c03f8fc43..255ef02e0 100755 --- a/Blacklight/XXX.php +++ b/Blacklight/XXX.php @@ -7,7 +7,6 @@ use App\Models\Release; use App\Models\XxxInfo; use App\Models\Category; use App\Models\Settings; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Blacklight\processing\adult\ADE; use Blacklight\processing\adult\ADM; @@ -128,7 +127,7 @@ class XXX $catsrch = Category::getCategorySearch($cat); } $order = $this->getXXXOrder($orderBy); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $xxxmoviesSql = sprintf( " @@ -598,8 +597,8 @@ class XXX 'trailers' => $mov['trailers'], 'directurl' => $mov['directurl'], 'classused' => $mov['classused'], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); // Update BoxCover. diff --git a/Blacklight/db/populate/AniDB.php b/Blacklight/db/populate/AniDB.php index 9116bc4d0..396abc1ce 100755 --- a/Blacklight/db/populate/AniDB.php +++ b/Blacklight/db/populate/AniDB.php @@ -290,7 +290,7 @@ class AniDB 'picture' => $AniDBInfoArray['picture'], 'categories' => $AniDBInfoArray['categories'], 'characters' => $AniDBInfoArray['characters'], - 'updated' => Carbon::now(), + 'updated' => now(), ] ); if (! empty($AniDBInfoArray['epsarr'])) { @@ -328,7 +328,7 @@ class AniDB private function populateMainTable() { $lastUpdate = Carbon::createFromTimestamp($this->lastUpdate); - $current = Carbon::now(); + $current = now(); if ($current->diff($lastUpdate)->format('%d') > $this->updateInterval) { if ($this->echooutput) { @@ -483,7 +483,7 @@ class AniDB 'picture' => $AniDBInfoArray['picture'], 'categories' => $AniDBInfoArray['categories'], 'characters' => $AniDBInfoArray['characters'], - 'updated' => Carbon::now(), + 'updated' => now(), ] ); if (! empty($AniDBInfoArray['epsarr'])) { diff --git a/Blacklight/http/RSS.php b/Blacklight/http/RSS.php index bfa445b04..c0b06fef9 100755 --- a/Blacklight/http/RSS.php +++ b/Blacklight/http/RSS.php @@ -5,7 +5,6 @@ namespace Blacklight\http; use Blacklight\NZB; use App\Models\Category; use Blacklight\Releases; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Cache; @@ -105,7 +104,7 @@ class RSS extends Capabilities ' LIMIT 0,'.($offset > 100 ? 100 : $offset) ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $result = Cache::get(md5($sql)); if ($result !== null) { return $result; @@ -167,7 +166,7 @@ class RSS extends Capabilities ' LIMIT '.($limit > 100 ? 100 : $limit).' OFFSET 0' ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $result = Cache::get(md5($sql)); if ($result !== null) { return $result; @@ -229,7 +228,7 @@ class RSS extends Capabilities ' LIMIT '.($limit > 100 ? 100 : $limit).' OFFSET 0' ); - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); $result = Cache::get(md5($sql)); if ($result !== null) { return $result; diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index e5bc8a533..a78f4501c 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -8,7 +8,6 @@ use Blacklight\NNTP; use Blacklight\db\DB; use App\Models\Settings; use Blacklight\ColorCLI; -use Illuminate\Support\Carbon; use Blacklight\processing\PostProcess; /** @@ -433,7 +432,7 @@ class Forking extends \fork_daemon $backfilldays = ''; if ((int) $backfill_days === 1) { $days = 'backfill_target'; - $backfilldays = Carbon::now()->subDays((int) $days); + $backfilldays = now()->subDays((int) $days); } elseif ((int) $backfill_days === 2) { $backfilldays = Settings::settingValue('..safebackfilldate'); } diff --git a/Blacklight/processing/PostProcess.php b/Blacklight/processing/PostProcess.php index 952636c2e..25ed76756 100755 --- a/Blacklight/processing/PostProcess.php +++ b/Blacklight/processing/PostProcess.php @@ -350,7 +350,7 @@ class PostProcess if ($filesAdded < 11 && ReleaseFile::query()->where(['releases_id' => $relID, 'name' => $file['name']])->first() === null) { // Try to add the files to the DB. - if (ReleaseFile::addReleaseFiles($relID, $file['name'], $file['hash_16K'], $file['size'], $query['postdate'] !== null ? Carbon::createFromFormat('Y-m-d H:i:s', $query['postdate']) : Carbon::now(), 0)) { + if (ReleaseFile::addReleaseFiles($relID, $file['name'], $file['hash_16K'], $file['size'], $query['postdate'] !== null ? Carbon::createFromFormat('Y-m-d H:i:s', $query['postdate']) : now(), 0)) { $filesAdded++; } } diff --git a/Blacklight/processing/Videos.php b/Blacklight/processing/Videos.php index 1f1812d51..468821d41 100755 --- a/Blacklight/processing/Videos.php +++ b/Blacklight/processing/Videos.php @@ -25,7 +25,6 @@ use App\Models\Video; use Blacklight\db\DB; use App\Models\TvInfo; use App\Models\VideoAlias; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; /** @@ -306,7 +305,7 @@ abstract class Videos public function getAliases($videoId, $alias = '') { $return = false; - $expiresAt = Carbon::now()->addMinutes(config('nntmux.cache_expiry_medium')); + $expiresAt = now()->addMinutes(config('nntmux.cache_expiry_medium')); if ($videoId > 0 || $alias !== '') { $aliasCache = Cache::get(md5($videoId.$alias)); diff --git a/Changelog b/Changelog index 1e4001306..c702d2e7a 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-05-31 DariusIII + * Chg: Use now() helper in place of Carbon::now() * Chg: Users can be logged in on 1 device at a time 2018-05-30 DariusIII * Chg: Update kevinlebrun/colors.php to version 1.0.3 diff --git a/app/Console/Commands/InstallNntmux.php b/app/Console/Commands/InstallNntmux.php index 64e9e1eeb..a220fdbf5 100644 --- a/app/Console/Commands/InstallNntmux.php +++ b/app/Console/Commands/InstallNntmux.php @@ -4,7 +4,6 @@ namespace App\Console\Commands; use App\Models\User; use App\Models\Settings; -use Illuminate\Support\Carbon; use Illuminate\Console\Command; use App\Extensions\util\Versions; use Symfony\Component\Process\Process; @@ -124,7 +123,7 @@ class InstallNntmux extends Command } if (! $error && $this->addAdminUser()) { - @file_put_contents(base_path().'/_install/install.lock', 'application install locked on '.Carbon::now()); + @file_put_contents(base_path().'/_install/install.lock', 'application install locked on '.now()); $this->info('Generating application key'); $process = new Process('php artisan key:generate --force'); $process->setTimeout(600); diff --git a/app/Console/Commands/NntmuxResetDb.php b/app/Console/Commands/NntmuxResetDb.php index d630b4cd4..08ea6b138 100644 --- a/app/Console/Commands/NntmuxResetDb.php +++ b/app/Console/Commands/NntmuxResetDb.php @@ -5,7 +5,6 @@ namespace App\Console\Commands; use App\Models\Group; use App\Models\Settings; use Blacklight\SphinxSearch; -use Illuminate\Support\Carbon; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; @@ -42,7 +41,7 @@ class NntmuxResetDb extends Command public function handle() { if ($this->confirm('This script removes all releases, nzb files, samples, previews , nfos, truncates all article tables and resets all groups. Are you sure you want reset the DB?')) { - $timestart = Carbon::now(); + $timestart = now(); DB::unprepared('SET FOREIGN_KEY_CHECKS = 0;'); DB::commit(); @@ -108,7 +107,7 @@ class NntmuxResetDb extends Command } } - $this->info('Deleted all releases, images, previews and samples. This script finished '.Carbon::now()->diffForHumans($timestart).' start'); + $this->info('Deleted all releases, images, previews and samples. This script finished '.now()->diffForHumans($timestart).' start'); DB::unprepared('SET FOREIGN_KEY_CHECKS = 1;'); DB::commit(); } else { diff --git a/app/Http/Controllers/BtcPaymentController.php b/app/Http/Controllers/BtcPaymentController.php index cb42da5c5..ea6fb8d88 100644 --- a/app/Http/Controllers/BtcPaymentController.php +++ b/app/Http/Controllers/BtcPaymentController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers; use App\Models\User; use App\Models\UserRole; use Illuminate\Http\Request; -use Illuminate\Support\Carbon; use Blacklight\libraries\Geary; class BtcPaymentController extends BasePageController @@ -87,7 +86,7 @@ class BtcPaymentController extends BasePageController // If order was paid in full (2) or overpaid (4) if ((int) $order['status'] === 2 || (int) $order['status'] === 4) { User::updateUserRole($callback_data['user_id'], $newRole); - User::updateUserRoleChangeDate($callback_data['user_id'], Carbon::now()->addYears($addYear)); + User::updateUserRoleChangeDate($callback_data['user_id'], now()->addYears($addYear)); } } } diff --git a/app/Http/Controllers/GetNzbController.php b/app/Http/Controllers/GetNzbController.php index 73ae7ac11..11ad97331 100644 --- a/app/Http/Controllers/GetNzbController.php +++ b/app/Http/Controllers/GetNzbController.php @@ -10,7 +10,6 @@ use Blacklight\Releases; use App\Models\UserDownload; use App\Models\UsersRelease; use Illuminate\Http\Request; -use Illuminate\Support\Carbon; use Blacklight\utility\Utility; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\File; @@ -100,7 +99,7 @@ class GetNzbController extends BasePageController return response()->streamDownload(function () use ($zip) { echo $zip; - }, Carbon::now()->format('Ymdhis').'.nzb.zip', ['Content-type:' => 'application/octet-stream']); + }, now()->format('Ymdhis').'.nzb.zip', ['Content-type:' => 'application/octet-stream']); } $this->show404(); @@ -128,7 +127,7 @@ class GetNzbController extends BasePageController $headers = [ 'Content-Type:' => 'application/x-nzb', - 'Expires:' => date('r', Carbon::now()->addDays(365)->timestamp), + 'Expires:' => date('r', now()->addDays(365)->timestamp), 'X-DNZB-Failure:' => $this->serverurl.'failed'.'?guid='.$request->input('id').'&userid='.$uid.'&rsstoken='.$rssToken, 'X-DNZB-Category:' => $relData['category_name'], 'X-DNZB-Details:' => $this->serverurl.'details/'.$request->input('id'), diff --git a/app/Http/Controllers/MovieController.php b/app/Http/Controllers/MovieController.php index 73b76c572..ed68af185 100644 --- a/app/Http/Controllers/MovieController.php +++ b/app/Http/Controllers/MovieController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers; use Blacklight\Movie; use App\Models\Category; use Illuminate\Http\Request; -use Illuminate\Support\Carbon; class MovieController extends BasePageController { @@ -138,7 +137,7 @@ class MovieController extends BasePageController $this->smarty->assign('genres', $genres); $this->smarty->assign('genre', $genre); - $years = range(1903, Carbon::now()->addYear()->year); + $years = range(1903, now()->addYear()->year); rsort($years); $year = ($request->has('year') && \in_array($request->input('year'), $years, false)) ? $request->input('year') : ''; $this->smarty->assign('years', $years); diff --git a/app/Models/Category.php b/app/Models/Category.php index 54e755fd6..849de5ea0 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Watson\Rememberable\Rememberable; use Illuminate\Database\Eloquent\Model; @@ -199,7 +198,7 @@ class Category extends Model { return self::query() ->remember(config('nntmux.cache_expiry_long')) - ->where('r.adddate', '>', Carbon::now()->subWeek()) + ->where('r.adddate', '>', now()->subWeek()) ->selectRaw('CONCAT(cp.title, " > ", categories.title) as title') ->selectRaw('COUNT(r.id) as count') ->join('categories as cp', 'cp.id', '=', 'categories.parentid') diff --git a/app/Models/Forumpost.php b/app/Models/Forumpost.php index 031818980..a576d70c3 100644 --- a/app/Models/Forumpost.php +++ b/app/Models/Forumpost.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -71,7 +70,7 @@ class Forumpost extends Model return -1; } - self::query()->where('id', $parentId)->increment('replies', 1, ['updated_at' => Carbon::now()]); + self::query()->where('id', $parentId)->increment('replies', 1, ['updated_at' => now()]); } return self::create( diff --git a/app/Models/Group.php b/app/Models/Group.php index 8c30a1c58..226e5397b 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -7,7 +7,6 @@ use Blacklight\NNTP; use Blacklight\ColorCLI; use Blacklight\Releases; use Blacklight\ReleaseImage; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Database\Eloquent\Model; @@ -269,7 +268,7 @@ class Group extends Model 'backfill_target' => $group['backfill_target'], 'first_record' => $group['first_record'], 'last_record' => $group['last_record'], - 'last_updated' => Carbon::now(), + 'last_updated' => now(), 'active' => $group['active'], 'backfill' => $group['backfill'], 'minsizetoformrelease' => $group['minsizetoformrelease'] === '' ? null : $group['minsizetoformrelease'], diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 785d822a9..209b3a61b 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -64,7 +63,7 @@ class Invitation extends Model // // Tidy any old invites sent greater than DEFAULT_INVITE_EXPIRY_DAYS days ago. // - self::query()->where('created_at', '<', Carbon::now()->subDays(self::DEFAULT_INVITE_EXPIRY_DAYS)); + self::query()->where('created_at', '<', now()->subDays(self::DEFAULT_INVITE_EXPIRY_DAYS)); return self::query()->where('guid', $inviteToken)->first(); } diff --git a/app/Models/Predb.php b/app/Models/Predb.php index c5fd15d64..ce0db6e17 100644 --- a/app/Models/Predb.php +++ b/app/Models/Predb.php @@ -5,7 +5,6 @@ namespace App\Models; use Blacklight\ColorCLI; use Blacklight\ConsoleTools; use Laravel\Scout\Searchable; -use Illuminate\Support\Carbon; use Watson\Rememberable\Rememberable; use Illuminate\Database\Eloquent\Model; @@ -107,7 +106,7 @@ class Predb extends Model ->join('releases', 'predb.title', '=', 'releases.searchname') ->select(['predb.id as predb_id', 'releases.id as releases_id']); if ($dateLimit !== false && is_numeric($dateLimit)) { - $query->where('adddate', '>', Carbon::now()->subDays($dateLimit)); + $query->where('adddate', '>', now()->subDays($dateLimit)); } $res = $query->get(); diff --git a/app/Models/Release.php b/app/Models/Release.php index 62df8d318..a1a7c96ee 100644 --- a/app/Models/Release.php +++ b/app/Models/Release.php @@ -4,7 +4,6 @@ namespace App\Models; use Blacklight\NZB; use Blacklight\SphinxSearch; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Watson\Rememberable\Rememberable; use Illuminate\Database\Eloquent\Model; @@ -265,7 +264,7 @@ class Release extends Model 'searchname' => $parameters['searchname'], 'totalpart' => $parameters['totalpart'], 'groups_id' => $parameters['groups_id'], - 'adddate' => Carbon::now(), + 'adddate' => now(), 'guid' => $parameters['guid'], 'leftguid' => $parameters['guid'][0], 'postdate' => $parameters['postdate'], diff --git a/app/Models/ReleaseComment.php b/app/Models/ReleaseComment.php index 4c22e62b6..13d28bde2 100644 --- a/app/Models/ReleaseComment.php +++ b/app/Models/ReleaseComment.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -147,8 +146,8 @@ class ReleaseComment extends Model 'gid' => $gid, 'text' => $text, 'users_id' => $userid, - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), 'host' => $host, 'username' => $username, ] diff --git a/app/Models/User.php b/app/Models/User.php index e5cd1469b..ce05c3b5e 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,7 +5,6 @@ namespace App\Models; use App\Mail\SendInvite; use App\Mail\AccountChange; use Illuminate\Support\Str; -use Illuminate\Support\Carbon; use Blacklight\utility\Utility; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; @@ -455,7 +454,7 @@ class User extends Authenticatable */ public static function updateExpiredRoles(): int { - $data = self::query()->whereDate('rolechangedate', '<', Carbon::now())->get(); + $data = self::query()->whereDate('rolechangedate', '<', now())->get(); foreach ($data as $u) { Mail::to($u['email'])->send(new AccountChange($u['id'])); @@ -921,7 +920,7 @@ class User extends Authenticatable { self::query()->where('id', $userID)->update( [ - 'lastlogin' => Carbon::now(), + 'lastlogin' => now(), 'host' => $host, ] ); @@ -1060,7 +1059,7 @@ class User extends Authenticatable UserDownload::query()->update(['releases_id' => null]); } - UserRequest::query()->where('timestamp', '<', Carbon::now()->subDays($days))->delete(); - UserDownload::query()->where('timestamp', '<', Carbon::now()->subDays($days))->delete(); + UserRequest::query()->where('timestamp', '<', now()->subDays($days))->delete(); + UserDownload::query()->where('timestamp', '<', now()->subDays($days))->delete(); } } diff --git a/app/Models/UserDownload.php b/app/Models/UserDownload.php index 46066d7fa..d31681364 100644 --- a/app/Models/UserDownload.php +++ b/app/Models/UserDownload.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -59,8 +58,8 @@ class UserDownload extends Model public static function getDownloadRequests($userID): int { // Clear old requests. - self::query()->where('users_id', $userID)->where('timestamp', '<', Carbon::now()->subDay())->delete(); - $value = self::query()->where('users_id', $userID)->where('timestamp', '>', Carbon::now()->subDay())->count('id'); + self::query()->where('users_id', $userID)->where('timestamp', '<', now()->subDay())->delete(); + $value = self::query()->where('users_id', $userID)->where('timestamp', '>', now()->subDay())->count('id'); return $value === false ? 0 : $value; } @@ -90,7 +89,7 @@ class UserDownload extends Model [ 'users_id' => $userID, 'releases_id' => $releaseID, - 'timestamp' => Carbon::now(), + 'timestamp' => now(), ] ); } diff --git a/app/Models/UserMovie.php b/app/Models/UserMovie.php index fecc899da..7e990df32 100644 --- a/app/Models/UserMovie.php +++ b/app/Models/UserMovie.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -48,7 +47,7 @@ class UserMovie extends Model 'users_id' => $uid, 'imdbid' => $imdbid, 'categories' => ! empty($catID) ? implode('|', $catID) : 'NULL', - 'created_at' => Carbon::now(), + 'created_at' => now(), ] ); } diff --git a/app/Models/UserRequest.php b/app/Models/UserRequest.php index 738c1a14c..2570081ba 100644 --- a/app/Models/UserRequest.php +++ b/app/Models/UserRequest.php @@ -2,7 +2,6 @@ namespace App\Models; -use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -84,7 +83,7 @@ class UserRequest extends Model */ public static function addApiRequest($userID, $request): void { - self::query()->insert(['users_id' => $userID, 'request' => $request, 'timestamp'=> Carbon::now()]); + self::query()->insert(['users_id' => $userID, 'request' => $request, 'timestamp'=> now()]); } /** @@ -100,9 +99,9 @@ class UserRequest extends Model public static function clearApiRequests($userID): void { if ($userID === false) { - self::query()->where('timestamp', '<', Carbon::now()->subDay())->delete(); + self::query()->where('timestamp', '<', now()->subDay())->delete(); } else { - self::query()->where('users_id', $userID)->where('timestamp', '<', Carbon::now()->subDay())->delete(); + self::query()->where('users_id', $userID)->where('timestamp', '<', now()->subDay())->delete(); } } } diff --git a/app/Models/UserSerie.php b/app/Models/UserSerie.php index 9be422565..658a9f97c 100644 --- a/app/Models/UserSerie.php +++ b/app/Models/UserSerie.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -60,8 +59,8 @@ class UserSerie extends Model 'users_id' => $userId, 'videos_id' => $videoId, 'categories' => ! empty($catID) ? implode('|', $catID) : 'NULL', - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); } diff --git a/app/Models/UsersRelease.php b/app/Models/UsersRelease.php index 5fa47c5ac..8c776252d 100644 --- a/app/Models/UsersRelease.php +++ b/app/Models/UsersRelease.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -64,8 +63,8 @@ class UsersRelease extends Model [ 'users_id' => $uid, 'releases_id' => $releaseid, - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), + 'created_at' => now(), + 'updated_at' => now(), ] ); } diff --git a/app/Models/Video.php b/app/Models/Video.php index 01c41d00f..be5da8bab 100644 --- a/app/Models/Video.php +++ b/app/Models/Video.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Support\Carbon; use Illuminate\Database\Eloquent\Model; /** @@ -160,7 +159,7 @@ class Video extends Model $join->on('videos.id', '=', 'us.videos_id')->where('us.users_id', '=', $uid); }) ->whereBetween('r.categories_id', [Category::TV_ROOT, Category::TV_OTHER]) - ->where('tve.firstaired', '<', Carbon::now()) + ->where('tve.firstaired', '<', now()) ->leftJoin('releases as r', 'r.videos_id', '=', 'videos.id') ->orderBy('videos.title') ->orderByDesc('tve.firstaired') diff --git a/misc/update/tmux/bin/groupfixrelnames.php b/misc/update/tmux/bin/groupfixrelnames.php index c15861797..3a8ecaa88 100644 --- a/misc/update/tmux/bin/groupfixrelnames.php +++ b/misc/update/tmux/bin/groupfixrelnames.php @@ -12,7 +12,6 @@ use App\Models\Settings; use Blacklight\ColorCLI; use Blacklight\NameFixer; use Blacklight\NZBContents; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Blacklight\processing\PostProcess; @@ -224,7 +223,7 @@ switch (true) { $pres = Predb::query() ->whereRaw('LENGTH(title) >= 15 AND title NOT REGEXP "[\"\<\> ]"') ->where('searched', '=', 0) - ->where('predate', '<', Carbon::now()->subDay()) + ->where('predate', '<', now()->subDay()) ->select(['id as predb_id', 'title', 'source', 'searched']) ->orderBy('predate') ->limit($maxPerRun) diff --git a/misc/update/tmux/bin/update_groups.php b/misc/update/tmux/bin/update_groups.php index 48d325b15..c7e68893d 100644 --- a/misc/update/tmux/bin/update_groups.php +++ b/misc/update/tmux/bin/update_groups.php @@ -7,7 +7,6 @@ use App\Models\Group; use Blacklight\ColorCLI; use App\Models\ShortGroup; use Blacklight\ConsoleTools; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; $start = time(); @@ -40,7 +39,7 @@ foreach ($data as $newgroup) { 'name' => $newgroup['group'], 'first_record' => $newgroup['first'], 'last_record' => $newgroup['last'], - 'updated' => Carbon::now(), + 'updated' => now(), ] ); ColorCLI::doEcho(ColorCLI::primary('Updated '.$newgroup['group']));