您现在的位置是:首页 > cms教程 > Discuz教程Discuz教程
discuz脚本发表帖子的方法
海云2025-07-10Discuz教程已有人查阅
导读还在为油光光的皮肤懊恼?还在为这些美丽路上的“绊脚石”忧愁?现在,就是扫除那些美丽困扰的时刻了快快参与媲美的新一轮微博活动让毛孔藏起来,美丽心情走起来
$db = mysql_connect("", "", "") or die("not connected");
mysql_query("set NAMES utf8", $db);
$clientip = $_SERVER["REMOTE_ADDR"];
$time = time();
$subject = "还在为大大的毛孔烦恼?";
$message = <<<EOF
还在为油光光的皮肤懊恼?还在为这些美丽路上的“绊脚石”忧愁?
现在,就是扫除那些美丽困扰的时刻了快快参与媲美的新一轮微博活动让毛孔藏起来,美丽心情走起来
【活动时间】
2012.12.11-2012.12.27a.m12:00
【评奖规则】
本次活动同一账号发帖次数不限
2012年12月27号活动结束后
随机抽取5位网友获得 贝德玛净妍毛孔修护乳
【奖品特点】
贝德玛净妍毛孔修护乳
皮脂调节净化专利,有助于保持毛孔畅通,使用后皮肤不再油光;
具有收缩毛孔的功效,减少皮脂的生成;
甘露醇与银杏叶提取物 保护皮肤受到自由基的侵害,让皮肤恢复自然光泽。
EOF;
$tid = to_bbs($subject, $message);
echo "<a href='http:// .aa.com/bbs/thread-$tid-1-1.html' target='_blank'>http:// .aa.com/bbs/thread-$tid-1-1.html</a>";
function to_bbs($subject, $message) {
global $db;
global $clientip;
global $time;
mysql_select_db('aa', $db) or die('数据库连接失败,请检查数据库名');
$fid = 11; //板块id
$author = '11'; //用户名
$authorid = '111'; //用户uid
$res = mysql_query("SELECT `modnewposts` FROM `pre_forum_forum` WHERE fid='$fid'", $db); //论坛板块设置,是否审核主题贴
$modnewthreads = mysql_result($res, 0); //是否审核主题贴
$displayorder = $modnewthreads ? -2 : 0;
$pinvisible = $modnewthreads ? -2 : 0;
$message = portal_threadcode($message); //将html标签转成规范的discuz标签
/** 插入主题表 * */
$sql = "INSERT INTO pre_forum_thread (`fid`, `posttableid`, `readperm`, `price`, `typeid`, `sortid`, `author`, `authorid`, `subject`, `dateline`, `lastpost`, `lastposter`, `displayorder`, `digest`, `special`, `attachment`, `moderated`, `status`, `isgroup`, `replycredit`, `closed`, `allowinvitation`)
VALUES ('$fid', '0', '0', '0', '0', '0', '$author', '$authorid', '$subject','$time' , '$time', '$author', $displayorder, '0', '0', '0', '0', '32', '0', '0', '0', '0')";
mysql_query($sql, $db);
/** 返回的帖子ID * */
$tid = mysql_insert_id();
/** 插入帖子表 * */
$sql = "INSERT INTO pre_forum_post_tableid (`pid` )VALUES ('null')";
mysql_query($sql, $db);
$pid = mysql_insert_id();
$sql = "INSERT INTO pre_forum_post (`pid`, `fid`, `tid`, `first`, `author`, `authorid`, `subject`, `dateline`, `message`, `useip`, `invisible`, `anonymous`, `usesig`, `htmlon`, `bbcodeoff`, `smileyoff`, `parseurloff`, `attachment`, `tags`, `replycredit`, `status`)
VALUES ('$pid', '$fid' , '$tid', '1', '$author', '$authorid', '$subject', '$time', '$message' , '$clientip', '$pinvisible', '0', '1', '0', '0', '-1', '0', '0', '', '0', '0')";
mysql_query($sql, $db);
if ($modnewthreads) {
/** 增加到审核库 * */
$sql = "REPLACE INTO `pre_common_moderate` set `id`='$tid',`idtype`='tid',`status`='0',`dateline`='$time'";
mysql_query($sql, $db);
/** 更新版块信息 * */
$sql = "UPDATE `pre_forum_forum` SET `todayposts`=`todayposts`+1 WHERE `fid`='$fid'";
mysql_query($sql, $db);
} else {
/** 更新版块信息 * */
$subject = str_replace("\t", ' ', $subject);
$lastpost = "$tid\t$subject\t$time\t$author";
$sql = "UPDATE `pre_forum_forum` SET `lastpost`='$lastpost', `threads`=`threads`+1, `posts`=`posts`+1, `todayposts`=`todayposts`+1 WHERE `fid`='$fid'";
mysql_query($sql, $db);
}
return $tid;
}
/*
* html标签 转换为discuzcode
*/
function portal_threadcode($message) {
$msglower = strtolower($message);
$message = str_replace(
array(
'</font>', '</p>', '<b>', '</b>', '<strike>', '</strike>', '<hr class="l" />', '<i class="pstatus">', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ul type="1" class="litype_1">', '<ul type="a" class="litype_2">',
'<ul type="A" class="litype_3">', '<li>', '</li>', '</ul>', '<blockquote>', '</blockquote>', '</span>', '<p>', '</div>', '<div>', ' ', '&', '<', '>', '"', 'text-indent:(\d{1,2}|null)em;text-align:(left|center|right)\">/i",
"/<span\s+style=\"float:left;margin-right:5px\">/i",
"/<span\s+style=\"float:right;margin-left:5px\">/i",
"/###NextPage###/i",
"/###NextPage\[title\=([\w\W]+?)\]###/i",
"/<p\s+style=\"text-align:\s+(left|center|right);\">/i",
"/<p\s+align=(left|center|right)>/i",
'/<script\s+type=\"text\/javascript\"(.*?)<\/script>/i',
), array(
"",
"",
"[backcolor=\\1]",
"[backcolor=\\1]",
"",
"",
"[font=\\1]",
"[align=\\1]",
"[align=\\1]",
"[p=\\1, \\2, \\3]",
"[float=left]",
"[float=right]",
"\n",
"[align=left]\\1[/align]",
"[align=\\1]",
"[align=\\1]",
"",
), $message
)
);
/* img标签 */
preg_match_all('/<a(.*?)>(.*?)<(img|IMG)(.*?)src=\"(.*?)\"(.*?)>(.*?)<\/a>/ix', $message, $match);
if ($match[0]) {
$match[5] = is_array($match[5]) ? $match[5] : array($match[5]);
$match[0] = is_array($match[0]) ? $match[0] : array($match[0]);
$match[5] = array_map('reimg', $match[5]);
$message = str_replace($match[0], $match[5], $message);
$match = array();
}
preg_match_all('/<(img|IMG)(.*?)src=\"(.*?)\"(.*?)>/isx', $message, $match);
if ($match[0]) {
$match[3] = is_array($match[3]) ? $match[3] : array($match[3]);
$match[0] = is_array($match[0]) ? $match[0] : array($match[0]);
$match[3] = array_map('reimg', $match[3]);
$message = str_replace($match[0], $match[3], $message);
$match = array();
}
/* 链接 */
$message = preg_replace(
array("/<a\s+href=\"(.*?)\"(.*?)>(.*?)<\/a>/i"), array("\\3"), $message
);
/* 音频视频 */
if (strpos($msglower, "[/flash]") != false) {
preg_match_all('/\[flash=(.*?)\](.*?)\[\/flash\]/isx', $message, $match);
$match[0] = is_array($match[0]) ? $match[0] : array($match[0]);
$match[1] = is_array($match[1]) ? $match[1] : array($match[1]);
$match[2] = is_array($match[2]) ? $match[2] : array($match[2]);
$revideo = array();
foreach ($match[0] as $key => $value) {
$revideo[$key] = portalpvideo($match[1][$key], $match[2][$key]);
}
$message = str_replace($match[0], $revideo, $message);
//$message = preg_replace('/\[flash=(.*?)\](.*?)\[\/flash\]/isx',"portalpvideo('\\1','\\2')",$message);
}
/* 解析源码视频 */
if (strpos($msglower, "</object>") != false) {
preg_match_all('/<object(.*?)width=\"(\d+)\"\s+height=\"(\d+)\">([\w\W]*?)src=\"(.*?)\"([\w\W]*?)<\/object>/isx', $message, $match);
$match[0] = is_array($match[0]) ? $match[0] : array($match[0]);
$match[2] = is_array($match[2]) ? $match[2] : array($match[2]);
$match[3] = is_array($match[3]) ? $match[3] : array($match[3]);
$match[5] = is_array($match[5]) ? $match[5] : array($match[5]);
$revideo = array();
foreach ($match[0] as $key => $value) {
$revideo[$key] = portalpvideo2($match[2][$key], $match[3][$key], $match[5][$key]);
}
$message = str_replace($match[0], $revideo, $message);
}
$message = strip_tags($message);
return $message;
}
/*
* 更改img标签
*/
function reimg($img) {
return "";
}
/*
* 解析文章中的视频为discuzcode
*/
function portalpvideo($param, $url) {
if (strtolower($param) == 'media' or strtolower($param) == 'real') {
$ext = substr(strrchr($url, '.'), 1);
return "[media=" . $ext . ",500,375]" . $url . "[/media]";
} elseif (strtolower($param) == 'mp3') {
return "";
} else {
return "" . $url . "";
}
}
/*
* 解析源码视频
*/
function portalpvideo2($width, $height, $url) {
$ext = substr(strrchr($url, '.'), 1);
return "[media=" . $ext . "," . $width . "," . $height . "]" . $url . "[/media]";
}
本文标签:
很赞哦! ()
相关教程
- HTML JavaScript 脚本
- LR实战Discuz开源论坛登录脚本
- PbootCMS升级处理数据库升级脚本的方法
- PbootCMS自动清理脚本每天只执行一次的实现方法
- ecshop购买脚本xpath定位元素(下拉框,单选框)
- dede织梦整合资料注册部分脚本可独立使用
- dede织梦cms中如何运行php脚本和变量底层字段进行处理
- 浅谈dedecms安全设置做目录执行php脚本限制的方法
- dedecms安全设置执行php脚本限制设置方法
- dedecms取消服务器主机空间目录脚本的执行权限方法
- dede织梦模板中怎么运行php脚本和变量在需要操作数据库字段
- dedecms安全设置教程,dede实现目录执行php脚本限制的方法
图文教程
Discuz开源论坛本地部署自动生成数据库的方法
这个版本可能比较有点老,但是万变不离其宗,再新的版本都是在已有的基础上更新的,所以掌握方法是最重要的!(安装成功的论坛首页)(后台管理登录页)
Discuz!NT中远程附件功能实现方法,FTP协议
大约在去年的12月份,我们开始着手设计和开发这项功能,而该项功能主要是解决类似于一些帖子附件(图片或文件)访问比较频繁,同时附件的体积又比较大
discuz缓存机制分析介绍
使用缓存机制的目的很明显,降低服务器性能的消耗,对于常用且变动比较小的数据的数据,可以尽可能的使用缓存来解决,代替最原生的不断的进行数据库查询匹配的过程。
discuz论坛发展历程和功能介绍
Crossday Discuz! Board(简称 Discuz!)是北京康盛新创科技有限责任公司推出的一套通用的社区论坛软件系统。自2001年6月面世以来,Discuz!已拥有11年以上的应用历史和200多万网站用户案例
相关源码
-
帝国cms淘宝客京东联盟网站整站源码下载本模板基于帝国CMS内核深度开发,为淘宝客行业量身定制。随着腾讯微信与淘宝生态的互联互通,淘宝客链接现可在微信、QQ等平台直接分享,为推广带来更多便利。模板特别优化了店铺推广功能,有效避免商品下架导致的链接失效问题,同时支持京东联盟等多平台商品推广。查看源码 -
自适应容器设备机械行业通用pbootcms网站模板本模板是一款基于PbootCMS开源内核深度开发,为容器制造、容器设备、压力容器及相关行业量身打造的高品质响应式企业网站模板。查看源码 -
(自适应响应式)pbootcms紫色美容整形机构企业模板下载基于PbootCMS内核开发的响应式网站模板,为医疗美容机构、整形医院等企业设计,提供完整的线上展示平台采用紫色系配色方案,整体风格专业大气。模板包含首页轮播、服务项目、专家团队、案例展示等核心模块,能够充分展示医疗美容机构的专业服务和特色优势。查看源码 -
(自适应响应式)html5蓝色智能水表营销型网站pbootcms模板下载PbootCMS内核开发,为智能水表企业打造的营销型网站解决方案,本模板基于PbootCMS内核开发,为智能水表及相关行业企业设计,采用HTML5+CSS3技术构建,具有响应式布局。查看源码 -
(PC+WAP)蓝色新能源环保太阳能光伏模板pbootcms下载新能源环保行业网站解决方案为太阳能光伏系统企业打造的专业网站模板,助力新能源企业高效展示产品与服务PbootCMS内核开发,源码开放可修改PC与手机端自适应设计查看源码 -
帝国cms7.5手游评测资讯礼包合集游戏专区下载网站模板本模板基于帝国CMS系统开发,为手游门户网站设计。支持PC端与移动端同步生成HTML静态页面,内置多端同步生成功能。模板架构针对手业特点优化,满足APP下载、游戏资讯、攻略等内容发布需求。查看源码
| 分享笔记 (共有 篇笔记) |