@@ -5,18 +5,18 @@ discard block |
||
| 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 | /*folder*/ |
| 12 | -function getImageDirName($photoid, $type = 'user_photo' ,$collectionNum =1000) |
|
| 12 | +function getImageDirName($photoid, $type = 'user_photo', $collectionNum = 1000) |
|
| 13 | 13 | { |
| 14 | 14 | $folderName = null; |
| 15 | 15 | switch ($type) { |
| 16 | 16 | case 'user_photo': |
| 17 | 17 | $folderName = (int) ($photoid / $collectionNum); |
| 18 | 18 | $folderName++; |
| 19 | - $dir = 'user_photo/'.$folderName.'/'; |
|
| 19 | + $dir = 'user_photo/' . $folderName . '/'; |
|
| 20 | 20 | break; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | return $folderName; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -function getImageFileName($photoid,$fileType='l',$type='user_photo') |
|
| 30 | +function getImageFileName($photoid, $fileType = 'l', $type = 'user_photo') |
|
| 31 | 31 | { |
| 32 | 32 | $fileName = null; |
| 33 | 33 | |
| 34 | 34 | switch ($type) { |
| 35 | 35 | case 'user_photo': |
| 36 | - $fileName = 'user'.(int)$photoid.'-'.$fileType; |
|
| 36 | + $fileName = 'user' . (int) $photoid . '-' . $fileType; |
|
| 37 | 37 | break; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -2,22 +2,22 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -function route(string $name ,array $params = []) |
|
| 5 | +function route(string $name, array $params = []) |
|
| 6 | 6 | { |
| 7 | 7 | $url = new \Core\Helpers\Url($GLOBALS['container']); |
| 8 | - return $url->get($name , $params); |
|
| 8 | + return $url->get($name, $params); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -function url(string $name ,array $params = []) |
|
| 11 | +function url(string $name, array $params = []) |
|
| 12 | 12 | { |
| 13 | 13 | $url = new \Core\Helpers\Url($GLOBALS['container']); |
| 14 | - return $url->get($name , $params); |
|
| 14 | + return $url->get($name, $params); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // translate |
| 18 | -function trans($key , $replace = []){ |
|
| 18 | +function trans($key, $replace = []) { |
|
| 19 | 19 | $container = $GLOBALS['container']; |
| 20 | - return $container->translator->trans($key,$replace); |
|
| 20 | + return $container->translator->trans($key, $replace); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | function public_path(string $uri = '') { |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $url = new \Core\Helpers\Url($container); |
| 29 | 29 | |
| 30 | - $url_asset = $url->getBasePath($request) .'/'. $uri; |
|
| 30 | + $url_asset = $url->getBasePath($request) . '/' . $uri; |
|
| 31 | 31 | return $url_asset; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function asset(string $uri = '') { |
| 35 | 35 | $url = public_path(); |
| 36 | - $url_asset = $url.'assets/'.$uri; |
|
| 36 | + $url_asset = $url . 'assets/' . $uri; |
|
| 37 | 37 | return $url_asset; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -function get_gravatar( $email, $s = 380, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { |
|
| 40 | +function get_gravatar($email, $s = 380, $d = 'mm', $r = 'g', $img = false, $atts = array()) { |
|
| 41 | 41 | $url = 'https://www.gravatar.com/avatar/'; |
| 42 | - $url .= md5( strtolower( trim( $email ) ) ); |
|
| 42 | + $url .= md5(strtolower(trim($email))); |
|
| 43 | 43 | $url .= "?s=$s&d=$d&r=$r"; |
| 44 | - if ( $img ) { |
|
| 44 | + if ($img) { |
|
| 45 | 45 | $url = '<img src="' . $url . '"'; |
| 46 | - foreach ( $atts as $key => $val ) |
|
| 46 | + foreach ($atts as $key => $val) |
|
| 47 | 47 | $url .= ' ' . $key . '="' . $val . '"'; |
| 48 | 48 | $url .= ' />'; |
| 49 | 49 | } |
@@ -43,8 +43,9 @@ |
||
| 43 | 43 | $url .= "?s=$s&d=$d&r=$r"; |
| 44 | 44 | if ( $img ) { |
| 45 | 45 | $url = '<img src="' . $url . '"'; |
| 46 | - foreach ( $atts as $key => $val ) |
|
| 47 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
| 46 | + foreach ( $atts as $key => $val ) { |
|
| 47 | + $url .= ' ' . $key . '="' . $val . '"'; |
|
| 48 | + } |
|
| 48 | 49 | $url .= ' />'; |
| 49 | 50 | } |
| 50 | 51 | return $url; |
@@ -17,12 +17,12 @@ |
||
| 17 | 17 | } |
| 18 | 18 | $i=0; |
| 19 | 19 | foreach($filesInConfig as $config_file){ |
| 20 | - if($config_file === 'phpmig.php'){continue;} |
|
| 21 | - $file[$i] = include_once __APP_ROOT__.'config/'.$config_file; |
|
| 22 | - if(is_array($file[$i])){ |
|
| 23 | - $configs = array_merge($configs, $file[$i]); |
|
| 24 | - $i++; |
|
| 25 | - } |
|
| 20 | + if($config_file === 'phpmig.php'){continue;} |
|
| 21 | + $file[$i] = include_once __APP_ROOT__.'config/'.$config_file; |
|
| 22 | + if(is_array($file[$i])){ |
|
| 23 | + $configs = array_merge($configs, $file[$i]); |
|
| 24 | + $i++; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | } |
| 28 | 28 | |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -define('__APP_ROOT__',__DIR__ . '/../') ; |
|
| 2 | +define('__APP_ROOT__', __DIR__ . '/../'); |
|
| 3 | 3 | $APPROOT = __APP_ROOT__; |
| 4 | -require __APP_ROOT__.'bootstrap/bootstrap.php'; |
|
| 5 | -require __APP_ROOT__.'vendor/autoload.php'; |
|
| 4 | +require __APP_ROOT__ . 'bootstrap/bootstrap.php'; |
|
| 5 | +require __APP_ROOT__ . 'vendor/autoload.php'; |
|
| 6 | 6 | |
| 7 | 7 | $env = new \Core\Helpers\Env(); |
| 8 | 8 | |
| 9 | 9 | defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
| 10 | 10 | |
| 11 | 11 | /*Dynamic containers in services*/ |
| 12 | -$config_dir = scandir(__APP_ROOT__.'/config/'); |
|
| 12 | +$config_dir = scandir(__APP_ROOT__ . '/config/'); |
|
| 13 | 13 | $ex_config_folders = array('..', '.'); |
| 14 | -$filesInConfig = array_diff($config_dir,$ex_config_folders); |
|
| 14 | +$filesInConfig = array_diff($config_dir, $ex_config_folders); |
|
| 15 | 15 | if (!isset($configs)) { |
| 16 | 16 | $configs = array(); |
| 17 | 17 | } |
| 18 | -$i=0; |
|
| 19 | -foreach($filesInConfig as $config_file){ |
|
| 20 | - if($config_file === 'phpmig.php'){continue;} |
|
| 21 | - $file[$i] = include_once __APP_ROOT__.'config/'.$config_file; |
|
| 22 | - if(is_array($file[$i])){ |
|
| 18 | +$i = 0; |
|
| 19 | +foreach ($filesInConfig as $config_file) { |
|
| 20 | + if ($config_file === 'phpmig.php') {continue; } |
|
| 21 | + $file[$i] = include_once __APP_ROOT__ . 'config/' . $config_file; |
|
| 22 | + if (is_array($file[$i])) { |
|
| 23 | 23 | $configs = array_merge($configs, $file[$i]); |
| 24 | 24 | $i++; |
| 25 | 25 | } |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $config['settings'] = $configs; |
| 30 | -require __APP_ROOT__.'core/Functions/general_helpers.php'; |
|
| 30 | +require __APP_ROOT__ . 'core/Functions/general_helpers.php'; |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | $app = new \Core\App($config); |
| 34 | 34 | |
| 35 | -if($config['settings']['debug'] && !$config['settings']['tracy']['active']){ |
|
| 35 | +if ($config['settings']['debug'] && !$config['settings']['tracy']['active']) { |
|
| 36 | 36 | ini_set('display_errors', 1); |
| 37 | 37 | ini_set('display_startup_errors', 1); |
| 38 | 38 | error_reporting(E_ALL); |
@@ -41,18 +41,18 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | use SlimFacades\Facade; |
| 43 | 43 | // get container app |
| 44 | -require __APP_ROOT__.'bootstrap/dependencies.php'; |
|
| 44 | +require __APP_ROOT__ . 'bootstrap/dependencies.php'; |
|
| 45 | 45 | |
| 46 | -require __APP_ROOT__.'bootstrap/routes.php'; |
|
| 47 | -require __APP_ROOT__.'core/Functions/helpers.php'; |
|
| 46 | +require __APP_ROOT__ . 'bootstrap/routes.php'; |
|
| 47 | +require __APP_ROOT__ . 'core/Functions/helpers.php'; |
|
| 48 | 48 | |
| 49 | -if(php_sapi_name() != 'cli') { |
|
| 50 | - if($config['settings']['debug'] && $config['settings']['tracy']['active']){ |
|
| 49 | +if (php_sapi_name() != 'cli') { |
|
| 50 | + if ($config['settings']['debug'] && $config['settings']['tracy']['active']) { |
|
| 51 | 51 | Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $config['settings']['tracy']['path']); |
| 52 | 52 | } |
| 53 | 53 | Facade::setFacadeApplication($app); |
| 54 | 54 | |
| 55 | - require __APP_ROOT__.'bootstrap/middlewares.php'; |
|
| 55 | + require __APP_ROOT__ . 'bootstrap/middlewares.php'; |
|
| 56 | 56 | |
| 57 | 57 | $app->run(); |
| 58 | 58 | |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | 'displayErrorDetails' => true, |
| 8 | 8 | 'addContentLengthHeader' => false, |
| 9 | 9 | 'determineRouteBeforeAppMiddleware' => true, |
| 10 | - 'debug'=>true , |
|
| 10 | + 'debug'=>true, |
|
| 11 | 11 | 'image' => [ |
| 12 | 12 | 'dir' => $APPROOT . '/public/uploads' |
| 13 | 13 | ], |
@@ -24,15 +24,15 @@ discard block |
||
| 24 | 24 | 'path' => __DIR__ . '/../storage/logs/app.log', |
| 25 | 25 | ], |
| 26 | 26 | 'db' => [ |
| 27 | - 'driver' => $env($APPROOT,'DB_DRIVER', 'mysql'), |
|
| 28 | - 'host' => $env($APPROOT,'DB_HOST', 'localhost'), |
|
| 29 | - 'database' => $env($APPROOT,'DB_NAME', 'cafesaba'), |
|
| 30 | - 'username' => $env($APPROOT,'DB_USERNAME', 'root'), |
|
| 31 | - 'password' => $env($APPROOT,'DB_PASS', ''), |
|
| 32 | - 'charset' => $env($APPROOT,'DB_CHARSET', 'utf8'), |
|
| 33 | - 'collation' => $env($APPROOT,'DB_COLLATION', 'utf8_unicode_ci'), |
|
| 34 | - 'prefix' => $env($APPROOT,'DB_PREFIX', ''), |
|
| 35 | - 'port' => $env($APPROOT,'DB_PORT', 3306), |
|
| 27 | + 'driver' => $env($APPROOT, 'DB_DRIVER', 'mysql'), |
|
| 28 | + 'host' => $env($APPROOT, 'DB_HOST', 'localhost'), |
|
| 29 | + 'database' => $env($APPROOT, 'DB_NAME', 'cafesaba'), |
|
| 30 | + 'username' => $env($APPROOT, 'DB_USERNAME', 'root'), |
|
| 31 | + 'password' => $env($APPROOT, 'DB_PASS', ''), |
|
| 32 | + 'charset' => $env($APPROOT, 'DB_CHARSET', 'utf8'), |
|
| 33 | + 'collation' => $env($APPROOT, 'DB_COLLATION', 'utf8_unicode_ci'), |
|
| 34 | + 'prefix' => $env($APPROOT, 'DB_PREFIX', ''), |
|
| 35 | + 'port' => $env($APPROOT, 'DB_PORT', 3306), |
|
| 36 | 36 | ], |
| 37 | 37 | 'view' => [ |
| 38 | 38 | 'path' => '../app/View', |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | 'showSlimEnvironmentPanel' => 1, |
| 53 | 53 | 'showSlimRequestPanel' => 1, |
| 54 | 54 | 'showSlimResponsePanel' => 1, |
| 55 | - 'showSlimContainer' =>1 , |
|
| 55 | + 'showSlimContainer' =>1, |
|
| 56 | 56 | 'showEloquentORMPanel' => 1, |
| 57 | - 'showIdiormPanel' => 0,// > 0 mean you enable logging |
|
| 57 | + 'showIdiormPanel' => 0, // > 0 mean you enable logging |
|
| 58 | 58 | // but show or not panel you decide in browser in panel selector |
| 59 | - 'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name |
|
| 59 | + 'showDoctrinePanel' => 'em', // here also enable logging and you must enter your Doctrine container name |
|
| 60 | 60 | // and also as above show or not panel you decide in browser in panel selector |
| 61 | 61 | 'showProfilerPanel' => 1, |
| 62 | 62 | 'showVendorVersionsPanel' => 1, |
@@ -10,7 +10,7 @@ |
||
| 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 | ] |
@@ -7,9 +7,9 @@ |
||
| 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 |
@@ -3,15 +3,15 @@ |
||
| 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 |
@@ -7,70 +7,70 @@ |
||
| 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 | } |
@@ -57,14 +57,20 @@ |
||
| 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 | |
@@ -22,13 +22,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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!', |
@@ -54,7 +54,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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!', |
@@ -4,7 +4,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | // monolog |
| 86 | -$container['logger'] = function ($c) { |
|
| 86 | +$container['logger'] = function($c) { |
|
| 87 | 87 | $settings = $c->get('settings')['app']['logger']; |
| 88 | 88 | $logger = new Monolog\Logger($settings['name']); |
| 89 | 89 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | 94 | // not found handler |
| 95 | -$container['notFoundHandler'] = function ($container) { |
|
| 96 | - return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
| 95 | +$container['notFoundHandler'] = function($container) { |
|
| 96 | + return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
| 97 | 97 | return $container['view']->render($response->withStatus(404), '404'); |
| 98 | 98 | }; |
| 99 | 99 | }; |
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | $translator = new \Core\Translator\Translator($container); |
| 104 | 104 | $translator->init(); |
| 105 | 105 | |
| 106 | -$container['translator'] = function () use ($translator) { |
|
| 106 | +$container['translator'] = function() use ($translator) { |
|
| 107 | 107 | return $translator; |
| 108 | 108 | }; |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | // Register provider |
| 112 | -$container['flash'] = function () { |
|
| 112 | +$container['flash'] = function() { |
|
| 113 | 113 | return new \Slim\Flash\Messages(); |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | // |
| 118 | -$container['session'] = function ($container) { |
|
| 118 | +$container['session'] = function($container) { |
|
| 119 | 119 | $setting_session_driver = $container['settings']['session']['driver'] ?? 'session'; |
| 120 | 120 | |
| 121 | 121 | $sessionOBJ = new \Core\Services\Session(); |
| 122 | - $session = $sessionOBJ->init($setting_session_driver) ; |
|
| 122 | + $session = $sessionOBJ->init($setting_session_driver); |
|
| 123 | 123 | return $session; |
| 124 | 124 | }; |
| 125 | 125 | |
@@ -130,17 +130,17 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | // Register Blade View helper |
| 133 | -$container['view'] = function ($container) { |
|
| 133 | +$container['view'] = function($container) { |
|
| 134 | 134 | $messages = $container->flash->getMessages(); |
| 135 | 135 | |
| 136 | - if(!is_dir('../app/View/cache')){ |
|
| 136 | + if (!is_dir('../app/View/cache')) { |
|
| 137 | 137 | @mkdir('../app/View/cache'); |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | |
| 141 | 141 | $viewSettings = $container['settings']['view']; |
| 142 | 142 | return new \Slim\Views\Blade( |
| 143 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
| 143 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
| 144 | 144 | $viewSettings['blade_cache_path'], |
| 145 | 145 | null, |
| 146 | 146 | [ |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | }; |
| 153 | 153 | |
| 154 | 154 | // Register Blade View helper |
| 155 | -$container['json'] = function ($container) { |
|
| 155 | +$container['json'] = function($container) { |
|
| 156 | 156 | return new \Core\Handlers\JsonHandler(); |
| 157 | 157 | }; |
| 158 | 158 | |
| 159 | -$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){ |
|
| 159 | +$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() { |
|
| 160 | 160 | |
| 161 | 161 | return "<?php echo 'Hello Directive'; ?>"; |
| 162 | 162 | }); |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | /*Dynamic containers in services*/ |
| 174 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
| 174 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
| 175 | 175 | $ex_folders = array('..', '.'); |
| 176 | -$filesInServices = array_diff($dir,$ex_folders); |
|
| 176 | +$filesInServices = array_diff($dir, $ex_folders); |
|
| 177 | 177 | |
| 178 | -foreach($filesInServices as $service){ |
|
| 179 | - $content = preg_replace('/.php/','',$service); |
|
| 180 | - $container[$content] = function () use ($content){ |
|
| 181 | - $class = '\\Core\\Services\\'.$content ; |
|
| 178 | +foreach ($filesInServices as $service) { |
|
| 179 | + $content = preg_replace('/.php/', '', $service); |
|
| 180 | + $container[$content] = function() use ($content){ |
|
| 181 | + $class = '\\Core\\Services\\' . $content; |
|
| 182 | 182 | return new $class(); |
| 183 | 183 | }; |
| 184 | 184 | } |