Просмотр файла lj/addtext.php

Размер файла: 4.86Kb
<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
include_once"../themes/$config_themes/index.php";
include_once"../template/isset.php";

require_once"../template/ljfun.php";
$date=date("d.m.y в H:i:s");
if($lj_raz==0){echo'<font color="#FF0000"><big><b>Добавление статей запрещенно администратором!</font></big></b><hr>';
echo'<br><a href="index.php?'.SID.'">В журнал</a><br>';
require_once"../themes/$config_themes/foot.php";
exit;}
if($lj_bal>$udata[36]){echo'<font color="#FF0000"><big><b>У Вас недостаточно балов для добавления минимум '.$lj_bal.' балов!</font></big></b><hr>';
echo'<br><a href="index.php?'.SID.'">В журнал</a><br>';
require_once"../themes/$config_themes/foot.php";
exit;}
if (!$_SESSION['log']=="" && !md5($_SESSION['par'])=="" && md5($_SESSION['par'])==$provpar && $_SESSION['log']==$provlog ) {
if(!isset($action)){
if($title=="") {
header ("Location: add.php?ist=ljnotitle");  exit();}
if($did=="") {
header ("Location: add.php?ist=ljnokat");  exit();}
if($msg=="") {
header ("Location: add.php?ist=ljnotext");  exit();}
if($log=="") {
header ("Location: add.php?isset=inputoff");  exit();}
if (strlen(utf_to_win(trim($title)))<3 || strlen(utf_to_win($title))>$lj_nazsim) { header ("Location: add.php?ist=inputoff&".SID); exit;}
if (strlen(utf_to_win(trim($msg)))<50  || strlen(utf_to_win($msg))>$lj_sim) { header ("Location: add.php?ist=inputoff&".SID); exit;}
if($config_floodstime > 0){
if(flooder($ip, $php_self) == TRUE ){header ("Location: index.php?isset=antiflood&".SID); exit;}
$flood_file = fopen(BASEDIR."local/flood.dat", "a+");
flock ($flood_file,LOCK_EX);
fputs ($flood_file, time()."|$ip|$php_self|\r\n");
fflush($flood_file);
flock ($flood_file,LOCK_UN);
fclose($flood_file);}
if (isset ($_GET['fid']) or isset ($_GET['title'])){header ("Location: index.php?isset=posts&".SID); exit;}
$did=check($did);
$msg=check($msg);
$title=check($title);
$ufile = file(BASEDIR."local/profil/$log.prof"); 
$udata = explode(":||:",$ufile[0]);
$udata[41]=round($udata[41]+$lj_many);
$udata[36]=round($udata[36]+$lj_bonus);
$udata[14]=$ip;
$udata[9]++;
for ($u=0; $u<$config_userprofkey; $u++){
$utext.=$udata[$u].':||:';}
if($udata[0]!="" && $udata[1]!="" && $udata[4]!="" && $utext!=""){
$fp=fopen(BASEDIR."local/profil/$log.prof","a+");
flock($fp,LOCK_EX);   
ftruncate($fp,0);                                                                 
fputs($fp,$utext);
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);  
unset($utext);
}
$dir = opendir ("$did"); 
   while ($file = readdir ($dir)) 
   {if (( $file != ".") && ($file != "..") && ($file != "name.dat") && !ereg (".dat$", "$file"))
   {$a[]=$file;}}  
   closedir ($dir);  
   sort($a);
   $shet_file = count($a);  
   $newname = $shet_file+1;
   $newname = $newname.'.txt';
$msg=str_replace ("&lt;br&gt;","\r\n",$msg);
$msg=str_replace ("<br>","\r\n",$msg);
$msg=str_replace ("<br />","\r\n",$msg);
$msg= smiles($msg);   
$fp=fopen("$did/$log.$did.$newname","w");
flock ($fp,LOCK_EX);
fputs($fp,"$title\r\n\r\nАвтор:$log\r\n Добавлено: $date \r\n \r\n $msg");
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
chmod($fp, 0666);
chmod("$did/$log.$did.$newname", 0666);
$f = file("../local/lj/$log.dat"); 
$u = explode(":||:",$f[0]);
$u[0]++;
$t=$u[0].':||:'.$log.':||:'.$date;
$fp = fopen("../local/lj/$log.dat","w");
flock ($fp,LOCK_EX);
fputs($fp,$t);
fflush ($fp);
flock ($fp,LOCK_UN);
fclose($fp);
chmod($fp, 0666);
chmod("../local/lj/$log.dat", 0666);
header ("Location: addtext.php?action=es&did=$did&name=$log.$did.$newname&".SID);}
if($action=="es"){
$f1 = file("../local/lj/$log.dat"); 
$u1 = explode(":||:",$f1[0]);
$name_kategory=file_get_contents("../lj/$did/name.dat");
echo '
<b>'.$log.', Вы добавили статью...</b><br><br>
<b>Раздел:</b> '.$name_kategory.'<br>
<b>Это ваша:</b> '.$u1[0].'-я запись ('.$date.')<br>
</div>';
echo '<div>
<li> <a href="lj.php?action=count&amp;did='.$did.'&amp;fid='.$name.'">Читать</a></li>
<li> <a href="add.php?'.SID.'">Добавить еще</a></li>';}


}else{echo 'Вы должны быть авторизованы! Выполните <a href="../pages/vhod.php?'.SID.'">вход</a> или <a href="../pages/registration.php?'.SID.'">зарегистрируйтесь</a><hr>';}
echo '<li> <a href="index.php?'.SID.'">B журнал</a></li>
<li> <a href="../index.php?'.SID.'">На главную</a></li></div>';
include_once"../themes/$config_themes/foot.php";
?>