<?php
// +-----------------------------------------------------------------------------------
// | Software: [ThinkPHP framework]
// | Version: V4.0
// | Site: http://www.czreg.com
// +-----------------------------------------------------------------------------------
// | Author: 飘叶 <cds425@163.com>
// | Copyright (c) 2012-2014, http://www.czreg.com All Rights Reserved.
// | time:2014.10.25
// | explain:QQ属性输出类
// +-----------------------------------------------------------------------------------

namespace Home\Controller;
use Think\Controller;
class FaceController extends Controller {
    public function __construct(){
        //将参数赋值给成员属性
         
    }
    //签到
    public function qd(){
    	$server = I('get.');
    	$config = $this->configset;
    	$verstr = md5($server['serverid'].$server['time'].$config['verifystring']);
    	if($server['verifystring']!=$verstr){
    		echo -1;//验证失败
    		exit;
    	}else{
    		$user = M('User')->where(array('serverid'=>$server['serverid']))->find();
    		if(!empty($user)){
    			$today = date('Y-m-d');
    			$jf = M('Jflog')->where(array('userid'=>$user['id'],'date'=>$today,'type'=>'2'))->find();
    			if(!empty($jf)){
    				echo -2;//今天已签过到了
    				exit;
    			}else{
    				$num=rand(1,5);//随机给会员1~5个积分
    				$arrdata = array(
			    		'userid'	=> $user['id'],
			    		'jf' 		=> $num,
			    		'date'		=> date('Y-m-d'),
			    		'type'		=> 2,
			    	);
			    	//入库，写积分统计表与用户表
			    	M('Jflog')->add($arrdata);
			    	M('User')->where(array('id'=>$user['id']))->setInc('jf',$num);
			    	echo $num;
    			}
    		}else{
    			echo -3;//查找不到用户
    			exit;
    		}
    	}
    }
}