求助~Discuz!7.1/2随机用户名/时间/图片附件接口
求助~DZ从7.0升级到7.1以后,采集发布以后,列表可以显示是附件但是问题是内容里面的图片无法正常显示,图片前面强制加入了域名.相当于是输入了两次域名一样.这种情况该怎么解决啊...
本帖最后由 wionch 于 2010-5-7 18:23 编辑
帖子内容
图也传上去了.
这是采集到的内容也发布成功了
第一个强制加入了域名 要解决这个问题 一个是在第二页的规则编辑里,标签设置里,取消自动补充网址 应该不是模块问题 是dz的问题 回复 3# afanfan2007
怎么取消自动补充网址??
要怎么修改啊? 不行啊.我重新了DZ.还是同样的问题啊....各位高手麻烦指点怎么修改啊... 在规则里面 这里是代码..要怎么改呀~!!!
<?php
date_default_timezone_set('Etc/GMT-8');//转换为北京时间
//error_reporting(E_ALL);
/*
火车采集器WEB发布接口文件 Discuz!7.x正式版
请将该文件直接上传至论坛根目录
为防止别人恶意使用该文件,建议改名后使用,改名后同时更改模块内相应文件名位置
广告时间:
火车头采集器商业版出售,需要的朋友可以联系我!
懷念過去↑文 联系qq:58607911
*/
date_default_timezone_set('Etc/GMT-8');//转换为北京时间
$replyusers="admin|admin2|admin3";
$attdir="tupian/"; //附件图片保存目录,本地整个文件夹拷入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</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 = $db->fetch_array($query);
$navigation = "» <a href=\"forumdisplay.php?fid=$fup\">$fup</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'] && (!$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') {
//复制newthread.inc.php
$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,secquesFROM {$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);
}
//过滤本版块中标题重复的帖子 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
//设置时间
$today=mktime(0,0,0,date("m"),date("d"),date("Y"));
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
$time=rand($today,$tomorrow);
//时间设置结束
$messages = explode("|||",$message);
$mc = count($messages);
$replycount = $mc -1;
$author = !$isanonymous ? $discuz_user : '';
$moderated = $digest || $displayorder > 0 ? 1 : 0;
$attachment = ($allowpostattach && $attachments = attach_upload()) ? 1 : 0;
$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'";
}
$db->query("INSERT INTO {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, special, attachment,moderated, supe_pushstatus $sgidadd1)
VALUES ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '$subject', '$time', '$time', '$author', '$displayorder', '$digest', '$special', '$attachment','$moderated', '$supe_pushstatus' $sgidadd2)");
$tid = $db->insert_id();
if($subscribed) {
$db->query("REPLACE INTO {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
VALUES ('$discuz_uid', '$tid', '$time', '$time')", '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 ? $time + $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', '$time', '".$messages."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
$pid = $db->insert_id();
function aimg($abc,$tid,$pid,$time,$uid) {
global $db, $tablepre,$attdir;
$text=$abc;
$pat="/\[^\[]+\[\/img\]/i"; //获得图片的代码
preg_match_all($pat,$text,$m);
$count=count($m);
if ($count) {
$isimage=1;
for($i=0;$i<$count;$i++) {
$pat2="/\w+[.]\w+/is";
preg_match($pat2,$m[$i],$filename);
$filetype='image/jpeg';
$filesize=filesize('./attachments/'.$attdir.$filename);
$fullname=$attdir.$filename;
$downloads=rand(1,30);
$db->query("INSERT INTO {$tablepre}attachments (aid, tid, pid, dateline, readperm, price, filename,filetype, filesize, attachment, downloads, isimage, uid) VALUES ('','$tid','$pid','$time','','','$filename','$filetype','$filesize','$fullname','$downloads','$isimage','$uid')");
$aid = $db->insert_id();
$zhbq=''.$aid.'';
$text=str_replace($m[$i],$zhbq,$text);
}
$db->query("update {$tablepre}posts set message='$text',attachment=attachment+$count where pid='$pid'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SETattachment='1'WHERE tid='$tid'", 'UNBUFFERED');
}
}
aimg($messages,$tid,$pid,$time,$uid);
$randatt=$_POST['anyatt'];
$pat3="/<a href=[^<>]+>[^<>]+<\/a>/i";
preg_match_all($pat3,$randatt,$fj);
$kcount=count($fj);
if ($kcount) {
for($i=0;$i<$kcount;$i++) {
$pat4="/\/(.*?)['|\"]/i";
preg_match($pat4,$fj[$i],$temp);
$fullname=substr($temp,0,-1);
$filesize=filesize('./attachments/'.$fullname);
$filename=basename($fullname);
$downloads=rand(1,30);
$db->query("INSERT INTO {$tablepre}attachments (aid, tid, pid, dateline, readperm, price, filename,filetype, filesize, attachment, downloads, isimage, uid) VALUES ('','$tid','$pid','$time','','','$filename','','$filesize','$fullname','$downloads','$isimage','$uid')");
$aid = $db->insert_id();
}
$db->query("update {$tablepre}posts set attachment=attachment+$kcount where pid='$pid'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SETattachment='1'WHERE tid='$tid'", 'UNBUFFERED');
}
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,filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$time', '$attach', '$attach', '$attach','$attach', '$attach', '$attach', '0', '$attach', '$attach', '$attach', '$attach')");
$searcharray[] = ''.$localid[$key].'';
$pregarray[] = '/\'.$localid[$key].'\[\/localimg\]/is';
$replacearray[] = ''.$db->insert_id().'';
}
$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}groups SET lastpost='$time' 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$time\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'", '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;}
$pre_user = $discuz_user;
$query =$db->query("SELECT uid,password,secquesFROM {$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;
}
$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'] && $time - $thread['lastpost'] < 7776000;
$newsubscribed = !empty($emailnotify) && $discuz_uid;
if($subscribed && !$modnewreplies) {
$db->query("UPDATE {$tablepre}subscriptions SET lastpost='$time' 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'] : $time)."', '$time')", '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;
//回复帖子的时间设置
$timeadd = rand(1,3600);
$time = $time + $timeadd;
//回复帖子的时间设置
$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', '', '$time', '".$messages[$re]."', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment')");
$pid = $db->insert_id();
/*
$db->query("REPLACE INTO {$tablepre}myposts (uid, tid, pid, position, dateline, special) VALUES ('$discuz_uid', '$tid', '$pid', '".($thread['replies'] + 1)."', '$time', '$special')", 'UNBUFFERED');
*/
$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,filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$time', '$attach', '$attach', '$attach','$attach', '$attach', '$attach', '0', '$attach', '$attach', '$attach', '$attach')");
$searcharray[] = ''.$localid[$key].'';
$pregarray[] = '/\'.$localid[$key].'\[\/localimg\]/is';
$insertid = $db->insert_id();
$replacearray[] = ''.$insertid.'';
}
if(!empty($trade) && $thread['special'] == 2 && !empty($_FILES['tradeattach']['tmp_name'])) {
$tradeaid = $insertid;
}
$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($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='$time', replies=replies+1 ".( $attachment ? ", attachment='1'" : "" ).( " WHERE tid='".$tid."'" ), 'UNBUFFERED');
updatepostcredits('+', $discuz_uid, $replycredits);
$lastpost = "$thread\t".addslashes($thread['subject'])."\t$time\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'", 'UNBUFFERED');
}
}
echo "成功回复";
}
}
//}
/*elseif($action == 'reply') {
require_once DISCUZ_ROOT.'./include/newreply.inc.php';
} elseif($action == 'edit') {
require_once DISCUZ_ROOT.'./include/editpost.inc.php';
} elseif($action == 'import') {
require_once DISCUZ_ROOT.'./include/supesite_import.inc.php';
} elseif($action == 'newtrade') {
require_once DISCUZ_ROOT.'./include/newtrade.inc.php';
}
*/
?> 不需要 改代码,是说规则。任务规则
页:
[1]
2