Размер файла: 4.21Kb
- <?
- /*
- =============================================
- Движок: SHCMS Engine
- =============================================
- Название файла: Установка аватара
- =============================================
- Official website: http://shcms.ru
- =============================================
- */
- define('SHCMS', true);
- include_once'../system/inc/basic_settings.php';
- $shcmsengine['title'] = 'Загрузка аватара';
- include_once'../template/head.php';
- registrat();
-
-
-
- if(isset($_POST['submit']))
- {
- $submit = $_POST['submit'];
- }
-
- if(isset($submit))
- {
- if(!empty($_FILES['image']))
- {
- if($_FILES['image']['error'])
- {
- echo '<div class="errors">Ошибка при выгрузке</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
- if(!$_FILES['image']['size'])
- {
- echo '<div class="errors">Содержимое файла пустое</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
- if(!preg_match('#\.jpe?g$#ui', $_FILES ['image']['name']) and !preg_match('#\.gif$#ui',$_FILES['image']['name'])and !preg_match('#\.png$#ui',$_FILES['image']['name']))
- {
- echo '<div class="errors">Неверное содержание файла</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
-
- if(!$img = @imagecreatefromjpeg($_FILES ['image'] ['tmp_name']) and !$img = @imagecreatefrompng($_FILES ['image'] ['tmp_name']) and !$img = imagecreatefromgif($_FILES['image']['tmp_name']))
- {
- echo '<div class="errors">Файл не является изображением JPEG, PNG или GIF</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
-
- if((@imagesx($img) < 130))
- {
- echo '<div class="errors">Ширина изобожения должно быть больше 130px</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
-
- if((@imagesy($img) < 130))
- {
- echo '<div class="errors">Ширина изобожения должно быть больше 130px</div>';
- header("Refresh: 1; url=?");
- include_once'../template/foot.php';
- exit();
- }
- }
-
- function format($name) {
- $f1 = strrpos($name, ".");
- $f2 = substr($name, $f1 + 1, 999);
- $fname = strtolower($f2);
- return $fname;
- }
- $listing = format($_FILES['image']['name']);
- $uploaddir = $_SERVER['DOCUMENT_ROOT']."/avatar/files/";
- $uploaddir.=$user_id.'.jpg';
- if(move_uploaded_file($_FILES["image"]["tmp_name"], $uploaddir))
- {
- $screen = new screen_shcms($uploaddir);
- $screen->autoimageresize(640, 480);
- $screen->imagesave($new_image->image_type, $uploaddir);
- $screen->imageout();
- echo '<div class="actshcms">Аватар успешно загружен</div>';
- }
- else
- {
- echo '<div class="actshcms">Аватар не загружен</div>';
- }
- }
-
- if(is_file('../avatar/files/'.$user_id.'.jpg')){
- echo '<div class="maintitle mainrazd">Ваш аватар</div><div class="maintext">';
- echo '<img class="image_avatar" src="../avatar/files/'.$user_id.'.jpg"/></div>';
- }else{
- echo '<div class="maintitle mainrazd">Аватар не загружен</div><div class="maintext">';
- errors('Вы еще не добавили аватар');
- echo '</div>';
- }
- echo '<div class="maintitle mainrazd">Загрузка аватара</div><div class="maintext">';
- echo 'Файл аватара<br/>';
- echo '<form enctype="multipart/form-data" action="?'.$conservation.'" method="post">';
- echo "<input accept='image/*,image/gif,image/jpeg,image/png' type='file' name='image'/>";;
- if(!is_file('../avatar/files/'.$user_id.'.jpg')) {
- echo '<br/><input type="submit" value="Установить" name="submit"/>';
- }
- else{
- echo '<br/><input type="submit" value="Заменить" name="submit"/>';
- }
- echo '</form></div>';
-
-
- include_once'../template/foot.php';
- ?>