<?php
/**
 *  Guojiz网址导航系统
 *	www.guojiz.com
 *  作者：梦雨
 *  @ QQ50361804
 */
namespace app\index\controller;
use think\Controller;
use think\Db;
use Captcha\Captcha;
use think\Cache;
use think\Config;
use think\Session;
use think\Request;
class Wang extends Controller
{
    public function _initialize()
    {
        returnhtml();
    }
    public function tijiaos()
    {
        $wang = Db::name('wang');
        $wangcate = Db::name('wangcate');
        $data = $this->request->post();
        $ch = config('web.XIN_Z');
        $data['time'] = time();
        $str = '12340';
        $randStr = str_shuffle($str);
        $rands = substr($randStr, 0, 2);
        $data['view'] = $rands;
        $data['uid'] = 1;
        $config = array('lianjie' => input('lianjie'));
        $contid = $_POST['tid'];
        $contids = $wangcate->where(array('keywords' => $contid))->value('show');
        $cont = $wangcate->where(array('keywords' => $contid))->value('id');
        $data['tid'] = $cont;
        if (warning() == 2) {
            $hasuserhead = $wang->where($config)->count();
            if ($contids == 1) {
                if ($hasuserhead > 0) {
                } else {
                    if ($wang->insert($data)) {
                    } else {
                    }
                }
            } else {
            }
        } else {
        }
        returnhtml();
    }
    public function tijiao()
    {
        $wang = Db::name('wang');
        $wangcate = Db::name('wangcate');
        $data = $this->request->post();
        $data['time'] = time();
        $str = '12340';
        $randStr = str_shuffle($str);
        $rands = substr($randStr, 0, 2);
        $data['view'] = $rands;
        $data['uid'] = 1;
        $config = array('lianjie' => input('lianjie'));
        $contid = $_POST['tid'];
        $contids = $wangcate->where('id = ' . $contid . '')->value('show');
        if (config('web.XIN_Y') == shul()) {
            $hasuserhead = $wang->where($config)->count();
            if ($contids == 1) {
                if ($hasuserhead > 0) {
                } else {
                    if ($wang->insert($data)) {
                    } else {
                    }
                }
            } else {
            }
        } else {
        }
        returnhtml();
    }
    public function index()
    {
        $map['open'] = 1;
        $tptc = Db::name('wang')->alias('w')->join('wangcate c', 'c.id=w.tid')->field('w.*,c.id as cid,c.name')->where('open = 1')->order('id desc')->paginate(9);
        $this->assign('tptc', $tptc);
        returnhtml();
        return view(WEB('wang_index.html'));
    }
    public function w()
    {
        if (!preg_match("/^\d*$/",input('id'))) {
            return $this->error('亲！你迷路了');
        }
        $id = input('id');
        if (empty($id)) {
            return $this->error('亲！你迷路了');
        } else {
            $wangcate = Db::name('wangcate');
            $c = $wangcate->where("id = {$id}")->find();
            if ($c) {
                $html = Db::name('wang');
                $open['open'] = 1;
                $id = $c['id'];
                $name = $c['name'];
                $tptc = $html->alias('f')->join('wangcate c', 'c.id=f.tid')->join('member m', 'm.userid=f.uid')->field('f.*,c.id as cid,m.userid,m.userhead,m.username,c.name')->where("f.tid={$id}")->where($open)->order('f.id desc')->paginate(9);
                $this->assign('tptc', $tptc);
                $this->assign('name', $name);
                $this->assign('id', $id);
                returnhtml();
                return view(WEB('wang_w.html'));
            } else {
                $this->error("亲！你迷路了！");
            }
        }
    }
    public function wangdj()
    {
        $so = input('so');
        if ($so == '') {
            $id = input('id');
            Db::name('wang')->where(array('id' => $id))->setInc('view', 1);
            $this->success("正在跳转请稍后",fun_sc_p('wang', array('id' => $id),  'lianjie').'#'.get('lailu','guojiz.com'));
        }
    }
}