<?php
// +----------------------------------------------------------------------
// | 微版本 [ windsns框架系统]
// +----------------------------------------------------------------------
// | Copyright (c) 2010~2028 http://www.windsns.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.weinuo.net ) 常州微诺信息科技有限公司 ● 微版本开发团队
// +----------------------------------------------------------------------
// | Author: liu21st <3339882530@qq.com>
// +----------------------------------------------------------------------
// | frame: windsns框架；版权所有，侵权必究！
// +----------------------------------------------------------------------
namespace app\m\controller;
use app\common\controller\Frontend;
use think\Config;
use think\Hook;
use think\Db;
use think\Request;


class Circlehuifu extends Frontend
{

  protected $layout = 'default';
    protected $noNeedLogin = ['login', 'register', 'third'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
        $auth = $this->auth;

        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }


        Hook::add('user_login_successed', function ($user) use ($auth) {
            $expire = input('post.keeplogin') ? 30 * 86400 : 0;
            Cookie::set('uid', $user->id, $expire);
            Cookie::set('token', $auth->getToken(), $expire);
        });
        Hook::add('user_register_successed', function ($user) use ($auth) {
            Cookie::set('uid', $user->id);
            Cookie::set('token', $auth->getToken());
        });
        Hook::add('user_delete_successed', function ($user) use ($auth) {
            Cookie::delete('uid');
            Cookie::delete('token');
        });
        Hook::add('user_logout_successed', function ($user) use ($auth) {
            Cookie::delete('uid');
            Cookie::delete('token');
        });
    }


    public function _empty($name)
    {
        $data = Hook::listen("user_request_empty", $name);
        foreach ($data as $index => $datum) {
            $this->view->assign($datum);
        }
        return $this->view->fetch('user/' . $name);
    }

   
    


    
public function getuserhuifu()
    {
        $getcircleid  =  input('get.contentid'); 
        $getuserfid  =  input('get.userfid'); 

        $userid = $this->auth->getUserinfo()['user_id'];

        $windsns_huifuadd['user_id']=  $userid; 
        $windsns_huifuadd['user_fid']=  $getuserfid; 
        $windsns_huifuadd['contentid']= $getcircleid;
        $windsns_huifuadd['circlehuifu_infos'] = input('post.circlehuifu_infos'); 
        $windsns_huifuadd['circlehuifu_times'] = time();

        if (!$windsns_huifuadd['circlehuifu_infos']) {
            echo 'no';
            exit;
        } else {
            $sqladd = Db::name('circlehuifu')->insert($windsns_huifuadd); 
            if ($getuserfid > 0) {
                $sqlupdate = Db::name('circlehuifu')
                    ->where('circlehuifu_id', $getuserfid)
                    ->setInc('replies', 1);
            }
            echo 'ok';
        }
    }
    
   
    
    

}
