diff --git a/database/yggtracker.mwb b/database/yggtracker.mwb index 9541d33..766ad8c 100644 Binary files a/database/yggtracker.mwb and b/database/yggtracker.mwb differ diff --git a/src/config/app.php.example b/src/config/app.php.example index 7bcc2cf..25ce928 100644 --- a/src/config/app.php.example +++ b/src/config/app.php.example @@ -88,7 +88,10 @@ define('MAGNET_META_TITLE_MIN_LENGTH', 10); define('MAGNET_META_TITLE_MAX_LENGTH', 255); define('MAGNET_META_DESCRIPTION_MIN_LENGTH', 0); -define('MAGNET_META_DESCRIPTION_MAX_LENGTH', 10000); +define('MAGNET_META_DESCRIPTION_MAX_LENGTH', 255); + +define('MAGNET_DESCRIPTION_MIN_LENGTH', 0); +define('MAGNET_DESCRIPTION_MAX_LENGTH', 10000); define('MAGNET_STOP_WORDS_SIMILAR', diff --git a/src/library/database.php b/src/library/database.php index 80d1f28..382f7e8 100644 --- a/src/library/database.php +++ b/src/library/database.php @@ -641,6 +641,17 @@ class Database { return $query->rowCount(); } + public function updateMagnetDescription(int $magnetId, string $description, int $timeUpdated) : int { + + $this->_debug->query->update->total++; + + $query = $this->_db->prepare('UPDATE `magnet` SET `description` = ?, `timeUpdated` = ? WHERE `magnetId` = ?'); + + $query->execute([$description, $timeUpdated, $magnetId]); + + return $query->rowCount(); + } + public function updateMagnetPublic(int $magnetId, bool $public, int $timeUpdated) : int { $this->_debug->query->update->total++; diff --git a/src/public/assets/theme/default/css/framework.css b/src/public/assets/theme/default/css/framework.css index eb5254b..474b35d 100644 --- a/src/public/assets/theme/default/css/framework.css +++ b/src/public/assets/theme/default/css/framework.css @@ -242,17 +242,6 @@ transition: opacity .2s; } -.max-height-220 { - max-height: 220px; - overflow: hidden; - transition: max-height .2s; -} - -*:hover > .max-height-parent-hover-840 { - max-height: 840px; - transition: max-height .2s; -} - .blur-2 { filter: blur(2px); } diff --git a/src/public/edit.php b/src/public/edit.php index e751eaf..7d9759c 100644 --- a/src/public/edit.php +++ b/src/public/edit.php @@ -42,6 +42,15 @@ $response = (object) 'message' => false, ] ], + 'description' => (object) + [ + 'value' => false, + 'valid' => (object) + [ + 'success' => true, + 'message' => false, + ] + ], 'dn' => (object) [ 'value' => false, @@ -211,17 +220,27 @@ else { else { $response->form->metaTitle->valid->success = false; - $response->form->metaTitle->valid->message = sprintf(_('* required, minimum %s-%s chars'), MAGNET_META_TITLE_MIN_LENGTH, MAGNET_META_TITLE_MAX_LENGTH); + $response->form->metaTitle->valid->message = sprintf(_('* required, %s-%s chars'), MAGNET_META_TITLE_MIN_LENGTH, MAGNET_META_TITLE_MAX_LENGTH); } - if (MAGNET_META_DESCRIPTION_MIN_LENGTH <= mb_strlen($_POST['metaDescription']) && MAGNET_META_DESCRIPTION_MAX_LENGTH >= mb_strlen($_POST['metaDescription'])) + if (mb_strlen($_POST['metaDescription']) < MAGNET_META_DESCRIPTION_MIN_LENGTH || mb_strlen($_POST['metaDescription']) > MAGNET_META_DESCRIPTION_MAX_LENGTH) + { + $response->form->metaDescription->valid->success = false; + $response->form->metaDescription->valid->message = sprintf(_('* required, %s-%s chars, %s provided'), MAGNET_META_DESCRIPTION_MIN_LENGTH, MAGNET_META_DESCRIPTION_MAX_LENGTH, mb_strlen($_POST['metaDescription'])); + } + else { $db->updateMagnetMetaDescription($magnet->magnetId, trim(strip_tags(html_entity_decode($_POST['metaDescription']))), time()); } + + if (mb_strlen($_POST['description']) < MAGNET_DESCRIPTION_MIN_LENGTH || mb_strlen($_POST['description']) > MAGNET_DESCRIPTION_MAX_LENGTH) + { + $response->form->description->valid->success = false; + $response->form->description->valid->message = sprintf(_('* required, %s-%s chars, %s provided'), MAGNET_DESCRIPTION_MIN_LENGTH, MAGNET_DESCRIPTION_MAX_LENGTH, mb_strlen($_POST['description'])); + } else { - $response->form->metaDescription->valid->success = false; - $response->form->metaDescription->valid->message = sprintf(_('* required, minimum %s-%s chars'), MAGNET_META_DESCRIPTION_MIN_LENGTH, MAGNET_META_DESCRIPTION_MAX_LENGTH); + $db->updateMagnetDescription($magnet->magnetId, trim(strip_tags(html_entity_decode($_POST['description']))), time()); } // Social @@ -364,6 +383,7 @@ else { if ($response->success && $response->form->metaTitle->valid->success && $response->form->metaDescription->valid->success && + $response->form->description->valid->success && $response->form->tr->valid->success && $response->form->as->valid->success && $response->form->xs->valid->success) @@ -389,6 +409,9 @@ else { // Meta Description $response->form->metaDescription->value = $magnet->metaDescription; + // Description + $response->form->description->value = $magnet->description; + // Magnet settings $response->form->public->value = (bool) $magnet->public; $response->form->comments->value = (bool) $magnet->comments; @@ -517,11 +540,16 @@ else {