Statistics on the IP and PV contributed by php to the target website from the daily outbound connection of the website

Source: Internet
Author: User
Tags php foreach
Save to database: & lt ;? Phpheader (& quot; Content-type: text/html; charsetutf-8 & quot;); // echo $ _ COOKIE [& amp; #39; iptag & amp; #39;]; date_default_timezone_set (& amp; #39; PRC stored in the database: Connect_errno) {die ('database connection failed :'. $ mysqli-> connect_error);} $ db-> query ('set names utf8 '); $ SQL = "select * from dede_tongji where sourceUrl = '$ sourceurl' and aimUrl =' $ aimurl' and date = '$ time '"; $ res = $ db-> query ($ SQL); www.2cto.com // first, check whether the current database has the data of this link on the day. if not, create the database. otherwise, based on the cookie value, to determine the increase of IP addresses and PVS respectively. If ($ row = $ res-> fetch_assoc () {$ pvSum = $ row ['pvsum'] + 1; if ($ _ COOKIE ['iptag'] = $ cookieTag) {$ SQL = "update dede_tongji set pvSum = '$ pvsum' where sourceUrl =' $ sourceurl' and aimUrl = '$ aimurl' and date =' $ time '"; $ db-> query ($ SQL); // otherwise, only one else {$ ipSum = $ row ['ipsum'] + 1 is added for ip and pv; $ SQL = "update dede_tongji set ipSum = '$ ipsum ', pvSum = '$ pvsum' where sourceUrl =' $ sourceurl' and aimUrl = '$ aimurl' and date =' $ time '"; $ db-> query ($ SQL) ;}} if no else exists, add a new data. $ SQL = "insert into dede_tongji (sourceUrl, aimUrl, ipSum, pvSum, date) values ('$ sourceurl',' $ aimurl', 1, 1, '$ time') "; if ($ db-> query ($ SQL )) {} else {$ db-> error;} // redirect echo using js"

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.