121 lines
4.2 KiB
PHP
121 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace web\ambap;
|
|
|
|
class index {
|
|
public static function json_init() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$ret['once'] = array();
|
|
$csql = new \ciy\sql('ap_banner');
|
|
$csql->where('groupcode', 'index');
|
|
$row = $db->get($csql);
|
|
$ret['once']['banner'] = $row;
|
|
$csql = new \ciy\sql('demo_normal');
|
|
$csql->order('id desc');
|
|
$csql->limit(1, 8);
|
|
$rows = $db->get($csql);
|
|
$ret['demos'] = $rows;
|
|
$ret['zc_menu'] = getrelation($db, $rows, 'zc_menu', 'menuid', 'id,name');
|
|
$ret['sharename'] = '分享主标题,千人千面';
|
|
return succjson($ret);
|
|
}
|
|
public static function json_paper() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$id = $post->getint('id');
|
|
$csql = new \ciy\sql('ap_paper');
|
|
$csql->where('id', $id);
|
|
$artrow = $db->getone($csql);
|
|
if (!is_array($artrow))
|
|
return errjson('文章不存在' . $id);
|
|
$ret = array('data' => $artrow);
|
|
$updata = array();
|
|
$updata['readcnt'] = array('readcnt+1');
|
|
$csql = new \ciy\sql('ap_paper');
|
|
$csql->where('id', $id);
|
|
$db->update($csql, $updata);
|
|
return succjson($ret);
|
|
}
|
|
public static function json_section_get() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$sectionid = $post->getint('id');
|
|
$csql = new \ciy\sql('ap_art_section');
|
|
$csql->where('id', $sectionid);
|
|
$sectionrow = $db->getone($csql);
|
|
if (!is_array($sectionrow))
|
|
return errjson('板块不存在' . $sectionid);
|
|
$query = $post->get('query');
|
|
$csql = new \ciy\sql('ap_art_post');
|
|
$csql->where('sectionid', $sectionid);
|
|
$csql->where('artstatus', 100);
|
|
$csql->where('name like', objstr($query, 'key'));
|
|
$csql->column('id,name,img,descs');
|
|
$csql->order('artsort desc, id desc');
|
|
$pageno = $post->getint('pageno', 1);
|
|
$pagecount = $post->getint('pagecount', 10);
|
|
$csql->limit($pageno, $pagecount);
|
|
$rows = $db->get($csql);
|
|
$ret = array('pageno' => $pageno, 'pagecount' => $pagecount, 'list' => $rows);
|
|
if ($post->getbool('once')) {
|
|
$ret['once'] = array();
|
|
$ret['once']['section'] = $sectionrow;
|
|
}
|
|
return succjson($ret);
|
|
}
|
|
public static function json_art_read() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$id = $post->getint('id');
|
|
$csql = new \ciy\sql('ap_art_post');
|
|
$csql->where('id', $id);
|
|
$artrow = $db->getone($csql);
|
|
if (!is_array($artrow))
|
|
return errjson('文章不存在' . $id);
|
|
$sectionid = $artrow['sectionid'];
|
|
$csql = new \ciy\sql('ap_art_section');
|
|
$csql->where('id', $sectionid);
|
|
$sectionrow = $db->getone($csql);
|
|
if (!is_array($sectionrow))
|
|
return errjson('板块不存在' . $sectionid);
|
|
$ret['data'] = $artrow;
|
|
$ret['section'] = $sectionrow;
|
|
$updata = array();
|
|
$updata['readcnt'] = array('readcnt+1');
|
|
$csql = new \ciy\sql('ap_art_post');
|
|
$csql->where('id', $id);
|
|
$db->update($csql, $updata);
|
|
return succjson($ret);
|
|
}
|
|
public static function json_art_hot() {
|
|
global $db;
|
|
$post = new \ciy\post();
|
|
$id = $post->getint('id');
|
|
$sec = $post->getint('sec');
|
|
$updata = array();
|
|
$updata['studycnt'] = array('studycnt+1');
|
|
$csql = new \ciy\sql('ap_art_post');
|
|
$csql->where('id', $id);
|
|
$db->update($csql, $updata);
|
|
return succjson();
|
|
}
|
|
public static function json_art_vent() {
|
|
global $db;
|
|
$rsuser = verifyfast();
|
|
$post = new \ciy\post();
|
|
$id = $post->getint('id');
|
|
$sectionid = $post->getint('sectionid');
|
|
$content = $post->get('content');
|
|
$updata = array();
|
|
$updata['artid'] = $id;
|
|
$updata['sectionid'] = $sectionid;
|
|
$updata['content'] = $content;
|
|
$updata['pubtimes'] = time();
|
|
$updata['audituser'] = 0;
|
|
$updata['vuser'] = $rsuser['id'];
|
|
$csql = new \ciy\sql('ap_art_vent');
|
|
$db->insert($csql, $updata);
|
|
return succjson();
|
|
}
|
|
} |