火车采集器软件交流官方论坛

 找回密码
 加入会员
搜索
火车采集器V9版免费下载火车浏览器 - 可视采集,万能群发,全自动脚本工具
查看: 3368|回复: 5

discuz 6.1.0的发布附件和图片及有时间间隔的接口源码

[复制链接]
发表于 2008-12-5 22:08:35 | 显示全部楼层 |阅读模式
这个是整合其它一些接口功能制作的.当然,本身也并不是完美,Dz7.0出来后打算做下改进.有什么好的意见请说.

  1. <?php
  2. /*
  3. discuz6.1随机接口文件,支持任意文件附件形式发布
  4. */
  5. $replyusers = "admin|999|aaa|bbb|ccc|ddd|eee";  //随机回复用户名,请改成你论坛存在的用户
  6. $filedir='files/'; //这里是文件的在attachments目录下的保存目录
  7. $attdir="images/";    //附件图片保存目录,本地整个文件夹拷入attachments目录;必须先上传文件再发布。
  8. //$isimage=0;
  9. define('CURSCRIPT', 'post');
  10. define('NOROBOT', TRUE);
  11. require_once './include/common.inc.php';
  12. require_once DISCUZ_ROOT.'./include/post.func.php';
  13. $_DTYPE = $checkoption = $optionlist = array();
  14. if($typeid) {
  15. threadtype_checkoption();
  16. }
  17. require_once DISCUZ_ROOT.'./include/discuzcode.func.php';
  18. $navigation = $navtitle = $thread = '';
  19. $navigation = "&raquo; <a href="forumdisplay.php?fid=$fid".($extra ? '&'.preg_replace("/^(&)*/", '', $extra) : '')."">$forum[name]</a> $navigation";
  20. $navtitle = $navtitle.strip_tags($forum['name']).' - ';
  21. if($forum['type'] == 'sub') {
  22. $query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
  23. $fup = $db->fetch_array($query);
  24. $navigation = "&raquo; <a href="forumdisplay.php?fid=$fup[fid]">$fup[name]</a> $navigation";
  25. $navtitle = $navtitle.strip_tags($fup['name']).' - ';
  26. }
  27. $special = empty($special) || !is_numeric($special) || $special < 0 || $special > 6 ? 0 : intval($special);
  28. $allowpostattach = !empty($forum['allowpostattach']) || (!$forum['postattachperm'] && $allowpostattach) || ($forum['postattachperm'] && forumperm($forum['postattachperm']));
  29. $attachextensions = $forum['attachextensions'] ? $forum['attachextensions'] : $attachextensions;
  30. $enctype = $allowpostattach ? 'enctype="multipart/form-data"' : '';
  31. $maxattachsize_kb = $maxattachsize / 1000;
  32. $postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
  33. $replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
  34. $digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
  35. $postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];
  36. $maxprice = isset($extcredits[$creditstrans]) ? $maxprice : 0;
  37. $extra = rawurlencode($extra);
  38. $blogcheck = empty($isblog) && empty($addtoblog) ? '' : 'checked="checked"';
  39. $notifycheck = empty($emailnotify) ? '' : 'checked="checked"';
  40. $stickcheck = empty($sticktopic) ? '' : 'checked="checked"';
  41. $digestcheck = empty($addtodigest) ? '' : 'checked="checked"';
  42. $subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
  43. $message = isset($message) ? censor(trim($message)) : '';
  44. $readperm = isset($readperm) ? intval($readperm) : 0;
  45. $price = isset($price) ? intval($price) : 0;
  46. $urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = '';
  47. $seccodecheck = ($seccodestatus & 4) && (!$seccodedata['minposts'] || $posts < $seccodedata['minposts']);
  48. $secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts < $secqaa['minposts']);
  49. if($iscircle = $supe['status'] && $supe['circlestatus'] && $forum['status'] == 2) {
  50. unset($forum['threadtypes']);
  51. }
  52. $allowpostpoll = $allowpost && $allowpostpoll && ($forum['allowpostspecial'] & 1);
  53. $allowposttrade = $allowpost && $allowposttrade && ($forum['allowpostspecial'] & 2);
  54. $allowpostreward = $allowpost && $allowpostreward && ($forum['allowpostspecial'] & 4) && isset($extcredits[$creditstrans]);
  55. $allowpostactivity = $allowpost && $allowpostactivity && ($forum['allowpostspecial'] & 8);
  56. $allowpostdebate = $allowpost && $allowpostdebate && ($forum['allowpostspecial'] & 16);
  57. $allowpostvideo = $allowpost && $allowpostvideo && ($forum['allowpostspecial'] & 32) && $videoopen;
  58. $allowanonymous = $forum['allowanonymous'] || $allowanonymous ? 1 : 0;
  59. $editorid = 'posteditor';
  60. $editoroptions = str_pad(decbin($editoroptions), 2, 0, STR_PAD_LEFT);
  61. $editormode = $editormode == 2 ? $editoroptions{0} : $editormode;
  62. $allowswitcheditor = $editoroptions{1};
  63. $advanceeditor = $special ? 0 : 1;
  64. $previewdisplay = !empty($previewpost) ? '' : 'none';
  65. if($action == 'newthread') {
  66. $discuz_action = 11;
  67. if(empty($forum['fid']) || $forum['type'] == 'group') {
  68. exit('未选择版块或版块不能发帖');
  69. }
  70. $isblog = empty($isblog) ? '' : 'yes';
  71. if($subject == '' || $message == '') {
  72.   exit('标题或内容为空');
  73. }
  74. if($post_invalid = checkpost()) {
  75.   exit('标题或内容超过发帖限制');
  76. }
  77. if($allowpostattach && is_array($_FILES['attach'])) {
  78.   foreach($_FILES['attach']['name'] as $attachname) {
  79.    if($attachname != '') {
  80.     checklowerlimit($postattachcredits);
  81.     break;
  82.    }
  83.   }
  84. }
  85. $typeid = isset($typeid) && isset($forum['threadtypes']['types'][$typeid]) ? $typeid : 0;
  86. $iconid = !empty($iconid) && isset($_DCACHE['icons'][$iconid]) ? $iconid : 0;
  87. $displayorder = $modnewthreads ? -2 : (($forum['ismoderator'] && !empty($sticktopic)) ? 1 : 0);
  88. $digest = ($forum['ismoderator'] && !empty($addtodigest)) ? 1 : 0;
  89. $blog = $allowuseblog && $forum['allowshare'] && !empty($addtoblog) ? 1 : 0;
  90. $readperm = $allowsetreadperm ? $readperm : 0;
  91. $isanonymous = $isanonymous && $allowanonymous ? 1 : 0;
  92. $price = intval($price);
  93. $price = $maxprice && !$special ? ($price <= $maxprice ? $price : $maxprice) : 0;
  94. if(!$typeid && $forum['threadtypes']['required'] && !$special) {
  95.   exit('未填写主题分类');
  96. }
  97. $discuz_user=$_POST['username'];
  98. $query =$db->query("SELECT uid,password,secques  FROM {$tablepre}members m WHERE m.username='$discuz_user'");
  99. if ($rs=$db->fetch_row($query)){
  100. list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
  101. }
  102. else
  103. {
  104. exit('不存在的用户名'.$discuz_user);
  105. }
  106. $messages = explode("|||",$message);
  107. $mc = count($messages);
  108. $replycount = $mc -1; //回复次数
  109. $author = !$isanonymous ? $discuz_user : '';
  110. $moderated = $digest || $displayorder > 0 ? 1 : 0;
  111. //$attachment = $_POST['att'];
  112. $subscribed = !empty($emailnotify) && $discuz_uid ? 1 : 0;
  113. $supe_pushstatus = $supe['status'] && $forum['supe_pushsetting']['status'] == 1 && !$modnewthreads ? '1' : '0';
  114. $sgidadd1 = $sgidadd2 = '';
  115. if($iscircle) {
  116.   $sgidadd1 = ', sgid';
  117.   $sgidadd2 = ", '$sgid'";
  118. }
  119. //这里选择文件类型
  120. function get_filetype($type)
  121. {
  122. $filetype['chm']='application/octet-stream';
  123. $filetype['ppt']='application/vnd.ms-powerpoint';
  124. $filetype['xls']='application/vnd.ms-excel';
  125. $filetype['doc']='application/msword';
  126. $filetype['exe']='application/octet-stream';
  127. $filetype['rar']='application/octet-stream';
  128. $filetype['js']="javascript/js";
  129. $filetype['css']="text/css";
  130. $filetype['hqx']="application/mac-binhex40";
  131. $filetype['bin']="application/octet-stream";
  132. $filetype['oda']="application/oda";
  133. $filetype['pdf']="application/pdf";
  134. $filetype['ai']="application/postsrcipt";
  135. $filetype['eps']="application/postsrcipt";
  136. $filetype['es']="application/postsrcipt";
  137. $filetype['rtf']="application/rtf";
  138. $filetype['mif']="application/x-mif";
  139. $filetype['csh']="application/x-csh";
  140. $filetype['dvi']="application/x-dvi";
  141. $filetype['hdf']="application/x-hdf";
  142. $filetype['nc']="application/x-netcdf";
  143. $filetype['cdf']="application/x-netcdf";
  144. $filetype['latex']="application/x-latex";
  145. $filetype['ts']="application/x-troll-ts";
  146. $filetype['src']="application/x-wais-source";
  147. $filetype['zip']="application/zip";
  148. $filetype['bcpio']="application/x-bcpio";
  149. $filetype['cpio']="application/x-cpio";
  150. $filetype['gtar']="application/x-gtar";
  151. $filetype['shar']="application/x-shar";
  152. $filetype['sv4cpio']="application/x-sv4cpio";
  153. $filetype['sv4crc']="application/x-sv4crc";
  154. $filetype['tar']="application/x-tar";
  155. $filetype['ustar']="application/x-ustar";
  156. $filetype['man']="application/x-troff-man";
  157. $filetype['sh']="application/x-sh";
  158. $filetype['tcl']="application/x-tcl";
  159. $filetype['tex']="application/x-tex";
  160. $filetype['texi']="application/x-texinfo";
  161. $filetype['texinfo']="application/x-texinfo";
  162. $filetype['t']="application/x-troff";
  163. $filetype['tr']="application/x-troff";
  164. $filetype['roff']="application/x-troff";
  165. $filetype['shar']="application/x-shar";
  166. $filetype['me']="application/x-troll-me";
  167. $filetype['ts']="application/x-troll-ts";
  168. $filetype['gif']="image/gif";
  169. $filetype['jpeg']="image/pjpeg";
  170. $filetype['jpg']="image/pjpeg";
  171. $filetype['jpe']="image/pjpeg";
  172. $filetype['ras']="image/x-cmu-raster";
  173. $filetype['pbm']="image/x-portable-bitmap";
  174. $filetype['ppm']="image/x-portable-pixmap";
  175. $filetype['xbm']="image/x-xbitmap";
  176. $filetype['xwd']="image/x-xwindowdump";
  177. $filetype['ief']="image/ief";
  178. $filetype['tif']="image/tiff";
  179. $filetype['tiff']="image/tiff";
  180. $filetype['pnm']="image/x-portable-anymap";
  181. $filetype['pgm']="image/x-portable-graymap";
  182. $filetype['rgb']="image/x-rgb";
  183. $filetype['xpm']="image/x-xpixmap";
  184. $filetype['txt']="text/plain";
  185. $filetype['c']="text/plain";
  186. $filetype['cc']="text/plain";
  187. $filetype['h']="text/plain";
  188. $filetype['html']="text/html";
  189. $filetype['htm']="text/html";
  190. $filetype['htl']="text/html";
  191. $filetype['rtx']="text/richtext";
  192. $filetype['etx']="text/x-setext";
  193. $filetype['tsv']="text/tab-separated-values";
  194. $filetype['mpeg']="video/mpeg";
  195. $filetype['mpg']="video/mpeg";
  196. $filetype['mpe']="video/mpeg";
  197. $filetype['avi']="video/x-msvideo";
  198. $filetype['qt']="video/quicktime";
  199. $filetype['mov']="video/quicktime";
  200. $filetype['moov']="video/quicktime";
  201. $filetype['movie']="video/x-sgi-movie";
  202. $filetype['au']="audio/basic";
  203. $filetype['snd']="audio/basic";
  204. $filetype['wav']="audio/x-wav";
  205. $filetype['aif']="audio/x-aiff";
  206. $filetype['aiff']="audio/x-aiff";
  207. $filetype['aifc']="audio/x-aiff";
  208. $filetype['swf']="application/x-shockwave-flash";
  209. return $filetype[$type];
  210. }
  211. //这里时间设定
  212. $nowtp = 0;
  213. if($replycount > 0 && $replycount < 6) {
  214.   $mintp = 600;
  215.   $maxtp = 1800;
  216.   $nowtp = 7200;
  217.   $viewts = rand(400,800);
  218. }
  219. if($replycount > 5 && $replycount < 11) {
  220.   $mintp = 300;
  221.   $maxtp = 1000;
  222.   $nowtp = 7200;
  223.   $viewts = rand(500,1200);
  224. }
  225. if($replycount > 10 && $replycount < 21) {
  226.   $mintp = 600;
  227.   $maxtp = 6000;
  228.   $nowtp = 86400;
  229.   $viewts = rand(800,1500);
  230. }
  231. if($replycount > 20 && $replycount < 31) {
  232.   $mintp = 600;
  233.   $maxtp = 6000;
  234.   $nowtp = 100000;
  235.   $viewts = rand(1200,2000);
  236. }
  237. if($replycount > 30 && $replycount < 41) {
  238.   $mintp = 600;
  239.   $maxtp = 6000;
  240.   $nowtp = 180000;
  241.   $viewts = rand(1800,3000);
  242. }
  243. if($replycount > 40 && $replycount < 51) {
  244.   $mintp = 1800;
  245.   $maxtp = 14400;
  246.   $nowtp = 600000;
  247.   $viewts = rand(2500,5000);
  248. }
  249. if($replycount > 50) {
  250.   $replycount = 50;
  251.   $mintp = 1800;
  252.   $maxtp = 14400;
  253.   $nowtp = 600000;
  254.   $viewts = rand(2500,5000);
  255. }
  256. //时间设定结束
  257. //这里是附件处理程序
  258. function makeatt($abc,$tid,$pid,$timestamp,$uid) {  
  259. global $db, $tablepre,$attdir,$filedir,$allowfile,$thumbstatus, $thumbwidth, $thumbheight,$maxattachsize, $maxsizeperday,$postp;
  260. //先处理里边的图片
  261. $text=$abc;
  262. //echo $uid;exit;
  263. $pat="/\[img\][^\[]+\[\/img\]/i"; //获得图片的代码
  264. preg_match_all($pat,$text,$m);
  265. $count=count($m[0]);
  266. //echo $count;
  267. //start if
  268. if ($count) {//如果有图片,执行下边操作
  269. $isimage=1;
  270. //for start
  271. for($i=0;$i<$count;$i++) {
  272. $pat2="/(.*\/)*(\d+.\w+)/is";
  273. preg_match($pat2,$m[0][$i],$filename);
  274. $filetype='image/jpeg';
  275. if(!file_exists('attachments/'.$attdir.$filename[2])){continue;}
  276. $filesize=filesize('./attachments/'.$attdir.$filename[2]);
  277. if($filesize==0){continue;}
  278. //echo $filename[2];
  279. $fullname=$attdir.$filename[2];

  280. //加水印开始
  281. require_once DISCUZ_ROOT.'./include/image.class.php';
  282.    @$fp = fopen($fullname, 'rb');
  283.    @flock($fp, 2);
  284.    @$attachedfile = fread($fp, $filesize);
  285.    @fclose($fp);
  286.             $target = './attachments/'.$attdir.$filename[2];
  287.    //echo $target;
  288.    $image = new Image($attachedfile, $target, $attach);
  289.    if($image->imagecreatefromfunc && $image->imagefunc) {
  290.    $image->Thumb($thumbwidth, $thumbheight);
  291.    $image->Watermark();
  292.     }
  293. //加水印结束
  294. $downloads=rand(10,300);
  295. $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')");
  296. $aid = $db->insert_id(); //获得附件aid
  297. $zhbq='[attach]'.$aid.'[/attach]';
  298. //echo $zhbq;
  299. $text=str_replace($m[0][$i],$zhbq,$text);  //将图片代码换成附件代码
  300. }
  301. //end for
  302. $db->query("update {$tablepre}posts set message='$text',attachment=attachment+$count where pid='$pid'", 'UNBUFFERED');//更新内容和附件数
  303. $db->query("UPDATE {$tablepre}threads SET  lastposter ='$uid'  WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
  304. $db->query("UPDATE {$tablepre}threads SET  attachment='1'  WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
  305. }
  306. //end if
  307. //这里开始处理附件
  308. $isimage=0;
  309. $pat3="/\[url=(\/.*?)*(.*?)?(\d+)\.(\w+)\](.*?)\[\/url\]/i";
  310. preg_match_all($pat3,$text,$fj);
  311. $kcount=count($fj[0]);
  312. if ($kcount) {//如果有url标签,则处理
  313. for($i=0;$i<$kcount;$i++) {
  314. preg_match($pat3,$fj[0][$i],$allowf);
  315. $fullname=$allowf[3].".".$allowf[4];
  316. $houzhui=Strtolower($allowf[4]);
  317. $allowfile = array('gif','jpeg','jpeg','bmp','jpg'); //禁止转化为附件的文件类型
  318. if(in_array($houzhui,$allowfile)){//如果不是允许的类型则不处理
  319. $img='attachments/'.$attdir.$allowf[3].'.'.$allowf[4];
  320. echo $img;
  321. if(file_exists($img)){
  322. $imgcode='[url='.$img.']'.$allowf[5].'[/url]';
  323. $text=str_replace($fj[0][$i],$allowf[5],$text);
  324. continue;
  325. }
  326. }
  327. if(!file_exists('attachments/'.$filedir.$fullname)){continue;}
  328. $filesize=filesize('./attachments/'.$filedir.$fullname);
  329. $filepath=$filedir.$fullname;
  330. $filename=str_replace($allowf[4],'',$allowf[5]).'.'.$allowf[4];
  331. $downloads=rand(1,300);
  332. $filetype=get_filetype($allowf[3]);
  333. if(!$filetype){$filetype='application/octet-stream';}
  334. $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')");
  335. $aid = $db->insert_id(); //获得附件aid
  336. $zhbq='[attach]'.$aid.'[/attach]';
  337. $text=str_replace($fj[0][$i],$zhbq,$text);  //将文件代码换成附件代码
  338. }
  339. $db->query("update {$tablepre}posts set message='$text',attachment=attachment+$count where pid='$pid'", 'UNBUFFERED');//更新内容和附件数
  340. $db->query("update {$tablepre}posts set attachment=attachment+$kcount where pid='$pid'", 'UNBUFFERED');
  341. $db->query("UPDATE {$tablepre}threads SET  lastposter ='$uid'  WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
  342. $db->query("UPDATE {$tablepre}threads SET  attachment='1'  WHERE tid='$tid'", 'UNBUFFERED');//这里说明这个帖子有附件
  343. }
  344. //附件处理结束
  345. }
  346. //这里是附件处理程序结束
  347. //过滤本版块中标题重复的帖子 begin
  348. $ForbidAdd='';
  349. $ForbidAdd=$db->result_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND subject='$subject' ORDER BY tid DESC LIMIT 1");
  350. if($ForbidAdd) {
  351.   exit('本主题已存在');
  352. }
  353. //过滤本版块中标题重复的帖子 end

  354. // 插入一条记录
  355. $views=rand(30,300);
  356.     $postp = $timestamp - $nowtp;
  357. $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)
  358.   VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '$subject', '$postp', '$timestamp', '$author', '$displayorder', '$digest', '$blog', '$special', '$attachment', '$subscribed', '$moderated', '$supe_pushstatus' $sgidadd2,'$views')");
  359. $tid = $db->insert_id(); //获得tid
  360. if($subscribed) {
  361.   $db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
  362.    VALUES ('$discuz_uid', '$tid', '$postp', '$postp')", 'UNBUFFERED');
  363. }
  364. $db->query("REPLACE INTO {$tablepre}mythreads (uid, tid, dateline, special) VALUES ('$discuz_uid', '$tid', '$postp', '$special')", 'UNBUFFERED');
  365. if($moderated) {
  366.   updatemodlog($tid, ($displayorder > 0 ? 'STK' : 'DIG'));
  367.   updatemodworks(($displayorder > 0 ? 'STK' : 'DIG'), 1);
  368. }
  369. if($forum['threadtypes']['special'][$typeid] && $optiondata && is_array($optiondata)) {
  370.   foreach($optiondata as $optionid => $value) {
  371.    $db->query("INSERT INTO {$tablepre}typeoptionvars (typeid, tid, optionid, value, expiration)
  372.     VALUES ('$typeid', '$tid', '$optionid', '$value', '".($typeexpiration ? $postp + $typeexpiration : 0)."')");
  373.   }
  374. }
  375. $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
  376. $smileyoff = checksmilies($message, !empty($smileyoff));
  377. $parseurloff = !empty($parseurloff);
  378. $htmlon = bindec(($tagstatus && !empty($tagoff) ? 1 : 0).($allowhtml && !empty($htmlon) ? 1 : 0));
  379. $pinvisible = $modnewthreads ? -2 : 0;
  380. $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
  381.   VALUES ('$fid', '$tid', '1', '$discuz_user', '$discuz_uid', '$subject', '$postp', '".$messages[0]."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
  382. $pid = $db->insert_id();//这里是获得发布的帖子的id
  383. //下边是处理附件
  384. makeatt($messages[0],$tid,$pid,$timestamp,$discuz_uid); //处理主题的附件
  385. if($tagstatus && $tags != '') {
  386. $tags = str_replace(array(chr(0xa1).chr(0xa1), chr(0xa1).chr(0x40), chr(0xe3).chr(0x80).chr(0x80)), ' ', $tags);
  387.   $tagarray = array_unique(explode(' ', censor($tags)));
  388.   $tagcount = 0;
  389.   foreach($tagarray as $tagname) {
  390.    $tagname = trim($tagname);
  391.    if(preg_match('/^([\x7f-\xff_-]|\w){3,20}$/', $tagname)) {
  392.     $query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'");
  393.     if($db->num_rows($query)) {
  394.      if(!$tagstatus = $db->result($query, 0)) {
  395.       $db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED');
  396.      }
  397.     } else {
  398.      $db->query("INSERT INTO {$tablepre}tags (tagname, closed, total)
  399.       VALUES ('$tagname', 0, 1)", 'UNBUFFERED');
  400.      $tagstatus = 0;
  401.     }
  402.     if(!$tagstatus) {
  403.      $db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED');
  404.     }
  405.     $tagcount++;
  406.     if($tagcount > 4) {
  407.      unset($tagarray);
  408.      break;
  409.     }
  410.    }
  411.   }
  412. }
  413. $tradeaid = 0;
  414. if($attachment) {
  415.   $searcharray = $pregarray = $replacearray = array();
  416.   foreach($attachments as $key => $attach) {
  417.    $db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
  418.     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]')");
  419.    $searcharray[] = '[local]'.$localid[$key].'[/local]';
  420.    $pregarray[] = '/\[localimg=(\d{1,3}),(\d{1,3})\]'.$localid[$key].'\[\/localimg\]/is';
  421.    $replacearray[] = '[attach]'.$db->insert_id().'[/attach]';
  422.   }
  423.   $message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
  424.   $db->query("UPDATE {$tablepre}posts SET message='$message' WHERE pid='$pid'");
  425.   updatecredits($discuz_uid, $postattachcredits, count($attachments));
  426. }
  427. if($iscircle && $sgid) {
  428.   supe_dbconnect();
  429.   $query = $supe['db']->query("UPDATE {$supe[tablepre]}groups SET lastpost='$postp' WHERE gid='$sgid'", 'SILENT');
  430. }
  431. if($modnewthreads) {
  432.   $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
  433. } else {
  434.   if($digest) {
  435.    foreach($digestcredits as $id => $addcredits) {
  436.     $postcredits[$id] = (isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits;
  437.    }
  438.   }
  439.   updatepostcredits('+', $discuz_uid, $postcredits);
  440.   $subject = str_replace("\t", ' ', $subject);
  441.   $lastpost = "$tid\t$subject\t$timestamp\t$author";
  442.   $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
  443.   if($forum['type'] == 'sub') {
  444.    $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
  445.   }
  446. }
  447. echo("成功|".$tid);
  448. }
  449. //上边是发表主题

  450. if($replycount)
  451. {
  452. $discuz_action = 12;
  453. require_once DISCUZ_ROOT.'./include/forum.func.php';
  454. print_r($replyuser);
  455. $replyusers = explode("|",$replyusers);
  456. $reusercount = count($replyusers);
  457. for($re=1;$re<=$replycount;$re++)
  458. {
  459.   $index = rand(1,$reusercount-1);
  460.   $discuz_user = $replyusers[$index];
  461.   if($discuz_user==$pre_user)  
  462.   {$discuz_user = $replyusers[0];}
  463.   $pre_user = $discuz_user;
  464.   $query =$db->query("SELECT uid,password,secques  FROM {$tablepre}members m WHERE m.username='$discuz_user'");
  465. if ($rs=$db->fetch_row($query)){
  466. list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
  467. }
  468. else
  469. {
  470. echo('不存在的用户名'.$discuz_user);
  471. continue;
  472. }
  473. if(".$messages[$re]." == '') {
  474.    continue;
  475.   }
  476. $attachnum = 0;
  477. if($allowpostattach && !empty($_FILES['attach']) && is_array($_FILES['attach'])) {
  478.   foreach($_FILES['attach']['name'] as $attachname) {
  479.    if($attachname != '') {
  480.     $attachnum ++;
  481.    }
  482.   }
  483.   $attachnum && checklowerlimit($postattachcredits, $attachnum);
  484. } else {
  485.   $_FILES = array();
  486. }
  487. $attachments = $attachnum ? attach_upload() : array();
  488. $attachment = empty($attachments) ? 0 : 1;
  489. $subscribed = $thread['subscribed'] && $timestamp - $thread['lastpost'] < 7776000;
  490. $newsubscribed = !empty($emailnotify) && $discuz_uid;
  491. if($subscribed && !$modnewreplies) {
  492.   $db->query("UPDATE {$tablepre}subscriptions SET lastpost='$timestamp' WHERE tid='$tid' AND uid<>'$discuz_uid'", 'UNBUFFERED');
  493. }
  494. if($newsubscribed) {
  495.   $db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
  496.    VALUES ('$discuz_uid', '$tid', '".($modnewreplies ? $thread['lastpost'] : $timestamp)."', '$timestamp')", 'UNBUFFERED');
  497. }
  498. $bbcodeoff = checkbbcodes($message, !empty($bbcodeoff));
  499. $smileyoff = checksmilies($message, !empty($smileyoff));
  500. $parseurloff = !empty($parseurloff);
  501. $htmlon = $allowhtml && !empty($htmlon) ? 1 : 0;
  502. $usesig = !empty($usesig) ? 1 : 0;
  503. $isanonymous = $allowanonymous && !empty($isanonymous)? 1 : 0;
  504. $author = empty($isanonymous) ? $discuz_user : '';
  505. $pinvisible = $modnewreplies ? -2 : 0;
  506. $timestamp = $timestamp + 1;
  507.    
  508.     $temptp = $postp;
  509. $randt = rand($mintp,$maxtp);
  510. $postp = $temptp + $randt;
  511. if($postp > $timestamp) {
  512.   $postp = $timestamp;
  513. }

  514. $db->query("INSERT INTO {$tablepre}posts (fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment)
  515.    VALUES ('$fid', '$tid', '0', '$discuz_user', '$discuz_uid', '', '$postp', '".$messages[$re]."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
  516. $pid = $db->insert_id();

  517. makeatt($messages[$re],$tid,$pid,$timestamp,$discuz_uid);
  518. $db->query("REPLACE INTO {$tablepre}myposts (uid, tid, pid, position, dateline, special) VALUES ('$discuz_uid', '$tid', '$pid', '".($thread['replies'] + 1)."', '$postp', '$special')", 'UNBUFFERED');
  519. $tradeaid = 0;
  520. if($modnewreplies) {
  521.   $db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
  522.   if($newsubscribed) {
  523.    $db->query("UPDATE {$tablepre}threads SET subscribed='1' WHERE tid='$tid'", 'UNBUFFERED');
  524.   }
  525.   
  526. } else {
  527.   $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');
  528.   updatepostcredits('+', $discuz_uid, $replycredits);
  529.   $lastpost = "$thread[tid]\t".addslashes($thread['subject'])."\t$postp\t$author";
  530.   $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
  531.   if($forum['type'] == 'sub') {
  532.    $db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
  533.   }  
  534. }
  535. echo "成功回复";
  536. }
  537. }
  538. ?>
复制代码
发表于 2008-12-5 22:18:35 | 显示全部楼层
纯支持一下.呵
发表于 2008-12-5 22:54:11 | 显示全部楼层
发表于 2009-1-10 20:44:44 | 显示全部楼层
啥时候出7.0正式版的??
发表于 2009-3-13 08:13:09 | 显示全部楼层
怎么使用啊?
发表于 2009-3-22 20:30:04 | 显示全部楼层
好.......
您需要登录后才可以回帖 登录 | 加入会员

本版积分规则

企业微信|手机版|Archiver|火车采集器官方站 ( 皖ICP备06000549 )

GMT+8, 2026-4-25 09:25

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表