From 2e57e49f08d25660513f9c772bb80cfb50539f12 Mon Sep 17 00:00:00 2001 From: salam Date: Mon, 5 Jan 2026 16:23:14 +0100 Subject: [PATCH] logifuture with proxy wip --- app/Console/Commands/Curl.php | 61 ++++++++++++------- app/Console/Commands/Grapper/Betsapi.php | 4 ++ app/Console/Commands/Grapper/Betsapi/Odds.php | 6 +- .../Commands/Grapper/Betsapi/Willhill.php | 18 +++--- app/Console/Commands/Grapper/Logifuture.php | 39 +++++++++--- .../Commands/Grapper/Logifuture/Auth.php | 41 ++++++------- .../Commands/Grapper/Logifuture/BaseUrl.php | 5 ++ .../Commands/Grapper/Logifuture/Fixtures.php | 2 - .../Commands/Grapper/Magloo/Fixtures.php | 4 +- app/Console/Commands/Grapper/Magloo/Odds.php | 2 +- .../Commands/Grapper/TxOdds/Fixtures.php | 2 - app/Console/Commands/Grapper/TxOdds/Odds.php | 8 +-- composer.json | 2 +- composer.lock | 2 +- database/seeders/ProvoiderSeeder.php | 4 +- setup.sh | 13 ++++ storage/tools/logifuture_proxy.php | 19 ++++++ storage/tools/prox2.php | 20 ++++++ storage/tools/proxydb1.php | 21 +++++++ 19 files changed, 196 insertions(+), 77 deletions(-) create mode 100644 storage/tools/logifuture_proxy.php create mode 100644 storage/tools/prox2.php create mode 100644 storage/tools/proxydb1.php diff --git a/app/Console/Commands/Curl.php b/app/Console/Commands/Curl.php index 5d1068a0..0e56319c 100644 --- a/app/Console/Commands/Curl.php +++ b/app/Console/Commands/Curl.php @@ -16,7 +16,10 @@ class Curl $proxy = Nuh::$options['p'] ?? 0; if ($debug) { - Notice::note($url); + Notice::note($url, 'g'); + if ($proxy) { + Notice::note(Nuh::$options['proxy'], 'r'); + } } if ($read) { @@ -29,22 +32,10 @@ class Curl return json_decode($file, true); } - - // POST - if (isset($_config['post'])) { - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post'])); - } - - // JSON - if (isset($_config['header'])) { - curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']); - } - if ($proxy) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, Nuh::$options['proxy']); - curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); @@ -55,34 +46,60 @@ class Curl 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', ]); } else { - $ch = curl_init($url); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); + // POST + if (isset($_config['post'])) { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($_config['post'])); + } + // JSON + if (isset($_config['header'])) { + curl_setopt($ch, CURLOPT_HTTPHEADER, $_config['header']); + } } - $data = curl_exec($ch); + $file = curl_exec($ch); $curl_errorno = curl_errno($ch); if ($curl_errorno) { Notice::note('curl_errorno: '.self::curlerrorcode($curl_errorno)); } - if (PHP_VERSION_ID < 80000) { - curl_close($ch); - } - if ($save) { $filename = app_path().self::$testfiles.strtolower(str_replace(' ', '_', Nuh::$options['name'])).'.json'; - file_put_contents($filename, $data); + file_put_contents($filename, $file); Notice::note('file saved localy', 'g'); } - return json_decode($data, true); + $data = json_decode($file, true); + + switch (json_last_error()) { + case JSON_ERROR_DEPTH: + echo ' - Maximum stack depth exceeded'; + break; + case JSON_ERROR_STATE_MISMATCH: + echo ' - Underflow or the modes mismatch'; + break; + case JSON_ERROR_CTRL_CHAR: + echo ' - Unexpected control character found'; + break; + case JSON_ERROR_SYNTAX: + echo ' - Syntax error, malformed JSON'; + break; + case JSON_ERROR_UTF8: + echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'; + break; + } + + return $data; } public static function curlerrorcode($id) diff --git a/app/Console/Commands/Grapper/Betsapi.php b/app/Console/Commands/Grapper/Betsapi.php index 23d4c98b..14aa0dc3 100644 --- a/app/Console/Commands/Grapper/Betsapi.php +++ b/app/Console/Commands/Grapper/Betsapi.php @@ -15,6 +15,10 @@ class Betsapi { public static function switch() { + $debug = Nuh::$options['d'] ?? 0; + if ($debug) { + Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['name'], 'b'); + } switch (Nuh::$options['name']) { case 'Fixtures': diff --git a/app/Console/Commands/Grapper/Betsapi/Odds.php b/app/Console/Commands/Grapper/Betsapi/Odds.php index f0930eb0..636dac54 100644 --- a/app/Console/Commands/Grapper/Betsapi/Odds.php +++ b/app/Console/Commands/Grapper/Betsapi/Odds.php @@ -2,13 +2,15 @@ namespace App\Console\Commands\Grapper\Betsapi; +use App\Console\Commands\Nuh; + class Odds { /** * Create a new class instance. */ - public function __construct() + public static function grap() { - // + $debug = Nuh::$options['d'] ?? 0; } } diff --git a/app/Console/Commands/Grapper/Betsapi/Willhill.php b/app/Console/Commands/Grapper/Betsapi/Willhill.php index 55e70464..204046c4 100644 --- a/app/Console/Commands/Grapper/Betsapi/Willhill.php +++ b/app/Console/Commands/Grapper/Betsapi/Willhill.php @@ -31,14 +31,18 @@ class Willhill */ $bookmaker_id = 42; - $res = Odds3way::join('events', 'odds_3ways.event_id', 'events.id') - ->where('odds_3ways.bookmaker_id', $bookmaker_id) - ->where('events.starttime', '>', Carbon::now()) - ->where('events.betsapi_id', 0) - ->where('events.sport_id', $sport_id) - ->where('odds_3ways.bmoid', '>', 0)->pluck('odds_3ways.event_id', 'odds_3ways.bmoid'); + $res = Event::with('odds_3way') + ->where('betsapi_id', 0) + ->where('sport_id', $sport_id) + ->where('starttime', '>', Carbon::now()) + ->pluck('id'); - foreach ($res as $willhill_id => $txodds_id) { + $events = Odds3way::where('bookmaker_id', $bookmaker_id) + ->whereIn('event_id', $res) + ->where('bmoid', '!=', 0) + ->pluck('event_id', 'bmoid'); + + foreach ($events as $willhill_id => $txodds_id) { $url = 'https://api.b365api.com/v1/williamhill/result?token='.config('env.betsapi_token').'&event_id='.$willhill_id; diff --git a/app/Console/Commands/Grapper/Logifuture.php b/app/Console/Commands/Grapper/Logifuture.php index bd2d8082..f8977910 100644 --- a/app/Console/Commands/Grapper/Logifuture.php +++ b/app/Console/Commands/Grapper/Logifuture.php @@ -13,12 +13,9 @@ class Logifuture public static function switch() { $debug = Nuh::$options['d'] ?? 0; - $proxy = Nuh::$options['p'] ?? 0; $sportmap = Sport::map('logi', 1, [1, 2, 3, 5]); - dd($sportmap); - if ($debug) { Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['sport']['name'], 'g'); } @@ -32,18 +29,42 @@ class Logifuture break; } - $base_url = BaseUrl::get(); - - $header = Auth::exe(); + $data = Auth::exe(); foreach ($sportmap as $client_sportid => $sportid) { - $url = $base_url.'/v1/matches?sportId='.$client_sportid; + $post_fields = [ + 'url' => BaseUrl::get().'/v1/matches?sportId='.$client_sportid, + 'header' => json_encode(['Authorization: Bearer '.$data['token'], 'accept: application/json', 'content-type: application/json']), + ]; - $data = Loader::curlLoader($url, ['curl_options' => $header]); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://proxydb1.nuhodds.com/logifuture.php'); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', + ]); + + $file = curl_exec($ch); + + dd($file); + + $data = json_decode($file, true); dd($data); } - } } + +$header = []; +$header[] = 'Authorization: Bearer '.$data['token']; +$header[] = 'accept: application/json'; +$header[] = 'content-type: application/json'; + +return $header; diff --git a/app/Console/Commands/Grapper/Logifuture/Auth.php b/app/Console/Commands/Grapper/Logifuture/Auth.php index 0b03cb1a..5805f291 100644 --- a/app/Console/Commands/Grapper/Logifuture/Auth.php +++ b/app/Console/Commands/Grapper/Logifuture/Auth.php @@ -4,38 +4,33 @@ namespace App\Console\Commands\Grapper\Logifuture; class Auth { - public static $pass = 'nuhodds'; + public static $password; public static function exe() { - $base_url = BaseUrl::get(); + $base_url = BaseUrl::get(); $url = $base_url.'/v1/authentication/token'; - $data = Loader::curlLoader($url, [ - 'header' => [ - 'accept: application/json', - 'content-type: application/json', - ], - 'post' => [ - 'username' => 'nuhodds', - 'password' => self::$pass, - ], + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://proxydb1.nuhodds.com/proxy.php'); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, [ + 'url' => $url, + 'password' => self::$password, + ]); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx', ]); - if (! is_array($data)) { + $file = curl_exec($ch); - Notice::note('no data sleep(60)', 'r'); - sleep(60); + $data = json_decode($file, true); - return false; - } - - $header = $data; - $header[] = 'Authorization: Bearer '.$data['token']; - $header[] = 'accept: application/json'; - $header[] = 'content-type: application/json'; - - return $header; + return $data; } } diff --git a/app/Console/Commands/Grapper/Logifuture/BaseUrl.php b/app/Console/Commands/Grapper/Logifuture/BaseUrl.php index dd7b00d6..c31890fc 100644 --- a/app/Console/Commands/Grapper/Logifuture/BaseUrl.php +++ b/app/Console/Commands/Grapper/Logifuture/BaseUrl.php @@ -3,6 +3,7 @@ namespace App\Console\Commands\Grapper\Logifuture; use App\Console\Commands\Nuh; +use App\Console\Commands\Grapper\Logifuture\Auth; class BaseUrl { @@ -13,17 +14,21 @@ class BaseUrl switch (Nuh::$options['provider_id']) { case 5: if ($test) { + Auth::$password = 'nuhodds'; $base_url = 'https://stg-external-api.bet9ja.com/external'; } else { + Auth::$password = 'uSwIqs!Y3eHrNbyH'; $base_url = 'https://external-api.bet9ja.com/external'; } break; case 6: if ($test) { + Auth::$password = 'nuhodds'; $base_url = 'https://stg-external-api.yajuego.co/external'; } else { $base_url = 'https://external-api.yajuego.co/external'; + Auth::$password = 'uSwIqs!Y3eHrNbyH'; } break; } diff --git a/app/Console/Commands/Grapper/Logifuture/Fixtures.php b/app/Console/Commands/Grapper/Logifuture/Fixtures.php index c5b9f4ab..50af3e7b 100644 --- a/app/Console/Commands/Grapper/Logifuture/Fixtures.php +++ b/app/Console/Commands/Grapper/Logifuture/Fixtures.php @@ -25,8 +25,6 @@ class Fixtures $sportmap = Sport::map('logi', 1, [1, 3]); - dd($sportmap); - self::$elements = LoadElements::load(Nuh::$options['provider_id']); self::$groups = LoadGroups::load(Nuh::$options['provider_id']); diff --git a/app/Console/Commands/Grapper/Magloo/Fixtures.php b/app/Console/Commands/Grapper/Magloo/Fixtures.php index 5f883785..fbf06646 100644 --- a/app/Console/Commands/Grapper/Magloo/Fixtures.php +++ b/app/Console/Commands/Grapper/Magloo/Fixtures.php @@ -34,7 +34,7 @@ class Fixtures } if ($debug) { - Notice::note('FIXTURES '.Nuh::$options['process'], 'b'); + Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['name'], 'g'); } $base_url = BaseUrl::get(); @@ -43,7 +43,9 @@ class Fixtures * Tornaments */ $url = $base_url.'/sport'; + $data = Curl::load($url); + if (! is_array($data) or \count($data) == 0) { Notice::note('no data in feed', 'r', 1); diff --git a/app/Console/Commands/Grapper/Magloo/Odds.php b/app/Console/Commands/Grapper/Magloo/Odds.php index 835410eb..512ac048 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds.php +++ b/app/Console/Commands/Grapper/Magloo/Odds.php @@ -37,7 +37,7 @@ class Odds } if ($debug) { - Notice::note('ODDS '.Nuh::$options['process'], 'b'); + Notice::note(Nuh::$options['provider']['name'].' '.Nuh::$options['name'], 'g'); } switch (Nuh::$options['provider_id']) { diff --git a/app/Console/Commands/Grapper/TxOdds/Fixtures.php b/app/Console/Commands/Grapper/TxOdds/Fixtures.php index 908a82a7..9c43d8f0 100644 --- a/app/Console/Commands/Grapper/TxOdds/Fixtures.php +++ b/app/Console/Commands/Grapper/TxOdds/Fixtures.php @@ -50,8 +50,6 @@ class Fixtures foreach ($data as $row) { - dd($row); - $event = [ 'provider_id' => (int) Nuh::$options['provider_id'], 'starttime' => Carbon::createFromDate((string) $row->time)->toDateTimeString(), diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 5ef49675..822edb77 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -128,10 +128,10 @@ class Odds $_calls[] = $url."&ot=$markets&peid=".$id; } } elseif (Nuh::$options['g']) { - // by groups - $res = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(1)->toDateTimeString())->groupBy('group_id')->pluck('group_id'); - foreach ($res as $id) { - $_calls[] = $url."&ot=$markets&pgid=".$id; + // one week per group names (mybee fastes) + $groupids = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->groupBy('group_id')->pluck('group_id'); + foreach ($groupids as $groupid) { + $_calls[] = $url = 'https://xml2.txodds.com/feed/odds/xml.php?'.Nuh::$AUTHTOKEN.'&all_odds=2&ot='.$markets.'&days=0,7&pgid='.$groupid; } } elseif (Nuh::$options['b']) { // one day diff --git a/composer.json b/composer.json index 35da9a4f..c9109eca 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "fakerphp/faker": "^1.23", "filament/upgrade": "^4.0", "laravel/pail": "^1.2.2", - "laravel/pint": "^1.13", + "laravel/pint": "^1.26", "laravel/sail": "^1.41", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.6", diff --git a/composer.lock b/composer.lock index 95e70337..f8fb3f15 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "79916f11ba10822650ae1a1dc62bbfe3", + "content-hash": "5d42c638156872c2ef5cc1aaf5a1cb3b", "packages": [ { "name": "agencetwogether/hookshelper", diff --git a/database/seeders/ProvoiderSeeder.php b/database/seeders/ProvoiderSeeder.php index 4a9f525b..8c739583 100644 --- a/database/seeders/ProvoiderSeeder.php +++ b/database/seeders/ProvoiderSeeder.php @@ -18,8 +18,8 @@ class ProvoiderSeeder extends Seeder ('2', 'BETSAPI'), ('3', 'MAGLOO KENIA'), ('4', 'MAGLOO NIGERIA'), - ('5', 'LOGIFUTUR NIGERA'), - ('6', 'LOGIFUTUR COLOMBIA'); + ('5', 'LOGIFUTURE NIGERA'), + ('6', 'LOGIFUTURE COLOMBIA'); "; DB::unprepared($sql); diff --git a/setup.sh b/setup.sh index f1bfae04..bc27f982 100755 --- a/setup.sh +++ b/setup.sh @@ -42,6 +42,18 @@ case "$1" in php artisan config:clear php artisan view:clear ;; +"9") + a nuh --d --b 1 + a nuh --d --g 2 + a nuh --d --b 3 + a nuh --d 4 + a nuh --d 5 + a nuh --d --b 6 + a nuh --d --p 8 + a nuh --d --p 9 + a nuh --d --p 10 + a nuh --d --p 11 + ;; *) echo "" echo "--------------------------" @@ -55,6 +67,7 @@ case "$1" in echo "6 => a filament:assets (copy to prod)" echo "7 => a db:seed --force" echo "8 => a cache:clear view:clear" + echo "9 => grap all books all sports for 1 day" echo "--------------------------" echo "" ;; diff --git a/storage/tools/logifuture_proxy.php b/storage/tools/logifuture_proxy.php new file mode 100644 index 00000000..1ec44d47 --- /dev/null +++ b/storage/tools/logifuture_proxy.php @@ -0,0 +1,19 @@ + 'nuhodds', 'password' => $_POST['password']])); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['accept: application/json', 'content-type: application/json']); + + $file = curl_exec($ch); + if (curl_errno($ch)) { + echo curl_error($ch); + } + echo $file; +}