get_results("SELECT * FROM `{$wpdb->prefix}bannerize` WHERE `trash` = '0' ORDER BY `id` ASC;"); if(is_array($adverts)) { foreach($adverts as $advert) { if($advert->banner_type != '3') { // Statistics $tracking = 'Y'; // target attr $new_window = ' target="'.esc_attr($advert->target).'"'; // rel attr $link_rel = ($advert->nofollow == '1') ? ' rel="nofollow"' : ''; // AdCode $adcode = ''; unset($new_window, $link_rel); } else { // Statistics $tracking = (!preg_match_all('/<(a|script|embed|iframe)[^>](.*?)>/i', $advert->free_html, $things)) ? 'N' : 'Y'; // AdCode $adcode = esc_attr($advert->free_html); unset($things); } // Enabled or Disabled $status = ($advert->enabled == '1') ? 'active' : 'disabled'; // Description $description = ($advert->description == '') ? 'Advert '.$advert->id : $advert->description; // Format advert $advertdata = adrotateswitch_format_advert('WP Bannerize', $description, $adcode, '', '', $tracking, 'Y', 'Y', 'Y', 'N', $status, 6, 0, 0, 0); $wpdb->insert($wpdb->prefix."adrotate", $advertdata); $ad_id = $wpdb->insert_id; if($include_schedules == 1) { $temp = explode(' ', esc_attr($advert->start_date)); list($syear, $smonth, $sday) = explode('-', $temp[0]); $start_date = gmmktime(0, 0, 0, $smonth, $sday, $syear); unset($temp); $temp = explode(' ', esc_attr($advert->end_date)); list($eyear, $emonth, $eday) = explode('-', $temp[0]); $end_date = gmmktime(0, 0, 0, $emonth, $eday, $eyear); unset($temp); $wpdb->insert($wpdb->prefix.'adrotate_schedule', array('name' => 'Imported schedule for advert '.$ad_id, 'starttime' => $start_date, 'stoptime' => $end_date, 'maxclicks' => 0, 'maximpressions' => $advert->maximpressions, 'spread' => 'N', 'dayimpressions' => 0, 'daystarttime' => '0000', 'daystoptime' => '0000', 'day_mon' => 'Y', 'day_tue' => 'Y', 'day_wed' => 'Y', 'day_thu' => 'Y', 'day_fri' => 'Y', 'day_sat' => 'Y', 'day_sun' => 'Y')); $schedule_id = $wpdb->insert_id; $wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $ad_id, 'group' => 0, 'user' => 0, 'schedule' => $schedule_id)); } if($include_stats == 1 AND ($advert->clickcount > 0 OR $advert->impressions > 0)) { $wpdb->insert($wpdb->prefix.'adrotate_stats', array('ad' => $ad_id, 'group' => 0, 'thetime' => $now, 'clicks' => esc_attr($advert->clickcount), 'impressions' => esc_attr($advert->impressions))); } unset($advertdata, $description, $adcode, $status, $ad_id, $schedule_id); } } else { wp_redirect('admin.php?page=adrotate-switch&s=2'); } wp_redirect('admin.php?page=adrotate-switch&s=1'); } else { adrotate_nonce_error(); } } ?>