<?php require_once('../Connections/telmanik_press.php'); ?>
<?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_update"])) && ($_POST["MM_update"] == "mutiple_file_upload_form")) {
  $updateSQL = sprintf("UPDATE logo SET image_name=%s, title=%s, `description`=%s WHERE id=%s",
                           GetSQLValueString($_FILES['image1']['name'], "text"),
                       GetSQLValueString($_POST['title'], "text"),
                       GetSQLValueString($_POST['description'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

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

  $updateGoTo = "success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_old_logo = "SELECT * FROM logo";
$old_logo = mysql_query($query_old_logo, $telmanik_press) or die(mysql_error());
$row_old_logo = mysql_fetch_assoc($old_logo);
$totalRows_old_logo = mysql_num_rows($old_logo);
?>
<!-- Turn Errors off for post\/--->
<?php error_reporting(E_ALL ^ E_NOTICE); ?>
<!--- Turn Errors off for post/\---->
<?php

?>
<?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("../logo/" . $_FILES["image1"]["name"]))
	
	
      {
      echo $_FILES["image1"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["image1"]["tmp_name"],
	  
      "../logo/" . $_FILES["image1"]["name"]);
      echo "Stored in: " . "../logo/" . $_FILES["image1"]["name"];
      }
    }
  }
else
  {
  echo $translate->__('Invalid file');
  }
   
  
  
?> 






<div id="edithead">
<p><?php echo $translate->__('Update your logo');?> - </p>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="mutiple_file_upload_form" id="mutiple_file_upload_form">
<input type="hidden" name="id" id="id" value="1" />
  <?php echo $translate->__('Select Image:');?> <BR />
    <input name="image1" type="file" id="images" value="<?php echo $row_old_logo['image_name']; ?>" size="100" /><BR />
    <?php echo $translate->__('Description:');?> <BR />
    <input name="description" type="text" value="<?php echo $row_old_logo['description']; ?>" size="100" /><BR />
   
    <?php echo $translate->__('Title:');?><BR />
    <input name="title" type="text" value="<?php echo $row_old_logo['title']; ?>" size="100" /><BR />
     <BR />
  
  
  <input type="submit" name="Submit" value="<?php echo $translate->__('Update');?>" />
  <input type="hidden" name="MM_insert" value="mutiple_file_upload_form" />
  <input type="hidden" name="MM_update" value="mutiple_file_upload_form" />
</form>
  <p>&nbsp;</p>
</div>
</div>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($old_logo);


?>
