A-A+

Discuz admin.php后台异地登录提示 及前台异地登录提示插件破解

2016年03月29日 13:49 学习笔记 暂无评论 阅读 469 views 次

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

首先修改后台文件source/admincp/admincp_main.php 在适当的位置添加如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
if($_G[uid] && $_G['cookie']['logindetail']){
echo <<<EOT
	<div class="focus userlogin" id="login_unusual">
		<div class="bm">
		<div class="bm_h cl">
		<a href="javascript:;" onclick="$('login_unusual').style.display='none';setcookie('logindetail', '', -1);" class="yss" title="关闭">关闭</a>
		<h2>异地登录提醒</h2>
		</div>
		<div class="bm_c">{$_G['cookie']['logindetail']}</div>
		</div>
	</div>
EOT;
}

然后修改后台登录文件source/class/discuz/discuz_admincp.php
找到 function check_admin_login() { 这处代码,然后在loaducenter();下面添加

1
2
3
4
5
6
7
$yddlnumber = C::t('common_admincp_yididl')->countid($this->adminuser['uid']);
if($yddlnumber>=2){  //这段代码都可以不添加,根据自己实际需求。
	$lang = lang('admincp_login');
	showmessage($lang[login_user_yddl], 'admin.php?action=login', array(), array('showdialog' => false, 'msgtype' => 2, 'refreshtime' => 14, 'alert' => 'right'));
} //login_user_ydd 这个是登录提示,自己在admincp_login语言包中添加,这段代码是我自己添加的数据表,用来储存异地登录次数,超过2次,进制登录后台!
$ipp = $this->core->var['clientip'];
$ipconnent = adders($ipp); //这一处是转换IP为地址,自己可以找淘宝的API什么的,下面我也会给出API

然后在这处代码下添加if($ucresult[0] > 0) {
C::t('common_admincp_session')->update($this->adminuser['uid'], $this->panel, array('dateline' => TIMESTAMP, 'ip' => $ipp, 'errorcount' => -1));
添加如下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$lastloginfo = C::t('common_admincp_dljilu')->allid($this->adminuser['uid'], 0, 1);
//$memberrs = C::t('common_member')->fetch($this->adminuser['uid'], 0, 1);
if($lastloginfo) {
	//require_once libfile('function/core');
	$lastloginfo['lastvisit'] = date('Y-m-d H:i', $lastloginfo['dateline']);
	$lastloginfo['lastarea'] = adders($lastloginfo['dlip']);
	if($lastloginfo['lastarea'] && $ipconnent && (mb_substr($lastloginfo['lastarea'],0,5,'utf-8') != mb_substr($ipconnent,0,5,'utf-8'))) {
	$logindetail = str_replace(array('{username}', '{ldateline}', '{larea}', '{cdateline}', '{carea}'), array($lastloginfo['zlusername'], $lastloginfo['lastvisit'], $lastloginfo['lastarea'], date('Y-m-d H:i', $_G['timestamp']),$ipconnent), lang('plugin/honhoo_loginunusual', 'login_notice'));
	dsetcookie('logindetail', $logindetail);
	C::t('common_admincp_yididl')->insert(array(
		'ydadminid' => $this->adminuser['uid'],
		'ydname' => $lastloginfo['zlusername'],
		'yddateline' => TIMESTAMP,
	));
	}
} //这里我做二次开发了,所以调用的是表common_admincp_dljilu 这里的数据,正常这里应该调用common_member_status这里的数据

再次找到$result = userlogin($_POST['admin_username'], $_POST['admin_password'], $_POST['admin_questionid'], $_POST['admin_answer'], 'username', $ipp);
if($result['status'] == 1) {
然后在下方合适的地方放入上面的代码。

下面附上一段淘宝API查询IP地址的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function adders($str) {
$ip = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$str);
$ip = json_decode($ip,true);    //翻译JSON格式
/* if(empty($ip)){
	$ip = file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".$str);
	$ip = json_decode($ip,true);    //翻译JSON格式
} */
//$ip = $ip['data']['country'].$ip['data']['region']." ".$ip['data']['city'].$ip['data']['isp'];   //调用数组
        // 这里是调用国家              省                     市                  ISP服务商
	if($ip['data']['region']){
		$ip = $ip['data']['region']." ".$ip['data']['city'];  
	}else{
		$ip = $ip['data']['country']." ".$ip['data']['country_id'];   
	}
return $ip;
}

再付一张异地登录的表

1
2
3
4
5
6
7
8
9
10
11
--
-- 表的结构 `hu_common_admincp_yididl`
--
 
CREATE TABLE IF NOT EXISTS `hu_common_admincp_yididl` (
  `ydid` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `ydadminid` mediumint(8) unsigned NOT NULL,
  `ydname` char(32) DEFAULT NULL,
  `yddateline` int(10) unsigned NOT NULL,
  PRIMARY KEY (`ydid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='异地登录' AUTO_INCREMENT=9 ;

table_common_admincp_yididl.php 内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
	public function allid($uid , $start = 0, $limit = 0) {
		return DB::fetch_first("SELECT * FROM %t WHERE ydadminid=%d order by ydid desc".DB::limit($start, $limit), array($this->_table, $uid));
	}
 
	public function countname($username) {
		return DB::result_first("SELECT COUNT(*) FROM %t WHERE ydname=%s ", array($this->_table, $username));
	}
 
	public function countid($uid) {
		return DB::result_first("SELECT COUNT(*) FROM %t WHERE ydadminid=%d ", array($this->_table, $uid));
	}
 
	public function countall() {
		return DB::result_first("SELECT COUNT(*) FROM %t ", array($this->_table));
	}
 
	public function fetch_all_ipdl($uid) {
			return DB::fetch_all('SELECT * FROM %t WHERE ydadminid=%d ORDER BY ydid desc', array($this->_table, $uid));
	}
 
	public function fetch_all_ipdl3() {
			return DB::fetch_all('SELECT * FROM %t ORDER BY ydid desc', array($this->_table));
	}
	public function fetch_all_by_panel($uid) {
		return DB::fetch_all('SELECT * FROM %t WHERE ydadminid=%d', array($this->_table, $uid), 'ydid');
	}
 
	public function delete_ydname($username) {
		DB::query("DELETE FROM %t WHERE ydname IN (%n)", array($this->_table, $usernames));
	}

最后最后附破解版异地登录提醒收费插件:
http://pan.baidu.com/s/1qXPVuGW 密码s7s7

标签:

给我留言