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

+15
View File
@@ -0,0 +1,15 @@
<?php
namespace App\Utilities;
class BkmIconMap
{
public static function get($image)
{
if ($image) {
return asset("storage/bookmaker-icons/$image.png");
} else {
return asset('storage/bookmaker-icons/missing.png');
}
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Utilities;
class DatabaseFunctions
{
public static function save_update($query)
{
$max_tries = 5;
$tries = 0;
do {
$retry = false;
$tries++;
try {
$query->save();
return $query;
} catch (\PDOException $exc) {
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
$retry = true;
sleep(1);
} else {
throw $exc;
}
}
} while ($retry);
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Utilities;
class Html
{
public static function table_header_90($_row)
{
$html = '<thead><tr text-rotate="90deg">';
$mm = 190 / \count($_row);
foreach ($_row as $value) {
$html .= '<td class="head right bl bt br bb" style="background-color:#d1d1d1; width: '.$mm.'mm;">'.$value.'</td>';
}
$html .= '</tr></thead>';
return $html;
}
public static function make_table($str)
{
$array = explode('<br />', $str);
$html = '<table class="table-striped bt bl">';
foreach ($array as $value) {
$tmp = explode('|', $value);
$html .= '<tr>';
$html .= self::td($tmp[0], 'br bb');
$html .= self::td($tmp[1], 'br bb');
$html .= '</tr>';
}
$html .= '</table>';
return $html;
}
public static function td($value = '', $classname = '', $colspan = 0)
{
$cls = $classname != '' ? ' class="'.$classname.'"' : '';
$spn = $colspan != '' ? ' colspan="'.$colspan.'"' : '';
return "<td $cls $spn>".$value.'</td>';
}
public static function tag($tag = 'div', $value = '', $class = '', $style = '')
{
$str1 = $class != '' ? ' class="'.$class.'"' : '';
$str2 = $style != '' ? ' style="'.$style.'"' : '';
return "<$tag $str1 $str2>".$value."</$tag>";
}
public static function end($value = 'div')
{
return "</$value>";
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Utilities;
use Illuminate\Support\Facades\Storage;
class Lastcall
{
public static function load($file)
{
$lastcall = (int) Storage::disk('local')->get($file);
if ($lastcall < time() - 30) {
$lastcall = time() - 30;
}
Storage::disk('local')->put($file, time());
return trim($lastcall);
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace App\Utilities;
class Margin
{
public static function calculate($arr, $stellen = 3)
{
if (! is_array($arr)) {
return false;
}
$r = 0;
foreach ($arr as $value) {
$value = $value < 1 ? 1 : $value;
$r += 100 / $value;
}
return round($r, $stellen);
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace App\Utilities;
class Notice
{
/**
* \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;
if (is_array($message)) {
print_r($message);
} else {
echo $message . PHP_EOL;
}
echo '-----------------------------------------------------------' . PHP_EOL;
echo "\e[0;39m";
if ($exit) {
exit();
}
}
public static function note($message, $color = '', $exit = false)
{
switch ($color) {
case 'g':
// green
echo "\e[0;32m";
break;
case 'gb':
case 'bg':
// bold green
echo "\e[1;32m";
break;
case 'r':
// red
echo "\e[0;31m";
break;
case 'br':
case 'rb':
// bold red
echo "\e[1;31m";
break;
case 'b':
// blue
echo "\e[0;34m";
break;
case 'bb':
// bold blue
echo "\e[1;34m";
break;
case 'y':
// yellow
echo "\e[0;33m";
break;
case 'p':
// purple
echo "\e[0;35m";
break;
case 'c':
// cyan
echo "\e[0;36m";
break;
case 'bi':
// blue intence
echo "\e[38;5;33m\n";
break;
default:
echo "\e[0;39m";
break;
}
echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL;
if (is_array($message)) {
print_r($message);
} else {
echo $message . PHP_EOL;
}
echo '-----------------------------------------------------------' . PHP_EOL;
echo "\e[0;39m";
if ($exit) {
exit();
}
}
public static function html($message, $color = '', $exit = false)
{
switch ($color) {
case 'g':
echo '<div style="margin:10px; padding:3px; color:green; width=20rem; text-align:center; border:solid 1px green; background-color:lightgreen;">';
break;
case 'r':
echo '<div style="margin:10px; padding:3px; color:red; width=20rem; text-align:center; border:solid 1px red; background-color:#fdd;">';
break;
case 'b':
echo '<div style="margin:10px; padding:3px; color:blue; width=20rem; text-align:center; border:solid 1px blue; background-color:lightblue;">';
break;
default:
echo '<div style="margin:10px; padding:3px; color:black; width=20rem; text-align:center; border:solid 1px black; background-color:#eee;">';
break;
}
if (is_array($message)) {
print_r($message);
} else {
echo $message;
}
echo '</div>';
if ($exit) {
exit();
}
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Utilities;
class OddsFormatting
{
public static function get($odd, $stellen = 2)
{
if ($odd != 0) {
return number_format($odd, $stellen);
}
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace App\Utilities;
class Round
{
public static function odd($value)
{
// $value = 1 / $value;
if ($value) {
if ($value <= 1) {
// to 0.01
$fac = pow(10, 2);
$value = round($value * $fac) / $fac;
} elseif ($value > 1 && $value <= 3) {
// to 0.01
$fac = pow(10, 2);
$value = round($value * $fac) / $fac;
} elseif ($value > 3 && $value <= 5) {
// to 0.05,
$value *= 20;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value /= 20;
$fac = pow(10, 2);
$value = round($value * $fac) / $fac;
} elseif ($value > 5 && $value <= 10) {
// to 0.1
$fac = pow(10, 1);
$value = round($value * $fac) / $fac;
} elseif ($value > 10 && $value <= 20) {
// to 0.25
$value *= 4;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value /= 4;
$fac = pow(10, 2);
$value = round($value * $fac) / $fac;
} elseif ($value > 20 && $value < 30) {
// to 0.5
$value *= 2;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value /= 2;
$fac = pow(10, 2);
$value = round($value * $fac) / $fac;
} elseif ($value > 30 && $value < 75) {
// to => 1
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
} elseif ($value > 75 && $value < 150) {
// to => 5
$value /= 5;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value *= 5;
} elseif ($value > 150 && $value < 300) {
// to => 10
$value /= 10;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value *= 10;
} elseif ($value > 300 && $value < 500) {
// to => 25
$value /= 25;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value *= 25;
} elseif ($value > 500 && $value < 1000) {
// to => 50
$value /= 50;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value *= 50;
} else {
// to => 50
$value /= 100;
$value = ($value - floor($value) > 0.5) ? ceil($value) : floor($value);
$value *= 100;
}
}
$value = round($value * 100) / 100;
// min max quote
if ($value < 1.01) {
$value = 1;
}
return $value;
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace App\Utilities;
use App\Actions\SupervisorMaker;
use App\Models\Supervisor;
class Supervisorctl
{
public static $starttime = 0;
public static $code = '';
public static function start(&$options)
{
$debug = $options['d'] ?? 0;
$proxy = $options['p'] ?? 0;
$maker = $options['x'] ?? 0;
$runanyway = $options['f'] ?? 0;
// sleep for 0,5 seconds
usleep(500000);
self::$starttime = microtime(true);
self::$code = $options['supervisor_id'];
$supervisor = Supervisor::with('sport')->with('provider')->find(self::$code)->toArray();
$options['name'] = $supervisor['name'];
$options['sport_id'] = $supervisor['sport_id'];
$options['txodds_market_id'] = $supervisor['txodds_market_id'];
$options['sleep'] = $supervisor['sleep'];
$options['lastcall'] = $supervisor['lastcall'];
$options['commandline_options'] = $supervisor['commandline_options'];
$options['is_active'] = $supervisor['is_active'];
$options['days_from'] = $supervisor['days_from'];
$options['days_to'] = $supervisor['days_to'];
$options['is_supervisor'] = $supervisor['is_supervisor'];
if (isset($supervisor['sport']['name'])) {
$options['sport'] = $supervisor['sport']['name'];
}
if ($supervisor['provider']) {
$options['provider_id'] = $supervisor['provider']['id'];
$options['provider'] = $supervisor['provider']['name'];
$options['base_url'] = $supervisor['provider']['base_url'];
}
if ($maker) {
SupervisorMaker::run($supervisor);
}
if ($supervisor) {
if ($debug) {
Notice::note('supervisor start '.self::$code, 'g');
}
if ($proxy) {
$options['proxy'] = 'https://prox2.nuhodds.com/proxy.php';
}
if ($options['sleep'] > 0) {
if (! $debug) {
sleep($options['sleep']);
} else {
if ($options['is_supervisor']) {
Notice::note('cron process', 'b');
} else {
Notice::note('production sleeps '.$options['sleep'].'sec', 'b');
}
}
}
switch ($options['provider_id']) {
case 3:
// MAGLOO KENIA
$options['bookmaker_id'] = 16;
break;
case 4:
// MAGLOO NIGERIA
$options['bookmaker_id'] = 10;
break;
case 5:
// LOGIFUTURE NIGERA
$options['bookmaker_id'] = 35;
break;
case 6:
// LOGIFUTURE COLOMBIA
$options['bookmaker_id'] = 36;
break;
case 9:
// BETICA
$options['bookmaker_id'] = 14;
break;
case 10:
// GOLDBET
$options['bookmaker_id'] = 128;
break;
}
if (! $options['is_active'] && ! $runanyway) {
Notice::note('Process disabled, sleeps 2 min then exit', 'r');
sleep(120);
exit;
}
} else {
Notice::note('unknown supervisor: '.self::$code, 'r', 1);
}
}
public static function end($options)
{
$processend = microtime(true);
$runtime = round(($processend - self::$starttime) / 60, 3);
Supervisor::where('id', self::$code)->update(['runtime' => $runtime]);
if ($options['d']) {
Notice::note('spervisor time: '.$runtime.' min', 'g');
}
}
}