<?php
/**
 * FunAdmin
 * ============================================================================
 * 版权所有 2017-2028 FunAdmin，并保留所有权利。
 * 网站地址: http://www.FunAdmin.com
 * ----------------------------------------------------------------------------
 * 采用最新Thinkphp8实现
 * ============================================================================
 * Author: yuege
 * Date: 2017/8/2
 */
namespace app\frontend\controller;
use app\common\controller\Frontend;
use think\App;
use think\captcha\facade\Captcha;
use think\facade\Console;
use think\facade\Db;
use think\Request;
class Index extends Frontend {
    protected $layout='';


    public function __construct(App $app)
    {
        
        parent::__construct($app);
    }
    public function index(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        
        $week = $weekArray[date("w")];
        
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select(); // 站点
        $link = Db::name("url")->where("status",1)->select(); // 友联
        $type = Db::name("type")->where('status',1)->select(); // 分类
        $tools = Db::name("tools")->where("status",1)->select(); // 工具
        $advertise = Db::name("advertise")->where("status",1)->select(); // 广告
        $contact = Db::name("contact")->where("status",1)->select(); // 联系方式
        
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/index',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
    
     public function lianxi(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        
        $week = $weekArray[date("w")];
        
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select();
        $link = Db::name("url")->where("status",1)->select();
        $type = Db::name("type")->where('status',1)->select();
        $tools = Db::name("tools")->where("status",1)->select();
        $advertise = Db::name("advertise")->where("status",1)->select();
        $contact = Db::name("contact")->where("status",1)->select();
        
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/lianxi',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
    
     public function youxi(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        
        $week = $weekArray[date("w")];
        
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select();
        $link = Db::name("url")->where("status",1)->select();
        $type = Db::name("type")->where('status',1)->select();
        $tools = Db::name("tools")->where("status",1)->select();
        $advertise = Db::name("advertise")->where("status",1)->select();
        $contact = Db::name("contact")->where("status",1)->select();
        
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/youxi',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
    
     public function gongju(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        
        $week = $weekArray[date("w")];
        
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select();
        $link = Db::name("url")->where("status",1)->select();
        $type = Db::name("type")->where('status',1)->select();
        $tools = Db::name("tools")->where("status",1)->select();
        $advertise = Db::name("advertise")->where("status",1)->select();
        $contact = Db::name("contact")->where("status",1)->select();
        
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/gongju',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
    
        public function utils(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        
        $week = $weekArray[date("w")];
        
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select();
        $link = Db::name("url")->where("status",1)->select();
        $type = Db::name("type")->where('status',1)->select();
        $tools = Db::name("tools")->where("status",1)->select();
        $advertise = Db::name("advertise")->where("status",1)->select();
        $contact = Db::name("contact")->where("status",1)->select();
        
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/utils',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
        public function contact(){
        $template = Db::name("config")->where("code","template")->find()['value'];
        $weekArray = ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'];
        $week = $weekArray[date("w")];
        $site = Db::name("site")->where("status",1)->order("weigh",'desc')->select();
        $link = Db::name("url")->where("status",1)->select();
        $type = Db::name("type")->where('status',1)->select();
        $tools = Db::name("tools")->where("status",1)->select();
        $advertise = Db::name("advertise")->where("status",1)->select();
        $contact = Db::name("contact")->where("status",1)->select();
        countTime(Db::name("site")->where(['zctime'=>['neq','NULL'],'status'=>1])->select());
        countData($this->request->ip());
        
       return view('/index/'.$template.'/contact',['site'=>$site,'link'=>$link,'type'=>$type,'week'=>$week,'tools'=>$tools,'advertise'=>$advertise,'contact'=>$contact]);
    }
    
    
    /**
     * @return \think\Response
     * 验证码
     */
    public function verify()
    {
        return Captcha::create();
    }

}