您好,欢迎访问一九零五行业门户网

火车头discuz61 完美采集的php接口文件

ps:对原文件的修改较大,程序中注释已经很详尽,这里就不多说了。
复制代码 代码如下:
$value){
//$$key = $value ;
//print($key.' = '.$value.'\n');
//}
//var_dump($_post);
//exit('end-0');
// 需要插入的数据表
// 1.cdb_threads
// 2.cdb_rewardlog // ok 悬赏记录表
// 3.cdb_mythreads
// 4.cdb_posts
// 5.cdb_tags _update
// 6.cdb_threadtags
// 7.cdb_forums _update
// 8.cdb_members _update ok 更改悬赏表
//done end !
$user_list = file('./makeuser/username.txt');
// 随机发帖的用户名单,必须是已经注册的
// 关于批量注册用户名可以参考 discuz 6.0+ 批量注册用户名
$user_list = array_map(curlandcopy, $user_list);
function curlandcopy($a){
return trim($a);
}
$replyusers = implode(|,$user_list);
//处理回复的格式
function trimandcurl($str){
$str = preg_replace('/\n\s{5,}/','', $str , 1);
$str = trim($str);
$str = checkandtranslate($str);
return $str;
}
function checkandtranslate($mess, $if_replace =1, $in_char_type='gbk', $out_char_type='utf-8'){
//if replace ?
if($if_replace){
$mess = curlandreplace($mess);
}
//if chinese gbk ?
if(preg_match('/[\x80-\xff]./', $mess) ){
$mess = mb_convert_encoding($mess, $out_char_type, $in_char_type);
}
return addslashes($mess) ;
}
function curlandreplace($message){
$replace_list = file('./makeuser/replace.txt');
foreach($replace_list as $item){
$item = preg_replace(/\s+/,||,$item);
$items = explode(||,$item);
$tmp = '';
$message = str_replace($items[0],$tmp,$message);
$message = str_replace($items[1],$items[0],$message);
$message = str_replace($tmp,$items[1],$message);
}
return $message;
}
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 = '';
//这里是新添加的代码以,开始
if ( $lid locoy )
{
// die(验证密码错误);
}
//这里是添加的代码,结束,
//rq204,q285576545,2008.7.29
$navigation = » $forum[name] $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 = » $fup[name] $navigation;
$navtitle = $navtitle.strip_tags($fup['name']).' - ';
}
$special = empty($special) || !is_numeric($special) || $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 $secqaacheck = $secqaa['status'][2] && (!$secqaa['minposts'] || $posts 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 //echo $typeid.','.','.','
if(!$typeid && $forum['threadtypes']['required'] && !$special) {
// exit('未填写主题分类');
}
$discuz_user=$_post['username'];
$discuz_user = checkandtranslate($discuz_user, 0);
$sql_tmp = select uid,password,secques from {$tablepre}members m where m.username like '%$discuz_user%';
$query =$db->query($sql_tmp);
if ($rs=$db->fetch_row($query)){
list($discuz_uid,$discuz_pw, $discuz_secques ) =$rs;
}
else
{
// exit('不存在的用户名'.$discuz_user);
exit('不存在的用户名'.$sql_tmp);
}
//var_dump($_post);exit('
this.line='.__line__);
$messages = explode(|||,$message);
//是否需要去除对最佳答案的评论
//$messages = array_merge(array_slice($messages, 0, 2), array_slice($messages, 3));
$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';
}
/*预处理数据*/
//$price = mt_rand(3,10);
$price = 0;
$views = mt_rand(30,256);
$timestamp = mt_rand(strtotime('2008-12-25') ,strtotime('2008-12-29'));
$tagstatus = 0;
$tags = ;
//已解决:
//$price = -$price;
//$closed = 1;
//未解决:
$closed = 0;
$db->query(insert into {$tablepre}threads (fid, readperm, price, iconid, typeid, author, authorid, subject, dateline, lastpost, lastposter, displayorder, digest, blog,attachment, subscribed, moderated, supe_pushstatus $sgidadd1 ,special ,closed ,views)
values ('$fid', '$readperm', '$price', '$iconid', '$typeid', '$author', '$discuz_uid', '.checkandtranslate($subject).', '$timestamp', '$timestamp', '$author', '$displayorder', '$digest', '$blog', '$attachment', '$subscribed', '$moderated', '$supe_pushstatus' $sgidadd2 ,0 ,$closed ,$views ));
$tid = $db->insert_id();
// making reward logs !
$db->query(insert into {$tablepre}rewardlog (tid,authorid,netamount,dateline) values ('$tid', '$discuz_uid', '$price', '0'));
// updating members logs !
//if minus credits ?
//$db->query(update {$tablepre}members set posts=posts+1,credits=credits+$price,lastpost='.$_server['request_time'].' where uid ='$discuz_uid' );
$db->query(update {$tablepre}members set posts=posts+1,lastpost='.$_server['request_time'].' where uid ='$discuz_uid' );
if($subscribed) {
$db->query(replace into {$tablepre}subscriptions (uid, tid, lastpost, lastnotify)
values ('$discuz_uid', '$tid', '$timestamp', '$timestamp'), 'unbuffered');
}
$db->query(replace into {$tablepre}mythreads (uid, tid, dateline, special) values ('$discuz_uid', '$tid', '$timestamp', '0'), '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 ? $timestamp + $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));
$htmlon = 1;
$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', '$timestamp', '.checkandtranslate($messages[0]).', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment'));
$pid = $db->insert_id();
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='.checkandtranslate($tagname, 0).');
if($db->num_rows($query)) {
if(!$tagstatus = $db->result($query, 0)) {
$db->query(update {$tablepre}tags set total=total+1 where tagname='.checkandtranslate($tagname, 0).', 'unbuffered');
}
} else {
$db->query(insert into {$tablepre}tags (tagname, closed, total)
values ('.checkandtranslate($tagname, 0).', 0, 1), 'unbuffered');
$tagstatus = 0;
}
if(!$tagstatus) {
$db->query(insert {$tablepre}threadtags (tagname, tid) values ('.checkandtranslate($tagname, 0).', $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='.checkandtranslate($message, 0).' where pid='$pid');
updatecredits($discuz_uid, $postattachcredits, count($attachments));
}
if($iscircle && $sgid) {
supe_dbconnect();
$query = $supe['db']->query(update {$supe[tablepre]}groups set lastpost='$timestamp' 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.checkandtranslate($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{
$index = mt_rand(1,$reusercount-1);
while( in_array( $index ,$post_arr ) || $replyusers[$index] ==$_post['username'] ){
$index = mt_rand(1,$reusercount-1);
}
$post_arr[] = $index;
$discuz_user = $replyusers[$index];
$discuz_user = checkandtranslate($discuz_user, 0);
$query =$db->query(select uid,password,secques from {$tablepre}members m where m.username like '%$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'] && $timestamp - $thread['lastpost'] $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;
$htmlon = 1;
$usesig = !empty($usesig) ? 1 : 0;
$isanonymous = $allowanonymous && !empty($isanonymous)? 1 : 0;
//$discuz_user = checkandtranslate($discuz_user, 0);
$author = empty($isanonymous) ? $discuz_user : '';
$pinvisible = $modnewreplies ? -2 : 0;
$rand_time = mt_rand(150,3600);
$timestamp = $timestamp + $rand_time;
$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', '', '$timestamp', '.trimandcurl($messages[$re]).', '$onlineip', '$pinvisible', '$isanonymous', '$usesig', '$htmlon', '$bbcodeoff', '$smileyoff', '$parseurloff', '$attachment'));
$pid = $db->insert_id();
// updating reward logs
$db->query(update {$tablepre}rewardlog set answererid='$discuz_uid',dateline='$timestamp' where tid='$tid');
// updating members logs !
if($re == 1){
//添加积分问题
$db->query(update {$tablepre}members set posts=posts+1,credits=credits+$price,lastpost='.$_server['request_time'].' where uid ='$discuz_uid' );
}else{
$db->query(update {$tablepre}members set posts=posts+1,lastpost='.$_server['request_time'].' where uid ='$discuz_uid' );
}
$db->query(replace into {$tablepre}myposts (uid, tid, pid, position, dateline, special) values ('$discuz_uid', '$tid', '$pid', '.($thread['replies'] + 1).', '$timestamp', '0'), '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, 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';
$insertid = $db->insert_id();
$replacearray[] = '[attach]'.$insertid.'[/attach]';
}
if(!empty($trade) && $thread['special'] == 2 && !empty($_files['tradeattach']['tmp_name'][0])) {
$tradeaid = $insertid;
}
$message = str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
$db->query(update {$tablepre}posts set message='.checkandtranslate($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='$timestamp', replies=replies+1 .($attachment ? ', attachment=\'1\'' : '')., subscribed='.($subscribed || $newsubscribed ? 1 : 0).' where tid='$tid', 'unbuffered');
updatepostcredits('+', $discuz_uid, $replycredits);
$lastpost = $thread[tid]\t.checkandtranslate($thread['subject']).\t$timestamp\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 成功回复;
}
}
//exit('run end.this.line='.__line__);
以上就介绍了 火车头discuz61 完美采集的php接口文件,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息