View file new.php

File size: 2.47Kb
<?php
@$pas=$_GET['pas'];
@$do=$_POST['do'];
require('ini.php');
Header('Content-type: application/xhtml+xml;charset=utf-8');
Header('Cache-control: no-cache, must-revalidate');
print'<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head><title>New</title><link rel="stylesheet" type="text/css" href="style.css" /></head><body><div>';
if($do!=''){
@$tname=htmlspecialchars($_POST['tname']);
@$nick=htmlspecialchars($_POST['nick']);
@$ttext=htmlspecialchars($_POST['text']);
$tname=trim($tname);
$nick=trim($nick);
$ttext=trim($ttext);
if($ttext=='' || $nick=='' || $tname==''){die('Не заполнено одно из необходимых полей!</div></body></html>');}
$tname=str_replace(':||:','',$tname);
$nick=str_replace(':||:','',$nick);
$ttext=str_replace(':||:','',$ttext);
$tname=str_replace("\n",'',$tname);
$nick=str_replace("\n",'',$nick);
$ttext=str_replace("\n",'',$ttext);
$br=getenv('HTTP_USER_AGENT');
$ip=getenv('REMOTE_ADDR');
$date=date('d.m G:i', time());
$arr=file('themes.dat');
$r=time();
foreach($arr as $str){
$str=explode(':||:',$str);
if($str[1]==$tname){die('Такая тема уже существует!<br />&lt;&lt;<a href="new.php">Назад</a></div></body></html>');}
}
$f=fopen('themes.dat','w');
$data='t'.$r.'.dat:||:'.trim($tname).':||:'.trim($nick).':||:'.$date.':||:1'."\n";
$d=implode('',$arr);
fputs($f,$data.$d);
fclose($f);
include'smiles.ini.php';
$ttext=str_replace($sstr,$simg,$ttext);
$f=fopen('data/t'.$r.'.dat','w');
chmod('data/t'.$r.'.dat',0777);
fputs($f,trim($nick).':||:'.trim($ttext).':||:'.$date.':||:'.$br.':||:'.$ip."\n");
fclose($f);
print'Тема создана.<br /><a href="view.php?';
if($pas){print'pas='.$pas.'&amp;';}
print'n=0">Перейти к теме</a>';
}
else{
print'<form action="new.php';
if($pas!=''){print'?pas='.$pas;}
echo'" method="post">
<div>Имя:</div>
<input type="text" name="nick" maxlenght="20" size="6" /><br />
<div>Название темы:</div>
<input type="text" name="tname" value="" maxlenght="80" size="14" /><br />
<div>Сообщение:</div>
<input type="text" name="text" value="" size="14" /><br />
<input type="submit" name="do" value="Добавить" />
</form>';
}
print'<hr />[<a href="index.php';
if($pas){print'?pas='.$pas;}
print'">К темам</a>]</div></body></html>';
?>