From 0fed16621a9f45ad87dbb3266f3a6c8f7839392f Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 10 May 2023 14:47:33 +0300 Subject: [PATCH] fix mime content type update --- crontab/crawler.php | 12 ++++++------ library/mysql.php | 9 --------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/crontab/crawler.php b/crontab/crawler.php index 150ad14..3b9343b 100644 --- a/crontab/crawler.php +++ b/crontab/crawler.php @@ -233,15 +233,17 @@ try { // Skip page processing non 200 code if (200 != $curl->getCode()) { - $db->updateHostPageHttpCode($queueHostPage->hostPageId, $curl->getCode(), time()); - $hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time()); continue; } - // Skip page processing on MIME type not provided - if (!$contentType = $curl->getContentType()) { + // Validate MIME content type + if ($contentType = $curl->getContentType()) { + + $db->updateHostPageMime($queueHostPage->hostPageId, Filter::mime($contentType), time()); + + } else { $hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time()); @@ -261,8 +263,6 @@ try { if ($hostPageBanned) { - $db->updateHostPageMime($queueHostPage->hostPageId, Filter::mime($contentType), time()); - $hostPagesBanned += $db->updateHostPageTimeBanned($queueHostPage->hostPageId, time()); continue; diff --git a/library/mysql.php b/library/mysql.php index 605b892..981b6b7 100644 --- a/library/mysql.php +++ b/library/mysql.php @@ -276,15 +276,6 @@ class MySQL { return $query->rowCount(); } - public function updateHostPageHttpCode(int $hostPageId, int $httpCode) { - - $query = $this->_db->prepare('UPDATE `hostPage` SET `httpCode` = ? WHERE `hostPageId` = ? LIMIT 1'); - - $query->execute([$httpCode, $hostPageId]); - - return $query->rowCount(); - } - public function updateHostPageMime(int $hostPageId, string $mime) { $query = $this->_db->prepare('UPDATE `hostPage` SET `mime` = ? WHERE `hostPageId` = ? LIMIT 1');