114 lines
3.0 KiB
PHP
114 lines
3.0 KiB
PHP
<?php
|
|
|
|
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\MakeExcel;
|
|
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\Grapper\Sofascore\TournamentTeams;
|
|
use App\Console\Commands\Nuh;
|
|
use App\Models\SofaScoreTask;
|
|
use App\Utilities\Notice;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
ini_set('magic_quotes_runtime', false);
|
|
|
|
class Sofascore
|
|
{
|
|
public static string $storage;
|
|
|
|
public static string $archive_name;
|
|
|
|
public static string $excel_name;
|
|
|
|
public static string $useragent = '4';
|
|
|
|
public static function switch()
|
|
{
|
|
$function = Nuh::$options['fun'];
|
|
|
|
switch ($function) {
|
|
|
|
case 1:
|
|
PlayerPerSeason::run();
|
|
break;
|
|
|
|
case 2:
|
|
SettingsToLocal::run();
|
|
break;
|
|
|
|
case 3:
|
|
self::setStorage();
|
|
Grapper::load();
|
|
break;
|
|
|
|
case 4:
|
|
self::setStorage();
|
|
ZipFolder::create();
|
|
break;
|
|
|
|
case 5:
|
|
self::setStorage();
|
|
SendMail::run();
|
|
break;
|
|
|
|
case 6:
|
|
self::setStorage();
|
|
Rose::run();
|
|
break;
|
|
|
|
case 7:
|
|
SqlMover::run();
|
|
break;
|
|
|
|
case 8:
|
|
self::setStorage();
|
|
MakeExcel::create();
|
|
break;
|
|
|
|
case 9:
|
|
TournamentTeams::get();
|
|
break;
|
|
|
|
default:
|
|
Notice::note('id not valid', 'br', 1);
|
|
}
|
|
}
|
|
|
|
public static function setStorage()
|
|
{
|
|
$task = Nuh::$options['task'];
|
|
|
|
self::$storage = storage_path('sofascore_data') . '/';
|
|
// for grapper to start with
|
|
|
|
$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;
|
|
}
|
|
}
|
|
}
|