您现在的位置是:首页 > 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 x3.0的方法
最近在做discuz改版的项目,遇到了很多问题,相信很多拥有discuz论坛的版主,站长和程序猿在升级或改版discuz的过程中遇到过和我一样的问题
Discuz开发移动端访客功能的实现步骤
discuz在移动端的功能着实很简单基本就几个页面就完了,pc端的很多功能都没事实现,尤其是个人空间页面,移动端简直没有任何操做可言。
CentOs7搭建论坛Discuz_X3.2的步骤方法
由于公司项目需要一个互动平台,可以发起活动,发消息留言,讨论过后发现这竟然是一个论坛的功能。 于是就不打算耗费功夫开发相关功能,直接另外搭一套BBS算球。。。 一直觉得搭建B
Discuz数据同步DiscuzToolkit的方法
公司想做个论坛,后来改用Discuz论坛,想实现一个功能,公司网站为主网站,通过在主站登陆,同时在Discuz论坛也实现登陆;
相关源码
-
(自适应)工商代理公司注册财务会计pbootcms模板免费下载为工商代理、财务会计服务企业设计的网站模板,基于PbootCMS开发,充分考虑了企业服务行业的展示需求与客户转化路径。设计风格专业严谨,布局清晰合理,呈现企业服务内容与专业优势。查看源码 -
(自适应)水墨风中药馆中医名医介绍pbootcms网站模板本模板基于PbootCMS内核开发,为中医馆、中医药企业量身定制,可快速搭建具有传统文化特色的官方网站。自适应手机端设计,数据实时同步,助您高效展示中医特色诊疗、中药产品、养生知识等内容,塑造专业品牌形象。查看源码 -
蓝色工业机械五金设备pbootcms模板源码下载(PC+WAP)为机械制造与五金设备企业设计的响应式网站模板,基于PbootCMS内核开发。采用蓝色工业风格强化行业属性,宽屏布局突出设备细节展示,支持PC与WAP端自适应查看源码 -
(自适应响应式)高端珠宝首饰奢侈品pbootcms模板下载本模板为珠宝首饰及奢侈品行业打造,采用PbootCMS内核开发,具备卓越的视觉表现力与商业转化能力。自适应设计确保在手机端呈现产品细节,后台数据实时同步,助您高效展示钻石查看源码 -
pbootcms源码宠物类网站源码下载(自适应多端)为宠物装备商店、宠物食品及用品企业打造的营销型模板,基于PbootCMS内核深度开发。采用响应式设计实现PC与移动端适配,PHP7.0+高性能架构支持MySQL/SQLite双数据库查看源码 -
(自适应)电子元件电路板元器件pbootcms网站源码下载为电子元器件、电路板制造类企业设计,特别适合展示产品参数、技术规格等内容。采用响应式技术,确保各类电子元件在不同设备上都能清晰展示。查看源码
| 分享笔记 (共有 篇笔记) |
