@@ -204,9 +204,11 @@ |
||
204 | 204 | |
205 | 205 | $user = $this->getUserDetailsByEmail($email); |
206 | 206 | |
207 | - if ($user === false) //no user exists |
|
207 | + if ($user === false) { |
|
208 | + //no user exists |
|
208 | 209 | { |
209 | 210 | $response->message = "email doesn't exist, register a new account?"; |
211 | + } |
|
210 | 212 | return $response; |
211 | 213 | } |
212 | 214 |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | //check if email is valid for sanity |
193 | 193 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
194 | 194 | $email = htmlspecialchars($email); |
195 | - throw new BlogocException("invalid email " . $email); |
|
195 | + throw new BlogocException("invalid email ".$email); |
|
196 | 196 | } |
197 | 197 | $sql = $this->baseSqlSelect(); |
198 | 198 | $sql .= " |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->bind(':roles_idroles', 1); //we set to one, should probably get from database and config |
236 | 236 | $this->execute(); |
237 | 237 | |
238 | - return (int)$this->dbh->lastInsertId(); |
|
238 | + return (int) $this->dbh->lastInsertId(); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public function updateUser(\stdClass $user):void |
247 | 247 | { |
248 | - $sql=" |
|
248 | + $sql = " |
|
249 | 249 | UPDATE $this->userTbl |
250 | 250 | SET |
251 | 251 | name=:name, |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | } |
297 | 297 | |
298 | 298 | if ($this->isAccountPasswordBlocked($user)) { |
299 | - $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes"; |
|
299 | + $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes"; |
|
300 | 300 | return $response; |
301 | 301 | } |
302 | 302 |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $twigOptions = []; |
51 | 51 | if (!Config::DEV_ENVIRONMENT) { |
52 | 52 | $twigOptions = [ |
53 | - 'cache' => dirname(__DIR__) . '/Cache' |
|
53 | + 'cache' => dirname(__DIR__).'/Cache' |
|
54 | 54 | ]; |
55 | 55 | } |
56 | - $loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views'); |
|
56 | + $loader = new \Twig_Loader_Filesystem(dirname(__DIR__).'/App/Views'); |
|
57 | 57 | $twig = new \Twig_Environment($loader, $twigOptions); |
58 | 58 | |
59 | 59 | return $twig; |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | if ($this->dbh) { |
69 | 69 | return $this->dbh; |
70 | 70 | } |
71 | - $dsn = "mysql:host=" . Config::DB_HOST . ";dbname=" . Config::DB_NAME . ";charset=utf8"; //Creating the Data Source name |
|
71 | + $dsn = "mysql:host=".Config::DB_HOST.";dbname=".Config::DB_NAME.";charset=utf8"; //Creating the Data Source name |
|
72 | 72 | $opt = [ |
73 | 73 | PDO::ATTR_PERSISTENT => true, |
74 | 74 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
75 | 75 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ |
76 | 76 | ]; |
77 | - $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt);; |
|
77 | + $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt); ; |
|
78 | 78 | return $this->dbh; |
79 | 79 | } |
80 | 80 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getCookie(): Dependency\Cookie |
122 | 122 | { |
123 | - if(!$this->cookie){ |
|
123 | + if (!$this->cookie) { |
|
124 | 124 | $this->cookie = new Cookie(); |
125 | 125 | } |
126 | 126 | return $this->cookie; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | if ($token_value) { |
29 | 29 | $this->token = $token_value; |
30 | - } else { |
|
30 | + }else { |
|
31 | 31 | $this->token = $this->generateToken(); |
32 | 32 | } |
33 | 33 | } |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | $loadModuleObj = $this->getModuleNamespace($loadModule); |
110 | 110 | //Modules must be children of the Module template |
111 | 111 | if (!is_subclass_of($loadModuleObj, 'Core\Modules\Module')) { |
112 | - throw new \ErrorException('Module ' . $loadModuleName . ' must be a sub class of module'); |
|
112 | + throw new \ErrorException('Module '.$loadModuleName.' must be a sub class of module'); |
|
113 | 113 | } |
114 | 114 | $loadedModule = new $loadModuleObj($this->container); |
115 | 115 | //we are not allowed to create public modules, they must be a placeholder ready |
116 | 116 | if (!property_exists($this, $loadModuleName)) { |
117 | - throw new \ErrorException('the protected or private variable of ' . $loadModuleName . ' is not present'); |
|
117 | + throw new \ErrorException('the protected or private variable of '.$loadModuleName.' is not present'); |
|
118 | 118 | } |
119 | 119 | $this->$loadModuleName = $loadedModule; |
120 | 120 | } |
@@ -131,23 +131,23 @@ discard block |
||
131 | 131 | $childClass = new \ReflectionClass(get_class($this)); |
132 | 132 | $childClassNamespace = $childClass->getNamespaceName(); |
133 | 133 | //check in classNameSpace |
134 | - if (class_exists($childClassNamespace . '\\Modules\\' . $loadModule)) { |
|
135 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', $childClassNamespace . '\\' . $loadModule); |
|
136 | - return $childClassNamespace . '\\' . $loadModule; |
|
134 | + if (class_exists($childClassNamespace.'\\Modules\\'.$loadModule)) { |
|
135 | + $this->addToDevHelper('module '.$loadModule.' loaded', $childClassNamespace.'\\'.$loadModule); |
|
136 | + return $childClassNamespace.'\\'.$loadModule; |
|
137 | 137 | } |
138 | 138 | //check in app |
139 | - if (class_exists('App\\Modules\\' . $loadModule)) { |
|
140 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', 'App\\Modules\\' . $loadModule); |
|
141 | - return 'App\\Modules\\' . $loadModule; |
|
139 | + if (class_exists('App\\Modules\\'.$loadModule)) { |
|
140 | + $this->addToDevHelper('module '.$loadModule.' loaded', 'App\\Modules\\'.$loadModule); |
|
141 | + return 'App\\Modules\\'.$loadModule; |
|
142 | 142 | } |
143 | 143 | //check in core, send error popup if overcharged |
144 | - if (class_exists('Core\\Modules\\' . $loadModule)) { |
|
145 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', 'Core\\Modules\\' . $loadModule); |
|
146 | - return 'Core\\Modules\\' . $loadModule; |
|
144 | + if (class_exists('Core\\Modules\\'.$loadModule)) { |
|
145 | + $this->addToDevHelper('module '.$loadModule.' loaded', 'Core\\Modules\\'.$loadModule); |
|
146 | + return 'Core\\Modules\\'.$loadModule; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | //if we are here then no module found |
150 | - throw new \ErrorException('module ' . $loadModule . ' does not exist or not loaded'); |
|
150 | + throw new \ErrorException('module '.$loadModule.' does not exist or not loaded'); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function getView($template) |
173 | 173 | { |
174 | 174 | $twig = $this->container->getTemplate(); |
175 | - return $twig->render($template . '.twig', $this->data); |
|
175 | + return $twig->render($template.'.twig', $this->data); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | $twig = $this->container->getTemplate(); |
201 | - $twig->display($template . '.twig', $this->data); |
|
201 | + $twig->display($template.'.twig', $this->data); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $categories = $categoryModel->getCategories(); |
51 | 51 | foreach ($categories as $category) { |
52 | 52 | $data += [ |
53 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
53 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
54 | 54 | ]; |
55 | 55 | } |
56 | 56 | return $data; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | $session = $this->container->getSession(); |
69 | 69 | |
70 | 70 | $userToken = $cookie->getCookie("rememberMe"); |
71 | - if($userToken && $this->isHexa($userToken)) |
|
71 | + if ($userToken && $this->isHexa($userToken)) |
|
72 | 72 | { |
73 | 73 | //we have a rememberMe Hash, login |
74 | 74 | $rememberedLogin = $rememberedLoginModel->findByToken($userToken); |
75 | - if($rememberedLogin){ |
|
75 | + if ($rememberedLogin) { |
|
76 | 76 | //we have a hash, login |
77 | 77 | $user = $userModel->getUserDetailsById($rememberedLogin->users_idusers); |
78 | 78 | $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $send[$item->name] = $item->value; |
41 | 41 | } |
42 | 42 | |
43 | - if(!$this->slug->isSlugValid($send["categories_slug"])) |
|
43 | + if (!$this->slug->isSlugValid($send["categories_slug"])) |
|
44 | 44 | { |
45 | 45 | $result["success"] = false; |
46 | 46 | $result["errorMessage"] = "Invalid Slug"; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | foreach ($categoryUpdate as $item) { |
74 | 74 | $send[$item->name] = $item->value; |
75 | 75 | } |
76 | - if(!$this->slug->isSlugValid($send["categories_slug"])) |
|
76 | + if (!$this->slug->isSlugValid($send["categories_slug"])) |
|
77 | 77 | { |
78 | 78 | $result["success"] = false; |
79 | 79 | $result["errorMessage"] = "Invalid Slug"; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | die(); |
82 | 82 | } |
83 | 83 | |
84 | - if(!$this->isInt($send["idcategories"])){ |
|
84 | + if (!$this->isInt($send["idcategories"])) { |
|
85 | 85 | $result["success"] = false; |
86 | 86 | $result["errorMessage"] = "Invalid ID"; |
87 | 87 | echo json_encode($result); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $send[$item->name] = $item->value; |
118 | 118 | } |
119 | 119 | |
120 | - if(!$this->isInt($send["idcategories"])){ |
|
120 | + if (!$this->isInt($send["idcategories"])) { |
|
121 | 121 | $result["success"] = false; |
122 | 122 | $result["errorMessage"] = "Invalid ID"; |
123 | 123 | echo json_encode($result); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | { |
27 | 27 | $this->onlyAdmin(); |
28 | 28 | $this->onlyPost(); |
29 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
30 | - $postId = (int)$this->request->getData("postId"); |
|
29 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
30 | + $postId = (int) $this->request->getData("postId"); |
|
31 | 31 | |
32 | 32 | $result = array(); |
33 | 33 | $result["success"] = $this->postModule->setPublished(!$state, $postId); |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | { |
45 | 45 | $this->onlyAdmin(); |
46 | 46 | $this->onlyPost(); |
47 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
48 | - $postId = (int)$this->request->getData("postId"); |
|
47 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
48 | + $postId = (int) $this->request->getData("postId"); |
|
49 | 49 | |
50 | 50 | $result = array(); |
51 | 51 | $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Core\Dependency; |
4 | 4 | |
5 | -class Cookie{ |
|
5 | +class Cookie { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * set a cookie |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function deleteCookie(string $name):void |
23 | 23 | { |
24 | - setcookie($name, "", time()-3600); //expire the cookie |
|
24 | + setcookie($name, "", time() - 3600); //expire the cookie |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -6,7 +6,7 @@ |
||
6 | 6 | use Core\Container; |
7 | 7 | use Core\Model; |
8 | 8 | |
9 | -class RoleModel extends Model{ |
|
9 | +class RoleModel extends Model { |
|
10 | 10 | |
11 | 11 | private $roleTbl; |
12 | 12 |