prefix."ad_buttons"; $structure = "CREATE TABLE $table ( id INT(9) NOT NULL AUTO_INCREMENT, ad_picture VARCHAR(100) NOT NULL, ad_link VARCHAR(500) NOT NULL, ad_text VARCHAR(80) NOT NULL, ad_strdat DATE NOT NULL, ad_enddat DATE NOT NULL, ad_views INT(9) DEFAULT 0, ad_clicks INT(9) DEFAULT 0, ad_active TINYINT(1) NOT NULL DEFAULT 0, adg_count VARCHAR(500) NOT NULL, adg_show tinytext NOT NULL, ad_pos INT(9) DEFAULT 0, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $ab_plugindir = get_option('siteurl').'/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)); $wpdb->query("INSERT INTO $table(id, ad_picture, ad_link, ad_text, ad_views, ad_clicks, ad_active) VALUES(1, '".$ab_plugindir."/ab125.jpg', 'http://wordpress.org/plugins/ad-buttons/', 'ads powered by Ad Buttons', 1, 0, 1)"); $table = $wpdb->prefix."ad_buttons_stats"; $structure = "CREATE TABLE $table ( abs_dat date NOT NULL, abs_ip int(10) NOT NULL, abs_view tinyint(4) NOT NULL, abs_click tinyint(4) NOT NULL, KEY abs_dat (abs_dat) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $table = $wpdb->prefix."ad_buttons_stats_hst"; $structure = "CREATE TABLE $table ( abs_dat date NOT NULL, abs_view int(11) NOT NULL, abs_click int(11) NOT NULL );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $ad_buttons_version = "2.3.1"; update_option("ad_buttons_version", $ad_buttons_version); $ad_buttons_db_version = "2.3.1"; update_option("ad_buttons_db_version", $ad_buttons_db_version); $ip2nation_db_version = "2.3.1"; update_option("ip2nation_db_available", $ip2nation_db_version); } register_activation_hook(__FILE__,'ad_buttons_install'); $ad_buttons_db_version = get_option("ad_buttons_db_version"); if($ad_buttons_db_version <> "2.3.1"){ // update database //set the options $newoptions = get_option('widget_adbuttons_cfg'); $newoptions['ab_dspcnt'] = '1'; $newoptions['ab_target'] = 'bnk'; $newoptions['ab_powered'] = '1'; $newoptions['ab_count'] = '1'; add_option('widget_adbuttons_cfg', $newoptions); // create table global $wpdb; $table = $wpdb->prefix."ad_buttons"; $structure = "CREATE TABLE $table ( id INT(9) NOT NULL AUTO_INCREMENT, ad_picture VARCHAR(100) NOT NULL, ad_link VARCHAR(500) NOT NULL, ad_text VARCHAR(80) NOT NULL, ad_strdat DATE NOT NULL, ad_enddat DATE NOT NULL, ad_views INT(9) DEFAULT 0, ad_clicks INT(9) DEFAULT 0, ad_active TINYINT(1) NOT NULL DEFAULT 0, adg_count VARCHAR(500) NOT NULL, adg_show tinytext NOT NULL, ad_pos INT(9) DEFAULT 0, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $ab_plugindir = get_option('siteurl').'/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)); $wpdb->query("INSERT INTO $table(id, ad_picture, ad_link, ad_text, ad_views, ad_clicks, ad_active) VALUES(1, '".$ab_plugindir."/ab125.jpg', 'http://wordpress.org/plugins/ad-buttons/', 'ads powered by Ad Buttons', 1, 0, 1)"); $table = $wpdb->prefix."ad_buttons_stats"; $structure = "CREATE TABLE $table ( abs_dat date NOT NULL, abs_ip int(10) NOT NULL, abs_view tinyint(4) NOT NULL, abs_click tinyint(4) NOT NULL, KEY abs_dat (abs_dat) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $table = $wpdb->prefix."ad_buttons_stats_hst"; $structure = "CREATE TABLE $table ( abs_dat date NOT NULL, abs_view int(11) NOT NULL, abs_click int(11) NOT NULL );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($structure); $ad_buttons_version = "2.3.1"; update_option("ad_buttons_version", $ad_buttons_version); $ad_buttons_db_version = "2.3.1"; update_option("ad_buttons_db_version", $ad_buttons_db_version); $ip2nation_db_version = "2.3.1"; update_option("ip2nation_db_available", $ip2nation_db_version); } //check if user is a bot of some sort function is_bot() { $bots = array('google','yahoo','msn','jeeves','lycos','whatuseek','BSDSeek','BullsEye','Yandex', 'Seznam','XoviBot','NerdyBot','MJ12bot','bingbot','spider', 'crawler','eniro.com','ApptusBot','scraper','validator'); //takes the list above and returns (google)|(yahoo)|(msn)... $regex = '('.implode($bots, ')|(').')'; //uses the generated regex above to see if those keywords are contained in the user agent variable return eregi($regex, $_SERVER['HTTP_USER_AGENT']); } function ab_show_ad($ad_id) { global $wpdb; global $ab_geot; // check if geo targeting has been enabled if(!$ab_geot) return(1); // check if this button has geo targeting information stored at all $results = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."ad_buttons WHERE id = $ad_id LIMIT 1"); foreach($results as $result){ $adg_count = $result->adg_count; $adg_show = $result->adg_show; } if(!$adg_count) return(1); if(!$adg_show) return(1); $sql = 'SELECT country FROM ip2nation WHERE ip < INET_ATON("'.$_SERVER['REMOTE_ADDR'].'") ORDER BY ip DESC LIMIT 0,1'; list($country) = mysql_fetch_row(mysql_query($sql)); if(stristr($adg_count, $country) === FALSE) { if($adg_show == 's'){ return(0); } else { return(1); } } else { if($adg_show == 's'){ return(1); } else { return(0); } } } function ad_buttons() { global $wpdb; global $ab_geot; $widget_adbuttons_cfg = array( 'ab_title' => '', 'ab_dspcnt' => '', 'ab_target' => '', 'ab_adsense' => '', 'ab_adsense_fixed' => '', 'ab_adsense_pos' => '', 'ab_adsense_pubid' => '', 'ab_adsense_channel' => '', 'ab_adsense_corners' => '', 'ab_adsense_col_border' => '', 'ab_adsense_col_title' => '', 'ab_adsense_col_bg' => '', 'ab_adsense_col_txt' => '', 'ab_adsense_col_url' => '', 'ab_nocss' => '', 'ab_width' => '', 'ab_padding' => '', 'ab_nofollow' => '', 'ab_powered' => '', 'ab_yah' => '', 'ab_yourad' => '', 'ab_geot' => '', 'ab_yaht' => '', 'ab_yahurl' => '', 'ab_anet' => '', 'ab_anetu' => '', 'ab_anett' => '', 'ab_fix' => '', 'ab_count' => '' ); $widget_adbuttons_cfg = get_option('widget_adbuttons_cfg'); $wp_root = get_option('home'); $ab_geot = $widget_adbuttons_cfg['ab_geot']; if($widget_adbuttons_cfg['ab_nofollow']){ $ab_nofollow = ' rel="nofollow" '; } if($widget_adbuttons_cfg['ab_powered']){ if($widget_adbuttons_cfg['ab_nocss']){ $ab_powered = 'powered by Ad Buttons'; } else { $ab_powered = '
'; } } if($widget_adbuttons_cfg['ab_adsense']){ if($widget_adbuttons_cfg['ab_nocss']){ $ab_adsensecss = ''; $ab_adsenseenddiv = ''; }else{ $ab_adsensecss = '
';
} else {
echo'
';
}
}
if($widget_adbuttons_cfg['ab_nocss']){
echo $ab_powered;
}else{
echo ''.$ab_powered.'