<?php
/**
* Created by sjmoban.com 老李.
* Date: 2018/1/29 0029
* Time: 下午 12:08
* E-mail: sjmoban@163.com
* QQ: 79089679
*/
require('../../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../../class/db_sql.php'); //引入数据库操作文件
require('../../data/dbcache/class.php'); //引入栏目缓存文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
class lsk{
public static function cat_getlist($ta=array()){
//传递过来的参数有pid,page但仿头条,直接读取所有类即可。只有一级分类,
global $class_r;
$rows=array();
foreach($class_r as $kk=>$row){
$ta['id']=$row['classid'];
$ta['title']=$row['classname'];
$ta['page']=0;
array_push($rows,$ta);
}
return array('status'=>'success','msg'=>'success','rows'=>$rows);
}
public static function news_getlist($ta=array()){
global $class_r,$dbtbpre,$empire;
$cid=$ta['cid'];
$tbname=$class_r[$cid]['tbname'];
$mid=$class_r[$cid]['modid'];
$page=$ta['page'];
$page=empty($page)?1:intval($page);
$add='';
if($class_r[$cid]['islast'])//终极栏目
{
$add.="classid='$cid'";
}
else
{
$add.=ReturnClass($class_r[$cid][sonclass]);
}
$perpage=25;
// $perpage=$class_r[$cid]['lencord'];//每页显示记录数
$offset=($page-1)*$perpage;
$sqlstr="select id,titlepic,title from {$dbtbpre}ecms_".$tbname.' where '.$add.' limit '.$offset.','.$perpage;
// $sqlstr="select ".ReturnSqlListF($mid)." from {$dbtbpre}ecms_".$tbname.' where '.$add.' limit 10';
$query=$empire->query($sqlstr);
$rows=array();
while($row=$empire->fetch($query)){
$row['page']=0;
$row['pictype']=1;
if(empty($row['titlepic'])){
$row['pictype']=0;
}else{
$row['picurl']=self::picurl($row['titlepic']);
}
$row['cid']=$cid;
$row['title']=stripSlashes($row['title']);
$row['clicks']=0;
array_push($rows,$row);
}
if(empty($rows)){
return array('status'=>'failed','msg'=>'没有数据了!');
}
return array('status'=>'success','msg'=>'success','rows'=>$rows,'page'=>$page,'picurl'=>self::picurl('dsfsdfsd'));
}
public static function news_getinfo($ta=array()){
global $class_r,$empire,$dbtbpre;
$id=intval($ta['id']);
$cid=intval($ta['cid']);
$tbname=$class_r[$cid]['tbname'];
$mid=$class_r[$cid]['modid'];
$sqlstr1="select * from {$dbtbpre}ecms_".$tbname." where id='$id'";
$row=$empire->fetch1($sqlstr1);
$sqlstr2="select ".ReturnSqlFtextF($mid)." from {$dbtbpre}ecms_".$tbname."_data_".$row['stb']." where id='$row[id]' limit 1";
$addr=$empire->fetch1($sqlstr2);
$row=array_merge($row,$addr);
if(!empty($ta['debug'])){
print_r($row);
}
$row['content_json']=stripSlashes(html_entity_decode(str_replace('&', "&",$row['newstext'])));
// $row['content_json']=$row['newstext'];
$imglist=array();
$row['title']=stripSlashes($row['title']);
$ra=array(
'content_json'=>$row['content_json'],
'id'=>$row['id'],
'title'=>$row['title']
);
return array('status'=>'success','msg'=>'success','row'=>$ra,'imglist'=>$imglist);
}
public static function picurl($picurl=''){
$picurl=ltrim($picurl,'/');
if(stripos($picurl,'http')===false){//即没找到
$picurl=$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].'/'.$picurl;
return $picurl;
}else{
return $picurl;
}
}
}
/*
db_close(); //关闭MYSQL链接
$empire=null; //注消操作类变量*/
?>