/* Counter Information Anbieter: http://www.banecom.de Autor: Andrija Huibner */ // einstellungen // ip-protection in seconds $counter_expire = 600; // datebase host $counter_host = "localhost"; $counter_user = "laber"; $counter_password = "123456pw#"; $counter_database = "laberkopp"; $counter_connected = true; // connect to database $link = @mysql_connect($counter_host, $counter_user, $counter_password); if (!$link) { // can't connect to database $counter_connected = false; echo "Counter: " . mysql_error(); } else { // select database $db_selected = @mysql_select_db($counter_database, $link); if (!$db_selected) { // can't select database $counter_connected = false; echo "Counter: " . mysql_error(); } } if ($counter_connected == true) { $ignore = false; // get counter information $sql = "select * from counter_values"; $res = mysql_query($sql); // fill when empty if (mysql_num_rows($res) == 0) { $sql = "INSERT INTO `counter_values` (`id`, `day_id`, `day_value`, `week_id`, `week_value`, `month_id`, `month_value`, `year_id`, `year_value`, `all_value`, `record_date`, `record_value`) VALUES ('1', '" . date("z") . "', '1', '" . date("W") . "', '1', '" . date("n") . "', '1', '" . date("Y") . "', '1', '1', NOW(), '1')"; mysql_query($sql); $sql = "select * from counter_values"; $res = mysql_query($sql); $ignore = true; } $row = mysql_fetch_assoc($res); $day_id = $row['day_id']; $day_value = $row['day_value']; $week_id = $row['week_id']; $week_value = $row['week_value']; $month_id = $row['month_id']; $month_value = $row['month_value']; $year_id = $row['year_id']; $year_value = $row['year_value']; $all_value = $row['all_value']; $record_date = $row['record_date']; $record_value = $row['record_value']; $counter_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? addslashes(trim($_SERVER['HTTP_USER_AGENT'])) : ""; $counter_time = time(); $counter_ip = trim(addslashes($_SERVER['REMOTE_ADDR'])); // ignorore some bots if (substr_count($counter_agent, "bot") > 0) $ignore = true; // delete free ips if ($ignore == false) { $sql = "delete from counter_ips where unix_timestamp(NOW())-unix_timestamp(visit) > $counter_expire"; mysql_query($sql); } // check for entry if ($ignore == false) { $sql = "select * from counter_ips where ip = '$counter_ip'"; $res = mysql_query($sql); if (mysql_num_rows($res) == 0) { // insert $sql = "INSERT INTO counter_ips (ip, visit) VALUES ('$counter_ip', NOW())"; mysql_query($sql); } else { $ignore = true; $sql = "update counter_ips set visit = NOW() where ip = '$counter_ip'"; mysql_query($sql); } } // online? $sql = "select * from counter_ips"; $res = mysql_query($sql); $online = mysql_num_rows($res); // add counter if ($ignore == false) { // day if ($day_id == date("z")) { $day_value++; } else { $day_value = 1; $day_id = date("z"); } // week if ($week_id == date("W")) { $week_value++; } else { $week_value = 1; $week_id = date("W"); } // month if ($month_id == date("n")) { $month_value++; } else { $month_value = 1; $month_id = date("n"); } // year if ($year_id == date("Y")) { $year_value++; } else { $year_value = 1; $year_id = date("Y"); } // all $all_value++; // neuer record? if ($day_value > $record_value) { $record_value = $day_value; $record_date = date("Y-m-d H:i:s"); } // speichern und aufräumen $sql = "update counter_values set day_id = '$day_id', day_value = '$day_value', week_id = '$week_id', week_value = '$week_value', month_id = '$month_id', month_value = '$month_value', year_id = '$year_id', year_value = '$year_value', all_value = '$all_value', record_date = '$record_date', record_value = '$record_value' where id = 1"; mysql_query($sql); } ?>
Online : echo $online; ?> | Heute : echo $day_value; ?> | Woche : echo $week_value; ?> | Monat : echo $month_value; ?> | Jahr : echo $year_value; ?> | Gesamt : echo $all_value; ?> | Rekord : echo $record_value; ?> ( echo date("d.m.Y", strtotime($record_date)) ?> ) |