@@ -20,7 +20,7 @@ |
||
20 | 20 | Paginator::useBootstrapFive(); |
21 | 21 | $smarty = app('smarty.view'); |
22 | 22 | view()->share('smarty', $smarty); |
23 | - Gate::define('viewPulse', function (User $user) { |
|
23 | + Gate::define('viewPulse', function(User $user) { |
|
24 | 24 | return $user->hasRole('Admin'); |
25 | 25 | }); |
26 | 26 | Event::listen(Login::class, LoginViaRemember::class); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | use Illuminate\Support\Facades\DB; |
16 | 16 | |
17 | 17 | $colorCli = new ColorCLI; |
18 | -if (! isset($argv[1])) { |
|
18 | +if (!isset($argv[1])) { |
|
19 | 19 | $colorCli->error('This script is not intended to be run manually, it is called from Multiprocessing.'); |
20 | 20 | exit(); |
21 | 21 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if (preg_match('/[a-fA-F0-9]{32,40}/i', $release->name, $hits)) { |
88 | 88 | $nameFixer->matchPredbHash($hits[0], $release, true, 1, true); |
89 | 89 | } |
90 | - if ($nameFixer->matched === false && ! empty($release->filehash) && preg_match('/[a-fA-F0-9]{32,40}/i', $release->filehash, $hits)) { |
|
90 | + if ($nameFixer->matched === false && !empty($release->filehash) && preg_match('/[a-fA-F0-9]{32,40}/i', $release->filehash, $hits)) { |
|
91 | 91 | $colorCli->primaryOver('h'); |
92 | 92 | $nameFixer->matchPredbHash($hits[0], $release, true, 1, true); |
93 | 93 | } |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | $nameFixer->reset(); |
100 | 100 | |
101 | - if ((int) $release->proc_uid === NameFixer::PROC_UID_NONE && (! empty($release->uid) || ! empty($release->mediainfo))) { |
|
101 | + if ((int) $release->proc_uid === NameFixer::PROC_UID_NONE && (!empty($release->uid) || !empty($release->mediainfo))) { |
|
102 | 102 | $colorCli->primaryOver('U'); |
103 | - if (! empty($release->uid)) { |
|
103 | + if (!empty($release->uid)) { |
|
104 | 104 | $nameFixer->checkName($release, true, 'UID, ', 1, true); |
105 | 105 | } |
106 | - if (empty($nameFixer->matched) && ! empty($release->mediainfo)) { |
|
106 | + if (empty($nameFixer->matched) && !empty($release->mediainfo)) { |
|
107 | 107 | $nameFixer->checkName($release, true, 'Mediainfo, ', 1, true); |
108 | 108 | } |
109 | 109 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | } |
116 | 116 | $nameFixer->reset(); |
117 | 117 | |
118 | - if ((int) $release->proc_crc32 === NameFixer::PROC_CRC_NONE && ! empty($release->crc)) { |
|
118 | + if ((int) $release->proc_crc32 === NameFixer::PROC_CRC_NONE && !empty($release->crc)) { |
|
119 | 119 | $colorCli->primaryOver('C'); |
120 | 120 | $nameFixer->checkName($release, true, 'CRC32, ', 1, true); |
121 | 121 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | } |
140 | 140 | $nameFixer->reset(); |
141 | 141 | |
142 | - if ((int) $release->proc_hash16k === NameFixer::PROC_HASH16K_NONE && ! empty($release->hash)) { |
|
142 | + if ((int) $release->proc_hash16k === NameFixer::PROC_HASH16K_NONE && !empty($release->hash)) { |
|
143 | 143 | $colorCli->primaryOver('H'); |
144 | 144 | $nameFixer->checkName($release, true, 'PAR2 hash, ', 1, true); |
145 | 145 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | $nameFixer->reset(); |
153 | 153 | |
154 | - if ((int) $release->nfostatus === Nfo::NFO_FOUND && (int) $release->proc_nfo === NameFixer::PROC_NFO_NONE && ! empty($release->textstring) && ! preg_match('/^=newz\[NZB\]=\w+/', $release->textstring)) { |
|
154 | + if ((int) $release->nfostatus === Nfo::NFO_FOUND && (int) $release->proc_nfo === NameFixer::PROC_NFO_NONE && !empty($release->textstring) && !preg_match('/^=newz\[NZB\]=\w+/', $release->textstring)) { |
|
155 | 155 | $colorCli->primaryOver('n'); |
156 | 156 | $nameFixer->done = $nameFixer->matched = false; |
157 | 157 | $nameFixer->checkName($release, true, 'NFO, ', 1, true); |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | if ((int) $release->proc_par2 === NameFixer::PROC_PAR2_NONE) { |
191 | 191 | $colorCli->primaryOver('p'); |
192 | - if (! isset($nzbcontents)) { |
|
192 | + if (!isset($nzbcontents)) { |
|
193 | 193 | $nntp = new NNTP; |
194 | 194 | $compressedHeaders = config('nntmux_nntp.compressed_headers'); |
195 | 195 | if ((config('nntmux_nntp.use_alternate_nntp_server') === true ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect()) !== true) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $nzbSplitLevel = (int) Settings::settingValue('nzbsplitlevel'); |
67 | 67 | $this->nzbSplitLevel = $nzbSplitLevel ?? 1; |
68 | 68 | $this->siteNzbPath = config('nntmux_settings.path_to_nzbs'); |
69 | - if (! Str::endsWith($this->siteNzbPath, '/')) { |
|
69 | + if (!Str::endsWith($this->siteNzbPath, '/')) { |
|
70 | 70 | $this->siteNzbPath .= '/'; |
71 | 71 | } |
72 | 72 | $this->_nzbCommentString = sprintf( |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $XMLWriter->startElement('head'); |
111 | 111 | $XMLWriter->startElement('meta'); |
112 | 112 | $XMLWriter->writeAttribute('type', 'category'); |
113 | - $XMLWriter->text(! empty($release->category->parent) ? $release->category->parent->title.' >'.$release->category->title : 'Other > Misc'); |
|
113 | + $XMLWriter->text(!empty($release->category->parent) ? $release->category->parent->title.' >'.$release->category->title : 'Other > Misc'); |
|
114 | 114 | $XMLWriter->endElement(); |
115 | 115 | $XMLWriter->startElement('meta'); |
116 | 116 | $XMLWriter->writeAttribute('type', 'name'); |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | $XMLWriter->endDocument(); |
173 | 173 | $path = ($this->buildNZBPath($release->guid, $this->nzbSplitLevel, true).$release->guid.'.nzb.gz'); |
174 | 174 | $fp = gzopen($path, 'wb7'); |
175 | - if (! $fp) { |
|
175 | + if (!$fp) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | gzwrite($fp, $XMLWriter->outputMemory()); |
179 | 179 | gzclose($fp); |
180 | 180 | unset($XMLWriter); |
181 | - if (! File::isFile($path)) { |
|
181 | + if (!File::isFile($path)) { |
|
182 | 182 | echo "ERROR: $path does not exist.\n"; |
183 | 183 | |
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | // Mark release as having NZB. |
187 | 187 | $release->update(['nzbstatus' => self::NZB_ADDED]); |
188 | - if (! empty($nzb_guid)) { |
|
188 | + if (!empty($nzb_guid)) { |
|
189 | 189 | $release->update(['nzb_guid' => DB::raw('UNHEX( '.escapeString(md5($nzb_guid)).' )')]); |
190 | 190 | } |
191 | 191 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | $nzbPath = $this->siteNzbPath.$nzbPath; |
218 | 218 | |
219 | - if ($createIfNotExist && ! File::isDirectory($nzbPath) && ! File::makeDirectory($nzbPath, 0777, true) && ! File::isDirectory($nzbPath)) { |
|
219 | + if ($createIfNotExist && !File::isDirectory($nzbPath) && !File::makeDirectory($nzbPath, 0777, true) && !File::isDirectory($nzbPath)) { |
|
220 | 220 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $nzbPath)); |
221 | 221 | } |
222 | 222 | |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | $i = 0; |
273 | 273 | $result = []; |
274 | 274 | |
275 | - if (! $nzb) { |
|
275 | + if (!$nzb) { |
|
276 | 276 | return $result; |
277 | 277 | } |
278 | 278 | |
279 | 279 | $xml = @simplexml_load_string(str_replace("\x0F", '', $nzb)); |
280 | - if (! $xml || strtolower($xml->getName()) !== 'nzb') { |
|
280 | + if (!$xml || strtolower($xml->getName()) !== 'nzb') { |
|
281 | 281 | return $result; |
282 | 282 | } |
283 | 283 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | // Strip file / part count to get proper sorting. |
292 | 292 | $i = preg_replace('#\d+[- ._]?(/|\||[o0]f)[- ._]?\d+?(?![- ._]\d)#i', '', $i); |
293 | 293 | // Change .rar and .par2 to be sorted before .part0x.rar and .volxxx+xxx.par2 |
294 | - if (str_contains($i, '.par2') && ! preg_match('#\.vol\d+\+\d+\.par2#i', $i)) { |
|
294 | + if (str_contains($i, '.par2') && !preg_match('#\.vol\d+\+\d+\.par2#i', $i)) { |
|
295 | 295 | $i = str_replace('.par2', '.vol0.par2', $i); |
296 | - } elseif (preg_match('#\.rar[^a-z0-9]#i', $i) && ! preg_match('#\.part\d+\.rar$#i', $i)) { |
|
296 | + } elseif (preg_match('#\.rar[^a-z0-9]#i', $i) && !preg_match('#\.part\d+\.rar$#i', $i)) { |
|
297 | 297 | $i = preg_replace('#\.rar(?:[^a-z0-9])#i', '.part0.rar', $i); |
298 | 298 | } |
299 | 299 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $fileSize = $numSegments = 0; |
327 | 327 | |
328 | 328 | // Parts. |
329 | - if (! isset($result[$i]['segments'])) { |
|
329 | + if (!isset($result[$i]['segments'])) { |
|
330 | 330 | $result[$i]['segments'] = []; |
331 | 331 | } |
332 | 332 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $result[$i]['partsactual'] = $numSegments; |
346 | 346 | |
347 | 347 | // Groups. |
348 | - if (! isset($result[$i]['groups'])) { |
|
348 | + if (!isset($result[$i]['groups'])) { |
|
349 | 349 | $result[$i]['groups'] = []; |
350 | 350 | } |
351 | 351 | foreach ($file->groups->group as $g) { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $this->echoCLI = config('nntmux.echocli'); |
110 | 110 | $groupID = ''; |
111 | 111 | |
112 | - if (! empty($groupName)) { |
|
112 | + if (!empty($groupName)) { |
|
113 | 113 | $groupInfo = UsenetGroup::getByName($groupName); |
114 | 114 | if ($groupInfo !== null) { |
115 | 115 | $groupID = $groupInfo['id']; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->colorCLI->header('Starting release update process ('.now()->format('Y-m-d H:i:s').')'); |
121 | 121 | } |
122 | 122 | |
123 | - if (! file_exists(config('nntmux_settings.path_to_nzbs'))) { |
|
123 | + if (!file_exists(config('nntmux_settings.path_to_nzbs'))) { |
|
124 | 124 | if ($this->echoCLI) { |
125 | 125 | $this->colorCLI->error('Bad or missing nzb directory - '.config('nntmux_settings.path_to_nzbs')); |
126 | 126 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $cat = new Categorize; |
182 | 182 | $categorized = $total = 0; |
183 | 183 | $releasesQuery = Release::query()->where(['categories_id' => Category::OTHER_MISC, 'iscategorized' => 0]); |
184 | - if (! empty($groupId)) { |
|
184 | + if (!empty($groupId)) { |
|
185 | 185 | $releasesQuery->where('groups_id', $groupId); |
186 | 186 | } |
187 | 187 | $releases = $releasesQuery->select(['id', 'fromname', 'groups_id', $type])->get(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->colorCLI->header('Process Releases -> Attempting to find complete collections.'); |
218 | 218 | } |
219 | 219 | |
220 | - $where = (! empty($groupID) ? ' AND c.groups_id = '.$groupID.' ' : ' '); |
|
220 | + $where = (!empty($groupID) ? ' AND c.groups_id = '.$groupID.' ' : ' '); |
|
221 | 221 | |
222 | 222 | $this->processStuckCollections($groupID); |
223 | 223 | $this->collectionFileCheckStage1($groupID); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | if ($this->echoCLI) { |
231 | 231 | $countQuery = Collection::query()->where('filecheck', self::COLLFC_COMPPART); |
232 | 232 | |
233 | - if (! empty($groupID)) { |
|
233 | + if (!empty($groupID)) { |
|
234 | 234 | $countQuery->where('groups_id', $groupID); |
235 | 235 | } |
236 | 236 | $count = $countQuery->count('id'); |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | $this->colorCLI->header('Process Releases -> Calculating collection sizes (in bytes).'); |
258 | 258 | } |
259 | 259 | // Get the total size in bytes of the collection for collections where filecheck = 2. |
260 | - DB::transaction(function () use ($groupID, $startTime) { |
|
260 | + DB::transaction(function() use ($groupID, $startTime) { |
|
261 | 261 | $checked = DB::update( |
262 | 262 | sprintf( |
263 | 263 | ' |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | AND c.filesize = 0 %s', |
274 | 274 | self::COLLFC_SIZED, |
275 | 275 | self::COLLFC_COMPPART, |
276 | - (! empty($groupID) ? ' AND c.groups_id = '.$groupID : ' ') |
|
276 | + (!empty($groupID) ? ' AND c.groups_id = '.$groupID : ' ') |
|
277 | 277 | ) |
278 | 278 | ); |
279 | 279 | if ($checked > 0 && $this->echoCLI) { |
@@ -312,16 +312,16 @@ discard block |
||
312 | 312 | |
313 | 313 | $groupMinimums = UsenetGroup::getGroupByID($grpID['id']); |
314 | 314 | if ($groupMinimums !== null) { |
315 | - if (! empty($groupMinimums['minsizetoformrelease']) && $groupMinimums['minsizetoformrelease'] > 0) { |
|
315 | + if (!empty($groupMinimums['minsizetoformrelease']) && $groupMinimums['minsizetoformrelease'] > 0) { |
|
316 | 316 | $groupMinSizeSetting = (int) $groupMinimums['minsizetoformrelease']; |
317 | 317 | } |
318 | - if (! empty($groupMinimums['minfilestoformrelease']) && $groupMinimums['minfilestoformrelease'] > 0) { |
|
318 | + if (!empty($groupMinimums['minfilestoformrelease']) && $groupMinimums['minfilestoformrelease'] > 0) { |
|
319 | 319 | $groupMinFilesSetting = (int) $groupMinimums['minfilestoformrelease']; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | if (Collection::query()->where('filecheck', self::COLLFC_SIZED)->where('filesize', '>', 0)->first() !== null) { |
324 | - DB::transaction(function () use ( |
|
324 | + DB::transaction(function() use ( |
|
325 | 325 | $groupMinSizeSetting, |
326 | 326 | $minSizeSetting, |
327 | 327 | $minSizeDeleted, |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | $collectionsQuery = Collection::query() |
394 | 394 | ->where('collections.filecheck', self::COLLFC_SIZED) |
395 | 395 | ->where('collections.filesize', '>', 0); |
396 | - if (! empty($groupID)) { |
|
396 | + if (!empty($groupID)) { |
|
397 | 397 | $collectionsQuery->where('collections.groups_id', $groupID); |
398 | 398 | } |
399 | 399 | $collectionsQuery->select(['collections.*', 'usenet_groups.name as gname']) |
@@ -448,7 +448,7 @@ discard block |
||
448 | 448 | $releaseID = Release::insertRelease( |
449 | 449 | [ |
450 | 450 | 'name' => $cleanRelName, |
451 | - 'searchname' => ! empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8', mb_list_encodings()) : $cleanRelName, |
|
451 | + 'searchname' => !empty($cleanedName) ? mb_convert_encoding($cleanedName, 'UTF-8', mb_list_encodings()) : $cleanRelName, |
|
452 | 452 | 'totalpart' => $collection->totalfiles, |
453 | 453 | 'groups_id' => $collection->groups_id, |
454 | 454 | 'guid' => createGUID(), |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | if ($releaseID !== null) { |
466 | 466 | // Update collections table to say we inserted the release. |
467 | - DB::transaction(static function () use ($collection, $releaseID) { |
|
467 | + DB::transaction(static function() use ($collection, $releaseID) { |
|
468 | 468 | Collection::query()->where('id', $collection->id)->update(['filecheck' => self::COLLFC_INSERTED, 'releases_id' => $releaseID]); |
469 | 469 | }, 10); |
470 | 470 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | } |
526 | 526 | } else { |
527 | 527 | // The release was already in the DB, so delete the collection. |
528 | - DB::transaction(static function () use ($collection) { |
|
528 | + DB::transaction(static function() use ($collection) { |
|
529 | 529 | Collection::query()->where('collectionhash', $collection->collectionhash)->delete(); |
530 | 530 | }, 10); |
531 | 531 | |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | $releasesQuery = Release::query()->with('category.parent')->where('nzbstatus', '=', 0); |
569 | - if (! empty($groupID)) { |
|
569 | + if (!empty($groupID)) { |
|
570 | 570 | $releasesQuery->where('releases.groups_id', $groupID); |
571 | 571 | } |
572 | 572 | $releases = $releasesQuery->select(['id', 'guid', 'name', 'categories_id'])->get(); |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | ), true); |
670 | 670 | } |
671 | 671 | |
672 | - DB::transaction(function () use ($deletedCount, $startTime) { |
|
672 | + DB::transaction(function() use ($deletedCount, $startTime) { |
|
673 | 673 | $deleted = 0; |
674 | 674 | $deleteQuery = Collection::query() |
675 | 675 | ->where('dateadded', '<', now()->subHours(Settings::settingValue('partretentionhours'))) |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | $releases = Release::query() |
833 | 833 | ->select(['id', 'guid']) |
834 | 834 | ->where('passwordstatus', '=', Releases::PASSWD_RAR) |
835 | - ->orWhereIn('id', function ($query) { |
|
835 | + ->orWhereIn('id', function($query) { |
|
836 | 836 | $query->select('releases_id') |
837 | 837 | ->from('release_files') |
838 | 838 | ->where('passworded', '=', Releases::PASSWD_RAR); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | foreach ($genrelist as $genre) { |
892 | 892 | $musicInfoQuery = MusicInfo::query()->where('genre_id', (int) $genre['id'])->select(['id']); |
893 | 893 | $releases = Release::query() |
894 | - ->joinSub($musicInfoQuery, 'mi', function ($join) { |
|
894 | + ->joinSub($musicInfoQuery, 'mi', function($join) { |
|
895 | 895 | $join->on('releases.musicinfo_id', '=', 'mi.id'); |
896 | 896 | }) |
897 | 897 | ->select(['releases.id', 'releases.guid']) |
@@ -977,18 +977,18 @@ discard block |
||
977 | 977 | */ |
978 | 978 | private function collectionFileCheckStage1(int $groupID): void |
979 | 979 | { |
980 | - DB::transaction(static function () use ($groupID) { |
|
980 | + DB::transaction(static function() use ($groupID) { |
|
981 | 981 | $collectionsCheck = Collection::query()->select(['collections.id']) |
982 | 982 | ->join('binaries', 'binaries.collections_id', '=', 'collections.id') |
983 | 983 | ->where('collections.totalfiles', '>', 0) |
984 | 984 | ->where('collections.filecheck', '=', self::COLLFC_DEFAULT); |
985 | - if (! empty($groupID)) { |
|
985 | + if (!empty($groupID)) { |
|
986 | 986 | $collectionsCheck->where('collections.groups_id', $groupID); |
987 | 987 | } |
988 | 988 | $collectionsCheck->groupBy('binaries.collections_id', 'collections.totalfiles', 'collections.id') |
989 | 989 | ->havingRaw('COUNT(binaries.id) IN (collections.totalfiles, collections.totalfiles+1)'); |
990 | 990 | |
991 | - Collection::query()->joinSub($collectionsCheck, 'r', function ($join) { |
|
991 | + Collection::query()->joinSub($collectionsCheck, 'r', function($join) { |
|
992 | 992 | $join->on('collections.id', '=', 'r.id'); |
993 | 993 | })->update(['collections.filecheck' => self::COLLFC_COMPCOLL]); |
994 | 994 | }, 10); |
@@ -1009,25 +1009,25 @@ discard block |
||
1009 | 1009 | */ |
1010 | 1010 | private function collectionFileCheckStage2(int $groupID): void |
1011 | 1011 | { |
1012 | - DB::transaction(static function () use ($groupID) { |
|
1012 | + DB::transaction(static function() use ($groupID) { |
|
1013 | 1013 | $collectionsCheck = Collection::query()->select(['collections.id']) |
1014 | 1014 | ->join('binaries', 'binaries.collections_id', '=', 'collections.id') |
1015 | 1015 | ->where('binaries.filenumber', '=', 0) |
1016 | 1016 | ->where('collections.totalfiles', '>', 0) |
1017 | 1017 | ->where('collections.filecheck', '=', self::COLLFC_COMPCOLL); |
1018 | - if (! empty($groupID)) { |
|
1018 | + if (!empty($groupID)) { |
|
1019 | 1019 | $collectionsCheck->where('collections.groups_id', $groupID); |
1020 | 1020 | } |
1021 | 1021 | $collectionsCheck->groupBy('collections.id'); |
1022 | 1022 | |
1023 | - Collection::query()->joinSub($collectionsCheck, 'r', function ($join) { |
|
1023 | + Collection::query()->joinSub($collectionsCheck, 'r', function($join) { |
|
1024 | 1024 | $join->on('collections.id', '=', 'r.id'); |
1025 | 1025 | })->update(['collections.filecheck' => self::COLLFC_ZEROPART]); |
1026 | 1026 | }, 10); |
1027 | 1027 | |
1028 | - DB::transaction(static function () use ($groupID) { |
|
1028 | + DB::transaction(static function() use ($groupID) { |
|
1029 | 1029 | $collectionQuery = Collection::query()->where('filecheck', '=', self::COLLFC_COMPCOLL); |
1030 | - if (! empty($groupID)) { |
|
1030 | + if (!empty($groupID)) { |
|
1031 | 1031 | $collectionQuery->where('groups_id', $groupID); |
1032 | 1032 | } |
1033 | 1033 | $collectionQuery->update(['filecheck' => self::COLLFC_TEMPCOMP]); |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | private function collectionFileCheckStage3(string $where): void |
1047 | 1047 | { |
1048 | - DB::transaction(static function () use ($where) { |
|
1048 | + DB::transaction(static function() use ($where) { |
|
1049 | 1049 | DB::update( |
1050 | 1050 | sprintf( |
1051 | 1051 | ' |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | ); |
1070 | 1070 | }, 10); |
1071 | 1071 | |
1072 | - DB::transaction(static function () use ($where) { |
|
1072 | + DB::transaction(static function() use ($where) { |
|
1073 | 1073 | DB::update( |
1074 | 1074 | sprintf( |
1075 | 1075 | ' |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | */ |
1107 | 1107 | private function collectionFileCheckStage4(string &$where): void |
1108 | 1108 | { |
1109 | - DB::transaction(static function () use ($where) { |
|
1109 | + DB::transaction(static function() use ($where) { |
|
1110 | 1110 | DB::update( |
1111 | 1111 | sprintf( |
1112 | 1112 | ' |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | */ |
1137 | 1137 | private function collectionFileCheckStage5(int $groupId): void |
1138 | 1138 | { |
1139 | - DB::transaction(static function () use ($groupId) { |
|
1139 | + DB::transaction(static function() use ($groupId) { |
|
1140 | 1140 | $collectionQuery = Collection::query()->whereIn('filecheck', [self::COLLFC_TEMPCOMP, self::COLLFC_ZEROPART]); |
1141 | - if (! empty($groupId)) { |
|
1141 | + if (!empty($groupId)) { |
|
1142 | 1142 | $collectionQuery->where('groups_id', $groupId); |
1143 | 1143 | } |
1144 | 1144 | $collectionQuery->update(['filecheck' => self::COLLFC_COMPCOLL]); |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | */ |
1157 | 1157 | private function collectionFileCheckStage6(string &$where): void |
1158 | 1158 | { |
1159 | - DB::transaction(function () use ($where) { |
|
1159 | + DB::transaction(function() use ($where) { |
|
1160 | 1160 | DB::update( |
1161 | 1161 | sprintf( |
1162 | 1162 | " |
@@ -1186,10 +1186,10 @@ discard block |
||
1186 | 1186 | { |
1187 | 1187 | $lastRun = Settings::settingValue('last_run_time'); |
1188 | 1188 | |
1189 | - DB::transaction(function () use ($groupID, $lastRun) { |
|
1189 | + DB::transaction(function() use ($groupID, $lastRun) { |
|
1190 | 1190 | $objQuery = Collection::query() |
1191 | 1191 | ->where('added', '<', Carbon::createFromFormat('Y-m-d H:i:s', $lastRun)->subHours($this->collectionTimeout)); |
1192 | - if (! empty($groupID)) { |
|
1192 | + if (!empty($groupID)) { |
|
1193 | 1193 | $objQuery->where('groups_id', $groupID); |
1194 | 1194 | } |
1195 | 1195 | $obj = $objQuery->delete(); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ]; |
152 | 152 | $primaryConnections = $this->_tmux->getUSPConnections('primary', $primaryUSP); |
153 | 153 | $alternateConnections = $this->_tmux->getUSPConnections('alternate', $alternateUSP); |
154 | - if ($this->_isConnected() && (($alternate && $this->_currentServer === config('nntmux_nntp.alternate_server') && ($this->_primaryNntpConnections < $alternateConnections['alternate']['active'])) || (! $alternate && $this->_currentServer === config('nntmux_nntp.server') && ($this->_primaryNntpConnections < $primaryConnections['primary']['active'])))) { |
|
154 | + if ($this->_isConnected() && (($alternate && $this->_currentServer === config('nntmux_nntp.alternate_server') && ($this->_primaryNntpConnections < $alternateConnections['alternate']['active'])) || (!$alternate && $this->_currentServer === config('nntmux_nntp.server') && ($this->_primaryNntpConnections < $primaryConnections['primary']['active'])))) { |
|
155 | 155 | return true; |
156 | 156 | } |
157 | 157 | |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | $ret = $connected = $cError = $aError = false; |
161 | 161 | |
162 | 162 | // Set variables to connect based on if we are using the alternate provider or not. |
163 | - if (! $alternate) { |
|
163 | + if (!$alternate) { |
|
164 | 164 | $sslEnabled = (bool) config('nntmux_nntp.ssl'); |
165 | 165 | $this->_currentServer = config('nntmux_nntp.server'); |
166 | 166 | $this->_currentPort = config('nntmux_nntp.port'); |
167 | 167 | $userName = config('nntmux_nntp.username'); |
168 | 168 | $password = config('nntmux_nntp.password'); |
169 | - $socketTimeout = ! empty(config('nntmux_nntp.socket_timeout')) ? config('nntmux_nntp.socket_timeout') : $this->_socketTimeout; |
|
169 | + $socketTimeout = !empty(config('nntmux_nntp.socket_timeout')) ? config('nntmux_nntp.socket_timeout') : $this->_socketTimeout; |
|
170 | 170 | } else { |
171 | 171 | $sslEnabled = (bool) config('nntmux_nntp.alternate_server_ssl'); |
172 | 172 | $this->_currentServer = config('nntmux_nntp.alternate_server'); |
173 | 173 | $this->_currentPort = config('nntmux_nntp.alternate_server_port'); |
174 | 174 | $userName = config('nntmux_nntp.alternate_server_username'); |
175 | 175 | $password = config('nntmux_nntp.alternate_server_password'); |
176 | - $socketTimeout = ! empty(config('nntmux_nntp.alternate_server_socket_timeout')) ? config('nntmux_nntp.alternate_server_socket_timeout') : $this->_socketTimeout; |
|
176 | + $socketTimeout = !empty(config('nntmux_nntp.alternate_server_socket_timeout')) ? config('nntmux_nntp.alternate_server_socket_timeout') : $this->_socketTimeout; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $enc = ($sslEnabled ? ' (ssl)' : ' (non-ssl)'); |
@@ -186,19 +186,19 @@ discard block |
||
186 | 186 | $authenticated = false; |
187 | 187 | |
188 | 188 | // If we are not connected, try to connect. |
189 | - if (! $connected) { |
|
189 | + if (!$connected) { |
|
190 | 190 | $ret = $this->connect($this->_currentServer, $sslEnabled, $this->_currentPort, 5, $socketTimeout); |
191 | 191 | } |
192 | 192 | // Check if we got an error while connecting. |
193 | 193 | $cErr = self::isError($ret); |
194 | 194 | |
195 | 195 | // If no error, we are connected. |
196 | - if (! $cErr) { |
|
196 | + if (!$cErr) { |
|
197 | 197 | // Say that we are connected so we don't retry. |
198 | 198 | $connected = true; |
199 | 199 | // When there is no error it returns bool if we are allowed to post or not. |
200 | 200 | $this->_postingAllowed = $ret; |
201 | - } elseif (! $cError) { |
|
201 | + } elseif (!$cError) { |
|
202 | 202 | $cError = $ret->getMessage(); |
203 | 203 | } |
204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | } |
209 | 209 | |
210 | 210 | // If we have no more retries and could not connect, return an error. |
211 | - if ($retries === 0 && ! $connected) { |
|
211 | + if ($retries === 0 && !$connected) { |
|
212 | 212 | $message = |
213 | 213 | 'Cannot connect to server '. |
214 | 214 | $this->_currentServer. |
@@ -233,9 +233,9 @@ discard block |
||
233 | 233 | $aErr = self::isError($ret2); |
234 | 234 | |
235 | 235 | // If there was no error, then we are authenticated. |
236 | - if (! $aErr) { |
|
236 | + if (!$aErr) { |
|
237 | 237 | $authenticated = true; |
238 | - } elseif (! $aError) { |
|
238 | + } elseif (!$aError) { |
|
239 | 239 | $aError = $ret2->getMessage(); |
240 | 240 | } |
241 | 241 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // If we ran out of retries, return an error. |
248 | - if ($retries === 0 && ! $authenticated) { |
|
248 | + if ($retries === 0 && !$authenticated) { |
|
249 | 249 | $message = |
250 | 250 | 'Cannot authenticate to server '. |
251 | 251 | $this->_currentServer. |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | // If we are connected and authenticated, try enabling compression if we have it enabled. |
262 | 262 | if ($connected && $authenticated) { |
263 | 263 | // Check if we should use compression on the connection. |
264 | - if (! $compression || config('nntmux_nntp.compressed_headers') === false) { |
|
264 | + if (!$compression || config('nntmux_nntp.compressed_headers') === false) { |
|
265 | 265 | $this->_compressionSupported = false; |
266 | 266 | } |
267 | 267 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $message = $this->_getMessage($groupName, $wanted); |
545 | 545 | |
546 | 546 | // Append the body to $body. |
547 | - if (! self::isError($message)) { |
|
547 | + if (!self::isError($message)) { |
|
548 | 548 | $body .= $message; |
549 | 549 | |
550 | 550 | if ($messageSize === 0) { |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | // If there is an error try the alternate provider or return the PEAR error. |
555 | 555 | } elseif ($alternate) { |
556 | - if (! $aConnected) { |
|
556 | + if (!$aConnected) { |
|
557 | 557 | $compressedHeaders = config('nntmux_nntp.compressed_headers'); |
558 | 558 | // Check if the current connected server is the alternate or not. |
559 | 559 | $aConnected = $this->_currentServer === config('nntmux_nntp.server') ? $nntp->doConnect($compressedHeaders, true) : $nntp->doConnect(); |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | // Check if it's an article number or message-ID. |
645 | - if (! is_numeric($identifier)) { |
|
645 | + if (!is_numeric($identifier)) { |
|
646 | 646 | // If it's a message-ID, check if it has the required triangular brackets. |
647 | 647 | $identifier = $this->_formatMessageID($identifier); |
648 | 648 | } |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | $emptyLine = false; |
663 | 663 | foreach ($article as $line) { |
664 | 664 | // If we found the empty line it means we are done reading the header and we will start reading the body. |
665 | - if (! $emptyLine) { |
|
665 | + if (!$emptyLine) { |
|
666 | 666 | if ($line === '') { |
667 | 667 | $emptyLine = true; |
668 | 668 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | } |
721 | 721 | |
722 | 722 | // Check if it's an article number or message-id. |
723 | - if (! is_numeric($identifier)) { |
|
723 | + if (!is_numeric($identifier)) { |
|
724 | 724 | // Verify we have the required triangular brackets if it is a message-id. |
725 | 725 | $identifier = $this->_formatMessageID($identifier); |
726 | 726 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | */ |
771 | 771 | public function postArticle(array|string $groups, string $subject, \Exception|string $body, string $from, bool $yEnc = true, bool $compress = true, string $extra = ''): mixed |
772 | 772 | { |
773 | - if (! $this->_postingAllowed) { |
|
773 | + if (!$this->_postingAllowed) { |
|
774 | 774 | $message = 'You do not have the right to post articles on server '.$this->_currentServer; |
775 | 775 | |
776 | 776 | return $this->throwError($this->colorCli->climate()->error($message)); |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | if ($this->_compressionEnabled) { |
905 | 905 | return true; |
906 | 906 | } |
907 | - if (! $this->_compressionSupported) { |
|
907 | + if (!$this->_compressionSupported) { |
|
908 | 908 | return false; |
909 | 909 | } |
910 | 910 | |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | return $response; |
919 | 919 | } |
920 | 920 | if ($response !== 290) { |
921 | - if (! $secondTry) { |
|
921 | + if (!$secondTry) { |
|
922 | 922 | // Retry. |
923 | 923 | $this->cmdQuit(); |
924 | 924 | if ($this->_checkConnection()) { |
@@ -976,7 +976,7 @@ discard block |
||
976 | 976 | $possibleTerm = false; |
977 | 977 | $data = null; |
978 | 978 | |
979 | - while (! feof($this->_socket)) { |
|
979 | + while (!feof($this->_socket)) { |
|
980 | 980 | // Did we find a possible ending ? (.\r\n) |
981 | 981 | if ($possibleTerm) { |
982 | 982 | // Loop, sleeping shortly, to allow the server time to upload data, if it has any. |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | stream_set_blocking($this->_socket, 1); |
992 | 992 | |
993 | 993 | // Don't sleep on last iteration. |
994 | - if (! empty($buffer)) { |
|
994 | + if (!empty($buffer)) { |
|
995 | 995 | break; |
996 | 996 | } |
997 | 997 | if ($i < 2) { |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | // Remove .\r\n from end, decompress data. |
1005 | 1005 | $deComp = @gzuncompress(mb_substr($data, 0, -3, '8bit')); |
1006 | 1006 | |
1007 | - if (! empty($deComp)) { |
|
1007 | + if (!empty($deComp)) { |
|
1008 | 1008 | $bytesReceived = \strlen($data); |
1009 | 1009 | if ($this->_echo && $bytesReceived > 10240) { |
1010 | 1010 | $this->colorCli->climate()->primaryOver( |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | // Check if the last char is >, if not add it. |
1079 | - if (! str_ends_with($messageID, '>')) { |
|
1079 | + if (!str_ends_with($messageID, '>')) { |
|
1080 | 1080 | $messageID .= '>'; |
1081 | 1081 | } |
1082 | 1082 | |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | // Check if this is an article number or message-id. |
1106 | - if (! is_numeric($identifier)) { |
|
1106 | + if (!is_numeric($identifier)) { |
|
1107 | 1107 | // It's a message-id so check if it has the triangular brackets. |
1108 | 1108 | $identifier = $this->_formatMessageID($identifier); |
1109 | 1109 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | $body = ''; |
1118 | 1118 | if ($response === NET_NNTP_PROTOCOL_RESPONSECODE_BODY_FOLLOWS) { |
1119 | 1119 | // Continue until connection is lost |
1120 | - while (! feof($this->_socket)) { |
|
1120 | + while (!feof($this->_socket)) { |
|
1121 | 1121 | // Retrieve and append up to 1024 characters from the server. |
1122 | 1122 | $line = fgets($this->_socket, 1024); |
1123 | 1123 | |
@@ -1367,6 +1367,6 @@ discard block |
||
1367 | 1367 | */ |
1368 | 1368 | public function _isConnected(bool $feOf = true): bool |
1369 | 1369 | { |
1370 | - return is_resource($this->_socket) && (! $feOf || ! feof($this->_socket)); |
|
1370 | + return is_resource($this->_socket) && (!$feOf || !feof($this->_socket)); |
|
1371 | 1371 | } |
1372 | 1372 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | // Get the default user role. |
148 | 148 | $userDefault = Role::query()->where('isdefault', '=', 1)->first(); |
149 | 149 | |
150 | - if (! empty($error)) { |
|
150 | + if (!empty($error)) { |
|
151 | 151 | return $this->showRegistrationForm($request, $error); |
152 | 152 | } |
153 | 153 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | break; |
171 | 171 | case 'view': |
172 | 172 | // See if it is a valid invite. |
173 | - if (($inviteCode !== null) && ! Invite::isValid($inviteCode)) { |
|
173 | + if (($inviteCode !== null) && !Invite::isValid($inviteCode)) { |
|
174 | 174 | $error = 'Invalid invitation token!'; |
175 | 175 | $showRegister = 0; |
176 | 176 | } else { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | if ((int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
205 | - if (! empty($inviteCode)) { |
|
205 | + if (!empty($inviteCode)) { |
|
206 | 206 | if (Invite::isValid($inviteCode)) { |
207 | 207 | $error = ''; |
208 | 208 | $showRegister = 1; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | // convert from a string array to an int array as we want to use int |
152 | - $book_reqids_ids = array_map(function ($value) { |
|
152 | + $book_reqids_ids = array_map(function($value) { |
|
153 | 153 | return (int) $value; |
154 | 154 | }, $book_reqids_ids); |
155 | 155 | $this->smarty->assign('book_reqids_ids', $book_reqids_ids); |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | $books_selected = explode(',', Settings::settingValue('book_reqids')); |
160 | 160 | |
161 | 161 | // convert from a string array to an int array |
162 | - $books_selected = array_map(function ($value) { |
|
162 | + $books_selected = array_map(function($value) { |
|
163 | 163 | return (int) $value; |
164 | 164 | }, $books_selected); |
165 | 165 | $this->smarty->assign('book_reqids_selected', $books_selected); |
166 | 166 | |
167 | 167 | $this->smarty->assign('themelist', Utility::getThemesList()); |
168 | 168 | |
169 | - if (! str_contains(config('settings.nntp_server'), 'astra')) { |
|
169 | + if (!str_contains(config('settings.nntp_server'), 'astra')) { |
|
170 | 170 | $this->smarty->assign('compress_headers_warning', 'compress_headers_warning'); |
171 | 171 | } |
172 | 172 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $privateProfiles = config('nntmux_settings.private_profiles'); |
32 | 32 | $publicView = false; |
33 | 33 | |
34 | - if ($privileged || ! $privateProfiles) { |
|
34 | + if ($privileged || !$privateProfiles) { |
|
35 | 35 | $altID = ($request->has('id') && (int) $request->input('id') >= 0) ? (int) $request->input('id') : false; |
36 | 36 | $altUsername = ($request->has('name') && $request->input('name') !== '') ? $request->input('name') : false; |
37 | 37 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | // Check if the user selected a theme. |
64 | - if (! isset($this->userdata->style) || $this->userdata->style === 'None') { |
|
64 | + if (!isset($this->userdata->style) || $this->userdata->style === 'None') { |
|
65 | 65 | $this->userdata->style = 'Using the admin selected theme.'; |
66 | 66 | } |
67 | 67 | $this->smarty->assign( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $action = $request->input('action') ?? 'view'; |
113 | 113 | |
114 | 114 | $userid = $this->userdata->id; |
115 | - if (! $this->userdata) { |
|
115 | + if (!$this->userdata) { |
|
116 | 116 | $this->show404('No such user!'); |
117 | 117 | } |
118 | 118 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | 'None', |
152 | 152 | ); |
153 | 153 | |
154 | - if ((int) $request->input('viewconsole') === 1 && $this->userdata->can('view console') && ! $this->userdata->hasDirectPermission('view console')) { |
|
154 | + if ((int) $request->input('viewconsole') === 1 && $this->userdata->can('view console') && !$this->userdata->hasDirectPermission('view console')) { |
|
155 | 155 | $this->userdata->givePermissionTo('view console'); |
156 | 156 | } elseif ((int) $request->input('viewconsole') === 0 && $this->userdata->can('view console') && $this->userdata->hasDirectPermission('view console')) { |
157 | 157 | $this->userdata->revokePermissionTo('view console'); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $this->userdata->revokePermissionTo('view console'); |
160 | 160 | } |
161 | 161 | |
162 | - if ((int) $request->input('viewmovies') === 1 && $this->userdata->can('view movies') && ! $this->userdata->hasDirectPermission('view movies')) { |
|
162 | + if ((int) $request->input('viewmovies') === 1 && $this->userdata->can('view movies') && !$this->userdata->hasDirectPermission('view movies')) { |
|
163 | 163 | $this->userdata->givePermissionTo('view movies'); |
164 | 164 | } elseif ((int) $request->input('viewmovies') === 0 && $this->userdata->can('view movies') && $this->userdata->hasDirectPermission('view movies')) { |
165 | 165 | $this->userdata->revokePermissionTo('view movies'); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $this->userdata->revokePermissionTo('view movies'); |
168 | 168 | } |
169 | 169 | |
170 | - if ((int) $request->input('viewaudio') === 1 && $this->userdata->can('view audio') && ! $this->userdata->hasDirectPermission('view audio')) { |
|
170 | + if ((int) $request->input('viewaudio') === 1 && $this->userdata->can('view audio') && !$this->userdata->hasDirectPermission('view audio')) { |
|
171 | 171 | $this->userdata->givePermissionTo('view audio'); |
172 | 172 | } elseif ((int) $request->input('viewaudio') === 0 && $this->userdata->can('view audio') && $this->userdata->hasDirectPermission('view audio')) { |
173 | 173 | $this->userdata->revokePermissionTo('view audio'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $this->userdata->revokePermissionTo('view audio'); |
176 | 176 | } |
177 | 177 | |
178 | - if ((int) $request->input('viewpc') === 1 && $this->userdata->can('view pc') && ! $this->userdata->hasDirectPermission('view pc')) { |
|
178 | + if ((int) $request->input('viewpc') === 1 && $this->userdata->can('view pc') && !$this->userdata->hasDirectPermission('view pc')) { |
|
179 | 179 | $this->userdata->givePermissionTo('view pc'); |
180 | 180 | } elseif ((int) $request->input('viewpc') === 0 && $this->userdata->can('view pc') && $this->userdata->hasDirectPermission('view pc')) { |
181 | 181 | $this->userdata->revokePermissionTo('view pc'); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $this->userdata->revokePermissionTo('view pc'); |
184 | 184 | } |
185 | 185 | |
186 | - if ((int) $request->input('viewtv') === 1 && $this->userdata->can('view tv') && ! $this->userdata->hasDirectPermission('view tv')) { |
|
186 | + if ((int) $request->input('viewtv') === 1 && $this->userdata->can('view tv') && !$this->userdata->hasDirectPermission('view tv')) { |
|
187 | 187 | $this->userdata->givePermissionTo('view tv'); |
188 | 188 | } elseif ((int) $request->input('viewtv') === 0 && $this->userdata->can('view tv') && $this->userdata->hasDirectPermission('view tv')) { |
189 | 189 | $this->userdata->revokePermissionTo('view tv'); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $this->userdata->revokePermissionTo('view tv'); |
192 | 192 | } |
193 | 193 | |
194 | - if ((int) $request->input('viewadult') === 1 && $this->userdata->can('view adult') && ! $this->userdata->hasDirectPermission('view adult')) { |
|
194 | + if ((int) $request->input('viewadult') === 1 && $this->userdata->can('view adult') && !$this->userdata->hasDirectPermission('view adult')) { |
|
195 | 195 | $this->userdata->givePermissionTo('view adult'); |
196 | 196 | } elseif ((int) $request->input('viewadult') === 0 && $this->userdata->can('view adult') && $this->userdata->hasDirectPermission('view adult')) { |
197 | 197 | $this->userdata->revokePermissionTo('view adult'); |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $this->userdata->revokePermissionTo('view adult'); |
200 | 200 | } |
201 | 201 | |
202 | - if ((int) $request->input('viewbooks') === 1 && $this->userdata->can('view books') && ! $this->userdata->hasDirectPermission('view books')) { |
|
202 | + if ((int) $request->input('viewbooks') === 1 && $this->userdata->can('view books') && !$this->userdata->hasDirectPermission('view books')) { |
|
203 | 203 | $this->userdata->givePermissionTo('view books'); |
204 | 204 | } elseif ((int) $request->input('viewbooks') === 0 && $this->userdata->can('view books') && $this->userdata->hasDirectPermission('view books')) { |
205 | 205 | $this->userdata->revokePermissionTo('view books'); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $this->userdata->revokePermissionTo('view books'); |
208 | 208 | } |
209 | 209 | |
210 | - if ((int) $request->input('viewother') === 1 && $this->userdata->can('view other') && ! $this->userdata->hasDirectPermission('view other')) { |
|
210 | + if ((int) $request->input('viewother') === 1 && $this->userdata->can('view other') && !$this->userdata->hasDirectPermission('view other')) { |
|
211 | 211 | $this->userdata->givePermissionTo('view other'); |
212 | 212 | } elseif ((int) $request->input('viewother') === 0 && $this->userdata->can('view other') && $this->userdata->hasDirectPermission('view other')) { |
213 | 213 | $this->userdata->revokePermissionTo('view other'); |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | $this->userdata->revokePermissionTo('view other'); |
216 | 216 | } |
217 | 217 | |
218 | - if ($request->has('password') && ! empty($request->input('password'))) { |
|
218 | + if ($request->has('password') && !empty($request->input('password'))) { |
|
219 | 219 | User::updatePassword($userid, $request->input('password')); |
220 | 220 | } |
221 | 221 | |
222 | - if (! $this->userdata->hasRole('Admin')) { |
|
223 | - if (! empty($request->input('email')) && $this->userdata->email !== $request->input('email')) { |
|
222 | + if (!$this->userdata->hasRole('Admin')) { |
|
223 | + if (!empty($request->input('email')) && $this->userdata->email !== $request->input('email')) { |
|
224 | 224 | $this->userdata->email = $request->input('email'); |
225 | 225 | |
226 | 226 | $verify_user = $this->userdata; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $this->setPreferences(); |
270 | 270 | $userId = $request->input('id'); |
271 | 271 | |
272 | - if ($userId !== null && (int) $userId === $this->userdata->id && ! $this->userdata->hasRole('Admin')) { |
|
272 | + if ($userId !== null && (int) $userId === $this->userdata->id && !$this->userdata->hasRole('Admin')) { |
|
273 | 273 | $user = User::find($userId); |
274 | 274 | SendAccountDeletedEmail::dispatch($user); |
275 | 275 | Auth::logout(); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | { |
255 | 255 | $res = self::query()->where('email', '<>', '[email protected]'); |
256 | 256 | |
257 | - if (! empty($role)) { |
|
257 | + if (!empty($role)) { |
|
258 | 258 | $res->where('roles_id', $role); |
259 | 259 | } |
260 | 260 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | 'rate_limit' => $rateLimit ? $rateLimit['rate_limit'] : 60, |
296 | 296 | ]; |
297 | 297 | |
298 | - if (! empty($email)) { |
|
298 | + if (!empty($email)) { |
|
299 | 299 | $email = trim($email); |
300 | 300 | $sql += ['email' => $email]; |
301 | 301 | } |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | { |
345 | 345 | $user = self::find($uid); |
346 | 346 | $currRoleExp = $user->rolechangedate ?? now()->toDateTimeString(); |
347 | - if (! empty($date)) { |
|
347 | + if (!empty($date)) { |
|
348 | 348 | $user->update(['rolechangedate' => $date]); |
349 | 349 | } |
350 | - if (empty($date) && ! empty($addYear)) { |
|
350 | + if (empty($date) && !empty($addYear)) { |
|
351 | 351 | $user->update(['rolechangedate' => Carbon::createFromDate($currRoleExp)->addYears($addYear)]); |
352 | 352 | } |
353 | 353 | } |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | return self::fromQuery( |
405 | 405 | sprintf( |
406 | 406 | $query, |
407 | - ! empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
408 | - ! empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
409 | - ! empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
410 | - (! empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
407 | + !empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
408 | + !empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
409 | + !empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
410 | + (!empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
411 | 411 | $order[0], |
412 | 412 | $order[1], |
413 | 413 | ($start === false ? '' : ('LIMIT '.$offset.' OFFSET '.$start)) |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | |
520 | 520 | public static function isValidUrl($url): bool |
521 | 521 | { |
522 | - return (! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
522 | + return (!preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
523 | 523 | } |
524 | 524 | |
525 | 525 | /** |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | // Make sure this is the last check, as if a further validation check failed, the invite would still have been used up. |
557 | 557 | $invitedBy = 0; |
558 | - if (! $forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
558 | + if (!$forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
559 | 559 | if ($inviteCode === '') { |
560 | 560 | return self::ERR_SIGNUP_BADINVITECODE; |
561 | 561 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | public static function checkAndUseInvite(string $inviteCode): int |
576 | 576 | { |
577 | 577 | $invite = Invitation::getInvite($inviteCode); |
578 | - if (! $invite) { |
|
578 | + if (!$invite) { |
|
579 | 579 | return -1; |
580 | 580 | } |
581 | 581 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | public static function add(string $userName, string $password, string $email, int $role, ?string $notes = '', string $host = '', int $invites = Invitation::DEFAULT_INVITES, int $invitedBy = 0) |
592 | 592 | { |
593 | 593 | $password = self::hashPassword($password); |
594 | - if (! $password) { |
|
594 | + if (!$password) { |
|
595 | 595 | return false; |
596 | 596 | } |
597 | 597 | |
@@ -633,9 +633,9 @@ discard block |
||
633 | 633 | |
634 | 634 | $cats = ['view console', 'view movies', 'view audio', 'view tv', 'view pc', 'view adult', 'view books', 'view other']; |
635 | 635 | |
636 | - if (! empty($allowed)) { |
|
636 | + if (!empty($allowed)) { |
|
637 | 637 | foreach ($cats as $cat) { |
638 | - if (! \in_array($cat, $allowed, false)) { |
|
638 | + if (!\in_array($cat, $allowed, false)) { |
|
639 | 639 | $ret[] = match ($cat) { |
640 | 640 | 'view console' => 1000, |
641 | 641 | 'view movies' => 2000, |