<?php require_once('../Connections/telmanik_press.php'); ?>
<!-- Turn Errors off for post\/--->
<?php error_reporting(E_ALL ^ E_NOTICE); ?>
<!--- Turn Errors off for post/\---->
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "mutiple_file_upload_form")) {
  $insertSQL = sprintf("INSERT INTO photos (gallery, image_name, `description`, title) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['selectgallery'], "text"),
                       GetSQLValueString($_FILES['image1']['name'], "text"),
                       GetSQLValueString($_POST['description'], "text"),
                       GetSQLValueString($_POST['title'], "text"));

  mysql_select_db($database_telmanik_press, $telmanik_press);
  $Result1 = mysql_query($insertSQL, $telmanik_press) or die(mysql_error());
}

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_galleryselect = "SELECT * FROM gallerys";
$galleryselect = mysql_query($query_galleryselect, $telmanik_press) or die(mysql_error());
$row_galleryselect = mysql_fetch_assoc($galleryselect);
$totalRows_galleryselect = mysql_num_rows($galleryselect);
?>
<?php require("assets/wrapper/header.php"); ?>

<div id="editload">
  <p></p>












<!--- first image1 block ---->
<?php





$allowedExts = array("jpg", "jpeg", "gif", "png", "JPG", "JPEG", "GIF", "PNG");
$extension = end(explode(".", $_FILES["image1"]["name"]));
if ((($_FILES["image1"]["type"] == "image/gif")
|| ($_FILES["image1"]["type"] == "image/jpeg")
|| ($_FILES["image1"]["type"] == "image/png")
|| ($_FILES["image1"]["type"] == "image/pjpeg"))
&& ($_FILES["image1"]["size"] < 2000000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["image1"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["image1"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["image1"]["name"] . "<br>";
    echo "Type: " . $_FILES["image1"]["type"] . "<br>";
    echo "Size: " . ($_FILES["image1"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["image1"]["tmp_name"] . "<br>";



    if (file_exists(".../photos/" . $_FILES["image1"]["name"]))
	
	
      {
      echo $_FILES["image1"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["image1"]["tmp_name"],
	  
      "../photos/" . $_FILES["image1"]["name"]);
      echo "Stored in: " . "../photos/" . $_FILES["image1"]["name"];
      }
    }
  }
else
  {
  echo $translate->__('Invalid file');
  }
   
  
  
?> 






<div id="edithead"><p><?php echo $translate->__('You can store as many files as you want per gallery.');?></p>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="mutiple_file_upload_form" id="mutiple_file_upload_form">
<?php echo $translate->__('Please Select Gallery you want to upload photos to');?><BR /><select name="selectgallery">
    <?php
do {  
?>
    <option value="<?php echo $row_galleryselect['gallery_name']?>"><?php echo $row_galleryselect['gallery_name']?></option>
    <?php
} while ($row_galleryselect = mysql_fetch_assoc($galleryselect));
  $rows = mysql_num_rows($galleryselect);
  if($rows > 0) {
      mysql_data_seek($galleryselect, 0);
	  $row_galleryselect = mysql_fetch_assoc($galleryselect);
  }
?>
  </select><BR />
 <?php echo $translate->__('Select Image:');?> <BR />
    <input name="image1" id="images" type="file" size="100" /><BR />
    <?php echo $translate->__('Description:');?> <BR />
    <input name="description" size="100" type="text" /><BR />
   
    <?php echo $translate->__('Title:');?><BR />
    <input name="title" size="100" type="text" /><BR />
     <BR />
  
  
  <input type="submit" name="Submit" value="<?php echo $translate->__('Upload');?>" />
  <input type="hidden" name="MM_insert" value="mutiple_file_upload_form" />
</form>
  <p>&nbsp;</p>
</div>
</div>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($galleryselect);
?>
