Your IP : 172.28.240.42


Current Path : /var/www/html/clients/nsmk.e-nk.ru/application/maxsite/plugins/file_manager/php/
Upload File :
Current File : /var/www/html/clients/nsmk.e-nk.ru/application/maxsite/plugins/file_manager/php/thumbnail.inc.php

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

$CI->load->library('image_lib');

function run_task($taskname, $task, $dim, $path, $filename)
	{
	global $CI, $encoding;

	$new = prepare_task($taskname, $filename);
	$error = '';
	$message='';

	//clearstatcache();
	
	if (isset($task->max))
		{
		($dim[0] >= $dim[1]) ? ($max = $dim[0]) : ($max = $dim[1]);

		if ($task->max > 1 and $task->max < $max ) // корректный размер
			{
			$conf = array(
				'image_library' => 'gd2'
				,'source_image' => $path . $filename
				,'maintain_ratio' => true
				,'width' => $task->max
				,'height' => $task->max
				);

			if ($taskname != 'image')
				{
				@mkdir($path . 'mini' . DIRECTORY_SEPARATOR, 0777);
				@chown($path . 'mini' . DIRECTORY_SEPARATOR, get_current_user()); // стоит запрет на хостинге

				$conf['new_image'] = $path . $new;
				}

			$CI->image_lib->initialize($conf );

			try	{
				if (!$CI->image_lib->resize())
					{
					$error = $CI->image_lib->display_errors('','');
					}
				}
			catch (Exception $e)
				{
				$error =  ' error! '.$e->getMessage();
				}
			}
		else	$message = 'некорректный размер';
		}
	else	$message = 'не указан размер';
		
	return array('filename' => mb_convert_encoding($new, "UTF-8", $encoding), 'error' => $error, 'message' => $message);
	}