⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.142
Server IP:
217.76.53.76
Server:
Linux vmi1397931.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
Server Software:
Apache
PHP Version:
8.2.27
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
www
/
wwwroot
/
ppt.com.ng
/
app
/
Helper
/
View File Name :
helpers.php
send(new GenericMailer($data, $view)); } catch (Exception $ex) { return $ex->getMessage(); } } function template($asset = false) { $activeTheme = config('basic.theme'); if ($asset) return 'assets/themes/' . $activeTheme . '/'; return 'themes.' . $activeTheme . '.'; } function recursive_array_replace($find, $replace, $array) { if (!is_array($array)) { return str_replace($find, $replace, $array); } $newArray = []; foreach ($array as $key => $value) { $newArray[$key] = recursive_array_replace($find, $replace, $value); } return $newArray; } function menuActive($routeName, $type = null) { $class = 'active'; if ($type == 3) { $class = 'selected'; } elseif ($type == 2) { $class = 'has-arrow active'; } elseif ($type == 1) { $class = 'in'; } if (is_array($routeName)) { foreach ($routeName as $key => $value) { if (request()->routeIs($value)) { return $class; } } } elseif (request()->routeIs($routeName)) { return $class; } } function getFileOld($image, $clean = '') { return file_exists($image) && is_file($image) ? asset($image) . $clean : asset(config('location.default')); } function getFileOrginal($image, $clean = '') { return file_exists($image) && is_file($image) ? asset($image) . $clean : asset(config('location.default')); } function getFile($disk = 'local', $image = '') { try { if ($disk == 'local') { $localImage = asset('/assets/uploads') . '/' . $image; return Storage::disk($disk)->exists($image) ? $localImage : asset(config('location.default')); } else { if(($image != '') || ($image != NULL)){ return Storage::disk($disk)->exists($image) ? Storage::disk($disk)->url($image) : asset(config('location.default')); }else{ return ''; } } } catch (Exception $e) { return asset(config('location.default')); } } function removeFile($path) { return file_exists($path) && is_file($path) ? @unlink($path) : false; } function loopIndex($object) { return ($object->currentPage() - 1) * $object->perPage() + 1; } function getAmount($amount, $length = 0) { if (0 < $length) { return number_format($amount + 0, $length); } return $amount + 0; } function strRandom($length = 12) { $characters = 'ABCDEFGHJKMNOPQRSTUVWXYZ123456789'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function diffForHumans($date) { $lang = session()->get('lang'); Carbon::setlocale($lang); return Carbon::parse($date)->diffForHumans(); } function dateTime($date, $format = 'd M, Y h:i A') { return date($format, strtotime($date)); } if (!function_exists('putPermanentEnv')) { function putPermanentEnv($key, $value) { $path = app()->environmentFilePath(); $escaped = preg_quote('=' . env($key), '/'); file_put_contents($path, preg_replace( "/^{$key}{$escaped}/m", "{$key}={$value}", file_get_contents($path) )); } } function checkTo($currencies, $selectedCurrency = 'USD') { foreach ($currencies as $key => $currency) { if (property_exists($currency, strtoupper($selectedCurrency))) { return $key; } } } function code($length) { if ($length == 0) return 0; $min = pow(10, $length - 1); $max = 0; while ($length > 0 && $length--) { $max = ($max * 10) + 9; } return random_int($min, $max); } function invoice() { return time() . code(4); } function wordTruncate($string, $offset = 0, $length = null): string { $words = explode(" ", $string); isset($length) ? array_splice($words, $offset, $length) : array_splice($words, $offset); return implode(" ", $words); } function linkToEmbed($string) { if (strpos($string, 'youtube') !== false) { $words = explode("/", $string); if (strpos($string, 'embed') == false) { array_splice($words, -1, 0, 'embed'); } $words = str_ireplace('watch?v=', '', implode("/", $words)); return $words; } return $string; } function slug($title) { return Str::slug($title); } function title2snake($string) { return Str::title(str_replace(' ', '_', $string)); } function snake2Title($string) { return Str::title(str_replace('_', ' ', $string)); } function kebab2Title($string) { return Str::title(str_replace('-', ' ', $string)); } function getLevelUser($id) { $ussss = new User(); return $ussss->referralUsers([$id]); } function getPercent($total, $current) { if ($current > 0 && $total > 0) { $percent = (($current * 100) / $total) ?: 0; } else { $percent = 0; } return round($percent, 0); } function flagLanguage($data) { return '{' . rtrim($data, ',') . '}'; } function getIpInfo($ip = null) { $deep_detect = TRUE; if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) { $ip = $_SERVER["REMOTE_ADDR"]; if ($deep_detect) { if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_CLIENT_IP']; } } $xml = @simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=" . $ip); $country = @$xml->geoplugin_countryName; $city = @$xml->geoplugin_city; $area = @$xml->geoplugin_areaCode; $code = @$xml->geoplugin_countryCode; $long = @$xml->geoplugin_longitude; $lat = @$xml->geoplugin_latitude; $user_agent = $_SERVER['HTTP_USER_AGENT']; $os_platform = "Unknown OS Platform"; $os_array = array( '/windows nt 10/i' => 'Windows 10', '/windows nt 6.3/i' => 'Windows 8.1', '/windows nt 6.2/i' => 'Windows 8', '/windows nt 6.1/i' => 'Windows 7', '/windows nt 6.0/i' => 'Windows Vista', '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', '/windows nt 5.1/i' => 'Windows XP', '/windows xp/i' => 'Windows XP', '/windows nt 5.0/i' => 'Windows 2000', '/windows me/i' => 'Windows ME', '/win98/i' => 'Windows 98', '/win95/i' => 'Windows 95', '/win16/i' => 'Windows 3.11', '/macintosh|mac os x/i' => 'Mac OS X', '/mac_powerpc/i' => 'Mac OS 9', '/linux/i' => 'Linux', '/ubuntu/i' => 'Ubuntu', '/iphone/i' => 'iPhone', '/ipod/i' => 'iPod', '/ipad/i' => 'iPad', '/android/i' => 'Android', '/blackberry/i' => 'BlackBerry', '/webos/i' => 'Mobile' ); foreach ($os_array as $regex => $value) { if (preg_match($regex, $user_agent)) { $os_platform = $value; } } $browser = "Unknown Browser"; $browser_array = array( '/msie/i' => 'Internet Explorer', '/firefox/i' => 'Firefox', '/safari/i' => 'Safari', '/chrome/i' => 'Chrome', '/edge/i' => 'Edge', '/opera/i' => 'Opera', '/netscape/i' => 'Netscape', '/maxthon/i' => 'Maxthon', '/konqueror/i' => 'Konqueror', '/mobile/i' => 'Handheld Browser' ); foreach ($browser_array as $regex => $value) { if (preg_match($regex, $user_agent)) { $browser = $value; } } $data['country'] = $country; $data['city'] = $city; $data['area'] = $area; $data['code'] = $code; $data['long'] = $long; $data['lat'] = $lat; $data['os_platform'] = $os_platform; $data['browser'] = $browser; $data['ip'] = request()->ip(); $data['time'] = date('d-m-Y h:i:s A'); return $data; } function resourcePaginate($data, $callback) { return $data->setCollection($data->getCollection()->map($callback)); } function clean($string) { $string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens. return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. } function camelToWord($str) { $arr = preg_split('/(?=[A-Z])/', $str); return trim(join(' ', $arr)); } function in_array_any($needles, $haystack) { return (bool)array_intersect($needles, $haystack); } function adminAccessRoute($search) { $list = collect(config('role'))->pluck('access')->flatten()->intersect(auth()->guard('admin')->user()->admin_access); if (is_array($search)) { $list = $list->intersect($search); if (0 < count($list)) { return true; } return false; } else { return $list->search(function ($item) use ($search) { if ($search == $item) { return true; } return false; }); } } function lastUriSegment() { $uriSegments = explode("/", parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); $lastUriSegment = array_pop($uriSegments); return $lastUriSegment; } if (!function_exists('getRoute')) { function getRoute($route, $params = null) { return isset($params) ? route($route, $params) : route($route); } } if (!function_exists('isMenuActive')) { function isMenuActive($routes, $type = 0) { $class = [ '0' => 'active', '1' => 'style=display:block', '2' => true ]; if (is_array($routes)) { foreach ($routes as $key => $route) { if (request()->routeIs($route)) { return $class[$type]; } } } elseif (request()->routeIs($routes)) { return $class[$type]; } if ($type == 1) { return 'style=display:none'; } else { return false; } } } if (!function_exists('getTitle')) { function getTitle($title) { return ucwords(preg_replace('/[^A-Za-z0-9]/', ' ', $title)); } } if (!function_exists('commaIntStringToArray')) { function commaIntStringToArray($string) { return array_map(static function ($value) { return (int)($value); }, explode(',', $string)); } } if (!function_exists('getIdsFromString')) { function getIdsFromString($string) { return array_reduce( preg_split('/,(?=\d__)/', $string), function ($carry, $item) { preg_match('/^(\d+)__/', $item, $matches); if ($matches) { $carry[] = (int)$matches[1]; } return $carry; }, [] ); } } if (!function_exists('extractNames')) { function extractNames($string) { $names = array_map( function ($item) { preg_match('/\d__[^_]+__([^,]+)/', $item, $matches); return $matches ? $matches[1] : null; }, preg_split('/,(?=\d__)/', $string) ); return array_filter($names); } } if (!function_exists('extractFormattedStrings')) { function extractFormattedStrings($string) { $formattedStrings = array_map( function ($item) { preg_match('/^(\d)__([^_]+)__(.+)/', $item, $matches); return $matches ? $matches[1] . '_cat_' . $matches[3] : null; }, explode(',', $string) ); return array_filter($formattedStrings); } } if (!function_exists('totalCartItemsAdded')) { function totalCartItemsAdded() { $cartItems = session()->get('cart_items'); if (!is_array($cartItems)) return 0; return array_sum(array_column($cartItems, 'quantity')); } } if (!function_exists('updatedCartItemsTotal')) { function updatedCartItemsTotal() { $sum = 0; foreach (session()->get('cart_items', []) as $item) $sum += $item['total']; session()->put('sub_total', $sum); return $sum; } } if (!function_exists('updateCartItems')) { /** * Add, update, reduce, or delete a cart item based on the provided parameters. * * @param int $itemId The ID of the part being added, updated, reduced, or deleted. * @param null $itemQuantity The quantity of the part. Defaults to 1. * @param bool $addQuantity Whether to add the specified quantity to the existing quantity. Defaults to false. * @param bool $reduceQuantity Whether to reduce the quantity by 1. Defaults to false. * @param bool $deleteItem Whether to delete the item from the cart. Defaults to false. * @return mixed|object * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ function updateCartItems(int $itemId, $itemQuantity = null, $addQuantity = false, $reduceQuantity = false, $deleteItem = false) { $part = Part::find($itemId); $cartItems = session()->get('cart_items', []); $itemQuantity = $itemQuantity ?? 1; if ($deleteItem && isset($cartItems[$itemId])) { unset($cartItems[$itemId]); } elseif (isset($cartItems[$itemId])) { if ($addQuantity) { $cartItems[$itemId]['quantity'] += $itemQuantity; } elseif ($reduceQuantity && $cartItems[$itemId]['quantity'] > 1) { $cartItems[$itemId]['quantity'] -= 1; } else { $cartItems[$itemId]['quantity'] = $itemQuantity; } $cartItems[$itemId]['total'] = $cartItems[$itemId]['price'] * $cartItems[$itemId]['quantity']; } else { $cartItems[$itemId] = [ 'id' => $part->id, // +int, 8 'name' => $part->name, // string, "Battery box" 'slug' => $part->slug, // uniue string, "battery-box" + n 'image_url' => $part->images->first()->filename, // etzDQ5nc7we1Es9xnNzjcEd21j1dlTO7.jpeg, {{ asset('/images/' . $part->images->first()->filename) }} 'price' => $part->price, // price of single unit 'total' => $part->price * $itemQuantity, // quantityPrice = singleItemPrice * quantity 'currency_code' => $part->currency_code, // USD, PKR, 'quantity' => $itemQuantity, // number of same items ]; } session()->put('cart_items', $cartItems); return $cartItems; } } /* plugin configuration */