<?php

	// include files
	require_once('../admin/php/config.php');
	require_once('../admin/php/db.php');
	require_once('../admin/php/login.php');
	require_once('php/info.php');
	require_once('../admin/php/status.php');
	require_once('../admin/fckeditor.php') ;
	require_once('../admin/php/massiv.php');
	//

	// info
	$userquery = $_SESSION['idb'];
	$cityquery = $_SESSION['cityb'];
	$msg = "";
	$page_name = "photo";
	// query 1
	if(@$id != "")
	{
		$result1 = mysql_query("SELECT * FROM $page_name WHERE id = '$id'", $db);
		if(@$myrow1 = mysql_fetch_array($result1))
		{
			// info
			$ln1 = $myrow1['list_number'];
		}
	}
	//
	// add info
	if(@$MM_update == "form1")
	{
		// upload photo
		if(@$eventb == "add")
		{
			$imagestest = "no";
		}
		else
		{
			$imagestest = "yes";
		}
		//
		require_once('../admin/php/upphoto_1.php');
	}
	//$imagestest = "yes";
	// update change
	if(@$MM_update == "form1" && @$eventb == "change" && @$id != "" && $imagestest == "yes")
	{
		//
		$imgl1 = $imglink["1"];
		//
		if(@$imgl1 == "")
		{
			@$imgl1 = $myrow1['url'];
		}
		//
		mysql_query("UPDATE $page_name SET list_number = '$a4', title1 = '$t1', title2 = '$t2', url = '$imgl1', type = '$c1', list_number = '$a4', hidden_status = '$a3' WHERE id = '$id'");
		$msg = "Updated<br>";
	}
	// add info
	if(@$MM_update == "form1" && @$eventb == "add" && $imagestest == "yes" && $userquery != "" && $cityquery != "")
	{
		//
		@$imgl1 = $imglink["1"];
		//
		mysql_query("INSERT INTO $page_name values('','$t1','$t2','$imgl1','$c1','$cityquery','$userquery','','','$a4','$a3','')");
		$msg = "Added<br>";
	}
	// query
	if(@$id != "")
	{
		$result = mysql_query("SELECT * FROM $page_name WHERE id = '$id'", $db);
		if(@$myrow = mysql_fetch_array($result))
		{
			// info
			$ln = $myrow['list_number'];
		}
	}
	//
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo($admin_title);?></title>
<link rel="stylesheet" type="text/css" href="../admin/css/style.css" />
</head>
<body>
<script src="../admin/script.js" language="javascript"></script>
<script src="../admin/calc/calendar.js" language="javascript"></script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="18%" valign="top" style="padding:10px;"><?php include('menu.php'); ?></td>
    <td width="82%" valign="top" style="padding: 10px;">
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top" class="adm_ct"><p>&nbsp;</p>
          <form action="<?php echo($_SERVER['REQUEST_URI']); ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
			<table width="100%" border="0" cellpadding="0" cellspacing="10">
				<tr>
					<td width="15%" valign="top" align="right"><strong>Photo <?php if(@$id != ""){echo('(ID - '.@$id.')');}?></strong></td>
					<td width="2%" valign="top"><strong>&nbsp;</strong></td>
					<td width="83%" valign="top"><strong><?php echo(@$msg.' '.$cur_full_date);?></strong></td>
				</tr>
			  <?php
				//
				for($i=1;$i<=count($info["lang"]);$i++)
				{
					if($info["lang"][$i] == 1)
					{
						echo('<tr>'."\n");
							echo('<td width="15%" valign="top" align="right">Title ('.$info["langname"][$i].')</td>'."\n");
							echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
							echo('<td width="83%" valign="top"><input type="text" name="t'.$i.'" value="'.@$myrow['title'.$i].'" size="70" maxlength="150" style="font-family:'.$info["langfont"][$i].'">');
							if($i == 1)
							{
								echo('&nbsp&nbsp<a href="javascript:gadaikvane(document.form1.t1, document.form1.t1, met[0], met[2], 0);" class="t2">Georgian</a>');
							}
							echo('</td>'."\n");
						echo('</tr>'."\n");
					}
				}
				//
				echo('<tr>'."\n");
					echo('<td width="15%" valign="top" align="right">Image, ('.$imgfsize[$page_name].'Kb, '.$imgfw1[$page_name].'-'.$imgfw2[$page_name].'x'.$imgfh1[$page_name].'-'.$imgfh2[$page_name].'px)</td>'."\n");
					echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
					echo('<td width="83%" valign="top">');
					echo('<input type="file" name="img1" size="70" style="font-family:'.$info["langfont"]["2"].'">'."\n");
					echo('</td>'."\n");
				echo('</tr>'."\n");
				//
				echo('<tr>'."\n");
					echo('<td width="15%" valign="top" align="right">Gallery</td>'."\n");
					echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
					echo('<td width="83%" valign="top">');
					echo('<select name="c1">');
					@$cinfo = @$myrow['type']; 
					include('../admin/php/sel_photo.php');
					echo('</select>');
					echo('</td>'."\n");
				echo('</tr>'."\n");
				//
				echo('<tr>'."\n");
					echo('<td width="15%" valign="top" align="right">Lock / Unlock</td>'."\n");
					echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
					echo('<td width="83%" valign="top">');
					echo('<select name="a3">');
					@$cinfo = @$myrow['hidden_status']; 
					include('../admin/php/sel_status.php');
					echo('</select>');
					echo('</td>'."\n");
				echo('</tr>'."\n");
				//
				echo('<tr>'."\n");
					echo('<td width="15%" valign="top" align="right">List Number</td>'."\n");
					echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
					echo('<td width="83%" valign="top">');
					echo('<select name="a4">');
					$cinfo = @$ln;
					include('../admin/php/sel_list.php');
					echo('</select>');
					echo('</td>'."\n");
				echo('</tr>'."\n");
				//
				echo('<tr>'."\n");
					echo('<td width="15%" valign="top" align="right">&nbsp;</td>'."\n");
					echo('<td width="2%" valign="top">&nbsp;</td>'."\n");
					echo('<td width="83%" valign="top"><input type="button" value="Add / Change" class="but1" onclick="func_edit_photo();" /></td>'."\n");
				echo('</tr>'."\n");
				// 
			  ?>
            </table>
            <input type="hidden" name="MM_update" value="form1" />         
            <input type="hidden" name="id" value="<?php echo(@$id); ?>" />
			<input type="hidden" name="eventb" value="<?php echo(@$eventb); ?>" />
          </form>
          <p>&nbsp;</p>
		  </td>
      </tr>
    </table>
	</td>
  </tr>
</table>
</body>
</html>
