PHP System traffic analysis program _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP System traffic analysis program. Createtablestream (iptext, sTimeint, visitsint, infotext );? If ($ day0) $ day0; $ mlinkmysql_connect (localhost, ajax, xxxxxxx); total number of times the home page has been browsed so far $ q> create table stream (
Ip text,
STime int,
Visits int,
Info text );
If ($ day <0) $ day = 0;
$ Mlink = mysql_connect ('localhost', 'Ajax ', 'xxxxxxx ');
// Count the total number of times the home page has been browsed so far
$ Query = "select SUM (visits) as tvisits from stream ";
$ Result = mysql_db_query ('Ajax ', $ query, $ mlink );

Echo 'total times of browsing the home page :';
If ($ row = mysql_fetch_object ($ result )){
Echo $ row-> tvisits;
}

$ Week = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
For ($ I = 0; $ I <= $ day; $ I ++ ){
Echo'

';
$ Ctime1 = time ()-24X3600 * $ I;
$ Ctime2 = time ()-24*3600 * ($ i-1 );
Echo 'date: '. date ("m Month D", $ ctime1). $ week [date ("w", $ ctime1)];
Echo "";

$ Stoday1 = mktime (0, 0, 0, date (m, $ ctime1), date (d, $ ctime1), date (Y, $ ctime1 ));
$ Stoday2 = mktime (0, 0, date (m, $ ctime2), date (d, $ ctime2), date (Y, $ ctime2 ));
// Count the total number of times the homepage is browsed on the current day
$ Query = 'SELECT SUM (visits) as tvisits from stream where sTime> = ';
$ Query. = $ stoday1. 'and sTime <'. $ stoday2;
$ Result = mysql_db_query ('Ajax ', $ query, $ mlink );
Echo 'cumulative number of homepage views :';
If ($ row = mysql_fetch_object ($ result )){
Echo $ row-> tvisits;
}
// Count the number of ip addresses visited on the current day
$ Query = 'select * from stream where sTime> = '. $ stoday1;
$ Query. = 'and sTime <'. $ stoday2. 'Order by sTime DESC ';
$ Result = mysql_db_query ('Ajax ', $ query, $ mlink );

Echo"
Total browsing count: ". mysql_num_rows ($ result );
Echo'

';
Echo'














';Echo' ';Echo" ";While ($ row = mysql_fetch_object ($ result )){Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo" ";}Echo"
IP address Last time Times User information
'. $ Row-> ip .''. Date ("h: I: sa", $ row-> sTime ).''. $ Row-> visits .''. $ Row-> info .'
";
Echo' ';
}
Mysql_close ($ mlink );
?>


Http://www.bkjia.com/PHPjc/315149.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315149.htmlTechArticlecreate table stream (ip text, sTime int, visits int, info text );? If ($ day0) $ day = 0; $ mlink = mysql_connect ('localhost', 'Ajax ', 'xxxxxxx '); // count the total number of times the home page has been browsed so far $ q...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.