amir6268
سه شنبه 03 آذر 1394, 14:42 عصر
سلام
میخواستم آخرین حضور کاربران سایت را با استفاده از دقیقه و روز نمایش بدم.
مثلا آخرین بازدید یک روز پیش
یا آخرین بازدید 10 دقیقه پیش
لطفا اگه میشه با کد بزارید ...
tamafi6
چهارشنبه 04 آذر 1394, 20:45 عصر
دوست عزیزباphp چقدرآشنایی دارید
درزیرمن یک نمونه کامل قرارمیدم که با php نوشته شده مزیت این نمونه این هست با هربار ورود ادمین یک پیغام برای ادمین هم ارسال میشه که برای امنیت خیلی مهمه
کافی هست خودتون کانفیگش کنید
<?php$root = $_SERVER['DOCUMENT_ROOT'] . '/minicms/';$data = 'data/';$email = "user@domain.com";$notify = true;$domain = "localhost";$use_number_format = true;$milestones = array(1, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000, 10000000);function statistics_check_file($file){ if (!file_exists($file)) { $handle = fopen($file, "w"); fclose($handle); chmod($file, 0666); return false; } return true;}
$file_detail = $root . $data . 'detail.dat';$file_total = $root . $data . 'total.dat';$file_notify = $root . $data . 'notify.dat';$ip = $_SERVER['REMOTE_ADDR'];$online = 0;$today = 0;$yesterday = 0;$total = 0;$minutes = 15;$time = time();$day = date("j");$month = date("n");$year = date("Y");$detail = "";$match = false;$match_today = false;$milestone_new = false;statistics_check_file($file_detail);$detail = explode("\n", file_get_contents($file_detail));$handle_detail = fopen($file_detail, "w");foreach ($detail as $line){ list($stored_ip, $stored_time, $stored_day, $stored_month, $stored_year) = explode("|", $line); $temp_day = $day - 1; $temp_month = $month; $temp_year = $year; if ($temp_day == 0) { $temp_month--; if ($temp_month == 0) { $temp_month = 12; $temp_year--; } switch ($temp_month) { case 1: $temp_day = 31; break; case 2: $temp_day = 28; break; case 3: $temp_day = 31; break; case 4: $temp_day = 30; break; case 5: $temp_day = 31; break; case 6: $temp_day = 30; break; case 7: $temp_day = 31; break; case 8: $temp_day = 31; break; case 9: $temp_day = 30; break; case 10: $temp_day = 31; break; case 11: $temp_day = 30; break; case 12: $temp_day = 31; break; } } if ($stored_ip == $ip) { $match = true; if ($stored_day == $day && $stored_month == $month && $stored_year == $year) { $match_today = true; $stored_time = $time; } } if ($stored_day == $day && $stored_month == $month && $stored_year == $year) { fwrite($handle_detail, "$stored_ip|$stored_time|$stored_day|$stored_month| $stored_year\n"); $today++; if ($time < $stored_time + ($minutes * 60)) { $online++; } } elseif ($stored_day == $temp_day && $stored_month == $temp_month && $stored_year == $temp_year) { fwrite($handle_detail, "$stored_ip|$stored_time|$stored_day|$stored_month| $stored_year\n"); $yesterday++; }}if (!$match || $match && !$match_today){ fwrite($handle_detail, "$ip|$time|$day|$month|$year\n"); $online++; $today++; $total++;}fclose ($handle_detail);if (!statistics_check_file($file_total)){ $handle_total = fopen($file_total, "w"); flock($handle_total, LOCK_EX); fwrite($handle_total, "0"); fclose($handle_total);}$total += file_get_contents($file_total);$handle_total = fopen($file_total, "w");flock($handle_total, LOCK_EX);fwrite($handle_total, $total);fclose($handle_total);if (!statistics_check_file($file_notify)){ $handle_notify = fopen($file_notify, "w"); flock($handle_notify, LOCK_EX); fwrite($handle_notify, "0"); fclose($handle_notify);}$milestone_last = file_get_contents($file_notify);$handle_notify = fopen($file_notify, "w");flock($handle_notify, LOCK_EX);foreach ($milestones as $milestone){ if ($total == $milestone && $milestone_last < $total) { fwrite($handle_notify, $total); $milestone_new = true; break; }}if (!$milestone_new){ fwrite($handle_notify, $milestone_last);}
fclose($handle_notify);if ($notify && $milestone_new){ $mail_date = date ("d F Y"); $mail_time = date ("g:i A"); $mail_subject = "[ $domain ] Statistics - $total"; $mail_to = "$email"; $mail_message = "SITE: $domain\nDATE: $mail_date, $mail_time\nMILESTONE: $total\n"; $mail_headers = "From: $mail_subject <$mail_to>\n"; $mail_sent = mail($mail_to, $mail_subject, $mail_message, $mail_headers);}if ($use_number_format){ $online = number_format($online); $today = number_format($today); $yesterday = number_format($yesterday); $total = number_format($total);}?>
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.