Просмотр файла count.php

Размер файла: 2.88Kb
<?php
include "conf.php";
echo "document.write (\"<font size=-1><a href=$rataddr>$ratname</a> \");";

if (isset($_GET['cat'])) $cat = htmlspecialchars(trim($_GET['cat'])); else $cat = "top";
if (isset($_GET['sit'])) $cnum = htmlspecialchars(trim($_GET['sit'])); else $cnum = "top";
/* Определение категории сайта:
	1 - интернет
	2 - компьютеры
	3 - культура
	4 - личное
	5 - сми
	6 - досуг
	7 - спорт
*/
if ($cat == "1") $cpat = "internet/";
if ($cat == "2") $cpat = "computer/";
if ($cat == "3") $cpat = "culture/";
if ($cat == "4") $cpat = "lichnoe/";
if ($cat == "5") $cpat = "smi/";
if ($cat == "6") $cpat = "dosug/";
if ($cat == "7") $cpat = "sport/";
	$infile = $cpat;
	$infile .= $cnum;
	$onfile = $infile;
	$infile .= ".txt";
	$onfile .= ".tmp";
$ifile = fopen ($infile, "r");
$ofile = fopen ($onfile, "w");
	$allhits = fgets ($ifile, 1024);
	$allhits = trim($allhits);
	$todhits = fgets ($ifile, 1024);
	$todhits = trim($todhits);
	$sname = fgets ($ifile, 1024);
	$sname = trim($sname);
	$saddr = fgets ($ifile, 1024);
	$saddr = trim($saddr);
	$semail = fgets ($ifile, 1024);
	$semail = trim($semail);
	$spass = fgets ($ifile, 1024);
	$spass = trim($spass);
	if ($snum == $action) {
	$allhits++;
	$todhits++;
	}
	fputs ($ofile, "$allhits\n");
	fputs ($ofile, "$todhits\n");
	fputs ($ofile, "$sname\n");
	fputs ($ofile, "$saddr\n");
	fputs ($ofile, "$semail\n");
	fputs ($ofile, "$spass");
fclose ($ofile);
fclose ($ifile);
$ifile = fopen ($onfile, "r");
$ofile = fopen ($infile, "w");
	$allhits = fgets ($ifile, 1024);
	$todhits = fgets ($ifile, 1024);
	$sname = fgets ($ifile, 1024);
	$saddr = fgets ($ifile, 1024);
	$semail = fgets ($ifile, 1024);
	$spass = fgets ($ifile, 1024);
	fputs ($ofile, "$allhits");
	fputs ($ofile, "$todhits");
	fputs ($ofile, "$sname");
	fputs ($ofile, "$saddr");
	fputs ($ofile, "$semail");
	fputs ($ofile, "$spass");
fclose ($ofile);
fclose ($ifile);
unlink ($onfile);
$allhits = trim($allhits);
$todhits = trim($todhits);
echo "document.write (\"$allhits + $todhits</font>\");";

// Проверка текушей даты, если она не равна той, что записана в date.txt, то
//вызывается модуль сброса счетчика reset.php
$file = fopen ("data/date.txt", "r");
	$da = trim(date(d));
	$df = trim(fgets ($file, 1024));
fclose ($file);
if ($da != $df) {
	$file = fopen ("data/date.txt", "w");
		fputs ($file, "$da");
	fclose ($file);
	include "reset.php";
}

// Проверка числа учтенных посещений, если оно будет больше значения $ratmabu в файле
//conf.php, то счетчик сбрасывается и производится сортировка рейтинга
$file = fopen ("data/curhits.txt", "r");
	$curvitsval = fgets ($file, 1024);
fclose ($file);
	$curvitsval = trim($curvitsval);
	$curvitsval++;
	if ($curvitsval > $ratmabu) {
		$curvitsval = "1";
		include "sort.php";
	}
$file = fopen ("data/curhits.txt", "w");
	fputs ($file, "$curvitsval");
fclose ($file);

?>