' . $donate_link_text . ''; $links[] = $donate_link; } } return $links; } } new cbnetmpdl(); load_plugin_textdomain('your-unique-name', false, basename( dirname( __FILE__ ) ) . '/languages' ); define(WP_ADDRESS_BAR_ADS_TABLE,$wpdb->prefix."addressbarads_list"); define(WP_POSTS,$wpdb->prefix."posts"); $plugin_dir = PluginUrl(); define(WP_ADDRESS_BAR_ADS_PLUGIN_URL, $plugin_dir); // function for the getting the current plugin folder path folder path function PluginUrl() { //Try to use WP API if possible, introduced in WP 2.6 if (function_exists('plugins_url')) return trailingslashit(plugins_url(basename(dirname(__FILE__)))); //Try to find manually... can't work if wp-content was renamed or is redirected $path = dirname(__FILE__); $path = str_replace("\\","/",$path); $path = trailingslashit(get_bloginfo('wpurl')) . trailingslashit(substr($path,strpos($path,"wp-content/"))); return $path; } //Sript use for the add the header javascript and headder code add_action('wp_head', 'addressBarAds_script'); function addressBarAds_script() { global $wpdb; global $post; $c=''; $thePostID = $post->ID; if($thePostID != '') { $c= $wpdb->get_row( "SELECT * FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids like '%".$thePostID."%' limit 1" ); } // cheching for the ads showing only for the given post and page ids// if($c != '') { ?> get_var("show tables like '". WP_ADDRESS_BAR_ADS_TABLE . "'")!= WP_ADDRESS_BAR_ADS_TABLE) { $sSql = "CREATE TABLE IF NOT EXISTS `". WP_ADDRESS_BAR_ADS_TABLE . "` ("; $sSql = $sSql . "`uba_plug_id` INT NOT NULL AUTO_INCREMENT ,"; $sSql = $sSql . "`uba_page_ids` text ,"; $sSql = $sSql . "`uba_plug_link` VARCHAR( 150 ),"; $sSql = $sSql . "`uba_plug_text` TEXT ,"; $sSql = $sSql . "`uba_plug_status` VARCHAR( 10 ) NOT NULL ,"; $sSql = $sSql . "`uba_key_pos` INT (2) NOT NULL default 0,"; $sSql = $sSql . "`uba_new_win` INT (2) NOT NULL default 0,"; $sSql = $sSql . "PRIMARY KEY ( `uba_plug_id` )"; $sSql = $sSql . ")"; $wpdb->query($sSql); unset($_REQUEST); } } //funtion for the manage the plugin content function addressbarads_admin_option() { //Checking fot the validation for the blank field. if(isset($_REQUEST['sbt_ads'])) { if($_REQUEST['remove_page']=="") $message_e="Please Select page/post."; if($_REQUEST['add_banner_code']=="") $message_e="Please Enter Urls."; if(trim($_REQUEST['add_text'])=="") $message_e="Please enter Urls text."; elseif($_REQUEST['add_text']!="") { if(strpos($_REQUEST['add_text'],'%') !== false) { $message_e="% sign is not allowed in ad!"; } else { $remove = array("\n", "\r\n", "\r"); $_REQUEST['add_text']=str_replace($remove,' ',$_REQUEST['add_text']); } } } global $wpdb; //Validation error. if($message_e=="") { //Adding the record if first time in the if content is blanks if(isset($_REQUEST['sbt_ads']) && $_REQUEST['sbt_ads']=="Save" && trim($_REQUEST['add_id'])=="" ) { $ads_list = $wpdb->get_results( "SELECT uba_page_ids FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids IN ( select ID from ".WP_POSTS.")"); if(count($ads_list) == '3') { $message_e="More than 3 ads are not allowed!"; } else { $sSql = "INSERT INTO `". WP_ADDRESS_BAR_ADS_TABLE . "` ( `uba_page_ids`,`uba_plug_link`,`uba_plug_text`,`uba_plug_status`,`uba_key_pos`,`uba_new_win`) value ("; if($_REQUEST['remove_page']==""); $message="Please Select page/post."; if($_REQUEST['uba_plug_link']==""); $message="Please Enter link Urls."; if(is_array($_REQUEST['remove_page'])) { $ads_id=implode(",",$_REQUEST['remove_page']); if(substr($ads_id, 0,1) == ',') { $ads_id=substr($ads_id, 1); } } else { $ads_id=$_REQUEST['remove_page']; } $duplicate=0; foreach($_REQUEST['remove_page'] as $addpagedup) { if($addpagedup != '') { $dup = $wpdb->get_row( "SELECT uba_plug_id FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids like '%$addpagedup%' limit 1 ", ARRAY_A ); if(isset($dup['uba_plug_id']) && $dup['uba_plug_id'] != '') { $duplicate=1; } } } if(trim($_REQUEST['before']) == '') { $_REQUEST['before']='0'; } if(trim($_REQUEST['add_new_tab']) == 'on') { $_REQUEST['add_new_tab']='1'; } else { $_REQUEST['add_new_tab']='0'; } $sSql = $sSql . "'".$ads_id."',"; $sSql = $sSql . "'".$_REQUEST['add_banner_code']."',"; $sSql = $sSql . "'".rawurlencode($_REQUEST['add_text'])."',1,"; $sSql = $sSql . "'".$_REQUEST['before']."',"; $sSql = $sSql . "'".$_REQUEST['add_new_tab']."')"; if($duplicate == 1) { $message= 'duplicate'; } else { $wpdb->query($sSql); $message= 'success'; unset($_REQUEST); } } } else if(!trim($_REQUEST['add_id'])=="")//Updating the records if the content is available { if(is_array($_REQUEST['remove_page'])) { $ads_id=implode(",",$_REQUEST['remove_page']); if(substr($ads_id, 0,1) == ',') { $ads_id=substr($ads_id, 1); } } else { $ads_id=$_REQUEST['remove_page']; } $duplicate=0; foreach($_REQUEST['remove_page'] as $addpagedup) { if($addpagedup != '') { $dup = $wpdb->get_row( "SELECT uba_plug_id FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids like '%$addpagedup%' and uba_plug_id != '$_REQUEST[add_id]' limit 1 ", ARRAY_A ); if(isset($dup['uba_plug_id']) && $dup['uba_plug_id'] != '') { $duplicate=1; } } } if(trim($_REQUEST['before']) == '') { $_REQUEST['before']='0'; } if(trim($_REQUEST['add_new_tab']) == 'on') { $_REQUEST['add_new_tab']='1'; } else { $_REQUEST['add_new_tab']='0'; } $sSql = " UPDATE `". WP_ADDRESS_BAR_ADS_TABLE . "` SET "; $sSql = $sSql . "`uba_page_ids` ='".$ads_id."',"; $sSql = $sSql . "`uba_plug_link`='".$_REQUEST['add_banner_code']."',"; $sSql = $sSql . "`uba_plug_text`='".rawurlencode($_REQUEST['add_text'])."',"; $sSql = $sSql . "`uba_key_pos`='".$_REQUEST['before']."',"; $sSql = $sSql . "`uba_new_win`='".$_REQUEST['add_new_tab']."'"; $sSql = $sSql . " where `uba_plug_id`='".$_REQUEST['add_id']."'"; if($duplicate == 1) { $message= 'duplicate'; } else { $wpdb->query($sSql); $message= 'success'; unset($_REQUEST); unset($_GET['ad_id']); } } } $post_str=''; $del_id=$_GET['del_id']; if(isset($del_id) && $del_id != '') { $del_Sql = "DELETE from `". WP_ADDRESS_BAR_ADS_TABLE. "` where uba_plug_id='".$del_id."'"; $wpdb->query($del_Sql); } $ad_id= $_GET['ad_id']; if(isset($ad_id) && $ad_id != '') { $post_str="where uba_plug_id='".$ad_id."'"; $c = $wpdb->get_row( "SELECT * FROM ".WP_ADDRESS_BAR_ADS_TABLE." ".$post_str." limit 1 ", ARRAY_A ); unset($_REQUEST); } //echo "SELECT * FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids IN ( select ID from ".WP_POSTS.")"; $ads_list = $wpdb->get_results( "SELECT * FROM ".WP_ADDRESS_BAR_ADS_TABLE." where uba_page_ids IN ( select ID from ".WP_POSTS.")"); $pages_wp = $wpdb->get_results( "SELECT * FROM ".WP_POSTS." where post_type in ('page','post')"); ?>
Ad saved successfully !');?>
Multiple ads on same page are not allowed !');?>
'.$message_e.'');?>