.
*/
! defined('ABSPATH') || ! function_exists('add_options_page') || ! function_exists('add_action') || ! function_exists('wp_die') && die('death by askapache firing squad');
! defined('COOKIEPATH') && define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/'));
! defined('SITECOOKIEPATH') && define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/'));
! defined('ADMIN_COOKIE_PATH') && define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin');
! defined('PLUGINS_COOKIE_PATH') && define('PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL));
! defined('WP_CONTENT_DIR') && define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
! defined('WP_PLUGIN_DIR') && define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
! defined('WP_CONTENT_URL') && define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
! defined('WP_PLUGIN_URL') && define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins');
class AskApacheGoogle404
{
var $options = false;
var $plugin = false;
var $errors = false;
var $messages = false;
var $code = 404;
var $message;
var $reason;
var $ASC = array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-Status',
226 => 'IM Used',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => 'Reserved',
307 => 'Temporary Redirect',
400 => array('Bad Request', "Your browser sent a request that this server could not understand."),
401 => array('Unauthorized', "This server could not verify that you are authorized to access the document requested."),
402 => array('Payment Required', "%I_ERR%"),
403 => array('Forbidden', "You don't have permission to access %R_URI% on this server."),
404 => array('Not Found', "We couldn't find that uri on our server, though it's most certainly not your fault."),
405 => array('Method Not Allowed', "The requested method %R_METH% is not allowed for the URL %R_URI%."),
406 => array('Not Acceptable', "An appropriate representation of the requested resource %R_URI% could not be found on this server."),
407 => array('Proxy Authentication Required', "An appropriate representation of the requested resource %R_URI% could not be found on this server."),
408 => array('Request Timeout', "Server timeout waiting for the HTTP request from the client."),
409 => array('Conflict', "%I_ERR%"),
410 => array('Gone', "The requested resource%R_URI%is no longer available on this server and there is no forwarding address. Please remove all references to this resource."),
411 => array('Length Required', "A request of the requested method GET requires a valid Content-length."),
412 => array('Precondition Failed', "The precondition on the request for the URL %R_URI% evaluated to false."),
413 => array('Request Entity Too Large', "The requested resource %R_URI% does not allow request data with GET requests, or the amount of data provided in the request exceeds the capacity limit."),
414 => array('Request-URI Too Long', "The requested URL's length exceeds the capacity limit for this server."),
415 => array('Unsupported Media Type', "The supplied request data is not in a format acceptable for processing by this resource."),
416 => array('Requested Range Not Satisfiable', ""),
417 => array('Expectation Failed', "The expectation given in the Expect request-header field could not be met by this server. The client sent Expect:"),
422 => array('Unprocessable Entity', "The server understands the media type of the request entity, but was unable to process the contained instructions."),
423 => array('Locked', "The requested resource is currently locked. The lock must be released or proper identification given before the method can be applied."),
424 => array('Failed Dependency', "The method could not be performed on the resource because the requested action depended on another action and that other action failed."),
425 => array('No Code', "%I_ERR%"),
426 => array('Upgrade Required', "The requested resource can only be retrieved using SSL. Either upgrade your client, or try requesting the page using https://"),
500 => array('Internal Server Error', "%I_ERR%"),
501 => array('Not Implemented', " %R_METH% to %R_URI% not supported."),
502 => array('Bad Gateway', "The proxy server received an invalid response from an upstream server."),
503 => array('Service Unavailable', "The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later."),
504 => array('Gateway Timeout', "The proxy server did not receive a timely response from the upstream server."),
505 => array('HTTP Version Not Supported', "%I_ERR%"),
506 => array('Variant Also Negotiates', "A variant for the requested resource %R_URI% is itself a negotiable resource. This indicates a configuration error."),
507 => array('Insufficient Storage', "The method could not be performed. There is insufficient free space left in your storage allocation."),
510 => array('Not Extended', "A mandatory extension policy in the request is not accepted by the server for this resource.")
);
/**
* AskApacheGoogle404::AskApacheGoogle404()
*/
function AskApacheGoogle404()
{
global $wpdb;
$this->LoadOptions();
add_action('wp_head', array(&$this, 'wp_header'));
add_filter('wp_title', array(&$this, 'title_fix'));
add_action('template_redirect', array(&$this, 'template_redirect'), 1);
if (is_admin())
{
$_GET['TB_iframe']=null;
add_filter('plugin_action_links_' . $this->plugin['pb'], array(&$this, 'plugin_action_links'));
add_action('activate_' . $this->plugin['pb'], array(&$this, 'activate'));
add_action('deactivate_' . $this->plugin['pb'], array(&$this, 'deactivate'));
add_action('admin_menu', array(&$this, 'admin_menu'));
add_action('admin_notices', array(&$this, 'admin_notices'));
add_action('load-' . $this->plugin['hook'], array(&$this, 'load'));
} else return;
}
/*
* +-------------------------------------------------------+
* | |
* | Activation / Deactivation
* | |
* +-------------------------------------------------------+
*/
/**
* AskApacheGoogle404::activate()
*/
function activate()
{
$this->InitOptions();
}
/**
* AskApacheGoogle404::deactivate()
*/
function deactivate()
{
$options = get_option('askapache_google_404_options');
update_option('aa_google_404_api_key', $options['api_key']);
delete_option('askapache_google_404_options');
//delete_option('askapache_google_404_plugin');
}
/*
* +-------------------------------------------------------+
* | |
* | Hooks, Filters, Actions
* | |
* +-------------------------------------------------------+
*/
/**
* AskApacheGoogle404::admin_menu()
*/
function admin_menu()
{
//$page_title, $menu_title, $access_level, $file, $function
add_options_page($this->plugin['Plugin Name'], $this->plugin['Short Name'], 8, $this->plugin['page'], array(&$this, 'options_page'));
}
/**
* AskApacheGoogle404::admin_notices()
*/
function admin_notices()
{
if ($this->options['api_key'] != '') return;
printf(__('
%s needs attention: please enter an API key or disable the plugin.
"; echo ""; echo "Click Here to Get a Google API Key!
If your active theme has a 404.php file it is used, otherwise the plugin handles it. If you use a 404.php file, add this the following code where you want the plugin output to be displayed..
'; echo '<?php if(function_exists("aa_google_404"))aa_google_404();?>';
echo 'If your server allows .htaccess files and this plugin isnt working, then add this to your .htaccess (everyone should if they have htaccess capability). Look for another update in a few, enjoy!
ErrorDocument 404 /index.php?error=404'."\n".'Redirect 404 /index.php?error=404'; $this->google_ajax_search_form(); // ?>
{$this->message}
\n
%3$s...