exit; } global $current_action; $current_action = 'edit'; if (isset($_POST['update'])) { if (do_edit('creative_server', $_POST, $_GET['id'])) { global $edited; $edited = 1; MAD_Admin_Redirect::redirect('edit_creative_server.php?edited=1&id=' . $_GET['id'] . ''); } else { global $edited; $edited = 2; } } if ($edited != 2) { $editdata = get_creativeserver_detail($_GET['id']); } require_once MAD_PATH . '/www/cp/templates/header.tpl.php'; ?> <div id="content"> <div id="contentHeader"> <h1>Edit Creative Server</h1> </div> <!-- #contentHeader --> <div class="container"> <div class="grid-24">
<?php global $current_section; $current_section = 'campaigns'; require_once '../../init.php'; // Required files require_once MAD_PATH . '/www/cp/auth.php'; require_once MAD_PATH . '/functions/adminredirect.php'; require_once MAD_PATH . '/www/cp/restricted.php'; require_once MAD_PATH . '/www/cp/admin_functions.php'; if (!check_permission('campaigns', $user_detail['user_id'])) { exit; } $creative_detail = get_creative_detail($_GET['id']); switch ($creative_detail['adv_type']) { case 1: if ($creative_detail['creativeserver_id'] == 1) { echo "<img src='../.." . MAD_CREATIVE_DIR . "" . $creative_detail['unit_hash'] . "." . $creative_detail['adv_creative_extension'] . "'>"; } else { $server_detail = get_creativeserver_detail($creative_detail['creativeserver_id']); echo "<img src='" . $server_detail['server_default_url'] . "" . $creative_detail['unit_hash'] . "." . $creative_detail['adv_creative_extension'] . "'>"; } break; case 2: echo "<img src='" . $creative_detail['adv_bannerurl'] . "'>"; break; case 3: echo $creative_detail['adv_chtml']; break; }
function do_create($type, $data, $detail) { global $user_detail; $time_now = time(); if ($type == 'user') { $data['email_address'] = strtolower($data['email_address']); if (!check_permission('add_administrator', $user_detail['user_id']) && $data['account_type'] != 2) { global $errormessage; $errormessage = 'You are not permitted to add users that are not in the Advertiser group.'; return false; } if (empty($data['first_name']) or empty($data['last_name']) or empty($data['email_address']) or empty($data['new_password']) or empty($data['new_password_2'])) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if ($data['new_password_2'] != $data['new_password']) { global $errormessage; $errormessage = 'The passwords you entered do not match.'; global $editdata; $editdata = $data; return false; } if (username_exists($data['email_address'])) { global $errormessage; $errormessage = 'A user with this e-mail address already exists in the system.'; global $editdata; $editdata = $data; return false; } $data['password_md5'] = md5($data['new_password']); $creation_date = time(); $data['first_name'] = sanitize($data['first_name']); $data['last_name'] = sanitize($data['last_name']); $data['company_name'] = sanitize($data['company_name']); $data['phone_number'] = sanitize($data['phone_number']); $data['fax_number'] = sanitize($data['fax_number']); $data['company_address'] = sanitize($data['company_address']); $data['company_city'] = sanitize($data['company_city']); $data['company_state'] = sanitize($data['company_state']); $data['company_zip'] = sanitize($data['company_zip']); $data['company_country'] = sanitize($data['company_country']); $data['tax_id'] = sanitize($data['tax_id']); $data['account_type'] = sanitize($data['account_type']); global $maindb; mysql_query("INSERT INTO md_uaccounts (email_address, pass_word, account_status, account_type, company_name, first_name, last_name, phone_number, fax_number, company_address, company_city, company_state, company_zip, company_country, tax_id, creation_date)\nVALUES ('{$data['email_address']}', '{$data['password_md5']}', '1', '{$data['account_type']}', '{$data['company_name']}', '{$data['first_name']}', '{$data['last_name']}', '{$data['phone_number']}', '{$data['fax_number']}', '{$data['company_address']}', '{$data['company_city']}', '{$data['company_state']}', '{$data['company_zip']}', '{$data['company_country']}', '{$data['tax_id']}', '{$creation_date}')", $maindb); global $created_user_id; $created_user_id = mysql_insert_id($maindb); create_rightset('user', $created_user_id, $data); return true; } if ($type == 'group') { if (empty($data['group_name'])) { global $errormessage; $errormessage = 'Please enter a group name.'; global $editdata; $editdata = $data; return false; } global $maindb; mysql_query("INSERT INTO md_user_groups (group_name, group_status)\nVALUES ('{$data['group_name']}', '1')", $maindb); global $created_group_id; $created_group_id = mysql_insert_id($maindb); create_rightset('group', $created_group_id, $data); return true; } if ($type == 'channel') { if (empty($data['channel_name'])) { global $errormessage; $errormessage = 'Please enter a channel name.'; global $editdata; $editdata = $data; return false; } global $maindb; mysql_query("INSERT INTO md_channels (channel_type, channel_name)\nVALUES ('1', '{$data['channel_name']}')", $maindb); return true; } if ($type == 'creativeserver') { if (empty($data['server_name']) or empty($data['remote_host']) or empty($data['remote_user']) or empty($data['remote_password']) or empty($data['remote_directory']) or empty($data['server_default_url'])) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } $data['server_type'] = sanitize($data['server_type']); $data['server_name'] = sanitize($data['server_name']); $data['remote_host'] = sanitize($data['remote_host']); $data['remote_user'] = sanitize($data['remote_user']); $data['remote_password'] = sanitize($data['remote_password']); $data['remote_directory'] = sanitize($data['remote_directory']); $data['server_default_url'] = sanitize($data['server_default_url']); global $maindb; mysql_query("INSERT INTO md_creative_servers (server_type, server_name, remote_host, remote_user, remote_password, remote_directory, server_default_url, server_status)\nVALUES ('{$data['server_type']}', '{$data['server_name']}', '{$data['remote_host']}', '{$data['remote_user']}', '{$data['remote_password']}', '{$data['remote_directory']}', '{$data['server_default_url']}', '1')", $maindb); return true; } if ($type == 'ad_unit') { if (empty($data['adv_name']) or $data['creative_format'] == 10 && (!is_numeric($data['custom_creative_width']) or !is_numeric($data['custom_creative_height']))) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if (!is_numeric($data['creative_format'])) { global $errormessage; $errormessage = 'Please choose a creative size for your ad.'; global $editdata; $editdata = $data; return false; } if ($data['creative_type'] == 3) { if (empty($data['html_body'])) { global $errormessage; $errormessage = 'Please enter a HTML body for your ad.'; global $editdata; $editdata = $data; return false; } } if ($data['creative_type'] == 2) { if (empty($data['creative_url']) or empty($data['click_url'])) { global $errormessage; $errormessage = 'Please enter a Creative URL and Click URL for your ad.'; global $editdata; $editdata = $data; return false; } } if ($data['creative_type'] == 1) { if (empty($data['click_url'])) { global $errormessage; $errormessage = 'Please enter a Click URL for your ad.'; global $editdata; $editdata = $data; return false; } if (!file_exists($_FILES['creative_file']['tmp_name']) || !is_uploaded_file($_FILES['creative_file']['tmp_name'])) { global $errormessage; $errormessage = 'Please upload a creative for your ad unit.'; global $editdata; $editdata = $data; return false; } } // Define Image Sizes if ($data['creative_format'] == 1) { $data['custom_creative_width'] = 320; $data['custom_creative_height'] = 50; } if ($data['creative_format'] == 2) { $data['custom_creative_width'] = 300; $data['custom_creative_height'] = 250; } if ($data['creative_format'] == 3) { $data['custom_creative_width'] = 728; $data['custom_creative_height'] = 90; } if ($data['creative_format'] == 4) { $data['custom_creative_width'] = 160; $data['custom_creative_height'] = 600; } if ($data['creative_format'] == 5) { $data['custom_creative_width'] = 300; $data['custom_creative_height'] = 50; } if ($data['creative_format'] == 6) { $data['custom_creative_width'] = 320; $data['custom_creative_height'] = 480; } // End Define Image Sizes // IF CREATIVE TYPE =1, ATTEMPT TO UPLOAD CREATIVE if ($data['creative_type'] == 1) { $creative_server = getconfig_var('default_creative_server'); // Generate Creative Hash $uniqid = uniqid(time()); $creative_hash = md5($uniqid); $file_extension = strtolower(substr(strrchr($_FILES['creative_file']['name'], "."), 1)); // Case: Remote Creative Server (FTP) if (getconfig_var('default_creative_server') > 1) { list($width, $height, $type, $attr) = getimagesize($_FILES['creative_file']['tmp_name']); if ($height != $data['custom_creative_height'] or $width != $data['custom_creative_width'] or empty($file_extension)) { global $errormessage; $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload a valid image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . ''; global $editdata; $editdata = $data; return false; } $creative_server_detail = get_creativeserver_detail(getconfig_var('default_creative_server')); if ($creative_server_detail['entry_id'] < 1) { global $errormessage; $errormessage = 'The default creative server does not seem to exist. Please change your creative server in your mAdserve control panel under Configuration>Creative Servers'; global $editdata; $editdata = $data; return false; } // Attempt: Upload include MAD_PATH . '/modules/ftp/ftp.class.php'; try { $ftp = new Ftp(); $ftp->connect($creative_server_detail['remote_host']); $ftp->login($creative_server_detail[remote_user], $creative_server_detail[remote_password]); $ftp->put($creative_server_detail[remote_directory] . $creative_hash . '.' . $file_extension, $_FILES['creative_file']['tmp_name'], FTP_BINARY); } catch (FtpException $e) { global $errormessage; $errormessage = 'FTP Client was unable to upload creative to remote server. Error given: ' . $e->getMessage() . ''; global $editdata; $editdata = $data; return false; } // End: Upload } // End Case: Remote Creative Server (FTP) // Case: Local Creative Server if (getconfig_var('default_creative_server') == 1) { include MAD_PATH . '/modules/upload/class.upload.php'; $handle = new Upload($_FILES['creative_file']); $handle->allowed = array('image/*'); $handle->file_new_name_body = $creative_hash; if ($handle->uploaded) { $image_width = $handle->image_src_x; $image_height = $handle->image_src_y; if (!empty($image_width) && !empty($image_height) && ($image_height != $data['custom_creative_height'] or $image_width != $data['custom_creative_width'])) { global $errormessage; $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload an image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . ''; global $editdata; $editdata = $data; return false; } $handle->Process(MAD_PATH . MAD_CREATIVE_DIR); if ($handle->processed) { // OK } else { global $errormessage; $errormessage = 'Creative could not be uploaded. Please check if your creative directory is writeable (' . MAD_CREATIVE_DIR . ') and that you have uploaded a valid image file.'; global $editdata; $editdata = $data; return false; } } else { // Not OK global $errormessage; $errormessage = 'Creative could not be uploaded. Please check if your creative directory is writeable (' . MAD_CREATIVE_DIR . ') and that you have uploaded a valid image file.'; global $editdata; $editdata = $data; return false; } } // End Case: Local Creative Sercer } // END CREATIVE UPLOAD global $maindb; // Insert Ad Unit into DB if (!isset($creative_server)) { $creative_server = ''; } if (!isset($creative_hash)) { $creative_hash = ''; } if (!isset($file_extension)) { $file_extension = ''; } if (!isset($data['adv_mraid'])) { $data['adv_mraid'] = ''; } $data['creative_type'] = sanitize($data['creative_type']); $data['click_url'] = sanitize($data['click_url']); $data['html_body'] = sanitize($data['html_body']); $data['creative_url'] = sanitize($data['creative_url']); $data['tracking_pixel'] = sanitize($data['tracking_pixel']); $data['adv_name'] = sanitize($data['adv_name']); $data['custom_creative_height'] = sanitize($data['custom_creative_height']); $data['custom_creative_width'] = sanitize($data['custom_creative_width']); $data['adv_mraid'] = sanitize($data['adv_mraid']); mysql_query("INSERT INTO md_ad_units (campaign_id, unit_hash, adv_type, adv_status, adv_click_url, adv_click_opentype, adv_chtml, adv_bannerurl, adv_impression_tracking_url, adv_name, adv_clickthrough_type, adv_creative_extension, adv_height, adv_width, creativeserver_id, adv_mraid)\nVALUES ('{$data['campaign_id']}', '{$creative_hash}', '{$data['creative_type']}', '1', '{$data['click_url']}', '', '{$data['html_body']}', '{$data['creative_url']}', '{$data['tracking_pixel']}', '{$data['adv_name']}', '', '{$file_extension}', '{$data['custom_creative_height']}', '{$data['custom_creative_width']}', '{$creative_server}', '{$data['adv_mraid']}')", $maindb); global $created_adunit_id; $created_adunit_id = mysql_insert_id($maindb); // END: Insert Ad Unit into DB return true; } if ($type == 'campaign') { if (!isset($data['as_values_1'])) { $data['as_values_1'] = ''; } if (!isset($data['placement_select'])) { $data['placement_select'] = ''; } if (!isset($data['channel_select'])) { $data['channel_select'] = ''; } if (!isset($data['target_iphone'])) { $data['target_iphone'] = ''; } if (!isset($data['target_ipod'])) { $data['target_ipod'] = ''; } if (!isset($data['target_ipad'])) { $data['target_ipad'] = ''; } if (!isset($data['target_android'])) { $data['target_android'] = ''; } if (!isset($data['target_other'])) { $data['target_other'] = ''; } $countries_active = 0; $separate_countries = explode(',', $data['as_values_1']); foreach ($separate_countries as $my_tag) { if (!empty($my_tag)) { $countries_active = 1; } } if (!is_numeric($data['campaign_priority']) or empty($data['campaign_name'])) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if ($data['geo_targeting'] == 2 && $countries_active != 1) { global $errormessage; $errormessage = 'Please select at least one country you want to target.'; global $editdata; $editdata = $data; return false; } if ($data['publication_targeting'] == 2 && count($data['placement_select']) < 1) { global $errormessage; $errormessage = 'Please select at least one placement you want to target.'; global $editdata; $editdata = $data; return false; } if ($data['channel_targeting'] == 2 && count($data['channel_select']) < 1) { global $errormessage; $errormessage = 'Please select at least one channel you want to target.'; global $editdata; $editdata = $data; return false; } if ($data['device_targeting'] == 2 && ($data['target_iphone'] != 1 && $data['target_ipod'] != 1 && $data['target_ipad'] != 1 && $data['target_android'] != 1 && $data['target_other'] != 1)) { global $errormessage; $errormessage = 'Please select at least one device type you want to target.'; global $editdata; $editdata = $data; return false; } if ($data['campaign_type'] == 'network' && !is_numeric($data['campaign_networkid'])) { global $errormessage; $errormessage = 'Please select an ad network to send your campaign traffic to.'; global $editdata; $editdata = $data; return false; } if (!empty($data['total_amount']) && !is_numeric($data['total_amount'])) { global $errormessage; $errormessage = 'Your daily cap needs to be a numeric value.'; global $editdata; $editdata = $data; return false; } if ($data['campaign_type'] != 'network') { if (empty($data['adv_name']) or $data['creative_format'] == 10 && (!is_numeric($data['custom_creative_width']) or !is_numeric($data['custom_creative_height']))) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if (!is_numeric($data['creative_format'])) { global $errormessage; $errormessage = 'Please choose a creative size for your ad.'; global $editdata; $editdata = $data; return false; } if ($data['creative_type'] == 3) { if (empty($data['html_body'])) { global $errormessage; $errormessage = 'Please enter a HTML body for your ad.'; global $editdata; $editdata = $data; return false; } } if ($data['creative_type'] == 2) { if (empty($data['creative_url']) or empty($data['click_url'])) { global $errormessage; $errormessage = 'Please enter a Creative URL and Click URL for your ad.'; global $editdata; $editdata = $data; return false; } } if ($data['creative_type'] == 1) { if (empty($data['click_url'])) { global $errormessage; $errormessage = 'Please enter a Click URL for your ad.'; global $editdata; $editdata = $data; return false; } if (!file_exists($_FILES['creative_file']['tmp_name']) || !is_uploaded_file($_FILES['creative_file']['tmp_name'])) { global $errormessage; $errormessage = 'Please upload a creative for your ad unit.'; global $editdata; $editdata = $data; return false; } } if ($data['start_date_type'] == 2 && empty($data['startdate_value'])) { global $errormessage; $errormessage = 'Please choose a start date for your campaign.'; global $editdata; $editdata = $data; return false; } if ($data['end_date_type'] == 2 && empty($data['enddate_value'])) { global $errormessage; $errormessage = 'Please choose an end date for your campaign.'; global $editdata; $editdata = $data; return false; } if ($data['start_date_type'] == 2) { $start_date = explode('/', $data['startdate_value']); $start_date_array['year'] = $start_date[2]; $start_date_array['day'] = $start_date[1]; $start_date_array['month'] = $start_date[0]; $start_date_array['unix'] = strtotime("{$start_date_array['year']}-{$start_date_array['month']}-{$start_date_array['day']}"); } if ($data['end_date_type'] == 2) { $end_date = explode('/', $data['enddate_value']); $end_date_array['year'] = $end_date[2]; $end_date_array['day'] = $end_date[1]; $end_date_array['month'] = $end_date[0]; $end_date_array['unix'] = strtotime("{$end_date_array['year']}-{$end_date_array['month']}-{$end_date_array['day']}"); } if ($data['end_date_type'] == 2 && $end_date_array['unix'] < time()) { global $errormessage; $errormessage = 'The end date you entered is in the past. Please choose an end date in the future.'; global $editdata; $editdata = $data; return false; } // Define Image Sizes if ($data['creative_format'] == 1) { $data['custom_creative_width'] = 320; $data['custom_creative_height'] = 50; } if ($data['creative_format'] == 2) { $data['custom_creative_width'] = 300; $data['custom_creative_height'] = 250; } if ($data['creative_format'] == 3) { $data['custom_creative_width'] = 728; $data['custom_creative_height'] = 90; } if ($data['creative_format'] == 4) { $data['custom_creative_width'] = 160; $data['custom_creative_height'] = 600; } if ($data['creative_format'] == 5) { $data['custom_creative_width'] = 300; $data['custom_creative_height'] = 50; } if ($data['creative_format'] == 6) { $data['custom_creative_width'] = 320; $data['custom_creative_height'] = 480; } // End Define Image Sizes // IF CREATIVE TYPE =1, ATTEMPT TO UPLOAD CREATIVE if ($data['creative_type'] == 1) { // Generate Creative Hash $uniqid = uniqid(time()); $creative_hash = md5($uniqid); $file_extension = strtolower(substr(strrchr($_FILES['creative_file']['name'], "."), 1)); // Case: Remote Creative Server (FTP) if (getconfig_var('default_creative_server') > 1) { list($width, $height, $type, $attr) = getimagesize($_FILES['creative_file']['tmp_name']); if ($height != $data['custom_creative_height'] or $width != $data['custom_creative_width'] or empty($file_extension)) { global $errormessage; $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload a valid image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . ''; global $editdata; $editdata = $data; return false; } $creative_server_detail = get_creativeserver_detail(getconfig_var('default_creative_server')); if ($creative_server_detail['entry_id'] < 1) { global $errormessage; $errormessage = 'The default creative server does not seem to exist. Please change your creative server in your mAdserve control panel under Configuration>Creative Servers'; global $editdata; $editdata = $data; return false; } // Attempt: Upload include MAD_PATH . '/modules/ftp/ftp.class.php'; try { $ftp = new Ftp(); $ftp->connect($creative_server_detail['remote_host']); $ftp->login($creative_server_detail[remote_user], $creative_server_detail[remote_password]); $ftp->put($creative_server_detail[remote_directory] . $creative_hash . '.' . $file_extension, $_FILES['creative_file']['tmp_name'], FTP_BINARY); } catch (FtpException $e) { global $errormessage; $errormessage = 'FTP Client was unable to upload creative to remote server. Error given: ' . $e->getMessage() . ''; global $editdata; $editdata = $data; return false; } // End: Upload } // End Case: Remote Creative Server (FTP) // Case: Local Creative Server if (getconfig_var('default_creative_server') == 1) { include MAD_PATH . '/modules/upload/class.upload.php'; $handle = new Upload($_FILES['creative_file']); $handle->allowed = array('image/*'); $handle->file_new_name_body = $creative_hash; if ($handle->uploaded) { $image_width = $handle->image_src_x; $image_height = $handle->image_src_y; if (!empty($image_width) && !empty($image_height) && ($image_height != $data['custom_creative_height'] or $image_width != $data['custom_creative_width'])) { global $errormessage; $errormessage = 'The image you uploaded does not appear to be in the right dimensions. Please upload an image sized ' . $data['custom_creative_width'] . 'x' . $data['custom_creative_height'] . ''; global $editdata; $editdata = $data; return false; } $handle->Process(MAD_PATH . MAD_CREATIVE_DIR); if ($handle->processed) { // OK } else { global $errormessage; $errormessage = 'Creative could not be uploaded. Please check if your creative directory is writeable (' . MAD_CREATIVE_DIR . ') and that you have uploaded a valid image file.'; global $editdata; $editdata = $data; return false; } } else { // Not OK global $errormessage; $errormessage = 'Creative could not be uploaded. Please check if your creative directory is writeable (' . MAD_CREATIVE_DIR . ') and that you have uploaded a valid image file.'; global $editdata; $editdata = $data; return false; } } // End Case: Local Creative Sercer } // END CREATIVE UPLOAD } $creation_timestamp = time(); /* Date Stuff */ if ($data['start_date_type'] == 1) { $start_date_array['year'] = date("Y"); $start_date_array['day'] = date("d"); $start_date_array['month'] = date("m"); } if ($data['end_date_type'] == 1) { $end_date_array['year'] = '2090'; $end_date_array['day'] = '12'; $end_date_array['month'] = '12'; } if ($data['start_date_type'] == 2) { $start_date = explode('/', $data['startdate_value']); $start_date_array['year'] = $start_date[2]; $start_date_array['day'] = $start_date[1]; $start_date_array['month'] = $start_date[0]; $start_date_array['unix'] = strtotime("{$start_date_array['year']}-{$start_date_array['month']}-{$start_date_array['day']}"); } if ($data['end_date_type'] == 2) { $end_date = explode('/', $data['enddate_value']); $end_date_array['year'] = $end_date[2]; $end_date_array['day'] = $end_date[1]; $end_date_array['month'] = $end_date[0]; $end_date_array['unix'] = strtotime("{$end_date_array['year']}-{$end_date_array['month']}-{$end_date_array['day']}"); } $data['startdate_value'] = '' . $start_date_array['year'] . '-' . $start_date_array['month'] . '-' . $start_date_array['day'] . ''; $data['enddate_value'] = '' . $end_date_array['year'] . '-' . $end_date_array['month'] . '-' . $end_date_array['day'] . ''; global $maindb; if (!isset($data['target_iphone'])) { $data['target_iphone'] = ''; } if (!isset($data['target_ipod'])) { $data['target_ipod'] = ''; } if (!isset($data['target_ipad'])) { $data['target_ipad'] = ''; } if (!isset($data['target_android'])) { $data['target_android'] = ''; } if (!isset($data['target_other'])) { $data['target_other'] = ''; } if (!isset($data['ios_version_min'])) { $data['ios_version_min'] = ''; } if (!isset($data['ios_version_max'])) { $data['ios_version_max'] = ''; } if (!isset($data['android_version_min'])) { $data['android_version_min'] = ''; } if (!isset($data['android_version_max'])) { $data['android_version_max'] = ''; } $data['campaign_type'] = sanitize($data['campaign_type']); $data['campaign_name'] = sanitize($data['campaign_name']); $data['campaign_desc'] = sanitize($data['campaign_desc']); $data['startdate_value'] = sanitize($data['startdate_value']); $data['enddate_value'] = sanitize($data['enddate_value']); $data['campaign_networkid'] = sanitize($data['campaign_networkid']); $data['campaign_priority'] = sanitize($data['campaign_priority']); $data['target_iphone'] = sanitize($data['target_iphone']); $data['target_ipod'] = sanitize($data['target_ipod']); $data['target_ipad'] = sanitize($data['target_ipad']); $data['target_android'] = sanitize($data['target_android']); $data['target_other'] = sanitize($data['target_other']); $data['ios_version_min'] = sanitize($data['ios_version_min']); $data['ios_version_max'] = sanitize($data['ios_version_max']); $data['android_version_min'] = sanitize($data['android_version_min']); $data['android_version_max'] = sanitize($data['android_version_max']); $data['geo_targeting'] = sanitize($data['geo_targeting']); $data['publication_targeting'] = sanitize($data['publication_targeting']); $data['channel_targeting'] = sanitize($data['channel_targeting']); $data['device_targeting'] = sanitize($data['device_targeting']); // Insert Campaign into DB mysql_query("INSERT INTO md_campaigns (campaign_owner, campaign_status, campaign_type, campaign_name, campaign_desc, campaign_start, campaign_end, campaign_creationdate, campaign_networkid, campaign_priority, target_iphone, target_ipod, target_ipad, target_android, target_other, ios_version_min, ios_version_max, android_version_min, android_version_max, country_target, publication_target, channel_target, device_target)\nVALUES ('{$user_detail['user_id']}', '1', '{$data['campaign_type']}', '{$data['campaign_name']}', '{$data['campaign_desc']}', '{$data['startdate_value']}', '{$data['enddate_value']}', '{$creation_timestamp}', '{$data['campaign_networkid']}', '{$data['campaign_priority']}', '{$data['target_iphone']}', '{$data['target_ipod']}', '{$data['target_ipad']}', '{$data['target_android']}', '{$data['target_other']}', '{$data['ios_version_min']}', '{$data['ios_version_max']}', '{$data['android_version_min']}', '{$data['android_version_max']}', '{$data['geo_targeting']}', '{$data['publication_targeting']}', {$data['channel_targeting']}, '{$data['device_targeting']}')", $maindb); global $created_campaign_id; $created_campaign_id = mysql_insert_id($maindb); // END: Insert Campaign into DB if ($data['campaign_type'] != 'network') { if ($data['creative_type'] == 1) { $creative_server = getconfig_var('default_creative_server'); } // Insert Ad Unit into DB if (!isset($creative_server)) { $creative_server = ''; } if (!isset($creative_hash)) { $creative_hash = ''; } if (!isset($file_extension)) { $file_extension = ''; } if (!isset($data['adv_mraid'])) { $data['adv_mraid'] = ''; } $data['creative_type'] = sanitize($data['creative_type']); $data['click_url'] = sanitize($data['click_url']); $data['html_body'] = sanitize($data['html_body']); $data['creative_url'] = sanitize($data['creative_url']); $data['tracking_pixel'] = sanitize($data['tracking_pixel']); $data['adv_name'] = sanitize($data['adv_name']); $data['custom_creative_height'] = sanitize($data['custom_creative_height']); $data['custom_creative_width'] = sanitize($data['custom_creative_width']); $data['adv_mraid'] = sanitize($data['adv_mraid']); mysql_query("INSERT INTO md_ad_units (campaign_id, unit_hash, adv_type, adv_status, adv_click_url, adv_click_opentype, adv_chtml, adv_bannerurl, adv_impression_tracking_url, adv_name, adv_clickthrough_type, adv_creative_extension, adv_height, adv_width, creativeserver_id, adv_mraid)\nVALUES ('{$created_campaign_id}', '{$creative_hash}', '{$data['creative_type']}', '1', '{$data['click_url']}', '', '{$data['html_body']}', '{$data['creative_url']}', '{$data['tracking_pixel']}', '{$data['adv_name']}', '', '{$file_extension}', '{$data['custom_creative_height']}', '{$data['custom_creative_width']}', '{$creative_server}', '{$data['adv_mraid']}')", $maindb); global $created_adunit_id; $created_adunit_id = mysql_insert_id($maindb); // END: Insert Ad Unit into DB } // Extra Targeting Variables // Country if ($data['geo_targeting'] == 2) { $separate_countries = explode(',', $data['as_values_1']); foreach ($separate_countries as $country_tag) { if (!empty($country_tag)) { // Add Country add_campaign_targeting($created_campaign_id, 'geo', $country_tag); } } } //End Country // Channel if ($data['channel_targeting'] == 2 && is_array($data['channel_select'])) { foreach ($data['channel_select'] as $channel_id) { add_campaign_targeting($created_campaign_id, 'channel', $channel_id); } } // End Channel // Placement if ($data['publication_targeting'] == 2 && is_array($data['placement_select'])) { foreach ($data['placement_select'] as $placement_id) { add_campaign_targeting($created_campaign_id, 'placement', $placement_id); } } // End Placement // End: Extra Targeting Variables if (!isset($data['cap_type'])) { $data['cap_type'] = ''; } if (!isset($data['total_amount'])) { $data['total_amount'] = ''; } // Add Campaign Limit mysql_query("INSERT INTO md_campaign_limit (campaign_id, cap_type, total_amount, total_amount_left)\nVALUES ('{$created_campaign_id}', '{$data['cap_type']}', '{$data['total_amount']}', '{$data['total_amount']}')", $maindb); // END: Add Campaign Limit return true; } if ($type == 'placement') { global $maindb; if (!isset($data['mobfox_min_cpc_active'])) { $data['mobfox_min_cpc_active'] = 0; } if (!isset($data['mobfox_backfill_active'])) { $data['mobfox_backfill_active'] = 0; } if (!isset($data['zone_height'])) { $data['zone_height'] = ''; } if (!isset($data['zone_width'])) { $data['zone_width'] = ''; } if (!is_numeric($detail)) { global $errormessage; $errormessage = 'Please select a Publication to add this zone to.'; global $editdata; $editdata = $data; return false; } if (!is_numeric($data['zone_refresh']) or empty($data['zone_name']) or $data['zone_size'] == '10' && (!is_numeric($data['custom_zone_width']) or !is_numeric($data['custom_zone_height'])) or empty($data['zone_type']) or $data['zone_type'] == 'banner' && !is_numeric($data['zone_size'])) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if ($data['mobfox_min_cpc_active'] == 1 && (!is_numeric($data['min_cpc']) or !is_numeric($data['min_cpm']) or $data['min_cpm'] > 5 or $data['min_cpc'] > 0.2)) { global $errormessage; $errormessage = 'Invalid minimum CPC/CPM values entered.'; global $editdata; $editdata = $data; return false; } $publication_detail = get_publication_detail($detail); if ($publication_detail['inv_type'] == 3 && $data['zone_type'] == 'interstitial') { global $errormessage; $errormessage = 'Full Page Interstitials are supported only inside iOS and Android applications.'; global $editdata; $editdata = $data; return false; } $uniqid = uniqid($data['zone_name']); $new_placement_hash = md5($uniqid); if ($data['zone_size'] == 1) { $data['zone_width'] = 320; $data['zone_height'] = 50; } if ($data['zone_size'] == 2) { $data['zone_width'] = 300; $data['zone_height'] = 250; } if ($data['zone_size'] == 3) { $data['zone_width'] = 728; $data['zone_height'] = 90; } if ($data['zone_size'] == 4) { $data['zone_width'] = 160; $data['zone_height'] = 600; } $data['zone_name'] = sanitize($data['zone_name']); $data['zone_type'] = sanitize($data['zone_type']); $data['zone_width'] = sanitize($data['zone_width']); $data['zone_height'] = sanitize($data['zone_height']); $data['zone_refresh'] = sanitize($data['zone_refresh']); $data['zone_channel'] = sanitize($data['zone_channel']); $data['zone_description'] = sanitize($data['zone_description']); $data['mobfox_backfill_active'] = sanitize($data['mobfox_backfill_active']); $data['mobfox_min_cpc_active'] = sanitize($data['mobfox_min_cpc_active']); $data['min_cpc'] = sanitize($data['min_cpc']); $data['min_cpm'] = sanitize($data['min_cpm']); $data['backfill_alt_1'] = sanitize($data['backfill_alt_1']); $data['backfill_alt_2'] = sanitize($data['backfill_alt_2']); $data['backfill_alt_3'] = sanitize($data['backfill_alt_3']); mysql_query("INSERT INTO md_zones (publication_id, zone_hash, zone_name, zone_type, zone_width, zone_height, zone_refresh, zone_channel, zone_description, mobfox_backfill_active, mobfox_min_cpc_active, min_cpc, min_cpm, backfill_alt_1, backfill_alt_2, backfill_alt_3)\nVALUES ('{$detail}', '{$new_placement_hash}', '{$data['zone_name']}', '{$data['zone_type']}', '{$data['zone_width']}', '{$data['zone_height']}', '{$data['zone_refresh']}', '{$data['zone_channel']}', '{$data['zone_description']}', '{$data['mobfox_backfill_active']}', '{$data['mobfox_min_cpc_active']}', '{$data['min_cpc']}', '{$data['min_cpm']}', '{$data['backfill_alt_1']}', '{$data['backfill_alt_2']}', '{$data['backfill_alt_3']}')", $maindb); global $created_zone_id; $created_zone_id = mysql_insert_id($maindb); mf_add_publication_layer($created_zone_id, 1); return true; } if ($type == 'publication') { global $maindb; if (!isset($data['mobfox_min_cpc_active'])) { $data['mobfox_min_cpc_active'] = 0; } if (!isset($data['mobfox_backfill_active'])) { $data['mobfox_backfill_active'] = 0; } if (!isset($data['zone_height'])) { $data['zone_height'] = ''; } if (!isset($data['zone_width'])) { $data['zone_width'] = ''; } if (empty($data['inv_name']) or !is_numeric($data['inv_type']) or empty($data['inv_address']) or !is_numeric($data['inv_defaultchannel']) or !is_numeric($data['zone_refresh']) or empty($data['zone_name']) or $data['zone_size'] == '10' && (!is_numeric($data['custom_zone_width']) or !is_numeric($data['custom_zone_height'])) or empty($data['zone_type']) or $data['zone_type'] == 'banner' && !is_numeric($data['zone_size'])) { global $errormessage; $errormessage = 'Please fill out all required fields.'; global $editdata; $editdata = $data; return false; } if ($data['mobfox_min_cpc_active'] == 1 && (!is_numeric($data['min_cpc']) or !is_numeric($data['min_cpm']) or $data['min_cpm'] > 5 or $data['min_cpc'] > 0.2)) { global $errormessage; $errormessage = 'Invalid minimum CPC/CPM values entered.'; global $editdata; $editdata = $data; return false; } if ($data['inv_type'] == 3 && $data['zone_type'] == 'interstitial') { global $errormessage; $errormessage = 'Full Page Interstitials are supported only inside iOS and Android applications.'; global $editdata; $editdata = $data; return false; } $data['inv_type'] = sanitize($data['inv_type']); $data['inv_name'] = sanitize($data['inv_name']); $data['inv_description'] = sanitize($data['inv_description']); $data['inv_address'] = sanitize($data['inv_address']); $data['inv_defaultchannel'] = sanitize($data['inv_defaultchannel']); mysql_query("INSERT INTO md_publications (inv_status, inv_type, inv_name, inv_description, inv_address, inv_defaultchannel, creator_id)\nVALUES (1, '{$data['inv_type']}', '{$data['inv_name']}', '{$data['inv_description']}', '{$data['inv_address']}', '{$data['inv_defaultchannel']}', '{$user_detail['user_id']}')", $maindb); $new_publication_id = mysql_insert_id($maindb); if (do_create('placement', $data, $new_publication_id)) { return true; } } }