Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ********************************************************
- * *
- * - Counter script by http://technoslab.blogspot.com *
- * - Make a file 'logs.dat' and chmod it to 0777 *
- * *
- ********************************************************
- */
- error_reporting(0);
- $period = 30;
- $logfile = "logs.dat";
- $time = time();
- $ip = $_SERVER['REMOTE_ADDR'];
- $info = file_get_contents($logfile);
- file_put_contents($logfile,"<info><ip>$ip</ip><time>$time</time></info>\n",FILE_APPEND);
- $contents = file_get_contents($logfile);
- if($contents==""){
- file_put_contents($logfile,"<visit>0</visit>");
- }
- preg_match_all("@<info><ip>(.+?)</ip><time>(.+?)</time></info>@",$contents,$match);
- $num1 = count($match[0]);
- preg_match("@<visit>(.+?)</visit>@",$contents,$tm);
- $num2 = $tm[1];
- $num = $num1 + $num2;
- if(filesize($logfile)>1024*2){
- file_put_contents($logfile,"<visit>$num</visit>");
- }
- $old = $time - $period;
- $online = 0;
- $processed = array();
- for($i=0;$i<$num;$i++){
- if($match[2][$i]>$old && !in_array($match[1][$i],$processed)){
- $processed[] = $match[1][$i];
- $online++;
- }
- }
- echo "<div style='background:url(http://s4.postimage.org/14y30hyuc/button_background.png) center repeat-x;height:20px;width:auto;float:left;font:bold 95% cursive;color:white;valign:middle;text-align:center;border:1px solid rgb(50,150,250);'>Online : $online | Visits : $num</div>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment