📄 piads_add.php
字号:
<?
include_once("../adser/top.php");
if($_POST["hnsubmit"]=="1"){
if($_POST["totpub"]<$cfg_adsmintextpub){
echo "广告投放量最低不能小于 $cfg_adsmintextpub 次!";
fun_alert("广告投放量最低不能小于 $cfg_adsmintextpub 次!");
fun_back();
exit();
}
$money=round($_POST["totpub"] * $_POST["price"]/10)/100;
$minnum=$cfg_adsmintextpub*$_POST["price"]/1000;
$totnum=$_POST["totnum"];
if($money < $minnum){
echo "您的广告投放量太少或您的投放单价太小!请重新提交!$money $minnum $_POST[totnum]";
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)){
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();
}
$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` , `link_tit` , `conn` ,`picname`, `time` , `overtime` ,`alert_num`, `profit`, `admin_stat`)
VALUES ('$_SESSION[adser_userid]','$_SESSION[adser_username]','1','4','$_POST[ads_form_id]','$_POST[price]','$_POST[totpub]','$_POST[totpub]','$money','$_POST[url]','$_POST[link_tit]','$_POST[conn]','$picname','$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]', `link_tit`='$_POST[link_tit]' , `conn`='$_POST[conn]' ,`picname`= '$picname', `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"];
$profit=(empty($row["profit"]))?0.8:$row["profit"];
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"];
}
$sqlads="select max(price*profit) as max, min(price*profit) as min from ads where ads_stat=2 and own_type=1 and ads_type=4";
$rowads=mysql_fetch_array(mysql_query($sqlads));
$maxp=round($rowads["max"]*100)/100;
$minp=round($rowads["min"]*100)/100;
if(!empty($maxp) || !empty($minp)){
$maxprice=empty($maxp)?" ":"当前系统中最高单价:<span class=\"orange_text\">$maxp</span>元/千次";
$minprice=empty($minp)?" ":"当前系统中最低单价:<span class=\"orange_text\">$minp</span>元/千次";
$str_vprice=$maxprice." ".$minprice;
}else{
$str_vprice="$cfg_leadsrecom 元/1000次";
}
?>
<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;}
var totpub=document.form1.totpub.value*1;
var minpub=document.form1.hn_minpub.value*1;
if(totpub<minpub){
alert("投放次数不能低于"+minpub+"次!");
document.form1.totpub.focus();
return false;
}
if(document.form1.hn_edit_id.value==""){
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_siteurl("点击链接地址",document.form1.url)){return false;}
if(check_null("广告简介",document.form1.conn)){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 hn_profit=document.form1.hn_profit.value*1;
var totnum=totpub*price/10;
tot_num=Math.round(totnum);
totnum=tot_num/100;
document.form1.totnum.value=totnum;
if(totnum>hn_balance){
var totpub=Math.floor(hn_balance*1000/price);
alert("投放数量超出了您的帐户余额!\n\n最大可以投放数量为 "+totpub+"次!");
document.form1.totnum.value=hn_balance;
document.form1.totpub.value=totpub;
}
var webprice=hn_profit*price;
document.form1.webprice.value=webprice;
}
-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -