Файл: plugins/user/photo.php
Строк: 36
<?php
core::only('user');
$title = 'Моя фотография';
require (SYS.'head.php');
if (isset($_GET['delete']) && file_exists(H.'/files/photo/'.$user['id'].'.png'))
{
unlink(H.'/files/photo/'.$user['id'].'.png');
core::go('?');
}
if (isset($_POST['save']))
{
$file = new upload($_FILES['photo']);
$all_ext = array('jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG');
$ext = explode(".", $_FILES['photo']['name']);
if (filesize($_FILES['photo']['tmp_name']) <= 0)$error = 'Выберите фотографию.';
elseif (!in_array($ext[1], $all_ext)) $error = 'Неверный формат.';
elseif (empty($error) && $file->uploaded)
{
$file->file_new_name_body = $user['id'];
$file->allowed = array('image/jpeg', 'image/gif', 'image/png');
$file->file_max_size = 1024 * 3000;
$file->file_overwrite = true;
$file->image_resize = true;
$file->image_x = 55;
$file->image_ratio_y = true;
$file->image_convert = 'png';
$file->process(H."/files/photo/");
$file->processed;
}
}
if (file_exists(H.'/files/photo/'.$user['id'].'.png'))
{
$listing[] = [
'title' => '<img src="/files/photo/'.$user['id'].'.png">',
'div' => 'block'
];
$listing[] = [
'title' => 'Удалить',
'url' => '?delete',
'div' => 'menu',
'icon' => 'delete'
];
$smarty->assign('listing', $listing);
$smarty->display('listing.tpl');
}
$smarty->assign([
'files' => 1,
'method' => 'POST',
'action' => '?'
]);
$elements[] = [
'type' => 'file',
'title' => 'Фотография',
'br' => 1,
'info' => [
'name' => 'photo'
]
];
$elements[] = [
'type' => 'submit',
'br' => 0,
'info' => [
'value' => 'Добавить',
'name' => 'save'
]
];
$smarty->assign('el', $elements);
$smarty->display('form.tpl');
require (SYS.'foot.php');