phpͳ¼ÆIPÒÔ¼°ÔÚÏßÈËÊýµÄͳ¼Æ
1.ÓÃJSµ÷ÓÃÎļþcount.php ÔÚÄãÐèÒª¼ÓÈëͳ¼ÆµÄµÄµØ·½¼ÓÈë<script src="count.php"></script> ʵ¼ÊÔËÓÃÖÐ×¢ÒâÐ޸ķ¾¶£¡
2.php»·¾³±ØÐëÖ§³Öputenv()º¯Êý,¿ÉÒÔͳ¼Æ×òÈÕ·ÃÎÊ£¬½ñÈÕ·ÃÎÊ£¬ÔÚÏßÈËÊý,Äú·ÃÎʵĴÎÊý¡£
3 . ÔÚcount.phpÏàͬĿ¼½¨Á¢ÒÔÏÂÎļþ count,temp,online,н¨Îı¾Îĵµcount.txt È»ºóÈ¥µôÀ©Õ¹Ãû¾ÍÊÇÎļþcountÁË£»Èç¹ûÊÇLinuxÖ÷»úÇë°ÑÕâÈý¸öÎļþÊôÐÔÉèΪ777.
count.phpÎļþ´úÂë:
<?
$file = "count"; // ¼ÇÊýÎļþÃû³Æ
$startno = "1000"; // ÆðʼÊýÖµ
$tempfile = "temp";
$t_now = time();
$t_array = getdate($t_now);
$day = $t_array['mday'];
$mon = $t_array['mon'];
$year = $t_array['year'];
if (file_exists("$file")) {
$count_info=file("$file");
$c_info = explode(",", $count_info[0]);
$total_c=$c_info[0];
$yesterday_c=$c_info[1];
$today_c=$c_info[2];
$lastday=$c_info[3];
} else {
$total_c="$startno";
$yesterday_c="0";
$today_c="0";
$lastday="0";
}
if ( !isset($HTTP_COOKIE_VARS["countcookie"]) || $HTTP_COOKIE_VARS["countcookie"] != $day) {
$your_c=1;
$lockfile=fopen("temp","a");
flock($lockfile,3);
putenv
Ïà¹ØÎĵµ£º
¼ÙÈçÓÐÁ½¸ö±í£º user ºÍ articles ±í
½á¹¹£º
user£º £¨id, name£©
articles: (id,user_id,title,content)
ÆäÖÐuser.id ºÍ user_id ¹ØÁª
ÔÚuserµÄ modelÖÐµÄ relations·½·¨ÀïÃæ¼Ó£º
return array('articles'=>array(self::HAS_MANY,'articles','user_id'));
ÔÚarticlesµÄ modelÖÐµÄ relations·½·¨ÀïÃæ¼Ó£º
......
ÒýÓÃÎļþµÄ·½·¨ÓÐ2ÖÖ£º
1¡¢require
require("conn.php"); Ò»°ã·ÅÔÚÒ³ÃæµÄµÚÒ»ÐУ¬×öΪ¸ÃÒ³Ö´ÐеÄÒ»²¿·Ö£¬Ê×ÏÈÖ´ÐÐrequireÄÚµÄconn.php È»ºóÔÙÖ´ÐÐÏÂÃæµÄ´úÂë
2¡¢include
include("header.php");µ±³ÌÐòµ½´ïÕâÀïµÄʱºò²Å»áÖ´ÐÐincludeµÄ header.php ......
ǰÑÔ£ºÎÒдµÄ¹ØÓÚÉè¼ÆÄ£Ê½µÄһϵÁÐÎÄÕ¡£ÕâϵÁеÄÎÄÕÂÖ÷ÒªÕë¶Ôû½Ó´¥¹ýÉè¼ÆÄ£Ê½µÄ£¬»òÕß˵½Ó´¥¹ýµ«»¹²»ÊǺÜÃ÷°×µÄPHPer¡£
ÎÊÌâµÄÌá³ö:
¿ÉÄܺܶàÈ˶¼Ð´¹ýÀ࣬Îļþ²Ù×÷µÄ£¬Êý¾Ý¿âµÄ……
¶ÔÓÚÊý¾Ý¿âµÄÀàÀ´ËµÓÐʱºò¿ÉÄܱ»ºöÂÔµÄÒ»¸öÎÊÌâÊÇ£ºÎÒÃÇ´´½¨ÀàµÄʵÀýʱһ°ã¶¼ÊÇͨ¹ý¹¹Ô캯ÊýÁ¬½ÓÁËÊý¾Ý¿â¡£Õâû´ ......
ÎÒÃdz£³£ÔÚÍøÕ¾ÉÏ¿´µ½Ä³ÆªÎÄÕ·¢±íÓÚ“3Ììǰ”£¬“5¸öÔÂǰ”£¬“4Äêǰ”¡£ÏÂÃæÕâ¸öº¯Êý¾ÍÌṩÁ˼ÆËãÕâ¸öʱ¼ä²îµÄ¹¦ÄÜ¡£
<?php
/**
* ʱ¼ä²î¼ÆËã
*
* @param Timestamp $time
* @return String Time Elapsed
* @author Shelley Shyan
* @copyright http://phparch.cn (Professiona ......