<?php
require( '../incfiles/lib/class.upload.php' );
if ( isset( $_FILES[ 'file' ] ) )
		{
				$handle = new upload( $_FILES[ 'file' ] );
				if ( $handle->uploaded )
						{
								// Обрабатываем фото
								$handle->file_new_name_body = $ku[ 'id' ];
								//$handle->mime_check = false;
								$handle->allowed            = array(
												 'image/jpeg',
												'image/gif',
												'image/png' 
								);
								$handle->file_max_size      = 1024 * $set[ 'flsz' ];
								$handle->file_overwrite     = true;
								$handle->image_resize       = true;
								$handle->image_x            = 256;
								//$handle->image_y = 256;
								$handle->image_convert      = 'png';
								$handle->process( 'images/avatars/' );
								if ( $handle->processed )
										{
												header( "location: ?user=$ku[id]" );
										}
								else
										{
												echo functions::display_error( $handle->error );
										}
								$handle->clean();
						}
		}
echo '<div class="event"><h1>Настройка аватара</h1></div>';
echo "<div class='block'>Ваш текущий аватар:</br>";
if ( file_exists( 'images/avatars/' . $ku[ 'id' ] . '.png' ) )
		{
				echo "<img src='images/avatars/$ku[id].png' alt='o'>";
		}
else
		{
				echo "<img src='images/noavatar.png' alt='o'>";
		}
if ( !isset( $ku[ ava ] ) )
		{
				echo '</br>Заменить аватар:';
		}
else
		{
				echo '</br>Загрузить аватар:';
		}
echo "<form method=\"post\" enctype='multipart/form-data'>";
echo "<input type='file' name='file' /><br/>";
echo "<input value='Загрузить' type='submit' name='ok' /><br /></form></div>";
?>