discuz x2 发帖代码

discuz

2011-10-22 14:55

<?php
define('APPTYPEID', 4);
define('CURSCRIPT', 'portal');

require './source/class/class_core.php';
$discuz = & discuz_core::instance();
$discuz->init();

$title="这23123又是345345一条帖子";              //标题
$fid=41;                                       //版块
$uid=1;                                        //发帖人ID
$uname='admin';                                //发帖人
$time=time();                                  //发帖时间
$content="这当然是[B]asd[/B]内容啦\r\n从前....结束\r\n";    //内容
$ip='127.0.0.1';                               //IP
$views=rand(0,100);                            //浏览次数
$htmlon=1;                                     // 是否支持HTML   1是支持. 要去后台给板块开启支持HTML

$array=array('fid'=>$fid,'posttableid'=>0,'typeid'=>0,'sortid'=>0,'readperm'=>0,'price'=>0,'author'=>$uname,'authorid'=>$uid,'subject'=>$title,'dateline'=>$time,'lastpost'=>$time,'lastposter'=>$uname,'views'=>$views,'replies'=>0,'displayorder'=>0,'highlight'=>0,'digest'=>0,'rate'=>0,'special'=>0,'attachment'=>0,'moderated'=>0,'closed'=>0,'stickreply'=>0,'recommends'=>0,'recommend_add'=>0,'recommend_sub'=>0,'heats'=>0,'status'=>32,'isgroup'=>0,'favtimes'=>0,'sharetimes'=>0,'stamp'=>-1,'icon'=>-1,'pushedaid'=>0,'cover'=>0,'replycredit'=>0);
$tid=DB::insert('forum_thread', $array, TRUE);



$array=array('fid'=>$fid,'tid'=>$tid,'first'=>1,'author'=>$uname,'authorid'=>$uid,'subject'=>$title,'dateline'=>$time,'message'=>"$content",'useip'=>$ip,'invisible'=>0,'anonymous'=>0,'usesig'=>1,'htmlon'=>$htmlon,'bbcodeoff'=>-1,'smileyoff'=>-1,'parseurloff'=>0,'attachment'=>0,'rate'=>0,'ratetimes'=>0,'status'=>0,'tags'=>'','comment'=>0,'replycredit'=>0);
$pid=DB::insert('forum_post', $array, TRUE);

$array=array('pid'=>$pid);
DB::insert('forum_post_tableid', $array);



$num=DB::fetch(DB::query('SELECT threads,posts,todayposts FROM '.DB::table('forum_forum')." WHERE fid='$fid'"));
$array=array('threads'=>$num[threads]+1,'posts'=>$num[posts]+1,'lastpost'=>"$pid        $title        $time        $uname",'todayposts'=>$num[todayposts]+1);
DB::update('forum_forum', $array,"fid='$fid'");



DB::query("UPDATE ".DB::table('common_member_count')." SET posts=posts+1 WHERE uid='$uid'", 'UNBUFFERED');
DB::query("UPDATE ".DB::table('common_member_status')." SET lastip='$ip',lastvisit='$time',lastactivity='$time',lastpost="$pid        $title        $time        $uname"  WHERE uid='$uid'", 'UNBUFFERED');

echo 'OK'.$pid;