<?php
error_reporting(0);
require_once("../../check.php");
require_once("../../../config.php");
isset($_POST['danhao'])?$danhao=$_POST['danhao']:$danhao=null;
date_default_timezone_set('PRC');
if($danhao==null){
    echo "no";
    exit;
}
//²éÑ¯ÊÇ·ñÖØ¸´
isset($_SERVER['HTTP_X_FORWARDED_FOR'])?$ip = $_SERVER['HTTP_X_FORWARDED_FOR']:$ip = $_SERVER['REMOTE_ADDR'];

$checksql = "select * from dunling_web_log where ip='$ip' and danhao='$danhao'";
$checkery = mysql_query($checksql,$config);
$check = mysql_num_rows($checkery);
if($check > "0"){
    echo "error";
    exit;
}

$websql =  "select * from dunling_web where danhao='$danhao'";
$webery = mysql_query($websql,$config);
$web = mysql_fetch_array($webery);
$danjia = $web['danjia'];
$upsql = "update dunling_user set jinbi=jinbi+'$danjia' where username='$username'";
$upery = mysql_query($upsql,$config);
$time = time();
$logsql = "insert into dunling_web_log (username,danhao,danjia,datetime,ip) values ('$username','$danhao','$danjia','$time','$ip')";
$logery = mysql_query($logsql,$config);

$webupsql = "update dunling_web set smoney = smoney-'$danjia' where danhao = '$danhao'";
$webupery = mysql_query($webupsql,$config);
echo 'ok';
mysql_close();
?>