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

Размер файла: 3.76Kb
<?php
include "conf.php";
$file = fopen ("head.htm", "r");
	while (!feof ($file)) {
		$line = fgets ($file, 1024);
		echo "$line";
	}
fclose ($file);
?>
<table width=100%>
<tr>
<td width=33% valign=top>
<a href=index.php>

<?php
	echo "$ratname";
?>

</a>
</td><td width=33% valign=top>
<a href=add.php>Добавить сайт</a></td>
<td width=33% valign=top><a href=remind.php>Забыли пароль?</a></td></tr></table>

<table width=100%>
<tr>
<td width=20% valign=top>
<b>Категории</b>
<?php
$i = "0";
$file = fopen ("internet/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=1>Интернет</a> ($i)";
$i = "0";
$file = fopen ("computer/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=2>Компьютеры</a> ($i)";
$i = "0";
$file = fopen ("culture/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=3>Культура</a> ($i)";
$i = "0";
$file = fopen ("lichnoe/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=4>Личное</a> ($i)";
$i = "0";
$file = fopen ("smi/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=5>СМИ</a> ($i)";
$i = "0";
$file = fopen ("dosug/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=6>Досуг</a> ($i)";
$i = "0";
$file = fopen ("sport/index.txt", "r");
	while (!feof ($file)) {
		$i++;
		$li = fgets ($file, 1024);
	}
fclose ($file);
$i = $i - 1;
	echo "<br><a href=index.php?cat=7>Спорт</a> ($i)";
?>

</td><td width=80% valign=top>

<?php
if (isset($_GET['cat'])) $cat = htmlspecialchars(trim($_GET['cat'])); else $cat = "0";
if ($cat == "0") {
$file = fopen ("about.htm", "r");
	while (!feof ($file)) {
		$line = fgets ($file, 1024);
		echo "$line";
	}
fclose ($file);
} else {
	if ($cat == "1") {
	$cname = "Интернет";
	$cpath = "internet/";
	}
	if ($cat == "2") {
	$cname = "Компьютеры";
	$cpath = "computer/";
	}
	if ($cat == "3") {
	$cname = "Культура";
	$cpath = "culture/";
	}
	if ($cat == "4") {
	$cname = "Личное";
	$cpath = "lichnoe/";
	}
	if ($cat == "5") {
	$cname = "СМИ";
	$cpath = "smi/";
	}
	if ($cat == "6") {
	$cname = "Досуг";
	$cpath = "dosug/";
	}
	if ($cat == "7") {
	$cname = "Спорт";
	$cpath = "sport/";
	}
	$i = "0";
	echo "<center><h2>$cname</h2></center>";
	echo "<table width=80%><tr><td width=10%>№</td><td width=50%>Сайт</td><td width=20%>";
	echo "сегодня</td><td width=20%>всего</td></tr>";
	$colr = "cccccc";
	$cfile = $cpath;
	$cfile .= "index.txt";
	$file = fopen ($cfile, "r");
		while (!feof ($file)) {
			$sfile = fgets($file, 1024);
			$sfile = trim($sfile);
			if ($sfile != "") {
				$sfile = $cpath.$sfile.".txt";
				$osfile = fopen ($sfile, "r");
					$i++;
					$tah = trim(fgets ($osfile, 1024));
					$tth = trim(fgets ($osfile, 1024));
					$tsn = trim(fgets ($osfile, 1024));
					$tsa = trim(fgets ($osfile, 1024));
					echo "<tr bgcolor=$colr><td>$i</td><td><a href=$tsa>$tsn</td>";
					echo "<td>$tth</td><td>$tah</td></tr>";
					if ($colr == "cccccc") {
						$colr = "dddddd";
					} else {
						$colr = "cccccc";
					}
				fclose ($osfile);
			}
		}
	fclose ($file);
	echo "</table>";
}
?>

</td></tr></table>

<?php
$file = fopen ("down.htm", "r");
	while (!feof ($file)) {
		$line = fgets ($file, 1024);
		echo "$line";
	}
fclose ($file);
?>