- # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
- # 功能名称: [记录会员登陆天数与次数] - 几天内登陆几次 By 折翼de天使♂
- # 功能说明: 这是一个稍微大点的小插件,有新增加数据表.如果不需要研究用户的习惯,可以不用.
- # 功能演示: http://www.dayku.cn/space.php?uid=1
- # 郑重说明: 请修改前备份文件涉及文件: sourse/do_login.php ; sourse/do_register.php ;
- # sourse/do_register.php ; common.php ; common.php ; template/模板目录/space_index.htm
- # 并备份数据库,如何修改出错.立即恢复!
- # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
①新建表:uc_logintimes
- CREATE TABLE IF NOT EXISTS `uc_logintimes` (
- `uid` mediumint(8) NOT NULL,
- `days` TINYINT( 4 ) NOT NULL DEFAULT '1',
- `times` int(11) NOT NULL default '1',
- `date` int(10) NOT NULL,
- PRIMARY KEY (`uid`)
- ) ENGINE=MyISAM DEFAULT CHARSET=gbk;
复制代码 ②打开 sourse/do_login.php
找- showmessage('login_success', $_POST['refer'], 1, array($ucsynlogin));
复制代码 上起一行加:- //记录登陆次数[一天一次] Begin
- $nowdate = time();
- $sql = 'SELECT * FROM `uc_logintimes` WHERE `uid` = '.$setarr['uid'].' ';
- $query = mysql_query($sql);
- $logintimes = mysql_fetch_assoc($query);
- if(!$logintimes){
- $sql = "INSERT INTO `uc_logintimes` VALUES ('".$setarr['uid']."','1','1','".$nowdate."')";
- mysql_query($sql);
- } elseif(date('Y-m-d',$logintimes['date']) < date('Y-m-d',$nowdate)) {
- $sql = "UPDATE `uc_logintimes` SET `days` = `days`+1 ,`times` = `times` + 1,`date` = '".$nowdate."' WHERE `uid` = '".$setarr['uid']."' ";
- mysql_query($sql);
- } elseif($logintimes['date'] < $nowdate) {
- $sql = "UPDATE `uc_logintimes` SET `times` = `times` + 1 WHERE `uid` = '".$setarr['uid']."' ";
- mysql_query($sql);
- }
- setcookie('loginlock',1,0);
- //记录登陆次数[一天一次] END
复制代码 ③打开 sourse/do_register.php
找- showmessage('registered', 'space.php?do=home');
复制代码 上起一行加- //记录登陆次数[一天一次] Begin
- $nowdate = time();
- $sql = "INSERT INTO `uc_logintimes` VALUES ('".$newuid."','1','1','".$nowdate."')";
- mysql_query($sql);
- setcookie('loginlock',1,0);
- //记录登陆次数[一天一次] END
复制代码 ④打开 common.php
找上起一行加:- //COOKIE判断增加登陆次数
- if(!$_COOKIE['loginlock']){
- //记录登陆次数[一天一次] Begin
- $loginuid = $_SGLOBAL[supe_uid];
- $nowdate = time();
- $sql = 'SELECT * FROM `uc_logintimes` WHERE `uid` = '.$loginuid.' ';
- $query = mysql_query($sql);
- $logintimes = mysql_fetch_assoc($query);
- if(!$logintimes){
- $sql = "INSERT INTO `uc_logintimes` VALUES ('".$loginuid."','1','1','".$nowdate."')";
- mysql_query($sql);
- } elseif(date('Y-m-d',$logintimes['date']) < date('Y-m-d',$nowdate)) {
- $sql = "UPDATE `uc_logintimes` SET `days` = `days`+1 ,`times` = `times` + 1,`date` = '".$nowdate."' WHERE `uid` = '".$loginuid."' ";
- mysql_query($sql);
- } elseif($logintimes['date'] < $nowdate) {
- $sql = "UPDATE `uc_logintimes` SET `times` = `times` + 1 WHERE `uid` = '".$loginuid."' ";
- mysql_query($sql);
- }
- setcookie('loginlock',1,0);
- //记录登陆次数[一天一次] END
- }
复制代码 ⑤ 打开 space.php
找- //处理
- include_once(S_ROOT."./source/space_{$do}.php");
复制代码 上起一行加:- //登陆次数
- $sql = "SELECT * FROM uc_logintimes WHERE uid = '".$space['uid']."' ";
- $logintimes = $_SGLOBAL['db']->fetch_array($_SGLOBAL['db']->query($sql));
复制代码 ⑥ 打开template/模板目录/space_index.htm
找- <!--{loop $applist $value}-->
- <li><a href="$value[url]" target="_blank" title="活动次数:$value[num],最后活动时间:<!--{date('m-d H:i',$value[updatetime],1)}-->">我的$value[appname]($value[num])</a></li>
- <!--{/loop}-->
复制代码 下起一行加:- <!--{if $logintimes}-->
- <li><a>登陆: $logintimes[days] 天 $logintimes[times] 次</a></li>
- <!--{/if}-->
复制代码 ⑦ 后台更新"模板缓存"..搞定! |