OBSERVIUM_VERSION); // Serialize and base64 encode stats array for transportation $stat_base64 = base64_encode(serialize($stats)); $tags = [ 'stats' => $stat_base64 ]; // Generate context/options with encoded data $ver_options = generate_http_context($config['http_api']['observium_versions'], $tags); // API URL $url = generate_http_url($config['http_api']['observium_versions'], $tags); // Request $response = get_http_request($url, $ver_options, 10); // Ratelimit 10/day if (test_http_request($config['http_api']['observium_versions'], $response) && $versions = safe_json_decode($response)) { print_debug_vars($versions); if (OBSERVIUM_EDITION === "community") { $train = "ce"; } elseif (OBSERVIUM_TRAIN === "stable") { $train = "stable"; } else { $train = "current"; // this same as rolling } $latest = $versions[$train]; set_obs_attrib('latest_ver', preg_replace('/^0\./', '', $latest['version'])); set_obs_attrib('latest_rev', $latest['revision']); set_obs_attrib('latest_rev_date', $latest['date']); } set_obs_attrib('last_versioncheck', time()); } $latest['revision'] = get_obs_attrib('latest_rev'); if ($latest['revision'] > OBSERVIUM_REV) { $latest['version'] = get_obs_attrib('latest_ver'); $latest['date'] = get_obs_attrib('latest_rev_date'); print_message("%GThere is a newer revision of Observium available!%n", 'color'); print_message("%GVersion %r" . $latest['version']."%G (" . format_unixtime(datetime_to_unixtime($latest['date']), 'jS F Y').") is %r". ($latest['revision']-OBSERVIUM_REV) ."%G revisions ahead.%n\n", 'color'); } elseif (isset($options['u']) && $latest['revision'] == OBSERVIUM_REV) { print_message("-- Observium is up to date."); } unset($latest, $versions, $train, $last_checked, $stats); // EOF