@@ -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,14 +68,14 @@ 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 | PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true |
77 | 77 | ]; |
78 | - $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt);; |
|
78 | + $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt); ; |
|
79 | 79 | return $this->dbh; |
80 | 80 | } |
81 | 81 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function getCookie(): Dependency\Cookie |
123 | 123 | { |
124 | - if(!$this->cookie){ |
|
124 | + if (!$this->cookie) { |
|
125 | 125 | $this->cookie = new Cookie(); |
126 | 126 | } |
127 | 127 | return $this->cookie; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | private function checkOriginalAdmin(): bool |
45 | 45 | { |
46 | - $userId = (int)$this->user->userId; |
|
46 | + $userId = (int) $this->user->userId; |
|
47 | 47 | //The admin selector should be disables and not sent so forcing default role |
48 | 48 | $userLockedOut = $this->user->userLockedOut ?? 0; |
49 | 49 | $userRoleSelector = $this->user->userRoleSelector ?? 2; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | //forcing the default values |
63 | - if($userId === 1){ |
|
63 | + if ($userId === 1) { |
|
64 | 64 | $this->user->userRoleSelector = 2; |
65 | 65 | $this->user->userLockedOut = 0; |
66 | 66 | } |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | $this->onlyUser(); |
174 | 174 | $this->onlyPost(); |
175 | 175 | |
176 | - $this->user = (object)$this->request->getDataFull(); |
|
176 | + $this->user = (object) $this->request->getDataFull(); |
|
177 | 177 | $redirectUrl = "/admin"; |
178 | 178 | |
179 | 179 | if ($this->user->userId !== $this->session->get("userId") || isset($this->user->userRoleSelector) || isset($this->user->locked_out)) { |
180 | 180 | //an admin is trying to update a user or form tampered with |
181 | 181 | $this->onlyAdmin(); |
182 | - $redirectUrl = "/admin/home/view-user/" . $this->user->userId; |
|
183 | - } else { |
|
182 | + $redirectUrl = "/admin/home/view-user/".$this->user->userId; |
|
183 | + }else { |
|
184 | 184 | //set the role to the original state for update |
185 | 185 | $beforeUser = $this->userModel->getUserDetailsById($this->user->userId); |
186 | 186 | $this->user->userRoleSelector = $beforeUser->roles_idroles; |
@@ -35,7 +35,7 @@ |
||
35 | 35 | $this->config = $this->siteConfig->getSiteConfig(); |
36 | 36 | $this->userModel = new UserModel($this->container); |
37 | 37 | $this->postModel = new PostModel($this->container); |
38 | - if($this->auth->isuser()) |
|
38 | + if ($this->auth->isuser()) |
|
39 | 39 | { |
40 | 40 | $this->data["user"] = $this->userModel->getUserDetailsById($this->session->get("userId")); |
41 | 41 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | if (!$this->configModel->updateConfig($update->name, $update->value)) { |
44 | 44 | $result['success'] = false; |
45 | 45 | $result['errorId'][] = $update->name; |
46 | - } else { |
|
46 | + }else { |
|
47 | 47 | $result['successId'][] = $update->name; |
48 | 48 | } |
49 | 49 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // Create the Transport for mail sending |
27 | 27 | //$config = $this->siteConfig->getSiteConfig(); |
28 | 28 | $this->transport = (new Swift_SmtpTransport($this->siteConfig["SMTP_server"], |
29 | - (int)$this->siteConfig["SMTP_port"])) |
|
29 | + (int) $this->siteConfig["SMTP_port"])) |
|
30 | 30 | ->setUsername($this->siteConfig["SMTP_user"]) |
31 | 31 | ->setPassword($this->siteConfig["SMTP_pass"]); |
32 | 32 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | public function sendResetPasswordMail(string $to, string $token, int $userId) |
69 | 69 | { |
70 | 70 | $url = $this->container->getRequest()->getBaseUrl(); |
71 | - $url .= "password/reset/get?token=" . $token; |
|
72 | - $url .= "&userId=" . $userId; |
|
71 | + $url .= "password/reset/get?token=".$token; |
|
72 | + $url .= "&userId=".$userId; |
|
73 | 73 | |
74 | - $message = "<h1>Message from <a href='" . $this->container->getRequest()->getBaseUrl() . "'>" . $this->siteConfig["site_name"] . "</a></h1>"; |
|
75 | - $message .= "<p>You have asked to reset your password, please click <a href=\"" . $url . "\">Here</a> to define a new password</p>"; |
|
74 | + $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>"; |
|
75 | + $message .= "<p>You have asked to reset your password, please click <a href=\"".$url."\">Here</a> to define a new password</p>"; |
|
76 | 76 | |
77 | 77 | $this->send($to, "Define New Password", $message); |
78 | 78 | } |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | public function sendNewPasswordMail(string $to, string $token, int $userId) |
87 | 87 | { |
88 | 88 | $url = $this->container->getRequest()->getBaseUrl(); |
89 | - $url .= "password/reset/get?token=" . $token; |
|
90 | - $url .= "&userId=" . $userId; |
|
91 | - $message = "<h1>Message from <a href='" . $this->container->getRequest()->getBaseUrl() . "'>" . $this->siteConfig["site_name"] . "</a></h1>"; |
|
89 | + $url .= "password/reset/get?token=".$token; |
|
90 | + $url .= "&userId=".$userId; |
|
91 | + $message = "<h1>Message from <a href='".$this->container->getRequest()->getBaseUrl()."'>".$this->siteConfig["site_name"]."</a></h1>"; |
|
92 | 92 | $message .= "<h2>Welcome to the site</h2>"; |
93 | - $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"" . $url . "\">Create your new password</a></p>"; |
|
93 | + $message .= "<p>You have sucsessfuly created an account, now all you need to do is <a href=\"".$url."\">Create your new password</a></p>"; |
|
94 | 94 | $message .= "<p>Have fun</p>"; |
95 | 95 | |
96 | - $this->send($to, "Define Password at " . $this->siteConfig["site_name"], $message); |
|
96 | + $this->send($to, "Define Password at ".$this->siteConfig["site_name"], $message); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $categories = $this->categoryModel->getCategories(); |
61 | 61 | foreach ($categories as $category) { |
62 | 62 | $data += [ |
63 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
63 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
64 | 64 | ]; |
65 | 65 | } |
66 | 66 | return $data; |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | $session = $this->container->getSession(); |
77 | 77 | $userToken = $cookie->getCookie("rememberMe"); |
78 | 78 | |
79 | - if($userToken && $this->isHexa($userToken)) |
|
79 | + if ($userToken && $this->isHexa($userToken)) |
|
80 | 80 | { |
81 | 81 | //we have a rememberMe Hash, login |
82 | 82 | $rememberedLogin = $this->rememberedLoginModel->findByToken($userToken); |
83 | - if($rememberedLogin){ |
|
83 | + if ($rememberedLogin) { |
|
84 | 84 | //we have a hash, login |
85 | 85 | $user = $this->userModel->getUserDetailsById($rememberedLogin->users_idusers); |
86 | 86 | $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use HTMLPurifier; |
9 | 9 | use HTMLPurifier_Config; |
10 | 10 | |
11 | -class CommentModel extends Model{ |
|
11 | +class CommentModel extends Model { |
|
12 | 12 | |
13 | 13 | private $commentTbl; |
14 | 14 | private $userTbl; |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | * @return int |
167 | 167 | * @throws \Exception |
168 | 168 | */ |
169 | - public function addComment(int $postId, int $userId, string $comment, bool $admin=false):int |
|
169 | + public function addComment(int $postId, int $userId, string $comment, bool $admin = false):int |
|
170 | 170 | { |
171 | 171 | $comment = $this->purifyHtml($comment); |
172 | - $sql=" |
|
172 | + $sql = " |
|
173 | 173 | INSERT INTO $this->commentTbl (users_idusers, posts_idposts, comment, approved, comment_date) |
174 | 174 | VALUES (:userId, :postId, :comment, :approved, NOW();) |
175 | 175 | "; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $this->bind(':approved', $admin); |
181 | 181 | |
182 | 182 | $this->execute(); |
183 | - return (int)$this->dbh->lastInsertId(); |
|
183 | + return (int) $this->dbh->lastInsertId(); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | { |
213 | 213 | $comment = $this->purifyHtml($comment); |
214 | 214 | |
215 | - $sql=" |
|
215 | + $sql = " |
|
216 | 216 | UPDATE $this->commentTbl |
217 | 217 | SET |
218 | 218 | comment = :comment, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $table = $reflect->getShortName(); //this is to only get the model name, otherwise we get the full namespace |
160 | 160 | //since our models all end with Model, we should remove it. |
161 | 161 | $table = $this->removeFromEnd($table, 'Model'); |
162 | - $table = $table . 's'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
162 | + $table = $table.'s'; //adding the s since the table should be plural. Might be some special case where the plural isn't just with an s |
|
163 | 163 | $table = strtolower($table); //the database names are in lowercase |
164 | 164 | } |
165 | 165 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | //if we are here, then table doesn't exist, check for view |
185 | - $view = 'v_' . $table; |
|
185 | + $view = 'v_'.$table; |
|
186 | 186 | $stmt->bindValue(':table', $view, PDO::PARAM_STR); |
187 | 187 | $stmt->execute(); |
188 | 188 | $exists = $stmt->rowCount() > 0; //will return 1 if table exists or 0 if non existant |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | protected function getTablePrefix($table) |
207 | 207 | { |
208 | 208 | if (Config::TABLE_PREFIX != '') { |
209 | - $table = Config::TABLE_PREFIX . '_' . $table; |
|
209 | + $table = Config::TABLE_PREFIX.'_'.$table; |
|
210 | 210 | } |
211 | 211 | return $table; |
212 | 212 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | protected function getRowById($rowId, $table = null) |
276 | 276 | { |
277 | 277 | $tableName = $this->getTable($table); |
278 | - $idName = 'id' . str_replace(Config::TABLE_PREFIX."_","",$tableName); |
|
278 | + $idName = 'id'.str_replace(Config::TABLE_PREFIX."_", "", $tableName); |
|
279 | 279 | $sql = "SELECT * FROM $tableName WHERE $idName = :rowId"; |
280 | 280 | $this->query($sql); |
281 | 281 | $this->bind(':rowId', $rowId); |