Просмотр файла forum/upl.php

Размер файла: 9.67Kb
<?php
// автор скрипта - Arab
// icq - 9988817   сайт: http://bola.net.ru

Error_Reporting(E_ALL & ~E_NOTICE);
Error_Reporting (ERROR | WARNING);

include_once "includ/functions.php";
include_once "includ/login.php";
include_once "includ/setting.php";
include_once "includ/online.php";
$ver=full_check($ver);

$realtime = time();
$realtime=check(strtolower($realtime));
$ip=check($_SERVER['REMOTE_ADDR']);
if (!$_SESSION[login]=="" && !md5($_SESSION[password])=="" && md5($_SESSION[password])==$npassword && $_SESSION[login]==$nlogin){

if($m_level=="4" && $m_balls<$upl_balls){  echo'<center><b>Вы не можете выгрузить файл так как у вас меньше  '.$upl_balls.' ти баллов!</b></center></div>';
include_once "../css/red/foot.php"; exit;}
if($let_upl=="0"){ echo'<b>Выгрузка файлов запрещена админом!</b></div>';
include_once "../css/red/foot.php"; exit;}
if($let_upl=="1" && $m_level=="4"){ echo'<b>Выгрузка файлов запрещена админом!</b></div>';
include_once "../css/red/foot.php"; exit;}

if (isset($_POST['upl_file'])) $upl_file=check($_POST['upl_file']);
if (isset($_POST['id'])) $id=check($_POST['id']);
if (isset($_POST['tems'])) $tems=check($_POST['tems']);
if (isset($_POST['msg'])) $msg=$_POST['msg'];
if (isset($_POST['strok'])) $strok=check($_POST['strok']);

$valid_types = array("rar","jar","jad","jpg","gif","zip","txt","cab");  // допустимые расширения файла

$Up_file=strtolower($_FILES['upl_file']['name']);
$Up_size=check($_FILES['upl_file']['size']);
$Up_size=check($Up_size);

$checkop = @file("$maindir/forum/data/forum/".check($id).".tem");
$chek = explode("|",$checkop[0]);
if($chek[9]=="closed"){
include_once "../css/red/index.php";
echo'<center><font color="#dd1111"><b>Нельзя писать в закрытую тему!</b></font></center>';
include_once "../css/red/foot.php"; exit;}

if($day_chas<=8 && $day_chas>=1){
$msg_time=time()-70;
if($m_antiflood>$msg_time){
include_once "../css/red/index.php";
echo'<p align="center"><br><b>Ночной сторож: нельзя добавлять сообщения чаще чем в каждые 70сек!</b></p>';
include_once "../css/red/foot.php"; exit;}}

$msg_time=time()-$conf_antiflood;
if($m_antiflood>$msg_time){
include_once "../css/red/index.php";
echo'<p align="center"><br><b>Анти-флуд: нельзя добавлять сообщения слишком часто!</b></p>';
include_once "../css/red/foot.php"; exit;}

if(eregi("[^a-z0-9._-]",$Up_file)){
include_once "../css/red/index.php";
echo'В названии файла '.$Up_file.' присутствуют недопустимые символы'; 
include_once "../css/red/foot.php"; exit;}

$tochek = substr_count("$Up_file", ".");
if($tochek>1){
include_once "../css/red/index.php";
echo'Ошибка!<br>Запрещенные символы в названии файла! Слишком много расширений!<br>';
include_once "../css/red/foot.php"; exit;}

if(stristr($Up_file,'.php') or stristr($Up_file,'.inc')){
include_once "../css/red/index.php";
echo'Идите нахуй<br>';
include_once "../css/red/foot.php"; exit;}

$ext = substr($Up_file, 1 + strrpos($Up_file, "."));
if (!in_array($ext, $valid_types)) {
include_once "../css/red/index.php";
echo '<br><b>Ошибка!</b><br>Данное расширение файла не разрешено!<br>
Разрешенные расширения: ';
foreach($valid_types as $index => $val){
echo("$val, ");}
echo'<br>'; include_once "../css/red/foot.php"; exit;}

if(file_exists("data/base/$Up_file")){
include_once "../css/red/index.php";
echo'Файл с таким названием уже существует!';
include_once "../css/red/foot.php"; exit;}

if(empty($Up_file)){
include_once "../css/red/index.php";
echo'<p align="center"><b>Имя файла пустое</b></p>';
include_once "../css/red/foot.php"; exit;}

if(win_to_utf(strlen(utf_to_win($Up_file)))<3 || win_to_utf(strlen(utf_to_win($Up_file)))>26){
include_once "../css/red/index.php";
echo'<p align="center"><b>Имя файла слишком короткое или длинное</b></p>';
include_once "../css/red/foot.php"; exit;}

if(empty($msg)){
include_once "../css/red/index.php";
echo'<p align="center"><b>Забыли написать описание</b></p>';
include_once "../css/red/foot.php"; exit;}

if(win_to_utf(strlen(utf_to_win($msg)))<3 || win_to_utf(strlen(utf_to_win($msg)))>2000){
include_once "../css/red/index.php";
echo'<p align="center"><b>Описание слишком короткое или длинное</b></p>';
include_once "../css/red/foot.php"; exit;}

$Up_file=check(strtolower($Up_file));
$msg=check($msg);

if(!file_exists(''.$maindir.'/forum/data/forum/'.$id.'.tem')){
include_once "../css/red/index.php";
echo'<center>Такой темы не существует!</center>';
include_once "../css/red/foot.php"; exit;}
if(!is_numeric($id)){
include_once "../css/red/index.php";
echo'Пошел нах!'; include_once "../css/red/foot.php"; exit;}
if(!is_numeric($tems)){
include_once "../css/red/index.php";
echo'Пошел нах!'; include_once "../css/red/foot.php"; exit;}
if(!file_exists(''.$maindir.'/forum/data/forum/razd'.$tems.'.dat')){
include_once "../css/red/index.php";
echo'<center>Такого раздела не существует!</center>';
include_once "../css/red/foot.php"; exit;}


if($Up_size!="0" and $Up_size<$forum_upsize){
copy($_FILES['upl_file']['tmp_name'], "$maindir/forum/data/base/".check("$realtime$Up_file"));
chmod("data/base/$Up_file", 0777);
}else{
include_once "../css/red/index.php";
$forum_upsizes=$forum_upsize='.$forum_upsize.'/1000;
echo 'Произошла ошибка при выгрузке файла! Возможно вес превышает допустимый размер';
include_once "../css/red/foot.php"; exit;}

///////////////////////////////////////// проверка на мат. если есть мат то юзер летит в баню
if($m_level=="4"){
$msg=antimat($msg);
if(eregi("W4d66R6T89ывnы7UвrаV3мKfD",$msg)){
$povod = "мат на форуме";
$vremya = check($realtime+$conf_avtobantime);
$allban = check($m_allban+1);

$text=$udata[0].'|'.$udata[1].'|'.$udata[2].'|'.$udata[3].'|'.$udata[4].'|'.$udata[5].'|'.$udata[6].'|'.$data[7].'|'.$udata[8].'|'.$udata[9].'|'.$udata[10].'|'.$udata[11].'|'.$udata[12].'|'.$udata[13].'|'.$udata[14].'|'.$udata[15].'|'.$udata[16].'|'.$udata[17].'|'.$vremya.'|'.$povod.'|'.$udata[20].'|'.$udata[21].'|'.$allban.'|'.$udata[23].'|'.$udata[24].'|'.$udata[25].'|'.$udata[26].'|'.$udata[27].'|'.$udata[28].'|'.time().'|';
$text=str_replace("\r\n", "", $text);
$fp=fopen(''.check($maindir).'/forum/data/users/'.check($login.log).'','r+');
flock($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,"$text");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
chmod (''.check($maindir).'/forum/data/users/'.check($login).'.log', 0666);

if($m_allban>"$conf_allbans"){ @unlink("$maindir/forum/data/users/$login.log"); @unlink("$maindir/forum/data/privat/$login.dat"); }
$msgtime = check(date("G:i/j F"));
$data = check(date("j.n.y"));
$time = check(date("G:i"));
$textmsg=$tems.'|'.$temname[1].'|Система|'.$temname[3].'|'.$id.'|Пользователь <b>'.$login.'</b> забанен за мат!|'.$time.'|'.$data.'|'.$ip.'|'.$temname[9].'|';

$fp=fopen("$maindir/forum/data/forum/".check($id).".tem","a+");
flock($fp,LOCK_EX);
fputs($fp,"$textmsg\r\n");
flock($fp,LOCK_UN);
fclose($fp);
chmod ("$maindir/forum/data/forum/$id.tem", 0666);
header ("Location: index.php?".SID); exit; }}






$data = check(date("j.n.y"));
$time = check(date("G:i"));

$fx = file("$maindir/forum/data/mainforum.dat");
$other = explode("|",$fx[$tems]);
$f = file("$maindir/forum/data/forum/".check($id).".tem");
$temname = explode("|",$f[0]);
$file_siz= filesize("data/base/$realtime$Up_file");

$txttem=$tems.'|'.$temname[1].'|'.$login.'|'.$temname[3].'|'.$id.'|<a href="data/base/'.$realtime.''.$Up_file.'">'.$Up_file.'</a>('.formatsize($file_siz).') <a href="?del='.$realtime.''.$Up_file.'">del</a><br> '.$msg.'|'.$time.'|'.$data.'|'.$ip.'|'.$temname[9].'|';		/////  ТЕМА
$fp=fopen("$maindir/forum/data/forum/".check($id).".tem","a+");
$txttem=str_replace("\r\n", "", $txttem);
fputs($fp,"$txttem\r\n");
fclose($fp);

$plusmsg=$other[3]+1;
$fx[$tems]="$other[0]|$other[1]|$other[2]|$plusmsg|$login|$temname[3]|$time|$data|$id|\r\n";
$rezultat=implode("",$fx);
$fp=fopen("$maindir/forum/data/mainforum.dat","w");
fputs($fp,$rezultat);

$fff = file("$maindir/forum/data/users/$login.log");	// +1 балл
$udata = explode("|",$fff[0]);
$ballplus=$udata[20]+1;
$forumplus=$udata[21]+1;

$text=$udata[0].'|'.$udata[1].'|'.$udata[2].'|'.$udata[3].'|'.$udata[4].'|'.$udata[5].'|'.$udata[6].'|'.$data[7].'|'.$udata[8].'|'.$udata[9].'|'.$udata[10].'|'.$udata[11].'|'.$udata[12].'|'.$udata[13].'|'.$udata[14].'|'.$udata[15].'|'.$udata[16].'|'.$udata[17].'|'.$udata[18].'|'.$udata[19].'|'.$ballplus.'|'.$forumplus.'|'.$udata[22].'|'.$udata[23].'|'.$udata[24].'|'.$udata[25].'|'.$udata[26].'|'.$udata[27].'|'.$udata[28].'|'.time().'|';

$text=str_replace("\r\n", "", $text);
$fp=fopen("$maindir/forum/data/users/$login.log","r+");
fputs($fp,"$text");
fclose($fp);
if($ver=="web"){
header ("Location: web.php?addmsg&messages&tem=$tems&id=$id&amp;".SID); }else{
header ("Location: index.php?addmsg&messages&tem=$tems&id=$id&amp;".SID); }

}else{
include_once "../css/red/index.php";
echo'Вы не авторизованы';
include_once "../css/red/foot.php"; exit;}

?>