function wbz404_suggestions() { if (is_404()) { $options = wbz404_getOptions(); if ($options['display_suggest'] == '1') { echo "<div class=\"404suggest\">"; $requestedURL = $_SERVER['REQUEST_URI']; $urlParts = parse_url($requestedURL); $permalinks = wbz404_rankPermalinks($urlParts['path'], $options['suggest_cats'], $options['suggest_tags']); echo $options['suggest_title']; $displayed = 0; foreach ($permalinks as $k => $v) { $permalink = wbz404_permalinkInfo($k, $v); if ($permalink['score'] >= $options['suggest_minscore']) { if ($displayed == 0) { echo $options['suggest_before']; } echo $options['suggest_entrybefore']; echo "<a href=\"" . $permalink['link'] . "\" title=\"" . $permalink['title'] . "\">" . $permalink['title'] . "</a>"; if (is_user_logged_in() && current_user_can('manage_options')) { echo " (" . $permalink['score'] . ")"; } echo $options['suggest_entryafter']; $displayed++; if ($displayed >= $options['suggest_max']) { break; } } else { break; } } if ($displayed >= 1) { echo $options['suggest_after']; } else { echo $options['suggest_noresults']; } //Promote Plugin if ($options['404_promote'] == "1") { echo wbz404_trans('Generated using the') . " <a href=\"" . WBZ404_HOME . "\" title=\"" . wbz404_trans('Wordpress 404 Manager Plugin') . "\" target=\"_blank\">"; echo wbz404_trans('404 Redirected') . "</a> " . wbz404_trans('plugin written by') . " <a href=\"http://www.weberz.com/\" title=\"Weberz Hosting\" target=\"_blank\">Weberz Hosting</a>."; } echo "</div>"; } } }
function wbz404_purgeRedirects() { global $wpdb; $message = ""; $redirects = $wpdb->prefix . "wbz404_redirects"; $logs = $wpdb->prefix . "wbz404_logs"; $sanity = $_POST['sanity']; if ($sanity == "1") { $type = $_POST['types']; if ($type != "") { if (is_array($type)) { $types = ""; $x = 0; for ($i = 0; $i < count($type); $i++) { if (preg_match('/[0-9]+/', $type[$i])) { if ($x > 0) { $types .= ","; } $types .= $type[$i]; $x++; } } if ($types != "") { $purge = $_POST['purgetype']; if ($purge == "logs" || $purge == "redirects") { $query = "delete from " . $logs . " where redirect_id in (select id from " . $redirects . " where status in (" . $types . "))"; $logcount = $wpdb->query($query); $message = $logcount . " " . wbz404_trans('Log entries were purged.'); if ($purge == "redirects") { $query = "delete from " . $redirects . " where status in (" . $types . ")"; $count = $wpdb->query($query); $message .= "<br>"; $message .= $count . " " . wbz404_trans('Redirect entries were purged.'); } } else { $message = wbz404_trans('Error: An invalid purge type was selected. Exiting.'); } } else { $message = wbz404_trans('Error: No valid redirect types were selected. Exiting.'); } } else { $message = wbz404_trans('An unknown error has occurred.'); } } else { $message = wbz404_trans('Error: No redirect types were selected. No purges will be done.'); } } else { $message = wbz404_trans('Error: You didn\'t check the I understand checkbox. No purging of records for you!'); } return $message; }