Completed
Push — master ( b271b9...07890b )
by Afshin
02:16
created
config/image.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 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
         'minquality' => 200 // kamtar az in width va height nemigirim
16 16
     ]
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@
 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
         'minquality' => 200 // kamtar az in width va height nemigirim
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
@@ -3,15 +3,15 @@
 block discarded – undo
3 3
 return [
4 4
     'databases'=>[
5 5
         'db' => [
6
-            'driver'    => $env($APPROOT,'DB_DRIVER', 'mysql'),
7
-            'host'      => $env($APPROOT,'DB_HOST', 'localhost'),
8
-            'database'  => $env($APPROOT,'DB_NAME', 'cafesaba'),
9
-            'username'  => $env($APPROOT,'DB_USERNAME', 'root'),
10
-            'password'  => $env($APPROOT,'DB_PASS', 'root'),
11
-            'charset'   => $env($APPROOT,'DB_CHARSET', 'utf8'),
12
-            'collation' => $env($APPROOT,'DB_COLLATION', 'utf8_unicode_ci'),
13
-            'prefix'    => $env($APPROOT,'DB_PREFIX', ''),
14
-            'port'      => $env($APPROOT,'DB_PORT', 3306),
6
+            'driver'    => $env($APPROOT, 'DB_DRIVER', 'mysql'),
7
+            'host'      => $env($APPROOT, 'DB_HOST', 'localhost'),
8
+            'database'  => $env($APPROOT, 'DB_NAME', 'cafesaba'),
9
+            'username'  => $env($APPROOT, 'DB_USERNAME', 'root'),
10
+            'password'  => $env($APPROOT, 'DB_PASS', 'root'),
11
+            'charset'   => $env($APPROOT, 'DB_CHARSET', 'utf8'),
12
+            'collation' => $env($APPROOT, 'DB_COLLATION', 'utf8_unicode_ci'),
13
+            'prefix'    => $env($APPROOT, 'DB_PREFIX', ''),
14
+            'port'      => $env($APPROOT, 'DB_PORT', 3306),
15 15
         ],
16 16
     ]
17 17
 ];
18 18
\ No newline at end of file
Please login to merge, or discard this patch.
core/Services/ImageService.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,70 +7,70 @@
 block discarded – undo
7 7
 class ImageService extends _Service
8 8
 {
9 9
 
10
-    public function cropResize($src,$destUrl, $width, $height, $quality = 80,$fileExt  = 'jpg')
10
+    public function cropResize($src, $destUrl, $width, $height, $quality = 80, $fileExt = 'jpg')
11 11
     {
12 12
         $image = GImage::open($src);
13 13
         $image->cropResize($width, $height);
14
-        $destUrl = $destUrl.'.'.$fileExt;
15
-        $image->save($destUrl, $fileExt = 'jpg', $quality );
14
+        $destUrl = $destUrl . '.' . $fileExt;
15
+        $image->save($destUrl, $fileExt = 'jpg', $quality);
16 16
         
17 17
 
18 18
         return $image;
19 19
     }
20 20
 
21
-    public function scaleResize($src,$destUrl, $width, $height, $quality = 80,$fileExt  = 'jpg')
21
+    public function scaleResize($src, $destUrl, $width, $height, $quality = 80, $fileExt = 'jpg')
22 22
     {
23 23
         $image = GImage::open($src);
24 24
         $image->scaleResize($width, $height);
25
-        $destUrl = $destUrl.'.'.$fileExt;
26
-        $image->save($destUrl, $fileExt = 'jpg', $quality );
25
+        $destUrl = $destUrl . '.' . $fileExt;
26
+        $image->save($destUrl, $fileExt = 'jpg', $quality);
27 27
 
28 28
 
29 29
         return $image;
30 30
     }
31 31
 
32
-    public function resize($src,$destUrl, $width, $height, $quality = 80,$fileExt  = 'jpg')
32
+    public function resize($src, $destUrl, $width, $height, $quality = 80, $fileExt = 'jpg')
33 33
     {
34 34
         $image = GImage::open($src);
35 35
         $image->resize($width, $height);
36
-        $destUrl = $destUrl.'.'.$fileExt;
37
-        $image->save($destUrl, $fileExt = 'jpg', $quality );
36
+        $destUrl = $destUrl . '.' . $fileExt;
37
+        $image->save($destUrl, $fileExt = 'jpg', $quality);
38 38
 
39 39
 
40 40
         return $image;
41 41
     }
42 42
 
43
-    public function zoomCrop($src,$destUrl, $width, $height, $quality = 80,$fileExt  = 'jpg')
43
+    public function zoomCrop($src, $destUrl, $width, $height, $quality = 80, $fileExt = 'jpg')
44 44
     {
45 45
         $image = GImage::open($src);
46 46
         $image->zoomCrop($width, $height);
47
-        $destUrl = $destUrl.'.'.$fileExt;
48
-        $image->save($destUrl, $fileExt = 'jpg', $quality );
47
+        $destUrl = $destUrl . '.' . $fileExt;
48
+        $image->save($destUrl, $fileExt = 'jpg', $quality);
49 49
         return $image;
50 50
     }
51 51
 
52
-    public function createPhotos($src,$photoid,$type='user_photo', $dimensions = false)
52
+    public function createPhotos($src, $photoid, $type = 'user_photo', $dimensions = false)
53 53
     {
54 54
         // Get default dimensions
55
-        $dest = realpath('.'.$GLOBALS['settings']['image']['upload_path']);
55
+        $dest = realpath('.' . $GLOBALS['settings']['image']['upload_path']);
56 56
 
57 57
         $defaultDimensions = $dimensions ? $dimensions : $GLOBALS['settings']['image'][$type]['dimensions'];
58 58
         foreach ($defaultDimensions as $keys=>$dimension)
59 59
         {
60
-            if(!isset($dimension[2])) $dimension[2] = 100; // quality
61
-            if(!isset($dimension[4])) $dimension[4] = 'jpg'; // quality
60
+            if (!isset($dimension[2])) $dimension[2] = 100; // quality
61
+            if (!isset($dimension[4])) $dimension[4] = 'jpg'; // quality
62 62
 
63
-            $destUrl = $dest.'/'.getImageDirName($photoid,$type).getImageFileName($photoid,$keys,$type);
63
+            $destUrl = $dest . '/' . getImageDirName($photoid, $type) . getImageFileName($photoid, $keys, $type);
64 64
 
65
-            if(isset($dimension[3]) && $dimension[3] == true){
66
-                $image = $this->zoomCrop($src,trim($destUrl),$dimension[0], $dimension[1], $dimension[2],$dimension[4]);
65
+            if (isset($dimension[3]) && $dimension[3] == true) {
66
+                $image = $this->zoomCrop($src, trim($destUrl), $dimension[0], $dimension[1], $dimension[2], $dimension[4]);
67 67
             }else {
68
-                $image = $this->cropResize($src,trim($destUrl),$dimension[0], $dimension[1], $dimension[2],$dimension[4]);
68
+                $image = $this->cropResize($src, trim($destUrl), $dimension[0], $dimension[1], $dimension[2], $dimension[4]);
69 69
             }
70 70
             
71 71
             // $image = $this->cropResize($src,trim($destUrl),$dimension[0], $dimension[1], $dimension[2],$dimension[4]);
72 72
 
73
-            if($image ){
73
+            if ($image) {
74 74
                 $cropedArr[$keys] = $src;
75 75
             }
76 76
         }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -57,14 +57,20 @@
 block discarded – undo
57 57
         $defaultDimensions = $dimensions ? $dimensions : $GLOBALS['settings']['image'][$type]['dimensions'];
58 58
         foreach ($defaultDimensions as $keys=>$dimension)
59 59
         {
60
-            if(!isset($dimension[2])) $dimension[2] = 100; // quality
61
-            if(!isset($dimension[4])) $dimension[4] = 'jpg'; // quality
60
+            if(!isset($dimension[2])) {
61
+                $dimension[2] = 100;
62
+            }
63
+            // quality
64
+            if(!isset($dimension[4])) {
65
+                $dimension[4] = 'jpg';
66
+            }
67
+            // quality
62 68
 
63 69
             $destUrl = $dest.'/'.getImageDirName($photoid,$type).getImageFileName($photoid,$keys,$type);
64 70
 
65 71
             if(isset($dimension[3]) && $dimension[3] == true){
66 72
                 $image = $this->zoomCrop($src,trim($destUrl),$dimension[0], $dimension[1], $dimension[2],$dimension[4]);
67
-            }else {
73
+            } else {
68 74
                 $image = $this->cropResize($src,trim($destUrl),$dimension[0], $dimension[1], $dimension[2],$dimension[4]);
69 75
             }
70 76
             
Please login to merge, or discard this patch.
core/Services/AuthService.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function hasRole($roleName)
24 24
     {
25
-        if(!self::check()){
25
+        if (!self::check()) {
26 26
             return false;
27 27
         }
28
-        $userRoles =  UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
28
+        $userRoles = UserDataAccess::getUserRoles(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
29 29
         $hasAccess = false;
30
-        foreach ($userRoles as $role){
31
-            if($role->name == $roleName){
30
+        foreach ($userRoles as $role) {
31
+            if ($role->name == $roleName) {
32 32
                 $hasAccess = true;
33 33
                 break;
34 34
             }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         return isset($_SESSION['user']['user_id']);
43 43
     }
44 44
 
45
-    public function attempt(string $loginField,string $password)
45
+    public function attempt(string $loginField, string $password)
46 46
     {
47 47
         $user = UserDataAccess::getUserLoginField($loginField);
48 48
         if (!$user) {
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
             ];
53 53
         }
54 54
         $setting = Config::get('settings.auth');
55
-        if(1 || $setting['2step']){
56
-            return $this->twoStepAuth($loginField,$password);
57
-        }else{
58
-            if ($this->checkPass($password,$user->password)) {
55
+        if (1 || $setting['2step']) {
56
+            return $this->twoStepAuth($loginField, $password);
57
+        }else {
58
+            if ($this->checkPass($password, $user->password)) {
59 59
                 $_SESSION['user']['user_id'] = $user->id;
60 60
                 $_SESSION['user']['mobile'] = $user->mobile;
61 61
                 return [
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',
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
 
80
-    public function checkPass($password,$database_pass)
80
+    public function checkPass($password, $database_pass)
81 81
     {
82
-        if($database_pass == $password){
82
+        if ($database_pass == $password) {
83 83
             return true;
84 84
         }
85 85
         return false;
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
     }
88 88
 
89 89
 
90
-    public function twoStepAuth(string $loginField,string $password)
90
+    public function twoStepAuth(string $loginField, string $password)
91 91
     {
92 92
         $user = UserDataAccess::getUserLoginField($loginField);
93
-        if(UserDataAccess::checkToken($password,$loginField)){
93
+        if (UserDataAccess::checkToken($password, $loginField)) {
94 94
             $_SESSION['user']['user_id'] = $user->id;
95 95
             $_SESSION['user']['mobile'] = $user->mobile;
96 96
 
@@ -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.
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.
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' => 0,// > 0 mean you enable logging
14
+        'showIdiormPanel' => 0, // > 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/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.
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
         'addContentLengthHeader' => false,
7 7
         'determineRouteBeforeAppMiddleware' => true,
8
-        'debug'=>true ,
8
+        'debug'=>true,
9 9
         'image' => [
10 10
             'dir' =>  $APPROOT . '/public/uploads'
11 11
         ],
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.
bootstrap/dependencies.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 $container = $app->getContainer();
5 5
 
6 6
 /* database connection */
7
-$container['db'] = function ($container) {
7
+$container['db'] = function($container) {
8 8
     $db = $container['settings']['databases']['db'];
9 9
     $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'],
10 10
         $db['username'], $db['password']);
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 //
53 53
 
54 54
 
55
-$container['generalErrorHandler'] = function ($container) {
55
+$container['generalErrorHandler'] = function($container) {
56 56
     return new \Core\Handlers\GeneralErrorHandler($container);
57 57
 };
58 58
 
59 59
 
60 60
 // Service factory for the ORM
61
-$container['validator'] = function () {
61
+$container['validator'] = function() {
62 62
     return new App\Validation\Validator();
63 63
 };
64 64
 
65 65
 
66
-$container['eloquent'] = function ($container) {
66
+$container['eloquent'] = function($container) {
67 67
     $db = $container['settings']['databases']['db'];
68 68
 
69 69
     $capsule = new \Illuminate\Database\Capsule\Manager;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 // monolog
86
-$container['logger'] = function ($container) {
86
+$container['logger'] = function($container) {
87 87
     $settings = $container->get('settings')['app']['logger'];
88 88
     $logger = new Monolog\Logger($settings['name']);
89 89
     $logger->pushProcessor(new Monolog\Processor\UidProcessor());
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 
94 94
 
95 95
 // not found handler
96
-$container['notFoundHandler'] = function ($container) {
97
-    return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) {
96
+$container['notFoundHandler'] = function($container) {
97
+    return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) {
98 98
         return $container['view']->render($response->withStatus(404), '404');
99 99
     };
100 100
 };
@@ -104,23 +104,23 @@  discard block
 block discarded – undo
104 104
 $translator = new \Core\Translator\Translator($container);
105 105
 $translator->init();
106 106
 
107
-$container['translator'] = function () use ($translator) {
107
+$container['translator'] = function() use ($translator) {
108 108
     return $translator;
109 109
 };
110 110
 
111 111
 
112 112
 // Register provider
113
-$container['flash'] = function () {
113
+$container['flash'] = function() {
114 114
     return new \Slim\Flash\Messages();
115 115
 };
116 116
 
117 117
 
118 118
 //
119
-$container['session'] = function ($container)  {
119
+$container['session'] = function($container) {
120 120
     $setting_session_driver = $container['settings']['session']['driver'] ?? 'session';
121 121
 
122 122
     $sessionOBJ = new \Core\Services\Session();
123
-    $session = $sessionOBJ->init($setting_session_driver) ;
123
+    $session = $sessionOBJ->init($setting_session_driver);
124 124
     return $session;
125 125
 };
126 126
 
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 
132 132
 
133 133
 // Register Blade View helper
134
-$container['view'] = function ($container) {
134
+$container['view'] = function($container) {
135 135
     $messages = $container->flash->getMessages();
136 136
 
137
-    if(!is_dir('../app/View/cache')){
137
+    if (!is_dir('../app/View/cache')) {
138 138
         @mkdir('../app/View/cache');
139 139
     }
140 140
 
141 141
 
142 142
     $viewSettings = $container['settings']['view'];
143 143
     return new \Slim\Views\Blade(
144
-        [$viewSettings['blade_template_path'].$viewSettings['template']],
144
+        [$viewSettings['blade_template_path'] . $viewSettings['template']],
145 145
         $viewSettings['blade_cache_path'],
146 146
         null,
147 147
         [
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 };
154 154
 
155 155
 // Register Blade View helper
156
-$container['json'] = function ($container) {
156
+$container['json'] = function($container) {
157 157
     return new \Core\Handlers\JsonHandler();
158 158
 };
159 159
 
160
-$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){
160
+$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() {
161 161
 
162 162
     return "<?php echo 'Hello Directive'; ?>";
163 163
 });
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 
173 173
 
174 174
 /*Dynamic containers in services*/
175
-$dir = scandir(__APP_ROOT__.'/core/Services/');
175
+$dir = scandir(__APP_ROOT__ . '/core/Services/');
176 176
 $ex_folders = array('..', '.');
177
-$filesInServices =  array_diff($dir,$ex_folders);
177
+$filesInServices = array_diff($dir, $ex_folders);
178 178
 
179
-foreach($filesInServices as $service){
180
-    $content = preg_replace('/.php/','',$service);
181
-    $container[$content] = function () use ($content){
182
-        $class =  '\\Core\\Services\\'.$content ;
179
+foreach ($filesInServices as $service) {
180
+    $content = preg_replace('/.php/', '', $service);
181
+    $container[$content] = function() use ($content){
182
+        $class = '\\Core\\Services\\' . $content;
183 183
         return new $class();
184 184
     };
185 185
 }
Please login to merge, or discard this patch.