Discuz論壇2.5 升級到PHP MySQL新版遇到的問題

gudesheng發表於2008-01-03

1 中文問題,在使用MySQL例項配置工具的使用,將使用的字符集設定為GBK,而不要設定為UTF-8

2 MySQL安裝後密碼無法訪問問題:

mysql> SET PASSWORD FOR
    -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd');

3 PHP有Warning

在php.ini裡面找到
bug_combat_warning = 1 兩行,1 改成 0

4 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;
 }
}



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=563538


相關文章