@@ -21,10 +21,11 @@ |
||
21 | 21 | public static function get($key,$default = null){ |
22 | 22 | $result = self::$config; |
23 | 23 | foreach (explode('.' , $key) as $segment) { |
24 | - if(isset($result[$segment])) |
|
25 | - $result = $result[$segment]; |
|
26 | - else |
|
27 | - $result = $default; |
|
24 | + if(isset($result[$segment])) { |
|
25 | + $result = $result[$segment]; |
|
26 | + } else { |
|
27 | + $result = $default; |
|
28 | + } |
|
28 | 29 | } |
29 | 30 | return $result; |
30 | 31 | } |
@@ -10,18 +10,18 @@ |
||
10 | 10 | |
11 | 11 | class Config { |
12 | 12 | private static $config = array(); |
13 | - private function __construct(){} |
|
14 | - public static function load($path = null){ |
|
13 | + private function __construct() {} |
|
14 | + public static function load($path = null) { |
|
15 | 15 | $path = ($path) ?: __APP_ROOT__ . '/config/*'; |
16 | 16 | foreach (glob($path) as $file) { |
17 | 17 | $config = include $file; |
18 | 18 | self::$config = array_merge(self::$config, $config); |
19 | 19 | } |
20 | 20 | } |
21 | - public static function get($key,$default = null){ |
|
21 | + public static function get($key, $default = null) { |
|
22 | 22 | $result = self::$config; |
23 | - foreach (explode('.' , $key) as $segment) { |
|
24 | - if(isset($result[$segment])) |
|
23 | + foreach (explode('.', $key) as $segment) { |
|
24 | + if (isset($result[$segment])) |
|
25 | 25 | $result = $result[$segment]; |
26 | 26 | else |
27 | 27 | $result = $default; |
@@ -5,12 +5,12 @@ |
||
5 | 5 | use Phpmig\Adapter; |
6 | 6 | use Illuminate\Database\Capsule\Manager as Capsule; |
7 | 7 | include 'settings.php'; |
8 | -$capsule = new Capsule; |
|
8 | +$capsule = new Capsule; |
|
9 | 9 | $capsule->addConnection($config['settings']['db']); |
10 | 10 | $capsule->setAsGlobal(); |
11 | 11 | $capsule->bootEloquent(); |
12 | 12 | $container = new ArrayObject(); |
13 | 13 | $container['phpmig.adapter'] = new Adapter\Illuminate\Database($capsule, 'migrations'); |
14 | -$container['phpmig.migrations_path'] = 'database/migrations'; |
|
14 | +$container['phpmig.migrations_path'] = 'database/migrations'; |
|
15 | 15 | $container['phpmig.migrations_template_path'] = 'core/resources/templates/create_migration.txt'; |
16 | 16 | return $container; |
17 | 17 | \ No newline at end of file |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | |
35 | 35 | public function resource($url, $controller, $args = []) |
36 | 36 | { |
37 | - $url = rtrim($url,'/'); |
|
38 | - $routeNames = implode('.',explode('/',trim($url,'/'))); |
|
39 | - |
|
40 | - $this->app->group($url, function () use ($controller,$routeNames, $args) { |
|
41 | - $this->get('', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
42 | - $this->get('/', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
43 | - $this->get('/index', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames.'.index'); |
|
44 | - |
|
45 | - $this->get('/create', $controller . ':create')->add(self::middleware('create', $args))->setName($routeNames.'.create'); |
|
46 | - $this->get('/{id:[0-9]+}', $controller . ':show')->add(self::middleware('show', $args))->setName($routeNames.'.show'); |
|
47 | - $this->get('/{id:[0-9]+}/edit', $controller . ':edit')->add(self::middleware('edit', $args))->setName($routeNames.'.edit'); |
|
48 | - $this->post('', $controller . ':store')->add(self::middleware('store', $args))->setName($routeNames.'.store'); |
|
49 | - $this->put('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('update', $args))->setName($routeNames.'.update'); |
|
50 | - $this->patch('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('index', $args))->setName($routeNames.'.update'); |
|
51 | - $this->delete('/{id:[0-9]+}', $controller . ':destroy')->add(self::middleware('destroy', $args))->setName($routeNames.'.destroy'); |
|
37 | + $url = rtrim($url, '/'); |
|
38 | + $routeNames = implode('.', explode('/', trim($url, '/'))); |
|
39 | + |
|
40 | + $this->app->group($url, function() use ($controller, $routeNames, $args) { |
|
41 | + $this->get('', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
42 | + $this->get('/', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
43 | + $this->get('/index', $controller . ':index')->add(self::middleware('index', $args))->setName($routeNames . '.index'); |
|
44 | + |
|
45 | + $this->get('/create', $controller . ':create')->add(self::middleware('create', $args))->setName($routeNames . '.create'); |
|
46 | + $this->get('/{id:[0-9]+}', $controller . ':show')->add(self::middleware('show', $args))->setName($routeNames . '.show'); |
|
47 | + $this->get('/{id:[0-9]+}/edit', $controller . ':edit')->add(self::middleware('edit', $args))->setName($routeNames . '.edit'); |
|
48 | + $this->post('', $controller . ':store')->add(self::middleware('store', $args))->setName($routeNames . '.store'); |
|
49 | + $this->put('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('update', $args))->setName($routeNames . '.update'); |
|
50 | + $this->patch('/{id:[0-9]+}', $controller . ':update')->add(self::middleware('index', $args))->setName($routeNames . '.update'); |
|
51 | + $this->delete('/{id:[0-9]+}', $controller . ':destroy')->add(self::middleware('destroy', $args))->setName($routeNames . '.destroy'); |
|
52 | 52 | |
53 | 53 | })->add(self::middleware('group', $args)); |
54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function middleware($middleWare = "group", $args) |
62 | 62 | { |
63 | - $routeResourceMiddleWare_default = function ($request, $response, $next) { |
|
63 | + $routeResourceMiddleWare_default = function($request, $response, $next) { |
|
64 | 64 | return $next($request, $response); |
65 | 65 | }; |
66 | 66 |
@@ -2,18 +2,18 @@ |
||
2 | 2 | use App\Controller\HomeController; |
3 | 3 | $route = new \Core\Route($app); |
4 | 4 | |
5 | -$files = getDirFiles(__APP_ROOT__.'app/Routes/'); |
|
5 | +$files = getDirFiles(__APP_ROOT__ . 'app/Routes/'); |
|
6 | 6 | /** Route Partial Loadup =================================================== */ |
7 | 7 | foreach ($files as $partial) { |
8 | - $file = __APP_ROOT__.'app/Routes/'.$partial; |
|
8 | + $file = __APP_ROOT__ . 'app/Routes/' . $partial; |
|
9 | 9 | |
10 | - if ( ! file_exists($file)) |
|
10 | + if (!file_exists($file)) |
|
11 | 11 | { |
12 | 12 | $msg = "Route partial [{$partial}] not found."; |
13 | 13 | } |
14 | 14 | include $file; |
15 | 15 | } |
16 | -$route->get('/', HomeController::class.':index')->setName('home'); |
|
16 | +$route->get('/', HomeController::class . ':index')->setName('home'); |
|
17 | 17 | |
18 | 18 | $route->resource('/user/auth', '\App\Controller\User\AuthController', $args = []); |
19 | 19 |
@@ -11,11 +11,11 @@ |
||
11 | 11 | |
12 | 12 | class Env |
13 | 13 | { |
14 | - public function __invoke($filePath ,$key, $default = null) |
|
14 | + public function __invoke($filePath, $key, $default = null) |
|
15 | 15 | { |
16 | 16 | |
17 | 17 | if (file_exists($filePath . '/.env')) { |
18 | - $_dotenv = new Dotenv($filePath ); |
|
18 | + $_dotenv = new Dotenv($filePath); |
|
19 | 19 | $_dotenv->load(); |
20 | 20 | unset($_dotenv); |
21 | 21 | }else { |
@@ -18,7 +18,7 @@ |
||
18 | 18 | $_dotenv = new Dotenv($filePath ); |
19 | 19 | $_dotenv->load(); |
20 | 20 | unset($_dotenv); |
21 | - }else { |
|
21 | + } else { |
|
22 | 22 | return ''; |
23 | 23 | } |
24 | 24 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | abstract class _TranslateHandler |
15 | 15 | { |
16 | - protected $container ; |
|
16 | + protected $container; |
|
17 | 17 | protected $local; |
18 | 18 | |
19 | 19 | function __construct(ContainerInterface $container) |
@@ -39,5 +39,5 @@ discard block |
||
39 | 39 | return $this->container; |
40 | 40 | } |
41 | 41 | |
42 | - abstract public function trans(string $key , array $replace); |
|
42 | + abstract public function trans(string $key, array $replace); |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * @var ContainerInterface $setting |
17 | 17 | * |
18 | - */ |
|
18 | + */ |
|
19 | 19 | public function init() |
20 | 20 | { |
21 | 21 | $setting = $this->settings['translation']; |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; |
34 | 34 | if(file_exists($translationBaseFile)){ |
35 | 35 | $lang = include ($translationBaseFile); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | return $key; |
38 | 38 | } |
39 | - }else{ |
|
39 | + } else{ |
|
40 | 40 | } |
41 | 41 | $keyArr = explode('.',$key); |
42 | 42 | unset($keyArr[0]); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | str_replace($key,$replace_item,$lang_new); |
50 | 50 | } |
51 | 51 | } |
52 | - }else{ |
|
52 | + } else{ |
|
53 | 53 | return $lang_new; |
54 | 54 | } |
55 | 55 | } |
@@ -23,48 +23,48 @@ discard block |
||
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | - private function _loadkey(string $key , array $replace = []) |
|
26 | + private function _loadkey(string $key, array $replace = []) |
|
27 | 27 | { |
28 | - list($namespace,$group) = explode('.',$key); |
|
28 | + list($namespace, $group) = explode('.', $key); |
|
29 | 29 | $t_dir = $this->getTranslation_dirs(); |
30 | 30 | |
31 | - if(in_array($this->local,$t_dir)){ |
|
32 | - $translationBaseFolder = $this->settings['translation']['translations_path'].$this->local; |
|
33 | - $translationBaseFile = $translationBaseFolder.'/'.$namespace.'.php'; |
|
34 | - if(file_exists($translationBaseFile)){ |
|
31 | + if (in_array($this->local, $t_dir)) { |
|
32 | + $translationBaseFolder = $this->settings['translation']['translations_path'] . $this->local; |
|
33 | + $translationBaseFile = $translationBaseFolder . '/' . $namespace . '.php'; |
|
34 | + if (file_exists($translationBaseFile)) { |
|
35 | 35 | $lang = include ($translationBaseFile); |
36 | - }else{ |
|
36 | + }else { |
|
37 | 37 | return $key; |
38 | 38 | } |
39 | - }else{ |
|
39 | + }else { |
|
40 | 40 | } |
41 | - $keyArr = explode('.',$key); |
|
41 | + $keyArr = explode('.', $key); |
|
42 | 42 | unset($keyArr[0]); |
43 | 43 | $keyArr = array_values($keyArr); |
44 | - $lang_new = $this->getDataFromTranslation($lang,$keyArr); |
|
44 | + $lang_new = $this->getDataFromTranslation($lang, $keyArr); |
|
45 | 45 | |
46 | - if(count($replace) > 0){ |
|
47 | - foreach($replace as $key=>$replace_item){ |
|
48 | - if(strpos($lang_new,'%') != 0){ |
|
49 | - str_replace($key,$replace_item,$lang_new); |
|
46 | + if (count($replace) > 0) { |
|
47 | + foreach ($replace as $key=>$replace_item) { |
|
48 | + if (strpos($lang_new, '%') != 0) { |
|
49 | + str_replace($key, $replace_item, $lang_new); |
|
50 | 50 | } |
51 | 51 | } |
52 | - }else{ |
|
52 | + }else { |
|
53 | 53 | return $lang_new; |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | - public function getDataFromTranslation( $data, $keyArr){ |
|
59 | - $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
60 | - if($arrayFound){ |
|
58 | + public function getDataFromTranslation($data, $keyArr) { |
|
59 | + $arrayFound = isset($data[$keyArr[0]]) ? $data[$keyArr[0]] : ''; |
|
60 | + if ($arrayFound) { |
|
61 | 61 | unset($keyArr[0]); |
62 | 62 | $keyArr = array_values($keyArr); |
63 | - if(isset($keyArr[0])){ |
|
64 | - return $this->getDataFromTranslation($arrayFound,$keyArr); |
|
63 | + if (isset($keyArr[0])) { |
|
64 | + return $this->getDataFromTranslation($arrayFound, $keyArr); |
|
65 | 65 | } |
66 | 66 | } |
67 | - return $arrayFound ; |
|
67 | + return $arrayFound; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | public function trans(string $key, array $replace = []) |
75 | 75 | { |
76 | - return $this->_loadkey($key,$replace); |
|
76 | + return $this->_loadkey($key, $replace); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | |
88 | - return array_diff($dir,$ex_folders); |
|
88 | + return array_diff($dir, $ex_folders); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | } |
92 | 92 | \ No newline at end of file |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | |
9 | 9 | namespace Core\Helpers; |
10 | 10 | |
11 | -class Hash{ |
|
11 | +class Hash { |
|
12 | 12 | /** |
13 | 13 | * Receives a string password and hashes it. |
14 | 14 | * |
15 | 15 | * @param string $password |
16 | 16 | * @return string $hash |
17 | 17 | */ |
18 | - public static function hash($password){ |
|
18 | + public static function hash($password) { |
|
19 | 19 | // return (string)password_hash($password, PASSWORD_DEFAULT); |
20 | 20 | return sha1(md5($password)); |
21 | 21 | } |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | * @param string $hash |
28 | 28 | * @return boolean If the hash was generated from the password |
29 | 29 | */ |
30 | - public static function checkHash($string, $hash){ |
|
31 | - if( password_verify( $string, $hash ) ){ |
|
30 | + public static function checkHash($string, $hash) { |
|
31 | + if (password_verify($string, $hash)) { |
|
32 | 32 | return true; |
33 | 33 | } |
34 | 34 | return false; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | return isset($_SESSION['user']['user_id']); |
26 | 26 | } |
27 | 27 | |
28 | - public function attempt(string $loginField,string $password) |
|
28 | + public function attempt(string $loginField, string $password) |
|
29 | 29 | { |
30 | 30 | $user = UserDataAccess::getUserLoginField($loginField); |
31 | 31 | if (!$user) { |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | $setting = Config::get('settings.auth'); |
38 | - if($setting['2step']){ |
|
38 | + if ($setting['2step']) { |
|
39 | 39 | $this->twoStepAuth(); |
40 | - }else{ |
|
41 | - if ($this->checkPass($password,$user->password)) { |
|
40 | + }else { |
|
41 | + if ($this->checkPass($password, $user->password)) { |
|
42 | 42 | $_SESSION['user']['user_id'] = $user->id; |
43 | 43 | $_SESSION['user']['mobile'] = $user->mobile; |
44 | 44 | return [ |
45 | 45 | 'type'=>'success', |
46 | 46 | 'message'=> 'Logined', |
47 | 47 | ]; |
48 | - }else{ |
|
48 | + }else { |
|
49 | 49 | return [ |
50 | 50 | 'type'=>'error', |
51 | 51 | 'message'=> 'password mismatch', |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - public function checkPass($password,$database_pass) |
|
63 | + public function checkPass($password, $database_pass) |
|
64 | 64 | { |
65 | - if($database_pass == $password){ |
|
65 | + if ($database_pass == $password) { |
|
66 | 66 | return true; |
67 | 67 | } |
68 | 68 | return false; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $setting = Config::get('settings.auth'); |
38 | 38 | if($setting['2step']){ |
39 | 39 | $this->twoStepAuth(); |
40 | - }else{ |
|
40 | + } else{ |
|
41 | 41 | if ($this->checkPass($password,$user->password)) { |
42 | 42 | $_SESSION['user']['user_id'] = $user->id; |
43 | 43 | $_SESSION['user']['mobile'] = $user->mobile; |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | 'type'=>'success', |
46 | 46 | 'message'=> 'Logined', |
47 | 47 | ]; |
48 | - }else{ |
|
48 | + } else{ |
|
49 | 49 | return [ |
50 | 50 | 'type'=>'error', |
51 | 51 | 'message'=> 'password mismatch', |