From 022ceba20d80a9f864be318733c8415c48c61a96 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Mon, 20 Jul 2015 11:33:48 +0200 Subject: [PATCH] fixup to 998763b so .. basicly everything was wrong with this one --- includes/community.class.php | 4 ++-- includes/kernel.php | 10 ++++++---- includes/loot.class.php | 10 +++++----- includes/utilities.php | 10 ++-------- localization/lang.class.php | 8 ++++---- pages/event.php | 2 +- pages/item.php | 2 +- pages/npc.php | 2 +- pages/object.php | 2 +- pages/screenshot.php | 14 +++++++------- 10 files changed, 30 insertions(+), 34 deletions(-) diff --git a/includes/community.class.php b/includes/community.class.php index e206359e..77afd721 100644 --- a/includes/community.class.php +++ b/includes/community.class.php @@ -190,7 +190,7 @@ class CommunityContent } else { - Util::logError('Comment '.$c['id'].' belongs to nonexistant subject.', E_USER_NOTICE); + trigger_error('Comment '.$c['id'].' belongs to nonexistant subject.', E_USER_NOTICE); unset($comments[$idx]); } } @@ -341,7 +341,7 @@ class CommunityContent { if (empty($p['name'])) { - Util::logError('Screenshot linked to nonexistant type/typeId combination: '.$p['type'].'/'.$p['typeId'], E_USER_NOTICE); + trigger_error('Screenshot linked to nonexistant type/typeId combination: '.$p['type'].'/'.$p['typeId'], E_USER_NOTICE); unset($p); } else diff --git a/includes/kernel.php b/includes/kernel.php index 8efaa41b..617e40d3 100644 --- a/includes/kernel.php +++ b/includes/kernel.php @@ -73,7 +73,7 @@ foreach ($sets as $k => $v) // this should not have been possible if (!strlen($v['value']) && !($v['flags'] & CON_FLAG_TYPE_STRING) && !$php) { - Util::logError('Aowow config value CFG_'.strtoupper($k).' is empty - config will not be used!', E_USER_ERROR); + trigger_error('Aowow config value CFG_'.strtoupper($k).' is empty - config will not be used!', E_USER_ERROR); continue; } @@ -87,12 +87,12 @@ foreach ($sets as $k => $v) $val = preg_replace('/[^\p{L}0-9~\s_\-\'\/\.:,]/ui', '', $v['value']); else if ($php) { - Util::logError('PHP config value '.strtolower($k).' has no type set - config will not be used!', E_USER_ERROR); + trigger_error('PHP config value '.strtolower($k).' has no type set - config will not be used!', E_USER_ERROR); continue; } else // if (!$php) { - Util::logError('Aowow config value CFG_'.strtoupper($k).' has no type set - value forced to 0!', E_USER_ERROR); + trigger_error('Aowow config value CFG_'.strtoupper($k).' has no type set - value forced to 0!', E_USER_ERROR); $val = 0; } @@ -120,8 +120,10 @@ set_error_handler(function($errNo, $errStr, $errFile, $errLine) { else if ($errNo == E_USER_WARNING) // 0x0200 $errName = 'E_USER_WARNING'; else if ($errNo == E_USER_NOTICE) // 0x0400 + { $errName = 'E_USER_NOTICE'; $uGroup = U_GROUP_STAFF; + } else if ($errNo == E_RECOVERABLE_ERROR) // 0x1000 $errName = 'E_RECOVERABLE_ERROR'; @@ -151,7 +153,7 @@ if (!CLI) // Setup Session if (CFG_SESSION_CACHE_DIR && Util::checkOrCreateDirectory(CFG_SESSION_CACHE_DIR)) - session_save_path(CFG_SESSION_CACHE_DIR); + session_save_path(getcwd().'/'.CFG_SESSION_CACHE_DIR); session_set_cookie_params(15 * YEAR, '/', '', $secure, true); session_cache_limiter('private'); diff --git a/includes/loot.class.php b/includes/loot.class.php index 8cd0d500..dcf2f631 100644 --- a/includes/loot.class.php +++ b/includes/loot.class.php @@ -175,7 +175,7 @@ class Loot } else // shouldn't have happened { - Util::logError('Unhandled case in calculating chance for item '.$entry['Item'].'!'); + trigger_error('Unhandled case in calculating chance for item '.$entry['Item'].'!', E_USER_WARNING); continue; } @@ -189,7 +189,7 @@ class Loot $sum = 0; else if ($sum >= 100.01) { - Util::logError('Loot entry '.$lootId.' / group '.$k.' has a total chance of '.number_format($sum, 2).'%. Some items cannot drop!'); + trigger_error('Loot entry '.$lootId.' / group '.$k.' has a total chance of '.number_format($sum, 2).'%. Some items cannot drop!', E_USER_WARNING); $sum = 100; } @@ -378,13 +378,13 @@ class Loot { // check for possible database inconsistencies if (!$ref['chance'] && !$ref['isGrouped']) - Util::logError('Loot by Item: Ungrouped Item/Ref '.$ref['item'].' has 0% chance assigned!'); + trigger_error('Loot by Item: Ungrouped Item/Ref '.$ref['item'].' has 0% chance assigned!', E_USER_WARNING); if ($ref['isGrouped'] && $ref['sumChance'] > 100) - Util::logError('Loot by Item: Group with Item/Ref '.$ref['item'].' has '.number_format($ref['sumChance'], 2).'% total chance! Some items cannot drop!'); + trigger_error('Loot by Item: Group with Item/Ref '.$ref['item'].' has '.number_format($ref['sumChance'], 2).'% total chance! Some items cannot drop!', E_USER_WARNING); if ($ref['isGrouped'] && $ref['sumChance'] >= 100 && !$ref['chance']) - Util::logError('Loot by Item: Item/Ref '.$ref['item'].' with adaptive chance cannot drop. Group already at 100%!'); + trigger_error('Loot by Item: Item/Ref '.$ref['item'].' with adaptive chance cannot drop. Group already at 100%!', E_USER_WARNING); $chance = abs($ref['chance'] ?: (100 - $ref['sumChance']) / $ref['nZeroItems']) / 100; diff --git a/includes/utilities.php b/includes/utilities.php index 2105d182..74e7a1f9 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -698,12 +698,6 @@ class Util public static $wowheadLink = ''; private static $notes = []; - public static function logError($errStr, $mode = E_USER_WARNING) - { - // handled by set_error_handler - trigger_error($errStr, $mode); - } - public static function addNote($uGroupMask, $str) { self::$notes[] = [$uGroupMask, $str]; @@ -1712,9 +1706,9 @@ class Util $path = preg_replace('|/+|', '/', $path); if (!is_dir($path) && !@mkdir($path, self::FILE_ACCESS, true)) - self::logError('Could not create directory: '.$path, E_USER_ERROR); + trigger_error('Could not create directory: '.$path, E_USER_ERROR); else if (!is_writable($path) && !@chmod($path, self::FILE_ACCESS)) - self::logError('Cannot write into directory: '.$path, E_USER_ERROR); + trigger_error('Cannot write into directory: '.$path, E_USER_ERROR); else return true; diff --git a/localization/lang.class.php b/localization/lang.class.php index 7226cca1..b5c92723 100644 --- a/localization/lang.class.php +++ b/localization/lang.class.php @@ -49,7 +49,7 @@ class Lang { if (!isset(self::$$prop)) { - Util::logError('Lang - tried to use undefined property Lang::$'.$prop); + trigger_error('Lang - tried to use undefined property Lang::$'.$prop, E_USER_WARNING); return null; } @@ -58,7 +58,7 @@ class Lang { if (!isset($var[$key])) { - Util::logError('Lang - undefined key "'.$key.'" in property Lang::$'.$prop.'[\''.implode('\'][\'', $args).'\']'); + trigger_error('Lang - undefined key "'.$key.'" in property Lang::$'.$prop.'[\''.implode('\'][\'', $args).'\']', E_USER_WARNING); return null; } @@ -73,14 +73,14 @@ class Lang if (!isset(self::$$prop)) { - Util::logError('Lang::sort - tried to use undefined property Lang::$'.$prop); + trigger_error('Lang::sort - tried to use undefined property Lang::$'.$prop, E_USER_WARNING); return null; } $var = &self::$$prop; if (!isset($var[$group])) { - Util::logError('Lang::sort - tried to use undefined property Lang::$'.$prop.'[\''.$group.'\']'); + trigger_error('Lang::sort - tried to use undefined property Lang::$'.$prop.'[\''.$group.'\']', E_USER_WARNING); return null; } diff --git a/pages/event.php b/pages/event.php index 1ca8a2d7..e8f68340 100644 --- a/pages/event.php +++ b/pages/event.php @@ -218,7 +218,7 @@ class EventPage extends GenericPage if ($v > 0) $list[] = $v; else if ($v === null) - Util::logError('game_event_prerequisite: this event has itself as prerequisite'); + trigger_error('game_event_prerequisite: this event has itself as prerequisite', E_USER_WARNING); }); if ($list) diff --git a/pages/item.php b/pages/item.php index 7b84b77e..744d7091 100644 --- a/pages/item.php +++ b/pages/item.php @@ -355,7 +355,7 @@ class ItemPage extends genericPage } else { - Util::logError('Referenced PageTextId #'.$next.' is not in DB'); + trigger_error('Referenced PageTextId #'.$next.' is not in DB', E_USER_WARNING); break; } } diff --git a/pages/npc.php b/pages/npc.php index f0689583..e9c8a776 100644 --- a/pages/npc.php +++ b/pages/npc.php @@ -509,7 +509,7 @@ class NpcPage extends GenericPage } } else - Util::logError('NPC '.$this->typeId.' is flagged as trainer, but doesn\'t have any spells set'); + trigger_error('NPC '.$this->typeId.' is flagged as trainer, but doesn\'t have any spells set', E_USER_WARNING); } // tab: sells diff --git a/pages/object.php b/pages/object.php index a57f5074..882bd924 100644 --- a/pages/object.php +++ b/pages/object.php @@ -213,7 +213,7 @@ class ObjectPage extends GenericPage } else { - Util::logError('Referenced PageTextId #'.$next.' is not in DB'); + trigger_error('Referenced PageTextId #'.$next.' is not in DB', E_USER_WARNING); break; } } diff --git a/pages/screenshot.php b/pages/screenshot.php index 98cbb788..3aa653cb 100644 --- a/pages/screenshot.php +++ b/pages/screenshot.php @@ -35,7 +35,7 @@ class ScreenshotPage extends GenericPage if ($this->minSize <= 0) { - Util::logError('config error: dimensions for uploaded screenshots equal or less than zero. Value forced to 200'); + trigger_error('config error: dimensions for uploaded screenshots equal or less than zero. Value forced to 200', E_USER_WARNING); $this->minSize = 200; } @@ -276,26 +276,26 @@ class ScreenshotPage extends GenericPage switch ($_FILES['screenshotfile']['error']) { case 1: - Util::logError('validateScreenshot - the file exceeds the maximum size of '.ini_get('upload_max_filesize')); + trigger_error('validateScreenshot - the file exceeds the maximum size of '.ini_get('upload_max_filesize'), E_USER_WARNING); return Lang::screenshot('error', 'selectSS'); case 3: - Util::logError('validateScreenshot - upload was interrupted'); + trigger_error('validateScreenshot - upload was interrupted'); return Lang::screenshot('error', 'selectSS'); case 4: - Util::logError('validateScreenshot() - no file was received'); + trigger_error('validateScreenshot() - no file was received', E_USER_WARNING); return Lang::screenshot('error', 'selectSS'); case 6: - Util::logError('validateScreenshot - temporary upload directory is not set'); + trigger_error('validateScreenshot - temporary upload directory is not set', E_USER_WARNING); return Lang::main('intError'); case 7: - Util::logError('validateScreenshot - could not write temporary file to disk'); + trigger_error('validateScreenshot - could not write temporary file to disk', E_USER_WARNING); return Lang::main('intError'); } // points to invalid file (hack attempt) if (!is_uploaded_file($_FILES['screenshotfile']['tmp_name'])) { - Util::logError('validateScreenshot - uploaded file not in upload directory'); + trigger_error('validateScreenshot - uploaded file not in upload directory', E_USER_WARNING); return Lang::main('intError'); }