HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/afisha38.ru/admin/modules/actions/images.inc
<?

//- Настройки модуля -----------------------------------------------------------
permission("mcp"); // tcp-техники; acp-админы; mcp-модеры; cp-рядовые участники
$skin_pname = "Управление изображениями";
$temp_html="";
//------------------------------------------------------------------------------

$errors = array();
$messages = array();


if (isset($_GET['id'])) {

	if(isset($_POST['image_type'])) {
		
		
		$image_n = image_get_filetype($_FILES['image_file']['tmp_name']);
		$src_size = GetImageSize($_FILES['image_file']['tmp_name']);
		
		if($src_size[0]<300 || $src_size[1]<300)
			$errors[] = "Изображение ".$_FILES['image_file']['name']." имеет размер менее 300х300 пикселей!";
		
		if(($_POST['image_type']=="image") && ($src_size[0]<$src_size[1]))
			$errors[] = "Высота изображения ".$_FILES['image_file']['name']." больше ширины и при этом оно не является постером!";
		
		if(!($image_n=="jpg" || $image_n=="jpeg" || $image_n=="gif"))
		$errors[] = "Изображение ".$_FILES['image_file']['name']." не в формате JPG или GIF!";

		if(sizeof($errors)==0)  {

			if ($_FILES['image_file']['name']!='') {
				
				
				if($_POST['image_type']=="image") {

					$handle=opendir('../images/b/actions/');
					$latest_num = 0;
					while ((false !== ($file = readdir($handle)))) {
						if (($file != ".") && ($file != "..")  && strstr($file,$_GET['id']."_") && (substr($file,0,strpos($file,$_GET['id']."_"))=="")) {
							if (strpos($file,$_GET['id']."_")==0/5) {
								$current_num = explode("_",$file);
								$current_num = explode(".",$current_num[1]);
								if($current_num[0]>$latest_num)
									$latest_num = $current_num[0];
							}
						}
					}
					closedir($handle);

					$image_dst = "../images/b/actions/".$_GET['id']."_".($latest_num+1).".".$image_n;

				}
				else if ($_POST['image_type']=="poster") {
					$image_dst = "../images/b/posters/".$_GET['id'].".".$image_n;
				}
				else
				header("Location: ./?m=".$_GET['m']."&task=list");		
						
				$result = image_convert($_FILES['image_file']['tmp_name'],$image_dst,$_POST['image_type']);
				
				if ($result) {
					$messages[] = "Изображение ".$_FILES['image_file']['name']." упешно загружено";
					
					$added = mysql_fetch_array(query("SELECT `added` FROM `actions` WHERE `id`=".$_GET['id']." LIMIT 1;"));
		
					if((time()-strtotime($added['added']))>10800) { // В течение 3 часов после добавления не обновляется поле `updated`
						query("UPDATE `actions` SET `updated`=NOW() WHERE `id`=".$_GET['id']." LIMIT 1;");
					}
				}
				else
					$messages[] = "Возникла ошибка при загрузке изображения ".$_FILES['image_file']['name']."";
			}
		}


	}
	
	$result = query("SELECT * FROM `actions` WHERE `id`='".$_GET['id']."';");
	if(mysql_num_rows($result)==1) {
		$action = mysql_fetch_array($result);
		$skin_pname .= " к событию &laquo;<a href=\"./?m=".$_GET['m']."&task=edit&id=".$_GET['id']."\">".$action['title']."</a>&raquo;";

		if(sizeof($errors)>0) {
			$temp_html .= "<ul>Обнаружены следующие ошибки:\n";
			foreach($errors as $error) {
				$temp_html .= "<li>".$error."</li>\n";
			}
			$temp_html .= "</ul>\n<hr>\n";
		}
		
		$poster = "";
		$image_type = "poster";
		$handle=opendir('../images/b/posters/');
		while ((false !== ($file = readdir($handle)))) {
			if (($file != ".") && ($file != "..")  && strstr($file,$_GET['id'].".") && (substr($file,0,strpos($file,$_GET['id']."."))=="")) {
				if (strpos($file,$_GET['id'].".")==0/5) {

					$image_src = "../images/s/posters/".$file;

					$size = getimagesize('../images/b/posters/'.$file);
					$image_resolution = $size[0]."x".$size[1];
					$image_size = round(filesize('../images/b/posters/'.$file)/1024)." Кб";
					
					$image_id = $file;
					
					$poster = preg_replace("/{%(\w+)%}/ee", "$\\1",skin_html("actions_images_row.htm",0));
				}
                	}
         	}
        if($poster=="")
        	$poster = preg_replace("/{%(\w+)%}/ee", "$\\1",skin_html("actions_images_empty.htm",0));
		closedir($handle);
		
		
		$files = array();
		$images = "";
		$image_type = "image";
		$image_files = get_images('../images/b/actions/');
		foreach ($image_files as $file) {
			if (($file != ".") && ($file != "..")  && strstr($file,$_GET['id']."_") && (substr($file,0,strpos($file,$_GET['id']."_"))=="")) {
				if (strpos($file,$_GET['id']."_")==0/5) {
					$image_src = "../images/s/actions/".$file;
					$files[] = $file;
					$size = getimagesize('../images/b/actions/'.$file);
					$image_resolution = $size[0]."x".$size[1];
					$image_size = round(filesize('../images/b/actions/'.$file)/1024)." Кб";
					
					$image_id = $file;
					
					$images .= preg_replace("/{%(\w+)%}/ee", "$\\1",skin_html("actions_images_row.htm",0));
				}
                	}
         	}
		
		$images .= preg_replace("/{%(\w+)%}/ee", "$\\1",skin_html("actions_images_empty.htm",0));

		
	}
}
else
	header("Location: ./?m=".$_GET['m']."&task=list");

$temp_html .= preg_replace("/{%(\w+)%}/ee", "$\\1",skin_html("actions_images.htm",0));

skin_html_design($temp_html);

?>