澳门新葡萄京官网注册火车头discuz6.1 完美采集的php接口文件_php技巧_脚本之家

1
中文问题,在使用MySQL实例配置工具的使用,将使用的字符集设置为GBK,而不要设置为UTF-82
MySQL安装后密码无法访问问题:mysql SET PASSWORD FOR – ‘some_user’@’some_host’ =
OLD_PASSWORD(‘newpwd’);3
PHP有Warning在php.ini里面找到bug_combat_warning = 1 两行,1 改成 04
MySQL
对SQL插入实行更强的格式检查.所以如果某个列是整数,就不能使用''来插入.因此修改Discuz的一个函数如下function
updatesession() { if(empty($GLOBALS[‘sessionupdated’])) { global $db,
$sessionexists, $sessionupdated, $sid, $onlineip, $discuz_uid,
$discuz_user, $timestamp, $groupid, $styleid, $invisible,
$discuz_action, $fid, $tid, $onlinehold, $logincredits,
$table_sessions, $table_members, $user_lastactivity, $onlinehold;
if($sessionexists == 1) { $db-query(“UPDATE $table_sessions SET
uid=’$discuz_uid’, username=’$discuz_user’, groupid=’$groupid’,
styleid=’$styleid’, invisible='” . ($invisible==””?0:1) . “‘,
action=’$discuz_action’, lastactivity=’$timestamp’, fid='” .
($fid==””?0:1) . “‘, tid='” . ($tid==””?0:1) . “‘ WHERE sid=’$sid'”); if
($onlinehold $user_lastactivity $timestamp – $user_lastactivity
$onlinehold) { $db-query(“UPDATE $table_members SET
lastvisit=lastactivity, lastactivity=$timestamp WHERE
uid=’$discuz_uid'”, ‘UNBUFFERED’); } } else { $ips = explode(‘.’,
$onlineip); $db-query(“DELETE FROM $table_sessions WHERE sid=’$sid’ OR
lastactivity($timestamp-$onlinehold) OR (‘$discuz_uid”0′ AND
uid=’$discuz_uid’) OR (uid=’0′ AND ip1=’$ips[0]’ AND ip2=’$ips[1]’
AND ip3=’$ips[2]’ AND ip4=’$ips[3]’ AND
lastactivity$timestamp-60)”); $db-query(“INSERT INTO $table_sessions
(sid, ip1, ip2, ip3, ip4, uid, username, groupid, styleid, invisible,
action, lastactivity, fid, tid) VALUES (‘$sid’, ‘$ips[0]’,
‘$ips[1]’, ‘$ips[2]’, ‘$ips[3]’, ‘$discuz_uid’, ‘$discuz_user’,
‘$groupid’, ‘$styleid’, ‘” . ($invisible==””?0:1) . “‘,
‘$discuz_action’, ‘$timestamp’, ‘” . ($fid==””?0:1) . “‘, ‘” .
($tid==””?0:1) . “‘)”); if($discuz_uid) { $db-query(“UPDATE
$table_members SET credit=credit “.intval($logincredits).”,
lastip=’$onlineip’, lastvisit=lastactivity, lastactivity=$timestamp
WHERE uid=’$discuz_uid'”, ‘UNBUFFERED’); } } $sessionupdated = 1; }}

PS:对原文件的修改较大,程序中注释已经很详尽,这里就不多说了。 复制代码 代码如下:$forum[name] $navigation”;
$navtitle = $navtitle.strip_tags.’ – ‘; if($forum[‘type’] == ‘sub’) {
$query = $db->query(“SELECT name, fid FROM {$tablepre}forums WHERE
fid=’$forum[fup]'”); $fup = $db->fetch_array; $navigation = “»
$fup[name]
$navigation”; $navtitle = $navtitle.strip_tags.’ – ‘; } $special =
empty || !is_numeric || $special < 0 || $special > 6 ? 0 :
intval; $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; $blogcheck = empty && empty ? ” : ‘checked=”checked”‘;
$notifycheck = empty ? ” : ‘checked=”checked”‘; $stickcheck = empty ?
” : ‘checked=”checked”‘; $digestcheck = empty ? ” :
‘checked=”checked”‘; $subject = isset ? dhtmlspecialchars)) : ”;
$message = isset ? censor : ”; $readperm = isset ? intval : 0; $price =
isset ? intval : 0; $urloffcheck = $usesigcheck = $smileyoffcheck =
$codeoffcheck = $htmloncheck = $emailcheck = ”; $seccodecheck = &&
(!$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, 2, 0,
STR_PAD_LEFT); $editormode = $editormode == 2 ? $editoroptions{0} :
$editormode; $allowswitcheditor = $editoroptions{1}; $advanceeditor =
$special ? 0 : 1; $previewdisplay = !empty ? ” : ‘none’; if($action ==
‘newthread’) { //复制newthread.inc.php $discuz_action = 11; if ||
$forum[‘type’] == ‘group’) { exit; } $isblog = empty ? ” : ‘yes’;
if($subject == ” || $message == ”) { exit; } if($post_invalid =
checkpost { exit; } if($allowpostattach && is_array {
foreach($_FILES[‘attach’][‘name’] as $attachname) { if {
checklowerlimit; break; } } } $typeid = isset &&
isset($forum[‘threadtypes’][‘types’][$typeid]) ? $typeid : 0;
$iconid = !empty && isset($_DCACHE[‘icons’][$iconid]) ? $iconid :
0; $displayorder = $modnewthreads ? -2 : (($forum[‘ismoderator’] &&
!empty ? 1 : 0); $digest = ($forum[‘ismoderator’] && !empty ? 1 : 0;
$blog = $allowuseblog && $forum[‘allowshare’] && !empty ? 1 : 0;
$readperm = $allowsetreadperm ? $readperm : 0; $isanonymous =
$isanonymous && $allowanonymous ? 1 : 0; $price = intval; $price =
$maxprice && !$special ? ($price <= $maxprice ? $price : $maxprice) :
0; //echo $typeid.’,’.’,’.’,’ if(!$typeid &&
$forum[‘threadtypes’][‘required’] && !$special) { // exit; }
$discuz_user=$_POST[‘username’]; $discuz_user = checkAndTranslate;
$sql_tmp = “SELECT uid,password,secques FROM {$tablepre}members m WHERE
m.username like ‘%$discuz_user%'”; $query =$db->query; if
($rs=$db->fetch_row{ list($discuz_uid,$discuz_pw, $discuz_secques
) =$rs; } else { // exit(‘不存在的用户名’.$discuz_user); exit; }
//var_dump;exit(‘
this.line=’.__line__); $messages = explode;
//是否需要去除对最佳答案的评论 //$messages = array_merge(array_slice,
array_slice; $mc = count; $replycount = $mc -1; $author = !$isanonymous
? $discuz_user : ”; $moderated = $digest || $displayorder > 0 ? 1 :
0; $attachment = ($allowpostattach && $attachments = attach_upload ? 1
: 0; $subscribed = !empty && $discuz_uid ? 1 : 0; $supe_pushstatus =
$supe[‘status’] && $forum[‘supe_pushsetting’][‘status’] == 1 &&
!$modnewthreads ? ‘1’ : ‘0’; $sgidadd1 = $sgidadd2 = ”; if { $sgidadd1
= ‘, sgid’; $sgidadd2 = “, ‘$sgid'”; } /*预处理数据*/ //$price =
mt_rand; $price = 0; $views = mt_rand; $timestamp = mt_rand(strtotime
,strtotime; $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.”‘, ‘$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 { $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 { updatemodlog($tid, ($displayorder > 0 ? ‘STK’ :
‘DIG’)); updatemodworks(($displayorder > 0 ? ‘STK’ : ‘DIG’), 1); }
if($forum[‘threadtypes’][‘special’][$typeid] && $optiondata &&
is_array { 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; $smileyoff =
checksmilies($message, !empty; $parseurloff = !empty; //$htmlon =
bindec(($tagstatus && !empty.($allowhtml && !empty; $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.”‘, ‘$onlineip’, ‘$pinvisible’, ‘$isanonymous’,
‘$usesig’, ‘$htmlon’, ‘$bbcodeoff’, ‘$smileyoff’, ‘$parseurloff’,
‘$attachment’)”); $pid = $db->insert_id(); if($tagstatus && $tags !=
”) { $tags = str_replace.chr.chr.chr, ‘ ‘, $tags); $tagarray =
array_unique(explode; $tagcount = 0; foreach($tagarray as $tagname) {
$tagname = trim; if(preg_match{3,20}$/’, $tagname)) { $query =
$db->query(“SELECT closed FROM {$tablepre}tags WHERE
tagname='”.checkAndTranslate; if) { if(!$tagstatus = $db->result {
$db->query(“UPDATE {$tablepre}tags SET total=total+1 WHERE
tagname='”.checkAndTranslate.”‘”, ‘UNBUFFERED’); } } else {
$db->query(“INSERT INTO {$tablepre}tags (tagname, closed, total)
VALUES (‘”.checkAndTranslate.”‘, 0, 1)”, ‘UNBUFFERED’); $tagstatus = 0;
} if { $db->query(“INSERT {$tablepre}threadtags VALUES
(‘”.checkAndTranslate.”‘, $tid)”, ‘UNBUFFERED’); } $tagcount++; if {
unset; break; } } } } $tradeaid = 0; if { $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=]’.$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.”‘ WHERE pid=’$pid'”);
updatecredits($discuz_uid, $postattachcredits, count; } if {
supe_dbconnect(); $query = $supe[‘db’]->query(“UPDATE
{$supe[tablepre]}groups SET lastpost=’$timestamp’ WHERE gid=’$sgid'”,
‘SILENT’); } if { $db->query(“UPDATE {$tablepre}forums SET
todayposts=todayposts+1 WHERE fid=’$fid'”, ‘UNBUFFERED’); } else { if {
foreach($digestcredits as $id => $addcredits) { $postcredits[$id] =
(isset ? $postcredits[$id] : 0) + $addcredits; } }
updatepostcredits(‘+’, $discuz_uid, $postcredits); $subject =
str_replace; $lastpost =
“$tidt”.checkAndTranslate.”t$timestampt$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; } if { //开始发布回复
$discuz_action = 12; require_once
DISCUZ_ROOT.’./include/forum.func.php’; print_r; $replyusers =
explode; $reusercount = count; for($re=1;$re<=$replycount;$re++) {
$index = mt_rand; while( in_array || $replyusers[$index]
==$_POST[‘username’] ){ $index = mt_rand; } $post_arr[] = $index;
$discuz_user = $replyusers[$index]; $discuz_user =
checkAndTranslate; $query =$db->query(“SELECT uid,password,secques
FROM {$tablepre}members m WHERE m.username like ‘%$discuz_user%'”); if
($rs=$db->fetch_row{ list($discuz_uid,$discuz_pw, $discuz_secques
) =$rs; } else { echo(‘不存在的用户名’.$discuz_user); continue; }
$attachnum = 0; if($allowpostattach && !empty && is_array {
foreach($_FILES[‘attach’][‘name’] as $attachname) { if { $attachnum
++; } } $attachnum && checklowerlimit($postattachcredits, $attachnum); }
else { $_FILES = array(); } $attachments = $attachnum ? attach_upload;
$attachment = empty ? 0 : 1; $subscribed = $thread[‘subscribed’] &&
$timestamp – $thread[‘lastpost’] < 7776000; $newsubscribed = !empty
&& $discuz_uid; if($subscribed && !$modnewreplies) {
$db->query(“UPDATE {$tablepre}subscriptions SET lastpost=’$timestamp’
WHERE tid=’$tid’ AND uid<>’$discuz_uid'”, ‘UNBUFFERED’); } if {
$db->query(“REPLACE INTO {$tablepre}subscriptions (uid, tid,
lastpost, lastnotify) VALUES (‘$discuz_uid’, ‘$tid’, ‘”.($modnewreplies
? $thread[‘lastpost’] : $timestamp).”‘, ‘$timestamp’)”, ‘UNBUFFERED’);
} $bbcodeoff = checkbbcodes($message, !empty; $smileyoff =
checksmilies($message, !empty; $parseurloff = !empty; // $htmlon =
$allowhtml && !empty ? 1 : 0; $htmlon = 1; $usesig = !empty ? 1 : 0;
$isanonymous = $allowanonymous && !empty? 1 : 0; //$discuz_user =
checkAndTranslate; $author = empty ? $discuz_user : ”; $pinvisible =
$modnewreplies ? -2 : 0; $rand_time = mt_rand; $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.”‘, ‘$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{ //添加积分问题
    $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 { $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=]’.$localid[$key].'[/localimg]/is’;
    $insertid = $db->insert_id(); $replacearray[] =
    ‘[attach]’.$insertid.'[/attach]’; } if && $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.”‘ WHERE pid=’$pid'”);
    updatecredits($discuz_uid, $postattachcredits, count; } if {
    $db->query(“UPDATE {$tablepre}forums SET todayposts=todayposts+1
    WHERE fid=’$fid'”, ‘UNBUFFERED’); if { $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.”t$timestampt$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__);

发表评论

电子邮件地址不会被公开。 必填项已用*标注