discuz论坛门户资讯入库接口【原创】
最近想打造一个社区门户站点,所以写了这个入库接口,可以对接数据入库。
<?php
/*
* Discuz x3.2 门户免登陆发布接口
* 2018-08-10
* Copyright 68xi.Ltd
* Author: 68xi
*
* 获取栏目列表: /jiekou_portal.php?get_cat=true&password=PWD
*
* 发布参数: (说明: 参数前面带 "*" 的为必填参数)
* *uid: 发布用户ID, 可单个, 也可多个, 多个发布用户ID之间请使用逗号(,)分割 (当填写多个用户ID, 接口会随机使用其中一个, 发布用户ID必须是系统已存在的用户ID)
* *catid: 栏目ID
* *title: 标题
* *content: 内容
* dateline: 发布时间, 默认当前时间, 格式: 2013-11-15 15:30:11
* summary: 内容摘要, 此参数为空时, 将使用discuz内部提取正文方式来获取摘要
* author: 原作者
* from: 来源
* fromurl: 来源网址
* viewnum: 文章阅读数字, 默认1
* setconver: 提取内容里的第一张图片为封面, 无论是本地图片还是网络图片, 都会尝试提取
*/ header('Content-type:text/html;charset=UTF-8'); //接口密码, 请保持与采集器上设置的密码一致, 为了网站安全, 强烈建议修改此值!!!
define('PASSWORD', '123456'); //调试模式, 上线后务必设置成false!!!
define('DEBUG', false); //输出信息并退出
function showMsg($msg) {
echo $msg;
exit;
} //打印变量信息 - 用于DEBUG
function dd($data, $exit = false) {
echo '<pre>';
print_r($data);
echo '</pre>';
if($exit) exit;
} //检测接口密码
if(!isset($_GET['password']) || $_GET['password'] != PASSWORD) showMsg('接口密码不正确!'); /******************* discuz头文件 开始 ********************/ #/portal.php
define('APPTYPEID', 4);
define('CURSCRIPT', 'portal'); require './source/class/class_core.php';
$discuz = C::app(); $cachelist = array('userapp', 'portalcategory', 'diytemplatenameportal');
$discuz->cachelist = $cachelist;
$discuz->init(); require DISCUZ_ROOT.'./source/function/function_home.php';
require DISCUZ_ROOT.'./source/function/function_portal.php'; define('CURMODULE', 'portalcp'); #/souce/module/portal/portalportalcp.php
$ac = 'article'; require_once libfile('function/portalcp'); #/source/include/portalcp/portalcp_article.php /******************* discuz头文件 结束 ********************/ $app = new App(); class App {
protected $global; //equal $_G
protected $uid; //发布用户ID //构造函数
public function __construct() {
global $_G;
$this->global = &$_G; //当前时间
define('DATE_TIME', date('Y-m-d H:i:s')); if(isset($_GET['get_cat']) && $_GET['get_cat'] == 'true') {
$this->get_cat(); //获取栏目
} else {
$this->publish_content(); //发布内容
}
} //获取栏目
protected function get_cat() {
$cat = $this->get_cat_list();
if(empty($cat)) showMsg('当前网站栏目为空, 请添加门户栏目后再重试'); $catStr = '';
foreach($cat as $key => $value) {
$catStr .= '<option value="'. $value['catid'] .'">'. $value['catname'] .'</option>';
}
$catStr = '<select>'. $catStr .'</select>';
showMsg($catStr);
} //获取栏目列表
protected function get_cat_list() {
//优化提示: 如果您网站的门户栏目在发布数据期间不会变动, 可以注释下面一行代码, 来加速接口执行速度
loadcache('portalcategory');
return $this->global['cache']['portalcategory'];
} //设置发布用户ID
private function set_uid() {
if(empty($_POST['uid'])) showMsg('发布用户ID不能为空');
$uidstr = str_replace(' ', '', $_POST['uid']);
if(strpos($uidstr, ',')) { //多发布用户ID
$uid_list = explode(',', $uidstr);
shuffle($uid_list);
$uid = intval(array_shift($uid_list));
} else { //单发布用户ID
$uid = intval($uidstr);
} if($uid == 0) showMsg('发布用户ID格式不正确'); $info = C::t('common_member')->fetch($uid);
if(empty($info)) showMsg('不存在该用户 (uid: '. $uid .')'); $this->uid = $uid; $this->global['uid'] = $uid;
$this->global['member']['uid'] = $uid;
$this->global['username'] = $info['username'];
$this->global['session']['uid'] = $uid; //绕过discuz权限检测
$this->global['group']['allowmanagearticle'] = true;
$this->global['group']['allowpostarticlemod'] = true;
} //将一些POST参数赋值至GET中, 因为discuz是通过$_GET来获取这些参数
private function post2get() {
foreach(array('author', 'url', 'from', 'fromurl', 'dateline', 'highlight_style') as $key) {
$_GET[$key] = isset($_POST[$key]) && $_POST[$key] ? $_POST[$key] : '';
}
} //发布内容前的初始化
private function init() {
//构造以下POST参数仅用于程序不抛错误提示
$_POST['id'] = '';
$_POST['url'] = '';
$_POST['raids'] = ''; //相关文章ID
$_POST['tag'] = ''; //聚合标签
$_POST['pagetitle'] = '';
$_POST['htmlname'] = '';
$_POST['highlight_style'] = '';
$_POST['pagetitle'] = '';
$_POST['attach_ids'] = '';
$_POST['highlight_style'] = array(
'#000',
0,
0,
0,
); //设置文章阅读数
$_POST['viewnum'] = isset($_POST['viewnum']) && $_POST['viewnum'] ? intval($_POST['viewnum']) : 1;
} //处理上传图片
private function process_attach() {
global $_G; if($_G['uid']) {
$_G['member'] = getuserbyuid($_G['uid']);
}
$_G['groupid'] = $_G['member']['groupid'];
loadcache('usergroup_'.$_G['member']['groupid']);
$_G['group'] = $_G['cache']['usergroup_'.$_G['member']['groupid']]; $aid = 0;
$catid = intval($_POST['catid']); $msg = '';
$errorcode = 0;
require_once libfile('function/portalcp');
if($aid) {
$article = C::t('portal_article_title')->fetch($aid);
if(!$article) {
$errorcode = 1;
} if(check_articleperm($catid, $aid, $article, false, true) !== true) {
$errorcode = 2;
} } else {
if(0 && check_articleperm($catid, $aid, null, false, true) !== true) {
$errorcode = 3;
}
} $upload = new discuz_upload(); $_FILES["Filedata"]['name'] = addslashes(diconv(urldecode($_FILES["Filedata"]['name']), 'UTF-8'));
$upload->init($_FILES['Filedata'], 'portal');
$attach = $upload->attach;
if(!$upload->error()) {
$upload->save();
}
if($upload->error()) {
$errorcode = 4;
} if(!$errorcode) {
if($attach['isimage'] && empty($_G['setting']['portalarticleimgthumbclosed'])) {
require_once libfile('class/image');
$image = new image();
$thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300;
$thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300;
$attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
$image->Watermark($attach['target'], '', 'portal');
} if(0 && getglobal('setting/ftp/on') && ((!$_G['setting']['ftp']['allowedexts'] && !$_G['setting']['ftp']['disallowedexts']) || ($_G['setting']['ftp']['allowedexts'] && in_array($attach['ext'], $_G['setting']['ftp']['allowedexts'])) || ($_G['setting']['ftp']['disallowedexts'] && !in_array($attach['ext'], $_G['setting']['ftp']['disallowedexts']))) && (!$_G['setting']['ftp']['minsize'] || $attach['size'] >= $_G['setting']['ftp']['minsize'] * 1024)) {
if(ftpcmd('upload', 'portal/'.$attach['attachment']) && (!$attach['thumb'] || ftpcmd('upload', 'portal/'.getimgthumbname($attach['attachment'])))) {
@unlink($_G['setting']['attachdir'].'/portal/'.$attach['attachment']);
@unlink($_G['setting']['attachdir'].'/portal/'.getimgthumbname($attach['attachment']));
$attach['remote'] = 1;
} else {
if(getglobal('setting/ftp/mirror')) {
@unlink($attach['target']);
@unlink(getimgthumbname($attach['target']));
$errorcode = 5;
}
}
} $setarr = array(
'uid' => $_G['uid'],
'filename' => $attach['name'],
'attachment' => $attach['attachment'],
'filesize' => $attach['size'],
'isimage' => $attach['isimage'],
'thumb' => $attach['thumb'],
'remote' => $attach['remote'],
'filetype' => $attach['extension'],
'dateline' => $_G['timestamp'],
'aid' => $aid
);
$setarr['attachid'] = C::t('portal_attachment')->insert($setarr, true);
if($attach['isimage']) {
require_once libfile('function/home');
$smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
$bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']);
$coverstr = addslashes(serialize(array('pic'=>'portal/'.$attach['attachment'], 'thumb'=>$attach['thumb'], 'remote'=>$attach['remote'])));
$returnstr = "{\"aid\":$setarr[attachid], \"isimage\":$attach[isimage], \"smallimg\":\"$smallimg\", \"bigimg\":\"$bigimg\", \"errorcode\":$errorcode, \"cover\":\"$coverstr\"}";
return json_decode($returnstr, true);
exit();
} else {
$fileurl = 'portal.php?mod=attachment&id='.$attach['attachid'];
echo "{\"aid\":$setarr[attachid], \"isimage\":$attach[isimage], \"file\":\"$fileurl\", \"errorcode\":$errorcode}";
exit();
}
} else {
echo "{\"aid\":0, \"errorcode\":$errorcode}";
}
} //获取网络图片, 用于封面图片
private function downloadremotefile($imageurl) {
global $_G;
$aid = 0; $upload = new discuz_upload(); $attach['ext'] = $upload->fileext($imageurl);
if(!$upload->is_image_ext($attach['ext'])) return; $content = dfsockopen($imageurl); if(empty($content)) continue;
$temp = explode('/', $imageurl); $attach['name'] = trim($temp[count($temp)-1]);
$attach['thumb'] = ''; $attach['isimage'] = $upload -> is_image_ext($attach['ext']);
$attach['extension'] = $upload -> get_target_extension($attach['ext']);
$attach['attachdir'] = $upload -> get_target_dir('portal');
$attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('portal').'.'.$attach['extension'];
$attach['target'] = getglobal('setting/attachdir').'./portal/'.$attach['attachment']; if(!@$fp = fopen($attach['target'], 'wb')) {
return;
} else {
flock($fp, 2);
fwrite($fp, $content);
fclose($fp);
}
if(!$upload->get_image_info($attach['target'])) {
@unlink($attach['target']);
return;
}
$attach['size'] = filesize($attach['target']);
$attach = daddslashes($attach); if(!$attach) return; if($attach['isimage'] || empty($_G['setting']['portalarticleimgthumbclosed'])) {
require_once libfile('class/image');
$image = new image();
$thumbimgwidth = $_G['setting']['portalarticleimgthumbwidth'] ? $_G['setting']['portalarticleimgthumbwidth'] : 300;
$thumbimgheight = $_G['setting']['portalarticleimgthumbheight'] ? $_G['setting']['portalarticleimgthumbheight'] : 300;
$attach['thumb'] = $image->Thumb($attach['target'], '', $thumbimgwidth, $thumbimgheight, 2);
$image->Watermark($attach['target'], '', 'portal');
} $setarr = array(
'uid' => $_G['uid'],
'filename' => $attach['name'],
'attachment' => $attach['attachment'],
'filesize' => $attach['size'],
'isimage' => $attach['isimage'],
'thumb' => $attach['thumb'],
'remote' => $attach['remote'],
'filetype' => $attach['extension'],
'dateline' => $_G['timestamp'],
'aid' => $aid
);
$setarr['attachid'] = C::t('portal_attachment')->insert($setarr, true); if($attach['isimage']) {
$errorcode = 0;
require_once libfile('function/home');
$smallimg = pic_get($attach['attachment'], 'portal', $attach['thumb'], $attach['remote']);
$bigimg = pic_get($attach['attachment'], 'portal', 0, $attach['remote']);
$coverstr = addslashes(serialize(array('pic'=>'portal/'.$attach['attachment'], 'thumb'=>$attach['thumb'], 'remote'=>$attach['remote'])));
$returnstr = "{\"aid\":$setarr[attachid], \"isimage\":$attach[isimage], \"smallimg\":\"$smallimg\", \"bigimg\":\"$bigimg\", \"errorcode\":$errorcode, \"cover\":\"$coverstr\"}";
$return = json_decode($returnstr, true);
return $return;
}
return;
} //发布内容
protected function publish_content() {
if(DEBUG) {
//调试模式下显示所有级别错误提示
error_reporting(E_ALL);
if(0) {
//构造发布参数, 用于页面调试
$_POST = array(
'uid' => '1',
'catid' => '1',
'title' => '测试标题 - '. DATE_TIME,
'content' => '测试内容 - '. DATE_TIME,
'summary' => '测试摘要~ - '. DATE_TIME,
'dateline' => DATE_TIME,
'author' => '清顽于世',
'from' => '新浪网',
'fromurl' => 'http://www.baidu.com/',
'viewnum' => '15',
'setconver' => '1',
);
}
} //图片上传
$upload = array();
if(!empty($_FILES) && !empty($_FILES['attach_0']['name'])) {
$files = $_FILES;
foreach ($files as $key => $value) {
$_FILES['Filedata'] = $value;
$attach = $this->process_attach(); //处理内容里的图片地址
if(!empty($attach)) {
$upload[] = $attach;
$_POST['content'] = preg_replace('#<img src="('. preg_quote($value['name']) .')" />#iUs', '<img src="'. $attach['bigimg'] .'" />', $_POST['content']);
}
}
} ////提取第一张图片至封面
if(!empty($_POST['setconver'])) {
//检测否是需要下载网络图片, 用于封面
preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $_POST['content'], $matches, PREG_SET_ORDER);
if(!empty($matches) && is_array($matches)) {
$imageurl = $matches[0][2];
if(substr($imageurl, 0, 7) == 'http://' || substr($imageurl, 0, 8) == 'https://') { //内容里第一张图片是网络图片
$data = $this->downloadremotefile($imageurl);
if(!empty($data)) {
$conver = $data['cover'];
} else {
$conver = '';
}
} else { //第一张图片为本地图片
$conver = $upload[0]['cover'];
} $_POST['conver'] = $conver;
}
} //发布内容前的初始化
$this->init(); //POST参数转为GET参数
$this->post2get(); //设置发布用户ID
$this->set_uid(); $catid = $_POST['catid'];
check_articleperm($catid); $_POST['title'] = getstr(trim($_POST['title']), 80); if(strlen($_POST['title']) < 1) {
showMsg('标题不能少于 2 个字符');
} $_POST['title'] = censor($_POST['title']); $_POST['pagetitle'] = getstr(trim($_POST['pagetitle']), 60);
$_POST['pagetitle'] = censor($_POST['pagetitle']);
$htmlname = basename(trim($_POST['htmlname'])); $highlight_style = $_GET['highlight_style'];
$style = '';
$style = implode('|', $highlight_style);
if(empty($_POST['summary'])) $_POST['summary'] = preg_replace("/(\s|\<strong\>##########NextPage(\[title=.*?\])?##########\<\/strong\>)+/", ' ', $_POST['content']); $summary = portalcp_get_summary($_POST['summary']);
$summary = censor($summary); $_GET['author'] = dhtmlspecialchars($_GET['author']);
$_GET['url'] = str_replace('&', '&', dhtmlspecialchars($_GET['url']));
$_GET['from'] = dhtmlspecialchars($_GET['from']);
$_GET['fromurl'] = str_replace('&', '&', dhtmlspecialchars($_GET['fromurl']));
$_GET['dateline'] = !empty($_GET['dateline']) ? strtotime($_GET['dateline']) : TIMESTAMP;
if(empty($_GET['dateline'])) $_GET['dateline'] = TIMESTAMP;
if(substr($_GET['url'], 0, 7) !== 'http://') {
$_GET['url'] = '';
}
if(substr($_GET['fromurl'], 0, 7) !== 'http://') {
$_GET['fromurl'] = '';
} if(0 && (censormod($_POST['title']) || $_G['group']['allowpostarticlemod'])) { //让文章发布状态始终为true
$article_status = 1;
} else {
$article_status = 0;
} $setarr = array(
'idtype' => '',
'title' => $_POST['title'],
'author' => $_GET['author'],
'from' => $_GET['from'],
'fromurl' => $_GET['fromurl'],
'dateline' => intval($_GET['dateline']),
'url' => $_GET['url'],
'allowcomment' => !empty($_POST['forbidcomment']) ? '0' : '1',
'summary' => $summary,
'catid' => intval($_POST['catid']),
'tag' => article_make_tag($_POST['tag']),
'status' => $article_status,
'highlight' => $style,
'showinnernav' => empty($_POST['showinnernav']) ? '0' : '1',
); if(empty($setarr['catid'])) {
showMsg('栏目不能为空');
} if(!empty($_POST['conver'])) {
$converfiles = dunserialize($_POST['conver']);
$setarr['pic'] = $converfiles['pic'];
$setarr['thumb'] = intval($converfiles['thumb']);
$setarr['remote'] = intval($converfiles['remote']);
} $id = 0;
$idtype = ''; if(empty($article)) {
$setarr['uid'] = $this->global['uid'];
$setarr['username'] = $this->global['username'];
$setarr['id'] = intval($_POST['id']);
$setarr['htmlname'] = $htmlname;
$table = '';
if(0 && $setarr['id']) {
if($_POST['idtype']=='blogid') {
$table = 'home_blogfield';
$setarr['idtype'] = 'blogid';
$id = $setarr['id'];
$idtype = $setarr['idtype'];
} else {
$table = 'forum_thread';
$setarr['idtype'] = 'tid'; require_once libfile('function/discuzcode');
$id = C::t('forum_post')->fetch_threadpost_by_tid_invisible($setarr['id']);
$id = $id['pid'];
$idtype = 'pid';
}
} $aid = C::t('portal_article_title')->insert($setarr, 1); if(0 && $table) {
if($_POST['idtype']=='blogid') {
C::t('home_blogfield')->update($setarr['id'], array('pushedaid' => $aid));
} elseif($setarr['idtype']=='tid') {
$modarr = array(
'tid' => $setarr['id'],
'uid' => $_G['uid'],
'username' => $_G['username'],
'dateline' => TIMESTAMP,
'action' => 'PTA',
'status' => '1',
'stamp' => '',
);
C::t('forum_threadmod')->insert($modarr); C::t('forum_thread')->update($setarr['id'], array('moderated' => 1, 'pushedaid' => $aid));
}
}
C::t('common_member_status')->update($this->global['uid'], array('lastpost' => TIMESTAMP), 'UNBUFFERED');
C::t('portal_category')->increase($setarr['catid'], array('articles' => 1));
C::t('portal_category')->update($setarr['catid'], array('lastpublish' => TIMESTAMP));
C::t('portal_article_count')->insert(array('aid'=>$aid, 'catid'=>$setarr['catid'], 'viewnum'=>$_POST['viewnum']));
} else {
//这里面基本不可能执行到
if($htmlname && $article['htmlname'] !== $htmlname) {
$setarr['htmlname'] = $htmlname;
$oldarticlename = $article['htmldir'].$article['htmlname'];
unlink($oldarticlename.'.'.$_G['setting']['makehtml']['extendname']);
for($i = 1; $i < $article['contents']; $i++) {
unlink($oldarticlename.$i.'.'.$_G['setting']['makehtml']['extendname']);
}
}
C::t('portal_article_title')->update($aid, $setarr);
} $content = getstr($_POST['content'], 0, 0, 0, 0, 1);
$content = censor($content);
if(0 && (censormod($content) || $this->global['group']['allowpostarticlemod'])) {
$article_status = 1;
} else {
$article_status = 0;
} $regexp = '/(\<strong\>##########NextPage(\[title=(.*?)\])?##########\<\/strong\>)+/is';
preg_match_all($regexp, $content ,$arr);
$pagetitle = !empty($arr[3]) ? $arr[3] : array();
$pagetitle = array_map('trim', $pagetitle);
array_unshift($pagetitle, $_POST['pagetitle']);
$contents = preg_split($regexp, $content);
$cpostcount = count($contents); $dbcontents = C::t('portal_article_content')->fetch_all($aid); $pagecount = $cdbcount = count($dbcontents);
if($cdbcount > $cpostcount) {
$cdelete = array();
foreach(array_splice($dbcontents, $cpostcount) as $value) {
$cdelete[$value['cid']] = $value['cid'];
}
if(!empty($cdelete)) {
C::t('portal_article_content')->delete($cdelete);
}
$pagecount = $cpostcount;
} foreach($dbcontents as $key => $value) {
C::t('portal_article_content')->update($value['cid'], array('title' => $pagetitle[$key], 'content' => $contents[$key], 'pageorder' => $key+1));
unset($pagetitle[$key], $contents[$key]);
} if($cdbcount < $cpostcount) {
foreach($contents as $key => $value) {
C::t('portal_article_content')->insert(array('aid' => $aid, 'id' => $setarr['id'], 'idtype' => $setarr['idtype'], 'title' => $pagetitle[$key], 'content' => $contents[$key], 'pageorder' => $key+1, 'dateline' => TIMESTAMP));
}
$pagecount = $cpostcount;
} $updatearticle = array('contents' => $pagecount);
if($article_status == 1) {
$updatearticle['status'] = 1;
updatemoderate('aid', $aid);
manage_addnotify('verifyarticle');
} $updatearticle = array_merge($updatearticle, portalcp_article_pre_next($catid, $aid));
C::t('portal_article_title')->update($aid, $updatearticle); $newaids = array();
$_POST['attach_ids'] = explode(',', $_POST['attach_ids']);
foreach ($_POST['attach_ids'] as $newaid) {
$newaid = intval($newaid);
if($newaid) $newaids[$newaid] = $newaid;
}
if($newaids) {
C::t('portal_attachment')->update_to_used($newaids, $aid);
} addrelatedarticle($aid, $_POST['raids']); if(0 && $_GET['from_idtype'] && $_GET['from_id']) { $id = intval($_GET['from_id']);
$notify = array();
switch ($_GET['from_idtype']) {
case 'blogid':
$blog = C::t('home_blog')->fetch($id);
if(!empty($blog)) {
$notify = array(
'url' => "home.php?mod=space&uid=$blog[uid]&do=blog&id=$id",
'subject' => $blog['subject']
);
$touid = $blog['uid'];
}
break;
case 'tid':
$thread = C::t('forum_thread')->fetch($id);
if(!empty($thread)) {
$notify = array(
'url' => "forum.php?mod=viewthread&tid=$id",
'subject' => $thread['subject']
);
$touid = $thread['authorid'];
}
break;
}
if(!empty($notify)) {
$notify['newurl'] = 'portal.php?mod=view&aid='.$aid;
notification_add($touid, 'pusearticle', 'puse_article', $notify, 1);
}
} if(trim($_GET['from']) != '') {
$from_cookie = '';
$from_cookie_array = array();
$from_cookie = getcookie('from_cookie');
$from_cookie_array = explode("\t", $from_cookie);
$from_cookie_array[] = $_GET['from'];
$from_cookie_array = array_unique($from_cookie_array);
$from_cookie_array = array_filter($from_cookie_array);
$from_cookie_num = count($from_cookie_array);
$from_cookie_start = $from_cookie_num - 10;
$from_cookie_start = $from_cookie_start > 0 ? $from_cookie_start : 0;
$from_cookie_array = array_slice($from_cookie_array, $from_cookie_start, $from_cookie_num);
$from_cookie = implode("\t", $from_cookie_array);
dsetcookie('from_cookie', $from_cookie);
}
dsetcookie('clearUserdata', 'home');
$op = 'add_success';
$article_add_url = 'portal.php?mod=portalcp&ac=article&catid='.$catid; $article = C::t('portal_article_title')->fetch($aid);
$viewarticleurl = $_POST['url'] ? "portal.php?mod=list&catid=$_POST[catid]" : fetch_article_url($article); showMsg('发布成功');
}
} //接口需要用到的函数库
function portalcp_get_summary($message) {
$message = preg_replace(array("/\[attach\].*?\[\/attach\]/", "/\&[a-z]+\;/i", "/\<script.*?\<\/script\>/"), '', $message);
$message = preg_replace("/\[.*?\]/", '', $message);
$message = getstr(strip_tags($message), 200);
return $message;
} function portalcp_article_pre_next($catid, $aid) {
$data = array(
'preaid' => C::t('portal_article_title')->fetch_preaid_by_catid_aid($catid, $aid),
'nextaid' => C::t('portal_article_title')->fetch_nextaid_by_catid_aid($catid, $aid),
);
if($data['preaid']) {
C::t('portal_article_title')->update($data['preaid'], array(
'preaid' => C::t('portal_article_title')->fetch_preaid_by_catid_aid($catid, $data['preaid']),
'nextaid' => C::t('portal_article_title')->fetch_nextaid_by_catid_aid($catid, $data['preaid']),
)
);
}
return $data;
}
?>
discuz论坛门户资讯入库接口【原创】的更多相关文章
- discuz数据批量入库接口
近期在做社区,首选discuz,数据需要用scrapy爬虫批量入库,就写了一个php入库接口. <?php define('PW', 'abc123456');//一定要修改 if($_REQU ...
- Discuz论坛黑链清理教程
本人亲测有效,原创文章哦~~~ 论坛黑链非常的麻烦,如果你的论坛有黑链,那么对不起,百度收录了你的黑链,不会自动删除,需要你手动去清理. 什么是黑链 黑链,顾名思义,就是一些赌博网站的外链,这些黑链相 ...
- java和Discuz论坛实现单点登录,通过Ucenter(用户管理中心)
标题有点问题,没有进行修改. 一 Discuz论坛搭建步骤 1:服务器环境配置 服务器要支持php语言+支持mysql 5.0以上的数据库 + Apache服务器(支持网站的一个服务器,通过域名的能访 ...
- jsp网站与discuz论坛用户同步
需求分析: 要想实现A(jsp网站)和B(discuz论坛)的同步,这里说的同步指的是 在AB网站任意一方注册之后在另一方都可以直接登录 AB两网站之间的用户登陆状态是同步的,在任意一方登录后,另一方 ...
- discuz 取消门户首页url中的portal.php
这几天准备用discuz搭建一个素食网站,一切就绪之后,访问discuz的门户时总是带着portal.php,可能是职业毛病,在url中总是带着,感觉太碍眼了,并且discuz就是搜索引擎收录一直抵制 ...
- 织梦系统与discuz论坛整合方法
如何完成dedecms模板系统与discuz论坛整合呢? 这里的整合指会员信息,会员登陆.退出的同步:论坛信息的引用:等等. 首先,我们先来安装织梦(dedecms)系统. 然后,我们在网站根目录下建 ...
- 自己动手利用CentOS6.5 搭建php环境安装discuz论坛
1.安装搭建论坛必要的软件 apache php mysql CentOS系统我们可以直接使用 yum install 的方式进行软件安装,腾讯云有提供软件安装源,是同步CentOS官方的安装源,包涵 ...
- LAMP环境搭建一个Discuz论坛
LAMP是Linux+Apache+Mysql/MariaDB+Perl/PHP/Python的简称.一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有 ...
- LNMP架构及DISCUZ论坛部署
1)(5分)服务器IP地址规划:client:12.0.0.12/24,网关服务器:ens36:12.0.0.1/24.ens33:172.16.10.1/24,Web1:172.16.10.10/2 ...
随机推荐
- csp联考T1
本题主要难点在于如何处理dist^2的问题 40分算法 n^2暴力就不必多嘴,直接枚举根节点DFS就行了. 70分算法 对于b=0的情况,我们可以考虑用换根法来计算根节点的变化对总权值带来的影响. 换 ...
- WordPress 设计学习
"One can never be defeated until defeat has been accepted as a reality"----- Bruce Lee 官网免 ...
- 从Asp .net到Asp core (第一篇)《回顾Asp .net生命周期与管道机制》
从2016年微软收购了Xamarin整合到Visual Studio里并将其开源到现在已有三年多时间,从.net core 1.0 到现在的2.2,以及即将问世的3.0,我们看到微软正在跨平台之路越走 ...
- win10无法安装软件解决
https://www.windowscentral.com/how-fix-network-resource-unavailable-install-error-windows-10
- adb命令查看连接PC的移动设备
cmd窗口中输入adb应会出现上图情况,如果显示不存在则需要网上下载adb工具并在我的电脑-属性-高级系统设置-环境变量中将adb工具的路径加入PATH,如下图: 输入adb devices 可以看到 ...
- TweenMax参数用法中文介绍
TweenMax 建立在 TweenLite 和 TweenFilterLite 基础之上,因此,又揉合了这二者的功能,使得功能更加的齐备,但是如果说易用性,觉得还是 TweenLite 来得方便一些 ...
- postman调用webapi错误记录
1.webapi ,接口中header中,value 不能太长,太长会报错 结局:value中不要存太长的数据 2.如果key 中有中文,会获取不到数据 , 解决:需要把中文转码,然后后端解码 3.如 ...
- java之servlet之文件下载
1.在页面中,可以直接通过超链接来下载: a) 如果浏览器能够打开该文件,那么直接在浏览器中显示---不是想要的效果 b) 任何人都能下载,不能进行权限控制 2.通过servlet来进行下载,在ser ...
- 创建Core项目使用IdentityServer4
本文主要参照https://www.bilibili.com/video/av42364337/?p=4 英文帮助文档:https://identityserver4.readthedocs.io/e ...
- 全面学习 Python 包:包的构建与分发
首发于公众号:Python编程时光 1. 为什么需要对项目分发打包? 平常我们习惯了使用 pip 来安装一些第三方模块,这个安装过程之所以简单,是因为模块开发者为我们默默地为我们做了所有繁杂的工作,而 ...