77use Illuminate\Support\Facades\ File ;
88use Database\Seeders\ ButtonSeeder ;
99use App\Models\ Page ;
10+ use App\Models\ Link ;
1011
1112set_time_limit (0 );
1213
429430 session ([' update_error' => $e -> getMessage ()]);
430431}
431432
432- ? >
433+ try {
434+
435+ $links = Link:: where (' button_id' , 94 )-> get ()-> groupBy (' user_id' );
436+
437+ foreach ($links as $userId => $userLinks ) {
438+ $hasXTwitter = $userLinks -> contains (' title' , ' x-twitter' );
439+
440+ foreach ($userLinks as $link ) {
441+ if ($link -> title == ' twitter' ) {
442+ if ($hasXTwitter ) {
443+ $link -> delete ();
444+ } else {
445+ $link -> title = ' x-twitter' ;
446+ $link -> save ();
447+ $hasXTwitter = true ;
448+ }
449+ }
450+ }
451+ }
452+
453+ } catch (exception $e ) {
454+ session ([' update_error' => $e -> getMessage ()]);
455+ }
456+
457+ try {
458+
459+ $themesPath = base_path (' themes' );
460+ $regex = '/ [0-9.-] /' ;
461+ $files = scandir ($themesPath );
462+ $files = array_diff ($files , array (' .' , ' ..' ));
463+
464+ $themeError = ' The update was successful. Your theme-filesystem was detected as corrupted and has been reset.' ;
465+
466+ foreach ($files as $file ) {
467+
468+ $basename = basename ($file );
469+ $filePath = $themesPath . ' /' . $basename ;
470+
471+ if (! is_dir ($filePath )) {
472+
473+ File:: deleteDirectory ($themesPath );
474+ mkdir ($themesPath );
475+ session ([' update_error' => $themeError ]);
476+ break ;
477+
478+ }
479+
480+ if (preg_match ($regex , $basename )) {
481+
482+ $newBasename = preg_replace ($regex , ' ' , $basename );
483+ $newPath = $themesPath . ' /' . $newBasename ;
484+ File:: copyDirectory ($filePath , $newPath );
485+ File:: deleteDirectory ($filePath );
486+
487+ }
488+
489+ }
490+
491+ } catch (exception $e ) {
492+ session ([' update_error' => $e -> getMessage ()]);
493+ }
494+
495+ ? >
0 commit comments