⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 campaign_edit2.php

📁 基于actionscript3.0的flashLoading控件
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

session_start(); 
header("Cache-control: private");

$campaign_id = $_POST["campaign_id"];
if($campaign_id == null || $campaign_id == "") {
	$campaign_id = $_GET["campaign_id"];
}
$campaign_name = $_POST["campaign_name"];
$start_date = $_POST["start_date"];
$banner_id = $_POST["banner_id"];
$end_date = $_POST["end_date"];
$campaign_active = $_POST["campaign_active"];
$impressions = $_POST["impressions"];
$clicks = $_POST["clicks"];
$monthly = $_POST["monthly"];
$img_link = $_POST["img_link"];
$limit = $_POST["limit"];
$weight = $_POST["weight"];
$savechanges = $_POST["savechanges"];
$image = $_POST["image"];

require 'config.php';

if($_SESSION['username'] == $admin_username && $_SESSION['password'] == $admin_password) {

	$connection = mysql_connect($DBhost,$DBuser,$DBpass) or die("Couldn't make connection: ". mysql_error());
	$db = mysql_select_db("$DBName", $connection) or die("Couldn't select database: ". mysql_error());

	print '<head>
		<title>Edit Banner</title>
		<link href="banner_styles.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" language="JavaScript1.2" src="jsfunctions.js"></script>

<script language="JavaScript1.2">

function confirmDelete() {
	var agree=confirm("Are you sure you want to delete this banner?");
	if (agree)
		return true;
	else
		return false;
}

function confirmReset() {
	var agree=confirm("Are you sure you want to reset all stats counters for this banner?");
	if (agree)
		return true;
	else
		return false;
}

function validate() {
	if (document.campaign_form.banner_id.value=="") {
		alert("A banner ad group must be selected for this banner");
		return false;		
	} else if (document.campaign_form.campaign_name.value=="") {
		alert("An name has not been entered for this campaign");
		return false;
	} else if (getRadioSelection(document.campaign_form.limit)=="impressions" && document.campaign_form.impressions_clicks.value =="") {
		alert("Enter the number of impressions.");
		return false;
	} else if (getRadioSelection(document.campaign_form.limit)=="clicks" && document.campaign_form.impressions_clicks.value =="") {
		alert("Enter the number of clicks.");
		return false;	
	} else if (document.campaign_form.start_date.value=="" || document.campaign_form.end_date.value=="") {
		alert("Both start date and end date must be entered");
		return false;
	} else if (document.campaign_form.weight.value=="" || document.campaign_form.weight<=0) {
		alert("A weight value of 1 or greater must be entered");
		return false;
	} else if(isDate(document.campaign_form.start_date.value) == false) {
		document.campaign_form.start_date.focus();
		return false;
	} else if(isDate(document.campaign_form.end_date.value) == false) {
		document.campaign_form.end_date.focus();
		return false;
	} else {
		return true;
	}

}

function saveForm() {
	if(validate()) {
		document.forms["campaign_form"].submit();
	}
}

function deleteForm() {
	if(confirmDelete()) {
		document.forms["delete_campaign"].submit();
	}
}

function deleteForce() {
	if(confirmDelete()) {
		document.forms["delete_campaign_force"].submit();
	}
}

function resetStats() {
	if(confirmReset()) {
		document.forms["campaign_form"].savechanges.value = "R";
		document.forms["campaign_form"].submit();
	}
}

function saveImg() {	
	if(validate()) {				
		document.forms["img_form"].submit();
	}
}
</script>
</head>

<body marginheight="30" topmargin="30">';

$message = "";

if($savechanges == "R") {
	$resetQuery = "	DELETE FROM ad_counters
					WHERE campaign_id = ".$campaign_id;
					
	mysql_query($resetQuery,$connection) or die("Couldn't execute query: ". mysql_error());
	$message = '<p class="messagebold">Stats counters for this banner have been reset</p>';
} else if($savechanges == "Y") {	

	if($campaign_active == "true") {
		$campaign_active = "Y";
	} else {
		$campaign_active = "N";
	}
	if($monthly == "true") {
		$monthly = "Y";
	} else {
		$monthly = "N";
	}

	$impressions = 0;
	$clicks = 0;
	
	if($limit == "impressions") {
		$impressions = $impressions_clicks;	
	} else if($limit == "clicks") {
		$clicks = $impressions_clicks;
	}

	$campaignSelect = "	SELECT id
						FROM ad_campaigns
						WHERE name LIKE '".$campaign_name."'
						AND id <> ".$campaign_id;

	$result = mysql_query($campaignSelect,$connection) or die("Couldn't execute query: ". mysql_error());
	$numR = mysql_num_rows($result);
	
	if($numR>0) {		
		$message = '<p class="messagebold">A banner with this name already exists!!!</p>';
	} else {	
		$campaignUpdate = "	UPDATE ad_campaigns
							SET name = '".$campaign_name."',
							startdate = '".$start_date."',
							banner_id = ".$banner_id.",
							enddate = '".$end_date."',
							active = '".$campaign_active."',
							impressions = ".$impressions.",
							clicks = ".$clicks.",
							monthly = '".$monthly."',
							weight = ".$weight."
							WHERE id = ".$campaign_id;
							
		
		mysql_query($campaignUpdate,$connection) or die("Couldn't execute query: ". mysql_error());
		$message = '<p class="messagebold">Changes have been saved successfully</p>';
  	}
}
	
$campaignQuery =	"	SELECT company_name, ad_campaigns.name, startdate, enddate, impressions,
						clicks, monthly, active, weight
						FROM ad_campaigns, ad_companies
						WHERE ad_campaigns.company_id = ad_companies.id
						AND ad_campaigns.id = ".$campaign_id;
				
$result = mysql_query($campaignQuery,$connection) or die("Couldn't execute query: ". mysql_error());
if($row = mysql_fetch_array($result)) {
	$company_name = $row['company_name'];	
	$campaign_name = $row['name'];
	$startdate = $row['startdate'];
	$enddate = $row['enddate'];
	$impressions = $row['impressions'];
	$clicks = $row['clicks'];
	$monthly = $row['monthly'];	
	$active = $row['active'];
	$weight = $row['weight'];
	//$message;

	if($impressions > 0) {
		$impressions_clicks = $impressions;
	} else if($clicks > 0) {
		$impressions_clicks = $clicks;
	}
}
print '<table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#ACC366" bgcolor="#2C78C5">
    <tr bgcolor="#ACC366">
      <td bgcolor="#ACC366">
	  <table width="100%"  border="1" cellpadding="3" cellspacing="0" bordercolor="#ACC366">
        <tr>
          <td><span class="heading">Edit Banner for '.$company_name.' (Step 3/3)</span></td>
        </tr>
      </table>        </td>
    </tr>
    <tr valign="top">
      <td>
	  <table width="100%"  border="1" cellpadding="10" cellspacing="0" bordercolor="#ACC366">
		<form name="campaign_form" method="post" action="campaign_edit2.php">
		<input type="hidden" name="campaign_id" value="'.$campaign_id.'">
		<input type="hidden" name="savechanges" value="Y">';
  if($message != "") {
		print '<tr bgcolor="#2C78C5"><td width="100%" colspan="4">'.$message.'</td></tr>';
  }
  print '<tr bgcolor="#2C78C5">
          <td width="110"><span class="bodytext">Banner Name</span></td>
          <td width="150"><p class="style1"><span class="bodytext">
            <input name="campaign_name" type="text" id="campaign_name" value="'.$campaign_name.'" class="formtext">
            </span>
            </td>
			<td width="110"><span class="bodytext">Banner Ad Group</span></td>
	        <td><span class="bodytext">
				<select size="1" name="banner_id" class="formtext">';

				$bannerQuery =	"	SELECT ad_campaigns.banner_id, ad_banners.banner_name
									FROM ad_campaigns, ad_banners
									WHERE ad_campaigns.banner_id = ad_banners.id
									AND ad_campaigns.id = ".$campaign_id;
		
				$result = mysql_query($bannerQuery,$connection) or die("Couldn't execute query: ". mysql_error());
				if($row = mysql_fetch_array($result)) {
					$banner_id = $row['banner_id'];
					$banner_name = $row['banner_name'];
			
					print '<option value="'.$banner_id.'">'.$banner_name.'</option>';
				} else {
					print '<option value="">Select Banner</option>';
				}	
				$query =	"	SELECT id, banner_name
								FROM ad_banners
								ORDER BY banner_name";
				
				$result = mysql_query($query,$connection) or die("Couldn't execute query: ". mysql_error());
				while($row = mysql_fetch_array($result)){
					$banner_id = $row['id'];
					$banner_name = $row['banner_name'];

					print '<option value="'.$banner_id.'">'.$banner_name.'</option>';
				}
				

print '</span></td>
          </tr>
        <tr bgcolor="#2C78C5">
          <td width="110"><span class="bodytext">Active</span></td>
          <td width="150"><span class="bodytext">';

		if($active == "Y")
			print '<input name="campaign_active" type="radio" value="true" checked>Yes';
		else
			print '<input name="campaign_active" type="radio" value="true">Yes';      
	 	if($active == "N")
			print '<input name="campaign_active" type="radio" value="false" checked>No';
		else
			print '<input name="campaign_active" type="radio" value="false">No';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -