This commit is contained in:
salam committed 2026-10-04 15:25:03 +02:00
1 parent 9bcd4432c6
commit 6f92f9e1d5
1209 files changed
+220940

No files matched your search

@@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
class ActiveHandicap
{
public static function set(&$_spreads)
{
$tmp = 10000;
$hcap = false;
foreach ($_spreads as $key => $value) {
$x = 0;
foreach ($value as $k => $v) {
if ($x == 0) {
$x = $v;
} else {
$x -= $v;
}
}
$x = abs($x);
if ($x < $tmp) {
$hcap = $key;
$tmp = $x;
}
}
foreach ($_spreads as $key => $value) {
if ($key == $hcap) {
$_spreads[$key]['active_spread'] = 1;
} else {
$_spreads[$key]['active_spread'] = 0;
}
}
}
}
@@ -0,0 +1,75 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
class Authentication
{
public static function authenticate()
{
$debug = Nuh::$options['d'] ?? 0;
$url = Nuh::$options['base_url'].'/v1/authentication/token';
if (config('env.app_env') == 'local') {
/*************************************************
* PROXY
*************************************************/
if ($debug) {
Notice::note('AUTH with PROXY'.PHP_EOL.$url, 'p');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prox1.nuhodds.com/proxy_logi_auth.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' => config('env.logifuture_token')]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
]);
} else {
/*************************************************
* DIRECT
*************************************************/
if ($debug) {
Notice::note('AUTH direct'.PHP_EOL.$url, 'b');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'username' => 'nuhodds',
'password' => config('env.logifuture_token'),
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'content-type: application/json',
]);
}
$file = curl_exec($ch);
$data = json_decode($file, true);
$header = [];
$header[] = 'Authorization: Bearer '.$data['token'];
$header[] = 'accept: application/json';
$header[] = 'content-type: application/json';
Logifuture::$auth_header = $header;
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
class FilterHandicap
{
public static function filter(&$_spreads, $filter, $data, $oddnames)
{
foreach ($data as $key => $value) {
$key = str_replace($filter, '', $key);
if (strpos($key, '_O') !== false) {
$hcap = str_replace('_O', '', $key);
$_spreads[$hcap]['ele1'] = $value;
} elseif (strpos($key, '_1H') !== false) {
$hcap = str_replace('_1H', '', $key);
$_spreads[$hcap]['ele1'] = $value;
} elseif (strpos($key, '_1') !== false) {
$hcap = str_replace('_1', '', $key);
$_spreads[$hcap]['ele1'] = $value;
} elseif (strpos($key, '_U') !== false) {
$hcap = str_replace('_U', '', $key);
$_spreads[$hcap]['ele2'] = $value;
} elseif (strpos($key, '_2H') !== false) {
$hcap = str_replace('_2H', '', $key);
$_spreads[$hcap]['ele2'] = $value;
} elseif (strpos($key, '_2') !== false) {
$hcap = str_replace('_2', '', $key);
$_spreads[$hcap]['ele2'] = $value;
}
}
}
}
@@ -0,0 +1,91 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Grapper\Logifuture;
use App\Console\Commands\Nuh;
use App\Utilities\Notice;
class LogifutureData
{
public static $testfiles = '/Console/Commands/TestFiles/';
public static function load($logifuture_sport_id)
{
$debug = Nuh::$options['d'] ?? 0;
$save = Nuh::$options['s'] ?? 0;
$read = Nuh::$options['r'] ?? 0;
$filename = app_path().self::$testfiles.str_replace(' ', '_', strtolower(Nuh::$options['sport'].'_'.Nuh::$options['provider'])).'.json';
if ($read) {
if ($debug) {
Notice::note('data read localy', 'g');
}
$file = file_get_contents($filename);
return json_decode($file, true);
}
$url = Nuh::$options['base_url'].'/v1/matches?sportId='.$logifuture_sport_id;
if (config('env.app_env') == 'local') {
/*************************************************
* PROXY
*************************************************/
if ($debug) {
Notice::note('DATA with PROXY'.PHP_EOL.$url, 'p');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prox1.nuhodds.com/proxy_logi_data.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,
'header' => json_encode(Logifuture::$auth_header),
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Proxy-Auth: AIkcoRnipSgMK88WMQhOQQN3LKDrNDCIebNfPnEayJdmDeTigx',
]);
} else {
/*************************************************
* DIRECT
*************************************************/
if ($debug) {
Notice::note('DATA direct'.PHP_EOL.$url, 'b');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, Logifuture::$auth_header);
}
$file = curl_exec($ch);
if ($save) {
file_put_contents($filename, $file);
Notice::note('file saved localy', 'g');
}
if (curl_errno($ch)) {
echo curl_error($ch);
}
return json_decode($file, true);
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsPoint;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class LogifutureStorePoints
{
public static function store(&$_spreads, $base)
{
ActiveHandicap::set($_spreads);
foreach ($_spreads as $handicap => $value) {
// code...
$odds = [];
$odds['home'] = $value['ele1'];
$odds['away'] = $value['ele2'];
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['active_spread'] = $value['active_spread'];
$odds['handicap'] = $handicap;
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds['flags'] = 1;
$odds = array_merge($odds, $base);
$res = OddsPoint::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPoint::create($odds);
} else {
$res->home = number_format($odds['home'], 2);
$res->away = number_format($odds['away'], 2);
$res->handicap = number_format($odds['handicap'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsPointQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class LogifutureStorePointsQ1
{
public static function store(&$_spreads, $base)
{
ActiveHandicap::set($_spreads);
foreach ($_spreads as $handicap => $value) {
// code...
$odds = [];
$odds['home'] = $value['ele1'];
$odds['away'] = $value['ele2'];
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['active_spread'] = $value['active_spread'];
$odds['handicap'] = $handicap;
$odds['flags'] = 1;
$odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']);
$odds = array_merge($odds, $base);
$res = OddsPointQ1::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('handicap', $odds['handicap'])
->first();
if (! $res) {
OddsPointQ1::create($odds);
} else {
$res->home = number_format($odds['home'], 2);
$res->away = number_format($odds['away'], 2);
$res->handicap = number_format($odds['handicap'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsTotal;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class LogifutureStoreTotals
{
public static function store(&$_spreads, $base)
{
ActiveHandicap::set($_spreads);
foreach ($_spreads as $total => $value) {
// code...
$odds = [];
$odds['over'] = $value['ele1'];
$odds['under'] = $value['ele2'];
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['active_spread'] = $value['active_spread'];
$odds['flags'] = 1;
$odds['total'] = $total;
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds = array_merge($odds, $base);
$res = OddsTotal::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotal::create($odds);
} else {
$res->over = number_format($odds['over'], 2);
$res->under = number_format($odds['under'], 2);
$res->total = number_format($odds['total'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsTotalQ1;
use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class LogifutureStoreTotalsQ1
{
public static function store(&$_spreads, $base)
{
ActiveHandicap::set($_spreads);
foreach ($_spreads as $total => $value) {
// code...
$odds = [];
$odds['over'] = $value['ele1'];
$odds['under'] = $value['ele2'];
$odds['margin'] = (float) Margin::calculate($odds, 1);
$odds['active_spread'] = $value['active_spread'];
$odds['flags'] = 1;
$odds['total'] = $total;
$odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']);
$odds = array_merge($odds, $base);
$res = OddsTotalQ1::where('event_id', $base['event_id'])
->where('bookmaker_id', $base['bookmaker_id'])
->where('total', $odds['total'])
->first();
if (! $res) {
OddsTotalQ1::create($odds);
} else {
$res->over = number_format($odds['over'], 2);
$res->under = number_format($odds['under'], 2);
$res->total = number_format($odds['total'], 2);
$res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference'];
$res->flags = 1;
$res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
$res->save();
}, 5);
}
}
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Console\Commands\Nuh;
use Illuminate\Support\Carbon;
class MapEvent
{
public static function filter($sport_id, $match)
{
$event = [];
$event['event_id'] = (int) $match['id'];
$event['bookmaker_id'] = Nuh::$options['bookmaker_id'];
$event['betradar_id'] = (int) preg_replace('"\D"', '', $match['externalId']);
$event['sport_id'] = $sport_id;
$event['provider_id'] = Nuh::$options['provider_id'];
$event['starttime'] = Carbon::parse($match['startDate'])->toDateTimeString();
$event['country'] = $match['sportCategory'];
$event['group_id'] = (int) $match['tournamentId'];
$event['group'] = addslashes($match['tournamentName']);
$str = str_replace('||', '|', $match['description']);
$str = trim(str_replace('|', ' ', $str));
if (Nuh::$options['bookmaker_id'] == 36) {
$teams = explode(' v ', $str);
} else {
$teams = explode(' - ', $str);
}
$event['home'] = addslashes($teams[0]);
$event['away'] = addslashes($teams[1]);
return $event;
}
}