File manager - Edit - /home/autoph/public_html/data03252025consolidation/src/helpers.php
Back
<?php use Pecee\SimpleRouter\SimpleRouter as Router; use Pecee\Http\Url; use Pecee\Http\Response; use Pecee\Http\Request; /** * Get url for a route by using either name/alias, class or method name. * * The name parameter supports the following values: * - Route name * - Controller/resource name (with or without method) * - Controller class name * * When searching for controller/resource by name, you can use this syntax "route.name@method". * You can also use the same syntax when searching for a specific controller-class "MyController@home". * If no arguments is specified, it will return the url for the current loaded route. * * @param string|null $name * @param string|array|null $parameters * @param array|null $getParams * @return \Pecee\Http\Url * @throws \InvalidArgumentException */ function url(?string $name = null, $parameters = null, ?array $getParams = null): Url { return Router::getUrl($name, $parameters, $getParams); } /** * @return \Pecee\Http\Response */ function response(): Response { return Router::response(); } /** * @return \Pecee\Http\Request */ function request(): Request { return Router::request(); } /** * Get input class * @param string|null $index Parameter index name * @param string|null $defaultValue Default return value * @param array ...$methods Default methods * @return \Pecee\Http\Input\InputHandler|array|string|null */ function input($index = null, $defaultValue = null, ...$methods) { if ($index !== null) { return request()->getInputHandler()->value($index, $defaultValue, ...$methods); } return request()->getInputHandler(); } /** * @param string $url * @param int|null $code */ function redirect(string $url, ?int $code = null): void { if ($code !== null) { response()->httpCode($code); } response()->redirect($url); } /** * Get current csrf-token * @return string|null */ function csrf_token(): ?string { $baseVerifier = Router::router()->getCsrfVerifier(); if ($baseVerifier !== null) { return $baseVerifier->getTokenProvider()->getToken(); } return null; } //Custom Helpers /** * Flatten the array * @return array|null */ function array_flatten(array $array) { $return = array(); array_walk_recursive($array, function ($a) use (&$return) { $return[] = $a; }); return $return; } function escape($string) { return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); // return htmlspecialchars($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); // return htmlentities($string, ENT_QUOTES | ENT_HTML5, 'UTF-8'); } function config($config) { // return (object) include(__DIR__ . '/../config/' . $config . '.php'); return (object) include(__DIR__ . '/config/' . $config . '.php'); } function sanitize($array) { if (!is_array($array)) { $array = preg_replace('/\h+/', ' ', escape(trim($array))); if (empty($array) && !strlen($array)) { $array = NULL; } } else { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = sanitize($value); } else { $array[$key] = preg_replace('/\h+/', ' ', escape(trim($value))); if (empty($value) && !strlen($value)) { $array[$key] = NULL; } } } } return $array; }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings