<?php

if (!empty($_FILES))
{
	$oblozhka = HOME.'/files/oblozhka/'.$user_id.'.jpg';
		if (file_exists($oblozhka))
		{
		unlink($oblozhka);
		}
		$dir = HOME.'/files/oblozhka';
		if (!is_dir($dir))
		{
			mkdir(HOME.'/files/oblozhka',0777);
		}
		$file_name = $user_id.'.jpg';
		///
		$savePath = HOME.'/files/oblozhka/'.$file_name;
		$filePath = $_FILES['file']['tmp_name'];
		$image = AcImage::createImage($filePath);
		$image
		->resizeByWidth(600)
		->cropCenter('3pr', '1pr')
		->save($savePath);

		mysql_query("UPDATE `users` SET `oblozhka` = '".$file_name."' WHERE `id` = '".$user_id."'");

		go(URL.'/user/?id='.$user_id.'');
	}
	else
	{
		$err = ''.lang('Неизвестный формат!','Невідомий формат!').'';

		mysql_query("UPDATE `users` SET `oblozhka` = '".$file_name."' WHERE `id` = '".$user_id."'");
	}


if (!empty($_FILES['file1'])) upload_obkl('file1');


if ($ajax_query == true) exit;



?>
