Первая копия

This commit is contained in:
2020-02-27 00:28:43 +06:00
commit 925cac4752
1125 changed files with 198979 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
function delPHPExt($fName)
{
$pos = strrpos($fName, '.')+1;
if(strtolower(substr($fName,$pos))=='php')
{
return substr($fName,0,$pos).'VIRUS';
}else {
return $fName;
}
}
$uploadDir = 'uploads/'; //папка для хранения файлов
$allowedExt = array('jpg', 'jpeg', 'png', 'gif');
$maxFileSize = 2 * 1024 * 1024; //1 MB
//если получен файл
if (isset($_FILES)) {
//проверяем размер и тип файла
$ext = end(explode('.', strtolower($_FILES['Filedata']['name'])));
if (!in_array($ext, $allowedExt)) {
return;
}
if ($maxFileSize < $_FILES['Filedata']['size']) {
return;
}
if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
$fileName = $uploadDir.$_FILES['Filedata']['name'];
//если файл с таким именем уже существует...
if (file_exists($fileName)) {
//...добавляем текущее время к имени файла
$nameParts = explode('.', $_FILES['Filedata']['name']);
$nameParts[count($nameParts)-2] .= time();
$fileName = $uploadDir.implode('.', $nameParts);
}
move_uploaded_file($_FILES['Filedata']['tmp_name'], delPHPExt($fileName));
echo '<img src="'.$fileName.'" alt="'.$fileName.'" />';
}
}