|
|
这个是整合其它一些接口功能制作的.当然,本身也并不是完美,Dz7.0出来后打算做下改进.有什么好的意见请说.
-
- <?php
- /*
- discuz6.1随机接口文件,支持任意文件附件形式发布
- */
- $replyusers = "admin|999|aaa|bbb|ccc|ddd|eee"; //随机回复用户名,请改成你论坛存在的用户
- $filedir='files/'; //这里是文件的在attachments目录下的保存目录
- $attdir="images/"; //附件图片保存目录,本地整个文件夹拷入attachments目录;必须先上传文件再发布。
- //$isimage=0;
- define('CURSCRIPT', 'post');
- define('NOROBOT', TRUE);
- require_once './include/common.inc.php';
- require_once DISCUZ_ROOT.'./include/post.func.php';
- $_DTYPE = $checkoption = $optionlist = array();
- if($typeid) {
- threadtype_checkoption();
- }
- require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
- $navigation = $navtitle = $thread = '';
- $navigation = "» <a href="forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."">$forum[name]</a> $navigation";
- $navtitle = $navtitle.strip_tags($forum['name']).' - ';
- if($forum['type'] == 'sub') {
- $query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
- $fup = $db->fetch_array($query);
- $navigation = "» <a href="forumdisplay.php?fid=$fup[fid]">$fup[name]</a> $navigation";
- $navtitle = $navtitle.strip_tags($fup['name']).' - ';
- }
- $special = empty($special) || !is_numeric($special) || $special < 0 || $special > 6 ? 0 : intval($special);
- $allowpostattach = !empty($forum['allowpostattach']) || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && forumperm($forum['postattachperm']));
- $attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
- $enctype = $allowpostattach ? 'enctype="multipart/form-data"' : '';
- $maxattachsize_kb = $maxattachsize / 1000;
- $postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
- $replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
- $digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
- $postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
- $maxprice = isset($extcredits[$creditstrans]) ? $maxprice : 0;
- $extra = rawurlencode($extra);
- $blogcheck = empty($isblog) && empty($addtoblog) ? '' : 'checked="checked"';
- $notifycheck = empty($emailnotify) ? '' : 'checked="checked"';
- $stickcheck = empty($sticktopic) ? '' : 'checked="checked"';
- $digestcheck = empty($addtodigest) ? '' : 'checked="checked"';
- $subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
- $message = isset($message) ? censor(trim($message)) : '';
- $readperm = isset($readperm) ? intval($readperm) : 0;
- $price = isset($price) ? intval($price) : 0;
- $urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = '';
- $seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
- $secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts < $secqaa['minposts']);
- if($iscircle = $supe['status'] && $supe['circlestatus'] && $forum['status'] == 2) {
- unset($forum['threadtypes']);
- }
- $allowpostpoll = $allowpost && $allowpostpoll && ($forum['allowpostspecial'] & 1);
- $allowposttrade = $allowpost && $allowposttrade && ($forum['allowpostspecial'] & 2);
- $allowpostreward = $allowpost && $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
- $allowpostactivity = $allowpost && $allowpostactivity && ($forum['allowpostspecial'] & 8);
- $allowpostdebate = $allowpost && $allowpostdebate && ($forum['allowpostspecial'] & 16);
- $allowpostvideo = $allowpost && $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
- $allowanonymous = $forum['allowanonymous'] || $allowanonymous ? 1 : 0;
- $editorid = 'posteditor';
- $editoroptions = str_pad(decbin($editoroptions), 2, 0, STR_PAD_LEFT);
- $editormode = $editormode == 2 ? $editoroptions{0} : $editormode;
- $allowswitcheditor = $editoroptions{1};
- $advanceeditor = $special ? 0 : 1;
- $previewdisplay = !empty($previewpost) ? '' : 'none';
- if($action == 'newthread') {
- $discuz_action = 11;
- if(empty($forum['fid']) || $forum['type'] == 'group') {
- exit('未选择版块或版块不能发帖');
- }
- $isblog = empty($isblog) ? '' : 'yes';
- if($subject == '' || $message == '') {
- exit('标题或内容为空');
- }
- if($post_invalid = checkpost()) {
- exit('标题或内容超过发帖限制');
- }
- if($allowpostattach && is_array($_FILES['attach'])) {
- foreach($_FILES['attach']['name'] as $attachname) {
- if($attachname != '') {
- checklowerlimit($postattachcredits);
- break;
- }
- }
- }
- $typeid = isset($typeid) && isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0;
- $iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $iconid : 0;
- $displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0);
- $digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1 : 0;
- $blog = $allowuseblog && $forum['allowshare'] && !empty($addtoblog) ? 1 : 0;
- $readperm = $allowsetreadperm ? $readperm : 0;
- $isanonymous = $isanonymous && $allowanonymous ? 1 : 0;
- $price = intval($price);
- $price = $maxprice && !$special ? ($price <= $maxprice ? $price : $maxprice) : 0;
- if(!$typeid && $forum['threadtypes']['required'] && !$special) {
- exit('未填写主题分类');
- }
- $discuz_user=$_POST['username'];
- $query =$db->query("SELECT uid,password,secques FROM {$tablepre}members m WHERE m.username='$discuz_user'");
- if ($rs=$db->fetch_row($query)){
- list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
- }
- else
- {
- exit('不存在的用户名'.$discuz_user);
- }
- $messages = explode("|||",$message);
- $mc = count($messages);
- $replycount = $mc -1; //回复次数
- $author = !$isanonymous ? $discuz_user : '';
- $moderated = $digest || $displayorder > 0 ? 1 : 0;
- //$attachment = $_POST['att'];
- $subscribed = !empty($emailnotify) && $discuz_uid ? 1 : 0;
- $supe_pushstatus = $supe['status'] && $forum['supe_pushsetting']['status'] == 1 && !$modnewthreads ? '1' : '0';
- $sgidadd1 = $sgidadd2 = '';
- if($iscircle) {
- $sgidadd1 = ', sgid';
- $sgidadd2 = ", '$sgid'";
- }
- //这里选择文件类型
- function get_filetype($type)
- {
- $filetype['chm']='application/octet-stream';
- $filetype['ppt']='application/vnd.ms-powerpoint';
- $filetype['xls']='application/vnd.ms-excel';
- $filetype['doc']='application/msword';
- $filetype['exe']='application/octet-stream';
- $filetype['rar']='application/octet-stream';
- $filetype['js']="javascript/js";
- $filetype['css']="text/css";
- $filetype['hqx']="application/mac-binhex40";
- $filetype['bin']="application/octet-stream";
- $filetype['oda']="application/oda";
- $filetype['pdf']="application/pdf";
- $filetype['ai']="application/postsrcipt";
- $filetype['eps']="application/postsrcipt";
- $filetype['es']="application/postsrcipt";
- $filetype['rtf']="application/rtf";
- $filetype['mif']="application/x-mif";
- $filetype['csh']="application/x-csh";
- $filetype['dvi']="application/x-dvi";
- $filetype['hdf']="application/x-hdf";
- $filetype['nc']="application/x-netcdf";
- $filetype['cdf']="application/x-netcdf";
- $filetype['latex']="application/x-latex";
- $filetype['ts']="application/x-troll-ts";
- $filetype['src']="application/x-wais-source";
- $filetype['zip']="application/zip";
- $filetype['bcpio']="application/x-bcpio";
- $filetype['cpio']="application/x-cpio";
- $filetype['gtar']="application/x-gtar";
- $filetype['shar']="application/x-shar";
- $filetype['sv4cpio']="application/x-sv4cpio";
- $filetype['sv4crc']="application/x-sv4crc";
- $filetype['tar']="application/x-tar";
- $filetype['ustar']="application/x-ustar";
- $filetype['man']="application/x-troff-man";
- $filetype['sh']="application/x-sh";
- $filetype['tcl']="application/x-tcl";
- $filetype['tex']="application/x-tex";
- $filetype['texi']="application/x-texinfo";
- $filetype['texinfo']="application/x-texinfo";
- $filetype['t']="application/x-troff";
- $filetype['tr']="application/x-troff";
- $filetype['roff']="application/x-troff";
- $filetype['shar']="application/x-shar";
- $filetype['me']="application/x-troll-me";
- $filetype['ts']="application/x-troll-ts";
- $filetype['gif']="image/gif";
- $filetype['jpeg']="image/pjpeg";
- $filetype['jpg']="image/pjpeg";
- $filetype['jpe']="image/pjpeg";
- $filetype['ras']="image/x-cmu-raster";
- $filetype['pbm']="image/x-portable-bitmap";
- $filetype['ppm']="image/x-portable-pixmap";
- $filetype['xbm']="image/x-xbitmap";
- $filetype['xwd']="image/x-xwindowdump";
- $filetype['ief']="image/ief";
- $filetype['tif']="image/tiff";
- $filetype['tiff']="image/tiff";
- $filetype['pnm']="image/x-portable-anymap";
- $filetype['pgm']="image/x-portable-graymap";
- $filetype['rgb']="image/x-rgb";
- $filetype['xpm']="image/x-xpixmap";
- $filetype['txt']="text/plain";
- $filetype['c']="text/plain";
- $filetype['cc']="text/plain";
- $filetype['h']="text/plain";
- $filetype['html']="text/html";
- $filetype['htm']="text/html";
- $filetype['htl']="text/html";
- $filetype['rtx']="text/richtext";
- $filetype['etx']="text/x-setext";
- $filetype['tsv']="text/tab-separated-values";
- $filetype['mpeg']="video/mpeg";
- $filetype['mpg']="video/mpeg";
- $filetype['mpe']="video/mpeg";
- $filetype['avi']="video/x-msvideo";
- $filetype['qt']="video/quicktime";
- $filetype['mov']="video/quicktime";
- $filetype['moov']="video/quicktime";
- $filetype['movie']="video/x-sgi-movie";
- $filetype['au']="audio/basic";
- $filetype['snd']="audio/basic";
- $filetype['wav']="audio/x-wav";
- $filetype['aif']="audio/x-aiff";
- $filetype['aiff']="audio/x-aiff";
- $filetype['aifc']="audio/x-aiff";
- $filetype['swf']="application/x-shockwave-flash";
- return $filetype[$type];
- }
- //这里时间设定
- $nowtp = 0;
- if($replycount > 0 && $replycount < 6) {
- $mintp = 600;
- $maxtp = 1800;
- $nowtp = 7200;
- $viewts = rand(400,800);
- }
- if($replycount > 5 && $replycount < 11) {
- $mintp = 300;
- $maxtp = 1000;
- $nowtp = 7200;
- $viewts = rand(500,1200);
- }
- if($replycount > 10 && $replycount < 21) {
- $mintp = 600;
- $maxtp = 6000;
- $nowtp = 86400;
- $viewts = rand(800,1500);
- }
- if($replycount > 20 && $replycount < 31) {
- $mintp = 600;
- $maxtp = 6000;
- $nowtp = 100000;
- $viewts = rand(1200,2000);
- }
- if($replycount > 30 && $replycount < 41) {
- $mintp = 600;
- $maxtp = 6000;
- $nowtp = 180000;
- $viewts = rand(1800,3000);
- }
- if($replycount > 40 && $replycount < 51) {
- $mintp = 1800;
- $maxtp = 14400;
- $nowtp = 600000;
- $viewts = rand(2500,5000);
- }
- if($replycount > 50) {
- $replycount = 50;
- $mintp = 1800;
- $maxtp = 14400;
- $nowtp = 600000;
- $viewts = rand(2500,5000);
- }
- //时间设定结束
- //这里是附件处理程序
- function makeatt($abc,$tid,$pid,$timestamp,$uid) {
- global $db, $tablepre,$attdir,$filedir,$allowfile,$thumbstatus, $thumbwidth, $thumbheight,$maxattachsize, $maxsizeperday,$postp;
- //先处理里边的图片
- $text=$abc;
- //echo $uid;exit;
- $pat="/\[img\][^\[]+\[\/img\]/i"; //获得图片的代码
- preg_match_all($pat,$text,$m);
- $count=count($m[0]);
- //echo $count;
- //start if
- if ($count) {//如果有图片,执行下边操作
- $isimage=1;
- //for start
- for($i=0;$i<$count;$i++) {
- $pat2="/(.*\/)*(\d+.\w+)/is";
- preg_match($pat2,$m[0][$i],$filename);
- $filetype='image/jpeg';
- if(!file_exists('attachments/'.$attdir.$filename[2])){continue;}
- $filesize=filesize('./attachments/'.$attdir.$filename[2]);
- if($filesize==0){continue;}
- //echo $filename[2];
- $fullname=$attdir.$filename[2];
- //加水印开始
- require_once DISCUZ_ROOT.'./include/image.class.php';
- @$fp = fopen($fullname, 'rb');
- @flock($fp, 2);
- @$attachedfile = fread($fp, $filesize);
- @fclose($fp);
- $target = './attachments/'.$attdir.$filename[2];
- //echo $target;
- $image = new Image($attachedfile, $target, $attach);
- if($image->imagecreatefromfunc && $image->imagefunc) {
- $image->Thumb($thumbwidth, $thumbheight);
- $image->Watermark();
- }
- //加水印结束
- $downloads=rand(10,300);
- $db->query("INSERT INTO {$tablepre}attachments (aid, tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid) VALUES ('','$tid','$pid','$postp','','','$filename[2]','','$filetype','$filesize','$fullname','$downloads','$isimage','$uid')");
- $aid = $db->insert_id(); //获得附件aid
- $zhbq='[attach]'.$aid.'[/attach]';
- //echo $zhbq;
- $text=str_replace($m[0][$i],$zhbq,$text); //将图片代码换成附件代码
- }
- //end for
- $db->query("update {$tablepre}posts set message='$text',attachment=attachment+$count where pid='$pid'", 'UNBUFFERED');//更新内容和附件数
- $db->query("UPDATE {$tablepre}threads SET lastposter ='$uid' WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
- $db->query("UPDATE {$tablepre}threads SET attachment='1' WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
- }
- //end if
- //这里开始处理附件
- $isimage=0;
- $pat3="/\[url=(\/.*?)*(.*?)?(\d+)\.(\w+)\](.*?)\[\/url\]/i";
- preg_match_all($pat3,$text,$fj);
- $kcount=count($fj[0]);
- if ($kcount) {//如果有url标签,则处理
- for($i=0;$i<$kcount;$i++) {
- preg_match($pat3,$fj[0][$i],$allowf);
- $fullname=$allowf[3].".".$allowf[4];
- $houzhui=Strtolower($allowf[4]);
- $allowfile = array('gif','jpeg','jpeg','bmp','jpg'); //禁止转化为附件的文件类型
- if(in_array($houzhui,$allowfile)){//如果不是允许的类型则不处理
- $img='attachments/'.$attdir.$allowf[3].'.'.$allowf[4];
- echo $img;
- if(file_exists($img)){
- $imgcode='[url='.$img.']'.$allowf[5].'[/url]';
- $text=str_replace($fj[0][$i],$allowf[5],$text);
- continue;
- }
- }
- if(!file_exists('attachments/'.$filedir.$fullname)){continue;}
- $filesize=filesize('./attachments/'.$filedir.$fullname);
- $filepath=$filedir.$fullname;
- $filename=str_replace($allowf[4],'',$allowf[5]).'.'.$allowf[4];
- $downloads=rand(1,300);
- $filetype=get_filetype($allowf[3]);
- if(!$filetype){$filetype='application/octet-stream';}
- $db->query("INSERT INTO {$tablepre}attachments (aid, tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid) VALUES ('','$tid','$pid','$postp','','','$filename','','$filetype','$filesize','$filepath','$downloads','$isimage','$uid')");
- $aid = $db->insert_id(); //获得附件aid
- $zhbq='[attach]'.$aid.'[/attach]';
- $text=str_replace($fj[0][$i],$zhbq,$text); //将文件代码换成附件代码
- }
- $db->query("update {$tablepre}posts set message='$text',attachment=attachment+$count where pid='$pid'", 'UNBUFFERED');//更新内容和附件数
- $db->query("update {$tablepre}posts set attachment=attachment+$kcount where pid='$pid'", 'UNBUFFERED');
- $db->query("UPDATE {$tablepre}threads SET lastposter ='$uid' WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
- $db->query("UPDATE {$tablepre}threads SET attachment='1' WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
- }
- //附件处理结束
- }
- //这里是附件处理程序结束
- //过滤本版块中标题重复的帖子 begin
- $ForbidAdd='';
- $ForbidAdd=$db->result_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND subject='$subject' ORDER BY tid DESC LIMIT 1");
- if($ForbidAdd) {
- exit('本主题已存在');
- }
- //过滤本版块中标题重复的帖子 end
- // 插入一条记录
- $views=rand(30,300);
- $postp = $timestamp - $nowtp;
- $db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, blog, special, attachment, subscribed, moderated, supe_pushstatus $sgidadd1,views)
- VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '$subject', '$postp', '$timestamp', '$author', '$displayorder', '$digest', '$blog', '$special', '$attachment', '$subscribed', '$moderated', '$supe_pushstatus' $sgidadd2,'$views')");
- $tid = $db->insert_id(); //获得tid
- if($subscribed) {
- $db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
- VALUES ('$discuz_uid', '$tid', '$postp', '$postp')", 'UNBUFFERED');
- }
- $db->query("REPLACE INTO {$tablepre}mythreads (uid, tid, dateline, special) VALUES ('$discuz_uid', '$tid', '$postp', '$special')", 'UNBUFFERED');
- if($moderated) {
- updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG'));
- updatemodworks(($displayorder > 0 ? 'STK' : 'DIG'), 1);
- }
- if($forum['threadtypes']['special'][$typeid] && $optiondata && is_array($optiondata)) {
- foreach($optiondata as $optionid => $value) {
- $db->query("INSERT INTO {$tablepre}typeoptionvars (typeid, tid, optionid, value, expiration)
- VALUES ('$typeid', '$tid', '$optionid', '$value', '".($typeexpiration ? $postp + $typeexpiration : 0)."')");
- }
- }
- $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
- $smileyoff = checksmilies($message, !empty($smileyoff));
- $parseurloff = !empty($parseurloff);
- $htmlon = bindec(($tagstatus && !empty($tagoff) ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0));
- $pinvisible = $modnewthreads ? -2 : 0;
- $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
- VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$postp', '".$messages[0]."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
- $pid = $db->insert_id();//这里是获得发布的帖子的id
- //下边是处理附件
- makeatt($messages[0],$tid,$pid,$timestamp,$discuz_uid); //处理主题的附件
- if($tagstatus && $tags != '') {
- $tags = str_replace(array(chr(0xa1).chr(0xa1), chr(0xa1).chr(0x40), chr(0xe3).chr(0x80).chr(0x80)), ' ', $tags);
- $tagarray = array_unique(explode(' ', censor($tags)));
- $tagcount = 0;
- foreach($tagarray as $tagname) {
- $tagname = trim($tagname);
- if(preg_match('/^([\x7f-\xff_-]|\w){3,20}$/', $tagname)) {
- $query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'");
- if($db->num_rows($query)) {
- if(!$tagstatus = $db->result($query, 0)) {
- $db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED');
- }
- } else {
- $db->query("INSERT INTO {$tablepre}tags (tagname, closed, total)
- VALUES ('$tagname', 0, 1)", 'UNBUFFERED');
- $tagstatus = 0;
- }
- if(!$tagstatus) {
- $db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED');
- }
- $tagcount++;
- if($tagcount > 4) {
- unset($tagarray);
- break;
- }
- }
- }
- }
- $tradeaid = 0;
- if($attachment) {
- $searcharray = $pregarray = $replacearray = array();
- foreach($attachments as $key => $attach) {
- $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
- VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
- $searcharray[] = '[local]'.$localid[$key].'[/local]';
- $pregarray[] = '/\[localimg=(\d{1,3}),(\d{1,3})\]'.$localid[$key].'\[\/localimg\]/is';
- $replacearray[] = '[attach]'.$db->insert_id().'[/attach]';
- }
- $message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
- $db->query("UPDATE {$tablepre}posts SET message='$message' WHERE pid='$pid'");
- updatecredits($discuz_uid, $postattachcredits, count($attachments));
- }
- if($iscircle && $sgid) {
- supe_dbconnect();
- $query = $supe['db']->query("UPDATE {$supe[tablepre]}groups SET lastpost='$postp' WHERE gid='$sgid'", 'SILENT');
- }
- if($modnewthreads) {
- $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
- } else {
- if($digest) {
- foreach($digestcredits as $id => $addcredits) {
- $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits;
- }
- }
- updatepostcredits('+', $discuz_uid, $postcredits);
- $subject = str_replace("\t", ' ', $subject);
- $lastpost = "$tid\t$subject\t$timestamp\t$author";
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
- if($forum['type'] == 'sub') {
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
- }
- }
- echo("成功|".$tid);
- }
- //上边是发表主题
- if($replycount)
- {
- $discuz_action = 12;
- require_once DISCUZ_ROOT.'./include/forum.func.php';
- print_r($replyuser);
- $replyusers = explode("|",$replyusers);
- $reusercount = count($replyusers);
- for($re=1;$re<=$replycount;$re++)
- {
- $index = rand(1,$reusercount-1);
- $discuz_user = $replyusers[$index];
- if($discuz_user==$pre_user)
- {$discuz_user = $replyusers[0];}
- $pre_user = $discuz_user;
- $query =$db->query("SELECT uid,password,secques FROM {$tablepre}members m WHERE m.username='$discuz_user'");
- if ($rs=$db->fetch_row($query)){
- list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
- }
- else
- {
- echo('不存在的用户名'.$discuz_user);
- continue;
- }
- if(".$messages[$re]." == '') {
- continue;
- }
- $attachnum = 0;
- if($allowpostattach && !empty($_FILES['attach']) && is_array($_FILES['attach'])) {
- foreach($_FILES['attach']['name'] as $attachname) {
- if($attachname != '') {
- $attachnum ++;
- }
- }
- $attachnum && checklowerlimit($postattachcredits, $attachnum);
- } else {
- $_FILES = array();
- }
- $attachments = $attachnum ? attach_upload() : array();
- $attachment = empty($attachments) ? 0 : 1;
- $subscribed = $thread['subscribed'] && $timestamp - $thread['lastpost'] < 7776000;
- $newsubscribed = !empty($emailnotify) && $discuz_uid;
- if($subscribed && !$modnewreplies) {
- $db->query("UPDATE {$tablepre}subscriptions SET lastpost='$timestamp' WHERE tid='$tid' AND uid<>'$discuz_uid'", 'UNBUFFERED');
- }
- if($newsubscribed) {
- $db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
- VALUES ('$discuz_uid', '$tid', '".($modnewreplies ? $thread['lastpost'] : $timestamp)."', '$timestamp')", 'UNBUFFERED');
- }
- $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
- $smileyoff = checksmilies($message, !empty($smileyoff));
- $parseurloff = !empty($parseurloff);
- $htmlon = $allowhtml && !empty($htmlon) ? 1 : 0;
- $usesig = !empty($usesig) ? 1 : 0;
- $isanonymous = $allowanonymous && !empty($isanonymous)? 1 : 0;
- $author = empty($isanonymous) ? $discuz_user : '';
- $pinvisible = $modnewreplies ? -2 : 0;
- $timestamp = $timestamp + 1;
-
- $temptp = $postp;
- $randt = rand($mintp,$maxtp);
- $postp = $temptp + $randt;
- if($postp > $timestamp) {
- $postp = $timestamp;
- }
- $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
- VALUES ('$fid', '$tid', '0', '$discuz_user', '$discuz_uid', '', '$postp', '".$messages[$re]."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
- $pid = $db->insert_id();
- makeatt($messages[$re],$tid,$pid,$timestamp,$discuz_uid);
- $db->query("REPLACE INTO {$tablepre}myposts (uid, tid, pid, position, dateline, special) VALUES ('$discuz_uid', '$tid', '$pid', '".($thread['replies'] + 1)."', '$postp', '$special')", 'UNBUFFERED');
- $tradeaid = 0;
- if($modnewreplies) {
- $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
- if($newsubscribed) {
- $db->query("UPDATE {$tablepre}threads SET subscribed='1' WHERE tid='$tid'", 'UNBUFFERED');
- }
-
- } else {
- $db->query("UPDATE {$tablepre}threads SET lastposter='$author', lastpost='$postp', replies=replies+1 ".($attachment ? ', attachment=\'1\'' : '').", subscribed='".($subscribed || $newsubscribed ? 1 : 0)."' WHERE tid='$tid'", 'UNBUFFERED');
- updatepostcredits('+', $discuz_uid, $replycredits);
- $lastpost = "$thread[tid]\t".addslashes($thread['subject'])."\t$postp\t$author";
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
- if($forum['type'] == 'sub') {
- $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
- }
- }
- echo "成功回复";
- }
- }
- ?>
复制代码 |
|