Changeset 3477266
- Timestamp:
- 03/08/2026 04:52:42 AM (4 weeks ago)
- Location:
- zubbin-uptime-node/trunk
- Files:
-
- 5 edited
-
includes/admin.php (modified) (4 diffs)
-
includes/client.php (modified) (1 diff)
-
includes/cron.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
zubbin-uptime-node.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zubbin-uptime-node/trunk/includes/admin.php
r3472274 r3477266 29 29 add_action("admin_post_zubbin_un_force_sync", [__CLASS__, "force_sync"]); 30 30 add_action("admin_post_zubbin_un_test_auth", [__CLASS__, "test_auth"]); 31 add_action("admin_post_zubbin_un_repair_pairing", [__CLASS__, "repair_pairing"]); 31 32 add_action("admin_post_zubbin_un_clear_logs", [__CLASS__, "clear_logs"]); 32 33 add_action("admin_post_zubbin_un_start_checkout", [__CLASS__, "start_checkout"]); … … 62 63 63 64 $s = ZUBBIN_UN_Settings::get(); 65 $flash = get_transient('zubbin_un_flash_notice'); 66 if (is_array($flash) && !empty($flash['type']) && !empty($flash['message'])) { 67 delete_transient('zubbin_un_flash_notice'); 68 self::notice((string)$flash['type'], (string)$flash['message']); 69 } 64 70 // Tab selection is a read-only UI concern (no state change). Nonce is not required. 65 71 // phpcs:ignore WordPress.Security.NonceVerification.Recommended … … 225 231 echo '<input type="hidden" name="action" value="zubbin_un_test_auth">'; 226 232 submit_button('Test Central Auth','secondary'); 233 echo '</form>'; 234 echo '<form method="post" action="'.esc_url(admin_url('admin-post.php')).'" style="margin-top:10px;">'; 235 wp_nonce_field('zubbin_un_repair_pairing'); 236 echo '<input type="hidden" name="action" value="zubbin_un_repair_pairing">'; 237 submit_button('Re-pair with Central','secondary', 'submit', false); 238 echo '<p class="description">Use this if Central rotated your node secret and this site is using stale credentials.</p>'; 227 239 echo '</form></div>'; 228 240 } … … 661 673 662 674 $r = ZUBBIN_UN_Client::test_auth($s); 663 if ((int)$r['http'] === 200) { 675 $ok = ((int)($r['http'] ?? 0) === 200 && !empty($r['body']['ok'])); 676 $msg = $ok ? 'Central auth succeeded.' : ('Central auth failed: ' . ZUBBIN_UN_Client::summarize_response($r)); 677 ZUBBIN_UN_Settings::save(['last_http' => (int)($r['http'] ?? 0), 'last_error' => $ok ? '' : $msg]); 678 set_transient('zubbin_un_flash_notice', ['type' => $ok ? 'success' : 'error', 'message' => $msg], 60); 679 if (class_exists('ZUBBIN_UN_Logger')) { 680 ZUBBIN_UN_Logger::info('test_auth', $ok ? 'Central auth succeeded' : 'Central auth failed', ['http' => (int)($r['http'] ?? 0), 'error' => (string)($r['body']['error'] ?? '')]); 681 } 682 wp_safe_redirect(admin_url('admin.php?page=zubbin_un&tab=dashboard')); 683 exit; 684 } 685 686 static function repair_pairing() { 687 if (!current_user_can('manage_options')) wp_die('Forbidden'); 688 check_admin_referer('zubbin_un_repair_pairing'); 689 690 $s = ZUBBIN_UN_Settings::get(); 691 $central_url = (string)($s['central_url'] ?? ''); 692 if ($central_url === '') { 693 set_transient('zubbin_un_flash_notice', ['type' => 'error', 'message' => 'Central URL is missing.'], 60); 694 wp_safe_redirect(admin_url('admin.php?page=zubbin_un&tab=onboarding')); 695 exit; 696 } 697 698 $r = ZUBBIN_UN_Client::auto_bootstrap($central_url); 699 if ((int)($r['http'] ?? 0) === 200 && !empty($r['body']['ok']) && !empty($r['body']['node_key']) && !empty($r['body']['node_secret'])) { 700 ZUBBIN_UN_Settings::save([ 701 'node_key' => (string)$r['body']['node_key'], 702 'node_secret' => (string)$r['body']['node_secret'], 703 'last_error' => '', 704 'last_http' => (int)($r['http'] ?? 0), 705 ]); 706 $s2 = ZUBBIN_UN_Settings::get(); 707 $sr = ZUBBIN_UN_Client::sync($s2); 708 $sync_msg = ((int)($sr['http'] ?? 0) === 200 && !empty($sr['body']['ok'])) ? ' Central sync succeeded.' : (' Central sync result: ' . ZUBBIN_UN_Client::summarize_response($sr)); 709 set_transient('zubbin_un_flash_notice', ['type' => 'success', 'message' => 'Node credentials refreshed from Central.' . $sync_msg], 60); 710 if (class_exists('ZUBBIN_UN_Logger')) { 711 ZUBBIN_UN_Logger::info('repair_pairing', 'Node re-paired with Central', ['http' => (int)($r['http'] ?? 0), 'mode' => (string)($r['body']['mode'] ?? '')]); 712 } 664 713 wp_safe_redirect(admin_url('admin.php?page=zubbin_un&tab=dashboard')); 665 714 exit; 666 715 } 667 716 717 $msg = 'Re-pair failed: ' . ZUBBIN_UN_Client::summarize_response($r); 718 ZUBBIN_UN_Settings::save(['last_error' => $msg, 'last_http' => (int)($r['http'] ?? 0)]); 719 set_transient('zubbin_un_flash_notice', ['type' => 'error', 'message' => $msg], 60); 720 if (class_exists('ZUBBIN_UN_Logger')) { 721 ZUBBIN_UN_Logger::warn('repair_pairing', 'Node re-pair failed', ['http' => (int)($r['http'] ?? 0), 'error' => (string)($r['body']['error'] ?? '')]); 722 } 723 wp_safe_redirect(admin_url('admin.php?page=zubbin_un&tab=dashboard')); 724 exit; 668 725 } 669 726 -
zubbin-uptime-node/trunk/includes/client.php
r3472274 r3477266 55 55 } 56 56 57 58 59 60 static function summarize_response($r) { 61 $http = (int)($r['http'] ?? 0); 62 $body = is_array($r['body'] ?? null) ? $r['body'] : []; 63 $error = (string)($body['error'] ?? ''); 64 $message = (string)($body['message'] ?? ''); 65 $raw = (string)($body['raw'] ?? ''); 66 67 $parts = []; 68 if ($error !== '') $parts[] = $error; 69 if ($message !== '' && $message !== $error) { 70 $parts[] = $message; 71 } elseif ($message === '' && $raw !== '') { 72 $parts[] = $raw; 73 } 74 75 $out = trim(implode(': ', array_filter($parts, function($v){ return $v !== ''; }))); 76 if ($out === '') { 77 $out = $http > 0 ? ('http_' . $http) : 'request_failed'; 78 } 79 80 if (!empty($body['attempted_urls']) && is_array($body['attempted_urls'])) { 81 $urls = implode(' | ', array_map('esc_url_raw', $body['attempted_urls'])); 82 if ($urls !== '') $out .= ' | attempted: ' . $urls; 83 } 84 85 return $out; 86 } 57 87 58 88 static function post_json_fallback($central_url, $route, $body=[], $headers=[], $timeout=20) { -
zubbin-uptime-node/trunk/includes/cron.php
r3458420 r3477266 107 107 'last_message' => (string)$check['msg'], 108 108 'last_http' => (int)$hb['http'], 109 'last_error' => (string)($hb['body']['error'] ?? ''),109 'last_error' => ZUBBIN_UN_Client::summarize_response($hb), 110 110 ]; 111 111 -
zubbin-uptime-node/trunk/readme.txt
r3472274 r3477266 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1.4.5 07 Stable tag: 1.4.51 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
zubbin-uptime-node/trunk/zubbin-uptime-node.php
r3472274 r3477266 3 3 * Plugin Name: Z UpTime – Uptime Monitoring Node 4 4 * Description: Lightweight WordPress uptime monitoring node that reports heartbeat and health to a Central dashboard. Alerts are handled by Central. 5 * Version: 1.4.5 05 * Version: 1.4.51 6 6 * Author: Zubbin 7 7 * Text Domain: zubbin-uptime-node … … 13 13 if (!defined('ABSPATH')) exit; 14 14 15 define('ZUBBIN_UN_VERSION', '1.4. 48');15 define('ZUBBIN_UN_VERSION', '1.4.51'); 16 16 17 17 // Default Central URL for client installs (override in wp-config.php if needed) … … 39 39 add_action('admin_post_zubbin_un_force_sync', ['ZUBBIN_UN_Admin','force_sync']);; 40 40 add_action('admin_post_zubbin_un_test_auth', ['ZUBBIN_UN_Admin','test_auth']); 41 add_action('admin_post_zubbin_un_repair_pairing', ['ZUBBIN_UN_Admin','repair_pairing']); 41 42 add_action('admin_post_zubbin_un_clear_logs', ['ZUBBIN_UN_Admin','clear_logs']); 42 43
Note: See TracChangeset
for help on using the changeset viewer.