• thinkphp百度小程序打造的接口api


         因为网站要对接百度小程序,于是做了一个api,用于对接百度小程序,代码如下:

    <?php
    header("Content-type: application/json; charset=utf-8"); 
    error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
    define('IN_DESTOON', true);
    define('FILE_APPEND', 1); 
    require './../config.inc.php';
    require './../include/global.func.php';
    require './../lang/zh-cn/lang.inc.php';
    require 'Db.class.php';
    $seturl ='https://www.kaotop.com/public/';
    $dbms = 'mysql';     //数据库类型
    $host = $CFG['db_host']; //数据库主机名
    $dbName = $CFG['db_name'];    //使用的数据库
    $user = $CFG['db_user'];      //数据库连接用户名
    $pass = $CFG['db_pass'];          //对应的密码
    $dsn = "$dbms:host=$host;dbname=$dbName";
    $port = 3306;
    try {
    	$PDO = new Db($dbms,$host,$dbName,$user,$pass,$port); //初始化一个PDO对象
    	//$PDO->pdo->query('set names utf8');
    } catch (PDOException $e) {
    	die("Error!: " . $e->getMessage() . "
    ");
    }
    
    require 'FileCache.class.php';
    $CONFIG = GetConfig();
    $cache = new cache($CONFIG['cache']*60*60);
    $cache->cacheCheck();
    
    $m = isset($_GET['m']) ? $_GET['m'] : '';
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $kw = isset($_GET['kw']) ? urldecode($_GET['kw']) : '';
    $catid = isset($_GET['catid']) ? $_GET['catid'] : '';
    $userid = isset($_GET['userid']) ? $_GET['userid'] : '';
    $username = isset($_GET['username']) ? $_GET['username'] : '';
    $itemid = isset($_GET['itemid']) ? $_GET['itemid'] : '';
    $pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 20;
    $limit = ($page-1)*$pageSize.','.$pageSize;
    $state = 200;
    $message = "success";
    if($m){
    	switch ($m){
    
    		//配置
    		case 'config':
    			$data = $CONFIG;
    		break;
    
    		//首页焦点图
    		case 'banner':
    			$table = 'youchuang_banner';
    			$fields = '*';
    			$where = '1';
    			$order = 'weigh DESC';
    			$arr = Db::select($PDO->pdo,$table,$fields,$where,$order);
    			$data = array();
    			$i = 0;
    			foreach($arr as $row){
    				$data[$i]['picture'] = $seturl.$row['image'];
    				echo $data[$i]['picture'];
    				$data[$i]['url'] = $row['url'];
    				$i++;
    			}
    		break;
    
    		//首页推荐分类
    		case 'index_category':
    			$table = 'youchuang_index_category';
    			$fields = '*';
    			$where = '1';
    			$order = 'weigh DESC';
    			$arr = Db::select($PDO->pdo,$table,$fields,$where,$order);
    			$data = array();
    			$i = 0;
    			foreach($arr as $row){
    				$data[$i]['icon'] = $seturl.$row['image'];
    				$data[$i]['id'] = $row['url'];
    				$data[$i]['name'] = $row['name'];
    				$i++;
    			}
    		break;
    
    		//首页推荐品牌
    		case 'index_brand':
    			$table = $CFG['tb_pre'].'brand_13';
    			$fields = 'itemid,title,thumb';
    		    $where = '`status`=3';
    			//$order = 'itemid DESC';
    			$order = GetOrder('brand');
    			$limit = 6;
    			$data = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    		break;
    
    		//推荐资讯
    		case 'index_article':
    			$table = $CFG['tb_pre'].'article_21';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach ($data as $row) {
    				$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    				$i++;
    			}
    		break;
    
    	//推荐小学
    		case 'index_xiaoxue':
    			$table = $CFG['tb_pre'].'article_23';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach ($data as $row) {
    				$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    				$i++;
    			}
    		break;
    
    
    
    		//推荐商家
    		case 'index_company':
    			$table = $CFG['tb_pre'].'company';
    			$fields = 'userid,username,company,thumb,introduce,business,address';
    				$where = '`status`=3';
    			$order = 'userid DESC';
    			//$order = GetOrder('company');
    			$limit = 6;
    			$data = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    		break;
    
    		//推荐产品
    		case 'index_sell':
    			$table = $CFG['tb_pre'].'sell_5';
    			$fields = 'itemid,company,thumb,introduce,unit,price';
    			$where = '`level`=1 AND `status`=3';
    			//$order = 'itemid DESC';
    			$order = GetOrder('sell');
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data = array();
    			}
    		break;
    
    		//资讯列表
    		case 'article_list':
    			$table = $CFG['tb_pre'].'article_21';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//资讯内容
    		case 'article_detail':
    			$moduleid=21;
    			$table = $CFG['tb_pre'].'article_21';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_21';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的资讯ID";
    			}
    		break;
    
    		//相关资讯
    		case 'article_more':
    			$table = $CFG['tb_pre'].'article_21';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //资讯搜索
            case 'article_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_21';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//资讯分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //资讯内容集合
            case 'article_detail_all':
    			$moduleid=21;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_21';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				//$table = $CFG['tb_pre'] . 'article_data_21';
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_21';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的资讯ID";
    			}
            break;
    //资讯模块关闭
    
    
    //小学列表
    		case 'xiaoxue_list':
    			$table = $CFG['tb_pre'].'article_23';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//小学内容
    		case 'xiaoxue_detail':
    			$moduleid=23;
    			$table = $CFG['tb_pre'].'article_23';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的小学ID";
    			}
    		break;
    
    		//相关小学
    		case 'xiaoxue_more':
    			$table = $CFG['tb_pre'].'article_23';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'xiaoxue_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //小学搜索
            case 'xiaoxue_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_23';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//小学分类
    		case 'xiaoxue_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //小学内容集合
            case 'xiaoxue_detail_all':
    			$moduleid=23;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_23';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_23';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的小学ID";
    			}
            break;
    //小学模块关闭
    
    //初中列表
    		case 'chuzhong_list':
    			$table = $CFG['tb_pre'].'article_24';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//初中内容
    		case 'chuzhong_detail':
    			$moduleid=24;
    			$table = $CFG['tb_pre'].'article_24';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的初中ID";
    			}
    		break;
    
    		//相关初中
    		case 'chuzhong_more':
    			$table = $CFG['tb_pre'].'article_24';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //初中搜索
            case 'chuzhong_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_24';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//初中分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //初中内容集合
            case 'chuzhong_detail_all':
    			$moduleid=24;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_24';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_24';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的初中ID";
    			}
            break;
    //初中模块关闭
    //高中列表
    		case 'gaozhong_list':
    			$table = $CFG['tb_pre'].'article_25';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//高中内容
    		case 'gaozhong_detail':
    			$moduleid=25;
    			$table = $CFG['tb_pre'].'article_25';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的高中ID";
    			}
    		break;
    
    		//相关高中
    		case 'gaozhong_more':
    			$table = $CFG['tb_pre'].'article_25';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //高中搜索
            case 'gaozhong_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_25';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//高中分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //高中内容集合
            case 'gaozhong_detail_all':
    			$moduleid=25;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_25';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_25';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的高中ID";
    			}
            break;
    //高中模块关闭
    
    //语言列表
    		case 'yuyan_list':
    			$table = $CFG['tb_pre'].'article_26';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//语言内容
    		case 'yuyan_detail':
    			$moduleid=26;
    			$table = $CFG['tb_pre'].'article_26';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的语言ID";
    			}
    		break;
    
    		//相关语言
    		case 'yuyan_more':
    			$table = $CFG['tb_pre'].'article_26';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //语言搜索
            case 'yuyan_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_26';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//语言分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //语言内容集合
            case 'yuyan_detail_all':
    			$moduleid=26;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_26';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_26';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的语言ID";
    			}
            break;
    //语言模块关闭
    //会计列表
    		case 'kuaiji_list':
    			$table = $CFG['tb_pre'].'article_27';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//会计内容
    		case 'kuaiji_detail':
    			$moduleid=27;
    			$table = $CFG['tb_pre'].'article_27';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的会计ID";
    			}
    		break;
    
    		//相关会计
    		case 'kuaiji_more':
    			$table = $CFG['tb_pre'].'article_27';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //会计搜索
            case 'kuaiji_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_27';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//会计分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //会计内容集合
            case 'kuaiji_detail_all':
    			$moduleid=27;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_27';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_27';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的会计ID";
    			}
            break;
    //会计模块关闭
    
    //驾考列表
    		case 'jiakao_list':
    			$table = $CFG['tb_pre'].'article_28';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//驾考内容
    		case 'jiakao_detail':
    			$moduleid=28;
    			$table = $CFG['tb_pre'].'article_28';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的驾考ID";
    			}
    		break;
    
    		//相关驾考
    		case 'jiakao_more':
    			$table = $CFG['tb_pre'].'article_28';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //驾考搜索
            case 'jiakao_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_28';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//驾考分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //驾考内容集合
            case 'jiakao_detail_all':
    			$moduleid=28;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_28';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_28';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的驾考ID";
    			}
            break;
    //驾考模块关闭
    
    //学历列表
    		case 'xueli_list':
    			$table = $CFG['tb_pre'].'article_29';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//学历内容
    		case 'xueli_detail':
    			$moduleid=29;
    			$table = $CFG['tb_pre'].'article_29';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_24';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的学历ID";
    			}
    		break;
    
    		//相关学历
    		case 'xueli_more':
    			$table = $CFG['tb_pre'].'article_29';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //学历搜索
            case 'xueli_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_29';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//学历分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //学历内容集合
            case 'xueli_detail_all':
    			$moduleid=29;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                 $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_29';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_29';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的学历ID";
    			}
            break;
    //学历模块关闭
    //司法列表
    		case 'sifa_list':
    			$table = $CFG['tb_pre'].'article_30';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//司法内容
    		case 'sifa_detail':
    			$moduleid=30;
    			$table = $CFG['tb_pre'].'article_30';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_30';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的司法ID";
    			}
    		break;
    
    		//相关司法
    		case 'sifa_more':
    			$table = $CFG['tb_pre'].'article_30';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //司法搜索
            case 'sifa_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_30';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//司法分类
    		case 'sifa_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //司法内容集合
            case 'sifa_detail_all':
    			$moduleid=30;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_30';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_30';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的司法ID";
    			}
            break;
    //司法模块关闭
    //it列表
    		case 'it_list':
    			$table = $CFG['tb_pre'].'article_31';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//it内容
    		case 'it_detail':
    			$moduleid=30;
    			$table = $CFG['tb_pre'].'article_31';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_31';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的itID";
    			}
    		break;
    
    		//相关it
    		case 'it_more':
    			$table = $CFG['tb_pre'].'article_31';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //it搜索
            case 'it_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_31';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//it分类
    		case 'article_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //it内容集合
            case 'it_detail_all':
    			$moduleid=31;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                  $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_31';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_31';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的itID";
    			}
            break;
    //it模块关闭
    //医护列表
    		case 'yihu_list':
    			$table = $CFG['tb_pre'].'article_33';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//医护内容
    		case 'yihu_detail':
    			$moduleid=33;
    			$table = $CFG['tb_pre'].'article_33';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data = Db::find($PDO->pdo,$table,$fields,$where);
                  $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_30';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的医护ID";
    			}
    		break;
    
    		//相关医护
    		case 'yihu_more':
    			$table = $CFG['tb_pre'].'article_33';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //医护搜索
            case 'yihu_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_33';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//医护分类
    		case 'yihu_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //医护内容集合
            case 'yihu_detail_all':
    			$moduleid=33;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_33';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_33';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的医护ID";
    			}
            break;
    //医护模块关闭
    //建筑列表
    		case 'jianzhu_list':
    			$table = $CFG['tb_pre'].'article_34';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//建筑内容
    		case 'jianzhu_detail':
    			$moduleid=33;
    			$table = $CFG['tb_pre'].'article_34';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    			$data = Db::find($PDO->pdo,$table,$fields,$where);
                                                   $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_30';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的建筑ID";
    			}
    		break;
    
    		//相关建筑
    		case 'jianzhu_more':
    			$table = $CFG['tb_pre'].'article_34';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //建筑搜索
            case 'jianzhu_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_34';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//建筑分类
    		case 'jianzhu_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //建筑内容集合
            case 'jianzhu_detail_all':
    			$moduleid=34;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_34';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_34';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的建筑ID";
    			}
            break;
    //建筑模块关闭
    //学术列表
    		case 'xueshu_list':
    			$table = $CFG['tb_pre'].'article_36';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//学术内容
    		case 'xueshu_detail':
    			$moduleid=33;
    			$table = $CFG['tb_pre'].'article_36';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    			$data = Db::find($PDO->pdo,$table,$fields,$where);
                                                   $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_30';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的学术ID";
    			}
    		break;
    
    		//相关学术
    		case 'xueshu_more':
    			$table = $CFG['tb_pre'].'article_36';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //学术搜索
            case 'xueshu_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_36';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//学术分类
    		case 'xueshu_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //学术内容集合
            case 'xueshu_detail_all':
    			$moduleid=36;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_36';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_36';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的学术ID";
    			}
            break;
    //学术模块关闭
    //合同列表
    		case 'hetong_list':
    			$table = $CFG['tb_pre'].'article_37';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('article',$mtype,$catid);
    		break;
    
    		//合同内容
    		case 'hetong_detail':
    			$moduleid=33;
    			$table = $CFG['tb_pre'].'article_37';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    			$data = Db::find($PDO->pdo,$table,$fields,$where);
                                                   $zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
               $split=ceil($chufa);
                   	$table= $CFG['tb_pre'].$moduleid."_".$split;//分表
    				//$table = $CFG['tb_pre'] . 'article_data_30';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的合同ID";
    			}
    		break;
    
    		//相关合同
    		case 'hetong_more':
    			$table = $CFG['tb_pre'].'article_37';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('article');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			$limit = rand(0,$conut).',10';
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach ($data as $row) {
    					$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    		break;
    
    		//相关搜索
    		case 'article_rand_keyword':
    			$data = RandKeyword('article',10);
            break;
            
            //合同搜索
            case 'hetong_search':
                if(!empty($kw)){
                    $table = $CFG['tb_pre'] . 'article_37';
                    $fields = 'itemid,title,thumb,introduce,addtime';
    				//$order = 'itemid DESC';
    				$order = GetOrder('article');
                    $where = '`status`=3 AND keyword LIKE"%' . $kw . '%"';
                    $data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if ($conut>0) {
                        $ids = '';
                        foreach ($data as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where, $order);
    					$i = 0;
    					foreach ($data as $row) {
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data = array();
                    }
                }else{
                    $data = array();
    				$state = 403;
    				$message = "请输入关键词";
                }
            break;
    
    		//合同分类
    		case 'hetong_cat':
    			$data = GetCatTop('article');
    			$item = array('catid'=>0,'catname'=>'全部');
    			array_unshift($data,$item);
    		break;
    
     //合同内容集合
            case 'hetong_detail_all':
    			$moduleid=37;
    			$module="article";
    			$zhengshu=100000;
    			$chufa=$itemid/$zhengshu;
                $split=ceil($chufa);
    			//分表
    			$table = $CFG['tb_pre'].'article_37';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table= $CFG['tb_pre'].$moduleid."_".$split;
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = 'itemid,title,thumb,introduce,addtime';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'article_37';
                    if($catid>0){
                        $arrchildid = GetCatChild($catid);
                        $where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
                    }
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
                    }
                    //$data['rand_keyword'] = RandKeyword('article',10);
    				$data['cat'] = GetCatTop('article');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('article','show',$catid);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的合同ID";
    			}
            break;
    //合同模块关闭
    //产品分类
    		case 'sell_cat':
    			if($catid>0){
    				$child = GetCatChild($catid);
    				$child = ltrim($child,$catid.',');
    				$table = $CFG['tb_pre'] . 'category';
    				$fields = 'catid,catname,child';
    				$where = '`catid` IN ('.$child.')';
    				if ($child) {
    					$data = Db::select($PDO->pdo, $table, $fields, $where, 'listorder ASC');
    				} else {
    					$data = array();
    					$state = 204;
    					$message = 'fail';
    				}
    			}else{
    				$data = GetCatTop('sell');
    			}
    		break;
    
    		//产品列表
    		case 'sell_list':
    			$table = $CFG['tb_pre'].'sell_5';
    			$fields = 'itemid,company,thumb,introduce,unit,price,title';
    			//$order = 'itemid DESC';
    			$order = GetOrder('sell');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('sell',$mtype,$catid);
    		break;
    
    		//产品搜索
    		case 'sell_search':
    			if($kw){
    				$table = $CFG['tb_pre'] . 'sell_search_5';
    				//$order = 'itemid DESC';
    				$order = GetOrder('sell');
    				$where = '`status`=3 AND content LIKE"%'.$kw.'%"';
    				$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    				$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    				if (!empty($data)) {
    					$ids = '';
    					foreach ($data as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$table = $CFG['tb_pre'] . 'sell_5';
    					$fields = 'itemid,company,thumb,introduce,unit,price,title';
    					$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				} else {
    					$data = array();
    				}
    				$SEO = CreateSeo('sell','search',$catid);
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请输入关键词";
    			}
    		break;
    
    		//产品详情
    		case 'sell_detail':
    			if ($itemid > 0) {
    				$table = $CFG['tb_pre'] . 'sell_5';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'sell_data_5';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('sell','show',$data['catid']);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//商城分类
    		case 'mall_cat':
    			if($catid>0){
    				$child = GetCatChild($catid);
    				$child = ltrim($child,$catid.',');
    				$table = $CFG['tb_pre'] . 'category';
    				$fields = 'catid,catname,child';
    				$where = '`catid` IN ('.$child.')';
    				if ($child) {
    					$data = Db::select($PDO->pdo, $table, $fields, $where, 'listorder ASC');
    				} else {
    					$data = array();
    					$state = 204;
    					$message = 'fail';
    				}
    			}else{
    				$data = GetCatTop('mall');
    			}
    		break;
    
    		//商城列表
    		case 'mall_list':
    			$table = $CFG['tb_pre'].'mall_16';
    			$fields = 'itemid,company,thumb,introduce,unit,price,title';
    			//$order = 'itemid DESC';
    			$order = GetOrder('mall');
    			$where = '`status`=3';
    			$mtype = 'index';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$mtype = 'list';
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('mall',$mtype,$catid);
    		break;
    
    		//商城搜索
    		case 'mall_search':
    			if($kw){
    				$table = $CFG['tb_pre'] . 'mall_16';
    				//$order = 'itemid DESC';
    				$order = GetOrder('mall');
    				$where = '`status`=3 AND title LIKE"%'.$kw.'%"';
    				$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    				$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    				if (!empty($data)) {
    					$ids = '';
    					foreach ($data as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$table = $CFG['tb_pre'] . 'mall_16';
    					$fields = 'itemid,company,thumb,introduce,unit,price,title';
    					$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				} else {
    					$data = array();
    				}
    				$SEO = CreateSeo('mall','search',$catid);
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请输入关键词";
    			}
    		break;
    
    		//商城详情
    		case 'mall_detail':
    			if ($itemid > 0) {
    				$table = $CFG['tb_pre'] . 'mall_16';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'mall_data_16';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('mall','show',$data['catid']);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//相关产品(调用产品分类)
    
    		//商家自定义顶级分类
    		case 'company_mycat_top':
    			if($userid>0){
    				$table = $CFG['tb_pre'].'type';
    				$fields = 'typeid,typename';
    				$where = 'item="product-'.$userid.'"';
    				$order = 'listorder ASC';
    				$data = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    				$conut = Db::find_conut($PDO->pdo,$table,'typeid',$where);
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//随机子分类
    		case 'rand_cat':
    			if($catid>0){
    				$child = GetCatChild($catid);
    				$child = ltrim($child,$catid.',');
    				$table = $CFG['tb_pre'] . 'category';
    				$fields = 'catid,catname,child';
    				$where = '`catid` IN ('.$child.')';
    				if ($child) {
    					$data = Db::select($PDO->pdo, $table, $fields, $where, 'RAND()',4);
    					$conut = Db::find_conut($PDO->pdo,$table,'catid',$where);
    				}else {
    					$data = array();
    					$state = 204;
    					$message = 'fail';
    				}
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//商家列表
    		case 'company_list':
    			$table = $CFG['tb_pre'].'company';
    			$table2 = $CFG['tb_pre'].'setting';
    			$where = '`item` =4 AND item_key="openall"';
    			$data = Db::find($PDO->pdo,$table2,'item_value',$where);
    			$openall = $data['item_value'];
    			$fields = 'userid,username,company,thumb,introduce,business,address';
    			$where = $openall == 1 ? '' : '`validated`=0';
    			$order = GetOrder('company');
    			$data = Db::select($PDO->pdo,$table,'userid',$where,$order,$limit);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['userid'] . ',';
    					//$ids .= $row['username'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'userid IN(' . $ids . ')';
    				//$where = 'username IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('company','list',$data['catid']);
    		break;
    
    		//商家搜索
    		case 'company_search':
    			$table = $CFG['tb_pre'].'company';
    			$fields = 'userid,username,company,thumb,introduce,business,address';
    			$table2 = $CFG['tb_pre'].'setting';
    			$where = '`item` =4 AND item_key="openall"';
    			$data = Db::find($PDO->pdo,$table2,'item_value',$where);
    			$openall = $data['item_value'];
    			//$where = 'company LIKE"%'.$kw.'%" OR keyword LIKE"%'.$kw.'%"';
    			$where = $openall == 1? 'CONCAt(company,keyword) LIKE"%'.$kw.'%"' : '`validated`=1 AND CONCAt(company,keyword) LIKE"%'.$kw.'%"';
    			//$order = 'userid DESC';
    			$order = GetOrder('company');
    			$data = Db::select($PDO->pdo,$table,'userid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'userid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['userid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'userid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('company','search',$data['catid']);
    		break;
    
    		//商家新闻动态
    		case 'company_news':
    			if(!empty($username)){
    				$table = $CFG['tb_pre'] . 'news';
    				$fields = '*';
    				$where = 'username="'.$username.'"';
    				$order = 'itemid DESC';
    				$data = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
    				$conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
    				if (!empty($data)) {
    					$ids = '';
    					foreach ($data as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach($data as $row){
    						$data[$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
    					$table = $CFG['tb_pre'] . 'company';
    					$where = 'username="' . $username . '"';
    					$data2 = Db::find($PDO->pdo, $table, 'company', $where);
    					$title = '新闻动态_' . $data2['company'];
    					$introduce = $data2['company'].'的最新新闻动态';
    					$keyword = '新闻动态,' . $data2['company'];
    					$SEO = array('seo_title' => $title, 'seo_keywords' => $keyword, 'seo_description' => $introduce);
    				} else {
    					$data = array();
    				}
    				//这里用数据库的方式直接调用
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请确保用户名正确";
    			}
    		break;
    
    		//商家信息
    		case 'company_detail':
    			if ($userid > 0) {
    				$table = $CFG['tb_pre'] . 'company';
    				$fields = '*';
    				$where = '`userid`="' . $userid . '"';
    				$data = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'company_data';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('company','show',$catid);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//提交留言板
    		case 'message':
    			if(!empty($_POST)){
    				$name = $_POST['name'];
    				$tel = $_POST['tel'];
    				$title = $_POST['title'];
    				$touser = $_POST['touser'];
    				$content = $_POST['content'];
    				if(!empty($name) && !empty($tel) && !empty($title) && !empty($touser) && !empty($content)){
    					$content .= '
    联系人:'.$name.'
    联系电话:'.$tel;
    					$table = $CFG['tb_pre'] . 'message';
    					$conut = Db::insert( $PDO->pdo, $table, ['title'=>''.$title.'','typeid'=>3,'content'=>''.$content.'','fromuser'=>'','touser'=>''.$touser.'','addtime'=>time(),'ip'=>''.getIP().'','isread'=>0,'issend'=>0,'feedback'=>0,'status'=>3,'groupids'=>''] );
    					if($conut>0){
    						$state = 200;
    						$message = '稍后客服会联系你';
    					}else{
    						$state = 204;
    						$message = 'fail';
    					}
    				}else{
    					$data = array();
    					$state = 204;
    					$message = "数据缺失";
    				}
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "没有提交任何数据";
    			}
    		break;
    
    		//知道列表
    		case 'know_list':
    			$table = $CFG['tb_pre'].'know_10';
    			$fields = 'itemid,title,addition,introduce,thumb,answer,process,passport,catid,addtime';
    			//$order = 'itemid DESC';
    			$order = GetOrder('know');
    			$where = '`status`=3';
    			if($catid>0){
    				$arrchildid = GetCatChild($catid);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    			}
    			$data = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data)) {
    				$ids = '';
    				foreach ($data as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data = Db::select($PDO->pdo, $table, $fields, $where,$order);
    				$i = 0;
    				foreach($data as $row){
    					$data[$i]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
    					$i++;
    				}
    			} else {
    				$data = array();
    			}
    			$SEO = CreateSeo('know','list',$catid);
    		break;
    
    		//知道详情
    		case 'know_detail':
    			if($itemid>0){
    				$table = $CFG['tb_pre'] . 'know_10';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['addtime'] = date("Y-m-d H:i:s",$data['addtime']);
    				$table = $CFG['tb_pre'] . 'know_data_10';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$table = $CFG['tb_pre'] . 'know_answer_10';
    				$order = GetOrder('know');
    				$where = 'qid='.$itemid.' AND `status`=3';
    				$data3 = Db::select($PDO->pdo, $table, 'itemid', $where, $order);
    				$data['answer_list'] = array();
    				if(!empty($data3)){
    					$ids = '';
    					foreach ($data3 as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$data['answer_list'] = Db::select($PDO->pdo, $table, '*', $where,$order);
    					$i = 0;
    					foreach ($data['answer_list'] as $row) {
    						$data['answer_list'][$i]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
    						$i++;
    					}
    				}
    				$table = $CFG['tb_pre'] . 'know_10';
    				$order = 'itemid DESC';
    				$fields = 'itemid,title,addition,introduce,thumb,answer,process,passport,catid,addtime';
    				$where = '`status`=3 AND `itemid`!='.$itemid;
    				$arrchildid = GetCatChild($data['catid']);
    				$where .= $arrchildid ? ' AND catid IN('.$arrchildid.')' : ' AND catid='.$catid;
    				$data['more'] = Db::select($PDO->pdo,$table,$fields,$where,$order,8);
    				$i = 0;
    				foreach ($data['more'] as $row) {
    					$data['more'][$i]['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
    					$i++;
    				}
    				$title = $data['title'];
    				$introduce = $data['introduce'];
    				$keyword = $data['keyword'];
    				$SEO = CreateSeo('know','show',$catid);
    			}else{
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
            break;
            
            //首页合并请求
    		case 'index_all':
    			$table = 'youchuang_banner';
    			$fields = '*';
    			$where = '1';
    			$order = 'weigh DESC';
    			$arr = Db::select($PDO->pdo,$table,$fields,$where,$order);
    			$data['banner'] = array();
    			$i = 0;
    			foreach($arr as $row){
    				$geturl ='http://www.kaotop.com/chuangyou_xcx/public/';
    			$data['banner'][$i]['picture'] =$geturl.$row['image'];
    				$data['banner'][$i]['url'] = $row['url'];
    				$i++;
    			}
    
    			$table = 'youchuang_index_category';
    			$fields = '*';
    			$where = '1';
    			$arr = Db::select($PDO->pdo,$table,$fields,$where,$order);
    			$data['category'] = array();
    			$i = 0;
    			foreach($arr as $row){
    				$data['category'][$i]['icon'] = $seturl.$row['image'];
    				$data['category'][$i]['id'] = $row['url'];
    				$data['category'][$i]['url'] = is_int($row['url']) ? '/pages/goods/list?id='.$row['url'] : $row['url'];
    				$data['category'][$i]['name'] = $row['name'];
    				$i++;
    			}
                
                $table = $CFG['tb_pre'].'brand_13';
    			$fields = 'itemid,title,thumb';
    			$where = '`level`=1';
    			$order = GetOrder('brand');
    			$limit = 6;
                $data['brand'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
                //资讯
                $table = $CFG['tb_pre'].'article_21';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data['article'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach($data['article'] as $row){
    				$data['article'][$i]['addtime'] = date('Y-m-d',$row['addtime']);
    				$i++;
    			}
    			//小学
               $table = $CFG['tb_pre'].'article_23';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data['xiaoxue'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach($data['xiaoxue'] as $row){
    				$data['xiaoxue'][$i]['addtime'] = date('Y-m-d',$row['addtime']);
    				$i++;
    			}
    			//初中
                $table = $CFG['tb_pre'].'article_24';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data['chuzhong'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach($data['chuzhong'] as $row){
    				$data['chuzhong'][$i]['addtime'] = date('Y-m-d',$row['addtime']);
    				$i++;
    			}
    			//高中
                 $table = $CFG['tb_pre'].'article_25';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data['gaozhong'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach($data['gaozhong'] as $row){
    				$data['gaozhong'][$i]['addtime'] = date('Y-m-d',$row['addtime']);
    				$i++;
    			}
    			//会计
                 $table = $CFG['tb_pre'].'article_27';
    			$fields = 'itemid,title,thumb,introduce,addtime';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('article');
    			$limit = 6;
    			$data['kuaiji'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    			$i = 0;
    			foreach($data['kuaiji'] as $row){
    				$data['kuaiji'][$i]['addtime'] = date('Y-m-d',$row['addtime']);
    				$i++;
    			}
    
                $table = $CFG['tb_pre'].'company';
    			$fields = 'userid,username,company,thumb,introduce,business,address';
    			$where = '`level`=1';
    			$order = GetOrder('company');
    			$limit = 6;
                $data['company'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
    
                $table = $CFG['tb_pre'].'sell_5';
    			$fields = 'itemid,company,thumb,introduce,unit,price,title';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('sell');
    			$data2 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data2)) {
    				$ids = '';
    				foreach ($data2 as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data['sell'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data['sell'] = array();
    			}
    
    			$table = $CFG['tb_pre'].'mall_16';
    			$fields = 'itemid,company,thumb,introduce,unit,price,title';
    			$where = '`level`=1 AND `status`=3';
    			$order = GetOrder('sell');
    			$data2 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
    			$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    			if (!empty($data2)) {
    				$ids = '';
    				foreach ($data2 as $row) {
    					$ids .= $row['itemid'] . ',';
    				}
    				$ids = rtrim($ids, ',');
    				$where = 'itemid IN(' . $ids . ')';
    				$data['mall'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    			} else {
    				$data['mall'] = array();
    			}
    
    			$SEO = array();
    			$table = $CFG['tb_pre'] . 'setting';
    			$where = '`item`=1';
    			$arr = Db::select($PDO->pdo, $table, '*', $where);
    			$seo = array();
    			foreach($arr as $row){
    				$seo[''.$row["item_key"].''] = $row['item_value'];
    			}
    			$SEO['seo_title'] = $seo['seo_title'];
    			$SEO['seo_keywords'] = $seo['seo_keywords'];
    			$SEO['seo_description'] = $seo['seo_description'];
            break;
    
            
            //产品详情集合
            case 'sell_detail_all':
                if ($itemid > 0) {
    				$table = $CFG['tb_pre'] . 'sell_5';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data['detail'] = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'sell_data_5';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
    				$data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$data['detail']['thumb'] = str_replace('.thumb.jpg','',$data['detail']['thumb']);
    				$data['detail']['thumb1'] = str_replace('.thumb.jpg','',$data['detail']['thumb1']);
    				$data['detail']['thumb2'] = str_replace('.thumb.jpg','',$data['detail']['thumb2']);
                    $username = $data['detail']['username'];
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'company';
                    $data3 = Db::find($PDO->pdo,$table,'userid','username="'.$username.'"');
    				$userid = $data3['userid'];
    				$data['detail']['userid'] = $userid;
                    $table = $CFG['tb_pre'].'type';
    				$fields = 'typeid,typename';
    				$where = 'item="product-'.$userid.'"';
    				$order = 'typeid ASC';
    				$data['mycat_top'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
                    $conut = Db::find_conut($PDO->pdo,$table,'typeid',$where);
                    $child = GetCatChild($catid);
    				$child = ltrim($child,$catid.',');
    				$table = $CFG['tb_pre'] . 'category';
    				$fields = 'catid,catname,child';
    				$where = '`catid` IN ('.$child.')';
    				if ($child) {
    					$data['rand_cat'] = Db::select($PDO->pdo, $table, $fields, $where, 'RAND()',4);
    					$conut = Db::find_conut($PDO->pdo,$table,'catid',$where);
    				}else {
    					$data['rand_cat'] = array();
    				}
    				$table = $CFG['tb_pre'] . 'sell_5';
    				$fields = 'itemid,company,thumb,introduce,unit,price,title';
    				$order = 'itemid DESC';
    				$where = '`status`=3';
    				if ($catid > 0) {
    					$arrchildid = GetCatChild($catid);
    					$where .= $arrchildid ? ' AND catid IN(' . $arrchildid . ')' : ' AND catid='.$catid;
    				}
    				$data2 = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
    				$conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
    				if (!empty($data)) {
    					$ids = '';
    					foreach ($data2 as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where, $order);
    				} else {
    					$data['more'] = array();
    				}
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('sell','show',$catid);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    		
    		//商品详情集合
            case 'mall_detail_all':
                if ($itemid > 0) {
    				$table = $CFG['tb_pre'] . 'mall_16';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data['detail'] = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'mall_data_16';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $username = $data['detail']['username'];
                    $catid = $data['detail']['catid'];
                    $table = $CFG['tb_pre'].'company';
                    $data3 = Db::find($PDO->pdo,$table,'userid','username="'.$username.'"');
    				$username= $data3['username'];
    				$data['detail']['username'] = $username;
                    $table = $CFG['tb_pre'].'type';
    				$fields = 'typeid,typename';
    				$where = 'item="product-'.$userid.'"';
    				$order = 'typeid ASC';
    				$data['mycat_top'] = Db::select($PDO->pdo,$table,$fields,$where,$order,$limit);
                    $conut = Db::find_conut($PDO->pdo,$table,'typeid',$where);
                    $child = GetCatChild($catid);
    				$child = ltrim($child,$catid.',');
    				$table = $CFG['tb_pre'] . 'category';
    				$fields = 'catid,catname,child';
    				$where = '`catid` IN ('.$child.')';
    				if ($child) {
    					$data['rand_cat'] = Db::select($PDO->pdo, $table, $fields, $where, 'RAND()',4);
    					$conut = Db::find_conut($PDO->pdo,$table,'catid',$where);
    				}else {
    					$data['rand_cat'] = array();
    				}
    				$table = $CFG['tb_pre'] . 'mall_16';
    				$fields = 'itemid,company,thumb,introduce,unit,price,title';
    				$order = 'itemid DESC';
    				$where = '`status`=3';
    				if ($catid > 0) {
    					$arrchildid = GetCatChild($catid);
    					$where .= $arrchildid ? ' AND catid IN(' . $arrchildid . ')' : ' AND catid='.$catid;
    				}
    				$data2 = Db::select($PDO->pdo, $table, 'itemid', $where, $order, $limit);
    				$conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
    				if (!empty($data)) {
    					$ids = '';
    					foreach ($data2 as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where, $order);
    				} else {
    					$data['more'] = array();
    				}
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('mall','show',$catid);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
            break;
            
            //商家首页集合
            case 'company_index_all':
                if ($userid > 0) {
    				$table = $CFG['tb_pre'] . 'company';
    				$fields = '*';
    				$where = '`userid`="' . $userid . '"';
                    $data['detail'] = Db::find($PDO->pdo, $table, $fields, $where);
                    $username = $data['detail']['username'];
    				$table = $CFG['tb_pre'] . 'company_data';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
                    $data['detail']['content'] = stripslashes(html_entity_decode($data2['content']));
                    $table = $CFG['tb_pre'] . 'news';
    				$fields = '*';
    				$where = 'username="'.$username.'"';
    				$order = 'itemid DESC';
    				$data3 = Db::select($PDO->pdo, $table, 'itemid', $where, $order, 10);
    				$conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
    				if (!empty($data3)) {
    					$ids = '';
    					foreach ($data3 as $row) {
    						$ids .= $row['itemid'] . ',';
    					}
    					$ids = rtrim($ids, ',');
    					$where = 'itemid IN(' . $ids . ')';
    					$data['news'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach($data['news'] as $row){
    						$data['news'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
    				} else {
    					$data['news'] = array();
                    }
                    $table = $CFG['tb_pre'] . 'sell_5';
                    $fields = 'itemid,company,thumb,introduce,unit,price';
                    $order = 'itemid DESC';
                    $where = '`username`="'.$username.'" AND `status`=3';
                    $data3 = Db::select($PDO->pdo, $table, 'itemid', $where, $order, 10);
                    $conut = Db::find_conut($PDO->pdo, $table, 'itemid', $where);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
                        $data['sell'] = Db::select($PDO->pdo, $table, $fields, $where, $order);
                    } else {
                        $data['sell'] = array();
    				}
    				$title = $data['detail']['company'];
    				$introduce = !empty($data['detail']['introduce']) ? mb_strcut($data['detail']['introduce'],100,'utf-8') : '';
    				$keyword = $data['detail']['keyword'];
    				$SEO = array('seo_title'=>$title,'seo_keywords'=>$keyword,'seo_description'=>$introduce);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//品牌详情集合
            case 'brand_detail_all':
                if ($itemid > 0) {
    				$table = $CFG['tb_pre'] . 'brand_13';
    				$fields = '*';
    				$where = '`itemid`="' . $itemid . '"';
    				$data['detail'] = Db::find($PDO->pdo, $table, $fields, $where);
    				$table = $CFG['tb_pre'] . 'brand_data_13';
    				$fields = 'content';
    				$data2 = Db::find($PDO->pdo, $table, $fields, $where);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['introduce'];
    				$keyword = $data['detail']['keyword'];
    				$SEO = CreateSeo('brand','show',$catid);
    			} else {
    				$data = array();
    				$state = 204;
    				$message = "请确保ID正确";
    			}
    		break;
    
    		//新闻内容集合
            case 'news_detail_all':
    			$table = $CFG['tb_pre'].'news';
    			$fields = '*';
    			$where = '`itemid`="'.$itemid.'"';
    			if($itemid>0){
    				$data['detail'] = Db::find($PDO->pdo,$table,$fields,$where);
    				$table = $CFG['tb_pre'] . 'news_data';
    				$fields = 'content';
    				$where = '`itemid`="' . $itemid . '"';
    				$data2 = Db::find($PDO->pdo,$table,$fields,$where);
    				$data['detail']['addtime'] = date("Y-m-d H:i:s",$data['detail']['addtime']);
                    $data['detail']['content'] = KillStyle(stripslashes(html_entity_decode($data2['content'])));
                    $fields = '*';
                    $order = 'itemid DESC';
                    $where = '`status`=3';
                    $username = $data['detail']['username'];
                    $table = $CFG['tb_pre'].'news';
    				$where .= $username ? ' AND username="'.$username.'" AND `itemid`!="'.$itemid.'"' : '';
                    $conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
                    $limit = rand(0,$conut).',10';
                    $data3 = Db::select($PDO->pdo,$table,'itemid',$where,$order,$limit);
                    if (!empty($data3)) {
                        $ids = '';
                        foreach ($data3 as $row) {
                            $ids .= $row['itemid'] . ',';
                        }
                        $ids = rtrim($ids, ',');
                        $where = 'itemid IN(' . $ids . ')';
    					$data['more'] = Db::select($PDO->pdo, $table, $fields, $where,$order);
    					$i = 0;
    					foreach ($data['more'] as $row) {
    						$data['more'][$i]['addtime'] = date('Y-m-d', $row['addtime']);
    						$i++;
    					}
                    } else {
                        $data['more'] = array();
    				}
    				$table = $CFG['tb_pre'].'company';
    				$where = 'username="'.$username.'"';
    				$data2 = Db::find($PDO->pdo,$table,'company',$where);
                    // $data['rand_keyword'] = RandKeyword('news',10);
    				// $data['cat'] = GetCatTop('news');
    				$title = $data['detail']['title'];
    				$introduce = $data['detail']['content'];
    				$keyword = $title.','.$data2['company'];
    				$SEO = array('seo_title'=>$title,'seo_keywords'=>$keyword,'seo_description'=>$introduce);
    			}else{
    				$data = array();
    				$state = 403;
    				$message = "请输入正确的资讯ID";
    			}
            break;
    		
    		default:
    		$data = array('state'=>404,'message'=>'找不到这个模块,请矫正!');
    		die(json_encode($data));
    		break;
    	}
    	$seo_title = $SEO['seo_title'];
    	$seo_keywords = $SEO['seo_keywords'];
    	$seo_description = $SEO['seo_description'];
    	$new_data = array();
    	$seo = array();
    	$seo['seo_title'] = $seo_title;
    	$seo['seo_keywords'] = $seo_keywords;
    	$seo['seo_description'] = $seo_description;
    	$new_data['data'] = $data;
    	$new_data['seo'] = $seo;
    	$new_data['state'] = $state;
    	$new_data['message'] = $message;
    	$new_data['page'] = $page;
    	$new_data['pagesize'] = $pageSize;
    	$new_data['conut'] = $conut;
    	echo json_encode($new_data);
    	$cache->caching();
    }else{
    	die('找不到模块');
    }
    
    
    function GetCatTop($module)
    {
    	global $PDO,$CFG;
    	$table = $CFG['tb_pre'] . 'module';
    	$fields = 'moduleid';
    	$where = '`module`="'.$module.'"';
    	$data = Db::find($PDO->pdo,$table,$fields,$where);
    	$moduleid = $data['moduleid'];
    	$table = $CFG['tb_pre'] . 'category';
    	$fields = 'catid,catname';
    	$where = '`moduleid`="'.$moduleid.'" AND `parentid`=0';
    	$data = Db::select($PDO->pdo,$table,$fields,$where,'listorder ASC');
    	return $data;
    }
    
    
    function GetCatChild($catid)
    {
    	global $PDO,$CFG;
    	$table = $CFG['tb_pre'] . 'category';
    	$fields = 'arrchildid';
    	$where = '`catid`="'.$catid.'"';
    	$data = Db::find($PDO->pdo,$table,$fields,$where);
    	return $data['arrchildid'];
    }
    
    
    function RandKeyword($module,$num)
    {
    	global $PDO,$CFG;
    	$table = $CFG['tb_pre'] . 'module';
    	$fields = 'moduleid';
    	$where = '`module`="'.$module.'"';
    	$data = Db::find($PDO->pdo,$table,$fields,$where);
    	$moduleid = $data['moduleid'];
    	$table = $CFG['tb_pre'] . 'keyword';
    	$fields = 'keyword,word';
    	$where = '`moduleid`="'.$moduleid.'" AND `status`=3';
    	$conut = Db::find_conut($PDO->pdo,$table,'itemid',$where);
    	$limit = rand(0,$conut).','.$num;
    	$data = Db::select($PDO->pdo,$table,$fields,$where,'itemid DESC',$limit);
    	return $data;
    }
    
    
    function GetOrder($module)
    {
    	global $PDO,$CFG;
    	$table = $CFG['tb_pre'] . 'module';
    	$fields = 'moduleid';
    	$where = '`module`="' . $module . '"';
    	$data = Db::find($PDO->pdo, $table, $fields, $where);
    	$moduleid = $data['moduleid'];
    	$table = $CFG['tb_pre'] . 'setting';
    	$where = '`item`=' . $moduleid.' AND `item_key`="order"';
    	$data = Db::find($PDO->pdo, $table, 'item_value', $where);
    	return $data['item_value'];
    }
    
    
    function GetConfig()
    {
    	global $PDO, $CFG;
    	$table = 'youchuang_setting';
    	$fields = '*';
    	$where = '1';
    	$arr = Db::find($PDO->pdo, $table, $fields, $where);
    	$data = array(		'site_name' => $arr['name'],		'app_id' => $arr['appid'],		'app_key' => $arr['appkey'],		'app_secret' => $arr['appsecret'],		'cache' => $arr['cache']
    	);
    	return $data;
    }
    
    //获取来访IP
    function getIP()
    {
        static $realip;
        if (isset($_SERVER)){
            if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
                $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
            } else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
                $realip = $_SERVER["HTTP_CLIENT_IP"];
            } else {
                $realip = $_SERVER["REMOTE_ADDR"];
            }
        } else {
            if (getenv("HTTP_X_FORWARDED_FOR")){
                $realip = getenv("HTTP_X_FORWARDED_FOR");
            } else if (getenv("HTTP_CLIENT_IP")) {
                $realip = getenv("HTTP_CLIENT_IP");
            } else {
                $realip = getenv("REMOTE_ADDR");
            } 
        }
    	$arr = explode(',',$realip);
    	$realip = $arr[0];
        return $realip;
    }
    
    
    function CreateSeo($module,$seo_file,$catid)
    {
    	global $PDO,$CFG, $L,$introduce,$title,$keyword,$kw,$page;
    	$table = $CFG['tb_pre'] . 'module';
    	$fields = '*';
    	$where = '`module`="' . $module . '"';
    	$data = Db::find($PDO->pdo, $table, $fields, $where);
    	$moduleid = $data['moduleid'];
    	$table = $CFG['tb_pre'] . 'setting';
    	$where = '`item`=1';
    	$DTL = Db::select($PDO->pdo, $table, '*', $where);
    	$DT = array();
    	foreach($DTL as $row){
    		$DT[''.$row["item_key"].''] = $row['item_value'];
    	}
    	
    	$MOD = include './../file/cache/module-'.$moduleid.'.php';
    	$seo_modulename = $MOD['name'];
    	$seo_sitename = $city_sitename ? $city_sitename : $DT['sitename'];
    	$seo_sitetitle = $DT['seo_title'];
    	$seo_sitekeywords = $DT['seo_keywords'];
    	$seo_sitedescription = $DT['seo_description'];
    	$seo_delimiter = $DT['seo_delimiter'];
    	$seo_page = $page > 1 ? lang($L['seo_page'], array($page)) . $seo_delimiter : ''; //解决了
    	$seo_catname = $seo_cattitle = $seo_parentname = $seo_catkeywords = $seo_catdescription = '';
    	if ($catid) {
    		$table = $CFG['tb_pre'] . 'category';
    		$fields = '*';
    		$where = '`catid`="' . $catid . '"';
    		$CAT = Db::find($PDO->pdo, $table, $fields, $where);
    		if ($CAT['parentid']) {
    			//如果发现是有上级分类就把所有上级分类找出来
    			$seo_catname = '';
    			$tmp = strip_tags(cat_pos2($CAT, 'DESTOON'));
    			$tmp = explode('DESTOON', $tmp);
    			$tmp = array_reverse($tmp);
    			foreach ($tmp as $k => $v) {
    				$seo_catname .= $v . $seo_delimiter;
    			}
    		} else {
    			$seo_catname = $CAT['catname'] . $seo_delimiter;
    		}
    		$seo_cattitle = $CAT['seo_title'] ? $CAT['seo_title'] . $seo_delimiter : $seo_catname;
    		$seo_catkeywords = $CAT['seo_keywords'] ? $CAT['seo_keywords'] : '';
    		$seo_catdescription = $CAT['seo_description'] ? $CAT['seo_description'] : '';
    	}
    	$seo_areaname = (isset($areaid) && $areaid) ? area_pos2($areaid, $seo_delimiter) . $seo_delimiter : '';
    	$seo_showtitle = isset($title) ? $title : '';
    	$seo_showintroduce = isset($introduce) ? $introduce : '';
    	switch ($seo_file) {
    		case 'index':
    			if ($MOD['title_index']) {
    				eval("$seo_title = "$MOD[title_index]";");
    			} else {
    				$seo_title = $seo_modulename . $seo_delimiter . $seo_sitename;
    			}
    			if ($MOD['keywords_index']) eval("$head_keywords = "$MOD[keywords_index]";");
    			if ($MOD['description_index']) eval("$head_description = "$MOD[description_index]";");
    			break;
    		case 'list':
    			if ($CAT['seo_title']) {
    				$seo_title = $CAT['seo_title'];
    			} else if ($MOD['title_list']) {
    				eval("$seo_title = "$MOD[title_list]";");
    			} else {
    				$seo_title = $seo_cattitle . $seo_page . $seo_modulename . $seo_delimiter . $seo_sitename;
    			}
    			$_seo_catname = $seo_catname;
    			$_seo_areaname = $seo_areaname;
    			if ($CAT['seo_keywords']) {
    				$head_keywords = $CAT['seo_keywords'];
    			} else if ($MOD['keywords_list']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ',', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ',', $_seo_areaname);
    				eval("$head_keywords = "$MOD[keywords_list]";");
    			}
    			if ($CAT['seo_description']) {
    				$head_description = $CAT['seo_description'];
    			} else if ($MOD['description_list']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ' ', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ' ', $_seo_areaname);
    				eval("$head_description = "$MOD[description_list]";");
    			}
    			break;
    		case 'show':
    			if ($MOD['title_show']) {
    				eval("$seo_title = "$MOD[title_show]";");
    			} else {
    				$seo_title = $seo_showtitle . $seo_delimiter . $seo_catname . $seo_modulename . $seo_delimiter . $seo_sitename;
    			}
    			$_seo_catname = $seo_catname;
    			$_seo_areaname = $seo_areaname;
    			if ($MOD['keywords_show']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ',', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ',', $_seo_areaname);
    				eval("$head_keywords = "$MOD[keywords_show]";");
    			} else {
    				$head_keywords = $keyword;
    			}
    			if ($MOD['description_show']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ' ', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ' ', $_seo_areaname);
    				eval("$head_description = "$MOD[description_show]";");
    			} else {
    				$head_description = $introduce ? $introduce : $title;
    			}
    			break;
    		case 'search':
    			if ($MOD['title_search']) {
    				$seo_kw = $kw ? $kw . $seo_delimiter : '';
    				eval("$seo_title = "$MOD[title_search]";");
    			} else {
    				$seo_title = $seo_modulename . $L['search'] . $seo_delimiter . $seo_page . $seo_sitename;
    				if ($catid) $seo_title = $seo_catname . $seo_title;
    				if ($areaid) $seo_title = $seo_areaname . $seo_title;
    				if ($kw) $seo_title = $kw . $seo_delimiter . $seo_title;
    			}
    			$_seo_catname = $seo_catname;
    			$_seo_areaname = $seo_areaname;
    			if ($MOD['keywords_search']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ',', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ',', $_seo_areaname);
    				$seo_kw = $kw ? $kw . ',' : '';
    				eval("$head_keywords = "$MOD[keywords_search]";");
    			}
    			if ($MOD['description_search']) {
    				if ($_seo_catname) $seo_catname = str_replace($seo_delimiter, ' ', $_seo_catname);
    				if ($_seo_areaname) $seo_areaname = str_replace($seo_delimiter, ' ', $_seo_areaname);
    				$seo_kw = $kw ? $kw : '';
    				eval("$head_description = "$MOD[description_search]";");
    			}
    			break;
    		default:
    			break;
    	}
    	$seo = array();
    	$seo['seo_title'] = $seo_title;
    	$seo['seo_keywords'] = $head_keywords;
    	$seo['seo_description'] = $head_description;
    	return $seo;
    }
    
    function cat_pos2($CAT, $str = ' » ', $target = '', $deep = 0, $start = 0) {
    	global $PDO, $CFG;
    	if(!$CAT) return '';
    	$table = $CFG['tb_pre'] . 'module';
    	$fields = '*';
    	$where = '1';
    	$data = Db::select($PDO->pdo, $table, $fields, $where);
    	$MODULE = array();
    	foreach($data as $row){
    		$MODULE[$row['moduleid']] = $row;
    	}
    	$arrparentids = $CAT['arrparentid'].','.$CAT['catid'];
    	$arrparentid = explode(',', $arrparentids);
    	$pos = '';
    	$target = $target ? ' target="_blank"' : '';	
    	$CATEGORY = array();
    	$table = $CFG['tb_pre'] . 'category';
    	$fields = 'catid,moduleid,catname,linkurl';
    	$where = 'catid IN ('.$arrparentids.')';
    	$result = Db::select($PDO->pdo, $table, $fields, $where);
    	foreach($result as $r) {
    		$CATEGORY[$r['catid']] = $r;
    	}
    	if($deep) $i = 1;
    	$j = 0;
    	foreach($arrparentid as $catid) {
    		if(!$catid || !isset($CATEGORY[$catid])) continue;
    		if($j++ < $start) continue;
    		if($deep) {
    			if($i > $deep) continue;
    			$i++;
    		}
    		$pos .= '<a href="'.$MODULE[$CATEGORY[$catid]['moduleid']]['linkurl'].$CATEGORY[$catid]['linkurl'].'"'.$target.'>'.$CATEGORY[$catid]['catname'].''.$str;
    	}
    	$_len = strlen($str);
    	if($str && substr($pos, -$_len, $_len) === $str) $pos = substr($pos, 0, strlen($pos) - $_len);
    	return $pos;
    }
    
    
    function encode_pass($tex, $key, $type = "encode")
    {
    	$chrArr = array(		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',		'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',		'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
    	);
    	if ($type == "decode") {
    		if (strlen($tex) < 14) return false;
    		$verity_str = substr($tex, 0, 8);
    		$tex = substr($tex, 8);
    		if ($verity_str != substr(md5($tex), 0, 8)) {
    			//完整性验证失败
    			return false;
    		}
    	}
    	$key_b = $type == "decode" ? substr($tex, 0, 6) : $chrArr[rand() % 62] . $chrArr[rand() % 62] . $chrArr[rand() % 62] . $chrArr[rand() % 62] . $chrArr[rand() % 62] . $chrArr[rand() % 62];
    	$rand_key = $key_b . $key;
    	$rand_key = md5($rand_key);
    	$tex = $type == "decode" ? base64_decode(substr($tex, 6)) : $tex;
    	$texlen = strlen($tex);
    	$reslutstr = "";
    	for ($i = 0; $i < $texlen; $i++) {
    		$reslutstr .= $tex{
    		$i} ^ $rand_key{
    		$i % 32};
    	}
    	if ($type != "decode") {
    		$reslutstr = trim($key_b . base64_encode($reslutstr), "==");
    		$reslutstr = substr(md5($reslutstr), 0, 8) . $reslutstr;
    	}
    	return $reslutstr;
    }
    
    if (!function_exists("file_put_contents")) { 
    
        function file_put_contents($n, $d, $flag = false) { 
            $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w'; 
            $f = @fopen($n, $mode); 
            if ($f === false) { 
                return 0; 
            } else { 
                if (is_array($d)) $d = implode($d); 
                $bytes_written = fwrite($f, $d); 
                fclose($f); 
                return $bytes_written; 
            } 
        } 
    
    } 
    function KillStyle($content)
    {
    //$content = preg_replace("/STYLE=.+?['|"]/i",'',$content);//去除样式 
    $content = preg_replace("/style=.+?['|"]/i",'',$content);//去除样式
    $content = preg_replace("/class=.+?['|"]/i",'',$content);//去除样式
    $content = preg_replace("/id=.+?['|"]/i",'',$content);//去除样式
    $content = preg_replace("/<(script.*?)>(.*?)<(/script.*?)>/si","",$content); //过滤script标签
    return $content;
    }
    

      演示小程序:

     

    文章转自:thinkphp百度小程序打造的接口api - 考高分网 (kaotop.com)

    千行代码,Bug何处藏。 纵使上线又怎样,朝令改,夕断肠。
  • 相关阅读:
    5-2 bash 脚本编程之一 变量、变量类型等
    4-4 grep及正则表达式
    4-3 管理及IO重定向
    4-2 权限及权限管理
    CentOS7 发布 ASP.NET MVC 4 --- mono 4.6.0 + jexus 5.8.1
    CentOS7 安装 nginx
    Hibernate学习笔记--------4.查询
    Hibernate学习笔记--------3.缓存
    Hibernate学习笔记--------2.一多|多多的CRUD
    Hibernate学习笔记--------1.单表操作
  • 原文地址:https://www.cnblogs.com/68xi/p/15456961.html
Copyright © 2020-2023  润新知