سلام من تازه واردم و به دعوت روزبه اومدم اينجا, ميخواستم يكي از سكريپت هايي رو كه چند وقت پيش براي سايت خودم نوشته بودم رو اينجا بزارم كه همه استفاده كنن.
کد:
<?
/*
____________________________________________________________________________
|(C)2001-2003 Alireza .... [email][email protected][/email] http://www.iran-teens.com
| Iran Teens Services is part of Uk based Pars Media, Inc
| This script has been released under GPL lisence.
| You don't require any link back to Iran-Teens.com However
| it will be appreciated if you give us credit in your website.
|---------------------------------------------------------------------
| Feel free to edit this script for you OWN need but you are NOT
| alowed to delet this copyright, re-distribute or sell this
| with out written permission from Pars media, Inc.
|---------------------------------------------------------------------
| This script is for use AS-IT-IS, Pars media, Inc is not responsible
| for providing any help and support however send me an email and if
| is was on mood I probably would help you. We ARE NOT responsible for
| any data loss or server problem cuased by this script. we have teste
| it on our dedicated server and has answered correctly
| >>>>>>>>>>>>>>>>> USE IT AT YOUR OWN RISK<<<<<<<<<<<<<<<<<<<<<
______________________________________________________________________________
*/
//----------------------------------------------------------------------------------------
//This is a PATH NOT URL to the directory that you have put this script
//I strongly recommend you use unusual name such as "ghjkj" and CHMOD it 777
$base_datapath = "/home/ali-onli/public_html/data";
//--------------------------------------------------------------------------------------------
//How many seconds different between webserver time and the real time in your place,
//3600 means 3600 seconds / 1 hour.
$offset=0;
//-------------------------------------------------------------------------------------------
/*
--------------------------------------------------------------------------------------------------
Copy and paste this to your PHP page
<?PHP
include("iranteens.php");
$visitors = daily_count("","");
echo "Visitors today: ".$visitors[0]." from total: ".$visitors[1]." visitors, since ".$visitors[2];
?>
--------------------------------------------------------------------------------------------------
*/
/*
* ============================================================
* function offset_time()
* Return updated Unix timestamp after recalculate with $offset
* ------------------------------------------------------------
*/
function offset_time() {
global $offset;
$offsettime = time()+$offset;
$localtime = getdate($offsettime);
$i = 0;
while(list($k,$v) = each($localtime)){
if($i == 0){
$detik = $v;
if($detik < 10){ $detik = "0".$detik; }
}elseif($i == 1){
$menit = $v;
if($menit < 10){ $menit = "0".$menit; }
}elseif($i == 2){
$jam = $v;
if($jam < 10){ $jam = "0".$jam; }
}elseif($i == 3){
$tanggal = $v;
if($tanggal < 10) { $tanggal = "0".$tanggal; }
}elseif($i == 5){
$bulan = $v;
if($bulan < 10) { $bulan = "0".$bulan; }
}elseif($i == 6){
$tahun = $v;
}
$i++;
}
$offset_time = "$tahun$bulan$tanggal$jam$menit$detik";
return $offset_time;
}
/*
* ============================================================
* function daily_count($counter_file_name, $visitor_file_name)
* Display how many visitors get in!
* ------------------------------------------------------------
*/
function daily_count($counter_file_name, $visitor_file_name){
global $base_datapath, $REMOTE_ADDR, $HTTP_USER_AGENT, $HTTP_REFERER;
if(empty($counter_file_name)){ $counter_file_name = "daily_count.wmn"; }
if(empty($visitor_file_name)){ $visitor_file_name = "daily_visitors.wmn"; }
$counter_file_path = $base_datapath."/".$counter_file_name;
$visitor_file_path = $base_datapath."/".$visitor_file_name;
$get_visitors = 0;
$get_total = 0;
$new = 1;
$newday = 0;
$visitor_found = 0;
$elap_time = 3600;
$visitor_host = gethostbyaddr($REMOTE_ADDR);
if(!$visitor_host){ $visitor_host = $REMOTE_ADDR; }
$offset_time = offset_time();
$currTime = time() + $offset;
$tahun = substr($offset_time,0,4);
$bulan = substr($offset_time,4,2);
$hari = substr($offset_time,6,2);
$currDate = $tahun."-".$bulan."-".$hari;
$firstDate = $currDate;
if(file_exists($counter_file_path) && file_exists($visitor_file_path)){
$new = 0;
$f_c_contents = file("$counter_file_path");
while(list($lineno,$row) = each($f_c_contents)){
$row_content = explode("|",$row);
if($row_content[0] == $currDate){
$f_v_contents = file("$visitor_file_path");
$get_visitors = $row_content[1];
while(list($v_lineno,$v_row) = each($f_v_contents)){
$row_v_content = explode("|",$v_row);
if(($row_v_content[1] == $REMOTE_ADDR) && (($row_v_content[0] + $elap_time) > $currTime)) {
$visitor_found = 1;
}
}
}else{
$newday = 1;
}
$firstDate = $row_content[3];
$get_total = $row_content[2];
}
}
if(!$visitor_found){
$get_visitors = $get_visitors + 1;
$get_total = $get_total + 1;
if($newday || $new){
$fo = fopen($visitor_file_path,"w");
}else{
$fo = fopen($visitor_file_path,"a");
}
fwrite($fo,"$currTime|$REMOTE_ADDR|$visitor_host|$HTTP_USER_AGENT|$HTTP_REFERER\n");
fclose($fo);
$fo = fopen($counter_file_path,"w");
fwrite($fo,"$currDate|$get_visitors|$get_total|$firstDate");
fclose($fo);
}
$return = array("$get_visitors","$get_total","$firstDate");
return $return;
}
?>