<?php
require_once("../check.php");
require_once("../../config.php");
isset($_POST['z'])?$z = $_POST['z']:$z=null;
isset($_POST['a1'])?$a1 = $_POST['a1']:$a1=null;
isset($_POST['a2'])?$a2 = $_POST['a2']:$a2=null;
isset($_POST['a3'])?$a3 = $_POST['a3']:$a3=null;
isset($_POST['a4'])?$a44 = $_POST['a4']:$a44=null;
isset($_POST['a5'])?$a5 = $_POST['a5']:$a5=null;
isset($_POST['b1'])?$b1 = $_POST['b1']:$b1=null;
isset($_POST['b2'])?$b2 = $_POST['b2']:$b2=null;
isset($_POST['b3'])?$b3 = $_POST['b3']:$b3=null;
    $a4=$a44*$a1;//计算出需要消耗的总金额
    $usersql = "select * from dunling_user where username='$username'";
    $userery = mysql_query($usersql,$config);
    $user = mysql_fetch_array($userery);
    $usermoney = $user['jinbi'];
    
    if($usermoney<$a4){
        echo "moneyerror";//金币不足
        exit;
    }

isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$ip = $_SERVER['HTTP_X_FORWARDED_FOR']:$ip = $_SERVER['REMOTE_ADDR'];
$datetime = time();
if($z=="1"){
    $danhao = "URL".rand(10000,99999).rand(10000,99999);
    $a2 = strip_tags($a2);
    $a2 = trim($a2);
    $asql = "insert into dunling_web (danhao,url,title,danjia,zmoney,smoney,time,username,datetime) values ('$danhao','$a3','$a2','$a1','$a4','$a4','$a5','$username','$datetime')";
    mysql_query($asql,$config);
    $ksql = "update dunling_user set jinbi=jinbi-'$a4' where username='$username'";
    mysql_query($ksql,$config);
    $logsql = "insert into dunling_guzhuzhichu_log (username,danhao,danjia,datetime,ip,lx) values ('$username','$danhao','$a1','$datetime','$ip','浏览任务')";
    mysql_query($logsql,$config);
    echo 'ok';
    exit;
    
}elseif($z=="2"){
    $b1 = strip_tags($b1);
    $b1 = trim($b1);
    $b2 = strip_tags($b2);
    $b2 = str_replace("\n","<br/>",$b2);
    $danhao = "RW".rand(10000,99999).rand(10000,99999);
    $asql = "insert into dunling_renwu (danhao,title,content,danjia,zmoney,smoney,username,datetime,img) values ('$danhao','$b1','$b2','$a1','$a44','$a44','$username','$datetime','$b3')";
    mysql_query($asql,$config);
    $ksql = "update dunling_user set jinbi=jinbi-'$a4' where username='$username'";
    mysql_query($ksql,$config);
    $logsql = "insert into dunling_guzhuzhichu_log (username,danhao,danjia,datetime,ip,lx) values ('$username','$danhao','$a1','$datetime','$ip','综合任务')";
    mysql_query($logsql,$config);
    echo 'ok';
    exit;
    
}
    mysql_close($config);
?>