Changeset 3412883
- Timestamp:
- 12/06/2025 09:58:41 AM (4 months ago)
- Location:
- dynamic-front-end-heartbeat-control
- Files:
-
- 35 added
- 1 deleted
- 3 edited
-
tags/1.2.996 (deleted)
-
tags/1.2.996.2 (added)
-
tags/1.2.996.2/LICENSE (added)
-
tags/1.2.996.2/admin (added)
-
tags/1.2.996.2/admin/affix.php (added)
-
tags/1.2.996.2/admin/ajax-handler.php (added)
-
tags/1.2.996.2/admin/asset-manager.php (added)
-
tags/1.2.996.2/admin/heartbeat-config.php (added)
-
tags/1.2.996.2/admin/unclogger-menu.php (added)
-
tags/1.2.996.2/css (added)
-
tags/1.2.996.2/css/dfhcsl-admin.css (added)
-
tags/1.2.996.2/defibrillator (added)
-
tags/1.2.996.2/defibrillator/cli-helper.php (added)
-
tags/1.2.996.2/defibrillator/db-health.php (added)
-
tags/1.2.996.2/defibrillator/load-estimator.php (added)
-
tags/1.2.996.2/defibrillator/rest-api.php (added)
-
tags/1.2.996.2/defibrillator/unclogger-db.php (added)
-
tags/1.2.996.2/defibrillator/unclogger.php (added)
-
tags/1.2.996.2/engine (added)
-
tags/1.2.996.2/engine/interval-helper.php (added)
-
tags/1.2.996.2/engine/server-load.php (added)
-
tags/1.2.996.2/engine/server-response.php (added)
-
tags/1.2.996.2/engine/system-load-fallback.php (added)
-
tags/1.2.996.2/heartbeat-async.php (added)
-
tags/1.2.996.2/heartbeat-controller.php (added)
-
tags/1.2.996.2/js (added)
-
tags/1.2.996.2/js/chart.js (added)
-
tags/1.2.996.2/js/dfhcsl-admin.js (added)
-
tags/1.2.996.2/js/heartbeat.js (added)
-
tags/1.2.996.2/js/heartbeat.min.js (added)
-
tags/1.2.996.2/readme.txt (added)
-
tags/1.2.996.2/settings.php (added)
-
tags/1.2.996.2/visitor (added)
-
tags/1.2.996.2/visitor/cookie-helper.php (added)
-
tags/1.2.996.2/visitor/manager.php (added)
-
tags/1.2.996.2/widget.php (added)
-
trunk/engine/server-load.php (modified) (2 diffs)
-
trunk/heartbeat-async.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dynamic-front-end-heartbeat-control/trunk/engine/server-load.php
r3412283 r3412883 489 489 } 490 490 491 add_filter('cron_schedules', static function (array $schedules): array { 491 function dfehc_register_minute_schedule(array $schedules): array 492 { 492 493 if (!isset($schedules['dfehc_minute'])) { 493 494 $schedules['dfehc_minute'] = [ 494 495 'interval' => 60, 495 'display' => __('Server load (DFEHC)', 'dfehc'),496 'display' => __('Server load (DFEHC)', 'dfehc'), 496 497 ]; 497 498 } 498 499 return $schedules; 499 }, 5); 500 501 $__dfehc_schedule = static function (): void { 500 } 501 add_filter('cron_schedules', 'dfehc_register_minute_schedule', 5); 502 503 function dfehc_clear_log_server_load_cron(): void 504 { 505 if (!function_exists('wp_next_scheduled') || !function_exists('wp_unschedule_event')) { 506 return; 507 } 508 while ($ts = wp_next_scheduled('dfehc_log_server_load_hook')) { 509 wp_unschedule_event($ts, 'dfehc_log_server_load_hook'); 510 } 511 } 512 513 function dfehc_schedule_log_server_load(): void 514 { 502 515 if (!apply_filters('dfehc_enable_load_logging', true)) { 516 dfehc_clear_log_server_load_cron(); 503 517 return; 504 518 } 519 if ( 520 !function_exists('wp_get_schedules') 521 || !function_exists('wp_next_scheduled') 522 || !function_exists('wp_schedule_event') 523 ) { 524 return; 525 } 526 $schedules = wp_get_schedules(); 527 if (!isset($schedules['dfehc_minute'])) { 528 dfehc_clear_log_server_load_cron(); 529 return; 530 } 505 531 if (!wp_next_scheduled('dfehc_log_server_load_hook')) { 532 $interval = (int) $schedules['dfehc_minute']['interval']; 533 $now = time(); 534 $start = $now - ($now % $interval) + $interval; 506 535 try { 507 $now = time();508 $start = $now - ($now % 60) + 60;509 536 wp_schedule_event($start, 'dfehc_minute', 'dfehc_log_server_load_hook'); 510 537 } catch (Throwable $e) { … … 514 541 } 515 542 } 516 }; 517 518 register_activation_hook(__FILE__, $__dfehc_schedule); 519 520 add_action('init', static function () use ($__dfehc_schedule): void { 521 $__dfehc_schedule(); 522 }, 1); 543 } 544 545 if (function_exists('register_activation_hook')) { 546 register_activation_hook(__FILE__, 'dfehc_schedule_log_server_load'); 547 } 548 549 function dfehc_deactivate_log_server_load(): void 550 { 551 dfehc_clear_log_server_load_cron(); 552 } 553 554 if (function_exists('register_deactivation_hook')) { 555 register_deactivation_hook(__FILE__, 'dfehc_deactivate_log_server_load'); 556 } 557 558 add_action('init', 'dfehc_schedule_log_server_load', 1); 523 559 524 560 function dfehc_load_acquire_lock(): bool -
dynamic-front-end-heartbeat-control/trunk/heartbeat-async.php
r3412705 r3412883 39 39 return set_transient($key, $value, $ttl); 40 40 } 41 }42 43 function dfehc_client_ip(): string44 {45 $ip = isset($_SERVER['REMOTE_ADDR']) ? (string) $_SERVER['REMOTE_ADDR'] : '0.0.0.0';46 $trusted = (array) apply_filters('dfehc_trusted_proxies', []);47 if ($trusted && in_array($ip, $trusted, true)) {48 $headers = (array) apply_filters('dfehc_proxy_ip_headers', ['HTTP_X_FORWARDED_FOR', 'HTTP_CF_CONNECTING_IP', 'HTTP_X_REAL_IP']);49 foreach ($headers as $h) {50 if (!empty($_SERVER[$h])) {51 $raw = (string) $_SERVER[$h];52 $parts = array_map('trim', explode(',', $raw));53 $cand = end($parts);54 if ($cand) {55 return $cand;56 }57 }58 }59 }60 return $ip;61 41 } 62 42 -
dynamic-front-end-heartbeat-control/trunk/readme.txt
r3412720 r3412883 3 3 Tested up to: 6.9 4 4 Requires PHP: 7.2 5 Stable tag: 1.2.996. 15 Stable tag: 1.2.996.2 6 6 License: GPLv2 or later 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 49 49 == Changelog == 50 50 51 = 1.2.996.2 = 52 53 * Improved cron scheduling. 51 54 52 55 = 1.2.996.1 =
Note: See TracChangeset
for help on using the changeset viewer.