Add (initial): futurewalker code
This commit is contained in:
@@ -3,3 +3,4 @@
|
||||
require 'string_helper.php';
|
||||
require 'geo_helper.php';
|
||||
require 'platform_helper.php';
|
||||
require 'proxy_helper.php';
|
||||
|
||||
@@ -31,3 +31,19 @@ function get_exponential_posts_gen_by_day($day, $period_days = 45)
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_notification_channel')) {
|
||||
|
||||
function get_notification_channel()
|
||||
{
|
||||
return 'telegram';
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_notification_user_id')) {
|
||||
|
||||
function get_notification_user_id()
|
||||
{
|
||||
return '629991336';
|
||||
}
|
||||
}
|
||||
|
||||
67
app/Helpers/Global/proxy_helper.php
Normal file
67
app/Helpers/Global/proxy_helper.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,24 @@
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
if (! function_exists('is_valid_url')) {
|
||||
function is_valid_url($url)
|
||||
{
|
||||
// Check if the URL is a valid full URL
|
||||
if (filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if it's a valid relative URL
|
||||
// Modify this regex as needed for your specific URL formats
|
||||
if (preg_match('/^\/[\w\/_.-]+(\.[\w]+)?$/i', $url)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('epoch_now_timestamp')) {
|
||||
function epoch_now_timestamp()
|
||||
{
|
||||
@@ -17,6 +35,14 @@ function read_duration($text)
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('remove_newline')) {
|
||||
|
||||
function remove_newline($string)
|
||||
{
|
||||
return preg_replace('/\s+/', ' ', trim($string));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('plain_text')) {
|
||||
function plain_text($content)
|
||||
{
|
||||
@@ -24,6 +50,32 @@ function plain_text($content)
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('markdown_to_plaintext')) {
|
||||
function markdown_to_plaintext($markdown)
|
||||
{
|
||||
// Headers
|
||||
$markdown = preg_replace('/^#.*$/m', '', $markdown);
|
||||
// Links and images
|
||||
$markdown = preg_replace('/\[(.*?)\]\(.*?\)/', '$1', $markdown);
|
||||
// Bold and italic
|
||||
$markdown = str_replace(['**', '__', '*', '_'], '', $markdown);
|
||||
// Ordered and unordered lists
|
||||
$markdown = preg_replace('/^[-\*].*$/m', '', $markdown);
|
||||
// Horizontal line
|
||||
$markdown = str_replace(['---', '***', '- - -', '* * *'], '', $markdown);
|
||||
// Inline code and code blocks
|
||||
$markdown = preg_replace('/`.*?`/', '', $markdown);
|
||||
$markdown = preg_replace('/```[\s\S]*?```/', '', $markdown);
|
||||
// Blockquotes
|
||||
$markdown = preg_replace('/^>.*$/m', '', $markdown);
|
||||
|
||||
// Remove multiple spaces, leading and trailing spaces
|
||||
$plaintext = trim(preg_replace('/\s+/', ' ', $markdown));
|
||||
|
||||
return $plaintext;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('markdown_min_read')) {
|
||||
function markdown_min_read($markdown)
|
||||
{
|
||||
@@ -48,12 +100,12 @@ function str_slug($string, $delimiter = '-')
|
||||
if (! function_exists('str_first_sentence')) {
|
||||
function str_first_sentence($str)
|
||||
{
|
||||
// Split the string at ., !, or ?
|
||||
$sentences = preg_split('/(\.|!|\?)(\s|$)/', $str, 2);
|
||||
// Split the string at ., !, or ? but include these characters in the match
|
||||
$sentences = preg_split('/([.!?])\s/', $str, 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
// Return the first part of the array if available
|
||||
if (isset($sentences[0])) {
|
||||
return trim($sentences[0]);
|
||||
// Check if we have captured the first sentence and its punctuation
|
||||
if (isset($sentences[0]) && isset($sentences[1])) {
|
||||
return trim($sentences[0].$sentences[1]);
|
||||
}
|
||||
|
||||
// If no sentence ending found, return the whole string
|
||||
|
||||
Reference in New Issue
Block a user