]> 91.132.146.200 Git - insipid.git/commitdiff
adding browserless.io as full page screenshot service
authorBanana <mail@bananas-playground.net>
Thu, 23 Nov 2023 12:58:48 +0000 (13:58 +0100)
committerBanana <mail@bananas-playground.net>
Thu, 23 Nov 2023 12:58:48 +0000 (13:58 +0100)
12 files changed:
ChangeLog
documentation/snapshots-of-linked-webpage.txt [deleted file]
documentation/update.txt
documentation/whole-page-snapshot.txt [new file with mode: 0644]
webroot/config.default.php
webroot/job/email-import.php
webroot/lib/category.class.php
webroot/lib/link.class.php
webroot/lib/management.class.php
webroot/lib/snapshot.class.php
webroot/lib/summoner.class.php
webroot/lib/tag.class.php

index 8ae409bb3d66c16a460ee015ec2ab2ae6a6dcd3b..3e8494ab1f10204110cc288f71af78395d864e77 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,14 @@
 version 2.x.x - Griffin Chapel ()
     + Added TIMEZONE as a new config setting. Please update your config.
       See update.txt for more details.
+    + Added new config settings for whole page screenshot creation. Please update your config.
+      See update.txt for more details.
+      See whole-page-snapshot.txt for more details.
     + Fixed: Snapshot json result from Google.
     + New home screen layout
     + Better logging
 
+
 version 2.8.2 - Dragon Chapel (2023-09-14)
 
     + Added LOGFILE and QUERY_DEBUG const to config.php. See update.txt for more details
diff --git a/documentation/snapshots-of-linked-webpage.txt b/documentation/snapshots-of-linked-webpage.txt
deleted file mode 100644 (file)
index 2ab930a..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Whole page screenshot of a website
-
-TBD
index 850faa2144adc0fa7d75692785ae2288b16774a3..9c89d63a1b10b93bbddd25fbd9594ad0fc3ba125 100644 (file)
@@ -2,7 +2,12 @@ If you are updating from a previous version make sure every update info from
 the version your are updating from is done.
 
 ## version 2.x.x - Griffin Chapel
-+ Add new config setting TIMEZONE to your config. See config.default.php for more details
++ Add new config setting TIMEZONE to your config. See config.default.php for more details.
++ Add new config settings for using page screenshot with browserless.io. See config.default.php for more details.
+  const COMPLETE_PAGE_SCREENSHOT_BROWSERLESS_API = "https://chrome.browserless.io/screenshot?token=";
+  const COMPLETE_PAGE_SCREENSHOT_API_KEY = 'YOUR-API-KEY';
+  const COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_TIMEOUT = 10000; # milliseconds
+  const COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_IMAGE_QUALITY = 75; # quality for jpeg
 
 ## version 2.8.2 - Dragon Chapel
 + Add query debug setting to config file.
diff --git a/documentation/whole-page-snapshot.txt b/documentation/whole-page-snapshot.txt
new file mode 100644 (file)
index 0000000..1b9af57
--- /dev/null
@@ -0,0 +1,12 @@
+Whole page screenshot of a website.
+
+It uses browserless.io to generate a whole page screenshot of a link.
+There is a free account which allows ap to 1000 requests per month.
+
+# Usage
+To use this feature edit the config and set COMPLETE_PAGE_SCREENSHOT to true
+and provide your browserles.io API key to COMPLETE_PAGE_SCREENSHOT_API_KEY.
+
+# Limitations and expectations
+Every link and its target is different. The settings to generate the screenshot should work for the most of
+them. But there are a lot of things which influence the result and can return in a not-so-good screenshot.
index 30ddb3bf71d629c619290be8a3fd54bdca1767d4..9369d3506945a8e78e2aa9db09d253a479ee97a3 100644 (file)
@@ -79,9 +79,14 @@ const EMAIL_REPLY_BACK_VALID = '';
 const EMAIL_REPLY_BACK_ADDRESS = '';
 const EMAIL_REPLY_BACK_SUBJECT = 'Insipid email import response';
 
-# Use ... to create a whole page screenshot of a given link
+# Set this to true to enable the option in the link form
+# You need the API Key from your browserless.io account
+# See whole-page-snapshot.txt for more details
 const COMPLETE_PAGE_SCREENSHOT = false;
-const COMPLETE_PAGE_SCREENSHOT_COMMAND = '/absolute/path/to/command';
+const COMPLETE_PAGE_SCREENSHOT_BROWSERLESS_API = "https://chrome.browserless.io/screenshot?token=";
+const COMPLETE_PAGE_SCREENSHOT_API_KEY = 'YOUR-API-KEY';
+const COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_TIMEOUT = 10000; # milliseconds
+const COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_IMAGE_QUALITY = 75; # quality for jpeg
 
 # Timezone setting
 const TIMEZONE = 'Europe/Berlin';
index 7fe14443ba185379cded313b5bf5ed5fb88d8782..ec64daaed8a5969ee9b7ace8f8ac19eb81d375b6 100644 (file)
@@ -120,7 +120,7 @@ try {
     if(DEBUG === true) $EmailReader->mailboxStatus();
 }
 catch (Exception $e) {
-    Summoner::sysLog('[ERROR] Email server connection failed: '.$e->getMessage());
+    Summoner::sysLog('ERROR Email server connection failed: '.$e->getMessage());
     exit();
 }
 
@@ -130,7 +130,7 @@ try {
     $emails = $EmailReader->messageWithValidSubject(EMAIL_MARKER);
 }
 catch (Exception $e) {
-    Summoner::sysLog('[ERROR] Can not process email messages: '.$e->getMessage());
+    Summoner::sysLog('ERROR Can not process email messages: '.$e->getMessage());
     exit();
 }
 
@@ -259,7 +259,7 @@ if(!empty($emails)) {
                                }
                                else {
                                        $DB->rollback();
-                    Summoner::sysLog("[ERROR] Link could not be added. SQL problem? ".$newdata['link']);
+                    Summoner::sysLog("ERROR Link could not be added. SQL problem? ".$newdata['link']);
                                        $emailData['importmessage'] = "Link could not be added";
                                        array_push($invalidProcessedEmails,$emailData);
                                }
index 5370547f8973ba03a85620703b500e86882ba654..5930849e0ee5503b9e8163905eb42baeaf3be43e 100644 (file)
@@ -66,7 +66,7 @@ class Category {
             $queryStr = "SELECT `id`,`name` FROM `".DB_PREFIX."_category`
                             WHERE `name` = '".$this->DB->real_escape_string($string)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -81,7 +81,7 @@ class Category {
                         $queryStr = "INSERT INTO `" . DB_PREFIX . "_category`
                                         SET `name` = '" . $this->DB->real_escape_string($string) . "'";
 
-                        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                         $this->DB->query($queryStr);
                         if (!empty($this->DB->insert_id)) {
@@ -96,7 +96,7 @@ class Category {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
         return $ret;
@@ -116,7 +116,7 @@ class Category {
                 FROM `".DB_PREFIX."_category`
                 WHERE `id` = '".$this->DB->real_escape_string($id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -126,7 +126,7 @@ class Category {
                     $this->_data = $result;
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -161,12 +161,12 @@ class Category {
                             SET `linkid` = '".$this->DB->real_escape_string($linkid)."',
                                 `categoryid` = '".$this->DB->real_escape_string($this->_id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $this->DB->query($queryStr);
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
     }
@@ -183,7 +183,7 @@ class Category {
                     FROM `".DB_PREFIX."_categoryrelation` 
                     WHERE `categoryid` = '".$this->DB->real_escape_string($this->_id)."'";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -193,7 +193,7 @@ class Category {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -219,7 +219,7 @@ class Category {
                     FROM `".DB_PREFIX."_category`
                     WHERE `id` = '".$this->DB->real_escape_string($this->_id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $this->DB->query($queryStr);
@@ -246,12 +246,12 @@ class Category {
                         SET `name` = '".$this->DB->real_escape_string($newValue)."'
                         WHERE `id` = '".$this->DB->real_escape_string($this->_id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $this->DB->query($queryStr);
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
 
             $this->_data['name'] = $newValue;
index 8b8a0fd0d55c3ea97169883658bc687d883be453..c14e8ad8d3f0d08de1dcefefe6c7705d9d7f609c 100644 (file)
@@ -78,7 +78,7 @@ class Link {
                 FROM `".DB_PREFIX."_link`
                 WHERE `hash` = '" . $this->DB->real_escape_string($hash) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -94,7 +94,7 @@ class Link {
                     $this->_pageScreenshot();
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -116,7 +116,7 @@ class Link {
                 FROM `".DB_PREFIX."_link`
                 WHERE `hash` = '" . $this->DB->real_escape_string($hash) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -129,7 +129,7 @@ class Link {
                     $this->_categories();
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -215,7 +215,7 @@ class Link {
                         `hash` = '" . $this->DB->real_escape_string($data['hash']) . "',
                         `search` = '" . $this->DB->real_escape_string($data['search']) . "'";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $this->DB->query($queryStr);
@@ -226,7 +226,7 @@ class Link {
                 Summoner::sysLog('ERROR Failed to create link: '.Summoner::cleanForLog($data));
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -273,13 +273,13 @@ class Link {
                             `search` = '" . $this->DB->real_escape_string($search) . "'
                           WHERE `hash` = '" . $this->DB->real_escape_string($this->_data['hash']) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             $this->DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
             try {
                 $query = $this->DB->query($queryStr);
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
 
 
@@ -308,9 +308,6 @@ class Link {
                 # decide to store or remove the image
                 if (isset($data['localImage'])) {
                     $image = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/thumbnail-' . $this->_data['hash'].'.jpg';
-
-                    if(DEBUG) Summoner::sysLog("DEBUG Try to save local image to: $image");
-
                     if ($data['localImage'] === true) {
                         if(DEBUG) Summoner::sysLog("DEBUG want to save local image to: $image");
 
@@ -320,9 +317,9 @@ class Link {
                             Summoner::downloadFile($data['image'], $image);
                         }
                     } elseif ($data['localImage'] === false) {
-                        if(DEBUG) Summoner::sysLog("DEBUG Image to be removed: $image");
-
+                        if(DEBUG) Summoner::sysLog("DEBUG want to remove local image: $image");
                         if (file_exists($image)) {
+                            if(DEBUG) Summoner::sysLog("DEBUG Image to be removed: $image");
                             unlink($image);
                         }
                     }
@@ -330,7 +327,7 @@ class Link {
 
                 # decide if we want to make a local snapshot
                 if(isset($data['snapshot'])) {
-                    $snapshot = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/snapshot-' . $this->_data['hash'].'.jpg';
+                    $snapshot = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/snapshot-' . $this->_data['hash'].'.webp';
                     if ($data['snapshot'] === true) {
                         if (!file_exists($snapshot) || $_imageUrlChanged === true) {
                             require_once 'lib/snapshot.class.php';
@@ -341,7 +338,9 @@ class Link {
                             }
                         }
                     } elseif ($data['snapshot'] === false) {
+                        if(DEBUG) Summoner::sysLog("DEBUG want to remove local snapshot: $snapshot");
                         if (file_exists($snapshot)) {
+                            if(DEBUG) Summoner::sysLog("DEBUG remove local snapshot: $snapshot");
                             unlink($snapshot);
                         }
                     }
@@ -349,18 +348,20 @@ class Link {
 
                 # decide if we want to make a local full page screenshot
                 if(isset($data['pagescreenshot'])) {
-                    $pagescreenshot = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/pagescreenshot-' . $this->_data['hash'].'.jpg';
+                    $pagescreenshot = ABSOLUTE_PATH . '/' . LOCAL_STORAGE . '/pagescreenshot-' . $this->_data['hash'].'.jpeg';
                     if ($data['pagescreenshot'] === true) {
                         if (!file_exists($pagescreenshot) || $_imageUrlChanged === true) {
                             require_once 'lib/snapshot.class.php';
                             $snap = new Snapshot();
                             $do = $snap->wholePageSnapshot($this->_data['link'], $pagescreenshot);
-                            if(!empty($do)) {
-                                Summoner::sysLog('ERROR Failed to create snapshot: '.Summoner::cleanForLog($data));
+                            if(!$do) {
+                                Summoner::sysLog('ERROR Failed to create pagescreenshot: '.Summoner::cleanForLog($data));
                             }
                         }
                     } elseif ($data['pagescreenshot'] === false) {
+                        if(DEBUG) Summoner::sysLog("DEBUG want to remove local pagescreenshot: $pagescreenshot");
                         if (file_exists($pagescreenshot)) {
+                            if(DEBUG) Summoner::sysLog("DEBUG remove local pagescreenshot: $pagescreenshot");
                             unlink($pagescreenshot);
                         }
                     }
@@ -406,7 +407,7 @@ class Link {
                 FROM `" . DB_PREFIX . "_combined`
                 WHERE `hash` = '" . $this->DB->real_escape_string($this->_data['hash']) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -418,7 +419,7 @@ class Link {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -440,7 +441,7 @@ class Link {
                 FROM `" . DB_PREFIX . "_combined`
                 WHERE `hash` = '" . $this->DB->real_escape_string($this->_data['hash']) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -452,7 +453,7 @@ class Link {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -480,13 +481,13 @@ class Link {
                     WHERE `linkid` = '" . $this->DB->real_escape_string($this->_data['id']) . "'";
             }
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             if (!empty($queryStr)) {
                 try {
                     $this->DB->query($queryStr);
                 } catch (Exception $e) {
-                    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
                 }
             }
         }
@@ -512,13 +513,13 @@ class Link {
                     WHERE `linkid` = '" . $this->DB->real_escape_string($this->_data['id']) . "'";
             }
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             if (!empty($queryStr)) {
                 try {
                     $this->DB->query($queryStr);
                 } catch (Exception $e) {
-                    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
                 }
             }
         }
@@ -549,9 +550,9 @@ class Link {
      */
     private function _snapshot(): void {
         if (!empty($this->_data['hash'])) {
-            $snapshot = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.jpg';
+            $snapshot = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.webp';
             if (file_exists($snapshot)) {
-                $this->_data['snapshotLink'] = LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.jpg';
+                $this->_data['snapshotLink'] = LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.webp';
                 $this->_data['snapshot'] = true;
             }
         }
@@ -565,9 +566,9 @@ class Link {
      */
     private function _pageScreenshot(): void {
         if (!empty($this->_data['hash'])) {
-            $pagescreenshot = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpg';
+            $pagescreenshot = ABSOLUTE_PATH.'/'.LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpeg';
             if (file_exists($pagescreenshot)) {
-                $this->_data['pagescreenshotLink'] = LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpg';
+                $this->_data['pagescreenshotLink'] = LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpeg';
                 $this->_data['pagescreenshot'] = true;
             }
         }
@@ -594,7 +595,7 @@ class Link {
      */
     private function _deleteSnapshot(): void {
         if (!empty($this->_data['hash']) && !empty($this->_data['snapshotLink'])) {
-            $snapshot = LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.jpg';
+            $snapshot = LOCAL_STORAGE.'/snapshot-'.$this->_data['hash'].'.webp';
             if (file_exists($snapshot)) {
                 unlink($snapshot);
             }
@@ -608,7 +609,7 @@ class Link {
      */
     private function _deletePageScreenshot(): void {
         if (!empty($this->_data['hash']) && !empty($this->_data['pagescreenshotLink'])) {
-            $pagescreenshot = LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpg';
+            $pagescreenshot = LOCAL_STORAGE.'/pagescreenshot-'.$this->_data['hash'].'.jpeg';
             if (file_exists($pagescreenshot)) {
                 unlink($pagescreenshot);
             }
index 25ed19705d6aa9f1027b467b2f4aa1b9173501dc..282c3fe77becfee3d121e3555910ab965ac87690 100644 (file)
@@ -116,7 +116,7 @@ class Management {
             $queryStr .= " AND ".$this->_decideLinkTypeForQuery();
             $queryStr .= " GROUP BY categoryid";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -126,7 +126,7 @@ class Management {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -137,7 +137,7 @@ class Management {
             $queryStr .= " LIMIT $limit";
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -152,7 +152,7 @@ class Management {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         $this->_categories = $ret;
@@ -180,7 +180,7 @@ class Management {
             $queryStr .= " AND ".$this->_decideLinkTypeForQuery();
             $queryStr .= " GROUP BY tagId";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -190,7 +190,7 @@ class Management {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -201,7 +201,7 @@ class Management {
             $queryStr .= " LIMIT $limit";
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -216,7 +216,7 @@ class Management {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -238,7 +238,7 @@ class Management {
             $queryStr .= " LIMIT $limit";
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -250,7 +250,7 @@ class Management {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -274,7 +274,7 @@ class Management {
         $queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
         $queryStr .= " LIMIT $offset, $limit";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -282,7 +282,7 @@ class Management {
                 $ret = $query->fetch_all(MYSQLI_ASSOC);
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -303,7 +303,7 @@ class Management {
         $queryStr = "SELECT `id`, `name` FROM `".DB_PREFIX."_category`";
         $queryStr .= " LIMIT $offset, $limit";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -311,7 +311,7 @@ class Management {
                 $ret = $query->fetch_all(MYSQLI_ASSOC);
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -332,7 +332,7 @@ class Management {
         $queryStr = "SELECT `id`, `name` FROM `".DB_PREFIX."_tag`";
         $queryStr .= " LIMIT $offset, $limit";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -340,7 +340,7 @@ class Management {
                 $ret = $query->fetch_all(MYSQLI_ASSOC);
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -419,7 +419,7 @@ class Management {
             }
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
 
         try {
             $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
@@ -435,7 +435,7 @@ class Management {
                 $ret['amount'] = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -492,7 +492,7 @@ class Management {
             }
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
 
         try {
             $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
@@ -503,14 +503,14 @@ class Management {
                     unset($linkObj);
                 }
 
-                if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryFrom.$queryWhere));
+                if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryFrom.$queryWhere));
 
                 $query = $this->DB->query("SELECT COUNT(DISTINCT(t.hash)) AS amount ".$queryFrom.$queryWhere);
                 $result = $query->fetch_assoc();
                 $ret['amount'] = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -558,7 +558,7 @@ class Management {
             }
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit));
 
         try {
             $query = $this->DB->query($querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit);
@@ -569,14 +569,14 @@ class Management {
                     unset($linkObj);
                 }
 
-                if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryFrom.$queryWhere));
+                if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryFrom.$queryWhere));
 
                 $query = $this->DB->query("SELECT COUNT(t.hash) AS amount ".$queryFrom.$queryWhere);
                 $result = $query->fetch_assoc();
                 $ret['amount'] = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -600,7 +600,7 @@ class Management {
                             ORDER BY t.created DESC
                             LIMIT 1";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -608,7 +608,7 @@ class Management {
                     $ret = $query->fetch_all(MYSQLI_ASSOC);
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
         return $ret;
@@ -629,7 +629,7 @@ class Management {
             $queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
             $queryStr .= " AND t.link = '".$this->DB->real_escape_string($url)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -637,7 +637,7 @@ class Management {
                     $ret = $query->fetch_all(MYSQLI_ASSOC);
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -661,7 +661,7 @@ class Management {
             $queryStr .= " AND ".$this->_decideLinkTypeForQuery();
             $queryStr .= " ORDER BY score DESC";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -669,7 +669,7 @@ class Management {
                     $ret = $query->fetch_all(MYSQLI_ASSOC);
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -688,7 +688,7 @@ class Management {
                         FROM `".DB_PREFIX."_link` AS t";
         $queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -697,7 +697,7 @@ class Management {
                 $ret = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -713,7 +713,7 @@ class Management {
 
         $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_tag`";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -722,7 +722,7 @@ class Management {
                 $ret = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -738,7 +738,7 @@ class Management {
 
         $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_category`";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -747,7 +747,7 @@ class Management {
                 $ret = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -764,7 +764,7 @@ class Management {
         $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_link`";
         $queryStr .= " WHERE `status` = 3";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -773,7 +773,7 @@ class Management {
                 $ret = $result['amount'];
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -832,7 +832,7 @@ class Management {
             $queryWhere = " WHERE ".$this->_decideLinkTypeForQuery();
             $queryWhere .= " AND t.hash = '".$this->DB->real_escape_string($hash)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($querySelect.$queryFrom.$queryWhere));
 
             try {
                 $query = $this->DB->query($querySelect.$queryFrom.$queryWhere);
@@ -853,7 +853,7 @@ class Management {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -877,7 +877,7 @@ class Management {
                 $queryStr = "DELETE FROM `" . DB_PREFIX . "_link` 
                         WHERE `hash` = '" . $this->DB->real_escape_string($hash) . "'";
 
-                if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                 try {
                     $query = $this->DB->query($queryStr);
@@ -885,7 +885,7 @@ class Management {
                         $ret = true;
                     }
                 } catch (Exception $e) {
-                    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
                 }
             }
         }
@@ -971,12 +971,12 @@ class Management {
                                 SET `search` = '".$this->DB->real_escape_string($searchStr)."'
                                 WHERE `hash` = '".$this->DB->real_escape_string($link['hash'])."'";
 
-                if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                 try {
                     $this->DB->query($queryStr);
                 } catch (Exception $e) {
-                    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
                 }
 
                 unset($LinkObj,$l,$searchStr,$_t,$queryStr);
@@ -1122,7 +1122,7 @@ class Management {
                         ORDER BY `linkid`, rel ASC";
         }
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -1138,7 +1138,7 @@ class Management {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         // now count the unique digit strings
@@ -1179,7 +1179,7 @@ class Management {
                                     WHERE `id` = '".$this->DB->real_escape_string($t)."'";
                         }
 
-                        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                         try {
                             $query = $this->DB->query($queryStr);
@@ -1189,7 +1189,7 @@ class Management {
                                 $_t['rel'][$t] = $relinfo['name'];
                             }
                         } catch (Exception $e) {
-                            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
                         }
                     } else {
                         $_t['rel'][$t] = $_existingRelInfo[$t];
@@ -1230,7 +1230,7 @@ class Management {
                             FROM `" . DB_PREFIX . "_link`
                             WHERE `id` = '" . $this->DB->real_escape_string($id) . "'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -1238,7 +1238,7 @@ class Management {
                     $ret = true;
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
index bfbdc73837d2d6a72a68e37e29c0027b8ea67f16..4b807f08909c4e1b8095d1fe06a27a9afe04d567 100644 (file)
@@ -29,7 +29,9 @@
 /**
  * class Snapshot
  * create from given ULR a Screenshot for storage
- * right now it uses google pagespeedonline.
+ * right now it uses google pagespeedonline for a simple snapshot
+ *
+ *
  */
 class Snapshot {
     /**
@@ -37,11 +39,6 @@ class Snapshot {
      */
     private string $_googlePageSpeed = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=';
 
-    /**
-     * @var string
-     */
-    private string $_wkhtmltoimageOptions = '--load-error-handling ignore --quality 80 --quiet --width 1900';
-
     /**
      * Snapshot constructor
      */
@@ -60,13 +57,13 @@ class Snapshot {
 
         if(!empty($url) && is_writable(dirname($filename))) {
             if(DEBUG) {
-                Summoner::sysLog("[DEBUG] try to save to $filename with $this->_googlePageSpeed for $url");
+                Summoner::sysLog("DEBUG try to save to $filename with $this->_googlePageSpeed for $url");
             }
             $theCall = Summoner::curlCall($this->_googlePageSpeed.urlencode($url).'&screenshot=true');
             if(!empty($theCall['status'])) {
                 $jsonData = json_decode($theCall['message'],true);
                 if(DEBUG) {
-                    Summoner::sysLog("[DEBUG] Call result data: ".Summoner::cleanForLog($jsonData));
+                    Summoner::sysLog("DEBUG Call result data: ".Summoner::cleanForLog($jsonData));
                 }
                 if(!empty($jsonData) && isset($jsonData['lighthouseResult']['fullPageScreenshot']['screenshot']['data'])) {
                     $imageData = $jsonData['lighthouseResult']['fullPageScreenshot']['screenshot']['data'];
@@ -79,11 +76,13 @@ class Snapshot {
                     fclose($source);
                     fclose($destination);
                 } elseif(DEBUG) {
-                    Summoner::sysLog("[DEBUG] invalid json data. Path ['lighthouseResult']['fullPageScreenshot']['screenshot']['data'] not found in : ".Summoner::cleanForLog($jsonData));
+                    Summoner::sysLog("DEBUG invalid json data. Path ['lighthouseResult']['fullPageScreenshot']['screenshot']['data'] not found in : ".Summoner::cleanForLog($jsonData));
                 }
             } elseif(DEBUG) {
-                Summoner::sysLog("[DEBUG] curl call failed ".Summoner::cleanForLog($theCall));
+                Summoner::sysLog("DEBUG curl call failed ".Summoner::cleanForLog($theCall));
             }
+        } else {
+            Summoner::sysLog("ERROR URL $url is empty or target $filename is not writeable.");
         }
 
         return $ret;
@@ -93,7 +92,7 @@ class Snapshot {
      * use configured COMPLETE_PAGE_SCREENSHOT_COMMAND to create a whole page screenshot
      * of the given link and store it locally
      *
-     * @TODO: TBD
+     * Uses browserless.io and needs settings in config.php
      *
      * @param String $url URL to take the screenshot from
      * @param string $filename
@@ -102,20 +101,58 @@ class Snapshot {
     public function wholePageSnapshot(string $url, string $filename): bool {
         $ret = false;
 
-        require_once 'lib/shellcommand.class.php';
-
         if(!empty($url) && is_writable(dirname($filename))) {
-            $cmd = COMPLETE_PAGE_SCREENSHOT_COMMAND;
-            $params = $this->_wkhtmltoimageOptions." ".$url." ".$filename;
-            $command = new ShellCommand($cmd." ".$params);
-            if ($command->execute()) {
-                $ret = $command->getOutput();
-            } else {
-                Summoner::sysLog($command->getError());
-                $ret = $command->getExitCode();
+
+            $postdata = json_encode(array(
+                'url' => $url,
+                'waitFor' => COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_TIMEOUT,
+                'options' => array(
+                    'fullPage' => true,
+                    'type' => "jpeg",
+                    'quality' => COMPLETE_PAGE_SCREEENSHOT_BROWSERLESS_IMAGE_QUALITY
+                )
+            ));
+
+            if(DEBUG) Summoner::sysLog("DEBUG browserless json data ".Summoner::cleanForLog($postdata));
+
+            $fh = fopen($filename, 'w+');
+
+            $api_url = COMPLETE_PAGE_SCREENSHOT_BROWSERLESS_API.COMPLETE_PAGE_SCREENSHOT_BROWSERLESS_API_KEY;
+            $ch = curl_init($api_url);
+            curl_setopt($ch, CURLOPT_FILE, $fh);
+            //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+            curl_setopt($ch, CURLOPT_POST, 1);
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Cache-Control: no-cache'));
+
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
+            curl_setopt($ch, CURLOPT_TIMEOUT, 30);
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+            curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
+
+            // DEBUG ONLY
+            //$curl_log = fopen(ABSOLUTE_PATH."/curl.log", 'w');
+            //curl_setopt($ch, CURLOPT_VERBOSE, true);
+            //curl_setopt($ch, CURLOPT_STDERR, $curl_log);
+
+            if(!empty($port)) {
+                curl_setopt($ch, CURLOPT_PORT, $port);
             }
+            $do = curl_exec($ch);
+            curl_close($ch);
+            fclose($fh);
+
+            if(DEBUG) Summoner::sysLog("DEBUG return ".Summoner::cleanForLog($do));
+
+            // DEBUG ONLY
+            //fclose($curl_log);
+
+            $ret = true;
+        } else {
+            Summoner::sysLog("ERROR URL $url is empty or target $filename is not writeable.");
         }
 
         return $ret;
     }
 }
+
index b1b33b8d1786a35fd13289871a0691968c7888a5..50a98522455a2c3fc802ab2bebe3a55fe48445a0 100644 (file)
@@ -31,7 +31,7 @@
  */
 class Summoner {
 
-    private const BROWSER_AGENT_STRING = 'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0';
+    private const BROWSER_AGENT_STRING = 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/119.0';
 
     /**
      * validate the given string with the given type. Optional check the string
@@ -207,7 +207,7 @@ class Summoner {
 
         return $ret;
     }
-    
+
     /**
      * try to gather meta information from given URL
      *
@@ -372,7 +372,6 @@ class Summoner {
             }
         }
 
-
         return $ret;
     }
 
index f0b2a0974889c9d291e41220e5c44dc4cb2f7091..07858aa767b0cde113aa93d46e23ca3e80e5d813 100644 (file)
@@ -74,7 +74,7 @@ class Tag {
             $queryStr = "SELECT `id`,`name` FROM `".DB_PREFIX."_tag`
                             WHERE `name` = '".$this->DB->real_escape_string($string)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -89,7 +89,7 @@ class Tag {
                         $queryStr = "INSERT INTO `" . DB_PREFIX . "_tag`
                                         SET `name` = '" . $this->DB->real_escape_string($string) . "'";
 
-                        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                         $this->DB->query($queryStr);
                         if (!empty($this->DB->insert_id)) {
@@ -104,7 +104,7 @@ class Tag {
                     }
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
         return $ret;
@@ -123,7 +123,7 @@ class Tag {
             $queryStr = "SELECT `id`,`name` FROM `".DB_PREFIX."_tag`
                             WHERE `id` = '".$this->DB->real_escape_string($id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $query = $this->DB->query($queryStr);
@@ -133,7 +133,7 @@ class Tag {
                     $this->_data = $result;
                 }
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
 
@@ -167,12 +167,12 @@ class Tag {
             $queryStr = "INSERT IGNORE INTO `".DB_PREFIX."_tagrelation`
                             SET `linkid` = '".$this->DB->real_escape_string($linkid)."',
                                 `tagid` = '".$this->DB->real_escape_string($this->_id)."'";
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $this->DB->query($queryStr);
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
         }
     }
@@ -189,7 +189,7 @@ class Tag {
                     FROM `".DB_PREFIX."_tagrelation` 
                     WHERE tagid = '".$this->DB->real_escape_string($this->_id)."'";
 
-        if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+        if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
         try {
             $query = $this->DB->query($queryStr);
@@ -199,7 +199,7 @@ class Tag {
                 }
             }
         } catch (Exception $e) {
-            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
         }
 
         return $ret;
@@ -226,12 +226,12 @@ class Tag {
                     FROM `".DB_PREFIX."_tag`
                     WHERE `id` = '".$this->DB->real_escape_string($this->_id)."'";
 
-                if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+                if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                 $this->DB->query($queryStr);
                 $this->DB->commit();
             } catch (Exception $e) {
-                Summoner::sysLog('[ERROR] Failed to remove tag: '.$e->getMessage());
+                Summoner::sysLog('ERROR Failed to remove tag: '.$e->getMessage());
 
                 $this->DB->rollback();
             }
@@ -252,12 +252,12 @@ class Tag {
                         SET `name` = '".$this->DB->real_escape_string($newValue)."'
                         WHERE `id` = '".$this->DB->real_escape_string($this->_id)."'";
 
-            if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
+            if(QUERY_DEBUG) Summoner::sysLog("QUERY ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
             try {
                 $this->DB->query($queryStr);
             } catch (Exception $e) {
-                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("ERROR ".__METHOD__." mysql catch: ".$e->getMessage());
             }
             $this->_data['name'] = $newValue;
         }