Files
futurewalker/app/Helpers/Global/proxy_helper.php

68 lines
2.3 KiB
PHP

<?php
if (! function_exists('get_smartproxy_rotating_server')) {
function get_smartproxy_rotating_server()
{
$proxy = config('platform.proxy.smartproxy.rotating_global.server');
$proxy_user = config('platform.proxy.smartproxy.rotating_global.user');
$proxy_psw = config('platform.proxy.smartproxy.rotating_global.password');
$reproxy_enable = config('platform.proxy.smartproxy.rotating_global.reproxy_enable');
if ($reproxy_enable) {
$proxy = config('platform.proxy.smartproxy.rotating_global.reproxy');
}
$proxy_server = "$proxy_user:$proxy_psw@$proxy";
return $proxy_server;
}
}
if (! function_exists('get_smartproxy_unblocker_server')) {
function get_smartproxy_unblocker_server()
{
$proxy = config('platform.proxy.smartproxy.unblocker.server');
$proxy_user = config('platform.proxy.smartproxy.unblocker.user');
$proxy_psw = config('platform.proxy.smartproxy.unblocker.password');
$reproxy_enable = config('platform.proxy.smartproxy.unblocker.reproxy_enable');
if ($reproxy_enable) {
$proxy = config('platform.proxy.smartproxy.unblocker.reproxy');
}
$proxy_server = "$proxy_user:$proxy_psw@$proxy";
return $proxy_server;
}
}
if (! function_exists('get_smartproxy_server')) {
function get_smartproxy_server()
{
$proxy = config('platform.proxy.smartproxy.rotating_global.server');
$proxy_user = config('platform.proxy.smartproxy.rotating_global.user');
$proxy_psw = config('platform.proxy.smartproxy.rotating_global.password');
$reproxy_enable = config('platform.proxy.smartproxy.rotating_global.reproxy_enable');
if ($reproxy_enable) {
$proxy = config('platform.proxy.smartproxy.rotating_global.reproxy');
}
$proxy_server = "$proxy_user:$proxy_psw@$proxy";
return $proxy_server;
}
}
if (! function_exists('calculate_smartproxy_cost')) {
function calculate_smartproxy_cost(float $kb, $type = 'rotating_global')
{
$cost_per_gb = config("platform.proxy.smartproxy.{$type}.cost_per_gb");
// Convert cost per GB to cost per KB
$cost_per_kb = $cost_per_gb / (1024 * 1024);
// Calculate total cost for the given $kb
$cost = ($cost_per_kb * $kb);
return round($cost, 3);
}
}