',
'css' =>
'#lDiv {width:140px;}
#lDiv .gsc-control .gsc-ad-box {padding-top:100px;}
#rDiv {width:500px; min-height:400px;}
#rDiv .gsc-control .gsc-ad-box,#gDiv {height:120px; margin-bottom:20px; padding:1em; width:99%; background-color:#EAF9EA;overflow:hidden;}
#gDiv .gsc-control .gsc-ad-box {width:50%;}
#gDiv .gsc-control .gsc-resultsHeader {border-bottom-width:0;color:#2B2D2B;font-weight:bold;}
#gDiv .gsc-control .gsc-results {position:relative; display:block; margin:0; overflow:hidden;}
#gDiv .gsc-control .gsc-results .gsc-trailing-more-results {display:none;}
#gDiv .gsc-control .gsc-results .gsc-expansionArea {display:none;}
.gs-videoResult .gs-text-box,.gs-imageResult .gs-text-box {display:none;}
.gsc-control {width:100% !important;margin:0 auto;position:relative;overflow:hidden;}
.gsc-control form {width:96%;}
.gsc-control table {margin:0;padding:0;}
.gsc-control, .gsc-control * {font-family:"trebuchet ms", verdana, sans-serif;font-size:13px;}',
'js' =>
'function OnLoad() {new cse();};
google.setOnLoadCallback(OnLoad);
google.load("search", "1");
function cse() {
var sDiv = document.getElementById("sDiv");
var gDiv = document.getElementById("gDiv");
var lDiv = document.getElementById("lDiv");
var rDiv = document.getElementById("rDiv");
this.gCT = new GSearchControl();
this.lCT = new GSearchControl();
this.rCT = new GSearchControl();
this.sForm = new GSearchForm(true, sDiv);
this.sForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
this.sForm.setOnClearCallback(this, cse.prototype.onClear);
this.lCT.setResultSetSize(GSearch.SMALL_RESULTSET);
this.lCT.setLinkTarget(GSearch.LINK_TARGET_SELF);
this.rCT.setResultSetSize(GSearch.LARGE_RESULTSET);
this.rCT.setLinkTarget(GSearch.LINK_TARGET_SELF);
this.gCT.setResultSetSize(GSearch.SMALL_RESULTSET);
this.gCT.setLinkTarget(GSearch.LINK_TARGET_SELF);
var sOPT;
sOPT = new GsearcherOptions();
sOPT.setExpandMode(GSearchControl.EXPAND_MODE_PARTIAL);
var drawOptions;
drawOptions = new GdrawOptions();
drawOptions.setSearchFormRoot(sDiv);
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
var srBST = new GwebSearch();
srBST.setUserDefinedLabel("Googles Best Guess");
srBST.setSiteRestriction(aa_MYSITE);
srBST.setQueryAddition(aa_BGLABEL);
this.gCT.addSearcher(srBST,sOPT);
this.gCT.draw(gDiv, drawOptions);
drawOptions = new GdrawOptions();
sOPT = new GsearcherOptions();
drawOptions.setSearchFormRoot(sDiv);
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_LINEAR);
sOPT.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
var srVID = new GvideoSearch();
srVID.setQueryAddition(aa_LABEL);
this.lCT.addSearcher(srVID,sOPT);
sOPT = new GsearcherOptions();
sOPT.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
var srIMG = new GimageSearch();
srIMG.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_OFF);
srIMG.setQueryAddition(aa_LABEL);
this.lCT.addSearcher(srIMG,sOPT);
this.lCT.draw(lDiv, drawOptions);
var srSITE = new GwebSearch();
srSITE.setUserDefinedLabel(aa_LABEL);
srSITE.setSiteRestriction(aa_MYSITE);
srSITE.setQueryAddition(aa_LABEL);
srSITE.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_OFF);
var srBLOG = new GblogSearch();
srBLOG.setQueryAddition(aa_LABEL);
srBLOG.setResultOrder(GSearch.ORDER_BY_DATE);
var srWEB = new GwebSearch();
srWEB.setQueryAddition(aa_LABEL);
srWEB.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_OFF);
var srNEW = new GnewsSearch();
var srCSE = new GwebSearch();
srCSE.setQueryAddition("askapache");
srCSE.setUserDefinedLabel("CSE");
srCSE.setRestriction(GSearch.RESTRICT_SAFESEARCH, GSearch.SAFESEARCH_OFF);
srCSE.setSiteRestriction("002660089121042511758:kk7rwc2gx0i", null);
var srLOC = new GlocalSearch();
this.rCT.addSearcher(srSITE);
this.rCT.addSearcher(srBLOG);
this.rCT.addSearcher(srWEB);
this.rCT.addSearcher(srNEW);
this.rCT.addSearcher(srCSE);
this.rCT.addSearcher(srLOC);
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
this.rCT.draw(rDiv, drawOptions);
this.sForm.execute(aa_XX);};
cse.prototype.onSubmit = function(form) { var q = form.input.value; if (q && q!= "") { this.gCT.execute(q); this.lCT.execute(q); this.rCT.execute(q);}; return false; };
cse.prototype.onClear = function(form) { this.gCT.clearAllResults(); this.lCT.clearAllResults(); this.rCT.clearAllResults(); form.input.value = ""; return false; };',
);
$k=$_GET['whcode'];
if ( array_key_exists($k, $orig_code )) print($orig_code[$k]);
}
die();
}
/**
* AskApacheGoogle404::admin_print_scripts()
*
* @return
*/
function admin_print_scripts()
{
$nonce1 = wp_create_nonce( 'get_aa404_data' );
$nonce2 = wp_create_nonce( 'get_aa404_data' );
$nonce3 = wp_create_nonce( 'get_aa404_data' );
?>
LoadOptions();
$code=$options=array();
foreach($this->options as $k=>$v)$options[$k]=$v;
foreach($this->code as $k=>$v)$code[$k]=$v;
if ( !wp_verify_nonce($_POST['_wpnonce'], 'aa404_google_ajax_search_form') ) wp_die( 'ERROR: Incorrect Form Submission, please try again.' );
foreach ( array('api_key', 'rel_num', 'rel_len', 'rec_num') as $k ) $options[$k] = (( isset($_POST["aa404_{$k}"]) ) ? $_POST["aa404_{$k}"] : $options[$k]);
foreach ( array('google_404', 'rel', 'rec', 'google_ajax') as $k ) $options[$k] = ( (!isset($_POST["aa404_{$k}"])) ? '0' : '1' );
foreach ( array('css', 'html', 'js', '404') as $k ) {
if ( isset($_POST["aa404_{$k}"]) ) {
$code[$k] = stripslashes( $_POST["aa404_{$k}"] );
}
}
$this->code=$code;
$this->options=$options;
$this->SaveOptions();
}
}
/**
* AskApacheGoogle404::options_page()
*
* @return
*/
function options_page()
{
?>
AskApache Google 404 Options
Subscribe to my feed for news/updates.. More features coming soon.. Nice ones on the horizon, Enjoy!
Found a 404.php template file at ' . $four_file . ' This file will be used to handle 404 errors, so please add the aa_google_404 function to that file where you would like this plugins output to be.
I could not find a 404.php file in your '.TEMPLATEPATH.' folder, so this plugin will mimic a 404.php, which is equally awesome.. However, if you would like more customization, create a 404.php in your current themes folder and use the aa_google_404 function to still use this plugin.
$aa_word ) $comp_words[] = $aa_word;
if ( sizeof((array )$comp_words) > 0 ) if ( sizeof($comp_words) > $num ) array_splice( $comp_words, $num + 1 );
return ( (sizeof($comp_words) > 0) ? trim(implode($sep, $comp_words)) : $_SERVER['HTTP_HOST'] );
}
/**
* AskApacheGoogle404::get_plugin_data()
*
* @param mixed $find
* @return
*/
function get_plugin_data( $find = array('Description', 'Author', 'Version', 'DB Version', 'Requires at least', 'Tested up to', 'WordPress', 'Plugin', 'Plugin Name', 'Short Name', 'Domain Path', 'Text Domain', '(?:[a-z]{2,25})? URI') )
{
$fp = fopen( __FILE__, 'r' );
if ( !is_resource($fp) ) return false;
$data = fread( $fp, 1000 );
fclose( $fp );
$mtx = $plugin = array();
preg_match_all( '/(' . join('|', $find) . ')\:[\s\t]*(.+)/i', $data, $mtx, PREG_SET_ORDER );
foreach ( $mtx as $m ) $plugin[trim( $m[1] )] = str_replace( array("\r", "\n", "\t"), '', trim($m[2]) );
$plugin['pb'] = preg_replace( '|^' . preg_quote(WP_PLUGIN_DIR, '|') . '/|', '', __FILE__ );
$plugin['Title'] = '' . $plugin['Plugin Name'] . '';
$plugin['Author'] = '' . $plugin['Author'] . '';
$plugin['page'] = basename( __FILE__ );
$plugin['hook'] = 'settings_page_' . rtrim( $plugin['page'], '.php' );
$plugin['action'] = 'options-general.php?page=' . $plugin['page'];
return $plugin;
}
}
endif;
if ( !in_array('AAGoogle404Handler', (array)get_declared_classes() ) && !class_exists( 'AAGoogle404Handler' ) ) :
/**
* AAGoogle404Handler
*
* @package
* @author webmaster@askapache.com
* @copyright AskApache
* @version 2009
* @access public
*/
class AAGoogle404Handler
{
var $options = false;
var $code = false;
var $status_code = 404;
var $errors = false;
var $messages = false;
var $message = false;
var $reason = false;
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.")
);
/**
* AAGoogle404Handler::AAGoogle404Handler()
*
* @return
*/
function AAGoogle404Handler()
{
global $wpdb;
add_action( 'wp_head', array(&$this, 'wp_header') );
add_filter( 'wp_title', array(&$this, 'title_fix') );
$this->options = get_option( 'askapache_google_404_options' );
$this->code = get_option( 'askapache_google_404_code' );
$this->status_code = ( isset($_SERVER['REDIRECT_STATUS']) && $_SERVER['REDIRECT_STATUS'] != 200 ) ? $_SERVER['REDIRECT_STATUS'] : ( !isset($_REQUEST['error']) ) ? 404 : ( int )$_REQUEST['error'];
$sr = array( '%I_ERR%' => 'The server encountered an internal error or misconfiguration and was unable to complete your request.', '%R_URI%' => attribute_escape(stripslashes($_SERVER['REQUEST_URI'])), '%R_METH%' => $_SERVER['REQUEST_METHOD'] );
$this->message = ( isset($this->ASC[$this->status_code][1]) ) ? str_replace( array_keys($sr), array_values($sr), $this->ASC[$this->status_code][1] ) : '';
$this->reason = $this->ASC[$this->status_code][0];
}
/**
* AAGoogle404Handler::handle_404()
*
* @return
*/
function handle_404()
{
global $wpdb, $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
if ( is_array($wp_query->query_vars) ) extract( $wp_query->query_vars, EXTR_SKIP );
ob_start();
@header( "HTTP/1.1 {$this->status_code} {$this->reason}", 1 );
@header( "Status: {$this->status_code} {$this->reason}", 1 );
if ( $this->status_code == 400 || $this->status_code == 403 || $this->status_code == 405 || (string )$this->status_code[0] == '5' ) return $this->handle_non_404();
if ( file_exists(TEMPLATEPATH . '/404.php') && is_file(TEMPLATEPATH . '/404.php') ) load_template( TEMPLATEPATH . '/404.php' );
else {
get_header();
$this->handle_it();
get_sidebar();
get_footer();
ob_flush(); flush(); exit; exit();
}
}
/**
* AAGoogle404Handler::handle_it()
*
* @return
*/
function handle_it()
{
$recent = $related = $google_help = $title = '';
$title = $this->status_code . ' ' . $this->reason;
if ( $this->options['google_404'] == '1' ) $google_helper = '' . "\n";
if ( $this->options['rec'] == '1' )
{
ob_start();
echo '