]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
changed how the logs are written
authorBanana <mail@bananas-playground.net>
Mon, 9 Oct 2023 12:47:40 +0000 (14:47 +0200)
committerBanana <mail@bananas-playground.net>
Mon, 9 Oct 2023 12:47:40 +0000 (14:47 +0200)
20 files changed:
CHANGELOG
upgrade/from-version-1.5.txt [new file with mode: 0644]
webclient/api.php
webclient/config/config.php.default
webclient/index.php
webclient/lib/doomguy.class.php
webclient/lib/googlebookparser.class.php
webclient/lib/gorenest.class.php
webclient/lib/managecollectionfields.class.php
webclient/lib/managecollections.class.php
webclient/lib/manageentry.class.php
webclient/lib/managetags.class.php
webclient/lib/mancubus.class.php
webclient/lib/musicbrainz.class.php
webclient/lib/possessed.class.php
webclient/lib/summoner.class.php
webclient/lib/tentacle.class.php
webclient/lib/trite.class.php
webclient/view/default/sysinfo/sysinfo.php
webclient/view/default/tool/tool-imdbweb.php

index bb817a384bbbb56abe68e4783f6db20874f8e389..9be717582e44286e6e819f4524334ee34f981aa9 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,5 @@
 1.x - Chizra
+    * Config change. Added new entry. See upgrade/from-version-1.5.txt. It won't work if it is missing.
     * Licence change to GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
 
 1.5 - Sacred Passage 2023-05-01
diff --git a/upgrade/from-version-1.5.txt b/upgrade/from-version-1.5.txt
new file mode 100644 (file)
index 0000000..2a1fe5d
--- /dev/null
@@ -0,0 +1,3 @@
+# Added new const to config.php file.
+Use config.php.default as a help. The new line is:
+const LOGFILE = PATH_SYSTEMOUT.'/bibliotheca.log';
\ No newline at end of file
index 0dad6b8236bfaf151dcf5fc1535477cbbf15ffb3..7a2ec6aab992b0e1ec7e06755c92901305951570 100644 (file)
@@ -35,7 +35,6 @@ if(!empty($_urlToParse)) {
 
 # set the error reporting
 ini_set('log_errors',true);
-ini_set('error_log',PATH_SYSTEMOUT.'/api.log');
 if(DEBUG === true) {
        ini_set('display_errors',true);
 }
index ad4dfbe233454414f4bfb89ff6d8dd3b4118d678..17b878b8281faa291382fc715e1d2ecdd727c15c 100644 (file)
@@ -31,6 +31,7 @@ const PATH_ABSOLUTE = '~pathabsolute~';
 const PATH_SYSTEMOUT = PATH_ABSOLUTE.'/systemout';
 const PATH_STORAGE = PATH_ABSOLUTE.'/storage';
 const PATH_WEB_STORAGE = 'storage';
+const LOGFILE = PATH_SYSTEMOUT.'/bibliotheca.log';
 
 # database config
 const DB_HOST = '~dbhost~';
index 760f13c51828edfeb4663a639f2ef48671cead5c..8465a868bdadd6113c0d011bfad1a42cf1fb03e2 100644 (file)
@@ -36,7 +36,6 @@ if(!empty($_urlToParse)) {
 
 # set the error reporting
 ini_set('log_errors',true);
-ini_set('error_log',PATH_SYSTEMOUT.'/error.log');
 if(DEBUG === true) {
        ini_set('display_errors',true);
 }
index 7506c29519c2c981797dfdebe531dac3a44afb38..a422ec1c54489881bc65b9ba44dc1ca72e68ffb6 100644 (file)
@@ -200,7 +200,7 @@ class Doomguy {
                                                                   `token` = '".$this->_DB->real_escape_string($tokenInfo['token'])."',
                                                                   `salt` = '".$this->_DB->real_escape_string($tokenInfo['salt'])."',
                                                                   `loginTime` = NOW()";
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                        try {
                                                $this->_DB->query($queryStr);
 
@@ -208,7 +208,7 @@ class Doomguy {
                                                $this->_loginActions();
                                        }
                                        catch (Exception $e) {
-                                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                        Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                                        }
 
                                        $ret = true;
@@ -231,7 +231,7 @@ class Doomguy {
                                                FROM `".DB_PREFIX."_user`
                                                WHERE `apiToken` = '".$this->_DB->real_escape_string($token)."'
                                                AND `apiTokenValidDate` > NOW()";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -243,7 +243,7 @@ class Doomguy {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
        }
@@ -278,7 +278,7 @@ class Doomguy {
                        }
                }
                else {
-                       error_log("[ERROR] ".__METHOD__."  invalid rights string: ".var_export($this->_rightsArray, true));
+            Summoner::sysLog("[ERROR] ".__METHOD__."  invalid rights string: ".Summoner::cleanForLog($this->_rightsArray));
                }
 
                return $str;
@@ -336,7 +336,7 @@ class Doomguy {
                        WHERE s.token = '".$this->_DB->real_escape_string($_SESSION[SESSION_NAME]['bibliothecatoken'])."'
                        AND s.salt <> ''
                        AND s.loginTime >= '".$timeframe."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
 
@@ -351,7 +351,7 @@ class Doomguy {
                                        $ret = true;
                                }
                                else {
-                                       error_log("[ERROR] ".__METHOD__." mismatched token.");
+                    Summoner::sysLog("[ERROR] ".__METHOD__." mismatched token.");
                                        if(isset($result['fk_user_id']) && !empty($result['fk_user_id'])) {
                                                $this->userID = $result['fk_user_id'];
                                        }
@@ -360,7 +360,7 @@ class Doomguy {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -381,7 +381,7 @@ class Doomguy {
                                        FROM `".DB_PREFIX."_user`
                                        WHERE `login` = '". $this->_DB->real_escape_string($u)."'
                                        AND `active` = '1'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -391,7 +391,7 @@ class Doomguy {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -408,12 +408,12 @@ class Doomguy {
                $timeframe = date("Y-m-d H:i:s",time()-SESSION_LIFETIME);
                $queryStr = "DELETE FROM `".DB_PREFIX."_userSession`
                                WHERE `loginTime` <= '".$timeframe."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $this->_DB->query($queryStr);
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
        }
 
@@ -431,7 +431,7 @@ class Doomguy {
                                                LEFT JOIN `".DB_PREFIX."_user2group` AS u2g ON u2g.fk_user_id = u.id
                                                LEFT JOIN `".DB_PREFIX."_group` AS g ON g.id= u2g.fk_group_id
                                                WHERE u.`id` = '".$this->_DB->real_escape_string($this->userID)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -462,7 +462,7 @@ class Doomguy {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
        }
@@ -477,12 +477,12 @@ class Doomguy {
                $queryStr = "DELETE FROM `".DB_PREFIX."_userSession`
                                WHERE `fk_user_id` = '".$this->_DB->real_escape_string($this->userID)."'
                                OR `loginTime` <= '".$timeframe."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $this->_DB->query($queryStr);
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                unset($_SESSION);
index 39a9a131da22b0651e4e104b35aa4547326a6619..2d966126232dcc803dabefc45abde4d64268d936 100644 (file)
@@ -77,17 +77,17 @@ class GoogleBooks {
                        $url = $this->_VOLUMES_ENDPOINT;
                        $url .= '?q=isbn:'.$isbn;
 
-                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." isbn query url: $url");
+                       if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." isbn query url: $url");
 
                        $do = $this->_curlCall($url);
                        if(!empty($do)) {
                                $data = json_decode($do, true);
                                if(!empty($data)) {
-                                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." isbn json data:".var_export($data,true));
+                                       if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." isbn json data:".Summoner::cleanForLog($data));
                                        $data = $this->_buildDataFromISBNsearch($data);
                                }
                                else {
-                                       error_log("[ERROR] ".__METHOD__." invalid isbn json data:".var_export($do,true));
+                    Summoner::sysLog("[ERROR] ".__METHOD__." invalid isbn json data:".Summoner::cleanForLog($do));
                                }
                        }
 
@@ -114,7 +114,7 @@ class GoogleBooks {
                $_tmpFile = tempnam(sys_get_temp_dir(), "bibliotheca-");
                $fh = fopen($_tmpFile,"w+");
                if($this->_DEBUG) {
-                       error_log('[DEBUG] '.__METHOD__.' url '.var_export($url,true));
+            Summoner::sysLog('[DEBUG] '.__METHOD__.' url '.Summoner::cleanForLog($url));
                }
 
                if($fh !== false) {
@@ -221,7 +221,7 @@ class GoogleBooks {
                curl_close($ch);
 
                if($this->_DEBUG) {
-                       error_log('[DEBUG] '.__METHOD__.' headers '.var_export($_headers,true));
+            Summoner::sysLog('[DEBUG] '.__METHOD__.' headers '.Summoner::cleanForLog($_headers));
                }
 
                return $ret;
index 5abc31a642d7948d5f35c34546c2b349f168d0ff..c6c98ef4c436be747349ccc8414d54022ea151f0 100644 (file)
@@ -104,7 +104,7 @@ class GoreNest {
                                        FROM `".DB_PREFIX."_menu`
                                        WHERE ".$this->_User->getSQLRightsString()."                            
                                                ORDER BY position";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query  = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -115,7 +115,7 @@ class GoreNest {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
        }
 
index 398919c783d2f985aeb083b71832e3d2248df10b..0e9c46a73b33a4791b4a68c69d90407d2176030d 100644 (file)
@@ -106,7 +106,7 @@ class ManageCollectionFields {
                                                `createstring`, `value`
                                        FROM `".DB_PREFIX."_sys_fields`
                                        ORDER BY `displayname`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -116,7 +116,7 @@ class ManageCollectionFields {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $this->_cacheAvailableFields;
@@ -184,11 +184,11 @@ class ManageCollectionFields {
 
                        $queryStrDeleteFields = "DELETE FROM `".DB_PREFIX."_collection_fields_".$this->_collectionId."`
                                                WHERE `fk_field_id` NOT IN (".implode(",",$ids).")";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrDeleteFields,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrDeleteFields));
 
                        $queryStrDeletee2l = "DELETE FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_collectionId."`
                                                WHERE `fk_field` NOT IN (".implode(",",$ids).")";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrDeletee2l,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrDeletee2l));
 
                        $queryStrInsertFields = "INSERT INTO `".DB_PREFIX."_collection_fields_".$this->_collectionId."` (`fk_field_id`,`sort`) VALUES ";
                        foreach ($ids as $k => $v) {
@@ -196,7 +196,7 @@ class ManageCollectionFields {
                        }
                        $queryStrInsertFields = trim($queryStrInsertFields, ",");
                        $queryStrInsertFields .= " ON DUPLICATE KEY UPDATE `sort` = VALUES(`sort`)";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrInsertFields,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrInsertFields));
 
                        if(!empty($_newColumns)) {
                                $queryStrAlterEntry = array();
@@ -218,7 +218,7 @@ class ManageCollectionFields {
                                // mysql implicit commit
                                if(!empty($queriesDeleteEntryTable)) {
                                        foreach($queriesDeleteEntryTable as $q) {
-                                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($q,true));
+                                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::sysLog($q));
                                                $this->_DB->query($q);
                                        }
                                }
@@ -230,7 +230,7 @@ class ManageCollectionFields {
                                // mysql implicit commit
                                if(!empty($_newColumns)) {
                                        foreach ($queryStrAlterEntry as $q1) {
-                                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($q1,true));
+                                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($q1));
                                                $this->_DB->query($q1);
                                        }
                                }
@@ -239,7 +239,7 @@ class ManageCollectionFields {
                        }
                        catch (Exception $e) {
                                $this->_DB->rollback();
-                               error_log("[ERROR] asd ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] asd ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -270,7 +270,7 @@ class ManageCollectionFields {
                else {
                        $queryStr .= " ORDER BY `cf`.`sort`";
                }
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -280,7 +280,7 @@ class ManageCollectionFields {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $this->_cacheExistingSysFields;
@@ -323,7 +323,7 @@ class ManageCollectionFields {
                $ret = array();
 
                $queryStr = "SHOW COLUMNS FROM `".DB_PREFIX."_collection_entry_".$this->_collectionId."`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -335,7 +335,7 @@ class ManageCollectionFields {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
index 540003139cfd9fed0540240c7fc00c6fe533f167..0b630eec8cf10c5db3b7c1f5608855e096c64612 100644 (file)
@@ -63,7 +63,7 @@ class ManageCollections {
                                        LEFT JOIN `".DB_PREFIX."_group` AS g ON `c`.`group` = `g`.`id`
                                        WHERE ".$this->_User->getSQLRightsString("write", "c")."
                                        ORDER BY `c`.`name`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if ($query !== false && $query->num_rows > 0) {
@@ -73,7 +73,7 @@ class ManageCollections {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -91,7 +91,7 @@ class ManageCollections {
                                        FROM `".DB_PREFIX."_group` 
                                        WHERE ".$this->_User->getSQLRightsString()."
                                        ORDER BY `name`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -101,7 +101,7 @@ class ManageCollections {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -118,7 +118,7 @@ class ManageCollections {
                $queryStr = "SELECT `id`, `name`, `login`
                                                FROM `".DB_PREFIX."_user`
                                                WHERE ".$this->_User->getSQLRightsString()."";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -128,7 +128,7 @@ class ManageCollections {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -145,7 +145,7 @@ class ManageCollections {
                $queryStr = "SELECT `id`, `name`, `description`
                                                FROM `".DB_PREFIX."_tool`
                                                WHERE ".$this->_User->getSQLRightsString()."";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -155,7 +155,7 @@ class ManageCollections {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -188,7 +188,7 @@ class ManageCollections {
                                                                `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."',
                                                                `defaultSortOrder` = '".$this->_DB->real_escape_string($data['defaultSortOrder'])."',
                                                                `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."'";
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                $this->_DB->query($queryStr);
                                $newId = $this->_DB->insert_id;
 
@@ -206,7 +206,7 @@ class ManageCollections {
                                                                                KEY `fk_field` (`fk_field`),
                                                                                FULLTEXT KEY `value` (`value`)
                                                                                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryEntry2lookup,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryEntry2lookup));
                                $this->_DB->query($queryEntry2lookup);
 
                                $queryCollectionFields = "CREATE TABLE `".DB_PREFIX."_collection_fields_".$newId."` (
@@ -215,7 +215,7 @@ class ManageCollections {
                                                                                 UNIQUE KEY `fk_field_id` (`fk_field_id`),
                                                                                 KEY `sort` (`sort`)
                                                                                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryCollectionFields,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryCollectionFields));
                                $this->_DB->query($queryCollectionFields);
 
                                $queryCollectionEntry = "CREATE TABLE `".DB_PREFIX."_collection_entry_".$newId."` (
@@ -228,13 +228,13 @@ class ManageCollections {
                                                                                 `rights` char(9) COLLATE utf8mb4_bin NOT NULL,
                                                                                 PRIMARY KEY (`id`)
                                                                                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci";
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryCollectionEntry,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryCollectionEntry));
                                $this->_DB->query($queryCollectionEntry);
 
                                $ret = true;
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                                $this->_DB->rollback();
                        }
                }
@@ -262,7 +262,7 @@ class ManageCollections {
                                        LEFT JOIN `".DB_PREFIX."_group` AS g ON `c`.`group` = `g`.`id`
                                        WHERE ".$this->_User->getSQLRightsString("write", "c")."
                                        AND `c`.`id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -273,7 +273,7 @@ class ManageCollections {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -290,7 +290,7 @@ class ManageCollections {
        public function updateCollection(array $data): bool {
                $ret = false;
 
-               if(DEBUG) error_log("[DEBUG] ".__METHOD__."  data: ".var_export($data,true));
+               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__."  data: ".Summoner::cleanForLog($data));
 
                if(!empty($data['name']) === true
                        && $this->_validUpdateCollectionName($data['name'], $data['id']) === true
@@ -307,7 +307,7 @@ class ManageCollections {
                                                        `defaultSortOrder` = '".$this->_DB->real_escape_string($data['defaultSortOrder'])."',
                                                        `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."'
                                                WHERE `id` = '".$this->_DB->real_escape_string($data['id'])."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                                $this->_updateToolRelation($data['id'],$data['tool']);
@@ -317,7 +317,7 @@ class ManageCollections {
                                $ret = true;
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
 
                        // update the search field if it is a field from the collection entry table
@@ -327,8 +327,8 @@ class ManageCollections {
                        $queryStr = "CREATE FULLTEXT INDEX ".$this->_DB->real_escape_string($data['defaultSearchField'])."
                                                ON `".DB_PREFIX."_collection_entry_".$data['id']."`
                                                        (`".$this->_DB->real_escape_string($data['defaultSearchField'])."`)";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryCheck,true));
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryCheck));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryCheck);
                                if($query !== false && $query->num_rows > 0) {
@@ -342,10 +342,10 @@ class ManageCollections {
                        } catch (Exception $e) {
                                if($e->getCode() == "1061") {
                                        // duplicate key message if the index is already there.
-                                       error_log("[NOTICE] ".__METHOD__."  mysql query: ".$e->getMessage());
+                    Summoner::sysLog("[NOTICE] ".__METHOD__."  mysql query: ".$e->getMessage());
                                }
                                else {
-                                       error_log("[ERROR] ".__METHOD__."  mysql query: ".$e->getMessage());
+                    Summoner::sysLog("[ERROR] ".__METHOD__."  mysql query: ".$e->getMessage());
                                }
                        }
                }
@@ -366,20 +366,20 @@ class ManageCollections {
                if(!empty($id) && Summoner::validate($id, 'digit')) {
                        $queryStr = "DELETE FROM `".DB_PREFIX."_collection`
                                                        WHERE `id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                        $queryStrTool = "DELETE FROM `".DB_PREFIX."_tool2collection`
                                                        WHERE `fk_collection_id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrTool,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrTool));
 
                        $queryStre2l = "DROP TABLE `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($id)."`";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStre2l,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStre2l));
 
                        $queryStrEntry = "DROP TABLE `".DB_PREFIX."_collection_entry_".$this->_DB->real_escape_string($id)."`";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrEntry,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrEntry));
 
                        $queryStrFields = "DROP TABLE `".DB_PREFIX."_collection_fields_".$this->_DB->real_escape_string($id)."`";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrFields,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrFields));
 
 
                        // mysql implicit commit with drop command
@@ -402,7 +402,7 @@ class ManageCollections {
                        }
                        catch (Exception $e) {
                                $this->_DB->rollback();
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -422,7 +422,7 @@ class ManageCollections {
                                        FROM `".DB_PREFIX."_tool2collection` AS t2c
                                        LEFT JOIN `".DB_PREFIX."_tool` AS t ON t.id = t2c.fk_tool_id
                                        WHERE t2c.fk_collection_id = '".$this->_DB->real_escape_string($id)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -432,7 +432,7 @@ class ManageCollections {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                }
 
                return  $ret;
@@ -449,7 +449,7 @@ class ManageCollections {
                if (Summoner::validate($name, 'nospace')) {
                        $queryStr = "SELECT `id` FROM `".DB_PREFIX."_collection`
                                                                WHERE `name` = '".$this->_DB->real_escape_string($name)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -457,7 +457,7 @@ class ManageCollections {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -480,7 +480,7 @@ class ManageCollections {
                        $queryStr = "SELECT `id` FROM `".DB_PREFIX."_collection`
                                                                WHERE `name` = '".$this->_DB->real_escape_string($name)."'
                                                                AND `id` != '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -488,7 +488,7 @@ class ManageCollections {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -508,7 +508,7 @@ class ManageCollections {
 
                $queryStr = "DELETE FROM `".DB_PREFIX."_tool2collection`
                                                                WHERE `fk_collection_id` = '".$this->_DB->real_escape_string($id)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $this->_DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
 
@@ -520,7 +520,7 @@ class ManageCollections {
                                                $insertQueryStr = "INSERT IGNORE INTO `".DB_PREFIX."_tool2collection`
                                                                                        SET `fk_tool_id` = '".$this->_DB->real_escape_string($v)."',
                                                                                                `fk_collection_id` = '".$this->_DB->real_escape_string($id)."'";
-                                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($insertQueryStr,true));
+                                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($insertQueryStr));
                                                $this->_DB->query($insertQueryStr);
                                        }
                                }
@@ -530,7 +530,7 @@ class ManageCollections {
                }
                catch (Exception $e) {
                        $this->_DB->rollback();
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -559,12 +559,12 @@ class ManageCollections {
                        }
                        $queryStr = trim($queryStr, ",");
 
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
        }
index 94d9dce40c6af64207caba6fde7212f9fa0a768b..70257177c7d75a9a8dff21e2731ea626271648bf 100644 (file)
@@ -95,7 +95,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_fields_".$this->_DB->real_escape_string($this->_collectionId)."` AS cf
                                                LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`
                                                ORDER BY `cf`.`sort`";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -109,7 +109,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -131,7 +131,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_DB->real_escape_string($this->_collectionId)."` 
                                                WHERE ".$this->_User->getSQLRightsString("write")."
                                                AND `id` = '".$this->_DB->real_escape_string($entryId)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
 
@@ -148,7 +148,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -168,8 +168,8 @@ class Manageentry {
        public function create(array $data, string $owner, string $group, string $rights, mixed $update=false): int {
                $ret = 0;
 
-               if(DEBUG) error_log("[DEBUG] ".__METHOD__." data: ".var_export($data,true));
-               if(DEBUG) error_log("[DEBUG] ".__METHOD__." update: ".var_export($update,true));
+               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." data: ".Summoner::cleanForLog($data));
+               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." update: ".Summoner::cleanForLog($update));
 
                if(!empty($data) && !empty($owner) && !empty($group) && !empty($rights)) {
 
@@ -184,11 +184,11 @@ class Manageentry {
                                        $queryData = $this->$_mn($d, $queryData);
                                }
                                else {
-                                       if(DEBUG)error_log("[DEBUG] ".__METHOD__." Missing query function for: ".var_export($d, true));
+                                       if(DEBUG)Summoner::sysLog("[DEBUG] ".__METHOD__." Missing query function for: ".Summoner::cleanForLog($d));
                                }
                        }
 
-                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." queryData: ".var_export($queryData,true));
+                       if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." queryData: ".Summoner::sysLog($queryData));
 
                        if(!empty($queryData['init']) || ($update !== false && is_numeric($update))) {
 
@@ -208,7 +208,7 @@ class Manageentry {
                                        $queryStr .= " WHERE `id` = '".$this->_DB->real_escape_string($update)."'";
                                }
 
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                                try {
                                        $this->_DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
@@ -244,11 +244,11 @@ class Manageentry {
                                }
                                catch (Exception $e) {
                                        $this->_DB->rollback();
-                                       error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                                }
                        }
                        else {
-                               if(DEBUG) error_log("[DEBUG] ".__METHOD__." empty init in: ".var_export($queryData,true));
+                               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." empty init in: ".Summoner::cleanForLog($queryData));
                        }
                }
 
@@ -274,7 +274,7 @@ class Manageentry {
                                        // remove assets
                                        $_path = PATH_STORAGE.'/'.$this->_collectionId.'/'.$entryId;
                                        if(is_dir($_path) && is_readable($_path)) {
-                                               if(DEBUG) error_log("[DEBUG] ".__METHOD__."  remove assets :".$_path);
+                                               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__."  remove assets :".$_path);
                                                $rmDir = Summoner::recursive_remove_directory($_path);
                                                if($rmDir === false) {
                                                        throw new Exception("Failed to delete path: ".$_path);
@@ -285,8 +285,8 @@ class Manageentry {
                                        $queryStr = "DELETE 
                                                FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."`
                                                WHERE `fk_entry` = '".$this->_DB->real_escape_string($entryId)."'";
-                                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." remove lookup queryStr: ".var_export($queryStr,true));
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                                       if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." remove lookup queryStr: ".Summoner::cleanForLog($queryStr));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                        $this->_DB->query($queryStr);
 
                                        // delete entry
@@ -294,7 +294,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_collectionId."`
                                                WHERE `id` = '".$this->_DB->real_escape_string($entryId)."'
                                                        AND " . $this->_User->getSQLRightsString("delete") . "";
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                        $this->_DB->query($queryStr);
 
                                        $this->_DB->commit();
@@ -302,7 +302,7 @@ class Manageentry {
                                }
                                catch (Exception $e) {
                                        $this->_DB->rollback();
-                                       error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                                }
                        }
                }
@@ -325,7 +325,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_collectionId."`
                                                WHERE `id` = '".$this->_DB->real_escape_string($entryId)."'
                                                        AND ".$this->_User->getSQLRightsString("write")."";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -335,7 +335,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -358,7 +358,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_collectionId."`
                                                WHERE `id` = '".$this->_DB->real_escape_string($entryId)."'
                                                        AND ".$this->_User->getSQLRightsString("delete")."";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -368,7 +368,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -414,7 +414,7 @@ class Manageentry {
                                                FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."`
                                                WHERE `fk_field` = '".$this->_DB->real_escape_string($fieldData['id'])."'
                                                        AND `fk_entry` = '".$this->_DB->real_escape_string($entryId)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -424,7 +424,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -505,7 +505,7 @@ class Manageentry {
                        $queryStr = "SELECT DISTINCT(`value`) 
                                                FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."`
                                                WHERE `fk_field` = '".$this->_DB->real_escape_string($data['id'])."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -515,7 +515,7 @@ class Manageentry {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
                return $data;
@@ -722,12 +722,12 @@ class Manageentry {
                if(!empty($queryString) && !empty($insertId)) {
                        // replace only once to avoid replacing actual data
                        $queryStr = Summoner::replaceOnce($queryString,$this->_replaceEntryString, $insertId);
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                        }
                }
        }
@@ -745,7 +745,7 @@ class Manageentry {
         */
        private function _runAfter_upload(array $uploadData, string $insertId) {
                if(!empty($uploadData) && !empty($insertId)) {
-                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." uploadata: ".var_export($uploadData,true));
+                       if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." uploadata: ".Summoner::cleanForLog($uploadData));
                        $_path = PATH_STORAGE.'/'.$this->_collectionId.'/'.$insertId;
                        if(!is_dir($_path)) {
                                if(!mkdir($_path, 0777, true)) {
@@ -757,7 +757,7 @@ class Manageentry {
                                // single upload. Delete existing first.
                                // also triggered if the single needs to be deleted
                                $_existingFiles = glob($_path.'/'.$uploadData['identifier'].'-*');
-                               if(DEBUG) error_log("[DEBUG] ".__METHOD__." remove single existing: ".var_export($_existingFiles,true));
+                               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." remove single existing: ".Summoner::cleanForLog($_existingFiles));
                                if(!empty($_existingFiles)) {
                                        foreach ($_existingFiles as $f) {
                                                unlink($f);
@@ -767,7 +767,7 @@ class Manageentry {
                        }
 
                        if($uploadData['multiple'] === true && isset($uploadData['deleteData'])) {
-                               if(DEBUG) error_log("[DEBUG] ".__METHOD__." remove multiple existing: ".var_export($uploadData['deleteData'],true));
+                               if(DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." remove multiple existing: ".Summoner::cleanForLog($uploadData['deleteData']));
                                foreach ($uploadData['deleteData'] as $k=>$v) {
                                        $_file = $_path.'/'.$v;
                                        if(file_exists($_file)) {
index 6ecb60ec09c8c8bf8c95c292c2d4d60f4da17f43..13f2d8bed09eabbc4aa63fef4d308be143a2b87a 100644 (file)
@@ -113,12 +113,12 @@ class ManageTags {
                                        SET `value` = '".$this->_DB->real_escape_string($to)."'
                                        WHERE `fk_field` = '".$this->_DB->real_escape_string($field)."'
                                                AND `value` = BINARY '".$this->_DB->real_escape_string($from)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $this->_DB->query($queryStr);
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        $ret = 'Error in move/rename query. See logs.';
                }
 
@@ -142,12 +142,12 @@ class ManageTags {
                $queryStr = "DELETE FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."`
                                        WHERE `fk_field` = '".$this->_DB->real_escape_string($field)."'
                                                AND `value` = BINARY '".$this->_DB->real_escape_string($what)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $this->_DB->query($queryStr);
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        $ret = 'Error in delete query. See logs.';
                }
 
index 30d830e5fd2c87028d6edf7ea48e88b3904c4db8..2dfe64f808e6146ac9930a62efb031b33ab915ce 100644 (file)
@@ -133,7 +133,7 @@ class Mancubus {
                                        WHERE ".$this->_User->getSQLRightsString("read", "c")."
                                        ORDER BY `c`.`name`
                                        LIMIT $selections";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
 
@@ -162,7 +162,7 @@ class Mancubus {
                                                        );
                                                }
                                                else {
-                                                       error_log("[WARN] ".__METHOD__." missing default search field for collectionid: ".$result['id']);
+                            Summoner::sysLog("[WARN] ".__METHOD__." missing default search field for collectionid: ".$result['id']);
                                                }
                                        }
                                        else {
@@ -175,7 +175,7 @@ class Mancubus {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -279,7 +279,7 @@ class Mancubus {
                        }
 
                        $queryStr = $querySelect.$queryFrom.$queryJoin.$queryWhere.$queryOrder.$queryLimit;
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 
                        try {
                                $query = $this->_DB->query($queryStr);
@@ -295,14 +295,14 @@ class Mancubus {
                                        }
 
                                        $queryStrCount = "SELECT COUNT(t.id) AS amount ".$queryFrom.$queryJoin.$queryWhere;
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrCount,true));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrCount));
                                        $query = $this->_DB->query($queryStrCount);
                                        $result = $query->fetch_assoc();
                                        $ret['amount'] = $result['amount'];
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -323,7 +323,7 @@ class Mancubus {
                                                FROM `".DB_PREFIX."_collection_entry_".$this->_DB->real_escape_string($this->_collectionId)."` 
                                                WHERE ".$this->_User->getSQLRightsString()."
                                                AND `id` = '".$this->_DB->real_escape_string($entryId)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
 
@@ -336,7 +336,7 @@ class Mancubus {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -402,7 +402,7 @@ class Mancubus {
                }
 
                $queryStr = $querySelect.$queryFrom.$queryWhere.$queryOrder.$queryLimit;
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
 
@@ -413,14 +413,14 @@ class Mancubus {
                                }
 
                                $queryCountStr = "SELECT COUNT(t.value) AS amount ".$queryFrom.$queryWhere;
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryCountStr,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryCountStr));
                                $query = $this->_DB->query($queryCountStr);
                                $result = $query->fetch_assoc();
                                $ret['amount'] = $result['amount'];
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -458,7 +458,7 @@ class Mancubus {
                                                FROM `".DB_PREFIX."_collection_fields_".$this->_DB->real_escape_string($this->_collectionId)."` AS cf
                                                LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`
                                                ORDER BY `cf`.`sort`";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -468,7 +468,7 @@ class Mancubus {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -528,7 +528,7 @@ class Mancubus {
                        else {
                                $queryStr = "SELECT `fk_field`, `value`, `fk_entry`
                                                        FROM `".DB_PREFIX."_collection_entry2lookup_".$this->_DB->real_escape_string($this->_collectionId)."`";
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                try {
                                        $query = $this->_DB->query($queryStr);
                                        if($query !== false && $query->num_rows > 0) {
@@ -538,7 +538,7 @@ class Mancubus {
                                        }
                                }
                                catch (Exception $e) {
-                                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                                }
                                if(isset($this->_cacheLookupValuesForEntry[$this->_collectionId][$entryId][$fieldData['id']])) {
                                        $ret =  $this->_cacheLookupValuesForEntry[$this->_collectionId][$entryId][$fieldData['id']];
index f611a355625676ebb55e2ab454c02a7cf09ae8d0..58602b879324ce9bb5aaa596dec048e1ed172abd 100644 (file)
@@ -108,17 +108,17 @@ class Musicbrainz {
                        $url .= '?&fmt=json&limit='.$this->_resultLimit.'&query=';
                        $url .= 'artist:'.$artist.'%20AND%20release:'.$album.'%20AND%20format:CD';
 
-                       if(DEBUG) error_log("[DEBUG] musicbrainz release url: $url");
+                       if(DEBUG) Summoner::sysLog("[DEBUG] musicbrainz release url: $url");
 
                        $do = $this->_curlCall($url);
                        $data = '';
                        if(!empty($do)) {
                                $data = json_decode($do, true);
                                if(!empty($data)) {
-                                       if(DEBUG) error_log("[DEBUG] musicbrainz releases json data:".var_export($data,true));
+                                       if(DEBUG) Summoner::sysLog("[DEBUG] musicbrainz releases json data:".Summoner::cleanForLog($data));
                                }
                                else {
-                                       error_log("[ERROR] musicbrainz invalid releases json data:".var_export($do,true));
+                    Summoner::sysLog("[ERROR] musicbrainz invalid releases json data:".Summoner::cleanForLog($do));
                                }
                        }
 
@@ -182,10 +182,10 @@ class Musicbrainz {
                        if(!empty($do)) {
                                $data = json_decode($do, true);
                                if(!empty($data)) {
-                                       if(DEBUG) error_log("[DEBUG] musicbrainz release json data:".var_export($data,true));
+                                       if(DEBUG) Summoner::sysLog("[DEBUG] musicbrainz release json data:".Summoner::cleanForLog($data));
                                }
                                else {
-                                       error_log("[ERROR] musicbrainz invalid release json data:".var_export($do,true));
+                    Summoner::sysLog("[ERROR] musicbrainz invalid release json data:".Summoner::cleanForLog($do));
                                }
                        }
 
@@ -214,11 +214,11 @@ class Musicbrainz {
                                if(!empty($do)) {
                                        $imageData = json_decode($do, true);
                                        if(!empty($imageData)) {
-                                               if(DEBUG) error_log("[DEBUG] image release json data:".var_export($imageData,true));
+                                               if(DEBUG) Summoner::sysLog("[DEBUG] image release json data:".Summoner::cleanForLog($imageData));
                                                $ret['image'] = isset($imageData['images'][0]['image']) ? $imageData['images'][0]['image'] : '';
                                        }
                                        else {
-                                               error_log("[ERROR] image invalid release json data:".var_export($do,true));
+                        Summoner::sysLog("[ERROR] image invalid release json data:".Summoner::cleanForLog($do));
                                        }
                                }
                        }
@@ -269,7 +269,7 @@ class Musicbrainz {
                        curl_close($ch);
 
                        if($this->_DEBUG) {
-                               error_log('[DEBUG] '.__METHOD__.' headers '.var_export($_headers,true));
+                Summoner::sysLog('[DEBUG] '.__METHOD__.' headers '.Summoner::cleanForLog($_headers));
                        }
 
                        $ret = $_tmpFile;
@@ -325,7 +325,7 @@ class Musicbrainz {
                curl_close($ch);
 
                if($this->_DEBUG) {
-                       error_log('[DEBUG] '.__METHOD__.' headers '.var_export($_headers,true));
+            Summoner::sysLog('[DEBUG] '.__METHOD__.' headers '.Summoner::cleanForLog($_headers));
                }
 
                return $ret;
index 7eb10bd46f7ae3ae9157a4f96559727e1d8a470f..09184b27b8b31a551b73097272174c1230ea3d4c 100644 (file)
@@ -64,7 +64,7 @@ class Possessed {
                                                FROM `".DB_PREFIX."_group`
                                                WHERE ".$this->_User->getSQLRightsString("delete")." 
                                                ORDER BY `name`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -74,7 +74,7 @@ class Possessed {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                       Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -91,7 +91,7 @@ class Possessed {
                $queryStr = "SELECT `id`, `login`, `name`, `active`, `baseGroupId`, `protected`, `created`
                                                FROM `".DB_PREFIX."_user`
                                                WHERE ".$this->_User->getSQLRightsString("delete")."";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -102,7 +102,7 @@ class Possessed {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                       Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -140,7 +140,7 @@ class Possessed {
                                                        `rights` = 'rwxr--r--',
                                                        `owner` = 0,
                                                        `group` = '".$this->_DB->real_escape_string($group)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
 
@@ -151,7 +151,7 @@ class Possessed {
                                        $queryStrOwner = "UPDATE `".DB_PREFIX . "_user`
                                                                                SET `owner` = '".$this->_DB->real_escape_string($_userid)."'
                                                                                WHERE `id` = '".$this->_DB->real_escape_string($_userid)."'";
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrOwner,true));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrOwner));
                                        $this->_DB->query($queryStrOwner);
                                        if(!empty($groups)) {
                                                $groups[] = $group;
@@ -172,7 +172,7 @@ class Possessed {
                        }
                        catch (Exception $e) {
                                $this->_DB->rollback();
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -218,7 +218,7 @@ class Possessed {
                        }
                        $queryStr .= " WHERE `id` = '".$this->_DB->real_escape_string($id)."'
                                                AND ".$this->_User->getSQLRightsString("delete")."";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
 
@@ -243,7 +243,7 @@ class Possessed {
                        }
                        catch (Exception $e) {
                                $this->_DB->rollback();
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -265,7 +265,7 @@ class Possessed {
                                                FROM `".DB_PREFIX."_user`
                                                WHERE ".$this->_User->getSQLRightsString("delete")."
                                                AND `id` = '".$this->_DB->real_escape_string($userId)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows == 1) {
@@ -274,7 +274,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -308,7 +308,7 @@ class Possessed {
                        }
                        catch (Exception $e) {
                                $this->_DB->rollback();
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -333,13 +333,13 @@ class Possessed {
                                                `owner` = '".$this->_DB->real_escape_string($this->_User->param('id'))."',
                                                `group` = '".ADMIN_GROUP_ID."',
                                                `rights` = 'rwxr--r--'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                                $ret = true;
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -365,13 +365,13 @@ class Possessed {
                                                `modificationuser` = '".$this->_DB->real_escape_string($this->_User->param('id'))."'
                                                WHERE `id` = '".$this->_DB->real_escape_string($id)."'
                                                        AND ".$this->_User->getSQLRightsString("delete")."";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                                $ret = true;
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -392,13 +392,13 @@ class Possessed {
                                                WHERE ".$this->_User->getSQLRightsString("delete")."
                                                        AND `protected` = '0'
                                                        AND `id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $this->_DB->query($queryStr);
                                $ret = true;
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -419,7 +419,7 @@ class Possessed {
                                                        FROM `".DB_PREFIX."_group`
                                                        WHERE ".$this->_User->getSQLRightsString("delete")." 
                                                        AND `id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -427,7 +427,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -446,7 +446,7 @@ class Possessed {
                if (Summoner::validate($name, 'nospace')) {
                        $queryStr = "SELECT `id` FROM `".DB_PREFIX."_group`
                                                                WHERE `name` = '".$this->_DB->real_escape_string($name)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -454,7 +454,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -475,7 +475,7 @@ class Possessed {
                        $queryStr = "SELECT `id` FROM `" . DB_PREFIX . "_group`
                                                                WHERE `name` = '".$this->_DB->real_escape_string($name)."'
                                                                AND `id` != '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -483,7 +483,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -502,7 +502,7 @@ class Possessed {
                if (Summoner::validate($login, 'nospace')) {
                        $queryStr = "SELECT `id` FROM `".DB_PREFIX."_user`
                                                                WHERE `login` = '".$this->_DB->real_escape_string($login)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -510,7 +510,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -531,7 +531,7 @@ class Possessed {
                        $queryStr = "SELECT `id` FROM `" . DB_PREFIX . "_user`
                                                                WHERE `login` = '".$this->_DB->real_escape_string($login)."'
                                                                AND `id` != '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows < 1) {
@@ -539,7 +539,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -558,7 +558,7 @@ class Possessed {
                if(Summoner::validate($groupId,'digit')) {
                        $queryStr = "SELECT `id` FROM `".DB_PREFIX."_group`
                                                WHERE `id` = '".$this->_DB->real_escape_string($groupId)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if($query !== false && $query->num_rows > 0) {
@@ -566,7 +566,7 @@ class Possessed {
                                }
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -592,7 +592,7 @@ class Possessed {
                                if($clean === true) {
                                        $queryStrDelete = "DELETE FROM `".DB_PREFIX."_user2group`
                                                WHERE `fk_user_id` = '".$this->_DB->real_escape_string($userid)."'";
-                                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStrDelete,true));
+                                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStrDelete));
                                        $this->_DB->query($queryStrDelete);
                                }
 
@@ -601,11 +601,11 @@ class Possessed {
                                        $queryStr .= "('".$this->_DB->real_escape_string($userid)."','".$this->_DB->real_escape_string($g)."'),";
                                }
                                $queryStr = trim($queryStr, ",");
-                               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                                $ret = $this->_DB->query($queryStr);
                        }
                        catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                               Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -630,7 +630,7 @@ class Possessed {
                                                `".DB_PREFIX."_group` AS g
                                        WHERE u2g.fk_user_id = '".$this->_DB->real_escape_string($userId)."'
                                        AND u2g.fk_group_id = g.id";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -643,7 +643,7 @@ class Possessed {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                       Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
index 8b28280950284566d0a99db9b006a9ccb840e6fb..054747b7eef17f2ac88b5bb1740bc97742275c97 100644 (file)
@@ -577,4 +577,26 @@ class Summoner {
                }
                return round($bytes, 2) . ' ' . $units[$i];
        }
+
+    /**
+     * Make the input more safe for logging
+     *
+     * @param mixed $input The string|array to be made more safe
+     * @return string
+     */
+    static function cleanForLog(mixed $input): string {
+        $input = var_export($input, true);
+        $input = preg_replace( "/[\t\n\r]/", " ", $input);
+        return addcslashes($input, "\000..\037\177..\377\\");
+    }
+
+    /**
+     * error_log with a dedicated destination
+     * Uses LOGFILE const
+     *
+     * @param string $msg The string to be written to the log
+     */
+    static function sysLog(string $msg): void {
+        error_log(date("c")." ".$msg."\n", 3, LOGFILE);
+    }
 }
index 483ecda25b6de36b91bd5766d95c4dca21b4622d..3ec0c194a1d80afdf365a095f22da2f95d034ff8 100644 (file)
@@ -62,7 +62,7 @@ class Tentacle {
                                        FROM `".DB_PREFIX."_tool`  
                                        WHERE ".$this->_User->getSQLRightsString()."
                                        AND `action` = '".$this->_DB->real_escape_string($identifier)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if ($query !== false && $query->num_rows > 0) {
@@ -70,8 +70,8 @@ class Tentacle {
                        }
 
                } catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
-                       if(DEBUG) error_log("[DEBUG] ".__METHOD__." mysql query: ".$queryStr);
+            Summoner::cleanForLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                       if(QUERY_DEBUG) Summoner::sysLog("[DEBUG] ".__METHOD__." mysql query: ".$queryStr);
                }
 
                return $ret;
index e2c9fa572de2611d6d7ddc05c4450ea580253efa..05295ffc13ee002893f2c058818036f24dda94fb 100644 (file)
@@ -129,7 +129,7 @@ class Trite {
                                        LEFT JOIN `".DB_PREFIX."_group` AS g ON `c`.`group` = `g`.`id`
                                        WHERE ".$this->_User->getSQLRightsString($right, "c")."
                                        AND `c`.`id` = '".$this->_DB->real_escape_string($id)."'";
-                       if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+                       if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                        try {
                                $query = $this->_DB->query($queryStr);
                                if ($query !== false && $query->num_rows > 0) {
@@ -138,7 +138,7 @@ class Trite {
                                        $this->_id = $this->_collectionData['id'];
                                }
                        } catch (Exception $e) {
-                               error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+                Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                        }
                }
 
@@ -179,7 +179,7 @@ class Trite {
                                        LEFT JOIN `".DB_PREFIX."_group` AS g ON `c`.`group` = `g`.`id`
                                        WHERE ".$this->_User->getSQLRightsString($rightsMode, "c")."
                                        ORDER BY `c`.`name`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
 
@@ -190,7 +190,7 @@ class Trite {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -216,7 +216,7 @@ class Trite {
                                                FROM `".DB_PREFIX."_collection_fields_".$this->_id."` AS cf
                                                LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`
                                                ORDER BY `cf`.`sort`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                $query = $this->_DB->query($queryStr);
                try {
                        if($query !== false && $query->num_rows > 0) {
@@ -225,7 +225,7 @@ class Trite {
                                }
                        }
                } catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                }
 
                return $this->_cacheExistingCollectionFields;
@@ -287,7 +287,7 @@ class Trite {
                else {
                        $queryStr .= " ORDER BY `sf`.`displayname`, `e2l`.`value`";
                }
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                $query = $this->_DB->query($queryStr);
                try {
                        if($query !== false && $query->num_rows > 0) {
@@ -305,7 +305,7 @@ class Trite {
                                }
                        }
                } catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__."  mysql catch: ".$e->getMessage());
                }
 
                return $ret;
@@ -323,7 +323,7 @@ class Trite {
                                        FROM `".DB_PREFIX."_tool2collection` AS t2c
                                        LEFT JOIN `".DB_PREFIX."_tool` AS t ON t.id = t2c.fk_tool_id
                                        WHERE t2c.fk_collection_id = '".$this->_DB->real_escape_string($this->_id)."'";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -333,7 +333,7 @@ class Trite {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                return  $ret;
@@ -352,7 +352,7 @@ class Trite {
                $this->_collectionData['stats'] = array();
 
                $queryStr = "SELECT COUNT(*) AS entries FROM `".DB_PREFIX."_collection_entry_".$this->_id."`";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -361,7 +361,7 @@ class Trite {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
 
                $tags = $this->getTags();
@@ -377,7 +377,7 @@ class Trite {
                                                WHERE TABLE_SCHEMA = 'bibliotheca'
                                                AND TABLE_NAME LIKE 'bib_collection_%_".$this->_id."'
                                                ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC";
-               if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+               if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
                try {
                        $query = $this->_DB->query($queryStr);
                        if($query !== false && $query->num_rows > 0) {
@@ -387,7 +387,7 @@ class Trite {
                        }
                }
                catch (Exception $e) {
-                       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+            Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
                }
                $this->_collectionData['stats']['tableSize'] = Summoner::bytesToHuman($tableSize);
 
index 4da85fba340735f5529e3d5c3f275c26c42bbc58..509b513efe14c809c8d381da0b0c20cc45f51ce2 100644 (file)
@@ -28,7 +28,7 @@ $queryStr = "SELECT (DATA_LENGTH + INDEX_LENGTH) AS `size`
                                                FROM information_schema.TABLES
                                                WHERE TABLE_SCHEMA = 'bibliotheca'
                                                ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC";
-if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
+if(QUERY_DEBUG) Summoner::sysLog("[QUERY] ".__METHOD__." query: ".Summoner::cleanForLog($queryStr));
 try {
        $query = $DB->query($queryStr);
        if($query !== false && $query->num_rows > 0) {
@@ -38,7 +38,7 @@ try {
        }
 }
 catch (Exception $e) {
-       error_log("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+    Summoner::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
 }
 $TemplateData['overallTableSize'] = Summoner::bytesToHuman($overallTableSize);
 
index 65f99d6ae62fd740795bdb7107e826920578b74d..36038df13452896cff9d8769ce2271941d7939f2 100644 (file)
@@ -63,7 +63,7 @@ if(isset($_POST['submitFormSearch'])) {
                                $IMDB->search($search);
                        }
                        catch (Exception $e) {
-                               if(DEBUG) error_log("[DEBUG] imdb search catch: ".$e->getMessage());
+                               if(DEBUG) Summoner::sysLog("[DEBUG] imdb search catch: ".$e->getMessage());
                        }
 
                        if ($IMDB->isReady) {
@@ -93,7 +93,7 @@ if(isset($_POST['submitFormSave'])) {
                                $IMDB->search($_imdbId); // cache used
                        }
                        catch (Exception $e) {
-                               if(DEBUG) error_log("[DEBUG] imdb search catch: ".$e->getMessage());
+                               if(DEBUG) Summoner::sysLog("[DEBUG] imdb search catch: ".$e->getMessage());
                        }
 
                        if ($IMDB->isReady) {