Add (ai gen)

This commit is contained in:
2023-10-01 00:35:27 +08:00
parent 645d0f1d02
commit f02081e30c
79 changed files with 4816 additions and 1041 deletions

View File

@@ -2,3 +2,4 @@
require 'string_helper.php';
require 'geo_helper.php';
require 'proxy_helper.php';

View File

@@ -0,0 +1,33 @@
<?php
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, $amplifier = 1)
{
$cost_per_gb = config('platform.proxy.smartproxy.rotating_global.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) * $amplifier;
return round($cost, 3);
}
}

View File

@@ -2,6 +2,13 @@
use Illuminate\Support\Str;
if (! function_exists('epoch_now_timestamp')) {
function epoch_now_timestamp()
{
return (int) round(microtime(true) * 1000);
}
}
if (! function_exists('str_first_sentence')) {
function str_first_sentence($str)
{
@@ -19,6 +26,20 @@ function str_first_sentence($str)
}
if (! function_exists('unslug')) {
function unslug($slug, $delimiter = '-')
{
return ucwords(str_replace($delimiter, ' ', $slug));
}
}
if (! function_exists('str_slug')) {
function str_slug($string, $delimiter = '-')
{
return Str::of(trim($string))->slug($delimiter);
}
}
if (! function_exists('is_empty')) {
/**
* A better function to check if a value is empty or null. Strings, arrays, and Objects are supported.