IPv6無法進(jìn)入管理員后臺

2024-07-29 15:24 更新

為了獲取更多最新內(nèi)容及功能更新,請直接訪問我們的首頁以查看DzzOffice筆記的最新地址。

描述

在采用IPv6網(wǎng)絡(luò)連接時,管理員后臺登錄存在問題。

原因分析:

因?yàn)閿?shù)據(jù)庫表字段長度和數(shù)據(jù)庫表代碼未考慮IPv6的問題。

解決方法

以下操作均需要無人訪問網(wǎng)站,操作完成后,需要重新訪問網(wǎng)站才能正常使用。

pichome 步驟

打開pichome數(shù)據(jù)庫,找到pichome_admincp_session數(shù)據(jù)庫表,修改ip字段的長度為45。 至此,管理員即可使用IPv6訪問后臺。修改pichome_session數(shù)據(jù)庫表,將ip1、ip2、ip3ip4這四個字段合為一個字段,并將其命名為ip字段(即刪除其中三個字段,剩余的一個重命名為ip),并將其字段類型改為varchar,長度改為45。同時,修改數(shù)據(jù)庫表pichome_failedlogin,修改ip字段類型改為varchar,長度改為45。至此,系統(tǒng)所有的ip地址都能記錄IPv6的地址了。

DzzOffice 步驟

打開DzzOffice數(shù)據(jù)庫,找到dzz_admincp_session數(shù)據(jù)庫表,修改ip字段的長度為45。 至此,管理員即可使用IPv6訪問后臺。修改dzz_session數(shù)據(jù)庫表,將ip1ip2、ip3、ip4這四個字段合為一個字段,并將其命名為ip字段(即刪除其中三個字段,剩余的一個重命名為ip),并將其字段類型改為varchar,長度改為45。同時,修改數(shù)據(jù)庫表dzz_failedlogin,修改ip字段類型改為varchar,長度改為45。至此,系統(tǒng)所有的ip地址都能記錄IPv6的地址了。

通用步驟

文件\core\class\dzz\dzz_session.php

原代碼

private $newguest = array('sid' => 0, 'ip1' => 0, 'ip2' => 0, 'ip3' => 0, 'ip4' => 0, 'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0, 'lastactivity' => 0, 'lastolupdate' => 0);

修改為

private $newguest = array('sid' => 0, 'ip' => '', 'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0, 'lastactivity' => 0, 'lastolupdate' => 0);

原代碼

public function set($key, $value) { if(isset($this->newguest[$key])) { $this->var[$key] = $value; } elseif ($key == 'ip') { $ips = explode('.', $value); $this->set('ip1', $ips[0]); $this->set('ip2', $ips[1]); $this->set('ip3', $ips[2]); $this->set('ip4', $ips[3]); } } public function get($key) { if(isset($this->newguest[$key])) { return $this->var[$key]; } elseif ($key == 'ip') { return $this->get('ip1').'.'.$this->get('ip2').'.'.$this->get('ip3').'.'.$this->get('ip4'); } }

修改為

public function set($key, $value) { if(isset($this->newguest[$key])) { $this->var[$key] = $value; } } public function get($key) { if(isset($this->newguest[$key])) { return $this->var[$key]; } }
文件\core\class\dzz\dzz_session_close.php

原代碼

protected $newguest = array('sid' => 0, 'ip1' => 0, 'ip2' => 0, 'ip3' => 0, 'ip4' => 0, 'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0, 'lastactivity' => 0, 'fid' => 0, 'tid' => 0, 'lastolupdate' => 0);

修改為

protected $newguest = array('sid' => 0, 'ip' => '', 'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0, 'lastactivity' => 0, 'fid' => 0, 'tid' => 0, 'lastolupdate' => 0);

原代碼

public function set($key, $value) { if(isset($this->newguest[$key])) { $this->var[$key] = $value; } elseif ($key == 'ip') { $ips = explode('.', $value); $this->set('ip1', $ips[0]); $this->set('ip2', $ips[1]); $this->set('ip3', $ips[2]); $this->set('ip4', $ips[3]); } } public function get($key) { if(isset($this->newguest[$key])) { return $this->var[$key]; } elseif ($key == 'ip') { return $this->get('ip1').'.'.$this->get('ip2').'.'.$this->get('ip3').'.'.$this->get('ip4'); } }

修改為

public function set($key, $value) { if(isset($this->newguest[$key])) { $this->var[$key] = $value; } } public function get($key) { if(isset($this->newguest[$key])) { return $this->var[$key]; } }
文件\core\class\table\table_session.php

原代碼

public function fetch($sid, $ip = false, $uid = false) { if(empty($sid)) { return array(); } $this->checkpk(); $session = parent::fetch($sid); if($session && $ip !== false && $ip != "{$session['ip1']}.{$session['ip2']}.{$session['ip3']}.{$session['ip4']}") { $session = array(); } if($session && $uid !== false && $uid != $session['uid']) { $session = array(); } return $session; }

修改為

public function fetch($sid, $ip = false, $uid = false) { if(empty($sid)) { return array(); } $this->checkpk(); $session = parent::fetch($sid); if($session && $ip !== false && $ip != "{$session['ip']}") { $session = array(); } if($session && $uid !== false && $uid != $session['uid']) { $session = array(); } return $session; }

原代碼

public function delete_by_session($session, $onlinehold, $guestspan) { if(!empty($session) && is_array($session)) { $onlinehold = time() - $onlinehold; $guestspan = time() - $guestspan; $session = daddslashes($session); $condition = " sid='{$session[sid]}' "; $condition .= " OR lastactivity<$onlinehold "; $condition .= " OR (uid='0' AND ip1='{$session['ip1']}' AND ip2='{$session['ip2']}' AND ip3='{$session['ip3']}' AND ip4='{$session['ip4']}' AND lastactivity>$guestspan) "; $condition .= $session['uid'] ? " OR (uid='{$session['uid']}') " : ''; DB::delete('session', $condition); } }

修改為

public function delete_by_session($session, $onlinehold, $guestspan) { if(!empty($session) && is_array($session)) { $onlinehold = time() - $onlinehold; $guestspan = time() - $guestspan; $session = daddslashes($session); $condition = " sid='{$session[sid]}' "; $condition .= " OR lastactivity<$onlinehold "; $condition .= " OR (uid='0' AND ".DB::field('ip', $session['ip'])." AND lastactivity>$guestspan) "; $condition .= $session['uid'] ? " OR (uid='{$session['uid']}') " : ''; DB::delete('session', $condition); } }

原代碼

public function count_by_ip($ip) { $count = 0; if(!empty($ip) && ($ip = explode('.', $ip)) && count($ip) > 2 ) { $count = DB::result_first('SELECT COUNT(*) FROM '.DB::table('session')." WHERE ip1='$ip[0]' AND ip2='$ip[1]' AND ip3='$ip[2]'"); } return $count; } public function fetch_all_by_ip($ip, $start = 0, $limit = 0) { $data = array(); if(!empty($ip) && ($ip = explode('.', $ip)) && count($ip) > 2 ) { $data = DB::fetch_all('SELECT * FROM %t WHERE ip1=%d AND ip2=%d AND ip3=%d ORDER BY lastactivity DESC'.DB::limit($start, $limit), array($this->_table, $ip[0], $ip[1], $ip[2]), null); } return $data; }

修改為

public function count_by_ip($ip) { $count = 0; if(!empty($ip)) { $count = DB::result_first('SELECT COUNT(*) FROM '.DB::table('session')." WHERE ".DB::field('ip', $ip)); } return $count; } public function fetch_all_by_ip($ip, $start = 0, $limit = 0) { $data = array(); if(!empty($ip)) { $data = DB::fetch_all('SELECT * FROM %t WHERE ip=%s ORDER BY lastactivity DESC'.DB::limit($start, $limit), array($this->_table, $ip), null); } return $data; }


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號