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

Размер файла: 3.5Kb
<?php
include "conf.php";
if (isset($_GET['site'])) {
if (isset($_GET['site'])) $saddr = htmlspecialchars(trim($_GET['site'])); else $s = "no";
if (isset($_GET['about'])) $sabout = htmlspecialchars(trim($_GET['about'])); else $s = "no";
if (isset($_GET['email'])) $semail = htmlspecialchars(trim($_GET['email'])); else $s = "no";
if (isset($_GET['cat'])) $scat = htmlspecialchars(trim($_GET['cat'])); else $s = "no";
if (isset($_GET['pass'])) $spass = htmlspecialchars(trim($_GET['pass'])); else $s = "no";
if ($s == "no") {
echo "Ошибка";
exit;
}
if ($scat == "1") $cpat ="internet/";
if ($scat == "2") $cpat = "computer/";
if ($scat == "3") $cpat = "culture/";
if ($scat == "4") $cpat = "lichnoe/";
if ($scat == "5") $cpat = "smi/";
if ($scat == "6") $cpat = "dosug/";
if ($scat == "7") $cpat = "sport/";
$file = fopen ("data/counter.txt", "r");
	$nco = fgets ($file, 1024);
fclose ($file);
$nres = $nco;
$nind = $nco;
$file = fopen ("data/counter.txt", "w");
	fputs ($file, ++$nco);
fclose ($file);
$cnfile = $cpat;
$cnfile .= $nres;
$cnfile .= ".txt";
$file = fopen ($cnfile, "w");
	fputs ($file, "0\n");
	fputs ($file, "0\n");
	fputs ($file, "$sabout\n");
	fputs ($file, "$saddr\n");
	fputs ($file, "$semail\n");
	fputs ($file, "$spass");
fclose ($file);
//Запись в файл категории index.txt
//
$indexfile = $cpat;
$ondexfile = $cpat;
$ondexfile .= "index.tmp";
$indexfile .= "index.txt";
$ifile = fopen ($indexfile, "r");
$ofile = fopen ($ondexfile, "w");
	while (!feof ($ifile)) {
		$il = fgets ($ifile, 1024);
		fputs ($ofile, "$il");
	}
	fputs ($ofile, "$nres\n");
fclose ($ifile);
fclose ($ofile);
$ifile = fopen ($indexfile, "w");
$ofile = fopen ($ondexfile, "r");
	while (!feof ($ofile)) {
		$il = fgets ($ofile, 1024);
		fputs ($ifile, "$il");
	}
fclose ($ifile);
fclose ($ofile);
unlink ($ondexfile);
$ifile = fopen ("data/db.txt", "a");
	fputs ($ifile, "$semail\n$spass\n$scat\n$nres\n");
fclose ($ifile);
//
//Создание кода счетчика и письма
//
$message = "Ваш сайт внесен в базу данных\n";
$message .= $sabout;
$message .= "\nадрес:\n";
$message .= $saddr;
$message .= "\nE-Mail:\n";
$message .= $semail;
$message .= "\nпароль\n";
$message .= $spass;
$message .= "\nID категории\n";
$message .= $scat;
$message .= "\nID сайта\n";
$message .= $nres;
$message .= "\n\nДля участия в рейтинге необходимо установить счетчик:\n";
$ucode = "<script language=\"javascript\" src=\"";
$ucode .= $rataddr;
$ucode .= "count.php?cat=";
$ucode .= $scat;
$ucode .= "&sit=";
$ucode .= $nres;
$ucode .= "\"><!-- --></script>";
$message .= $ucode;
mail ($semail, $ratname, $message);
echo "<br>Ваш сайт начнет учавствовать в рейтинге после добавления на его страницы счетчика";
echo "<br>Посьмо с вашими данными и этим кодом выслано на $semail<br>";
echo "<br>Код счетчика";
echo "<form><textarea cols=60 rows=5>$ucode</textarea></form>";
} 
else 
{
echo "<form action=add.php method=get>";
echo "<br>Адрес сайта<br><input type=text name=site value=http://>";
echo "<br>Название сайта";
echo "<br><input type=text name=about>";
echo "<br>E-Mail<br><input type=text name=email>";
echo "<br>Категория<br><select name=cat> <option value=1>Интернет</option><option value=2>Компьютеры</option>";
echo "<option value=3>Культура</option><option value=4>Личное</option>";
echo "<option value=5>СМИ</option><option value=6>Досуг</option>";
echo "<option value=7>Спорт</option></select>";
echo "<br>Пароль<br><input type=text name=pass>";
echo "<br><input type=submit>";
echo "</form>";
}
?>