> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $brightness = (int)(($r + $g + $b) / 3); $total_brightness += $brightness; } } $avg_brightness = $total_brightness / ($width * $height); // Determine if the image is more dark or light if ($avg_brightness < 128) { return 'dark'; } else { return 'light'; } } catch (\Throwable $th) { return null; } } function infoIcon($tip) { echo '
'; } function external_file_get_contents($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0'); $data = curl_exec($ch); curl_close($ch); return $data; } function uri($path) { $url = str_replace(['http://', 'https://'], '', url('')); return "//" . $url . "/" . $path; } function footer($key) { $upperStr = strtoupper($key); if (env('TITLE_FOOTER_'.$upperStr) == "") { $title = __('messages.footer.'.$key); } else { $title = env('TITLE_FOOTER_'.$upperStr); } return $title; } function strip_tags_except_allowed_protocols($str) { preg_match_all('/]+>(.*?)<\/a>/i', $str, $matches, PREG_SET_ORDER); foreach ($matches as $val) { if (!preg_match('/href=["\'](http:|https:|mailto:|tel:)[^"\']*["\']/', $val[0])) { $str = str_replace($val[0], $val[1], $str); } } return $str; } if(!function_exists('setBlockAssetContext')) { function setBlockAssetContext($type = null) { static $currentType = null; if ($type !== null) { $currentType = $type; } return $currentType; } } // Get custom block assets if(!function_exists('block_asset')) { function block_asset($file) { $type = setBlockAssetContext(); // Retrieve the current type context return url("block-asset/$type?asset=$file"); } } if(!function_exists('get_block_file_contents')) { function get_block_file_contents($file) { $type = setBlockAssetContext(); // Retrieve the current type context return file_get_contents(base_path("blocks/$type/$file")); } } function block_text_translation_check($text) { if (empty($text)) { return false; } $translate = __("messages.$text"); return $translate === "messages.$text" ? true : false; } function block_text($text) { $translate = __("messages.$text"); return $translate === "messages.$text" ? $text : $translate; } function bt($text) { return block_text($text); }