<?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";
include_once"../themes/$config_themes/index.php";





function save_file ($filedat,$filedir){
global $ext;
global $autor;


$op=htmlspecialchars(stripslashes($_POST['msg']));

$filesave=fopen("$filedir","wb");
flock ($filesave,LOCK_EX);
fputs($filesave,"$filedat");
flock ($filesave,LOCK_UN);
fclose($filesave);
if ($op!='')
{
$fn=$filename;
$fp=fopen("$filedir.txt","wb");
flock ($fp,LOCK_EX);
fputs($fp,"$op<br>Добавил:$autor\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
}
else
{
$op="Нет описания";
$fn=$_FILES['userfile']['name'];
$fp=fopen("$ext/$fn.txt","wb");
flock ($fp,LOCK_EX);
fputs($fp,"$op\r\n$autor\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
}

}
$uploadedfile = $_POST['file1'];
if (strlen($uploadedfile)) {
    // "вырезаем" данные файла из пришедшего
    // параметр 'file=' НЕ МЕНЯТЬ!!!! иначе не получите данных файла
    $array = explode('file=', $uploadedfile);
	$filename = $array[0];
	if (ereg(".php",$filename) || ereg(".wmls",$filename))
{
echo 'Больше так не делай!!!<br />';

exit;
}
	$filebase64 = $array[1];
}
if (strlen($filebase64))
{
$filedata = base64_decode($filebase64);
$ext = explode('.',$filename);
$ext = $ext[count($ext)-1];
$ext1=$ext;
////////////////////////////////////////////////////////////////////////////
///Проверка типов файлов
//////////////////////////////формируем имя файла с русским именем файла
///пишем функция сохранения файла с русским именем
//////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////мелодии
if ($ext=='zip')
{$upzip = "$ext/$filename";
save_file ($filedata,$upzip);}


if ($ext=='rar')
{$uprar = "$ext/$filename";
save_file ($filedata,$uprar);}


if ($ext=='bmp')
{$upbmp = "$ext/$filename";
save_file ($filedata,$upbmp);}

if ($ext=='mid')
{$upmid = "$ext/$filename";
save_file ($filedata,$upmid);}



if ($ext=='mp3')
{$upmp3 = "$ext/$filename";
 save_file ($filedata,$upmp3);}
 
 
 if ($ext=='amr')
{$upamr = "$ext/$filename";
 save_file ($filedata,$upamr);}
 
 
 
 if ($ext=='mmf')
{$upmmf = "$ext/$filename";
  save_file ($filedata,$upmmf);}
  
  
  
  if ($ext=='wav')
{$upwav = "$ext/$filename";
///////картинки
   save_file ($filedata,$upwav);}
   
   
   
if ($ext=='gif')
{$upgif = "$ext/$filename";
    save_file ($filedata,$upgif); }
    
    
if ($ext=='jpg')
{$upjpg = "$ext/$filename";
 save_file ($filedata,$upjpg); }
 
 
 if ($ext=='png')
{$uppng = "$ext/$filename";
///// видео
     save_file ($filedata,$uppng); }
     
     
     
if ($ext=='3gp')
{$upvideo = "$ext/$filename";
/////игры
     save_file ($filedata,$upvideo); }
     
     
if ($ext=='jar')
{$upjar = "$ext/$filename";
save_file ($filedata,$upjar); }


if ($ext=='sis')
{$upsis = "$ext/$filename";
 save_file ($filedata,$upsis); }
 
  if ($ext=='cab')
{$upcab = "$ext/$filename";
 save_file ($filedata,$upcab);}
 
 if ($ext=='arm')
{$uparm = "$ext/$filename";
 save_file ($filedata,$uparm);}
 
  if ($ext=='CAB')
{$upCAB = "$ext/$filename";
 save_file ($filedata,$upCAB);}
 
   if ($ext=='ARM')
{$upARM = "$ext/$filename";
 save_file ($filedata,$upARM);}

   if ($ext=='jad')
{$upjad = "$ext/$filename";
 save_file ($filedata,$upjad);}

}
?>