ACC SHELL

Path : /srv/www/vhosts/sc-brno/sefar/modules/fotogalerie/
File Upload :
Current File : /srv/www/vhosts/sc-brno/sefar/modules/fotogalerie/modul.php

<?
class CModul_Fotky{
	function CModul_Fotky($pripojeni){
		$this->pripojeni = $pripojeni;
		$this->conf_id='modul_fotky';

		$this->strankovat_po = false;

	}
	function create_modul($id_bloku){

		$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."elementy (id_bloku, poradi, modul) SELECT '".$id_bloku."', max(poradi)+1, '".$this->conf_id."' FROM ".$GLOBALS['config_db_prefix']."elementy WHERE id_bloku='".$id_bloku."'");

//		$vlozene_id = mysql_insert_id($this->pripojeni->conn);
		
//		$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."modul_texty (id_elementu, text) VALUES ('".$vlozene_id."', '')");
	
	
	}


	function show_element_preview($id_elementu){
		$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_fotky WHERE deleted='0' AND id_elementu='".$id_elementu."' LIMIT 3");
		while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			//echo"<div class='fotka'>";
			
				echo"<img src='../images/tn/".$data->ikona."' alt=''/> ";
			//echo"</div>";
		
		}
			echo"<div class='modul-opearace'>";
			echo"<a href='./admin.php?lang=".$this->lang."&amp;sekce=obsah&amp;id=".$_REQUEST['id']."&amp;operace=edit-element&amp;id_bloku=".$polozka_menu->id."&amp;id_elementu=".$id_elementu."' class='button green'>upravit</a>";
			echo"  ";						
			if($_SESSION['auth_uzivatel_authorisation']==9)
				echo"<a href='./admin.php?lang=".$this->lang."&amp;sekce=obsah&amp;id=".$_REQUEST['id']."&amp;operace=delete-element&amp;id_bloku=".$polozka_menu->id."&amp;id_elementu=".$id_elementu."' onclick='return confirm(Opravdu odstranit modul?)' class='button red'>odstranit modul</a>";
			echo"</div>\n\n";						
	
	}

	function show_element_view($id_elementu){
 // echo "<h2>Fotogalerie</h2><br>";
		echo"<div class='fotky-obal'>";
		$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_fotky WHERE deleted='0' and id_elementu='".$id_elementu."' ");
		if($this->strankovat_po){
			echo"<ul id='holder' class='x'>";
			echo"<li><div>";
			$i=1;		
			while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
				if(!$bez_strankovani && $new_page){
					$new_page = false;
					echo"<li><div>";
				}			
			
			
				echo"<div class='fotka'>";
					echo"<a href='./images/obr/".$data->ikona."' rel='prettyPhoto[pp_gal]'><img src='./images/tn/".$data->ikona."' alt='".$data->anotace."' title='".$data->anotace."'/></a>";
					echo"<p>".$data->anotace."</p>";
				echo"</div>";
//			echo "</div>" ;
		
			if ( ( $i%$this->strankovat_po)==0 ){
				echo"</div></li>";
				$new_page = true;
			}
			$i++;
	
			}
			echo "</div></li></ul>";		
		}
		else{
		
			while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
				echo"<div class='fotka'>";
				
					echo"<a href='./images/obr/".$data->ikona."' rel='prettyPhoto[pp_gal]'><img src='./images/tn/".$data->ikona."' alt='".$data->anotace."' title='".$data->anotace."'/></a>";
					echo"<p>".$data->anotace."</p>";
				echo"</div>";
			
			}
		
		}
		
		
		echo"</div>";
	
	}


	function vyhledat($fraze){
		return '';
	
	}



	function admin_edituj()
	{
		if($_REQUEST['editace']=='pripojene-obrazky'){
			$this->attached_images_edit();		 
		}
		else{
		 	$this->articles_edit();
		 
		}
	}
	                                
	function show_admin_form($id_elementu)
	{
		 $admin_url.="admin.php";
		 $admin_url.="?web_id=".$_REQUEST['web_id'];
		 $admin_url.="&amp;lang=".$_REQUEST['lang'];
		 $admin_url.="&amp;sekce=".$_REQUEST['sekce'];
		 $admin_url.="&amp;operace=".$_REQUEST['operace'];
		 $admin_url.="&amp;id=".$_REQUEST['id'];
		 $admin_url.="&amp;id_bloku=".$_REQUEST['id_bloku'];
		 $admin_url.="&amp;id_elementu=".$_REQUEST['id_elementu'];
		
		if($_REQUEST['editace']=='pripojene-obrazky'){
			$this->attached_images_form();		
		}
		else{
			$this->articles_form();		
		}
	}	
	function articles_edit()
	{
		if ($_FILES['ikona']['tmp_name']){
			$nazev_obrazku = time()."_".$this->seo_gen($_FILES['ikona']['name'], "files");
		    $this->do_thumbnail_cropped("ikona", "../../images/obr/", "../../images/tn/", $nazev_obrazku, 125, "", "");
		}
		
		if($_REQUEST['publikovat']){
			list($rok, $mesic, $den) = explode("-", $_REQUEST['publikovat']);
			$cas_publikace = mktime(0, 0, 0, $mesic, $den, $rok);
		}
		
		if ($_REQUEST['id']){
			$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."modul_fotky SET cas_publikace='".$cas_publikace."', cas_zmeny='".time()."', priznak1='".($_REQUEST['priznak1']+0)."', priznak2='".($_REQUEST['priznak2']+0)."', priznak3='".($_REQUEST['priznak3']+0)."', hidden='".($_REQUEST['hidden']+0)."', nazev='".$_REQUEST['nazev']."', anotace='".$_REQUEST['anotace']."', text='".$_REQUEST['text']."', keywords='".$_REQUEST['keywords']."', description='".$_REQUEST['description']."' ".($nazev_obrazku?", ikona='".$nazev_obrazku."'":"")." WHERE id='".$_REQUEST['id']."'");
		}
		else{
			$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."modul_fotky (id_elementu, cas_vytvoreni, cas_publikace, cas_zmeny, priznak1, priznak2, priznak3, hidden, lang, nazev, anotace, text, keywords, description, ikona) VALUES ('".(0+$_REQUEST['id_elementu'])."', '".time()."', '".$cas_publikace."', '".time()."', '".($_REQUEST['priznak1']+0)."', '".($_REQUEST['priznak2']+0)."', '".($_REQUEST['priznak3']+0)."', '".($_REQUEST['hidden']+0)."', '".$_REQUEST['lang']."', '".$_REQUEST['nazev']."', '".$_REQUEST['anotace']."', '".$_REQUEST['text']."', '".$_REQUEST['keywords']."', '".$_REQUEST['description']."','".$nazev_obrazku."')");
		}
		
	}
	function articles_delete($id)
	{
		if ($id){
//			$this->pripojeni->dotaz("DELETE FROM ".$GLOBALS['config_db_prefix']."modul_fotky WHERE id='".(0+$id)."'");
			$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."modul_fotky SET deleted='1' WHERE id='".(0+$id)."'");
		}		
	}
	function articles_form()
	{

		 $admin_url.="admin.php";
		 $admin_url.="?web_id=".$_REQUEST['web_id'];
		 $admin_url.="&amp;lang=".$_REQUEST['lang'];
		 $admin_url.="&amp;sekce=".$_REQUEST['sekce'];
		 $admin_url.="&amp;operace=".$_REQUEST['operace'];
		 $admin_url.="&amp;id=".$_REQUEST['id'];
		 $admin_url.="&amp;id_bloku=".$_REQUEST['id_bloku'];
		 $admin_url.="&amp;id_elementu=".$_REQUEST['id_elementu'];


		if ($_REQUEST['delete']){
			$this->articles_delete($_REQUEST['delete']);
		}
		if ($_REQUEST['add'] || $_REQUEST['oprava']){
			$db_opravna_polozka  = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_fotky WHERE id='".$_REQUEST['oprava']."' LIMIT 1");
			if ($db_opravna_polozka && $opravna_polozka = $this->pripojeni->objekt_dotazu($db_opravna_polozka)){
			}
		
			echo"<div class='block-border'>";
			echo"<div class='block-content'>";
			echo"<h1>".(!$opravna_polozka->id?"Vložení fotky":"Editace fotky")."</h1>";
				
		
		
		
		
	
			echo"<form action='./functions/function.php' method='post' enctype='multipart/form-data' class='form  validated-form'>\n";
				echo"<input type='hidden' name='web_id' value='".$this->web_id."'/>\n";
				echo"<input type='hidden' name='lang' value='".$this->lang."'/>\n";
				echo"<input type='hidden' name='sekce' value='".$this->sekce."'/>\n";
				echo"<input type='hidden' name='id_menu' value='".$_REQUEST['id_menu']."'/>\n";
	
	
				echo"<input type='hidden' name='web_id' value='".$_REQUEST['web_id']."'/>\n";
				echo"<input type='hidden' name='lang' value='".$_REQUEST['lang']."'/>\n";
				echo"<input type='hidden' name='sekce' value='".$_REQUEST['sekce']."'/>\n";
				echo"<input type='hidden' name='id_bloku' value='".$_REQUEST['id_bloku']."'/>\n";
				echo"<input type='hidden' name='id_elementu' value='".$_REQUEST['id_elementu']."'/>\n";
				echo"<input type='hidden' name='id' value='".$_REQUEST['id']."'/>\n";
	
				echo"<input type='hidden' name='return' value='lang=".$_REQUEST['lang']."&amp;sekce=".$_REQUEST['sekce']."&amp;id=".$_REQUEST['id']."&amp;operace=".$_REQUEST['operace']."&amp;id_bloku=".$_REQUEST['id_bloku']."&amp;id_elementu=".$_REQUEST['id_elementu']."'/>\n";
	
	
				echo"<input type='hidden' name='id' value='".$opravna_polozka->id."'/>\n";
	
	
				echo"<section id='form-block'>";
				
				echo"<table class='formularovka table'>";
					echo"<tr><th>Název</th><td><input type='text' name='nazev' value='".$opravna_polozka->nazev."'/></td></tr>\n";
	//				echo"<tr><td>Publikovat</td><td><input type='text' name='publikovat' value='".date("Y-m-d", ($opravna_polozka->cas_publikace?$opravna_polozka->cas_publikace:time()))."'/></td></tr>\n";
					echo"<tr><th>Soubor".($opravna_polozka->ikona?"":"<span class='povinny'></span>")." </th><td><span><input type='file' name='ikona' ".($opravna_polozka->ikona?"":"class='required'")." title='Soubor'/></span><br/>".($opravna_polozka->ikona?"<img src='../images/tn/".$opravna_polozka->ikona."' alt=''/>":"")."</td></tr>\n";
	//				echo"<tr><td>Příznak 1</td><td><input type='checkbox' name='priznak1' value='1' ".($opravna_polozka->priznak1?"checked='checked'":"")."/></td></tr>\n";
	//				echo"<tr><td>Příznak 2</td><td><input type='checkbox' name='priznak2' value='1' ".($opravna_polozka->priznak2?"checked='checked'":"")."/></td></tr>\n";
	//				echo"<tr><td>Příznak 3</td><td><input type='checkbox' name='priznak3' value='1' ".($opravna_polozka->priznak3?"checked='checked'":"")."/></td></tr>\n";
					echo"<tr><th>Anotace</th><td><textarea name='anotace' >".$opravna_polozka->anotace."</textarea></td></tr>\n";
	/*
					echo"<tr><td>Text</td><td>";
					echo"<textarea name='text' id='text'>".$opravna_polozka->text."</textarea>";
	?>	
	  		<script type="text/javascript">
				//<![CDATA[
	CKEDITOR.replace( 'text',
					{
	          toolbar:
	          [
	          	['Source','-','Preview','-','Templates'],
	          	['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'],
	          	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
	          	'/',
	          	['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
	          	['NumberedList','BulletedList','-','CreateDiv'],
	          	['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
	          	['Link','Unlink','Anchor'],
	          	['Image','Flash','Table','HorizontalRule','SpecialChar','PageBreak'],
	          	'/',
	          	['Format','FontSize'],
	          	['Maximize', 'ShowBlocks','-','About']
	          ],
	
	 	filebrowserBrowseUrl : './ckfinder/ckfinder.html',
	 	filebrowserImageBrowseUrl : './ckfinder/ckfinder.html?type=Images',
	 	filebrowserFlashBrowseUrl : './ckfinder/ckfinder.html?type=Flash',
	 	filebrowserUploadUrl : './ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
	 	filebrowserImageUploadUrl : './ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
	 	filebrowserFlashUploadUrl : './ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
	          
					});
	        			//]]>
				</script>
	<?
					echo"</td></tr>\n";
	*/	
	
	//				echo"<tr><td>Keywords</td><td><input type='text' name='keywords' value='".$opravna_polozka->keywords."'/></td></tr>\n";
	//				echo"<tr><td>Description</td><td><textarea name='description' >".$opravna_polozka->description."</textarea></td></tr>\n";
					
					echo"<tr><td></td><td><input type='submit' name='edit_obsah_elementu' value='Ok' class='submitter'/> <a href='".$admin_url."' class='button blue'>Storno</a> </td></tr>\n";
	
	
				echo"</table>";
	
	      echo"</section>";
	
			echo"</form>\n\n";
			echo"</div></div>";
		}
		else{
			echo"<div class='block-border'>";
			echo"<div class='block-content'>";
			echo"<h1>Seznam fotek</h1>";
				
				
			$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_fotky WHERE   deleted='0' and id_elementu='".$_REQUEST['id_elementu']."' ORDER BY id desc");
			echo"<table class='vypisy table with-head'>\n";
			echo"<thead><tr><th>Název</th><th>Náhled</th><th style='width:60px;'>Operace</th></tr></thead>";
			while ($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
				echo"<tr class='".(($i++)%2?"s":"l")."'>\n";
					echo"<td>".$data->nazev."</td>\n";
					echo"<td><img src='../images/tn/".$data->ikona."' alt=''/></td>\n";
						echo"\t\t<td class='op'>";
						echo"<a href='".$admin_url."&amp;oprava=".$data->id."' class='edit'><img src='./images/icons/fugue/pencil.png' alt='upravit'/></a> &nbsp; ";			
						echo"<a href='".$admin_url."&amp;delete=".$data->id."' class='del' onclick=\"return confirm('Opravdu odstranit tuto položku?')\"><img src='./images/icons/fugue/cross-circle.png' alt='odstranit'/></a>";
						echo"</td>\n";			
				echo"</tr>";
			}
			echo"</table>";

			echo"<a href='".$admin_url."&amp;add=true' class='button blue'>+</a>";

			echo"</div></div>";
		
		}


	}
	
	
	
	
	function attached_images_edit()
	{
		if ($_FILES['ikona']['tmp_name']){
			$nazev_obrazku = time()."_".$this->seo_gen($_FILES['ikona']['name'], "files");
			//$this->do_thumbnail_cropped('ikona', "../../images/obr/", "../../images/tn/", $nazev_obrazku,$square="", 300,300);
      $this->do_thumbnail_cropped("ikona", "../../images/obr", "../../images/tn/", $nazev_obrazku, 375, "", "");
		}
		if ($_REQUEST['id']){
			$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."attached_images SET nazev='".$_REQUEST['nazev']."', priznak='".(0+$_REQUEST['priznak'])."' ".($nazev_obrazku?", soubor='".$nazev_obrazku."'":"")." WHERE id='".$_REQUEST['id']."'");
		}
		else{
			$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."attached_images (id_menu, priznak, soubor, nazev) VALUES ('".(0+$_REQUEST['id_menu'])."', '".(0+$_REQUEST['priznak'])."', '".$nazev_obrazku."', '".$_REQUEST['nazev']."')");
		}
	}
	function attached_images_delete($id)
	{
		if ($id){
			$this->pripojeni->dotaz("DELETE FROM ".$GLOBALS['config_db_prefix']."attached_images WHERE id='".(0+$id)."'");
		}		
	}
	function attached_images_form()
	{

		if ($_REQUEST['delete']){
			$this->attached_images_delete($_REQUEST['delete']);
		}
		if ($_REQUEST['oprava']){
			$db_opravna_polozka  = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."attached_images WHERE id='".$_REQUEST['oprava']."' LIMIT 1");
			if ($db_opravna_polozka && $opravna_polozka = $this->pripojeni->objekt_dotazu($db_opravna_polozka)){
			}
		}

		echo"<form action='./functions/function.php' method='post' enctype='multipart/form-data'>\n";
			echo"<input type='hidden' name='web_id' value='".$this->web_id."'/>\n";
			echo"<input type='hidden' name='lang' value='".$this->lang."'/>\n";
			echo"<input type='hidden' name='sekce' value='".$this->sekce."'/>\n";
			echo"<input type='hidden' name='id_menu' value='".$_REQUEST['id_menu']."'/>\n";

			echo"<input type='hidden' name='id' value='".$opravna_polozka->id."'/>\n";

			echo"<table>";
				echo"<tr><th>Název</th><td><input type='text' name='nazev' value='".$opravna_polozka->nazev."'/></td></tr>\n";
				echo"<tr><th>Soubor</th><td><input type='file' name='ikona' /><br/>".($opravna_polozka->soubor?"<img src='../images/tn/".$opravna_polozka->soubor."' alt=''/>":"")."</td></tr>\n";
				echo"<tr><th>Pořadí (vyšší číslo = vypsáno dříve)</th><td><input type='text' name='priznak' value='".(0+$opravna_polozka->priznak)."' /></td></tr>\n";
				echo"<tr><td></td><td><input type='submit' name='edit_attached_images' value='Odeslat' class='submitter'/></td></tr>\n";


			echo"</table>";



		echo"</form>\n\n";


		$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."attached_images WHERE id_menu='".$_REQUEST['id_menu']."' ORDER BY id desc");
		echo"<table class='vypisy'>\n";
		while ($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			echo"<tr class='".(($i++)%2?"s":"l")."'>\n";
				echo"<td><img src='../images/tn/".$data->soubor."' alt=''/></td>\n";
				echo"<td>".$data->nazev."</td>\n";
					echo"\t\t<td class='op'><a href='./admin.php?lang=".$this->lang."&amp;web_id=".$this->web_id."&amp;sekce=".$this->sekce."&amp;id_menu=".$_REQUEST['id_menu']."&amp;oprava=".$data->id."' class='edit'>opravit</a></td>\n";			
					echo"\t\t<td class='op'><a href='./admin.php?lang=".$this->lang."&amp;web_id=".$this->web_id."&amp;sekce=".$this->sekce."&amp;id_menu=".$_REQUEST['id_menu']."&amp;delete=".$data->id."' class='del' onclick=\"return confirm('Opravdu odstranit tuto položku?')\">odstranit</a></td>\n";			
			echo"</tr>";
		}
		echo"</table>";

	}

	
	
	




	
	
	
	
	










	function do_thumbnail_cropped($soubor, $path, $tn_dir, $new_name, $square="", $max_width="", $max_height="")
	{
		if ($soubor){
			if (!@fopen($path.$new_name, "r")){
				@copy($_FILES[$soubor]['tmp_name'], $path.$new_name);
			}
		}
		if(@$velikost_obrazku = GetImageSize($path.$new_name)){
			
			if ($square ){
				if (($velikost_obrazku[0]>$square || $velikost_obrazku[1]>$square)){

					if($velikost_obrazku[0]>$velikost_obrazku[1]){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
						$height=ImageSY($im)*($square/ImageSX($im)); 
						$im2 = ImageCreateTrueColor($square,$square); 
//						ImageCopyResampled ($im2, $im, 0, 0, round((ImageSX($im)-ImageSY($im))/2), 0, $square, $square, ImageSY($im)+round((ImageSX($im)-ImageSY($im))/2), ImageSY($im));
						ImageCopyResampled ($im2, $im, 0, 0, round((ImageSX($im)-ImageSY($im))/2), 0, $square, $square, ImageSY($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
						
					}
					else{
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
						$width=ImageSX($im)*($square/ImageSY($im)); 
						$im2 = ImageCreateTrueColor($square, $square); 
						//ImageCopyResampled ($im2, $im, 0, 0, 0, round((ImageSY($im)-ImageSX($im))/2), $square, $square, ImageSX($im), ImageSX($im)+round((ImageSY($im)-ImageSX($im))/2));
						ImageCopyResampled ($im2, $im, 0, 0, 0, round((ImageSY($im)-ImageSX($im))/2), $square, $square, ImageSX($im), ImageSX($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
					}

				}
				else{
					@copy($path.$new_name, $tn_dir.$new_name);
				}

			}
			elseif($max_width && $max_height){
        //pokud sx/sy > Sx/Sy
          // rx=sx&ry=sy . sSx=Sx & sSy = sy*SX/sx

						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$im2 = ImageCreateTrueColor($max_width,$max_height); 

				if( ($velikost_obrazku[0]/$velikost_obrazku[1])<($max_width/$max_height) ){


//					ImageCopyResampled ($im2, $im, 0, 0, 0, round((ImageSY-($max_height*ImageSX($im)/$max_width))/2), $max_width, $max_height, ImageSX($im), round($max_height*ImageSX($im)/$max_width));
          ImageCopyResampled ($im2, $im, 0, 0, 0, round((ImageSY($im)-($max_height*ImageSX($im)/$max_width))/2), $max_width, $max_height, ImageSX($im), round($max_height*ImageSX($im)/$max_width));
				}
				else{
         ImageCopyResampled ($im2, $im, 0, 0, round((ImageSX($im)-($max_width*ImageSY($im)/$max_height))/2), 0, $max_width, $max_height, round($max_width*ImageSY($im)/$max_height), ImageSY($im));
				}
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}

			elseif($max_width){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$height=ImageSY($im)*($max_width/ImageSX($im)); 
				$im2 = ImageCreateTrueColor($max_width,$height); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $max_width, $height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
			elseif($max_height){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$width=ImageSX($im)*($max_height/ImageSY($im)); 
				$im2 = ImageCreateTrueColor($width, $max_height); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $width, $max_height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
		}
	}



	function do_thumbnail($soubor, $path, $tn_dir, $new_name, $square="", $max_width="", $max_height="")
	{
		if ($soubor){
			if (!@fopen($path.$new_name, "r")){
				@copy($_FILES[$soubor]['tmp_name'], $path.$new_name);
			}
		}
		@$velikost_obrazku = GetImageSize($path.$new_name);
		
		if ($square){
			if($velikost_obrazku[0]>$velikost_obrazku[1]){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$height=ImageSY($im)*($square/ImageSX($im)); 
				$im2 = ImageCreateTrueColor($square,$height); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $square, $height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
			else{
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$width=ImageSX($im)*($square/ImageSY($im)); 
				$im2 = ImageCreateTrueColor($width, $square); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $width, $square, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
		}
		elseif($max_width && $max_height){
			if( ($velikost_obrazku[0]/$velikost_obrazku[1])>($max_width/$max_height) ){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$height=ImageSY($im)*($max_width/ImageSX($im)); 
				$im2 = ImageCreateTrueColor($max_width,$height); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $max_width, $height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
			else{
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
				$width=ImageSX($im)*($max_height/ImageSY($im)); 
				$im2 = ImageCreateTrueColor($width, $max_height); 
				ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $width, $max_height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
			}
		}

		elseif($max_width){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
			$height=ImageSY($im)*($max_width/ImageSX($im)); 
			$im2 = ImageCreateTrueColor($max_width,$height); 
			ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $max_width, $height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
		}
		elseif($max_height){
						if($velikost_obrazku['mime']=="image/gif")$im = ImageCreateFromGIF ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/png")$im = ImageCreateFromPNG ($path.$new_name); 
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageCreateFromJPEG ($path.$new_name); 
			$width=ImageSX($im)*($max_height/ImageSY($im)); 
			$im2 = ImageCreateTrueColor($width, $max_height); 
			ImageCopyResampled ($im2, $im, 0, 0, 0, 0, $width, $max_height, ImageSX($im), ImageSY($im));
						if($velikost_obrazku['mime']=="image/gif")$im = ImageGIF($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/png")$im = ImagePNG($im2, $tn_dir.$new_name);
						if($velikost_obrazku['mime']=="image/jpeg")$im = ImageJPEG($im2, $tn_dir.$new_name);
		}
	}

	function code_gen()
	{
		$totalChar = 8; // number of chars in the code
		$salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";  // salt to select chars from
		srand((double)microtime()*1000000); // start the random generator
		$code=""; // set the inital variable
		for ($i=0;$i<$totalChar;$i++)  // loop and create password
			$code = $code. substr ($salt, rand() % strlen($salt), 1);
		return $code;
	}

	function seo_gen($title, $typ='')
	{
		static $convertTable = array (
			'á' => 'a', 'Á' => 'A', 'ä' => 'a', 'Ä' => 'A', 'č' => 'c',
			'Č' => 'C', 'ď' => 'd', 'Ď' => 'D', 'é' => 'e', 'É' => 'E',
			'ě' => 'e', 'Ě' => 'E', 'ë' => 'e', 'Ë' => 'E', 'í' => 'i',
			'Í' => 'I', 'i' => 'i', 'I' => 'I', 'l' => 'l', 'L' => 'L',
			'l' => 'l', 'L' => 'L', 'ň' => 'n', 'Ň' => 'N', 'n' => 'n',
			'N' => 'N', 'ó' => 'o', 'Ó' => 'O', 'ö' => 'o', 'Ö' => 'O',
			'ř' => 'r', 'Ř' => 'R', 'r' => 'r', 'R' => 'R', 'š' => 's',
			'Š' => 'S', 's' => 's', 'S' => 'S', 'ť' => 't', 'Ť' => 'T',
			'ú' => 'u', 'Ú' => 'U', 'ů' => 'u', 'Ů' => 'U', 'ü' => 'u',
			'Ü' => 'U', 'ý' => 'y', 'Ý' => 'Y', 'y' => 'y', 'Y' => 'Y',
			'ž' => 'z', 'Ž' => 'Z', 'z' => 'z', 'Z' => 'Z', 
			':' => '-', '/' => '-',
		);
		$title = strtolower(strtr($title, $convertTable));
		$title = Str_Replace(Array(" ", "_"), "-", $title); //nahradí mezery a podtržítka pomlckami
		if ($typ=='files')
			$title = Str_Replace(Array("(",")","!",",","\"","'"), "", $title); //odstraní ().!,"'
		else
			$title = Str_Replace(Array("(",")",".","!",",","\"","'"), "", $title); //odstraní ().!,"'
		
		$title = ereg_replace('/[^a-zA-Z0-9]+/u', '-', $title);
		$title = str_replace('--', '-', $title);
		$title = trim($title, '-');
		return urlencode($title);
	}
}
?>

ACC SHELL 2018