Example #1
0
    public function index()
    {
        $where = '';
        $parameter = array();
        $name = trim($_REQUEST['name']);
        $position_id = intval($_REQUEST['position_id']);
        if (!empty($name)) {
            $where .= " AND a.name LIKE '%" . mysqlLikeQuote($name) . "%'";
            $this->assign("name", $name);
            $parameter['name'] = $name;
        }
        if ($position_id > 0) {
            $this->assign("position_id", $position_id);
            $parameter['position_id'] = $position_id;
            $where .= " AND a.position_id = '{$position_id}'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT a.id) AS acount 
			FROM ' . C("DB_PREFIX") . 'province_adv AS a ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['acount'];
        $sql = 'SELECT a.*,ap.name AS position_name  
			FROM ' . C("DB_PREFIX") . 'province_adv AS a 
			LEFT JOIN ' . C("DB_PREFIX") . 'province_adv_position AS ap ON ap.id = a.position_id ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'a.id');
        $ap_list = M("ProvinceAdvPosition")->where('status = 1')->select();
        $this->assign("ap_list", $ap_list);
        $this->display();
    }
    public function index()
    {
        if (isset($_REQUEST['cate_id'])) {
            $cate_id = intval($_REQUEST['cate_id']);
        } else {
            $cate_id = intval($_SESSION['goods_category_tags_cate_id']);
        }
        $_SESSION['goods_category_tags_cate_id'] = $cate_id;
        $parameter = array();
        $parameter['cate_id'] = $cate_id;
        $where = 'gct.cate_id = ' . $cate_id;
        $this->assign("cate_id", $cate_id);
        $tag_name = trim($_REQUEST['tag_name']);
        if (!empty($tag_name)) {
            $this->assign("tag_name", $tag_name);
            $parameter['tag_name'] = $tag_name;
            $where .= " AND gt.tag_name LIKE '%" . mysqlLikeQuote($tag_name) . "%'";
        }
        $model = M();
        $sql = 'SELECT COUNT(DISTINCT gt.tag_id) AS tcount FROM ' . C("DB_PREFIX") . 'goods_category_tags as gct 
				LEFT JOIN ' . C("DB_PREFIX") . 'goods_tags as gt ON gt.tag_id = gct.tag_id 
				WHERE ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT gct.*,gt.tag_name FROM ' . C("DB_PREFIX") . 'goods_category_tags as gct 
				LEFT JOIN ' . C("DB_PREFIX") . 'goods_tags as gt ON gt.tag_id = gct.tag_id 
				WHERE ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'sort', true);
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $name = trim($_REQUEST['name']);
        $page = trim($_REQUEST['page']);
        if (!empty($name)) {
            $where .= " AND name LIKE '%" . mysqlLikeQuote($name) . "%'";
            $this->assign("name", $name);
            $parameter['name'] = $name;
        }
        if (!empty($page)) {
            $this->assign("page", $page);
            $parameter['page'] = $page;
            $where .= " AND page = '{$page}'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT id) AS acount 
			FROM ' . C("DB_PREFIX") . 'm_adv ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['acount'];
        $sql = 'SELECT * FROM ' . C("DB_PREFIX") . 'm_adv ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'id');
        $this->display();
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $keyword = trim($_REQUEST['keyword']);
        $uname = trim($_REQUEST['uname']);
        $sid = intval($_REQUEST['sid']);
        $city_id = intval($_REQUEST['city_id']);
        if (!empty($keyword)) {
            $this->assign("keyword", $keyword);
            $parameter['keyword'] = $keyword;
            $where .= " AND sg.name LIKE '%" . mysqlLikeQuote($keyword) . "%' ";
        }
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        if ($sid > 0) {
            $this->assign("sid", $sid);
            $parameter['sid'] = $sid;
            $where .= " AND sg.sid = {$sid}";
        }
        if ($city_id > 0) {
            $this->assign("city_id", $city_id);
            $parameter['city_id'] = $city_id;
            $where .= " AND sg.city_id = {$city_id}";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT sg.gid) AS tcount
			FROM ' . C("DB_PREFIX") . 'second_goods AS sg 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = sg.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT sg.*,s.name AS sname,u.user_name   
			FROM ' . C("DB_PREFIX") . 'second_goods AS sg 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = sg.uid 
			LEFT JOIN ' . C("DB_PREFIX") . 'second AS s ON s.sid = sg.sid 
			' . $where . ' GROUP BY sg.gid';
        $this->_sqlList($model, $sql, $count, $parameter, 'sg.gid');
        $second_list = D("Second")->order('sort asc,sid asc')->findAll();
        $this->assign("second_list", $second_list);
        $city_list = D("Region")->where('parent_id = 0')->order('sort asc,id asc')->findAll();
        $this->assign("city_list", $city_list);
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $uname = trim($_REQUEST['uname']);
        $begin_time_str = trim($_REQUEST['begin_time']);
        $end_time_str = trim($_REQUEST['end_time']);
        $begin_time = !empty($begin_time_str) ? strZTime($begin_time_str) : 0;
        $end_time = !empty($end_time_str) ? strZTime($end_time_str) : 0;
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        if ($begin_time > 0) {
            $this->assign("begin_time", $begin_time_str);
            $parameter['begin_time'] = $begin_time_str;
            $where .= " AND usl.create_day >= '" . $begin_time . "'";
        }
        if ($end_time > 0) {
            $this->assign("end_time", $end_time_str);
            $parameter['end_time'] = $end_time_str;
            $where .= " AND usl.create_day < '" . ($end_time + 86400) . "'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT usl.id) AS tcount
			FROM ' . C("DB_PREFIX") . 'user_score_log AS usl 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = usl.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT usl.*,u.user_name   
			FROM ' . C("DB_PREFIX") . 'user_score_log AS usl 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = usl.uid 
			' . $where . ' GROUP BY usl.id';
        $this->_sqlList($model, $sql, $count, $parameter, 'usl.id');
        $list = $this->get('list');
        foreach ($list as $k => $v) {
            if ($v['score'] >= 0) {
                $list[$k]['inc_score'] = abs($v['score']);
            } else {
                $list[$k]['dec_score'] = abs($v['score']);
            }
        }
        $this->assign('list', $list);
        $this->display();
        return;
    }
 public function search()
 {
     $cid = intval($_REQUEST['cid']);
     $sid = intval($_REQUEST['sid']);
     $key = trim($_REQUEST['key']);
     $type = intval($_REQUEST['type']);
     $tag_name = trim($_REQUEST['tag_name']);
     $custom_tags = trim($_REQUEST['custom_tags']);
     $where = '';
     if (!empty($key)) {
         $where .= ' AND tag_name LIKE \'%' . mysqlLikeQuote($key) . '%\'';
     }
     if ($cid > 0) {
         $cids = D('GoodsCategoryTags')->getTagIDs($cid);
         if (count($cids) > 0) {
             $where .= ' AND tag_id NOT IN (' . implode(',', $cids) . ')';
         }
     }
     if ($sid > 0) {
         $sids = D('StyleCategoryTags')->getTagIDs($sid);
         if (count($cids) > 0) {
             $where .= ' AND tag_id NOT IN (' . implode(',', $sids) . ')';
         }
     }
     $tag_names = array();
     if (!empty($tag_name)) {
         $tag_name = explode('   ', $tag_name);
         foreach ($tag_name as $name) {
             $tag_names[] = addslashes($name);
         }
     }
     if (!empty($custom_tags)) {
         $custom_tags = explode(',', $custom_tags);
         foreach ($custom_tags as $custom) {
             $custom = explode('|', $custom);
             $tag_names[] = addslashes($custom[0]);
         }
     }
     if (count($tag_names) > 0) {
         $where .= ' AND tag_name NOT ' . createIN($tag_names);
     }
     $list = array();
     if (empty($where)) {
         $list = D('GoodsTags')->limit('0,60')->order('sort ASC,tag_id ASC')->findAll();
     } else {
         $list = D('GoodsTags')->where('1' . $where)->limit('0,60')->order('sort ASC,tag_id ASC')->findAll();
     }
     if ($type == 1) {
         echo json_encode($list);
     } else {
         $this->assign("tag_list", $list);
         echo $this->fetch('GoodsTags:tags');
     }
 }
    public function index()
    {
        $where = '';
        $parameter = array();
        $uname = trim($_REQUEST['uname']);
        $begin_time_str = trim($_REQUEST['begin_time']);
        $end_time_str = trim($_REQUEST['end_time']);
        $begin_time = !empty($begin_time_str) ? strZTime($begin_time_str) : 0;
        $end_time = !empty($end_time_str) ? strZTime($end_time_str) : 0;
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        if ($begin_time > 0) {
            $this->assign("begin_time", $begin_time_str);
            $parameter['begin_time'] = $begin_time_str;
            $where .= " AND r.create_day >= '" . $begin_time . "'";
        }
        if ($end_time > 0) {
            $this->assign("end_time", $end_time_str);
            $parameter['end_time'] = $end_time_str;
            $where .= " AND r.create_day < '" . ($end_time + 86400) . "'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT r.id) AS tcount
			FROM ' . C("DB_PREFIX") . 'referrals AS r 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = r.rid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT r.*,CONCAT(u.user_name,\':\',us.reg_ip) as ruser_name,CONCAT(u1.user_name,\':\',us1.reg_ip) as user_name   
			FROM ' . C("DB_PREFIX") . 'referrals AS r 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = r.rid 
			LEFT JOIN ' . C("DB_PREFIX") . 'user_status AS us ON us.uid = r.rid 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u1 ON u1.uid = r.uid 
			LEFT JOIN ' . C("DB_PREFIX") . 'user_status AS us1 ON us1.uid = r.uid 
			' . $where . ' GROUP BY r.id';
        $this->_sqlList($model, $sql, $count, $parameter, 'r.id');
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $keyword = trim($_REQUEST['keyword']);
        $uname = trim($_REQUEST['uname']);
        $cid = (int) $_REQUEST['cid'];
        if (!empty($keyword)) {
            $this->assign("keyword", $keyword);
            $parameter['keyword'] = $keyword;
            $where .= " AND a.title LIKE '%" . mysqlLikeQuote($keyword) . "%' ";
        }
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        if ($cid > 0) {
            $this->assign("cid", $cid);
            $parameter['cid'] = $cid;
            $where .= " AND a.cid = {$cid}";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE' . $where;
            $where = str_replace('WHERE AND', 'WHERE', $where);
        }
        $sql = 'SELECT COUNT(DISTINCT a.id) AS tcount 
			FROM ' . C("DB_PREFIX") . 'album AS a 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = a.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT a.*,ac.name AS cname,u.user_name   
			FROM ' . C("DB_PREFIX") . 'album AS a 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = a.uid 
			LEFT JOIN ' . C("DB_PREFIX") . 'album_category AS ac ON ac.id = a.cid 
			' . $where . ' GROUP BY a.id';
        $this->_sqlList($model, $sql, $count, $parameter, 'a.id');
        $category_list = D("AlbumCategory")->order('sort asc,id asc')->findAll();
        $this->assign("category_list", $category_list);
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $keyword = trim($_REQUEST['keyword']);
        $uname = trim($_REQUEST['uname']);
        $fid = intval($_REQUEST['fid']);
        if (!empty($keyword)) {
            $this->assign("keyword", $keyword);
            $parameter['keyword'] = $keyword;
            $where .= " AND ft.title LIKE '%" . mysqlLikeQuote($keyword) . "%' ";
        }
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
        }
        if ($fid > 0) {
            $this->assign("fid", $fid);
            $parameter['fid'] = $fid;
            $where .= " AND ft.fid = {$fid}";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT ft.tid) AS tcount
			FROM ' . C("DB_PREFIX") . 'forum_thread AS ft 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = ft.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT ft.tid,LEFT(ft.title,80) AS title,u.user_name,ft.create_time,ft.post_count,ft.is_top,ft.is_best,
			ft.is_event,f.name AS fname,ft.share_id  
			FROM ' . C("DB_PREFIX") . 'forum_thread AS ft 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = ft.uid 
			LEFT JOIN ' . C("DB_PREFIX") . 'forum AS f ON f.fid = ft.fid 
			' . $where . ' GROUP BY ft.tid';
        $this->_sqlList($model, $sql, $count, $parameter, 'ft.tid');
        $cate_tree = M("Forum")->findAll();
        $cate_tree = D("Forum")->toFormatTree($cate_tree, 'name', 'fid', 'parent_id');
        $this->assign("cate_tree", $cate_tree);
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $keyword = trim($_REQUEST['keyword']);
        $uname = trim($_REQUEST['uname']);
        $aid = intval($_REQUEST['aid']);
        if (!empty($keyword)) {
            $this->assign("keyword", $keyword);
            $parameter['keyword'] = $keyword;
            $where .= " AND at.title LIKE '%" . mysqlLikeQuote($keyword) . "%' ";
        }
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
        }
        if ($aid > 0) {
            $this->assign("aid", $aid);
            $parameter['aid'] = $aid;
            $where .= " AND at.aid = {$aid}";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT at.tid) AS tcount
			FROM ' . C("DB_PREFIX") . 'ask_thread AS at 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = at.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT at.tid,LEFT(at.title,80) AS title,u.user_name,at.create_time,at.post_count,at.is_top,at.is_best,
			a.name AS aname,at.share_id  
			FROM ' . C("DB_PREFIX") . 'ask_thread AS at 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = at.uid 
			LEFT JOIN ' . C("DB_PREFIX") . 'ask AS a ON a.aid = at.aid 
			' . $where . ' GROUP BY at.tid';
        $this->_sqlList($model, $sql, $count, $parameter, 'at.tid');
        $cate_tree = M("Ask")->order('sort asc,aid asc')->findAll();
        $this->assign("cate_tree", $cate_tree);
        $this->display();
        return;
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $name = trim($_REQUEST['name']);
        $sn = trim($_REQUEST['sn']);
        $user_name = trim($_REQUEST['user_name']);
        $goods_status = trim($_REQUEST['goods_status']);
        if (!empty($name)) {
            $this->assign("name", $name);
            $parameter['name'] = $name;
            $like_name = mysqlLikeQuote($name);
            $where .= ' AND data_name LIKE \'%' . $like_name . '%\'';
        }
        if (!empty($sn)) {
            $this->assign("sn", $sn);
            $parameter['sn'] = $sn;
            $where .= ' AND sn = \'' . $sn . '\'';
        }
        if (!empty($user_name)) {
            $this->assign("user_name", $user_name);
            $parameter['user_name'] = $user_name;
            $where .= ' AND user_name = \'' . $user_name . '\'';
        }
        if ($goods_status != "" && $goods_status >= 0) {
            $this->assign("goods_status", $goods_status);
            $parameter['goods_status'] = $goods_status;
            $where .= ' AND goods_status = ' . $goods_status;
        } else {
            $this->assign("goods_status", -1);
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(id) AS tcount
			FROM ' . C("DB_PREFIX") . 'order ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT * FROM ' . C("DB_PREFIX") . 'order ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'id');
        $this->display();
        return;
    }
Example #12
0
    public function index()
    {
        $where = '';
        $parameter = array();
        $word = trim($_REQUEST['word']);
        $type = intval($_REQUEST['type']);
        $cid = intval($_REQUEST['cid']);
        if (!empty($word)) {
            $where .= " AND w.word LIKE '%" . mysqlLikeQuote($word) . "%'";
            $this->assign("word", $word);
            $parameter['word'] = $word;
        }
        if ($type > 0) {
            $this->assign("type", $type);
            $parameter['type'] = $type;
            $where .= " AND w.type = '{$type}'";
        } else {
            $this->assign("type", 0);
        }
        if ($cid > 0) {
            $this->assign("cid", $cid);
            $parameter['cid'] = $cid;
            $where .= " AND w.cid = '{$cid}'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(DISTINCT w.id) AS wcount 
			FROM ' . C("DB_PREFIX") . 'word AS w ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['wcount'];
        $sql = 'SELECT w.*,wt.name AS cname  
			FROM ' . C("DB_PREFIX") . 'word AS w 
			LEFT JOIN ' . C("DB_PREFIX") . 'word_type AS wt ON wt.id = w.cid ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'w.id');
        $type_list = M("WordType")->where('status = 1')->findAll();
        $this->assign("type_list", $type_list);
        $this->display();
    }
    public function index()
    {
        $where = '';
        $parameter = array();
        $name = trim($_REQUEST['name']);
        $begin_time_str = trim($_REQUEST['begin_time']);
        $end_time_str = trim($_REQUEST['end_time']);
        $begin_time = !empty($begin_time_str) ? strZTime($begin_time_str) : 0;
        $end_time = !empty($end_time_str) ? strZTime($end_time_str) : 0;
        if (!empty($name)) {
            $this->assign("name", $name);
            $parameter['name'] = $name;
            $like_name = mysqlLikeQuote($name);
            $where .= ' AND name LIKE \'%' . $like_name . '%\'';
        }
        if ($begin_time > 0) {
            $this->assign("begin_time", $begin_time_str);
            $parameter['begin_time'] = $begin_time_str;
            $where .= " AND begin_time >= '" . $begin_time . "'";
        }
        if ($end_time > 0) {
            $this->assign("end_time", $end_time_str);
            $parameter['end_time'] = $end_time_str;
            $where .= " AND end_time < '" . ($end_time + 86400) . "'";
        }
        $model = M();
        if (!empty($where)) {
            $where = 'WHERE 1' . $where;
        }
        $sql = 'SELECT COUNT(id) AS tcount
			FROM ' . C("DB_PREFIX") . 'exchange_goods ' . $where;
        $count = $model->query($sql);
        $count = $count[0]['tcount'];
        $sql = 'SELECT * FROM ' . C("DB_PREFIX") . 'exchange_goods ' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'id');
        $this->display();
        return;
    }
Example #14
0
 public function getUserList()
 {
     $key = trim($_REQUEST['key']);
     $where = '';
     if (!empty($key)) {
         $match_key = segmentToUnicodeA($key, '+');
         $where .= " AND match(user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
         $like_name = mysqlLikeQuote($key);
         $where .= ' AND user_name LIKE \'%' . $like_name . '%\'';
     }
     $sql = 'SELECT uid,user_name FROM ' . C("DB_PREFIX") . 'user WHERE status = 1 ' . $where . ' ORDER BY uid DESC limit 0,30';
     $userList = M()->query($sql);
     echo json_encode($userList);
 }
    public function look()
    {
        $where = '';
        $parameter = array();
        $keyword = trim($_REQUEST['keyword']);
        $uname = trim($_REQUEST['uname']);
        $type = trim($_REQUEST['type']);
        $share_data = !isset($_REQUEST['share_data']) ? 'img' : trim($_REQUEST['share_data']);
        $cate_id = intval($_REQUEST['cate_id']);
        $status = !isset($_REQUEST['status']) ? 0 : intval($_REQUEST['status']);
        $inner_sql = '';
        $where .= " WHERE sp.type = 'look'";
        if (!empty($keyword)) {
            $this->assign("keyword", $keyword);
            $parameter['keyword'] = $keyword;
            $match_key = segmentToUnicodeA($keyword, '+');
            $where .= " AND match(sm.content_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $inner_sql .= 'INNER JOIN ' . C("DB_PREFIX") . 'share_match AS sm ON sm.share_id = s.share_id ';
        }
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        $model = M();
        $sql = 'SELECT COUNT(DISTINCT s.share_id) AS scount
			FROM ' . C("DB_PREFIX") . 'share_photo AS sp
			INNER JOIN ' . C("DB_PREFIX") . 'share AS s ON s.share_id = sp.share_id 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = s.uid 
			' . $inner_sql . $where;
        $count = $model->query($sql);
        $count = $count[0]['scount'];
        $sql = 'SELECT s.share_id,LEFT(s.content,80) AS content,u.user_name,s.create_time,s.collect_count,s.relay_count,			s.comment_count,s.type,s.share_data,s.status,s.is_best 
			FROM ' . C("DB_PREFIX") . 'share_photo AS sp  
			INNER JOIN ' . C("DB_PREFIX") . 'share AS s ON s.share_id = sp.share_id 
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = s.uid 
			' . $inner_sql . $where . ' GROUP BY s.share_id';
        $this->_sqlList($model, $sql, $count, $parameter, 's.share_id');
        $this->display();
    }
    public function check()
    {
        $where = '';
        $parameter = array();
        $uname = trim($_REQUEST['uname']);
        $mid = intval($_REQUEST['mid']);
        if (!empty($uname)) {
            $this->assign("uname", $uname);
            $parameter['uname'] = $uname;
            $match_key = segmentToUnicodeA($uname, '+');
            $where .= " AND match(u.user_name_match) against('" . $match_key . "' IN BOOLEAN MODE) ";
            $like_name = mysqlLikeQuote($uname);
            $where .= ' AND u.user_name LIKE \'%' . $like_name . '%\'';
        }
        if ($mid > 0) {
            $this->assign("mid", $mid);
            $parameter['mid'] = $mid;
            $where .= " AND ma.mid = {$mid}";
        }
        if (!empty($where)) {
            $where = ' WHERE' . $where;
            $where = str_replace('WHERE AND', 'WHERE', $where);
        }
        $model = M();
        $sql = 'SELECT COUNT(DISTINCT ma.id) AS scount
			FROM ' . C("DB_PREFIX") . 'medal_apply AS ma 
			LEFT JOIN ' . C("DB_PREFIX") . 'medal AS m ON m.mid = ma.mid  
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = ma.uid 
			' . $where;
        $count = $model->query($sql);
        $count = $count[0]['scount'];
        $sql = 'SELECT ma.id,ma.reason,ma.create_time,u.user_name,m.name,m.image,m.give_type 
			FROM ' . C("DB_PREFIX") . 'medal_apply AS ma 
			LEFT JOIN ' . C("DB_PREFIX") . 'medal AS m ON m.mid = ma.mid  
			LEFT JOIN ' . C("DB_PREFIX") . 'user AS u ON u.uid = ma.uid 
			' . $where;
        $this->_sqlList($model, $sql, $count, $parameter, 'ma.id');
        $medal_list = D('Medal')->where('status = 1 AND give_type = 1')->order('sort asc')->findAll();
        $this->assign("medal_list", $medal_list);
        $this->display();
    }