<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"../template/functions.php";
require_once"../template/maincore.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";
function save_file ($_FILES,$uploadfile)
{
global $ext;
global $autor;
$op=htmlspecialchars(stripslashes($_POST['msg']));


if($_FILES['userfile']['size']<=921600){
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
if ($op!='')
{
$op=stripslashes(htmlspecialchars($op));
$op=str_replace("\n\r","<br />",$op);
$op=str_replace("\n","<br />",$op);
$op=str_replace("\r","<br />",$op);
$op=str_replace("<br /><br />","<br />",$op);
$fn=$_FILES['userfile']['name'];
$fp=fopen("$ext/$fn.txt","wb");

flock ($fp,LOCK_EX);
fputs($fp,"$op<br>Добавил:$autor\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
}
else 
{

$fn=$_FILES['userfile']['name'];
$fp=fopen("$ext/$fn.txt","wb");
flock ($fp,LOCK_EX);
fputs($fp,"$dt[6]|:|$autor\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
}

}

else
{
require_once 'error.php';
require_once"../template/foot.php";
exit;
}



}
}

if (ereg(".php",$_FILES['userfile']['name']) || ereg(".wmls",$_FILES['userfile']['name']))
{
echo 'Больше так не делай!!!<br />';
}


$ext = explode('.',$_FILES['userfile']['name']);
$ext = $ext[count($ext)-1];
$f="/";
$ext1=$ext;
////////////////////////////////////////////////////////////////////////////
///Проверка типов файлов
//////////////////////////////формируем имя файла с русским именем файла
///пишем функция сохранения файла с русским именем
//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////мелодии
if ($ext=='mid')
{$upmid = $upmelod.$ext.$f. basename($_FILES['userfile']['name']);
save_file ($_FILES,$upmid);}

if ($ext=='mp3')
{$upmp3 = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upmp3);}
 
if ($ext=='amr')
{$upamr = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upamr);}
 
if ($ext=='mmf')
{$upmmf = $ext.$f. basename($_FILES['userfile']['name']);
  save_file ($_FILES,$upmmf);}
  
if ($ext=='wav')
{$upwav = $ext.$f. basename($_FILES['userfile']['name']);
///////картинки
   save_file ($_FILES,$upwav);}
   
   if ($ext=='bmp')
{$upbmp = $ext.$f. basename($_FILES['userfile']['name']);
///////картинки
   save_file ($_FILES,$upbmp);}
   
    if ($ext=='rar')
{$uprar = $ext.$f. basename($_FILES['userfile']['name']);
///////картинки
   save_file ($_FILES,$uprar);}
   
if ($ext=='gif')
{$upgif = $ext.$f. basename($_FILES['userfile']['name']);
    save_file ($_FILES,$upgif);}
    
if ($ext=='jpg')
{$upjpg = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upjpg);}
 
if ($ext=='png')
{$uppng = $ext.$f. basename($_FILES['userfile']['name']);
     save_file ($_FILES,$uppng);}
     
if ($ext=='zip')
{$upzip = $ext.$f. basename($_FILES['userfile']['name']);
     save_file ($_FILES,$upzip);} // zip
     
if ($ext=='3gp')
{$upvideo = $ext.$f. basename($_FILES['userfile']['name']);
     save_file ($_FILES,$upvideo);}
     
if ($ext=='jar')
{$upjar = $ext.$f. basename($_FILES['userfile']['name']);
save_file ($_FILES,$upjar);}

if ($ext=='sis')
{$upsis = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upsis);}
 
 if ($ext=='cab')
{$upcab = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upcab);}
 
 if ($ext=='arm')
{$uparm = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$uparm);}
 
  if ($ext=='jad')
{$upjad = $ext.$f. basename($_FILES['userfile']['name']);
 save_file ($_FILES,$upjad);}
 
 ?>