@@ -7,8 +7,6 @@ |
||
| 7 | 7 | use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; |
| 8 | 8 | use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; |
| 9 | 9 | use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; |
| 10 | -use phpFastCache\CacheManager; |
|
| 11 | -use phpFastCache\Core\phpFastCache; |
|
| 12 | 10 | |
| 13 | 11 | // define timezone |
| 14 | 12 | date_default_timezone_set(App::$Properties->get('timezone')); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | date_default_timezone_set(App::$Properties->get('timezone')); |
| 15 | 15 | |
| 16 | 16 | return [ |
| 17 | - 'Database' => function () { |
|
| 17 | + 'Database' => function() { |
|
| 18 | 18 | $capsule = new Capsule; |
| 19 | 19 | if (env_name !== 'Install') { |
| 20 | 20 | try { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | try { |
| 36 | 36 | $capsule->connection()->getPdo(); |
| 37 | 37 | } catch (\Exception $e) { |
| 38 | - $instUri = \App::$Alias->scriptUrl . '/install'; |
|
| 38 | + $instUri = \App::$Alias->scriptUrl.'/install'; |
|
| 39 | 39 | \App::$Response->redirect($instUri, true); |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | try { |
| 48 | 48 | $pdo = \App::$Database->connection()->getPdo(); |
| 49 | 49 | $handler = new PdoSessionHandler($pdo, [ |
| 50 | - 'db_table' => App::$Properties->get('database')['prefix'] . 'sessions' |
|
| 50 | + 'db_table' => App::$Properties->get('database')['prefix'].'sessions' |
|
| 51 | 51 | ]); |
| 52 | 52 | } catch (Exception $e) { |
| 53 | - $handler = new NativeFileSessionHandler(root . '/Private/Sessions'); |
|
| 53 | + $handler = new NativeFileSessionHandler(root.'/Private/Sessions'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | $storage = new NativeSessionStorage([ |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | return new Session($storage); |
| 63 | 63 | }, |
| 64 | - 'User' => function () { |
|
| 64 | + 'User' => function() { |
|
| 65 | 65 | return new Apps\ActiveRecord\User(); |
| 66 | 66 | }, |
| 67 | - 'Mailer' => function () { |
|
| 67 | + 'Mailer' => function() { |
|
| 68 | 68 | $mCfg = App::$Properties->get('mail'); |
| 69 | 69 | // initialize swiftmailer transporter |
| 70 | 70 | $transport = (new Swift_SmtpTransport($mCfg['host'], $mCfg['port'])) |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | $swift = (new Swift_Mailer($transport)); |
| 83 | 83 | return \Ffcms\Core\Helper\Mailer::factory($swift, $mCfg['user']); |
| 84 | 84 | }, |
| 85 | - 'Captcha' => function () { |
|
| 85 | + 'Captcha' => function() { |
|
| 86 | 86 | return new Extend\Core\Captcha\Gregwar(); |
| 87 | 87 | }, |
| 88 | - 'Cache' => function () { |
|
| 88 | + 'Cache' => function() { |
|
| 89 | 89 | // initialize symfony cache manager |
| 90 | - $cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter('web', 3600, root . '/Private/Cache'); |
|
| 90 | + $cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter('web', 3600, root.'/Private/Cache'); |
|
| 91 | 91 | return $cache; |
| 92 | 92 | }, |
| 93 | 93 | '_hybridauth' => function() { |
@@ -71,12 +71,14 @@ |
||
| 71 | 71 | ->setUsername($mCfg['user']); |
| 72 | 72 | |
| 73 | 73 | // set auth password if exist |
| 74 | - if ($mCfg['password'] !== null && strlen($mCfg['password']) > 0) |
|
| 75 | - $transport->setPassword($mCfg['password']); |
|
| 74 | + if ($mCfg['password'] !== null && strlen($mCfg['password']) > 0) { |
|
| 75 | + $transport->setPassword($mCfg['password']); |
|
| 76 | + } |
|
| 76 | 77 | |
| 77 | 78 | // set encryption method |
| 78 | - if (\Ffcms\Core\Helper\Type\Arr::in($mCfg['encrypt'], ['tls', 'ssl'])) |
|
| 79 | - $transport->setEncryption($mCfg['encrypt']); |
|
| 79 | + if (\Ffcms\Core\Helper\Type\Arr::in($mCfg['encrypt'], ['tls', 'ssl'])) { |
|
| 80 | + $transport->setEncryption($mCfg['encrypt']); |
|
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | // initialize mailer instance |
| 82 | 84 | $swift = (new Swift_Mailer($transport)); |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use Ffcms\Core\Arch\Widget; |
| 7 | 7 | use Ffcms\Core\Helper\HTML\Listing; |
| 8 | 8 | use Ffcms\Core\Helper\Type\Any; |
| 9 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Class LanguageSwitcher. Show language switched as listing html object |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | foreach ($this->langs as $lang) { |
| 55 | 55 | $items[] = [ |
| 56 | 56 | 'type' => 'link', |
| 57 | - 'link' => App::$Alias->baseUrlNoLang . '/' . $lang . App::$Request->getPathInfo(), |
|
| 57 | + 'link' => App::$Alias->baseUrlNoLang.'/'.$lang.App::$Request->getPathInfo(), |
|
| 58 | 58 | 'text' => '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="flag flag-'.$lang.'" alt="'.$lang.'"/>', |
| 59 | 59 | 'html' => true, |
| 60 | 60 | '!secure' => true |
@@ -6,7 +6,6 @@ |
||
| 6 | 6 | use Extend\Core\Arch\FrontWidget as AbstractWidget; |
| 7 | 7 | use Ffcms\Core\Helper\Type\Any; |
| 8 | 8 | use Ffcms\Core\Traits\ClassTools; |
| 9 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 10 | 9 | use Apps\ActiveRecord\ContentTag as TagRecord; |
| 11 | 10 | |
| 12 | 11 | class Contenttag extends AbstractWidget |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $cfg = $this->getConfigs(); |
| 32 | 32 | // check cache is defined |
| 33 | - if (!$this->cache|| !Any::isInt($this->cache)) { |
|
| 33 | + if (!$this->cache || !Any::isInt($this->cache)) { |
|
| 34 | 34 | $this->cache = $cfg['cache']; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $this->_lang = App::$Request->getLanguage(); |
| 43 | - $this->_cacheName = 'widget.contenttag.' . $this->createStringClassSnapshotHash(); |
|
| 43 | + $this->_cacheName = 'widget.contenttag.'.$this->createStringClassSnapshotHash(); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | use Ffcms\Core\App; |
| 5 | 5 | use Extend\Core\Arch\FrontWidget as Widget; |
| 6 | 6 | use Ffcms\Core\Helper\Type\Any; |
| 7 | -use Ffcms\Core\Helper\Type\Obj; |
|
| 8 | 7 | use Ffcms\Core\Traits\ClassTools; |
| 9 | 8 | use Apps\ActiveRecord\Content; |
| 10 | 9 | |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | |
| 77 | 77 | // render view |
| 78 | 78 | return App::$View->render($this->tpl, [ |
| 79 | - 'records' => $query |
|
| 79 | + 'records' => $query |
|
| 80 | 80 | ]); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -35,15 +35,15 @@ |
||
| 35 | 35 | |
| 36 | 36 | // check cache is defined |
| 37 | 37 | if (!$this->cache || !Any::isInt($this->cache)) { |
| 38 | - $this->cache = (int)$cfg['cache']; |
|
| 38 | + $this->cache = (int) $cfg['cache']; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // check item count is defined |
| 42 | - if (!$this->count|| !Any::isInt($this->count)) { |
|
| 43 | - $this->count = (int)$cfg['count']; |
|
| 42 | + if (!$this->count || !Any::isInt($this->count)) { |
|
| 43 | + $this->count = (int) $cfg['count']; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $this->_cacheName = 'widget.newcontent.' . $this->createStringClassSnapshotHash(); |
|
| 46 | + $this->_cacheName = 'widget.newcontent.'.$this->createStringClassSnapshotHash(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | // check if SAPI client == cli (php built-in dev server) |
| 15 | 15 | if (php_sapi_name() === 'cli-server') { |
| 16 | - $path = root . DIRECTORY_SEPARATOR . ltrim($uriRequest, '/'); |
|
| 16 | + $path = root.DIRECTORY_SEPARATOR.ltrim($uriRequest, '/'); |
|
| 17 | 17 | // if static file exist |
| 18 | 18 | if (is_file($path)) { |
| 19 | 19 | // check if it looks like standalone php script |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | // get configs to prepare posible route to switch environment |
| 30 | -$configs = require(root . '/Private/Config/Default.php'); |
|
| 30 | +$configs = require(root.'/Private/Config/Default.php'); |
|
| 31 | 31 | // remove base path |
| 32 | 32 | $uriRequest = substr($uriRequest, strlen($configs['basePath'])); |
| 33 | 33 | $uriArray = explode('/', $uriRequest); |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | $uriLoader = ucfirst(strtolower(str_replace('.', '', $uriLoader))); |
| 39 | 39 | |
| 40 | 40 | // if loader of interface is available - require it |
| 41 | -if (in_array($uriLoader, $loaderList, true) && file_exists(root . '/Loader/' . $uriLoader . '/index.php')) { |
|
| 42 | - require_once (root . '/Loader/' . $uriLoader . '/index.php'); |
|
| 41 | +if (in_array($uriLoader, $loaderList, true) && file_exists(root.'/Loader/'.$uriLoader.'/index.php')) { |
|
| 42 | + require_once (root.'/Loader/'.$uriLoader.'/index.php'); |
|
| 43 | 43 | } else { // else - try to load default interface |
| 44 | - require_once (root . '/Loader/Front/index.php'); |
|
| 44 | + require_once (root.'/Loader/Front/index.php'); |
|
| 45 | 45 | } |
| 46 | 46 | \ No newline at end of file |
@@ -45,10 +45,10 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | public static function check($user1, $user2) |
| 47 | 47 | { |
| 48 | - $query = self::where(function ($query) use ($user1, $user2) { |
|
| 48 | + $query = self::where(function($query) use ($user1, $user2) { |
|
| 49 | 49 | $query->where('user_id', '=', $user1) |
| 50 | 50 | ->where('target_id', '=', $user2); |
| 51 | - })->orWhere(function ($query) use ($user1, $user2) { |
|
| 51 | + })->orWhere(function($query) use ($user1, $user2) { |
|
| 52 | 52 | $query->where('user_id', '=', $user2) |
| 53 | 53 | ->where('target_id', '=', $user1); |
| 54 | 54 | }); |
@@ -86,15 +86,15 @@ |
||
| 86 | 86 | public function getAnswerCount() |
| 87 | 87 | { |
| 88 | 88 | // check if count is cached |
| 89 | - if (MainApp::$Memory->get('commentpost.answer.count.' . $this->id) !== null) { |
|
| 90 | - return MainApp::$Memory->get('commentpost.answer.count.' . $this->id); |
|
| 89 | + if (MainApp::$Memory->get('commentpost.answer.count.'.$this->id) !== null) { |
|
| 90 | + return MainApp::$Memory->get('commentpost.answer.count.'.$this->id); |
|
| 91 | 91 | } |
| 92 | 92 | // get count from db |
| 93 | 93 | $count = CommentAnswer::where('comment_id', '=', $this->id) |
| 94 | 94 | ->where('moderate', '=', 0) |
| 95 | 95 | ->count(); |
| 96 | 96 | // save in cache |
| 97 | - MainApp::$Memory->set('commentpost.answer.count.' . $this->id, $count); |
|
| 97 | + MainApp::$Memory->set('commentpost.answer.count.'.$this->id, $count); |
|
| 98 | 98 | return $count; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | $this->_content->save(); |
| 77 | 77 | |
| 78 | 78 | // update content author rating |
| 79 | - $authorId = (int)$this->_content->author_id; |
|
| 79 | + $authorId = (int) $this->_content->author_id; |
|
| 80 | 80 | if ($authorId > 0 && App::$User->isExist($authorId)) { |
| 81 | 81 | $authorObject = App::$User->identity($authorId); |
| 82 | 82 | if ($authorObject !== null) { |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | public function check() |
| 49 | 49 | { |
| 50 | 50 | // check if user is auth'd or guest name is defined |
| 51 | - if (!App::$User->isAuth() && ((int)$this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
| 51 | + if (!App::$User->isAuth() && ((int) $this->_configs['guestAdd'] !== 1 || Str::length($this->guestName) < 2)) { |
|
| 52 | 52 | throw new JsonException(__('Guest name is not defined')); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // guest moderation |
| 56 | - if (!App::$User->isAuth() && (bool)$this->_configs['guestModerate']) { |
|
| 56 | + if (!App::$User->isAuth() && (bool) $this->_configs['guestModerate']) { |
|
| 57 | 57 | $captcha = App::$Request->request->get('captcha'); |
| 58 | 58 | if (!App::$Captcha->validate($captcha)) { |
| 59 | 59 | throw new JsonException(__('Captcha is incorrect! Click on image to refresh and try again')); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // check if message length is correct |
| 69 | - if (Str::length($this->message) < (int)$this->_configs['minLength'] || Str::length($this->message) > (int)$this->_configs['maxLength']) { |
|
| 69 | + if (Str::length($this->message) < (int) $this->_configs['minLength'] || Str::length($this->message) > (int) $this->_configs['maxLength']) { |
|
| 70 | 70 | throw new JsonException(__('Message length is incorrect. Current: %cur%, min - %min%, max - %max%', [ |
| 71 | 71 | 'cur' => Str::length($this->message), |
| 72 | 72 | 'min' => $this->_configs['minLength'], |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | $record->lang = App::$Request->getLanguage(); |
| 112 | 112 | $record->ip = $this->ip; |
| 113 | 113 | // check if premoderation is enabled and user is guest |
| 114 | - if ((bool)$this->_configs['guestModerate'] && $this->_userId < 1) { |
|
| 114 | + if ((bool) $this->_configs['guestModerate'] && $this->_userId < 1) { |
|
| 115 | 115 | $record->moderate = 1; |
| 116 | 116 | } |
| 117 | 117 | $record->save(); |
| 118 | 118 | |
| 119 | 119 | // add notification for comment post owner |
| 120 | 120 | $commentPost = $record->post; |
| 121 | - if ($commentPost !== null && (int)$commentPost->user_id !== 0 && (int)$commentPost->user_id !== $this->_userId) { |
|
| 122 | - $notify = new EntityAddNotification((int)$commentPost->user_id); |
|
| 121 | + if ($commentPost !== null && (int) $commentPost->user_id !== 0 && (int) $commentPost->user_id !== $this->_userId) { |
|
| 122 | + $notify = new EntityAddNotification((int) $commentPost->user_id); |
|
| 123 | 123 | $notify->add($commentPost->pathway, EntityAddNotification::MSG_ADD_COMMENTANSWER, [ |
| 124 | 124 | 'snippet' => Text::snippet($this->message, 50), |
| 125 | 125 | 'post' => Text::snippet($commentPost->message, 50) |