public function recordLogin($uid) { $data['uid'] = $uid; $data['ip'] = get_client_ip(); $data['place'] = convert_ip($data['ip']); $data['ctime'] = time(); M('login_record')->add($data); }
function php_count($id = "index", $type = "", $image = "1", $path = "") { require "config.php"; $from = check($_SERVER[HTTP_REFERER]); $count_file = "{$path}{$config[dir]}/{$id}.php"; //数据文件 $count_bak_file = "{$path}{$config[dir]}/{$id}.bak.php"; //备份数据文件 if (!file_exists($count_file)) { //如果数据文件不存在 if ($config[mode] == b) { $fp = fopen($count_file, "w"); chmod("{$count_file}", 0666); fputs($fp, "{$php_code}|0|0|0|0|0|0||||||||http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}||||||"); fclose($fp); $fp = fopen("{$config['dir']}/list.txt", "a"); flock($fp, LOCK_EX); fputs($fp, "{$id}\n"); fclose($fp); } else { echo "<font color=ff0000>帐号<b>{$id}</b>不存在</font>"; exit; } } $info = file_myfun($count_file); if (!$info[0]) { //数据为0则使用备份数据文件 $info = file_myfun($count_bak_file); $bak = "0"; } $info_all = count($info); list(, $yesterday, $today, $month, $total, $all_day, $top_day, $top_day_time, $top_online, $top_online_time, $mode, $time1, $pass, $pagename, $pageurl, $ip1, $bak_num) = explode("|", $info[0]); $time = time(); if ($bak == "0") { $bak_num++; } if (!$_COOKIE["STAT_BOOM_{$id}"] or $_COOKIE["STAT_BOOM_{$id}"] != $id) { //判断防止刷新 $yx_time = $time + $config[jgtime]; setcookie("STAT_BOOM_{$id}", "{$id}", "{$yx_time}", "{$_SERVER['PHP_SELF']}"); if (date("d", $time1) != date("d", $time)) { //判断是否同一天 $all_day++; $yesterday = $today; $today = 1; if ($bak != "0") { copy($count_file, $count_bak_file); } } else { $today++; } if (date("m", $time1) != date("m", $time)) { //判断是否同一月 $month = 1; } else { $month++; } if ($today > $top_day) { $top_day = $today; $top_day_time = date("Y-m-d"); } $total++; $ip = guest_ip(); $locality = convert_ip($ip); //************************** 写入新数据 **************************// $fp = fopen($count_file, "w"); flock($fp, LOCK_EX); fputs($fp, "{$php_code}|{$yesterday}|{$today}|{$month}|{$total}|{$all_day}|{$top_day}|{$top_day_time}|{$top_online}|{$top_online_time}|{$mode}|{$time}|{$pass}|{$pagename}|{$pageurl}|{$ip}|{$bak_num}|||\n"); if ($info_all > $config[info_max]) { $i = $info_all - $config[info_max] + 1; } else { $i = 1; } for ($i; $i < $info_all; $i++) { $info[$i] = trim($info[$i]) . "\n"; fputs($fp, $info[$i]); } fputs($fp, "{$time}|{$ip}|{$locality}|{$from}|\n"); fclose($fp); } //************************** 显示信息 **************************// if ($type == img) { $count = $total; $len = strlen($count); //总访量位数 if ($len < 7) { $rest = 7 - $len; } else { $rest = 2; } for ($i = 1; $i <= $rest; $i++) { $count = "0" . $count; //补足0 } for ($i = 0; $i < strlen($count); $i++) { $number = substr($count, $i, 1); $images = "<img src='{$config[url]}images/number/{$image}/{$number}.gif' border=0>"; $show = "{$show}" . "{$images}"; } echo "<A href='{$config[url]}index.php?id={$id}' title='-=BOOM流量统计2.9=- 今日:{$today} | 昨日:{$yesterday}'>{$show}</A>"; } elseif ($type == move) { echo "<table width='88' border='0' cellspacing='1' cellpadding='2' height='31' background='{$config[url]}/images/logo/{$image}.gif'>"; echo " <tr height=14><td align='center' valign='top'><marquee scrollDelay='50' scrollAmount='2'>"; echo " <a href='{$config[url]}index.php?id={$id}' target=blank style='FONT-FAMILY:Arial, Verdana; font-size: 9pt; color: #ffffff; text-decoration: none'>总访问量:" . $total . " 本月访问:" . $month . " 今日访问:" . $today . "</a></marquee></td></tr>"; echo " <tr height=8><td></td></tr></table>"; } elseif ($type == ico) { echo "<A href='{$config[url]}index.php?id={$id}'><IMG src='{$config[url]}/images/ico/{$image}.gif' border=0 title='-=BOOM流量统计2.9=- 今日:{$today} | 昨日:{$yesterday}'></A>"; } elseif ($type == hide) { } else { echo "<A href='{$config[url]}index.php?id={$id}' title='-=BOOM流量统计2.9=- 昨日:{$yesterday} | 本月:{$month}'>今日访问:{$today} 总访问量{$total}</A>"; } }
/** * 不为好友的“IP相近用户”(取100个) * * @param array $fuid * @return array */ public function getRelatedUserFromIp($fuid) { $map['uid'] = array('not in', $fuid); $map['login_place'] = convert_ip(get_client_ip()); $res = M('login_record')->where($map)->field('uid')->limit(100)->findAll(); return getSubByKey($res, 'uid'); }
public function recordLogin($uid) { $data['uid'] = $uid; $data['ip'] = get_client_ip(); $data['place'] = convert_ip($data['ip']); $data['ctime'] = time(); M('login_record')->add($data); //登陆积分 X('Credit')->setUserCredit($uid, 'user_login'); }
} else { $today++; } if (date("m", $time1) != date("m", $time)) { //判断是否同一月 $month = 1; } else { $month++; } if ($today > $top_day) { $top_day = $today; $top_day_time = date("Y-m-d"); } $total++; $ip = guest_ip(); $locality = convert_ip($ip); //************************** 写入新数据 **************************// $fp = fopen($count_file, "w"); flock($fp, LOCK_EX); fputs($fp, "{$php_code}|{$yesterday}|{$today}|{$month}|{$total}|{$all_day}|{$top_day}|{$top_day_time}|{$top_online}|{$top_online_time}|{$mode}|{$time}|{$pass}|{$pagename}|{$pageurl}|{$ip}|{$bak_num}|||\n"); if ($info_all > $config[info_max]) { $i = $info_all - $config[info_max] + 1; } else { $i = 1; } for ($i; $i < $info_all; $i++) { $info[$i] = trim($info[$i]) . "\n"; fputs($fp, $info[$i]); } fputs($fp, "{$time}|{$ip}|{$locality}|{$from}|\n"); fclose($fp);