📄 ads_add.php
字号:
<?
include_once("../adser/top.php");
if($_POST["hnsubmit"]=="1"){
if($_POST["rate"]>$_POST["hn_maxrate"]){
echo "最高点/弹比例不能大于".$_POST["hn_maxrate"]."!";
fun_alert("最高点/弹比例不能大于".$_POST["hn_maxrate"]."!");
fun_back();
exit();
}
if($_POST["rate"]<1 && $_POST["ads_form_id"]!="open"){
echo "最高点/弹比例不能小于1!";
fun_alert("最高点/弹比例不能小于1!");
fun_back();
exit();
}
if($_POST["totpub"]<$cfg_adsminpub){
echo "广告投放量最低不能小于 $cfg_adsminpub 次!";
fun_alert("广告投放量最低不能小于 $cfg_adsminpub 次!");
fun_back();
exit();
}
$money=round($_POST["totpub"] * $_POST["price"]/10 * ((1+abs($_POST["rate"]/100)) * (1+abs($_POST["rate"]/100)) +0.1))/100;
$minnum=round($cfg_adsminpub*$_POST["price"]*1.1/10)/100;
$totnum=$_POST["totnum"];
if($money < $minnum){
echo "您的广告投放量太少或您的投放单价太小!请重新提交!";
fun_alert("您的广告投放量太少或您的投放单价太小!请重新提交!");
fun_back();
exit();
}
$sqladz="select * from advertizer where username='$_SESSION[adser_username]'";
$rsadz=mysql_query($sqladz);
$rowadz=mysql_fetch_array($rsadz);
$rate=$_POST["rate"]/100;
if($_POST["over_y"]=="-" || $_POST["over_m"]=="-" || $_POST["over_d"]=="-"){
$overtime="0000-00-00 00:00:00";
}else{
$overtime=$_POST["over_y"]."-".$_POST["over_m"]."-".$_POST["over_d"]." 23:59:59";
}
if(empty($_POST["hn_edit_id"]) && empty($file_name) && $_POST["ads_form_id"]!="open"){
echo "上传文件格式只能是GIF/JPEG/JPG/SWF!";
fun_alert("上传文件格式只能是GIF/JPEG/JPG/SWF!!");
fun_back();
exit();
}
if(!empty($file_name)){
if($file_size>$cfg_upfilesize*1024){
echo "上传文件不能大于 $cfg_upfilesize KB!";
fun_alert("上传文件不能大于 $cfg_upfilesize KB!");
fun_back();
exit();
}
$arrf=explode(".",$file_name);
$counta=count($arrf)-1;
$f_type=$arrf[$counta];
$f_type=strtolower($f_type);
if(!($f_type=="gif" || $f_type=="jpeg" || $f_type=="jpg" || $f_type=="swf")){
echo "上传文件格式只能是GIF/JPEG/JPG/SWF!";
fun_alert("上传文件格式只能是GIF/JPEG/JPG/SWF!");
fun_back();
exit();
}
$picname=$_SESSION["adser_username"]."/".$_SESSION["adser_username"]."_".$time.".".$f_type;
$realpicurl="../ads/".$picname;
$dirname="../ads/".$_SESSION["adser_username"];
if(!(file_exists("$dirname") && is_dir("$dirname"))){
mkdir("$dirname", 0777);
}
copy($file,$realpicurl);
}
if(empty($_POST["hn_edit_id"])){
if($money > $rowadz["balance"]){
echo "投放数量超出了您的帐户余额!";
fun_alert("投放数量超出了您的帐户余额!");
fun_back();
exit();
}
if($_POST["ads_form_id"]=="open"){
$ads_form_id=0;
$ads_type=2;
}else{
$ads_form_id=$_POST["ads_form_id"];
$ads_type=1;
}
$alert_num=empty($_POST["alert_num"])?500:$_POST["alert_num"];
$profit=$rowadz["profit"];
$sql="INSERT INTO `ads` ( `adser_id` , `username` , `own_type` , `ads_type` , `ads_form_id` , `price` , `totpub` , `spare` , `money`, `url` , `openurl` , `openurl2` , `openurl3` , `openurl4` , `openurl5` , `link_tit` , `conn`, `picname` , `rate`, `time` , `overtime` ,`alert_num`, `profit`, `admin_stat`)
VALUES ('$_SESSION[adser_userid]','$_SESSION[adser_username]','1','$ads_type','$ads_form_id','$_POST[price]','$_POST[totpub]','$_POST[totpub]','$money','$_POST[url]','$_POST[openurl]','$_POST[openurl2]','$_POST[openurl3]','$_POST[openurl4]','$_POST[openurl5]','$_POST[link_tit]','$_POST[conn]','$picname','$rate','$datetime','$overtime','$alert_num','$profit','1')";
$rsu=mysql_query($sql);
//echo "$rsu = <br> $sql";
if($rsu){
$sql_u="UPDATE `advertizer` SET `balance` = `balance`- $money where username='$_SESSION[adser_username]'";
$rsu=mysql_query($sql_u);
}
$str_mes="添加";
}else{
$sql="select * from ads where username='$_SESSION[adser_username]' and own_type='1' and id='$_POST[hn_edit_id]'";
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs);
$old_money=$row["money"];
if($money-$old_money > $rowadz["balance"]){
echo "投放数量超出了您的帐户余额!";
fun_alert("投放数量超出了您的帐户余额!");
fun_back();
exit();
}
if(empty($file_name)){
$picname=$row["picname"];
}
if($row["ads_stat"]=="0" && $row["admin_stat"]=="1"){
$sql="update `ads` set `price`= '$_POST[price]', `totpub`= '$_POST[totpub]', `spare`= '$_POST[totpub]', `money`='$money', `url` ='$_POST[url]', `openurl`= '$_POST[openurl]', `openurl2` = '$_POST[openurl2]', `openurl3`= '$_POST[openurl3]' , `openurl4`= '$_POST[openurl4]' , `openurl5`='$_POST[openurl5]' , `link_tit`='$_POST[link_tit]', `conn`='$_POST[conn]' , `picname`= '$picname', `rate`='$rate', `time`='$datetime' , `overtime` ='$overtime',`alert_num`='$alert_num', `admin_stat`=1 where id='$_POST[hn_edit_id]' and username='$_SESSION[adser_username]'";
$rsu=mysql_query($sql);
//echo "$rsu = <br> $sql";
}
if($rsu){
$sql_u="UPDATE `advertizer` SET `balance` = `balance`- $money + $old_money where username='$_SESSION[adser_username]'";
$rsu=mysql_query($sql_u);
}
$str_mes="修改";
}
if($rsu){
fun_alert("广告".$str_mes."成功!");
fun_goto("../adser/ads_stat.php");
}else{
fun_alert("广告".$str_mes."失败!");
fun_back();
}
exit();
}
$sql="select * from advertizer where username='$_SESSION[adser_username]'";
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs);
$balance=$row["balance"];
if(!empty($_REQUEST["edit_id"])){
$sql="select * from ads where username='$_SESSION[adser_username]' and own_type='1' and id='$_REQUEST[edit_id]'";
$rs=mysql_query($sql);
$rowe=mysql_fetch_array($rs);
$ads_stat=$rowe["ads_stat"];
$admin_stat=$rowe["admin_stat"];
$picurl=$rowe["picname"];
$overtime=$rowe["overtime"];
$oy=substr($overtime,0,4);
$om=substr($overtime,5,2);
$od=substr($overtime,8,2);
if($oy=="0000"){$oy="-";}
if($om=="00"){$oy="-";}
if($od=="00"){$oy="-";}
if(!($ads_stat=="0" && $admin_stat=="1")){
echo "修改广告失败!";
fun_alert("修改广告失败!");
fun_back();
}
$picurl=$rowe["picname"];
$balance=$balance+$rowe["money"];
}
?>
<script>
<!--
function check_sub(){
if(document.form1.balance.value=="0"){
alert("您的当前帐户余额不足,请先充值!");
return false;
}
if(check_null("广告项目名称",document.form1.link_tit)){return false;}
if(check_number("投放量",document.form1.totpub)){return false;}
if(check_number("单价",document.form1.price)){return false;}
if(check_number("最高点/弹比例",document.form1.rate)){return false;}
var totpub=document.form1.totpub.value;
var minpub=document.form1.hn_minpub.value;
if(totpub<minpub){
alert("投放次数不能低于"+minpub+"次!");
return false;
}
var maxrate=document.form1.hn_maxrate.value*1;
var rate=document.form1.rate.value*1;
if(maxrate<rate){
alert("最高点/弹比例不能大于"+maxrate+"%!");
document.form1.rate.focus();
return false;
}
if(document.form1.hn_edit_id.value=="" && document.form1.hn_adstype.value!='1'){
var file=document.form1.file.value;
var patten=/(.*)\.(.*)/;
patten.test(file);
var ha=RegExp.$2;
if(!(ha=='jpeg' || ha=='gif' || ha=='swf' || ha=='jpg' || ha=='JPEG' || ha=='GIF' || ha=='SWF' || ha=='JPG')){
alert("图片文件格式只能是jpeg、gif、jpg、swf 文件!");
return false;
}
}
if(check_null("点击链接地址",document.form1.url)){return false;}
if(check_null("默认弹窗地址",document.form1.openurl)){return false;}
document.form1.submit();
}
function counter(){
var totpub=document.form1.totpub.value*1;
var price=document.form1.price.value*1;
var hn_balance=document.form1.hn_balance.value;
var rate=document.form1.rate.value;
var totnum=totpub*price*((1+rate/100)*(1+rate/100)+0.1)/1000;
var tot_num=totnum*100;
tot_num=Math.round(tot_num);
totnum=tot_num/100;
document.form1.totnum.value=totnum;
if(totnum>hn_balance){
var totpub=Math.floor(hn_balance*1000/price/((1+rate/100)*(1+rate/100)+0.1));
alert("投放数量超出了您的帐户余额!\n\n最大可以投放数量为 "+totpub+"次!");
document.form1.totnum.value=hn_balance;
document.form1.totpub.value=totpub;
}
}
function changeopen(selObj){ //v3.0
var va=selObj.options[selObj.selectedIndex].value;
if(va=="open"){
document.form1.rate.value=0;
document.form1.hn_adstype.value=1;
showrate.style.display="none";
}else{
if(document.form1.rate.value==0){
document.form1.rate.value=10;
}
document.form1.hn_adstype.value=0;
showrate.style.display="";
}
}
function showurl(){
showurl2.style.display="";
showurl3.style.display="";
showurl4.style.display="";
showurl5.style.display="";
}
-->
</script>
<table width="1001" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f7f7f7">
<tr>
<td width="200" height="323" valign="top" bgcolor="#E8EEF4">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -