ACC SHELL

Path : /srv/www/vhosts/sc-brno/tecaprint/modules/zamestnanci/
File Upload :
Current File : /srv/www/vhosts/sc-brno/tecaprint/modules/zamestnanci/modul.php.bak

<?
class CModul_Zamestnanci{
	function CModul_Zamestnanci($pripojeni){
		$this->pripojeni = $pripojeni;
		$this->conf_id='modul_zamestnanci';
	}
	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."'");
		$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."elementy (id_bloku, poradi, modul, nazev) SELECT '".$id_bloku."', max(poradi)+1, '".$this->conf_id."', '".$_REQUEST['nazev']."' 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_zamestnanci WHERE id_elementu='".$id_elementu."' AND deleted='0' LIMIT 3");
		while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			echo"<div class='osoba'>";
				echo"<h3>".$data->titul." ".$data->jmeno." ".$data->prijmeni." ".$data->titul_za."</h3>";
				echo"<div class='anotace'>".$data->funkce." ".($data->zarizeni?" (".$data->zarizeni.")":"")."</div>";
			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' title='Upravit obsah'>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' title='Odstranit modul'>Odstranit modul</a>";
			echo"</div>\n\n";						
	
	}

	function show_element_view($id_elementu){
  
  	$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id_elementu='".$id_elementu."'  AND deleted='0'  ");
			
			$celkem_polozek = $this->pripojeni->pocet_radku($dbdata);     
			$messages_per_page=10;
			$page = ($_REQUEST['page'] ? $_REQUEST['page'] : 1);
			$odkud_vypisovat=($page-1)*$messages_per_page;
			if ($messages_per_page)
				$celkem_stran = $celkem_stran=  ceil($celkem_polozek/$messages_per_page);

			$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id_elementu='".$id_elementu."'  AND deleted='0'   order by  poradi asc, prijmeni, jmeno	 LIMIT $odkud_vypisovat, $messages_per_page");

  
	//$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id_elementu='".$id_elementu."' AND deleted='0' ");
		while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			echo"<div class='osoba ".($data->ikona?"osoba-ikona":"")."'>";
    
				echo $data->ikona? "<div class='ikona'><img src='./images/obr/".$data->ikona."' alt='".$data->prijmeni."'/></div>" :"";
				echo"<h3>".$data->titul." ".$data->jmeno." ".$data->prijmeni." ".$data->titul_za."</h3>";
				echo"<div class='funkce'>".$data->funkce."</div>";


				echo $data->kompetence? "<div class='kompetence'> ".$data->kompetence."</div>" :"";
				echo"<dl>";
				echo $data->zarizeni ? "<dt>Zařízení:</dt><dd class='zarizeni'>".$data->zarizeni."</dd>" :"";
				echo $data->adresa ? "<dt>Adresa:</dt><dd class='adresa'>".$data->adresa."</dd>" :"";
				echo $data->telefon ? "<dt>Telefon:</dt><dd class='telefon'>".$data->telefon."</dd>" :"";
        		echo $data->fax ? "<dt>Fax:</dt><dd class='fax'>".$data->fax."</dd>" :"";
				echo $data->mobil ? "<dt>Mobil:</dt><dd class='mobil'>".$data->mobil."</dd>" :"";
				echo $data->email ? "<dt>E-mail:</dt><dd class='email'><a href='mailto:".$data->email."'>".$data->email."</a>"."</dd>" :"";
				echo"</dl>";
			echo"</div>";
		
		}
	 $this->strankovani($page, $celkem_stran);		
	}

	function vyhledat($fraze){
		$dbdata = $this->pripojeni->dotaz("SELECT distinct id_elementu FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE concat(jmeno, ' ', prijmeni, ' ', funkce, ' ', kompetence,' ', zarizeni,' ', adresa, ' ', telefon, ' ', mobil, ' ', email) LIKE '%".$fraze."%' AND deleted='0' " );
		while($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			$idecka .= ($idecka?", ":"").$data->id_elementu;		
		}
		return $idecka;
	
	}
                     
   function strankovani($aktualni_strana, $celkem_stran, $nazev_parametru='page'){
  	$cesta .= "./";
  	$cesta .= $_REQUEST['lev1']?$_REQUEST['lev1']."/":"";
  	$cesta .= $_REQUEST['lev2']?$_REQUEST['lev2']."/":"";
  	$cesta .= $_REQUEST['lev3']?$_REQUEST['lev3']."/":"";
  	$cesta .= $_REQUEST['lev4']?$_REQUEST['lev4']."/":"";

/* 
  	if (is_array($_GET)) {
   		foreach ($_GET as $key=>$value) {
     		if($key!='lev1' && $key!='lev2' && $key!='lev3' && $key!='lev4' && $key!=$nazev_parametru ){
				 $cesta.= (!$kolikaty_param++?"?":"&amp;").$key."=".$value;
			 }
		}
   	}
*/  	
		if($celkem_stran>1){
			echo"<div class='strankovani'>";
			
			if($aktualni_strana>1){
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=1' class='a-first'>&nbsp;</a> ";
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".($i>1?$i-1:1)."' class='a-prev'>&nbsp;</a> ";
			}
			else{
				echo"<b class='a-first'>&nbsp;</b> ";
				echo"<b class='a-prev'>&nbsp;</b> ";
			
			}
			for ($i=1; $i<=$celkem_stran; $i++) {
				if($i!=$aktualni_strana){
	  	    	echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".$i."' ".($i==$aktualni_strana?"class='active'":"").">".$i."</a> ";
				}
				else{
		  	    	echo"<b>".$i."</b> ";
				}
	 		}
			if($aktualni_strana<$celkem_stran){
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".($i<$celkem_stran?$i+1:$celkem_stran)."' class='a-next'>&nbsp;</a> ";
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".$celkem_stran."' class='a-last'>&nbsp;</a> ";
			}
			else{
				echo"<b class='a-next'>&nbsp;</b> ";
				echo"<b class='a-last'>&nbsp;</b> ";
			}  
	
	  		echo"</div>";
		
	
		}
  }


	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('ikona', "../../images/obr/", "../../images/tn/", $nazev_obrazku, 120);
		}
		
		
		if ($_REQUEST['id']){
			$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."modul_zamestnanci SET hidden='".($_REQUEST['hidden']+0)."', jmeno='".$_REQUEST['jmeno']."', prijmeni='".$_REQUEST['prijmeni']."', titul='".$_REQUEST['titul']."', titul_za='".$_REQUEST['titul_za']."', funkce='".$_REQUEST['funkce']."', kompetence='".$_REQUEST['kompetence']."', fax='".$_REQUEST['fax']."', adresa='".$_REQUEST['adresa']."', email='".$_REQUEST['email']."', telefon='".$_REQUEST['telefon']."' , mobil='".$_REQUEST['mobil']."' , poradi='".($_REQUEST['poradi']+0)."' ".($nazev_obrazku?", ikona='".$nazev_obrazku."'":"")." WHERE id='".$_REQUEST['id']."'");
		}
		else{
			$this->pripojeni->dotaz("INSERT INTO ".$GLOBALS['config_db_prefix']."modul_zamestnanci (id_elementu, hidden, jmeno, prijmeni, titul, titul_za, funkce, fax,  adresa, email, telefon, poradi, ikona, kompetence, mobil) VALUES
       ('".(0+$_REQUEST['id_elementu'])."', '".($_REQUEST['hidden']+0)."', '".$_REQUEST['jmeno']."', '".$_REQUEST['prijmeni']."',  '".$_REQUEST['titul']."', '".$_REQUEST['titul_za']."', '".$_REQUEST['funkce']."', '".$_REQUEST['fax']."', '".$_REQUEST['adresa']."', '".$_REQUEST['email']."', '".$_REQUEST['telefon']."', '".($_REQUEST['poradi']+0)."', '".$nazev_obrazku."', '".$_REQUEST['kompetence']."', '".$_REQUEST['mobil']."')");
		}
		
	}
	function articles_delete($id)
	{
		if ($id){
//			$this->pripojeni->dotaz("DELETE FROM ".$GLOBALS['config_db_prefix']."modul_clanky WHERE id='".(0+$id)."'");
			$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."modul_zamestnanci 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['oprava']){
			if($_REQUEST['clear_icon']){
				$this->pripojeni->dotaz("UPDATE ".$GLOBALS['config_db_prefix']."modul_zamestnanci set ikona='' WHERE id='".$_REQUEST['oprava']."' LIMIT 1");
			}		
		
			$db_opravna_polozka  = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id='".$_REQUEST['oprava']."' LIMIT 1");
			if ($db_opravna_polozka && $opravna_polozka = $this->pripojeni->objekt_dotazu($db_opravna_polozka)){
			}
		}

 		if($_REQUEST['oprava'] || $_REQUEST['add_new']){
 		
			echo"<div class='block-border'>";
			echo"<div class='block-content'>";
			echo"<h1>".(!$opravna_polozka->id?"Vložení osoby":"Editace osoby")."</h1>";
			
		echo"<form action='./functions/function.php' method='post' enctype='multipart/form-data' class='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>Jméno</th><td><input type='text' name='jmeno' value='".$opravna_polozka->jmeno."'/></td></tr>\n";
				echo"<tr><th>Příjmení</th><td><input type='text' name='prijmeni' value='".$opravna_polozka->prijmeni."'/></td></tr>\n";
				echo"<tr><th>Titul</th><td><input type='text' name='titul' value='".$opravna_polozka->titul."'/></td></tr>\n";
				echo"<tr><th>Titul za jm.</th><td><input type='text' name='titul_za' value='".$opravna_polozka->titul_za."'/></td></tr>\n";
				echo"<tr><th>Funkce</th><td><input type='text' name='funkce' value='".$opravna_polozka->funkce."'/></td></tr>\n";
				echo"<tr><th>Kompetence</th><td><textarea name='kompetence' >".$opravna_polozka->kompetence."</textarea></td></tr>\n";



				//echo"<tr><th>Zařízeni</th><td><input type='text' name='zarizeni' value='".$opravna_polozka->zarizeni."'/></td></tr>\n";
				
				//echo"<tr><th>Adresa</td><th><textarea name='adresa' >".$opravna_polozka->adresa."</textarea></td></tr>\n";
				echo"<tr><th>Telefon</th><td><input type='text' name='telefon' value='".$opravna_polozka->telefon."'/></td></tr>\n";
				echo"<tr><th>GSM</th><td><input type='text' name='mobil' value='".$opravna_polozka->mobil."'/></td></tr>\n";
        	echo"<tr><th>Fax</th><td><input type='text' name='fax' value='".$opravna_polozka->fax."'/></td></tr>\n";
				echo"<tr><th>Email</th><td><input type='text' name='email' value='".$opravna_polozka->email."'/></td></tr>\n";
				
				echo"<tr><th>Pořadí</th><td><input type='text' name='poradi' value='".$opravna_polozka->poradi."'/></td></tr>\n";
	        echo"<tr><th>Foto</th><td><input type='file' name='ikona' /><br/>".($opravna_polozka->ikona?"<img src='../images/tn/".$opravna_polozka->ikona."' alt=''/> <a href='".$admin_url."&amp;oprava=".$opravna_polozka->id."&amp;clear_icon=true'><img src='./images/icons/fugue/cross-circle.png' alt='odstranit' onclick='return confirm(\"Opravdu odstranit ikonu?\");'/></a> <a href='./force_download.php?file=".$opravna_polozka->ikona."'><img src='./images/icons/fugue/arrow-270.png' alt=''/></a>":"")."</td></tr>\n";
				
//				echo"<tr><th>Foto</th><td><input type='file' name='ikona' /><br/>".($opravna_polozka->ikona?"<img src='../images/tn/".$opravna_polozka->ikona."' alt=''/>":"")."</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' title='Zpět na seznam osob'>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 osob</h1>";		     
    // echo t.$_REQUEST['id_elementu'];
    
    
    
		$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id_elementu='".$_REQUEST['id_elementu']."' AND deleted='0'  ORDER BY poradi, prijmeni, jmeno");
		
			$celkem_polozek = $this->pripojeni->pocet_radku($dbdata);
			$messages_per_page=10;
			$page = ($_REQUEST['page'] ? $_REQUEST['page'] : 1);
			$odkud_vypisovat=($page-1)*$messages_per_page;
			if ($messages_per_page)
				$celkem_stran = $celkem_stran=  ceil($celkem_polozek/$messages_per_page);
	
		
		$dbdata = $this->pripojeni->dotaz("SELECT * FROM  ".$GLOBALS['config_db_prefix']."modul_zamestnanci WHERE id_elementu='".$_REQUEST['id_elementu']."' AND deleted='0'  ORDER BY poradi, prijmeni, jmeno LIMIT $odkud_vypisovat, $messages_per_page ");		
		
		echo"<table class='vypisy table with-head'>\n";
		echo"<thead><tr><th>Osoba</th><th>Funkce</th><th>Pořadí</th><th>Operace</th></tr></thead>";
		while ($dbdata && $data = $this->pripojeni->objekt_dotazu($dbdata)){
			echo"<tr class='".(($i++)%2?"s":"l")."'>\n";
				echo"<td>".$data->titul." ".$data->jmeno." ".$data->prijmeni." ".$data->titul_za."</td>\n";
				echo"<td>".$data->funkce."</td>";
//				echo"<td>".$data->zarizeni."</td>";
				echo"<td>".$data->poradi."</td>";
        
					echo"\t\t<td class='op'><a href='".$admin_url."&amp;oprava=".$data->id."' class='edit'><img src='./images/icons/fugue/pencil.png' alt='upravit'/></a> &nbsp; \n";			
					echo"\t\t<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></td>\n";			
			echo"</tr>";
		}
		echo"</table>";
		
		
						$this->strankovani_admin($page, $celkem_stran, $admin_url);
						
						
		echo"<a href='".$admin_url."&amp;add_new=true' class='button blue' title='Přidat osobu'>+</a>  ";

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



 	function strankovani_admin($aktualni_strana, $celkem_stran, $cesta){
		$nazev_parametru='page';	
		$kolikaty_param = 1;
			
		if($celkem_stran>1){
			echo"<div class='strankovani'>";
			
			if($aktualni_strana>1){
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=1' class='a-first'>&nbsp;</a> ";
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".($i>1?$i-1:1)."' class='a-prev'>&nbsp;</a> ";
			}
			else{
				echo"<b class='a-first'>&nbsp;</b> ";
				echo"<b class='a-prev'>&nbsp;</b> ";
			
			}
			for ($i=1; $i<=$celkem_stran; $i++) {
				if($i!=$aktualni_strana){
	  	    	echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".$i."' ".($i==$aktualni_strana?"class='active'":"").">".$i."</a> ";
				}
				else{
		  	    	echo"<b>".$i."</b> ";
				}
	 		}
			if($aktualni_strana<$celkem_stran){
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".($i<$celkem_stran?$i+1:$celkem_stran)."' class='a-next'>&nbsp;</a> ";
				echo"<a href='".$cesta.($kolikaty_param?"&amp;":"?").$nazev_parametru."=".$celkem_stran."' class='a-last'>&nbsp;</a> ";
			}
			else{
				echo"<b class='a-next'>&nbsp;</b> ";
				echo"<b class='a-last'>&nbsp;</b> ";
			}  
	
	  		echo"</div>";
		
	
		}
  }





	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