Options configuration panel Version: 4.1 Author: AskApache Author URI: http://www.askapache.com */ /* == Installation == 1. Upload askapache-google-404.zip to the /wp-content/plugins/ directory 2. Unzip into its own folder /wp-content/plugins/askapache-google-404/askapache-google-404.php 3. Activate the plugin through the 'Plugins' menu in WordPress by clicking "AskApache Google 404" 4. Go to your Options Panel and open the "AskApache Google 404" submenu. /wp-admin/options-general.php?page=askapache-google-404.php 5. Enter in your google Ajax API Key and hit "Update" Button. 6. Add the code to your 404.php template page by including in your main content area. */ /* /--------------------------------------------------------------------\ | | | License: GPL | | | | AskApache Google 404 Plugin - Adds Ajax Powered Search to 404 Page | | Copyright (C) 2007, AskApache, www.askapache.com | | All rights reserved. | | | | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | | | | You should have received a copy of the GNU General Public License | | along with this program; if not, write to the | | Free Software Foundation, Inc. | | 51 Franklin Street, Fifth Floor | | Boston, MA 02110-1301, USA | | | \--------------------------------------------------------------------/ */ $aa_disallowed_words=array('about','after','ago','all','almost','along','alot','test','also','and','answer','any','anybody','anybodys','anywhere','are','arent','around','askd','because','been','before','being','best','better','between','big','btw','but','can','come','could','couldnt','did','didnt','does','doesnt','dont','etc','either','ever','everybody','everybodys','everyone','far','for','found','game','going','good','got','gotten','had','has','have','havent','having','her','here','hers','him','his','how','hows','ive','isnt','its','just','know','large','less','like','liked','little','looking','look','looked','looking','lot','maybe','many','more','most','much','must','mustnt','near','need','never','new','news','none','not','nothing','now','off','often','old','once','only','oops','other','our','ours','out','over','please','put','question','questions','questioned','quote','rather','really','recent','said','saw','say','says','she','see','sees','should','small','some','something','sometime','somewhere','soon','take','than','thank','that','thatd','thats','the','their','theirs','theres','theirs','them','then','there','these','they','theyll','theyd','theyre','this','those','though','through','thus','too','under','until','untrue','upon','very','via','want','was','way','well','went','were','werent','what','when','where','which','whom','whose','why','wide','will','with','within','without','wont','world','worse','worst','would','wrote','yes','yet','you','youd','youll','your','youre','yours'); // aa_google_404_options_setup //--------------------------- function aa_google_404_options_setup() { global $aa_G404; add_options_page($aa_G404['Name'], 'AA Google 404', 8, basename(__FILE__), 'aa_google_404_page'); }//===================================================================================== // aa_google_404 //--------------------------- function aa_google_404(){ $aa_google_404_code_html = get_option('aa_google_404_code_html'); echo $aa_google_404_code_html; }//===================================================================================== // aa_google_404_page //--------------------------- function aa_google_404_page() { global $aa_G404,$aa_google_404_api_key,$aa_google_404_code_js,$aa_google_404_code_css,$aa_google_404_code_html,$aa_status; if (! user_can_access_admin_page()) wp_die( __('You do not have sufficient permissions to access this page.') ); if ( !file_exists(TEMPLATEPATH.'/404.php')){ if (!copy(dirname(__FILE__).'/404.php', TEMPLATEPATH.'/404.php'))$aa_status.='

ERROR:Attempt to create 404.php FAILED!

'; else $aa_status.='

Message:Attempt to create 404.php SUCCESS!

'; } ?>

[ : - : - : ]



" method="post">












More Info from Google



Successfully Updated Code.

'; if(isset($_POST['aaresetgooglecode'])) { aa_google_404_activate(); $aa_status = '

Successfully Reset Plugin Options.

'; } } if(strpos($aa_google_404_api_key, 'askapache')!==false){ $aa_status = '

Warning: You need to get a free Google API Key before this plugin will fully work.

'; } $aa_google_404_code_html = get_option('aa_google_404_code_html'); $aa_google_404_code_js = get_option('aa_google_404_code_js'); $aa_google_404_code_css = get_option('aa_google_404_code_css'); $aa_google_404_api_key = get_option('aa_google_404_api_key'); $aa_label='+askapache'; $aa_execute=aa_get_keywords('|'); $aa_mysite=str_replace('www.','',$_SERVER['HTTP_HOST']); echo "\n\n".''."\n"; echo ''; echo "\n".''."\n"; echo $aa_google_404_code_js; echo $aa_google_404_code_css; echo "\n".''."\n\n"; }//===================================================================================== // aa_google_404_header //--------------------------- function aa_google_404_header(){ global $aa_google_404_api_key,$aa_google_404_code_js,$aa_google_404_code_css,$aa_google_404_code_html; if(is_404()) { $aa_google_404_code_html = get_option('aa_google_404_code_html'); $aa_google_404_code_js = get_option('aa_google_404_code_js'); $aa_google_404_code_css = get_option('aa_google_404_code_css'); $aa_google_404_api_key = get_option('aa_google_404_api_key'); $aa_google_404_api_key=str_replace('-askapache','',$aa_google_404_api_key); $aa_label=get_option('blogname'); $aa_execute=aa_get_keywords('|',6); $aa_best_guess_keywords=aa_get_keywords(' ',2); $aa_best_guess='OR allinurl:'.$aa_best_guess_keywords; $aa_mysite=str_replace('www.','',$_SERVER['HTTP_HOST']); echo "\n\n".''."\n"; echo ''; echo "\n".''."\n"; echo $aa_google_404_code_js; echo $aa_google_404_code_css; echo "\n".''."\n\n"; } }//===================================================================================== // aa_get_keywords //--------------------------- function aa_get_keywords($sep,$aa_num_keywords_allowed=6){ global $aa_disallowed_words; $aa_computed_searchwords=array(); $aa_matched_keywords=array(); $url=strtolower(html_entity_decode(strip_tags($_SERVER['REQUEST_URI']))); $t=preg_match_all("/[\w]{3,15}/", $url, $aa_matched_keywords); foreach ($aa_matched_keywords[0] as $key => $aa_word){ if(!in_array($aa_word,$aa_disallowed_words))$aa_computed_searchwords[]=$aa_word; } if(sizeof($aa_computed_searchwords)>0){ $aa_computed_searchwords = array_unique($aa_computed_searchwords); if(sizeof($aa_computed_searchwords)>$aa_num_keywords_allowed) array_splice($aa_computed_searchwords, $aa_num_keywords_allowed+1); $aa_computed_searchwords = implode($sep, $aa_computed_searchwords); return trim($aa_computed_searchwords); } else return $_SERVER['HTTP_HOST']; }//===================================================================================== // aa_google_404_deactivate //--------------------------- function aa_google_404_deactivate(){ delete_option('aa_google_404_url'); delete_option('aa_google_404_code_html'); delete_option('aa_google_404_code_js'); delete_option('aa_google_404_code_css'); delete_option('aa_google_404_api_key'); }//===================================================================================== // aa_google_404_activate //--------------------------- function aa_google_404_activate(){ global $aa_G404; $aa_G404=get_plugin_data(__FILE__); $aa_google_404_api_key='ABQIAAAAulvh3KQawKQWxn64grPVShSrXMCP0pDj9HHVk8NG53Pp2_-7KxQrSRl65MAnUMDqm9AubaFv5BYXEg-askapache'; $aa_google_404_code_html='
'."\n".'Wait a sec, I might be able to help...'."\n".'
'."\n".'
'."\n"; $aa_google_404_code_css= "\n".''."\n"; $aa_google_404_code_js= ''; update_option('aa_google_404_api_key',$aa_google_404_api_key); update_option('aa_google_404_code_html',stripslashes($aa_google_404_code_html)); update_option('aa_google_404_code_js',stripslashes($aa_google_404_code_js)); update_option('aa_google_404_code_css',stripslashes($aa_google_404_code_css)); }//===================================================================================== //add_action('template_redirect', 'redirect_canonical'); add_action('admin_menu', 'aa_google_404_options_setup'); if(false!==($aa_goadm=strpos($_SERVER['REQUEST_URI'], basename(__FILE__))))add_action('admin_head', 'aa_google_404_admin_header'); add_action('wp_head', 'aa_google_404_header'); //register_deactivation_hook(__FILE__, 'aa_google_404_deactivate'); register_activation_hook(__FILE__, 'aa_google_404_activate'); ?>