HEX
Server: Apache/2.4.65 (Debian)
System: Linux srv39710 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.4.11
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/www/www-root/data/www/NEWs/news.mowik.click/actions/imgupload.php
<?php
include('../inc/conf.php');
crabs_adm_check();
$path = '../img/upl_news/';
function getExtension($str) 
{
$i = strrpos($str,".");
if (!$i) { return ""; } 
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$valid_formats = array("jpg","png","gif","jpeg","PNG","JPG","JPEG","GIF");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['photoimg']['name'];
$aname = mysqli_real_escape_string($connect_db, $name);
$size = $_FILES['photoimg']['size'];
if(strlen($name))
{
$ext = getExtension($name);
if(in_array($ext,$valid_formats))
{
if($size<(1024*1024))
{
$rand = rand(0,999);
$actual_image_name = time().'_'.$rand.'.'.$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if(move_uploaded_file($tmp, $path.$actual_image_name))
{
$site = SITE;
echo json_encode(array(
'initialPreview' => array("<img src='https://{$site}/img/upl_news/{$actual_image_name}' class='file-preview-image' />",),
'initialPreviewConfig' => array(array('caption' => "<input type='text' value='https://{$site}/img/upl_news/{$actual_image_name}' class='form-control' onclick='this.select()' />", 'width' => '120px', 'url' => 'https://{SITE}/img/upl_news/{$actual_image_name}', 'key' => $actual_image_name),),
'append' => true));
}
else {
echo json_encode(array('error'=>'Ошибка'));
}
}
else {
echo json_encode(array('error'=>'Размер изображения более 1 Мб'));
}
}
else {
echo json_encode(array('error'=>'Неверный тип файла'));
}
}
else {
echo json_encode(array('error'=>'Выберите изображение'));
exit;
}
}
?>