} global $current_site; $domain = $current_site->domain; $register_url = "http://premium.wpmudev.org/wp-admin/profile.php?page=ustapi&domain={$domain}"; function ust_trim_array($input) { if (!is_array($input)) { return trim($input); } return array_map('ust_trim_array', $input); } //process form if (isset($_POST['ust_settings'])) { //check the api key and connection $request["API_KEY"] = $_POST['ust']['api_key']; $api_response = ust_http_post('api_check', $request); if ($api_response && $api_response != 'Valid') { $_POST['ust']['api_key'] = ''; echo '<div id="message" class="error"><p>' . __(sprintf('There was a problem with the API key you entered: "%s" <a href="%s" target="_blank">Fix it here»</a>', $api_response, $register_url), 'ust') . '</p></div>'; } else { if (!$api_response) { $_POST['ust']['api_key'] = ''; echo '<div id="message" class="error"><p>' . __('There was a problem connecting to the API server. Please try again later.', 'ust') . '</p></div>'; } } $_POST['ust']['hide_adminbar'] = isset($_POST['ust']['hide_adminbar']) ? 1 : 0; //handle checkbox if (isset($_POST['ust']['keywords']) && trim($_POST['ust']['keywords'])) { $_POST['ust']['keywords'] = explode("\n", trim($_POST['ust']['keywords'])); } else { $_POST['ust']['keywords'] = '';
function ust_check_api() { global $current_site, $ust_admin_url; $ust_url = $ust_admin_url . "-settings"; //check the api key and connection $api_response = ust_http_post(); if ($api_response && $api_response != 'Valid') { $message = __(sprintf("There seems to be a problem with the Anti-Splog plugin API key on your server at %s.\n%s\n\nFix it here: %s", $current_site->domain, $api_response, $ust_url), 'ust'); } else { if (!$api_response) { $message = __(sprintf("The Anti-Splog plugin on your server at %s is having a problem connecting to the API server.\n\nFix it here: %s", $current_site->domain, $ust_url), 'ust'); } } if ($message) { //email site admin $admin_email = get_site_option("admin_email"); $subject = __('A problem with your Anti-Splog plugin', 'ust'); wp_mail($admin_email, $subject, $message); //clear API key $ust_settings = get_site_option("ust_settings"); $ust_settings['api_key'] = ''; update_site_option("ust_settings", $ust_settings); } }