diff --git a/app/Console/Commands/Grapper/Sofascore.php b/app/Console/Commands/Grapper/Sofascore.php index bfa0f022..3712dd33 100644 --- a/app/Console/Commands/Grapper/Sofascore.php +++ b/app/Console/Commands/Grapper/Sofascore.php @@ -4,14 +4,16 @@ namespace App\Console\Commands\Grapper; use App\Console\Commands\Grapper\Sofascore\Grapper; use App\Console\Commands\Grapper\Sofascore\Helper\Strings; +use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder; use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason; use App\Console\Commands\Grapper\Sofascore\Rose; use App\Console\Commands\Grapper\Sofascore\SendMail; use App\Console\Commands\Grapper\Sofascore\SettingsToLocal; +use App\Console\Commands\Grapper\Sofascore\SqlMover; use App\Console\Commands\Nuh; use App\Models\SofaScoreTask; use App\Utilities\Notice; -use App\Utilities\ZipFolder; +use Illuminate\Support\Carbon; ini_set('magic_quotes_runtime', false); @@ -19,6 +21,10 @@ class Sofascore { public static string $storage; + public static string $archive_name; + + public static string $useragent; + public static function switch() { $function = Nuh::$options['fun']; @@ -35,23 +41,32 @@ class Sofascore case 3: self::setStorage(); + Grapper::load(); break; case 4: self::setStorage(); - ZipFolder::create(self::$storage); + + ZipFolder::create(); break; case 5: self::setStorage(); + SendMail::run(); break; case 6: + self::setStorage(); + Rose::run(); break; + case 7: + SqlMover::run(); + break; + default: Notice::note('id not valid', 'br', 1); } @@ -61,6 +76,29 @@ class Sofascore { $task = Nuh::$options['task']; - self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name')); + self::$storage = storage_path('sofascore_data') . '/'; + self::$useragent = 4; + + $storage_name = Strings::clean(SofaScoreTask::where('id', $task)->value('name')) . '/'; + + switch ($task) { + case 1: + self::$archive_name = Carbon::now()->subDays(3)->format('Y-m-d') . '.zip'; + self::$storage .= $storage_name; + break; + case 2: + case 3: + self::$archive_name = $storage_name . '.zip'; + self::$storage .= $storage_name; + break; + case 4: + self::$archive_name = 'rosa-' . Carbon::now()->format('Y-m-d') . '.zip'; + self::$storage .= $storage_name . 'rosa-' . Carbon::now()->format('Y-m-d'); + break; + + default: + self::$archive_name = 'archive.zip'; + break; + } } } diff --git a/app/Console/Commands/Grapper/Sofascore/Grapper.php b/app/Console/Commands/Grapper/Sofascore/Grapper.php index 18189115..ce752f98 100644 --- a/app/Console/Commands/Grapper/Sofascore/Grapper.php +++ b/app/Console/Commands/Grapper/Sofascore/Grapper.php @@ -21,7 +21,7 @@ class Grapper { $debug = Nuh::$options['d'] ?? 0; - $force = Nuh::$options['f'] ?? 0; + $force = Nuh::$options['ff'] ?? 0; $task_id = Nuh::$options['task'] ?? 0; @@ -29,26 +29,34 @@ class Grapper $days = LoadDays::load(); + $count = 0; + $active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get(); + /** + * daily restart always + */ + if ($task_id == 1) SofaScoreEventGrapped::where('grapper_id', $task_id)->delete(); /** * empty grapping folder * empty mailing text */ if ($restart) { - File::cleanDirectory(Sofascore::$storage); - SofaScoreEventGrapped::where('grapper_id', $task_id)->delete(); + foreach ($days as $d) { + SofaScoreTaskDay::where('grapper_id', (int) $task_id) + ->where('day', $d['day']) + ->update(['done' => 0]); + } + if ($debug) { - Notice::note('Restart grapper', 'br'); - Notice::note('Cleand task directory', 'b'); - Notice::note('Flush table SofaScoreEventGrapped for task', 'b'); + Notice::note('reset grapper', 'br', 1); } } else { if ($debug) { - Notice::note('Continuing grapper', 'bg'); + Notice::note('continuing grapper', 'bg'); } } @@ -61,7 +69,7 @@ class Grapper $day = $d['day']; if ($debug) { - Notice::note('Start ' . $tournament->tournament->name, 'b'); + Notice::note('START ' . $tournament->tournament->name, 'p'); } $res = SofaScoreDayTournament::whereDate('day', '=', $day)->where('tournament_id', $tournament->sofa_score_tournament_id)->first(); @@ -86,6 +94,8 @@ class Grapper foreach ($data['events'] as $event) { + Sofascore::$useragent = rand(1, 6); + if (!$force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) { if ($debug) { Notice::note('Grapped ' . $day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'g'); @@ -114,7 +124,7 @@ class Grapper $grapped->url = $url; $grapped->starttime = $starttime->toDateTimeString(); - $folder = Sofascore::$storage . '/' . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug']; + $folder = Sofascore::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['slug'] . '/' . $event['slug']; File::makeDirectory($folder, 0775, true, true); @@ -219,7 +229,14 @@ class Grapper 'done' => 1, ]); - Notice::note('DAY DONE', 'br', 1); + $count++; + + Notice::note($count . ' DAYS DONE', 'bb'); + + // if ($count > 20) + // Notice::note($count . ' DAYS DONE', 'br', 1); + // else + // Notice::note($count . ' DAYS DONE', 'bb'); } } } diff --git a/app/Console/Commands/Grapper/Sofascore/Helper/CurlSofa.php b/app/Console/Commands/Grapper/Sofascore/Helper/CurlSofa.php index 5fc60402..f5f3cf25 100644 --- a/app/Console/Commands/Grapper/Sofascore/Helper/CurlSofa.php +++ b/app/Console/Commands/Grapper/Sofascore/Helper/CurlSofa.php @@ -2,6 +2,7 @@ namespace App\Console\Commands\Grapper\Sofascore\Helper; +use App\Console\Commands\Grapper\Sofascore; use App\Utilities\Notice; use App\Console\Commands\Nuh; @@ -10,7 +11,7 @@ class CurlSofa { public static $testfile = '/Console/Commands/Grapper/Sofascore/test/'; - + public static function load(string $url) { $debug = Nuh::$options['d'] ?? 0; @@ -32,8 +33,20 @@ class CurlSofa return json_decode($data, true); } + $useragents = []; + $useragents[1] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15'; + $useragents[2] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15'; + $useragents[3] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'; + $useragents[4] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15'; + $useragents[5] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0'; + $useragents[6] = 'Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36'; + + // if ($debug) { + // Notice::note($useragents[Sofascore::$useragent], 'b'); + // } + $headers = [ - 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0', + 'User-Agent: ' . $useragents[Sofascore::$useragent], 'Accept: */*', 'Accept-Language: de,en-US;q=0.7,en;q=0.3', 'Accept-Encoding: gzip, deflate, br, zstd', diff --git a/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php b/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php index cc42244e..680da4b4 100644 --- a/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php +++ b/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php @@ -94,7 +94,7 @@ class LoadDays } if (! $dates) { - Notice::note(__FILE__ . PHP_EOL . 'no dates', 'r', 1); + Notice::note('NO DATES OR ALL GRAPPED', 'br', 1); } // remove when element in array is double (day and slug) diff --git a/app/Utilities/ZipFolder.php b/app/Console/Commands/Grapper/Sofascore/Helper/ZipFolder.php similarity index 79% rename from app/Utilities/ZipFolder.php rename to app/Console/Commands/Grapper/Sofascore/Helper/ZipFolder.php index cebb40db..5852da0e 100644 --- a/app/Utilities/ZipFolder.php +++ b/app/Console/Commands/Grapper/Sofascore/Helper/ZipFolder.php @@ -1,30 +1,31 @@ open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) { - if (is_dir($path)) { + if (is_dir(Sofascore::$storage)) { - $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); + $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Sofascore::$storage)); foreach ($files as $file) { if (!$file->isDir()) { $filePath = $file->getRealPath(); - $relativePath = substr($filePath, strlen($path) + 1); + $relativePath = substr($filePath, strlen(Sofascore::$storage) + 1); $zip->addFile($filePath, $relativePath); } } diff --git a/app/Console/Commands/Grapper/Sofascore/Rose.php b/app/Console/Commands/Grapper/Sofascore/Rose.php index 05616523..09d99007 100644 --- a/app/Console/Commands/Grapper/Sofascore/Rose.php +++ b/app/Console/Commands/Grapper/Sofascore/Rose.php @@ -4,31 +4,56 @@ namespace App\Console\Commands\Grapper\Sofascore; use App\Console\Commands\Grapper\Sofascore; use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa; -use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays; use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper; +use App\Console\Commands\Grapper\Sofascore\Helper\Strings; use App\Console\Commands\Nuh; -use App\Models\SofaScoreDayTournament; -use App\Models\SofaScoreEventGrapped; -use App\Models\SofaScoreTaskDay; -use App\Models\SofaScoreTaskTournament; -use App\Models\SofaScoreTournament; +use App\Models\SofaScoreRosa; use App\Utilities\Notice; -use Illuminate\Support\Carbon; +use Carbon\Carbon; use Illuminate\Support\Facades\File; class Rose { public static function run() { + File::makeDirectory(Sofascore::$storage, 0775, true, true); $debug = Nuh::$options['d'] ?? 0; - $task_id = Nuh::$options['task'] ?? 0; + $restart = Nuh::$options['restart'] ?? 0; - $url = Nuh::$options['base_url'] . "api/v1/team/4937/players"; + if ($restart) { + SofaScoreRosa::query()->update(['grapped' => 0]); + if ($debug) { + Notice::note('Restart rosa grapper', 'b'); + } + } else { + if ($debug) { + Notice::note('continuing grapping', 'bg'); + } + } - $data = CurlSofa::load($url); + $res = SofaScoreRosa::where('id', '>', 441)->get(); - dd($data); + foreach ($res as $value) { + + $url = Nuh::$options['base_url'] . 'api/v1/team/' . $value->ssteam_id . '/players'; + + $data = CurlSofa::load($url); + + /********************************* + * add team to folder + *********************************/ + + File::put(Sofascore::$storage . '/' . Strings::clean($value->ssteam_name) . '.json', json_encode($data)); + + SofaScoreRosa::where('id', $value->id)->update(['grapped' => 1]); + + + if (rand(0, 1)) + Sleeper::rand(1); + else + Sleeper::rand(0); + } } } diff --git a/app/Console/Commands/Grapper/Sofascore/SendMail.php b/app/Console/Commands/Grapper/Sofascore/SendMail.php index c8480300..a97b88fb 100644 --- a/app/Console/Commands/Grapper/Sofascore/SendMail.php +++ b/app/Console/Commands/Grapper/Sofascore/SendMail.php @@ -2,14 +2,15 @@ namespace App\Console\Commands\Grapper\Sofascore; -use App\Console\Commands\Grapper\Sofascore; -use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays; use App\Console\Commands\Nuh; use App\Mail\SofaScoreDataMail; use App\Models\SofaScoreEventGrapped; use App\Utilities\Notice; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Mail; +use App\Console\Commands\Grapper\Sofascore; +use App\Models\SofaScoreTask; +use Carbon\Carbon; class SendMail { @@ -17,26 +18,29 @@ class SendMail { $debug = Nuh::$options['d'] ?? 0; - $days = LoadDays::load(); + $task_id = Nuh::$options['task'] ?? 0; - foreach ($days as $d) { + $task = SofaScoreTask::where('id', $task_id)->first(); - $day = $d['day']; + $zip_file = Sofascore::$storage . Sofascore::$archive_name; - $message = self::createMailText($day); + $header = self::createHeader($task); - $zip_file = Sofascore::$storage . '/' . $day . '.zip'; + $message = self::createMessage($task); - if (File::exists($zip_file)) { + if (File::exists($zip_file)) { - Mail::to('hermann.telser@gmail.com') - ->cc('ubaldo.perrucci@gmail.com') - ->send( - new SofaScoreDataMail($day, $message, $zip_file) - ); - if ($debug) { - Notice::note('Mail send' . $day); - } + Mail::to('hermann.telser@gmail.com') + // ->cc('ubaldo.perrucci@gmail.com') + ->send( + new SofaScoreDataMail($header, $message) + ); + if ($debug) { + Notice::note('Mail: ' . $header); + } + } else { + if ($debug) { + Notice::note('zip not found ' . $zip_file, 'r', 1); } } @@ -45,15 +49,41 @@ class SendMail } } - public static function createMailText(string $day) + public static function createMessage(SofaScoreTask $task) { - $res = SofaScoreEventGrapped::where('day', $day)->get(); - $text = "## Mail Content $day - "; + $res = SofaScoreEventGrapped::where('grapper_id', $task->id)->get(); + + $text = ' + + '; + foreach ($res as $value) { - $text .= "### $value->liga * $value->name * $value->starttime - "; + $text .= $value->liga . ' - ' . $value->name . ' - ' . $value->starttime; + $text .= ' + '; } return $text; } + + public static function createHeader(SofaScoreTask $task) + { + $text = "## "; + switch ($task->mode) { + case 'daily': + $text = $task->name . ' - ' . Carbon::now()->subDays(3)->format('Y-m-d'); + break; + case 'date': + $text = $task->name . ' - ' . $task->day_from; + break; + case 'range': + $text = $task->name . ' - ' . $task->day_from . ' - ' . $task->day_to; + break; + + default: + $text = $task->name; + break; + } + + return $text; + } } diff --git a/app/Console/Commands/Grapper/Sofascore/SettingsToLocal.php b/app/Console/Commands/Grapper/Sofascore/SettingsToLocal.php index df48e1d1..930991eb 100644 --- a/app/Console/Commands/Grapper/Sofascore/SettingsToLocal.php +++ b/app/Console/Commands/Grapper/Sofascore/SettingsToLocal.php @@ -19,18 +19,27 @@ class SettingsToLocal Notice::note('Settings To Local', 'bb'); } + if ($debug) { + Notice::note('SofaScoreTask', 'g'); + } SofaScoreTask::truncate(); $rows = DB::connection('remote_mariadb')->table('sofa_score_tasks')->get(); foreach ($rows as $row) { SofaScoreTask::insert((array) $row); } + if ($debug) { + Notice::note('SofaScoreTaskTournament', 'g'); + } SofaScoreTaskTournament::truncate(); $rows = DB::connection('remote_mariadb')->table('sofa_score_task_tournaments')->get(); foreach ($rows as $row) { SofaScoreTaskTournament::insert((array) $row); } + if ($debug) { + Notice::note('SofaScoreRosa', 'g'); + } SofaScoreRosa::truncate(); $rows = DB::connection('remote_mariadb')->table('sofa_score_rosas')->get(); foreach ($rows as $row) { diff --git a/app/Console/Commands/Grapper/Sofascore/SqlMover.php b/app/Console/Commands/Grapper/Sofascore/SqlMover.php index 8cf9e2b9..f5a61aeb 100644 --- a/app/Console/Commands/Grapper/Sofascore/SqlMover.php +++ b/app/Console/Commands/Grapper/Sofascore/SqlMover.php @@ -2,21 +2,27 @@ namespace App\Console\Commands\Grapper\Sofascore; -use App\Models\SofaScoreTaskTournament; -use App\Models\SofaScoreTournament; +use App\Models\StatistikoEvent; use App\Utilities\Notice; class SqlMover { public static function run() { + // $ligas = [649, 242, 20, 40, 325, 41]; + $ligas = [5, 9, 19, 26, 13, 99]; - $res = SofaScoreTaskTournament::get(); + Notice::note('SqlMover', 'b'); - foreach ($res as $value) { - $res2 = SofaScoreTournament::where('tournament_id', $value->sofa_score_tournament_id)->first(); + foreach ($ligas as $liga_id) { - SofaScoreTaskTournament::where('id', $value->id)->update(['sofa_score_category_id' => $res2->sofa_score_category_id]); + $res = StatistikoEvent::where('league_id', $liga_id)->pluck('match_id'); + + dd($res); + + foreach ($res as $match_id) { + dd($match_id); + } } Notice::note('done', 'bb', 1); diff --git a/app/Console/Commands/Grapper/TxOdds/Groups.php b/app/Console/Commands/Grapper/TxOdds/Groups.php index 331e82e7..368424cb 100644 --- a/app/Console/Commands/Grapper/TxOdds/Groups.php +++ b/app/Console/Commands/Grapper/TxOdds/Groups.php @@ -25,7 +25,9 @@ class Groups foreach ($kontos as $konto => $authentication) { - $url = 'https://xml2.txodds.com/feed/groups.php?'.$authentication.'&sid='.implode(',', $years); + $url = 'https://xml2.txodds.com/feed/groups.php?' . $authentication . '&sid=' . implode(',', $years); + + // https://xml2.txodds.com/feed/groups.php?ident=betaid1&passwd=Dy59vpRC&sid=25 // // 181996 diff --git a/app/Console/Commands/Nuh.php b/app/Console/Commands/Nuh.php index 0a5f928c..ab453655 100644 --- a/app/Console/Commands/Nuh.php +++ b/app/Console/Commands/Nuh.php @@ -23,7 +23,7 @@ class Nuh extends Command public static $id = 0; - protected $signature = 'nuh {process=help} {--truncate} {--id=0} {--fun=} {--task=0} {--restart=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}'; + protected $signature = 'nuh {process=help} {--truncate} {--id=0} {--fun=} {--ff} {--task=0} {--restart=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}'; public function handle() { @@ -64,6 +64,7 @@ class Nuh extends Command $txt .= '--d debug' . PHP_EOL; $txt .= '--e echo client data' . PHP_EOL; $txt .= '--f force (what ever in script)' . PHP_EOL; + $txt .= '--ff force grapping (sofascore)' . PHP_EOL; $txt .= '--g by minor groups (tx)' . PHP_EOL; $txt .= '--t load today' . PHP_EOL; $txt .= '--m mail it' . PHP_EOL; diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php index 9e1f4756..c6b2f99c 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreRosas/Tables/SofaScoreRosasTable.php @@ -8,7 +8,6 @@ use Filament\Actions\Action; use Filament\Actions\BulkAction; use Filament\Actions\BulkActionGroup; use Filament\Actions\CreateAction; -use Filament\Actions\DeleteBulkAction; use Filament\Actions\EditAction; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\ToggleColumn; @@ -22,6 +21,7 @@ class SofaScoreRosasTable public static function configure(Table $table): Table { return $table + ->description('The squad for the team selected will be send next day via mail. The selection will be unset after sending.') ->columns([ TextColumn::make('ssteam_id')->label('Id')->badge()->width('1rem'), TextColumn::make('country.name')->label('Country'), diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTasks/RelationManagers/SofaScoreTaskTournamentsRelationManager.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTasks/RelationManagers/SofaScoreTaskTournamentsRelationManager.php index 574107a6..63d12b73 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTasks/RelationManagers/SofaScoreTaskTournamentsRelationManager.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTasks/RelationManagers/SofaScoreTaskTournamentsRelationManager.php @@ -20,6 +20,7 @@ use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\SelectFilter; +use Filament\Tables\Filters\TernaryFilter; use Filament\Tables\Table; use Illuminate\Support\Collection; @@ -71,6 +72,7 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager TextColumn::make('category.name') ->label('Category') ->searchable(), + TextColumn::make('tournament.tournament_id'), TextColumn::make('tournament.name') ->weight(FontWeight::Bold) ->searchable(), @@ -88,7 +90,8 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager ->pluck('sofa_score_category_id') ->toArray(); return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); - }) + }), + TernaryFilter::make('disabled'), ], layout: FiltersLayout::AboveContent) ->deferFilters(false) ->headerActions([ diff --git a/app/Mail/SofaScoreDataMail.php b/app/Mail/SofaScoreDataMail.php index 9d39074c..6e344679 100644 --- a/app/Mail/SofaScoreDataMail.php +++ b/app/Mail/SofaScoreDataMail.php @@ -8,6 +8,7 @@ use Illuminate\Mail\Mailables\Attachment; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Illuminate\Queue\SerializesModels; +use App\Console\Commands\Grapper\Sofascore; class SofaScoreDataMail extends Mailable { @@ -16,11 +17,12 @@ class SofaScoreDataMail extends Mailable /** * Create a new message instance. */ - public function __construct(string $day, string $message, string $zip_file) + public function __construct(string $header, string $message) { - $this->day = $day; + $this->header = $header; $this->message = $message; - $this->zip_file = $zip_file; + $this->archive_name = Sofascore::$archive_name; + $this->zip_file = Sofascore::$storage . Sofascore::$archive_name; } /** @@ -29,7 +31,7 @@ class SofaScoreDataMail extends Mailable public function envelope(): Envelope { return new Envelope( - subject: 'Sofa Score ' . $this->day, + subject: $this->header, ); } @@ -55,7 +57,7 @@ class SofaScoreDataMail extends Mailable { return [ Attachment::fromPath($this->zip_file) - ->as('sofa archive ' . $this->day . '.zip') + ->as($this->archive_name) ->withMime('application/x-zip-compressed') ]; } diff --git a/app/Utilities/Notice.php b/app/Utilities/Notice.php index 87ff7ed7..1cef2842 100644 --- a/app/Utilities/Notice.php +++ b/app/Utilities/Notice.php @@ -4,18 +4,27 @@ namespace App\Utilities; class Notice { - // note + /** + * \e[1;30m Black + * \e[1;31m Red + * \e[1;32m Green + * \e[1;33m Yellow + * \e[1;34m Blue + * \e[1;35m Purple + * \e[1;36m Cyan + * \e[1;37m White + */ public static function db($message, $exit = false) { echo "\e[0;35m"; - echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL; + echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL; if (is_array($message)) { print_r($message); } else { - echo $message.PHP_EOL; + echo $message . PHP_EOL; } - echo '-----------------------------------------------------------'.PHP_EOL; + echo '-----------------------------------------------------------' . PHP_EOL; echo "\e[0;39m"; if ($exit) { exit(); @@ -72,13 +81,13 @@ class Notice break; } - echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL; + echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL; if (is_array($message)) { print_r($message); } else { - echo $message.PHP_EOL; + echo $message . PHP_EOL; } - echo '-----------------------------------------------------------'.PHP_EOL; + echo '-----------------------------------------------------------' . PHP_EOL; echo "\e[0;39m"; if ($exit) { exit(); diff --git a/database/migrations/2026_07_20_150818_create_sofa_score_roses_table.php b/database/migrations/2026_07_20_150818_create_sofa_score_roses_table.php index c64b8723..8acb1804 100644 --- a/database/migrations/2026_07_20_150818_create_sofa_score_roses_table.php +++ b/database/migrations/2026_07_20_150818_create_sofa_score_roses_table.php @@ -17,6 +17,7 @@ return new class extends Migration $table->integer('ssteam_id'); $table->string('ssteam_name'); $table->boolean('is_active')->default(false); + $table->boolean('grapped')->default(false); $table->timestamps(); }); } diff --git a/grapper.sh b/grapper.sh new file mode 100755 index 00000000..cf85de66 --- /dev/null +++ b/grapper.sh @@ -0,0 +1,138 @@ +case "$1" in +"1") + echo "" + echo "\033[1;32m"; + echo "--------------------------" + echo "⚽ Daily Task: 1" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "5 sec to stop" + echo "--------------------------" + sleep 5 + + echo "\n⚽ Grapper" + php artisan nuh --d --f --ff 67 --fun=3 --task=1 + + echo "\n⚽ CreateZip" + php artisan nuh --d --f 67 --fun=4 --task=1 + + echo "\n⚽ SendMail" + php artisan nuh --d --f 67 --fun=5 --task=1 + + echo "\n😎 task done :)" + echo "" +;; +"2") + echo "" + echo "\033[1;34m"; + echo "--------------------------" + echo "⚽ Day: 2" + echo "--------------------------" + echo "\033[0;0m"; + echo "not implemented yet" +;; +"3") + echo "" + echo "\033[1;33m"; + echo "--------------------------" + echo "⚽ Range Task: 3" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "only grapping but the process can be restarted" + echo "To do:" + echo "on ending make Zip" + echo "upload to Cloud" + echo "send Mail to Ubaldo" + echo "--------------------------\n" + + echo "\n--------------------------" + echo "5 sec to stop" + echo "restart with second param: 1" + echo "--------------------------" + sleep 5 + + + echo "\n⚽ Grapper" + php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$2 + + # echo "\n⚽ CreateZip" + # php artisan nuh --d --f 67 --fun=4 --task=3 + + # echo "\n⚽ SendMail" + # php artisan nuh --d --f 67 --fun=5 --task=3 + + echo "\n😎 task done :)" + echo "" +;; +"4") + echo "" + echo "\033[1;35m"; + echo "--------------------------" + echo "⚽ Rosa Task: 4" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "5 sec to stop" + echo "restart with second param: 1" + echo "--------------------------" + sleep 5 + + echo "\n⚽ Rosa" + php artisan nuh --d --f 67 --fun=6 --task=4 --restart=$2 + + echo "\n😎 task done :)" + echo "" +;; +"5") + echo "" + echo "\033[1;36m"; + echo "--------------------------" + echo "⚽ Copy Settings: 5" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "5 sec to stop" + echo "--------------------------" + sleep 5 + + echo "\n⚽ close all vpn" + killall ssh + + echo "\n⚽ open vpn" + ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190 + + echo "\n⚽ Settings To Local" + php artisan nuh --d --f 67 --fun=2 --task=0 + + echo "\n⚽ close vpn" + killall ssh + + echo "\n😎 task done :)" + echo "" +;; +*) + echo "" + echo "\033[1;30m"; + echo "--------------------------" + echo " Grapper Options" + echo "--------------------------" + echo "\033[1;32m"; + echo "⚽ Daily\tTask: 1" + echo "\033[1;34m"; + echo "⚽ Day\t\tTask: 2" + echo "\033[1;33m"; + echo "⚽ Range\tTask: 3" + echo "\033[1;35m"; + echo "⚽ Rosa\t\tTask: 4" + echo "\033[1;36m"; + echo "⚽ Settings\tTask: 5" + echo "\033[0;0m"; + echo "--------------------------" +;; +esac \ No newline at end of file diff --git a/grapper/daily.sh b/grapper/daily.sh new file mode 100755 index 00000000..ddf55f55 --- /dev/null +++ b/grapper/daily.sh @@ -0,0 +1,60 @@ +case "$1" in +"1") + echo "" + echo "\033[1;32m"; + echo "--------------------------" + echo "⚽ Daily Task: 1" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "5 sec to stop" + echo "--------------------------" + sleep 5 + + echo "\n⚽ Grapper" + php artisan nuh --d --f --ff 67 --fun=3 --task=1 + + echo "\n⚽ CreateZip" + php artisan nuh --d --f 67 --fun=4 --task=1 + + echo "\n⚽ SendMail" + php artisan nuh --d --f 67 --fun=5 --task=1 + + echo "\n😎 task done :)" + echo "" + ;; +"2") + echo "" + echo "\033[1;34m"; + echo "--------------------------" + echo "⚽ Range Task: 3" + echo "--------------------------" + echo "\033[0;0m"; + + echo "\n--------------------------" + echo "To do:" + echo "on ending make Zip" + echo "upload to Cloud" + echo "send Mail to Ubaldo" + echo "--------------------------\n" + + echo "\n--------------------------" + echo "5 sec to stop" + echo "restart with: 1" + echo "--------------------------" + sleep 5 + + + echo "\n⚽ Grapper" + # php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$1 + + echo "\n⚽ CreateZip" + # php artisan nuh --d --f 67 --fun=4 --task=3 + + echo "\n⚽ SendMail" + # php artisan nuh --d --f 67 --fun=5 --task=3 + + echo "\n😎 task done :)" + echo "" +;; diff --git a/grapper/grap1.sh b/grapper/grap1.sh deleted file mode 100755 index 5427fea9..00000000 --- a/grapper/grap1.sh +++ /dev/null @@ -1,46 +0,0 @@ -case "$1" in - ''|*[!0-9]*) - echo "" - echo "--------------------------" - echo "GRAPPER SOFASCORE" - echo "--------------------------" - echo "parameter ID" - echo "--task = sofa_score_tasks_id" - echo "--restart = [0|1]" - echo "--------------------------" - echo "--fun = Sofascore.php switch() " - echo "SELECT liga, name, starttime FROM sofa_score_event_grappeds WHERE grapper_id = 1;" - echo "" - exit 1 - ;; - *) - # AUTO GRAPPER SOFASCORE (debug) - - echo "\n⚽ sofa_score_task $1" - - # echo "\n⚽ close all vpn" - # killall ssh - - # echo "\n⚽ open vpn" - # ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190 - - # echo "\n⚽ Settings To Local" - # php artisan nuh --d --f 67 --fun=2 --task=$1 - - # echo "\n⚽ close vpn" - # killall ssh - - echo "\n⚽ Grapper" - php artisan nuh --d --f 67 --fun=3 --task=$1 --restart=$2 - - # echo "\n⚽ CreateZip" - # php artisan nuh --d --f 67 --fun=4 --task=$1 - - # echo "\n⚽ SendMail" - # php artisan nuh --d --f 67 --fun=5 --task=$1 - - echo "\n😎 done :)" - ;; -esac - - diff --git a/grapper/range.sh b/grapper/range.sh new file mode 100755 index 00000000..28852622 --- /dev/null +++ b/grapper/range.sh @@ -0,0 +1,34 @@ +echo "" +echo "\033[1;34m"; +echo "--------------------------" +echo "⚽ Range Task: 3" +echo "--------------------------" +echo "\033[0;0m"; + +echo "\n--------------------------" +echo "To do:" +echo "on ending make Zip" +echo "upload to Cloud" +echo "send Mail to Ubaldo" +echo "--------------------------\n" + +echo "\n--------------------------" +echo "5 sec to stop" +echo "restart with: 1" +echo "--------------------------" +sleep 5 + + +echo "\n⚽ Grapper" +# php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$1 + +echo "\n⚽ CreateZip" +# php artisan nuh --d --f 67 --fun=4 --task=3 + +echo "\n⚽ SendMail" +# php artisan nuh --d --f 67 --fun=5 --task=3 + +echo "\n😎 task done :)" +echo "" + + diff --git a/grapper/rose.sh b/grapper/rose.sh new file mode 100755 index 00000000..d90878aa --- /dev/null +++ b/grapper/rose.sh @@ -0,0 +1,18 @@ +echo "" +echo "\033[1;35m"; +echo "--------------------------" +echo "⚽ Rosa Task: 4" +echo "--------------------------" +echo "\033[0;0m"; + +echo "\n--------------------------" +echo "5 sec to stop" +echo "restart with: 1" +echo "--------------------------" +sleep 5 + +echo "\n⚽ Rosa" +php artisan nuh --d --f 67 --fun=6 --task=4 --restart=$1 + +echo "\n😎 task done :)" +echo "" diff --git a/grapper/setting.sh b/grapper/setting.sh new file mode 100755 index 00000000..20bade35 --- /dev/null +++ b/grapper/setting.sh @@ -0,0 +1,26 @@ +echo "" +echo "\033[1;36m"; +echo "--------------------------" +echo "⚽ Copy settings" +echo "--------------------------" +echo "\033[0;0m"; + +echo "\n--------------------------" +echo "5 sec to stop" +echo "--------------------------" +sleep 5 + +echo "\n⚽ close all vpn" +killall ssh + +echo "\n⚽ open vpn" +ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190 + +echo "\n⚽ Settings To Local" +php artisan nuh --d --f 67 --fun=2 --task=0 + +echo "\n⚽ close vpn" +killall ssh + +echo "\n😎 task done :)" +echo ""