File manager - Edit - /home/autoph/public_html/tasks/src.tar
Back
helpers.php 0000644 00000006532 15025010271 0006716 0 ustar 00 <?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; } Utilities/Token.php 0000644 00000000257 15025010271 0010305 0 ustar 00 <?php namespace App\Utilities; use Ramsey\Uuid\Uuid; // use App\Core\View; class Token { public static function generate() { return Uuid::uuid4(); } } Utilities/Slug.php 0000644 00000000333 15025010271 0010132 0 ustar 00 <?php namespace App\Utilities; class Slug { public static function create($data){ $data = strtolower(trim($data)); $slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $data); return $slug; } } Utilities/Auth.php 0000644 00000005346 15025010271 0010132 0 ustar 00 <?php namespace App\Utilities; use App\Utilities\Session; class Auth { private static $instance; function __construct() { if (!empty(Session::get('user'))) { // $user = new \App\Models\User; // $response = $user->getUser(array(Session::get('uid'))); // foreach ($response as $key => $value) { foreach ($_SESSION['user'] as $key => $value) { $this->{$key} = $value; } } } public static function user() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; } public static function check() { if (!empty(Session::get('user'))) { return true; } return false; } // public static function getPerm() // { // $roleId = Auth::user()->roleId; // $permissions_arr = array(); // if (!empty($roleId)) { // $permissions_json = \App\Models\Role::rolePermissions($roleId); // if (!empty($permissions_json)) { // $permissions_arr = json_decode($permissions_json, true); // } // } // if (!empty(Auth::user()->admin)) { // $permissions_arr = array_merge($permissions_arr, array('admin' => true)); // } // if (!empty(Auth::user()->vendor)) { // $permissions_arr = array_merge($permissions_arr, array('vendor' => true)); // } // return $permissions_arr; // } // public static function hasPermission($perm) // { // $permissions_arr = self::getPerm(); // if (!empty($permissions_arr['admin'])) { // return true; // } // if (is_array($perm)) { // foreach ($perm as $perm_row) { // if (empty($permissions_arr[$perm_row])) { // return false; // } // } // return true; // } else { // if (!empty($permissions_arr[$perm])) { // return true; // } // } // return false; // } // public static function hasAnyPermission($perm) // { // $permissions_arr = self::getPerm(); // if (!empty($permissions_arr['admin'])) { // return true; // } // if (is_array($perm)) { // foreach ($perm as $perm_row) { // if (!empty($permissions_arr[$perm_row])) { // return true; // } // } // return false; // } else { // if (!empty($permissions_arr[$perm])) { // return true; // } // } // return false; // } } Utilities/MobileFormatter.php 0000644 00000001727 15025010271 0012323 0 ustar 00 <?php namespace App\Utilities; class MobileFormatter { public static function format($data) { if (strlen($data) < 5) { return ""; } $final_data = ""; //if area code equal to 639xx it will change to 09xxxxxxxxx if (substr($data, 0, 2) === "09") { $final_data = "9" . substr($data, 2, strlen($data)); } else if (substr($data, 0, 3) === "639") { $final_data = "9" . substr($data, 3, strlen($data)); } else if (substr($data, 0, 1) === "9" && strlen($data) == 10) { $final_data = "9" . substr($data, 1, strlen($data)); } else { $final_data = $data; } //if number start with 09xxx, check the length, if length is not 11 return blank, if not 09xxx return it if (substr($final_data, 0, 1) === "9") { if (strlen($final_data) == 10) { return $final_data; } } return ''; } } Utilities/Hash.php 0000644 00000000425 15025010271 0010105 0 ustar 00 <?php namespace App\Utilities; class Hash { public static function verify($password, $hash_password) { return password_verify($password, $hash_password); } public static function hash($password) { return password_hash($password, PASSWORD_DEFAULT); } } ?>