From: Banana Date: Mon, 9 Oct 2023 12:47:40 +0000 (+0200) Subject: changed how the logs are written X-Git-Tag: 1.6~24 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=d46de80332c080aa5cfa5d1cc2ccde65cd488e28;p=bibliotheca-php.git changed how the logs are written --- diff --git a/CHANGELOG b/CHANGELOG index bb817a3..9be7175 100644 --- 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 index 0000000..2a1fe5d --- /dev/null +++ b/upgrade/from-version-1.5.txt @@ -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 diff --git a/webclient/api.php b/webclient/api.php index 0dad6b8..7a2ec6a 100644 --- a/webclient/api.php +++ b/webclient/api.php @@ -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); } diff --git a/webclient/config/config.php.default b/webclient/config/config.php.default index ad4dfbe..17b878b 100644 --- a/webclient/config/config.php.default +++ b/webclient/config/config.php.default @@ -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~'; diff --git a/webclient/index.php b/webclient/index.php index 760f13c..8465a86 100644 --- a/webclient/index.php +++ b/webclient/index.php @@ -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); } diff --git a/webclient/lib/doomguy.class.php b/webclient/lib/doomguy.class.php index 7506c29..a422ec1 100644 --- a/webclient/lib/doomguy.class.php +++ b/webclient/lib/doomguy.class.php @@ -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); diff --git a/webclient/lib/googlebookparser.class.php b/webclient/lib/googlebookparser.class.php index 39a9a13..2d96612 100644 --- a/webclient/lib/googlebookparser.class.php +++ b/webclient/lib/googlebookparser.class.php @@ -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; diff --git a/webclient/lib/gorenest.class.php b/webclient/lib/gorenest.class.php index 5abc31a..c6c98ef 100644 --- a/webclient/lib/gorenest.class.php +++ b/webclient/lib/gorenest.class.php @@ -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()); } } diff --git a/webclient/lib/managecollectionfields.class.php b/webclient/lib/managecollectionfields.class.php index 398919c..0e9c46a 100644 --- a/webclient/lib/managecollectionfields.class.php +++ b/webclient/lib/managecollectionfields.class.php @@ -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; diff --git a/webclient/lib/managecollections.class.php b/webclient/lib/managecollections.class.php index 5400031..0b630ee 100644 --- a/webclient/lib/managecollections.class.php +++ b/webclient/lib/managecollections.class.php @@ -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()); } } } diff --git a/webclient/lib/manageentry.class.php b/webclient/lib/manageentry.class.php index 94d9dce..7025717 100644 --- a/webclient/lib/manageentry.class.php +++ b/webclient/lib/manageentry.class.php @@ -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)) { diff --git a/webclient/lib/managetags.class.php b/webclient/lib/managetags.class.php index 6ecb60e..13f2d8b 100644 --- a/webclient/lib/managetags.class.php +++ b/webclient/lib/managetags.class.php @@ -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.'; } diff --git a/webclient/lib/mancubus.class.php b/webclient/lib/mancubus.class.php index 30d830e..2dfe64f 100644 --- a/webclient/lib/mancubus.class.php +++ b/webclient/lib/mancubus.class.php @@ -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']]; diff --git a/webclient/lib/musicbrainz.class.php b/webclient/lib/musicbrainz.class.php index f611a35..58602b8 100644 --- a/webclient/lib/musicbrainz.class.php +++ b/webclient/lib/musicbrainz.class.php @@ -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; diff --git a/webclient/lib/possessed.class.php b/webclient/lib/possessed.class.php index 7eb10bd..09184b2 100644 --- a/webclient/lib/possessed.class.php +++ b/webclient/lib/possessed.class.php @@ -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; diff --git a/webclient/lib/summoner.class.php b/webclient/lib/summoner.class.php index 8b28280..054747b 100644 --- a/webclient/lib/summoner.class.php +++ b/webclient/lib/summoner.class.php @@ -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); + } } diff --git a/webclient/lib/tentacle.class.php b/webclient/lib/tentacle.class.php index 483ecda..3ec0c19 100644 --- a/webclient/lib/tentacle.class.php +++ b/webclient/lib/tentacle.class.php @@ -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; diff --git a/webclient/lib/trite.class.php b/webclient/lib/trite.class.php index e2c9fa5..05295ff 100644 --- a/webclient/lib/trite.class.php +++ b/webclient/lib/trite.class.php @@ -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); diff --git a/webclient/view/default/sysinfo/sysinfo.php b/webclient/view/default/sysinfo/sysinfo.php index 4da85fb..509b513 100644 --- a/webclient/view/default/sysinfo/sysinfo.php +++ b/webclient/view/default/sysinfo/sysinfo.php @@ -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); diff --git a/webclient/view/default/tool/tool-imdbweb.php b/webclient/view/default/tool/tool-imdbweb.php index 65f99d6..36038df 100644 --- a/webclient/view/default/tool/tool-imdbweb.php +++ b/webclient/view/default/tool/tool-imdbweb.php @@ -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) {