@@ -15,7 +15,7 @@ |
||
15 | 15 | echo "Extracted autoload already exists. Skipping phar extraction as presumably it's already extracted."; |
16 | 16 | } else { |
17 | 17 | $composerPhar = $root . 'composer.phar'; |
18 | - if (! file_exists($composerPhar)) { |
|
18 | + if (!file_exists($composerPhar)) { |
|
19 | 19 | $composer = file_get_contents('https://getcomposer.org/download/latest-stable/composer.phar'); |
20 | 20 | file_put_contents($composerPhar, $composer); |
21 | 21 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $container->set('themesdir', __DIR__ . '/../public/themes/'); |
42 | 42 | |
43 | 43 | // Set settings array in container for use in all routes |
44 | -$container->set('settings', static function () { |
|
44 | +$container->set('settings', static function() { |
|
45 | 45 | $config = file_get_contents(__DIR__ . '/../config/config.json'); |
46 | 46 | return json_decode($config, true); |
47 | 47 | }); |
@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | |
51 | 51 | // Rename config.sample.json to config.json |
52 | 52 | $confDir = $container->get('configdir'); |
53 | -if ((file_exists($confDir . 'config.sample.json')) && (! file_exists($confDir . 'config.json'))) { |
|
53 | +if ((file_exists($confDir . 'config.sample.json')) && (!file_exists($confDir . 'config.json'))) { |
|
54 | 54 | rename($confDir . 'config.sample.json', $confDir . 'config.json'); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Create folders that doesn't exist |
58 | 58 | |
59 | 59 | // Plugins Dir |
60 | -if (! file_exists($container->get('pluginsdir'))) { |
|
60 | +if (!file_exists($container->get('pluginsdir'))) { |
|
61 | 61 | mkdir($container->get('pluginsdir'), 0755, true); |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Pages Dir |
65 | -if (! file_exists($container->get('pagesdir'))) { |
|
65 | +if (!file_exists($container->get('pagesdir'))) { |
|
66 | 66 | mkdir($container->get('pagesdir'), 0755, true); |
67 | 67 | } |
68 | 68 | |
69 | 69 | // Data dir (to store blockchain data) |
70 | -if (! file_exists($container->get('datadir'))) { |
|
70 | +if (!file_exists($container->get('datadir'))) { |
|
71 | 71 | mkdir($container->get('datadir'), 0755, true); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Comments |
75 | -if (! file_exists($container->get('commentsdir'))) { |
|
75 | +if (!file_exists($container->get('commentsdir'))) { |
|
76 | 76 | mkdir($container->get('commentsdir'), 0755, true); |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Create Cache dir only in Production mode |
80 | -if ((! file_exists($container->get('cachedir'))) && ($settings['devMode'] === false)) { |
|
80 | +if ((!file_exists($container->get('cachedir'))) && ($settings['devMode'] === false)) { |
|
81 | 81 | mkdir($container->get('cachedir'), 0755, true); |
82 | 82 | } else { |
83 | 83 | // Flush Cache folder if disabled |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | //AppFactory::setContainer($container); |
106 | 106 | |
107 | 107 | // Set Twig engine for templating |
108 | -$container->set('view', static function () { |
|
108 | +$container->set('view', static function() { |
|
109 | 109 | $settings = json_decode(file_get_contents(__DIR__ . '/../config/config.json'), true); |
110 | 110 | $tpls = [ |
111 | 111 | __DIR__ . '/../resources/views/', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | }); |
131 | 131 | |
132 | 132 | //Set Session engine |
133 | -$container->set('session', static function () { |
|
133 | +$container->set('session', static function() { |
|
134 | 134 | return new \SlimSession\Helper(); |
135 | 135 | }); |
136 | 136 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $actualLink = $link . "{$_SERVER['REQUEST_URI']}"; |
162 | 162 | $installLink = $link . '/prepare'; |
163 | 163 | |
164 | -if ((! file_exists($container->get('password'))) && ($actualLink !== $installLink)) { |
|
164 | +if ((!file_exists($container->get('password'))) && ($actualLink !== $installLink)) { |
|
165 | 165 | header('Location: ' . $installLink); |
166 | 166 | exit; |
167 | 167 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | // Admin routes |
186 | 186 | $app->get('/login', HomeController::class . ':login')->setName('login'); |
187 | 187 | $app->post('/login', HomeController::class . ':loginPost')->setName('login-post'); |
188 | -$app->group('/admin', static function (RouteCollectorProxy $group): void { |
|
188 | +$app->group('/admin', static function(RouteCollectorProxy $group): void { |
|
189 | 189 | $group->get('', AdminController::class . ':adminIndex')->setName('admin'); |
190 | 190 | |
191 | 191 | $group->get('/settings', AdminController::class . ':adminSettings')->setName('admin-settings'); |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | }); |
210 | 210 | |
211 | 211 | // generate routes from static pages |
212 | -$app->group("/pages", function (RouteCollectorProxy $group) { |
|
212 | +$app->group("/pages", function(RouteCollectorProxy $group) { |
|
213 | 213 | |
214 | 214 | //$pagesDir = $this->get('pagesdir'); |
215 | 215 | $pages = preg_grep('~\.(html)$~', scandir(__DIR__ . '/../resources/blog/pages/')); |
216 | 216 | foreach ($pages as $page) { |
217 | 217 | $route = substr($page, 0, strrpos($page, '.')); |
218 | - $group->get('' . $route, function ($request, $response) { |
|
218 | + $group->get('' . $route, function($request, $response) { |
|
219 | 219 | $settings = $this->get('settings'); |
220 | 220 | $uri = $request->getUri(); |
221 | 221 | $route = substr(strrchr($uri, '/'), 1); |
@@ -89,7 +89,7 @@ |
||
89 | 89 | * */ |
90 | 90 | public function install(Request $request, Response $response): Response |
91 | 91 | { |
92 | - if (! file_exists($this->app->get('password'))) { |
|
92 | + if (!file_exists($this->app->get('password'))) { |
|
93 | 93 | $data = $request->getParsedBody(); |
94 | 94 | // Create password file with username and password (signed msg)) |
95 | 95 | $cred = [$data['username'] => $data['passwd']]; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | // Check if comments exists for this post |
68 | 68 | $cmts = $this->app->get('commentsdir') . $permlink . '.comments'; |
69 | - if ((! file_exists($cmts)) || (file_exists($cmts)) && (time() - filemtime($cmts) > 120)) { |
|
69 | + if ((!file_exists($cmts)) || (file_exists($cmts)) && (time() - filemtime($cmts) > 120)) { |
|
70 | 70 | $api = new HiveCondenser($apiConfig); |
71 | 71 | $replies = $api->getContentReplies($article['author'], $permlink); |
72 | 72 | $result = json_encode($replies, JSON_PRETTY_PRINT); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $posts = []; |
111 | 111 | $result = []; |
112 | 112 | |
113 | - if (! isset($tag)) { |
|
113 | + if (!isset($tag)) { |
|
114 | 114 | $result = []; |
115 | 115 | } else { |
116 | 116 | $matches = []; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $passwd = $cred[$author]; |
52 | 52 | |
53 | 53 | /* If sessons keys are not set */ |
54 | - if (! isset($session['sh_author']) || (! isset($session['sh_sign']))) { |
|
54 | + if (!isset($session['sh_author']) || (!isset($session['sh_sign']))) { |
|
55 | 55 | header('Location: /login'); |
56 | 56 | die; |
57 | 57 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $cache_interval = 300; |
88 | 88 | |
89 | 89 | $current_time = time(); |
90 | - if ((! file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
90 | + if ((!file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
91 | 91 | $result = json_encode($api->getAccounts($settings['author']), JSON_PRETTY_PRINT); |
92 | 92 | file_put_contents($accountFile, $result); |
93 | 93 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $cache_interval = 300; |
128 | 128 | |
129 | 129 | $current_time = time(); |
130 | - if ((! file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
130 | + if ((!file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
131 | 131 | $result = json_encode($api->getAccounts($settings['author']), JSON_PRETTY_PRINT); |
132 | 132 | file_put_contents($accountFile, $result); |
133 | 133 | } |
@@ -203,22 +203,22 @@ discard block |
||
203 | 203 | $data = $request->getParsedBody(); |
204 | 204 | $redirect = $data['redirect']; |
205 | 205 | $settings = $this->app->get('settings'); |
206 | - $crosspost = ! isset($data['cross']) ? $settings['crosspost'] : (bool) $data['cross']; |
|
207 | - $devMode = ! isset($data['devel']) ? $settings['devMode'] : (bool) $data['devel']; |
|
208 | - $api = ! isset($data['api']) ? $settings['api'] : $data['api']; |
|
209 | - $displayPosts = ! isset($data['displayedPosts']) ? $settings['displayedPosts'] : (int) $data['displayedPosts']; |
|
210 | - $author = ! isset($data['author']) ? $settings['author'] : $data['author']; |
|
211 | - $title = ! isset($data['title']) ? $settings['title'] : $data['title']; |
|
212 | - $baseline = ! isset($data['baseline']) ? $settings['baseline'] : $data['baseline']; |
|
213 | - $displayType = ! isset($data['displayTypes']) ? $settings['displayType']['type'] : $data['displayTypes']; |
|
214 | - $displayedTag = ! isset($data['tag']) ? $settings['displayType']['tag'] : $data['tag']; |
|
215 | - $socialDesc = ! isset($data['socialDesc']) ? $settings['social']['description'] : $data['socialDesc']; |
|
216 | - $socialImage = ! isset($data['socialImage']) ? $settings['social']['image'] : $data['socialImage']; |
|
217 | - $twitter = ! isset($data['twitter']) ? $settings['social']['twitter'] : $data['twitter']; |
|
218 | - $facebook = ! isset($data['facebook']) ? $settings['social']['facebook'] : $data['facebook']; |
|
219 | - $instagram = ! isset($data['instagram']) ? $settings['social']['instagram'] : $data['instagram']; |
|
220 | - $linkedin = ! isset($data['linkedin']) ? $settings['social']['linkedin'] : $data['linkedin']; |
|
221 | - $language = ! isset($data['lang']) ? $settings['lang'] : $data['lang']; |
|
206 | + $crosspost = !isset($data['cross']) ? $settings['crosspost'] : (bool)$data['cross']; |
|
207 | + $devMode = !isset($data['devel']) ? $settings['devMode'] : (bool)$data['devel']; |
|
208 | + $api = !isset($data['api']) ? $settings['api'] : $data['api']; |
|
209 | + $displayPosts = !isset($data['displayedPosts']) ? $settings['displayedPosts'] : (int)$data['displayedPosts']; |
|
210 | + $author = !isset($data['author']) ? $settings['author'] : $data['author']; |
|
211 | + $title = !isset($data['title']) ? $settings['title'] : $data['title']; |
|
212 | + $baseline = !isset($data['baseline']) ? $settings['baseline'] : $data['baseline']; |
|
213 | + $displayType = !isset($data['displayTypes']) ? $settings['displayType']['type'] : $data['displayTypes']; |
|
214 | + $displayedTag = !isset($data['tag']) ? $settings['displayType']['tag'] : $data['tag']; |
|
215 | + $socialDesc = !isset($data['socialDesc']) ? $settings['social']['description'] : $data['socialDesc']; |
|
216 | + $socialImage = !isset($data['socialImage']) ? $settings['social']['image'] : $data['socialImage']; |
|
217 | + $twitter = !isset($data['twitter']) ? $settings['social']['twitter'] : $data['twitter']; |
|
218 | + $facebook = !isset($data['facebook']) ? $settings['social']['facebook'] : $data['facebook']; |
|
219 | + $instagram = !isset($data['instagram']) ? $settings['social']['instagram'] : $data['instagram']; |
|
220 | + $linkedin = !isset($data['linkedin']) ? $settings['social']['linkedin'] : $data['linkedin']; |
|
221 | + $language = !isset($data['lang']) ? $settings['lang'] : $data['lang']; |
|
222 | 222 | $newSettings = [ |
223 | 223 | 'author' => $author, |
224 | 224 | 'title' => $title, |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | 'crosspost' => $crosspost, |
241 | 241 | 'api' => $api, |
242 | 242 | 'devMode' => $devMode, |
243 | - 'displayedPosts' => (int) $displayPosts, |
|
243 | + 'displayedPosts' => (int)$displayPosts, |
|
244 | 244 | ]; |
245 | 245 | $file = json_encode($newSettings, JSON_PRETTY_PRINT); |
246 | 246 | // Create array from config file |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | public function saveTheme(string $theme, Response $response): Response |
264 | 264 | { |
265 | 265 | $settings = $this->app->get('settings'); |
266 | - if (! isset($theme)) { |
|
266 | + if (!isset($theme)) { |
|
267 | 267 | return $response->withHeader('Location', '/admin/themes')->withStatus(302); |
268 | 268 | } |
269 | 269 | $settings['theme'] = $theme; |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $file = $this->app->get('blogfile'); |
50 | 50 | |
51 | 51 | // if the JSON file doesn't exist or if it's old, take it from API |
52 | - if (! file_exists($file) || (time() - filemtime($file) > 120)) { |
|
52 | + if (!file_exists($file) || (time() - filemtime($file) > 120)) { |
|
53 | 53 | // Prepare API call according to displayed posts type |
54 | 54 | $displayType = $settings['displayType']['type']; |
55 | 55 | if ($displayType === 'author') { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /* |
56 | 56 | * Get Hive engine tokens from account |
57 | 57 | */ |
58 | - if ((! file_exists($heFile)) || ($current_time - filemtime($heFile) > $cache_interval)) { |
|
58 | + if ((!file_exists($heFile)) || ($current_time - filemtime($heFile) > $cache_interval)) { |
|
59 | 59 | $config = [ |
60 | 60 | 'debug' => false, |
61 | 61 | 'heNode' => 'api.hive-engine.com/rpc', |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | ]; |
81 | 81 | $api = new HiveCondenser($apiConfig); |
82 | 82 | |
83 | - if ((! file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
83 | + if ((!file_exists($accountFile)) || ($current_time - filemtime($accountFile) > $cache_interval)) { |
|
84 | 84 | $result = json_encode($api->getAccounts($settings['author']), JSON_PRETTY_PRINT); |
85 | 85 | file_put_contents($accountFile, $result); |
86 | 86 | } |
87 | 87 | |
88 | - if ((! file_exists($bcFile)) || ($current_time - filemtime($bcFile) > 600)) { |
|
88 | + if ((!file_exists($bcFile)) || ($current_time - filemtime($bcFile) > 600)) { |
|
89 | 89 | $result = json_encode($api->getDynamicGlobalProperties(), JSON_PRETTY_PRINT); |
90 | 90 | file_put_contents($bcFile, $result); |
91 | 91 | } |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | */ |
98 | 98 | $bcVars = json_decode(file_get_contents($bcFile), true); |
99 | 99 | $vests = []; |
100 | - $vests['tvfh'] = (float) $bcVars['total_vesting_fund_hive']; |
|
101 | - $vests['tvs'] = (float) $bcVars['total_vesting_shares']; |
|
100 | + $vests['tvfh'] = (float)$bcVars['total_vesting_fund_hive']; |
|
101 | + $vests['tvs'] = (float)$bcVars['total_vesting_shares']; |
|
102 | 102 | $vests['totalVests'] = $vests['tvfh'] / $vests['tvs']; |
103 | - $vests['userHP'] = round((float) $account[0]['vesting_shares'] * $vests['totalVests'], 3); |
|
104 | - $vests['delegHP'] = round((float) $account[0]['delegated_vesting_shares'] * $vests['totalVests'], 3); |
|
103 | + $vests['userHP'] = round((float)$account[0]['vesting_shares'] * $vests['totalVests'], 3); |
|
104 | + $vests['delegHP'] = round((float)$account[0]['delegated_vesting_shares'] * $vests['totalVests'], 3); |
|
105 | 105 | |
106 | 106 | /* |
107 | 107 | * Just render the view with vars |