From 22d02378ef71ffc2d48c19831da731ee2fc951b4 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Tue, 27 Mar 2018 12:39:14 +0200 Subject: [PATCH] Config/Profiler * update config to enable/disable profiler in general, instead of just the queue * regenerate affected files on config change --- includes/ajaxHandler/admin.class.php | 3 ++- includes/ajaxHandler/profile.class.php | 3 +++ includes/profiler.class.php | 2 +- pages/arenateam.php | 3 +++ pages/arenateams.php | 3 +++ pages/guild.php | 3 +++ pages/guilds.php | 3 +++ pages/profiler.php | 8 ++++++++ pages/profiles.php | 3 +++ prQueue | 4 ++-- setup/db_structure.sql | 4 ++-- setup/tools/clisetup/siteconfig.func.php | 3 ++- setup/updates/1522146994_01.sql | 2 ++ 13 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 setup/updates/1522146994_01.sql diff --git a/includes/ajaxHandler/admin.class.php b/includes/ajaxHandler/admin.class.php index b9edffcb..93982ccd 100644 --- a/includes/ajaxHandler/admin.class.php +++ b/includes/ajaxHandler/admin.class.php @@ -471,7 +471,8 @@ class AjaxAdmin extends AjaxHandler $msg .= ' * remember to rebuild all static files for the language you just added.
'; $msg .= ' * you can speed this up by supplying the regionCode to the setup:
--locales= -f
'; break; - case 'profiler_queue': + case 'profiler_enable': + $buildList = 'realms,realmMenu'; $fn = function($x) use (&$msg) { if (!$x) return true; diff --git a/includes/ajaxHandler/profile.class.php b/includes/ajaxHandler/profile.class.php index 50cded7d..5c6436cc 100644 --- a/includes/ajaxHandler/profile.class.php +++ b/includes/ajaxHandler/profile.class.php @@ -47,6 +47,9 @@ class AjaxProfile extends AjaxHandler if (!$this->params) return; + if (!CFG_PROFILER_ENABLE) + return; + switch ($this->params[0]) { case 'unlink': diff --git a/includes/profiler.class.php b/includes/profiler.class.php index 6be872d5..dcee1f3c 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -244,7 +244,7 @@ class Profiler public static function resyncStatus($type, array $subjectGUIDs) { - $response = [CFG_PROFILER_QUEUE ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 + $response = [CFG_PROFILER_ENABLE ? 2 : 0]; // in theory you could have multiple queues; used as divisor for: (15 / x) + 2 if (!$subjectGUIDs) $response[] = [PR_QUEUE_STATUS_ENDED, 0, 0, PR_QUEUE_ERROR_CHAR]; else diff --git a/pages/arenateam.php b/pages/arenateam.php index ff2104e1..24ec0f99 100644 --- a/pages/arenateam.php +++ b/pages/arenateam.php @@ -20,6 +20,9 @@ class ArenaTeamPage extends GenericPage public function __construct($pageCall, $pageParam) { + if (!CFG_PROFILER_ENABLE) + $this->error(); + $params = array_map('urldecode', explode('.', $pageParam)); if ($params[0]) $params[0] = Profiler::urlize($params[0]); diff --git a/pages/arenateams.php b/pages/arenateams.php index 3fdddf26..e72f2f59 100644 --- a/pages/arenateams.php +++ b/pages/arenateams.php @@ -17,6 +17,9 @@ class ArenaTeamsPage extends GenericPage public function __construct($pageCall, $pageParam) { + if (!CFG_PROFILER_ENABLE) + $this->error(); + $this->getSubjectFromUrl($pageParam); $this->filterObj = new ArenaTeamListFilter(); diff --git a/pages/guild.php b/pages/guild.php index 39a3ee0d..8ba18176 100644 --- a/pages/guild.php +++ b/pages/guild.php @@ -20,6 +20,9 @@ class GuildPage extends GenericPage public function __construct($pageCall, $pageParam) { + if (!CFG_PROFILER_ENABLE) + $this->error(); + $params = array_map('urldecode', explode('.', $pageParam)); if ($params[0]) $params[0] = Profiler::urlize($params[0]); diff --git a/pages/guilds.php b/pages/guilds.php index 05aae2fa..cee61f76 100644 --- a/pages/guilds.php +++ b/pages/guilds.php @@ -17,6 +17,9 @@ class GuildsPage extends GenericPage public function __construct($pageCall, $pageParam) { + if (!CFG_PROFILER_ENABLE) + $this->error(); + $this->getSubjectFromUrl($pageParam); $this->filterObj = new GuildListFilter(); diff --git a/pages/profiler.php b/pages/profiler.php index 08a941b8..f0a26ddb 100644 --- a/pages/profiler.php +++ b/pages/profiler.php @@ -13,6 +13,14 @@ class ProfilerPage extends GenericPage protected $js = ['profile_all.js', 'profile.js']; protected $css = [['path' => 'Profiler.css']]; + public function __construct($pageCall, $pageParam) + { + if (!CFG_PROFILER_ENABLE) + $this->error(); + + parent::__construct($pageCall, $pageParam); + } + protected function generateContent() { $this->addJS('?data=realms&locale='.User::$localeId.'&t='.$_SESSION['dataKey']); diff --git a/pages/profiles.php b/pages/profiles.php index a0943620..3cd64741 100644 --- a/pages/profiles.php +++ b/pages/profiles.php @@ -20,6 +20,9 @@ class ProfilesPage extends GenericPage public function __construct($pageCall, $pageParam) { + if (!CFG_PROFILER_ENABLE) + $this->error(); + $this->getSubjectFromUrl($pageParam); $realms = []; diff --git a/prQueue b/prQueue index 4d2c645d..ad162fd7 100755 --- a/prQueue +++ b/prQueue @@ -41,8 +41,8 @@ $error = function ($type, $typeId, $realmId) }; -// if (CFG_PROFILER_QUEUE) - wont work because it is not redefined if changed in config -while (DB::Aowow()->selectCell('SELECT value FROM ?_config WHERE `key` = "profiler_queue"')) +// if (CFG_PROFILER_ENABLE) - wont work because it is not redefined if changed in config +while (DB::Aowow()->selectCell('SELECT value FROM ?_config WHERE `key` = "profiler_enable"')) { if (($tDiff = (microtime(true) - $tCycle)) < (CFG_PROFILER_QUEUE_DELAY / 1000)) { diff --git a/setup/db_structure.sql b/setup/db_structure.sql index d6202737..7eea4c1d 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -2996,7 +2996,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_config` WRITE; /*!40000 ALTER TABLE `aowow_config` DISABLE KEYS */; -INSERT INTO `aowow_config` VALUES ('sql_limit_search','500',1,129,'default: 500 - max results for search'),('sql_limit_default','300',1,129,'default: 300 - max results for listviews'),('sql_limit_quicksearch','10',1,129,'default: 10 - max results for suggestions'),('sql_limit_none','0',1,129,'default: 0 - unlimited results (i wouldn\'t change that mate)'),('ttl_rss','60',1,129,'default: 60 - time to live for RSS (in seconds)'),('name','Aowow Database Viewer (ADV)',1,136,' - website title'),('name_short','Aowow',1,136,' - feed title'),('board_url','http://www.wowhead.com/forums?board=',1,136,' - another halfbaked javascript thing..'),('contact_email','feedback@aowow.org',1,136,' - displayed sender for auth-mails, ect'),('battlegroup','Pure Pwnage',1,136,' - pretend, we belong to a battlegroup to satisfy profiler-related Jscripts'),('debug','0',1,132,'default: 0 - disable cache, enable sql-errors, enable error_reporting'),('maintenance','1',1,132,'default: 0 - display brb gnomes and block access for non-staff'),('user_max_votes','50',1,129,'default: 50 - vote limit per day'),('force_ssl','0',1,132,'default: 0 - enforce SSL, if the server is behind a load balancer'),('locales','333',1,161,'default: 0x14D - allowed locales - 0:English, 2:French, 3:German, 6:Spanish, 8:Russian'),('screenshot_min_size','200',1,129,'default: 200 - minimum dimensions of uploaded screenshots in px (yes, it\'s square)'),('site_host','',1,136,' - points js to executable files'),('static_host','',1,136,' - points js to images & scripts'),('cache_decay','25200',2,129,'default: 60 * 60 * 7 - time to keep cache in seconds'),('cache_mode','1',2,161,'default: 1 - set cache method - 0:filecache, 1:memcached'),('cache_dir','',2,136,'default: cache/template - generated pages are saved here (requires CACHE_MODE: filecache)'),('acc_failed_auth_block','900',3,129,'default: 15 * 60 - how long an account is closed after exceeding FAILED_AUTH_COUNT (in seconds)'),('acc_failed_auth_count','5',3,129,'default: 5 - how often invalid passwords are tolerated'),('acc_allow_register','1',3,132,'default: 1 - allow/disallow account creation (requires AUTH_MODE: aowow)'),('acc_auth_mode','0',3,145,'default: 0 - source to auth against - 0:aowow, 1:TC auth-table, 2:external script'),('acc_create_save_decay','604800',3,129,'default: 604800 - time in wich an unconfirmed account cannot be overwritten by new registrations'),('acc_recovery_decay','300',3,129,'default: 300 - time to recover your account and new recovery requests are blocked'),('session_timeout_delay','3600',4,129,'default: 60 * 60 - non-permanent session times out in time() + X'),('session.gc_maxlifetime','604800',4,200,'default: 7*24*60*60 - lifetime of session data'),('session.gc_probability','1',4,200,'default: 0 - probability to remove session data on garbage collection'),('session.gc_divisor','100',4,200,'default: 100 - probability to remove session data on garbage collection'),('session_cache_dir','',4,136,'default: - php sessions are saved here. Leave empty to use php default directory.'),('rep_req_upvote','125',5,129,'default: 125 - required reputation to upvote comments'),('rep_req_downvote','250',5,129,'default: 250 - required reputation to downvote comments'),('rep_req_comment','75',5,129,'default: 75 - required reputation to write a comment'),('rep_req_reply','75',5,129,'default: 75 - required reputation to write a reply'),('rep_req_supervote','2500',5,129,'default: 2500 - required reputation for double vote effect'),('rep_req_votemore_base','2000',5,129,'default: 2000 - gains more votes past this threshold'),('rep_reward_register','100',5,129,'default: 100 - activated an account'),('rep_reward_upvoted','5',5,129,'default: 5 - comment received upvote'),('rep_reward_downvoted','0',5,129,'default: 0 - comment received downvote'),('rep_reward_good_report','10',5,129,'default: 10 - filed an accepted report'),('rep_reward_bad_report','0',5,129,'default: 0 - filed a rejected report'),('rep_reward_dailyvisit','5',5,129,'default: 5 - daily visit'),('rep_reward_user_warned','-50',5,129,'default: -50 - moderator imposed a warning'),('rep_reward_comment','1',5,129,'default: 1 - created a comment (not a reply) '),('rep_req_premium','25000',5,129,'default: 25000 - required reputation for premium status through reputation'),('rep_reward_upload','10',5,129,'default: 10 - suggested / uploaded video / screenshot was approved'),('rep_reward_article','100',5,129,'default: 100 - submitted an approved article/guide'),('rep_reward_user_suspended','-200',5,129,'default: -200 - moderator revoked rights'),('rep_req_votemore_add','250',5,129,'default: 250 - required reputation per additional vote past threshold'),('serialize_precision','5',0,65,' - some derelict code, probably unused'),('memory_limit','1500M',0,200,'default: 1500M - parsing spell.dbc is quite intense'),('default_charset','UTF-8',0,72,'default: UTF-8'),('analytics_user','',6,136,'default: - enter your GA-user here to track site stats'),('profiler_queue','0',7,132,'default: 0 - enable/disable profiler queue'),('profiler_queue_delay','3000',7,129,'default: 3000 - min. delay between queue cycles (in ms)'),('profiler_resync_ping','5000',7,129,'default: 5000 - how often the javascript asks for for updates, when queued (in ms)'),('profiler_resync_delay','3600',7,129,'default: 1*60*60 - how often a character can be refreshed (in sec)'); +INSERT INTO `aowow_config` VALUES ('sql_limit_search','500',1,129,'default: 500 - max results for search'),('sql_limit_default','300',1,129,'default: 300 - max results for listviews'),('sql_limit_quicksearch','10',1,129,'default: 10 - max results for suggestions'),('sql_limit_none','0',1,129,'default: 0 - unlimited results (i wouldn\'t change that mate)'),('ttl_rss','60',1,129,'default: 60 - time to live for RSS (in seconds)'),('name','Aowow Database Viewer (ADV)',1,136,' - website title'),('name_short','Aowow',1,136,' - feed title'),('board_url','http://www.wowhead.com/forums?board=',1,136,' - another halfbaked javascript thing..'),('contact_email','feedback@aowow.org',1,136,' - displayed sender for auth-mails, ect'),('battlegroup','Pure Pwnage',1,136,' - pretend, we belong to a battlegroup to satisfy profiler-related Jscripts'),('debug','0',1,132,'default: 0 - disable cache, enable sql-errors, enable error_reporting'),('maintenance','1',1,132,'default: 0 - display brb gnomes and block access for non-staff'),('user_max_votes','50',1,129,'default: 50 - vote limit per day'),('force_ssl','0',1,132,'default: 0 - enforce SSL, if the server is behind a load balancer'),('locales','333',1,161,'default: 0x14D - allowed locales - 0:English, 2:French, 3:German, 6:Spanish, 8:Russian'),('screenshot_min_size','200',1,129,'default: 200 - minimum dimensions of uploaded screenshots in px (yes, it\'s square)'),('site_host','',1,136,' - points js to executable files'),('static_host','',1,136,' - points js to images & scripts'),('cache_decay','25200',2,129,'default: 60 * 60 * 7 - time to keep cache in seconds'),('cache_mode','1',2,161,'default: 1 - set cache method - 0:filecache, 1:memcached'),('cache_dir','',2,136,'default: cache/template - generated pages are saved here (requires CACHE_MODE: filecache)'),('acc_failed_auth_block','900',3,129,'default: 15 * 60 - how long an account is closed after exceeding FAILED_AUTH_COUNT (in seconds)'),('acc_failed_auth_count','5',3,129,'default: 5 - how often invalid passwords are tolerated'),('acc_allow_register','1',3,132,'default: 1 - allow/disallow account creation (requires AUTH_MODE: aowow)'),('acc_auth_mode','0',3,145,'default: 0 - source to auth against - 0:aowow, 1:TC auth-table, 2:external script'),('acc_create_save_decay','604800',3,129,'default: 604800 - time in wich an unconfirmed account cannot be overwritten by new registrations'),('acc_recovery_decay','300',3,129,'default: 300 - time to recover your account and new recovery requests are blocked'),('session_timeout_delay','3600',4,129,'default: 60 * 60 - non-permanent session times out in time() + X'),('session.gc_maxlifetime','604800',4,200,'default: 7*24*60*60 - lifetime of session data'),('session.gc_probability','1',4,200,'default: 0 - probability to remove session data on garbage collection'),('session.gc_divisor','100',4,200,'default: 100 - probability to remove session data on garbage collection'),('session_cache_dir','',4,136,'default: - php sessions are saved here. Leave empty to use php default directory.'),('rep_req_upvote','125',5,129,'default: 125 - required reputation to upvote comments'),('rep_req_downvote','250',5,129,'default: 250 - required reputation to downvote comments'),('rep_req_comment','75',5,129,'default: 75 - required reputation to write a comment'),('rep_req_reply','75',5,129,'default: 75 - required reputation to write a reply'),('rep_req_supervote','2500',5,129,'default: 2500 - required reputation for double vote effect'),('rep_req_votemore_base','2000',5,129,'default: 2000 - gains more votes past this threshold'),('rep_reward_register','100',5,129,'default: 100 - activated an account'),('rep_reward_upvoted','5',5,129,'default: 5 - comment received upvote'),('rep_reward_downvoted','0',5,129,'default: 0 - comment received downvote'),('rep_reward_good_report','10',5,129,'default: 10 - filed an accepted report'),('rep_reward_bad_report','0',5,129,'default: 0 - filed a rejected report'),('rep_reward_dailyvisit','5',5,129,'default: 5 - daily visit'),('rep_reward_user_warned','-50',5,129,'default: -50 - moderator imposed a warning'),('rep_reward_comment','1',5,129,'default: 1 - created a comment (not a reply) '),('rep_req_premium','25000',5,129,'default: 25000 - required reputation for premium status through reputation'),('rep_reward_upload','10',5,129,'default: 10 - suggested / uploaded video / screenshot was approved'),('rep_reward_article','100',5,129,'default: 100 - submitted an approved article/guide'),('rep_reward_user_suspended','-200',5,129,'default: -200 - moderator revoked rights'),('rep_req_votemore_add','250',5,129,'default: 250 - required reputation per additional vote past threshold'),('serialize_precision','5',0,65,' - some derelict code, probably unused'),('memory_limit','1500M',0,200,'default: 1500M - parsing spell.dbc is quite intense'),('default_charset','UTF-8',0,72,'default: UTF-8'),('analytics_user','',6,136,'default: - enter your GA-user here to track site stats'),('profiler_enable','0',7,132,'default: 0 - enable/disable profiler feature'),('profiler_queue_delay','3000',7,129,'default: 3000 - min. delay between queue cycles (in ms)'),('profiler_resync_ping','5000',7,129,'default: 5000 - how often the javascript asks for for updates, when queued (in ms)'),('profiler_resync_delay','3600',7,129,'default: 1*60*60 - how often a character can be refreshed (in sec)'); /*!40000 ALTER TABLE `aowow_config` ENABLE KEYS */; UNLOCK TABLES; @@ -3006,7 +3006,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1521735364,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1522146995,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/clisetup/siteconfig.func.php b/setup/tools/clisetup/siteconfig.func.php index aad8a67f..e68c8464 100644 --- a/setup/tools/clisetup/siteconfig.func.php +++ b/setup/tools/clisetup/siteconfig.func.php @@ -46,7 +46,8 @@ function siteconfig() CLI::write(' * remember to rebuild all static files for the language you just added.', CLI::LOG_INFO); CLI::write(' * you can speed this up by supplying the regionCode to the setup: '.CLI::bold('--locales= -f')); break; - case 'profiler_queue': + case 'profiler_enable': + array_push($updScripts, 'realms', 'realmMenu'); $fn = function($x) { if (!$x) return true; diff --git a/setup/updates/1522146994_01.sql b/setup/updates/1522146994_01.sql new file mode 100644 index 00000000..fbebd0aa --- /dev/null +++ b/setup/updates/1522146994_01.sql @@ -0,0 +1,2 @@ +DELETE FROM `aowow_config` WHERE `key` IN ('profiler_queue', 'profiler_enable'); +INSERT INTO `aowow_config` VALUES ('profiler_enable', '0', 7, 132, 'default: 0 - enable/disable profiler feature');