core = $core; if (isset($_GET['ad_id'])) { $this->ad_id = $_GET['ad_id']; } $this->date_time = $rDateTime = date('Y-m-d H:i:s'); $this->action_by_ip = $_SERVER['REMOTE_ADDR']; $this->check_add_update(); $this->display_form(); } function check_add_update() { $output = ''; if (isset($_POST['msbd_adsmp_save']) && $_POST['msbd_adsmp_save'] == 'save') { $this->sponsor_type = $this->core->msbd_sanitization($_POST['sponsor_type'], 'text'); $this->content_type = $this->core->msbd_sanitization($_POST['content_type'], 'text'); $this->script = $this->core->msbd_sanitization($_POST['script'], 'html_js'); $this->remark = $this->core->msbd_sanitization($_POST['remark'], 'html'); $this->adv_sizes = $this->core->msbd_sanitization($_POST['adv_sizes'], 'text'); $this->width = $this->core->msbd_sanitization($_POST['width'], 'number'); $this->height = $this->core->msbd_sanitization($_POST['height'], 'number'); $this->status = $this->core->msbd_sanitization($_POST['status'], 'text'); $newdata = array( 'date_time' => $this->date_time, 'sponsor_type' => $this->sponsor_type, 'content_type' => $this->content_type, 'script' => $this->script, 'remark' => $this->remark, 'adv_sizes' => $this->adv_sizes, 'width' => $this->width, 'height' => $this->height, 'status' => $this->status, 'action_by_ip' => $this->action_by_ip ); //dump($newdata, 'NEW DATA'); $validData = true; if ($this->adv_sizes=='' && empty($this->width) && empty($this->height) ) { $output .= '
You must choose a predefined size of advertisement or provide width and height combination.
'; $validData = false; } if ($this->sponsor_type == '') { $output .= '
You must choose a type of advertisement.
'; $validData = false; } if ($this->content_type == '') { $output .= '
You must choose a type of advertisement content.
'; $validData = false; } if ($this->script == '') { $output .= '
You must add the script of advertisement.
'; $validData = false; } $var_filter = "sponsor_type='$this->sponsor_type' AND content_type='$this->content_type' AND width='$this->width' AND height='$this->height' AND adv_sizes='$this->adv_sizes'"; if($this->ad_id!="") { $var_filter .= " AND id!='$this->ad_id'"; } //$this->core->db->debug_queries = TRUE; $isExist = $this->core->db->check_exist($var_filter, false); if ($isExist) { $output .= '
Advertisement from the sponsor with same size, and type is exist!
'; $validData = false; } if ($validData) { $this->core->db->save($newdata, $this->ad_id); $output .= '
The advertisement has been saved.
'; } } echo $output; } function display_form($record = NULL) { if ($this->ad_id && $record == NULL) { $record =(array) $this->core->db->get($this->ad_id, TRUE); $this->display_form($record); return; } if (is_null($record)) { $record = array( 'date_time' => NULL, 'sponsor_type' => NULL, 'content_type' => NULL, 'script' => NULL, 'remark' => NULL, 'adv_sizes' => NULL, 'width' => NULL, 'height' => NULL, 'status' => NULL, 'action_by_ip' => NULL, ); } ?>
get_sponsor_options('class="select" type="text" name="sponsor_type" id="sponsor_type"', $record['sponsor_type']); ?>
get_ad_content_type_options('class="select" type="text" name="content_type" id="content_type"', $record['content_type']); ?>
get_ad_size_options('class="select" type="text" name="adv_sizes" id="adsmp_adv_sizes"', $record['adv_sizes']); ?>
get_ad_status_options('class="select" type="text" name="status" id="status"', $record['status']); ?>
'; $record =(array) $this->core->db->get_sponsor_types(); foreach($record as $row) { if($selVal==$row['title']) $html .= ''; else $html .= ''; } $html .= ''; return $html; } function get_ad_status_options($att, $selVal='') { $html = ''; return $html; } function get_ad_content_type_options($att, $selVal='') { $html = ''; return $html; } function get_ad_size_options($att, $selVal='') { $record =(array) $this->core->db->get_adv_sizes(); $html = ''; return $html; } } /* end of file msbd-ads-admin-add-edit.php */