Вход Регистрация
Файл: obmen/inc/upload_form.php
Строк: 243
<?
if ($dir_id['upload']==1){




if (isset(
$_GET['act']) && $_GET['act']=='upload' && $l!='/')
{
if (!isset(
$set['obmen_limit_up']) || $set['obmen_limit_up']<=$user['balls']){
echo 
"<form class='foot' enctype="multipart/form-data" action='?act=upload&amp;ok&amp;page=$page' method="post">";
echo 
"Файл:<br />n";
echo 
"<input name='file' type='file' maxlength='$dir_id[maxfilesize]' /><br />n";
echo 
"Скриншот:<br />n";
echo 
"<input name='screen' type='file' accept='image/*' /><br />n";
echo 
"Описание:<br />n";
echo 
"<textarea name='opis'></textarea><br />n";
echo 
"<input class="submit" type="submit" value="Выгрузить" /><br />n";
echo 
"*Разрешается выгружать файлы форматов: $dir_id[ras]<br />n";
echo 
"Размером до: ".size_file($dir_id['maxfilesize'])."<br />n";
echo 
"&laquo;<a href='?'>Отмена</a><br />n";
echo 
"</form>";
}
else
{
echo 
"Выгружать файлы в обменник могут только пользователи, набравшие $set[obmen_limit_up] и более баллов<br />n";
}
}



echo 
"<div class="foot">n";
echo 
"&raquo;<b><a href='?act=upload&amp;page=$page'>Выгрузить файл</a></b><br />n";

if ( 
$set['obmen_import'] && isset($_GET['act']) && $_GET['act'] == 'import' && isset($user) && isset($_POST['file']) ) {


#

function get_mime_type($ext) {

$mime_types = array(
         
'ez' => 'application/andrew-inset',
         
'hqx' => 'application/mac-binhex40',
         
'cpt' => 'application/mac-compactpro',
         
'doc' => 'application/msword',
         
'bin' => 'application/octet-stream',
         
'dms' => 'application/octet-stream',
         
'lha' => 'application/octet-stream',
         
'lzh' => 'application/octet-stream',
         
'exe' => 'application/octet-stream',
         
'class' => 'application/octet-stream',
         
'so' => 'application/octet-stream',
         
'dll' => 'application/octet-stream',
         
'oda' => 'application/oda',
         
'pdf' => 'application/pdf',
         
'ai' => 'application/postscript',
         
'eps' => 'application/postscript',
         
'ps' => 'application/postscript',
         
'smi' => 'application/smil',
         
'smil' => 'application/smil',
         
'wbxml' => 'application/vnd.wap.wbxml',
         
'wmlc' => 'application/vnd.wap.wmlc',
         
'wmlsc' => 'application/vnd.wap.wmlscriptc',
         
'bcpio' => 'application/x-bcpio',
         
'vcd' => 'application/x-cdlink',
         
'pgn' => 'application/x-chess-pgn',
         
'cpio' => 'application/x-cpio',
         
'csh' => 'application/x-csh',
         
'dcr' => 'application/x-director',
         
'dir' => 'application/x-director',
         
'dxr' => 'application/x-director',
         
'dvi' => 'application/x-dvi',
         
'spl' => 'application/x-futuresplash',
         
'gtar' => 'application/x-gtar',
         
'hdf' => 'application/x-hdf',
         
'js' => 'application/x-javascript',
         
'skp' => 'application/x-koan',
         
'skd' => 'application/x-koan',
         
'skt' => 'application/x-koan',
         
'skm' => 'application/x-koan',
         
'latex' => 'application/x-latex',
         
'nc' => 'application/x-netcdf',
         
'cdf' => 'application/x-netcdf',
         
'sh' => 'application/x-sh',
         
'shar' => 'application/x-shar',
         
'swf' => 'application/x-shockwave-flash',
         
'sit' => 'application/x-stuffit',
         
'sv4cpio' => 'application/x-sv4cpio',
         
'sv4crc' => 'application/x-sv4crc',
         
'tar' => 'application/x-tar',
         
'tcl' => 'application/x-tcl',
         
'tex' => 'application/x-tex',
         
'texinfo' => 'application/x-texinfo',
         
'texi' => 'application/x-texinfo',
         
't' => 'application/x-troff',
         
'tr' => 'application/x-troff',
         
'roff' => 'application/x-troff',
         
'man' => 'application/x-troff-man',
         
'me' => 'application/x-troff-me',
         
'ms' => 'application/x-troff-ms',
         
'ustar' => 'application/x-ustar',
         
'src' => 'application/x-wais-source',
         
'xhtml' => 'application/xhtml+xml',
         
'xht' => 'application/xhtml+xml',
         
'zip' => 'application/zip',
         
'7z' => 'application/7z',
         
'rar' => 'application/x-rar',
         
'gz' => 'application/gzip',
         
'au' => 'audio/basic',
         
'snd' => 'audio/basic',
         
'mid' => 'audio/midi',
         
'midi' => 'audio/midi',
         
'kar' => 'audio/midi',
         
'mpga' => 'audio/mpeg',
         
'mp2' => 'audio/mpeg',
         
'mp3' => 'audio/mpeg',
         
'aif' => 'audio/x-aiff',
         
'aiff' => 'audio/x-aiff',
         
'aifc' => 'audio/x-aiff',
         
'm3u' => 'audio/x-mpegurl',
         
'ram' => 'audio/x-pn-realaudio',
         
'rm' => 'audio/x-pn-realaudio',
         
'rpm' => 'audio/x-pn-realaudio-plugin',
         
'ra' => 'audio/x-realaudio',
         
'wav' => 'audio/x-wav',
         
'pdb' => 'chemical/x-pdb',
         
'xyz' => 'chemical/x-xyz',
         
'bmp' => 'image/bmp',
         
'gif' => 'image/gif',
         
'ief' => 'image/ief',
         
'jpeg' => 'image/jpeg',
         
'jpg' => 'image/jpeg',
         
'jpe' => 'image/jpeg',
         
'png' => 'image/png',
         
'tiff' => 'image/tiff',
         
'tif' => 'image/tif',
         
'djvu' => 'image/vnd.djvu',
         
'djv' => 'image/vnd.djvu',
         
'wbmp' => 'image/vnd.wap.wbmp',
         
'ras' => 'image/x-cmu-raster',
         
'pnm' => 'image/x-portable-anymap',
         
'pbm' => 'image/x-portable-bitmap',
         
'pgm' => 'image/x-portable-graymap',
         
'ppm' => 'image/x-portable-pixmap',
         
'rgb' => 'image/x-rgb',
         
'xbm' => 'image/x-xbitmap',
         
'xpm' => 'image/x-xpixmap',
         
'xwd' => 'image/x-windowdump',
         
'igs' => 'model/iges',
         
'iges' => 'model/iges',
         
'msh' => 'model/mesh',
         
'mesh' => 'model/mesh',
         
'silo' => 'model/mesh',
         
'wrl' => 'model/vrml',
         
'vrml' => 'model/vrml',
         
'css' => 'text/css',
         
'html' => 'text/html',
         
'htm' => 'text/html',
         
'asc' => 'text/plain',
         
'txt' => 'text/plain',
         
'php' => 'text/plain',
         
'cgi' => 'text/plain',
         
'pl' => 'text/plain',
         
'rtx' => 'text/richtext',
         
'rtf' => 'text/rtf',
         
'sgml' => 'text/sgml',
         
'sgm' => 'text/sgml',
         
'tsv' => 'text/tab-seperated-values',
         
'wml' => 'text/vnd.wap.wml',
         
'wmls' => 'text/vnd.wap.wmlscript',
         
'wmlsc' => 'application/vnd.wap.wmlscriptc',
         
'etx' => 'text/x-setext',
         
'xml' => 'text/xml',
         
'xsl' => 'text/xml',
         
'mpeg' => 'video/mpeg',
         
'mpg' => 'video/mpeg',
         
'mpe' => 'video/mpeg',
         
'qt' => 'video/quicktime',
         
'mov' => 'video/quicktime',
         
'mxu' => 'video/vnd.mpegurl',
         
'avi' => 'video/x-msvideo',
         
'movie' => 'video/x-sgi-movie',
         
'3gp' => 'video/3gpp',
         
'mp4' => 'video/mp4',
         
'flv' => 'video/flv',
         
'mms' => 'application/vnd.wap.mms-message',
         
'rmf' => 'audio/rmf',
         
'sis' => 'application/vnd.symbian.install',
         
'sisx' => 'application/vnd.symbian.install',
         
'jar' => 'application/java-archive',
         
'jad' => 'text/vnd.sun.j2me.app-descriptor',
         
'ics' => 'text/calendar',
         
'vcs' => 'text/x-vcalendar',
         
'vcf' => 'text/x-vcard',
         
'emy' => 'text/x-emelody',
         
'imy' => 'text/x-imelody',
         
'hid' => 'application/x-tar',
         
'mmf' => 'application/vnd.smaf',
         
'mpc' => 'application/vnd.mophun.certificate',
         
'mpn' => 'application/vnd.mophun.application',
         
'thm' => 'application/vnd.eri.thm',
         
'tpl' => 'application/vnd.sonyericsson.mms-template',
         
'ice' => 'x-conference-xcooltalk',
         
'ico' => 'image/favicon.ico'
      
);
      
return isset(
$mime_types[$ext]) ? $mime_types[$ext] : 'application/octet-stream';

}

#



$file trim(stripslashes($_POST['file']));
$name trim(stripslashes($_POST['name']));
$screen trim(stripslashes($_POST['screen']));
$opis mysql_real_escape_string(trim(stripslashes($_POST['opis'])));

$file_de urldecode($file);

if ( 
preg_match('~^http://[a-z0-9.-]+.[a-z]{2,}/[a-z0-9.?=,/s-_]+$~i'$file_de) && preg_match('~(.*?).[a-z0-9]+$~i'$name) ) {

/*
if ( preg_match('~^http://[a-z0-9.?=&]+$~i', $file) && preg_match('~(.*?).[a-z0-9]+$~i', $name) ) {
*/
$file file_get_contents($file);

if ( 
$file ) {

$name2 preg_replace('~.[^.]*$~i'null$name); // имя файла без расширения
$ras strtolower(preg_replace('~^.*.~i'null$name));
$type get_mime_type($ras);
$rasss explode(';'$dir_id['ras']);

$ras_ok=false;
$count count($rasss);
for ( 
$i 0$i $count$i++ )
if ( 
$rasss[$i] != NULL && $ras == $rasss[$i] ) $ras_ok true;

if ( 
$ras_ok ) {

mysql_query("INSERT INTO `obmennik_files` (`id_dir`, `name`, `ras`, `type`, `size`, `time`, `time_last`, `id_user`, `opis` )
VALUES ('
$dir_id[id]', '".mysql_real_escape_string($name2)."', '".mysql_real_escape_string($ras)."', '".mysql_real_escape_string($type)."', '".mysql_real_escape_string($size)."', '$time', '$time', '$user[id]', '".mysql_real_escape_string($opis)."' )");
$id_file=mysql_insert_id();

file_put_contents(H."sys/obmen/files/$id_file.dat"$file);

$size filesize(H."sys/obmen/files/$id_file.dat");

mysql_query("update `obmennik_files` set `size`='".$size."' where `id`='".$id_file."' limit 1;");

$link 'http://'.$_SERVER['SERVER_NAME'].'/obmen'.$dir_id['dir'].urlencode($name).'.'.$ras.'&amp;showinfo';
$link mysql_real_escape_string('Добавил'.( $user['pol'] == 'а' '' ).' <a href="'.$link.'">файл</a> в обменнике');
mysql_query("insert into `frends_news_line` set `uid`='".$user['id']."', `date`='".$time."', `link`='".$link."';");
mysql_query("update `user` set `balls`=`balls`+1 where `id`='".$user['id']."' limit 1;");

if ( !empty(
$screen) && preg_match('~^http://[a-z0-9.-]+.[a-z]{2,}/[a-z0-9.?=,/]+$~i'$screen) ) {


$imgc imagecreatefromstring(file_get_contents($screen));

if ( 
$imgc ) {

$img_x=imagesx($imgc);
$img_y=imagesy($imgc);
if (
$img_x==$img_y)
{
$dstW=128// ширина
$dstH=128// высота 
}
elseif (
$img_x>$img_y)
{
$prop=$img_x/$img_y;
$dstW=128;
$dstH=ceil($dstW/$prop);
}
else
{
$prop=$img_y/$img_x;
$dstH=128;
$dstW=ceil($dstH/$prop);
}
$screen=imagecreatetruecolor($dstW$dstH);
imagecopyresampled($screen$imgc0000$dstW$dstH$img_x$img_y);
imagedestroy($imgc);
$screen=img_copyright($screen); // наложение копирайта
imagegif($screen,H."sys/obmen/screens/128/$id_file.gif");
imagedestroy($screen);

}


}


}
else {
$err='Неверное расширение файла';
unset(
$file);
}

}
else 
$err[] = 'Файл не был импортирован';

}
else 
$err[] = 'Некорректный адрес';


}







echo 
"</div>n";
}
?>
Онлайн: 3
Реклама