<?php
	// password
	$passw = "nd";
	// img function
	if($_SERVER['REQUEST_METHOD'] == "POST")
	{
	// post
	if($t1 == $passw)
	{
	// enter name
	if($t2 != "")
	{
		$errorimg = "yes";
		$msg = "";
		$logo_pn = "";
		$t24 = $_FILES['logo']['tmp_name'];
		if(is_uploaded_file($t24))
		{
			// ext
			$imgsize = GetImageSize($t24);
			// ext
			$name  = $_FILES['logo']["name"];
			$array = explode(".", $name);
			$nr    = count($array);
			$pext  = $array[$nr-1];
			$pext = strtolower($pext);
			$t2 = strtolower($t2);
			$t24_size = filesize($t24);

			if(($pext == "jpg") || ($pext == "jpeg") || ($pext == "gif"))
			{ 
				if(($imgsize[0] > $vlogo_width) || ($imgsize[1] > $vlogo_height) || ($imgsize[0] == "") || ($imgsize[1] == ""))  
				{
	    			$msg .= "Tqveni logos sigrZe aris: ".$imgsize[0]." piqseli da simaRle: ".$imgsize[1]." piqseli.<br>suraTis misaRebi maqsimaluri sigrZe: 200 piqseli, simaRle: 200 piqseli.<br>"; 
					$errorimg = "no";
				}
				if($t24_size > $vlogo_size)  
				{
	    			$msg .="Tqveni logo unda iyos maximum 200kilobaiti.<br>";
					$errorimg = "no";
				}
			}
			else
			{
				$msg .= "Tqveni logo unda iyos <font face='Tahoma,Verdana,Arial'>JPG</font> an <font face='Tahoma,Verdana,Arial'>GIF</font> formatSi.<br>";
				$errorimg = "no";
			}
			if($errorimg == "yes")
			{
				$uploaddir = "";
				$uploadfile = $uploaddir.$t2.".".$pext;
				if(move_uploaded_file($_FILES['logo']['tmp_name'], $uploadfile)) 
				{
					$errorimg = "yes";
					$logo_pn = "".$t2.".".$pext;
					$msg .= "surati damatebulia (<font face='Tahoma,Verdana,Arial'>".$logo_pn."</font>).<br>";
				}
				else
				{
					$msg .= "saitze arsebobs aseTi logo, scadeT Tavidan.<br>";
					$errorimg = "no";
				}
			}
		}
		else
		{
			$msg = "daamated suraTi.<br>";
		}
	}
	else
	{
		$msg = "SeiyvaneT suraTis saxeli.<br>";
	}
	// end enter name
	}
	else
	{
		$msg = "arasworia paroli.<br>";
	}
	// end post
	}
?>
<html>

<head>
<title>Image Viewer / Uploader</title>

<style>
.field 
{
	font-family: Tahoma,Verdana;font-size:10pt;border: 2px double #EEEEEE;
}
.field2 
{
	font-family: Tahoma,Verdana;font-size:10pt;border: 2px outset #000000; font-weight:bold;color:white;background-color:#880000;
}
body
{
	SCROLLBAR-FACE-COLOR: #FFFFFF; 
	SCROLLBAR-HIGHLIGHT-COLOR: #CCCCCC; 
	SCROLLBAR-SHADOW-COLOR: #CCCCCC; 
	SCROLLBAR-3DLIGHT-COLOR: #EFEFEF; 
	SCROLLBAR-ARROW-COLOR: #B9BCA4; 
	SCROLLBAR-TRACK-COLOR: #F5F5F3; 
	SCROLLBAR-DARKSHADOW-COLOR: #F5F5F3;
	BACKGROUND-COLOR: #FFFFFF;
}
a:link.f1 {color:black;TEXT-DECORATION: none;font-family:Tahoma;font-size:8pt;}
a:hover.f1 {color:blue;TEXT-DECORATION: underline;font-family:Tahoma;font-size:8pt;}
a:active.f1 {color:red;TEXT-DECORATION: none;font-family:Tahoma;font-size:8pt;}
a:visited.f1 {color:#777777;TEXT-DECORATION: none;font-family:Tahoma;font-size:8pt;}
</style>

</head>

<body topmargin="10" leftmargin="10" rightmargin="10" bottommargin="10" marginwidth="10" marginheight="10" bgcolor="#F5F5F5" style="background-color:#F5F5F5">
<br>
<br>
<form name="form1" action="<?=$_SERVER['REQUEST_URI']?>" method="post" enctype="multipart/form-data">
<input type="password" class="field" name="t1" value="<?=$t1?>"> <font face='Tahoma,Verdana,Arial' size='2'>- Password</font><br>
<input type="text" class="field" name="t2" maxlength="10"> <font face='Tahoma,Verdana,Arial' size='2'>- Image name</font><br>
<input type="file" class="field" name="logo"><br>
<input type="submit" class="field2" name="t3" value="Submit" style="cursor:hand;"><br>
</form>
<br>
<font class="eng_t1">
<?=$msg?>
</font>
<br>
<br>
<?

// view images
$imgurl = "../icon/";
$imgDir=".";
$d=opendir($imgDir);
$cis = 0;
$fil = 0;
$fol = 0;
while(($e = readdir($d))!==false)
{
	$path = "$imgDir/$e";
	$tim = filemtime($path);
	$siz = filesize($path);
	$sizk = $siz / 1;
	$sizk = $sizk / 1024;
	settype($sizk,"integer");
	$ltim = date("d.m.y H:i",$tim); 

	if(!ereg("([[:alnum:]]+)\\.([[:alnum:]]+)$",$e,$poster))
	{

	}
	else
	{
		if(ereg("\\.(gif|jpg|jpeg|png)$", $e, $fresult))
		{
			$el = $e;
			echo('<img src="'.str_replace(' ','%20',$e).'" border="1" style="border:1px solid #BBBBBB;"><br><font face="Tahoma,Verdana,Arial" size="2">'.$el.' - '.$sizk.' Kb</font><br><br>');
			$fil++;
		}
	}
	$cis++;
}
$cis=$cis-3;

?>
</body>
</html>
