@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | use Core\Container; |
| 10 | 10 | use Core\Traits\StringFunctions; |
| 11 | 11 | |
| 12 | -class Comments extends AdminController{ |
|
| 12 | +class Comments extends AdminController { |
|
| 13 | 13 | |
| 14 | 14 | use StringFunctions; |
| 15 | 15 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | //update comment |
| 117 | - if($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"])) |
|
| 117 | + if ($this->commentModel->update($commentId, $comment["commentTextArea"], $comment["commentApproved"])) |
|
| 118 | 118 | { |
| 119 | 119 | $this->alertBox->setAlert("Comment updated"); |
| 120 | 120 | } |
@@ -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; |
@@ -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 |
@@ -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); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | if (!$this->configModel->updateConfig($update->name, $update->value)) { |
| 48 | 48 | $result['success'] = false; |
| 49 | 49 | $result['errorId'][] = $update->name; |
| 50 | - } else { |
|
| 50 | + }else { |
|
| 51 | 51 | $result['successId'][] = $update->name; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | * Send a test mail |
| 60 | 60 | * @throws JsonException |
| 61 | 61 | */ |
| 62 | - public function testMail(){ |
|
| 62 | + public function testMail() { |
|
| 63 | 63 | $this->onlyAdmin(); |
| 64 | 64 | $this->onlyPost(); |
| 65 | 65 | $result = array(); |
| 66 | 66 | $result['success'] = false; |
| 67 | - try{ |
|
| 67 | + try { |
|
| 68 | 68 | $this->sendMail->sendTestMail(); |
| 69 | 69 | $result['success'] = true; |
| 70 | - }catch (Swift_TransportException $e) { |
|
| 70 | + } catch (Swift_TransportException $e) { |
|
| 71 | 71 | $result['success'] = false; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -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,14 +86,14 @@ 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 | /** |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | die(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if(!$this->categoryModel->isCategorySlugUnique($send["categories_slug"])) |
|
| 54 | + if (!$this->categoryModel->isCategorySlugUnique($send["categories_slug"])) |
|
| 55 | 55 | { |
| 56 | 56 | $result["success"] = false; |
| 57 | 57 | $result["errorMessage"] = "Slug is not unique"; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $this->query($sql); |
| 91 | 91 | $this->bind(":tag", $tag); |
| 92 | 92 | $this->execute(); |
| 93 | - return (int)$this->dbh->lastInsertId(); |
|
| 93 | + return (int) $this->dbh->lastInsertId(); |
|
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function getTags(): array |
| 120 | 120 | { |
| 121 | - if($this->countTags() > 0) |
|
| 121 | + if ($this->countTags() > 0) |
|
| 122 | 122 | { |
| 123 | 123 | return $this->getResultSet($this->tagTbl); |
| 124 | 124 | } |