日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > php >内容正文

php

php 固定人数拼手气_独立统计在线人数和访问数代码分享(php)

發(fā)布時(shí)間:2024/9/19 php 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 固定人数拼手气_独立统计在线人数和访问数代码分享(php) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

代碼有2張,和一個(gè)sql

1.conn_count.php

< ?php

$host="localhost"; //請(qǐng)?jiān)陔p引號(hào)內(nèi)填寫你的mysql數(shù)據(jù)庫主機(jī)

$root=""; //請(qǐng)?jiān)陔p引號(hào)內(nèi)填寫你的mysql數(shù)據(jù)庫賬號(hào)

$pw=""; //請(qǐng)?jiān)陔p引號(hào)內(nèi)填寫你的mysql數(shù)據(jù)庫密碼

$name=""; //請(qǐng)?jiān)陔p引號(hào)內(nèi)填寫你的mysql數(shù)據(jù)庫名稱

$link=mysql_connect($host,$root,$pw);

mysql_select_db($name,$link);

?>

2.count.php

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< html xmlns="http://www.w3.org/1999/xhtml">

< head>

< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

< title>站內(nèi)統(tǒng)計(jì)代碼

< style type="text/css">

< !--

body {

background-color: #ccc;

}

-- >

< /style>< /head>

< body>

< ?php

require_once("conn_count.php");

$get_ip=$_SERVER['REMOTE_ADDR'];

$date=date("Y-m-d");

$time=date("H:i:s");

$sel_ip=mysql_query("select * from ip where ip='$get_ip'");

$check=mysql_fetch_array($sel_ip);

$check1=$check['ip'];

if($check1==""){

mysql_query("insert into ip(ip,time) values ('$get_ip','$date')");

}

$sel_str_ip=mysql_query("select id from ip");

$str_ip=mysql_num_rows($sel_str_ip);//ip總數(shù)

$today_sel_ip=mysql_query("select * from ip where time='$date'");

$today_ip=mysql_num_rows($today_sel_ip);//今日ip總數(shù)

mysql_query("update parameter set count=count+1,today=today+1");

$sel_count=mysql_query("select * from parameter");

$sel_tab=mysql_fetch_array($sel_count);

$blog_count=$sel_tab['count'];//總訪問量

$today_count=$sel_tab['today'];//今日訪問量

$sel_date=mysql_query("select * from parameter where today_date='$date'");

$check_date=mysql_fetch_array($sel_date);

$check_d=$check_date['today_date'];

if($check_d!=$date){

mysql_query("update parameter set today_date='$date',today=1");

}

$ip_sql=mysql_query("select ip from online where ip='$get_ip'");

if(!list($sel_old)=mysql_fetch_row($ip_sql)){

mysql_query("insert into online(ip,onlinetime) values ('$get_ip','$time')");

}

$that_time=$sel_tab['time'];

function conversec($datet){

$ip_h=intval(substr($datet,0,2));

$ip_m=intval(substr($datet,3,2));

$ip_s=intval(substr($datet,6,2));

$retval=$ip_h*3600+$ip_m*60+$ip_s;

return $retval;

}

$tp=conversec($time);

$tm=conversec($that_time);

$ip_c=$tp-$tm;

if($ip_c>1200 or $ip_c<0){

mysql_query("delete from online");

mysql_query("update parameter set time='$time'");

mysql_query("insert into online(ip,onlinetime) values ('$get_ip','$time')");

}

$sel_now_ip=mysql_query("select id from online");

$now_ip=mysql_num_rows($sel_now_ip);//當(dāng)前人數(shù)

$now_rand=rand(11,99);

#echo "ip總數(shù):".$str_ip."今日ip總數(shù):".$today_ip."總訪問量:".$blog_count."今日訪問量:".$today_count."當(dāng)前在線:".$now_ip;

echo "您是第 ".$blog_count." 個(gè)來到本站的訪客,當(dāng)前火爆在線人數(shù):".$now_ip.$now_rand."人!";

mysql_close();

?>

< /body>

< /html>

3.sql

CREATE TABLE `ip` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`ip` VARCHAR( 30 ) NOT NULL ,

`time` DATE NOT NULL

) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci

CREATE TABLE `parameter` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`count` TEXT NOT NULL ,

`today` TEXT NOT NULL ,

`today_date` DATE NOT NULL ,

`time` TIME NOT NULL

) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci

CREATE TABLE `online` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,

`ip` VARCHAR( 19 ) NOT NULL ,

`onlinetime` TIME NOT NULL

) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci

INSERT INTO `parameter` (

`id` ,

`count` ,

`today` ,

`today_date` ,

`time`

)

VALUES (

NULL , '1', '', '2011-06-21', '14:55:26'

);

sql分別運(yùn)行 創(chuàng)建各表

4.調(diào)用方式

< iframe width="100%" height="30" src="count.php" scrolling="no" frameborder="0" marginheight="0" marginwidth="0">< /iframe>

無限星辰 , 版權(quán)所有丨如未注明 , 均為原創(chuàng)丨本網(wǎng)站采用BY-NC-SA協(xié)議進(jìn)行授權(quán) , 轉(zhuǎn)載請(qǐng)注明獨(dú)立統(tǒng)計(jì)在線人數(shù)和訪問數(shù)代碼分享(php)!

總結(jié)

以上是生活随笔為你收集整理的php 固定人数拼手气_独立统计在线人数和访问数代码分享(php)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。