Файловый менеджер - Редактировать - /home/clickysoft/public_html/charliapp-v2.clickysoft.net/app/helpers.php
Назад
<?php use Illuminate\Support\Facades\DB; use Illuminate\Http\JsonResponse; if (!function_exists('getEnumValues')) { function getEnumValues($table, $column) { $type = DB::select(DB::raw("SHOW COLUMNS FROM `{$table}` WHERE Field = '{$column}'"))[0]->Type; preg_match('/^enum\((.*)\)$/', $type, $matches); $enum = array(); foreach (explode(',', $matches[1]) as $value) { $v = trim($value, "'"); $enum[] = $v; } return $enum; } } if(!function_exists('convertFieldName')) { function convertFieldName($field_name) { $words = explode("_", $field_name); $fieldName = []; foreach ($words as $word) { $fieldName[] = ucfirst($word); } return implode(" ", $fieldName); } } if(!function_exists('check_date')) { function check_date($dt, $sep = "-") { if (empty($dt) || is_null($dt)) { return false; } $d = explode($sep, $dt); if (sizeof($d) != 3) { return false; } if (!ctype_digit($d[0]) || !ctype_digit($d[1]) || !ctype_digit($d[2])) { return false; } return checkdate($d[1], $d[0], $d[2]); } } if(!function_exists('make_slug')) { function make_slug($string = null, $separator = "-") { if (is_null($string)) { return ""; } $string = mb_strtolower($string, "UTF-8"); $string = preg_replace("/[^a-z0-9_\s\-ءاأإآؤئبتثجحخدذرزسشصضطظعغفقكلمنهويةى]/u", "", $string); $string = trim($string); $string = preg_replace("/[\s-]+/", " ", $string); $string = preg_replace("/[\s_]/", $separator, $string); return $string; } } if(!function_exists('dmy2ymd')) { function dmy2ymd($date) { if (empty($date)) { return NULL; } $dt = explode("-", $date); return $dt[2] . '-' . $dt[1] . '-' . $dt[0]; } } if(!function_exists('colorDropDown')) { function colorDropDown($colors, $errorClass, $default = '') { $options = '<option value="">Please select</option>'; foreach ($colors as $color) { $options .= '<option value="' . $color->id . '" bcolor="' . $color->color_code . '" fcolor="' . $color->foreground_color . '"' . ((int)$default == $color->id ? ' selected' : '') . '>' . $color->color . '</option>'; } return '<select class="form-control color select2 ' . $errorClass . '" name="color_id" id="color_id">' . $options . '</select>'; } } if(!function_exists('get_guid')) { function get_guid() { $data = PHP_MAJOR_VERSION < 7 ? openssl_random_pseudo_bytes(16) : random_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // Set version to 0100 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // Set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } } if(!function_exists('date_difference')) { function date_difference($date1, $date2) { $dt1 = new DateTime($date1); $dt2 = new DateTime($date2); $difference = $dt1->diff($dt2); return $difference->format("%r%a"); } } if(!function_exists('fixTowAfterDot')) { function fixTowAfterDot($value) { $num = explode(".", (string)$value); if (count($num) > 1 && strlen($num[1]) > 2) { return (float)($num[0] . "." . substr((string)$num[1], 0, 2)); } return $value; } } if(!function_exists('getProfileImage')) { function getProfileImage($user) { if(empty($user->profile_image->original_url)) { $name = explode(" ", !empty($user->name) ? trim($user->name) : 'guest'); $initials = count($name) > 1 ? $name[0][0].$name[1][0] : $name[0][0]; return "https://via.placeholder.com/40/EEEEEE/000000/?text=".$initials; } return $user->profile_image->original_url; } } if(!function_exists('getGroupIcon')) { function getGroupIcon($group, $type = "thumbnail") { if(empty($group->group_icon->{$type})) { $name = explode(" ", !empty($group->group_name) ? trim($group->group_name) : 'guest'); $initials = count($name) > 1 ? $name[0][0].$name[1][0] : $name[0][0]; return "https://via.placeholder.com/40/EEEEEE/000000/?text=".$initials; } return $group->group_icon->{$type}; } } if(!function_exists('isValidEmailAddress')) { function isValidEmailAddress($email) { return filter_var($email, FILTER_VALIDATE_EMAIL); } } if (!function_exists('makeJsonResponse')) { function makeJsonResponse($status, $message, $statusCode = 200, $data = [], $errors = []) : JsonResponse { return response()->json([ 'status' => $status, 'code' => $statusCode, 'message' => $message, 'data' => $data ?? [], 'errors' => $errors ], $statusCode, [], 1); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка