<?php
require_once("../check.php");
require_once("../../config.php");
require_once("../../core/setting.php");
isset($_POST['id'])?$id=$_POST['id']:$id=null;
isset($_POST['username'])?$username=$_POST['username']:$username=null;
isset($_POST['money'])?$tixianmoney=$_POST['money']:$tixianmoney="0";
isset($_POST['liushuihao'])?$liushuihao=$_POST['liushuihao']:$liushuihao=null;
isset($_POST['fukuanren'])?$fukuanren=$_POST['fukuanren']:$fukuanren=null;

if(($liushuihao==null) or ($fukuanren == null)){
    exit;
}

//查用户的上线
$usersql = "select unions from dunling_menber where username='$username'";
$userery = mysql_query($usersql,$config);
$useriii = mysql_fetch_array($userery);
$union = $useriii['unions'];
if($union>"0"){
    $tichengbili = $setting['ticheng'];
    $ticheng = $tichengbili*$tixianmoney; 
    //当上级存在，则返现
    $fxsql = "update dunling_menber set moneypay=moneypay+'$ticheng',money=money+'$ticheng',ticheng=ticheng+'$ticheng' where id='$union'";
    mysql_query($fxsql,$config);    
}

$payoksql = "update dunling_pay set zt='1',liushuihao='$liushuihao',fukuanren='$fukuanren' where id='$id'";
$payok = mysql_query($payoksql,$config);
mysql_close();
if($payok){
    echo "ok";
}
?>