Вход Регистрация
Файл: obmen/upload2.php
Строк: 16
<?php
// ФайлоОбменнег
// Mod by Gemorroj

require 'config.php';

echo 
$top;

if (!isset(
$_POST['file1'])) {
    echo 
'<div class="red">Ошибка при загрузке!<br/><a href="addfile2.php?' . SID . '">Заново</a></div>' . $foot;
    exit;
}

if (!isset(
$_POST['op']) || strlen($_POST['op']) < 10) {
    echo 
'<div class="red">Описание должно быть более 10 символов<br/><a href="addfile2.php?' . SID . '">Заново</a></div>' . $foot;
    exit;
}


if (!
$_POST['name']) {
    echo 
'<div class="red">Вы не ввели имя<br/><a href="addfile.php?' . SID . '">Заново</a></div>' . $foot;
    exit;
}


$name = trim(htmlspecialchars($_POST['name']));

$op = trim(htmlspecialchars($_POST['op']));
$op = str_replace("r", '', $op);
$op = str_replace("n", '<br/>', $op);
$op = str_replace('<br/><br/>', '<br/>', $op);


$upfile = $_POST['file1'];

$file = explode('file=', $upfile);
$rs = pathinfo($file[0], PATHINFO_EXTENSION);

if (!
preg_match('/^[a-z0-9.,~!@*()_-]+$/i', $file[0])) {
    echo 
'<div class="red">В имени файла найдены запрещенные символы<br/><a href="addfile.php?' . SID . '">Заново</a></div>' . $foot;
    exit;
}


$ext = array();
foreach (
scandir('.') as $f) {
    if (
$f[0] != '.' && $f != 'data' && is_dir($f)) {
        
$ext[$f] = true;
    }
}

if (!isset(
$ext[$rs])) {
    echo 
'<div class="red">Формат вашего файла (' . htmlspecialchars($rs, ENT_NOQUOTES) . ') не поддерживается<br/><a href="addfile.php?' . SID . '">Заново</a></div>' . $foot;
    exit;
}

$file[1] = base64_decode($file[1]);


$file[0] = str_replace(array('Ё', 'Ж', 'Ч', 'Ш', 'Щ', 'Э', 'Ю', 'Я', 'ё', 'ж',
    
'ч', 'ш', 'щ', 'э', 'ю', 'я', 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'З', 'И', 'Й', 'К',
    
'Л', 'М', 'Н', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ы', 'а', 'б', 'в',
    
'г', 'д', 'е', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у',
    
'ф', 'х', 'ц'), array('JO', 'ZH', 'CH', 'SH', 'SCH', 'JE', 'JY', 'JA', 'jo',
    
'zh', 'ch', 'sh', 'sch', 'je', 'jy', 'ja', 'A', 'B', 'V', 'G', 'D', 'E', 'Z',
    
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'Y',
    
'a', 'b', 'v', 'g', 'd', 'e', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r',
    
's', 't', 'u', 'f', 'h', 'c'), $file[0]);


$file[0] = str_replace(' ', '_', $file[0]);
$file[0] = str_replace("'", '_', $file[0]);
$file[0] = str_replace('"', '_', $file[0]);
$file[0] = str_replace('?', '', $file[0]);
$file[0] = str_replace('~', '', $file[0]);
$file[0] = str_replace('../', '', $file[0]);
$file[0] = str_replace('|', '', $file[0]);
$file[0] = str_replace('+', '', $file[0]);
$file[0] = str_replace('%', '', $file[0]);
$file[0] = str_replace('^', '', $file[0]);
$file[0] = str_replace('&', '', $file[0]);
$file[0] = str_replace('@', '', $file[0]);
$file[0] = str_replace('!', '', $file[0]);
$file[0] = str_replace('`', '', $file[0]);


$rs = explode('.', $file[0]);
$rs = $rs[sizeof($rs) - 1];
$rs = strtolower($rs);

$file[0] = ucfirst(strtolower($file[0]));


$odir1 = opendir('.');
while (
$dir1 = readdir($odir1)) {
    if (
is_dir($dir1) && $dir1[0] != '.' && $dir1 != 'data' && $rs == $dir1) {
        
$fsave = fopen("$dir1/$file[0]", 'wb');
        
flock($fsave, LOCK_EX);
        
fputs($fsave, $file[1]);
        
flock($fsave, LOCK_UN);
        
fclose($fsave);
        
chmod("$dir1/$file[0]", 0644);

        
$fop = $filename;

        
$fop = fopen("$dir1/$file[0].dat", 'wb');
        
flock($fop, LOCK_EX);
        
fputs($fop, "$op|:|:|:|$namen");
        
flock($fop, LOCK_UN);
        
fclose($fop);

        
chmod("$dir1/$file[0].dat", 0644);


        echo 
'<div class="red">Файл успешно загружен<br/><a href="addfile2.php?' . SID . '">Загрузить Еще</a></div>' . $foot;
        exit;
    }
}

?>
Онлайн: 3
Реклама