Completed
Push — master ( 9e3424...8921ba )
by Afshin
02:53
created
core/Services/AuthService.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         $setting = Config::get('settings.auth');
55 55
         if(1 || $setting['2step']){
56 56
             return $this->twoStepAuth($loginField,$password);
57
-        }else{
57
+        } else{
58 58
             if ($this->checkPass($password,$user->password)) {
59 59
                 $_SESSION['user']['user_id'] = $user->id;
60 60
                 $_SESSION['user']['mobile'] = $user->mobile;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
                     'type'=>'success',
63 63
                     'message'=> 'Logined',
64 64
                 ];
65
-            }else{
65
+            } else{
66 66
                 return [
67 67
                     'type'=>'error',
68 68
                     'message'=> 'password mismatch',
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                 'type'=>'success',
99 99
                 'message'=> 'Logined',
100 100
             ];
101
-        }else{
101
+        } else{
102 102
             return [
103 103
                 'type'=>'error',
104 104
                 'message'=> 'problem!',
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -17,21 +17,21 @@  discard block
 block discarded – undo
17 17
 {
18 18
     public function user()
19 19
     {
20
-        if(!isset($_SESSION['user']) && json_decode($_COOKIE['user'],true) !== null){
21
-            $_SESSION['user'] = json_decode($_COOKIE['user'],true);
20
+        if (!isset($_SESSION['user']) && json_decode($_COOKIE['user'], true) !== null) {
21
+            $_SESSION['user'] = json_decode($_COOKIE['user'], true);
22 22
         }
23 23
         return UserDataAccess::getUserById(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
24 24
     }
25 25
 
26 26
     public function hasRole($roleName)
27 27
     {
28
-        if(!self::check()){
28
+        if (!self::check()) {
29 29
             return false;
30 30
         }
31
-        $userRoles =  UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
31
+        $userRoles = UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
32 32
         $hasAccess = false;
33
-        foreach ($userRoles as $role){
34
-            if($role->name == $roleName){
33
+        foreach ($userRoles as $role) {
34
+            if ($role->name == $roleName) {
35 35
                 $hasAccess = true;
36 36
                 break;
37 37
             }
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function check()
44 44
     {
45
-        if(!isset($_SESSION['user']) && json_decode($_COOKIE['user'],true) !== null){
46
-            $_SESSION['user'] = json_decode($_COOKIE['user'],true);
45
+        if (!isset($_SESSION['user']) && json_decode($_COOKIE['user'], true) !== null) {
46
+            $_SESSION['user'] = json_decode($_COOKIE['user'], true);
47 47
         }
48 48
         return isset($_SESSION['user']['user_id']);
49 49
     }
50 50
 
51
-    public function attempt(string $loginField,string $password)
51
+    public function attempt(string $loginField, string $password)
52 52
     {
53 53
         $user = UserDataAccess::getUserLoginField($loginField);
54 54
         if (!$user) {
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
             ];
59 59
         }
60 60
         $setting = Config::get('settings.auth');
61
-        if(1 || $setting['2step']){
62
-            return $this->twoStepAuth($loginField,$password);
63
-        }else{
64
-            if ($this->checkPass($password,$user->password)) {
61
+        if (1 || $setting['2step']) {
62
+            return $this->twoStepAuth($loginField, $password);
63
+        }else {
64
+            if ($this->checkPass($password, $user->password)) {
65 65
                 $_SESSION['user']['user_id'] = $user->id;
66 66
                 $_SESSION['user']['mobile'] = $user->mobile;
67 67
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                     'type'=>'success',
76 76
                     'message'=> 'Logined',
77 77
                 ];
78
-            }else{
78
+            }else {
79 79
                 return [
80 80
                     'type'=>'error',
81 81
                     'message'=> 'password mismatch',
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 
91 91
 
92 92
 
93
-    public function checkPass($password,$database_pass)
93
+    public function checkPass($password, $database_pass)
94 94
     {
95
-        if($database_pass == $password){
95
+        if ($database_pass == $password) {
96 96
             return true;
97 97
         }
98 98
         return false;
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
     }
101 101
 
102 102
 
103
-    public function twoStepAuth(string $loginField,string $password)
103
+    public function twoStepAuth(string $loginField, string $password)
104 104
     {
105 105
         $user = UserDataAccess::getUserLoginField($loginField);
106
-        if(UserDataAccess::checkToken($password,$loginField)){
106
+        if (UserDataAccess::checkToken($password, $loginField)) {
107 107
             $_SESSION['user']['user_id'] = $user->id;
108 108
             $_SESSION['user']['mobile'] = $user->mobile;
109 109
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                 'type'=>'success',
118 118
                 'message'=> 'Logined',
119 119
             ];
120
-        }else{
120
+        }else {
121 121
             return [
122 122
                 'type'=>'error',
123 123
                 'message'=> 'problem!',
Please login to merge, or discard this patch.
config/view.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php 
2 2
 return [
3 3
     // Renderer settings
4
-	'view' => [
5
-	    'blade_template_path' => '../app/View/', // String or array of multiple paths
6
-	    'blade_cache_path'    => '../app/View/cache', // Mandatory by default, though could probably turn caching off for development
7
-	    'template'    => 'blade', // template name
8
-	],
4
+    'view' => [
5
+        'blade_template_path' => '../app/View/', // String or array of multiple paths
6
+        'blade_cache_path'    => '../app/View/cache', // Mandatory by default, though could probably turn caching off for development
7
+        'template'    => 'blade', // template name
8
+    ],
9 9
 ];
10 10
 ?>
Please login to merge, or discard this patch.
bootstrap/middlewares.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if($config['settings']['app']['debug'] && $config['settings']['tracy']['active']) {
2
+if ($config['settings']['app']['debug'] && $config['settings']['tracy']['active']) {
3 3
     $app->add(new RunTracy\Middlewares\TracyMiddleware($app));
4 4
 }
5 5
 
Please login to merge, or discard this patch.
config/tracy.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
         'showSlimEnvironmentPanel' => 1,
10 10
         'showSlimRequestPanel' => 1,
11 11
         'showSlimResponsePanel' => 1,
12
-        'showSlimContainer' =>1 ,
12
+        'showSlimContainer' =>1,
13 13
         'showEloquentORMPanel' => 1,
14
-        'showIdiormPanel' => 1,// > 0 mean you enable logging
14
+        'showIdiormPanel' => 1, // > 0 mean you enable logging
15 15
         // but show or not panel you decide in browser in panel selector
16
-        'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name
16
+        'showDoctrinePanel' => 'em', // here also enable logging and you must enter your Doctrine container name
17 17
         // and also as above show or not panel you decide in browser in panel selector
18 18
         'showProfilerPanel' => 1,
19 19
         'showVendorVersionsPanel' => 1,
Please login to merge, or discard this patch.
config/databases.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 return [
3 3
     'databases'=>[
4 4
         'db' => [
5
-            'driver'    => $env(__APP_ROOT__,'DB_DRIVER', 'mysql'),
6
-            'host'      => $env(__APP_ROOT__,'DB_HOST', 'localhost'),
7
-            'database'  => $env(__APP_ROOT__,'DB_NAME', 'cafesaba'),
8
-            'username'  => $env(__APP_ROOT__,'DB_USERNAME', 'root'),
9
-            'password'  => $env(__APP_ROOT__,'DB_PASS', ''),
10
-            'charset'   => $env(__APP_ROOT__,'DB_CHARSET', 'utf8'),
11
-            'collation' => $env(__APP_ROOT__,'DB_COLLATION', 'utf8_unicode_ci'),
12
-            'prefix'    => $env(__APP_ROOT__,'DB_PREFIX', ''),
13
-            'port'      => $env(__APP_ROOT__,'DB_PORT', 3306),
5
+            'driver'    => $env(__APP_ROOT__, 'DB_DRIVER', 'mysql'),
6
+            'host'      => $env(__APP_ROOT__, 'DB_HOST', 'localhost'),
7
+            'database'  => $env(__APP_ROOT__, 'DB_NAME', 'cafesaba'),
8
+            'username'  => $env(__APP_ROOT__, 'DB_USERNAME', 'root'),
9
+            'password'  => $env(__APP_ROOT__, 'DB_PASS', ''),
10
+            'charset'   => $env(__APP_ROOT__, 'DB_CHARSET', 'utf8'),
11
+            'collation' => $env(__APP_ROOT__, 'DB_COLLATION', 'utf8_unicode_ci'),
12
+            'prefix'    => $env(__APP_ROOT__, 'DB_PREFIX', ''),
13
+            'port'      => $env(__APP_ROOT__, 'DB_PORT', 3306),
14 14
         ],
15 15
     ]
16 16
 ];
17 17
\ No newline at end of file
Please login to merge, or discard this patch.
config/phpmig.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 use Illuminate\Database\Capsule\Manager as Capsule;
7 7
 $env = new \Core\Helpers\Env();
8 8
 $config = include 'databases.php';
9
-$capsule   = new Capsule;
9
+$capsule = new Capsule;
10 10
 $capsule->addConnection($config['databases']['db']);
11 11
 $capsule->setAsGlobal();
12 12
 $capsule->bootEloquent();
13 13
 $container = new ArrayObject();
14 14
 $container['phpmig.adapter'] = new Adapter\Illuminate\Database($capsule, 'migrations');
15
-$container['phpmig.migrations_path'] =  'database/migrations';
15
+$container['phpmig.migrations_path'] = 'database/migrations';
16 16
 $container['phpmig.migrations_template_path'] = 'core/resources/templates/create_migration.txt';
17 17
 return $container;
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
config/app.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
     'displayErrorDetails' => true,
6 6
     'app' => [
7 7
         'log_timer' => true,
8
-        'debug'=>true ,
8
+        'debug'=>true,
9 9
         'image' => [
10 10
             'dir' =>  __APP_ROOT__ . 'public/uploads'
11 11
         ],
Please login to merge, or discard this patch.
config/image.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
                 'm' => [400,250,70],
11 11
                 'l'  => [800,600,80],
12 12
                 'thumb'  => [250, 250,80,true],
13
-           ],
13
+            ],
14 14
         ],
15 15
         'category_photo' => [
16 16
             'dimensions' => [
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
                 'l'  => [800,600,80],
19 19
                 'thumb'  => [250, 250,80,true],
20 20
                 's'  => [150, 80,80],
21
-           ],
21
+            ],
22 22
         ],
23 23
         'minquality' => 200 // kamtar az in width va height nemigirim
24 24
     ]
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@
 block discarded – undo
7 7
         'quality'     => 100,
8 8
         'user_photo' => [
9 9
             'dimensions' => [
10
-                'm' => [400,250,70],
11
-                'l'  => [800,600,80],
12
-                'thumb'  => [250, 250,80,true],
10
+                'm' => [400, 250, 70],
11
+                'l'  => [800, 600, 80],
12
+                'thumb'  => [250, 250, 80, true],
13 13
            ],
14 14
         ],
15 15
         'category_photo' => [
16 16
             'dimensions' => [
17
-                'm' => [400,250,70],
18
-                'l'  => [800,600,80],
19
-                'thumb'  => [250, 250,80,true],
20
-                's'  => [150, 80,80],
17
+                'm' => [400, 250, 70],
18
+                'l'  => [800, 600, 80],
19
+                'thumb'  => [250, 250, 80, true],
20
+                's'  => [150, 80, 80],
21 21
            ],
22 22
         ],
23 23
         'minquality' => 200 // kamtar az in width va height nemigirim
Please login to merge, or discard this patch.
core/Functions/general_helpers.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,43 +5,43 @@
 block discarded – undo
5 5
     $dir = scandir($path);
6 6
     $ex_folders = array('..', '.');
7 7
 
8
-    return array_diff($dir,$ex_folders);
8
+    return array_diff($dir, $ex_folders);
9 9
 }
10 10
 
11 11
 
12 12
 /*folder*/
13
-function getImageDirName($photoid, $type = 'user_photo' ,$collectionNum =1000)
13
+function getImageDirName($photoid, $type = 'user_photo', $collectionNum = 1000)
14 14
 {
15 15
     $folderName = null;
16 16
     switch ($type) {
17 17
         case 'user_photo':
18 18
             $folderName = (int) ($photoid / $collectionNum);
19 19
             $folderName++;
20
-            $dir = 'user_photo/'.$folderName.'/';
20
+            $dir = 'user_photo/' . $folderName . '/';
21 21
             break;
22 22
     }
23 23
 
24 24
     if ($folderName) {
25 25
         $folderName = $dir;
26
-    }else{
26
+    }else {
27 27
         $folderName = (int) ($photoid / $collectionNum);
28 28
         $folderName++;
29
-        $folderName = $type.'/'.$folderName.'/';
29
+        $folderName = $type . '/' . $folderName . '/';
30 30
     }
31 31
 
32 32
     return $folderName;
33 33
 }
34 34
 
35
-function getImageFileName($photoid,$fileType='l',$type='user_photo')
35
+function getImageFileName($photoid, $fileType = 'l', $type = 'user_photo')
36 36
 {
37 37
     $fileName = null;
38 38
 
39 39
     switch ($type) {
40 40
         case 'user_photo':
41
-            $fileName = 'user'.(int)$photoid.'-'.$fileType;
41
+            $fileName = 'user' . (int) $photoid . '-' . $fileType;
42 42
         break;
43 43
         case 'category_photo':
44
-            $fileName = 'category'.(int)$photoid.'-'.$fileType;
44
+            $fileName = 'category' . (int) $photoid . '-' . $fileType;
45 45
         break;
46 46
     }
47 47
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 
24 24
     if ($folderName) {
25 25
         $folderName = $dir;
26
-    }else{
26
+    } else{
27 27
         $folderName = (int) ($photoid / $collectionNum);
28 28
         $folderName++;
29 29
         $folderName = $type.'/'.$folderName.'/';
Please login to merge, or discard this patch.