#!/usr/bin/php ]*generator[^>]*wordpress\s+([0-9.]+)/i', $data, $matches); if (count ($matches) < 2 || !$matches[1]) { echo "no version in web found...\n"; exit (WRN); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://api.wordpress.org/core/version-check/1.2/?version=" . $matches[1]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_NOSIGNAL, 1); $data = curl_exec($ch); curl_close($ch); $data = explode ("\n", $data); if (version_compare ($data[3], $matches[1]) > 0) { echo "Your core is out of date! " . $matches[1] . " -> " . $data[3] . "\n"; exit (ERR); } // that's it echo "Running " . $matches[1] . " is fine.\n"; exit (OOK); } // ok lets check a local installation! if ($domain) // multihost $_SERVER['HTTP_HOST'] = $domain; // include wp stuff, don't need to to reinvent the wheel... require_once($instdir.'/wp-load.php'); // let wordpress prepare it's tests wp_version_check(); wp_update_plugins(); wp_update_themes(); // if it's pre 2.9 get_site_transient might be missing... pretty old my friend! if (!function_exists ("get_site_transient")) { echo "OMG. Time to get some updates!!!"; exit (ERR); } $ret = OOK; $suppl = ""; $msg = array (); // check the core of your wordpress if ($check_core) { $core = get_site_transient('update_core'); if (isset ($core->updates) && version_compare ($core->updates[0]->current, $core->version_checked) > 0) { $msg[] = "Core is out-of-date!"; $suppl .= "Core: " . $core->version_checked . " -> " . $core->updates[0]->current . "; "; $ret = max ($ret, ERR); } else $msg[] = "Core is up-to-date."; } else $msg[] = "Skipping core checks!"; // check the plugins if ($check_plugins) { $plugin_msg = array (); $plugins = get_site_transient('update_plugins'); if (isset ($plugins->response)) { foreach($plugins->response as $name => $update) { $plugin_msg[] = $update->slug . ": " . $plugins->checked[$name] ." -> " . $update->new_version; } } if (count ($plugin_msg)) { $s = "s are"; if (count ($plugin_msg) == 1) $s = " is"; $msg[] = count ($plugin_msg) . " plugin" . $s . " out-of-date!"; $suppl .= implode ("; ", $plugin_msg) . "; "; $ret = max ($ret, ERR); } else $msg[] = "Plugins are up-to-date."; } else $msg[] = "Skipping plugin checks!"; // check the themes if ($check_themes) { $themes_msg = array (); $themes = get_site_transient('update_themes'); if (isset ($themes->response)) { foreach($themes->response as $name => $update) { $themes_msg[] = $name . ": " . $themes->checked[$name] ." -> " . $update["new_version"]; } } if (count ($themes_msg)) { $s = "s are"; if (count ($plugin_msg) == 1) $s = " is"; $msg[] = count ($themes_msg) . " theme" . $s . " out-of-date!"; $suppl .= implode ("; ", $themes_msg) . "; "; $ret = max ($ret, ERR); } else $msg[] = "Themes are up-to-date."; } else $msg[] = "Skipping theme checks!"; // Get the perfdata $count_posts = wp_count_posts(); $perfdata['posts_published'] = sprintf('%s=%s', 'posts_published', $count_posts->publish); $comments_count = wp_count_comments(); $perfdata['comments'] = sprintf('%s=%s', 'comments', $comments_count->total_comments); $count_users = count_users(); $perfdata['users'] = sprintf('%s=%s', 'users', $count_users['total_users']); // collect our info if ($ret == OOK) echo "Well done! "; else echo "Need attention! "; echo implode (" - ", $msg) . " - " . $suppl . "|" . implode(' ', $perfdata) . "\n"; exit ($ret);