get_var("SELECT `id` FROM `".$wpdb->prefix."adrotate` WHERE `type` = 'empty' ORDER BY `id` DESC LIMIT 1;"); if($edit_id == 0) { $wpdb->insert($wpdb->prefix."adrotate", array('title' => '', 'bannercode' => '', 'thetime' => $now, 'updated' => $now, 'author' => $current_user->user_login, 'imagetype' => 'dropdown', 'image' => '', 'link' => '', 'tracker' => 'N', 'responsive' => 'N', 'type' => 'empty', 'weight' => 6, 'sortorder' => 0, 'cbudget' => 0, 'ibudget' => 0, 'crate' => 0, 'irate' => 0, 'cities' => serialize(array()), 'countries' => serialize(array()))); $edit_id = $wpdb->insert_id; $wpdb->insert($wpdb->prefix.'adrotate_schedule', array('name' => 'Schedule for ad '.$edit_id, 'starttime' => $now, 'stoptime' => $in84days, 'maxclicks' => 0, 'maximpressions' => 0)); $schedule_id = $wpdb->insert_id; $wpdb->insert($wpdb->prefix.'adrotate_linkmeta', array('ad' => $edit_id, 'group' => 0, 'user' => 0, 'schedule' => $schedule_id)); } $ad_edit_id = $edit_id; } $edit_banner = $wpdb->get_row("SELECT * FROM `".$wpdb->prefix."adrotate` WHERE `id` = '$ad_edit_id';"); $groups = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."adrotate_groups` WHERE `name` != '' ORDER BY `sortorder` ASC, `id` ASC;"); $schedules = $wpdb->get_row("SELECT `".$wpdb->prefix."adrotate_schedule`.`id`, `starttime`, `stoptime`, `maxclicks`, `maximpressions` FROM `".$wpdb->prefix."adrotate_schedule`, `".$wpdb->prefix."adrotate_linkmeta` WHERE `ad` = $edit_banner->id AND `group` = 0 AND `user` = 0 AND `schedule` = `".$wpdb->prefix."adrotate_schedule`.`id` ORDER BY `".$wpdb->prefix."adrotate_schedule`.`id` ASC LIMIT 1;"); $linkmeta = $wpdb->get_results("SELECT `group` FROM `".$wpdb->prefix."adrotate_linkmeta` WHERE `ad` = '$edit_banner->id' AND `user` = 0 AND `schedule` = 0;"); wp_enqueue_media(); wp_enqueue_script('uploader-hook', plugins_url().'/'.ADROTATE_FOLDER.'/library/uploader-hook.js', array('jquery')); list($sday, $smonth, $syear, $shour, $sminute) = explode(" ", date("d m Y H i", $schedules->starttime)); list($eday, $emonth, $eyear, $ehour, $eminute) = explode(" ", date("d m Y H i", $schedules->stoptime)); $meta_array = ''; foreach($linkmeta as $meta) { $meta_array[] = $meta->group; } if(!is_array($meta_array)) $meta_array = array(); if($ad_edit_id) { if($edit_banner->type != 'empty') { // Errors if(strlen($edit_banner->bannercode) < 1 AND $edit_banner->type != 'empty') echo '
'. __('The AdCode cannot be empty!', 'adrotate').'
'. __('You didn\'t use %image% in your AdCode but did select an image!', 'adrotate').'
'. __('You did use %image% in your AdCode but did not select an image!', 'adrotate').'
'. __('There is a problem saving the image specification. Please reset your image and re-save the ad!', 'adrotate').'
'. __("Clicktracking is enabled but no valid link was found in the adcode!", 'adrotate').'
'. __('AdRotate cannot find an error but the ad is marked erroneous, try re-saving the ad!', 'adrotate').'
'. __('This ad is expired and currently not shown on your website!', 'adrotate').'
'. __('The ad will expire in less than 2 days!', 'adrotate').'
'. __('This ad will expire in less than 7 days!', 'adrotate').'
'. __('This ad has been disabled and does not rotate on your site!', 'adrotate').'