Banner Updated!
"; if (isset($_GET['action'])) { if( 0 == strcmp('new', $_GET['action'])) { $list = false; if (isset($_POST['save'])) { $table = $adMangler->adsTable; $data = array('width' => $_POST['width'],'height' => $_POST['height'],'active' => $_POST['active'],'approved' => $_POST['approved'],'type' => $_POST['type'],'code' => $_POST['code'],'href' => $_POST['href'],'advertiser' => $_POST['advertiser'],'base' => $_POST['base'],'src' => $_POST['src']); $format = array('%d','%d','%d','%d','%s','%s','%s','%s','%d','%s'); $wpdb->insert($table, $data, $format); $insert_id = $wpdb->insert_id; echo $message; $sql = "SELECT * FROM $adMangler->adsTable WHERE id=$insert_id"; $banner = $wpdb->get_row($sql); echo $adMangler->FormatAd($banner); // This is a bug fix to prevent duplicate ads being created $action = str_replace("new", "edit", $action); $action .= "&id=$insert_id"; $assoc = array(); $i=0; if (is_array($_POST['pageID'])) { foreach ($_POST['pageID'] as $id) { $assoc[] = array('ad_ID'=>$insert_id, 'page_id'=>$id, 'page_exclusive'=>$_POST['pagex'][$i], 'custom_slot'=>$_POST['cslot'][$i], 'slot'=>$_POST['slot'][$i], 'slot_exclusive'=>$_POST['slotx'][0] ); $i++; } } $table = $adMangler->positionsTable; $format = array('%d','%d','%d','%d','%d','%d'); foreach ($assoc as $data) $wpdb->insert($table, $data, $format); $sql = "SELECT * FROM $adMangler->positionsTable WHERE ad_id=".intval($insert_id)." ORDER BY page_id ASC"; $banner->positions = $wpdb->get_results($sql); } } else if (0 == strcmp('delete', $_GET['action']) && isset($_GET['id'])) { $sql = "DELETE FROM $adMangler->adsTable WHERE id=".intval($_GET['id']); $wpdb->query($sql); $list = true; } else if (0 == strcmp('edit', $_GET['action']) && isset($_GET['id'])) { $list = false; if (isset($_POST['save'])) { $table = $adMangler->adsTable; $data = array('width' => $_POST['width'],'height' => $_POST['height'],'active' => $_POST['active'],'approved' => $_POST['approved'],'type' => $_POST['type'],'code' => $_POST['code'],'href' => $_POST['href'],'advertiser' => $_POST['advertiser'],'base' => $_POST['base'],'src' => $_POST['src']); $format = array('%d','%d','%d','%d','%s','%s','%s','%s','%d','%s'); $where = array('id' => $_GET['id']); $where_format = array('%d'); $wpdb->update($table, $data, $where, $format, $where_format); $wpdb->query("DELETE FROM $adMangler->positionsTable WHERE ad_id={$_GET['id']}"); $assoc = array(); $i=0; if (is_array($_POST['pageID'])) { foreach ($_POST['pageID'] as $id) { $assoc[] = array('ad_ID'=>$_GET['id'], 'page_id'=>$id, 'page_exclusive'=>$_POST['pagex'][$i], 'custom_slot'=>$_POST['cslot'][$i], 'slot'=>$_POST['slot'][$i], 'slot_exclusive'=>$_POST['slotx'][0] ); $i++; } } $table = $adMangler->positionsTable; $format = array('%d','%d','%d','%d','%d','%d'); foreach ($assoc as $data) $wpdb->insert($table, $data, $format); echo $message; } } if (isset($_GET['id'])) { $sql = "SELECT * FROM $adMangler->adsTable WHERE id=".intval($_GET['id']); $banner = $wpdb->get_row($sql); $sql = "SELECT * FROM $adMangler->positionsTable WHERE ad_id=".intval($_GET['id'])." ORDER BY page_id ASC"; $banner->positions = $wpdb->get_results($sql); echo $adMangler->FormatAd($banner); } } if (!$list): ?>| Action | Preview | Active | Approved | Base | Page Associations | Type | Size |
|---|---|---|---|---|---|---|---|
| Edit | Delete |
preview
FormatAd($result); ?>
|
active) ? "Yes" : "No"; ?> | approved) ? "Yes" : "No"; ?> | base) ? "Yes" : "No"; ?> | type; ?> | width; ?>xheight; ?> |