<?php session_start();  //Developed by ITechScripts
require 'include/configurations.php'; // ITECHBIDS Configuration File
$max_filesize_sql="select * from genaralsettings where set_id=57";
$max_filesize_res=mysql_query($max_filesize_sql);
$max_filesize_row=mysql_fetch_array($max_filesize_res);
$max_filesize=$max_filesize_row[set_value];

$auction_query="select * from genaralsettings where set_id=42";
$table=mysql_query($auction_query);
$row=mysql_fetch_array($table);
$bid_permission=$row['set_value'];

$_mode=$_REQUEST[mode];
$productid=$_REQUEST[productid];
$postformat=$_SESSION[postformat];
$userid=$_SESSION[userid];
$flag=$_POST[flag];
$edit="select * from auction_details where productid=$productid";
$modifyres=mysql_query($edit);
$modifyrow=mysql_fetch_array($modifyres);

$cat_sql="select category_name from site_categories where category_id=".$modifyrow['category_id'];
$cat_res=mysql_query($cat_sql);
$cat_row=mysql_fetch_array($cat_res);

function itechitems_11($itechitems_11id,$cat_string)
{
$cat_sql1="select * from site_categories where category_id=".$itechitems_11id;
$cat_sql_res1=mysql_query($cat_sql1);
$cat_sql_row1=mysql_fetch_array($cat_sql_res1);
$cat_string.="$cat_sql_row1[category_name]".",";
if($cat_sql_row1[category_head_id])
{
 itechitems_11($cat_sql_row1[category_head_id],$cat_string);
}
else
{
$cat_string=explode(",",$cat_string);
$cat_count=count($cat_string);
$cat_str=" ";
for($ci=$cat_count-1;$ci>=0;$ci--)
{
if($cat_string[$ci])
{
$cat_str="$cat_str"."$cat_string[$ci]"." > ";
}
} 
echo "$cat_str";
}
} 

if($res=mysql_query($cat_sql))
{
$row=mysql_fetch_array($res);
$tablename=$row[tablename];
$file_path=$row[file_path];
}
if($tablename)
  {
  $tab_sql="select * from $tablename";
  $tab_res=mysql_query($tab_sql);
  $i =2;
while ($i < mysql_num_fields($tab_res))
{
      $tab_col = mysql_fetch_field($tab_res, $i);
   	  $dummy="$".$tab_col->name;
      $dummy=$_POST[$tab_col->name];
	  if($set!=1)
	  {
	  $table_sql="select * from $tablename where productid=$productid";
	  $table_res=mysql_query($table_sql);
      $table_row=mysql_fetch_array($table_res);
	  $_SESSION[$tab_col->name]=$table_row[$tab_col->name];
	  }
	$i++;
} // while
$set=1;
}
$fea_item="select * from featuredproducts where productid=$productid";
$fea_res=mysql_query($fea_item);
$fea_row=mysql_fetch_array($fea_res);
$producttitle=$modifyrow[producttitle];
$itemdes=$modifyrow[detailed_descrip];
$start_delay=$modifyrow[start_delay];
$currency=$modifyrow[currency];
$rev_price=$modifyrow[reserve_price];
$or_price=$modifyrow[or_price];
$return_pol=$modifyrow[return_pol];
$selling_method=$modifyrow[selling_method];
$postformat=$selling_method;

$Gallery=$fea_row[gallery_feature];
$Highlight=$fea_row[highlight];
$Privateauc=$fea_row[Privateauc];

$Bold=$fea_row[bold];
$Subtitle=$fea_row[subtitle_feature];
$Subtitle_name=$fea_row[subtitle];
$Home=$fea_row[home_feature];
$size_of_qty=$modifyrow[size_of_quantity];
$postmethod=$modifyrow[selling_method];
$_SESSION[shipping_route]=$modifyrow[shipping_route];
$_SESSION[shipping_amt]=$modifyrow[shipping_cost];
$_SESSION[tax]=$modifyrow[tax];
if(empty($postformat))
{
if($postmethod=="auction")
$postformat=1;
else
$postformat=4;
}
$quick=$modifyrow[quick_buy_price]; 
$min_amt=$modifyrow[min_bid_amount];
$rev_price=$modifyrow[reserve_price];
$bid_inc=$modifyrow[bidincrement];
$qty=$modifyrow[Quantity];
$_SESSION[img2]=$modifyrow[picture2];
$_SESSION[img3]=$modifyrow[picture3];
$_SESSION[img1]=$modifyrow[picture1];
$_SESSION[img4]=$modifyrow[picture4];
$_SESSION[img5]=$modifyrow[picture5];
$_SESSION[img6]=$modifyrow[picture6];
$_SESSION[img7]=$modifyrow[picture7];
$_SESSION[img8]=$modifyrow[picture8];
$_SESSION[categoryid]=$modifyrow[category_id];
$image1=$modifyrow[picture1];
$image2=$modifyrow[picture2];
$image3=$modifyrow[picture3];
$image4=$modifyrow[picture4];
$image5=$modifyrow[picture5];
$image6=$modifyrow[picture6];
$image7=$modifyrow[picture7];
$image8=$modifyrow[picture8];
if($flag==1)
{
  if($tablename)
  {
  $tab_sql="select * from $tablename";
  $tab_res=mysql_query($tab_sql);
  $i =2;
while ($i < mysql_num_fields($tab_res))
{
    $tab_col = mysql_fetch_field($tab_res, $i);
    if (!$tab_col) 
	{
echo '<b>'.$err_28.'</b><br>';
  }
	else
	{
	  $dummy="$".$tab_col->name;
      $dummy=$_POST[$tab_col->name];
	    $_SESSION[$tab_col->name]=$_POST[$tab_col->name];		
		if(empty($_SESSION[$tab_col->name]))
        {
		$err_dummy=$err_23;
        // $err_dummy="Please Enter this Information";
	     $err_flag=1;
        }
		else
		{
		 $var_type=$tab_col->type;
		 if($var_type=="int" or $var_type=="tinyint")
		  {
		   if(!is_numeric($_SESSION[$tab_col->name]))
	        {
		    $err_flag=1;
	        }
		  }
		}
	   }
	$i++;
} // while
} // if($tablename)
$mode=$_POST[mode];
$productid=$_POST[productid];
$sub_cat=$_POST[cbosubcat];
$producttitle=$_POST[txttitle];
$itemdes=$_POST[htmlcontent];

$itemdes=str_replace("'" , "\'" , $itemdes);


$_SESSION[item_des]=$itemdes;

$item_counter_style=$_POST['item_counter_style'];
$start_delay=$_POST['cbo_start_delay'];
$currency=$_POST['cbocurrency'];
$days=$_POST[cbodays];
$mins=$_POST[cbomins];
$hours=$_POST[cbohours];
$secs=$_POST[cbosecs];
$or_price=$_POST[txt_or];
$return_pol=$_POST[txt_return];
$currency=$_POST['cbocurrency'];
$postformat=$_SESSION[postformat];
$size_of_qty=$_POST['size_of_qty'];
$postformat=$_POST['postformat'];
$myprice=0;
$rev_price=$_POST[txt_rev_price];

$_SESSION['sale_price']=$myprice;
if(empty($producttitle))
{
		$err_title=$err_23;
// $err_title="Please Enter this Information";
	 $err_flag=1;
}

if(strlen($itemdes)==0)
{ 
		$err_des=$err_23; 
// $err_des="Please Enter this Information";
 $err_flag=1;
}
else
{
$err_flag=0;
}

if($selling_method==5)
{

 $quick=$_POST[txt_quick]; 
 
 
 if(!empty($quick) || $quick!="0.00" )
{
 if(!is_numeric($quick) )
	{
		$err_fix_price=$err_21;
      //$err_fix_price="Your Quick Buy Price is invalid";
	  $err_flag=1;
	}
 }
 
 if($modifyrow[selling_method]=="fix")
{
 if(empty($quick) || $quick=="0.00")
{
		$err_fix_price=$err_23;
        $err_flag=1;
}
}
 
$min_amt=$_POST[txt_min_amt];
$rev_price=$_POST[txt_rev_price];
$bid_inc=$_POST[txt_bid_inc];
$repost=$_POST[repost];

if($modifyrow[selling_method]!="fix")
{




 if(empty($min_amt))
{
		$err_min_amt=$err_23;
// $err_min_amt="Please Enter this Information";
	 $err_flag=1;
}
else
{
 if(!is_numeric($min_amt))
	{
		$err_min_amt=$err_18;
      //$err_min_amt="Your minimum bid amount is invalid";
	  $err_flag=1;
	}
}


 if(empty($bid_inc))
{
		$err_bid_inc=$err_23;
// $err_bid_inc="Please Enter this Information";
	 $err_flag=1;
}
else
{
 if(!is_numeric($bid_inc))
	{
		$err_bid_inc=$err_12;
      //$err_bid_inc="Your Bid increment is invalid";
	  $err_flag=1;
	}
}
} // if($modifyrow[selling_method]!="ads" and $modifyrow[selling_method]!="fix")

} //
$qty=1;
 if(empty($qty))
{
		$err_qty=$err_23;
// $err_qty="Please Enter this Information";
	 $err_flag=1;
}
else
{
 if(!is_numeric($qty))
	{
		$err_qty=$err_10;
      //$err_qty="Your Quantity is invalid";
	  $err_flag=1;
	}
}

if($postformat=="1")
{
$overimage="blank";
}
if($postformat=="2")
{
$overimage="penny";
}
if($postformat=="3")
{
$overimage="100";
}
if($postformat=="4")
{
$overimage="nail";
}
if($postformat=="5")
{
$overimage="fixed";
}
if($postformat=="6")
{
$overimage="beginner";
}
if($postformat=="7")
{
$overimage="10sec";
}
if($postformat=="8")
{
$overimage="15sec";
}
if($postformat=="9")
{
$overimage="20sec";
}

$srv = getcwd();
$srv=str_replace("/admin" , "/overlay" , $srv);
$srv = "$srv/";

$srv1 = getcwd();
$srv1=str_replace("/admin" , "/uploads" , $srv1);
$srv1 = "$srv1/";

$ref = $_SERVER["SERVER_NAME"];
$ref2 = $_SERVER["REQUEST_URI"];
$ref2=str_replace("/admin/modifyauction.php" , "/uploads" , $ref2);

$dname = 'http://'.$ref2;

	$trans_r = 255;
	$trans_g = 255;
	$trans_b = 255;
	$cache_fs = "$srv1";
	$cache_uri = $dname;








        srand();
        $overlay = $srv.''.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img1'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img1']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img1']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img1']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img1']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "400";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
            $_SESSION[img1]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}
	
		if(!isset($show))
			$show = 'result';
	}



        srand();
        $overlay = $srv.'s'.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img2'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img2']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img2']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img2']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img2']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "100";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
$_SESSION[img2]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}
	
		if(!isset($show))
			$show = 'result';
	}



        srand();
        $overlay = $srv.''.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img3'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img3']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img3']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img3']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img3']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "400";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
$_SESSION[img3]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}
	
		if(!isset($show))
			$show = 'result';
	}




        srand();
        $overlay = $srv.'s'.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img4'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img4']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img4']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img4']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img4']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "100";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
$_SESSION[img4]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}
	
		if(!isset($show))
			$show = 'result';
	}



        srand();
        $overlay = $srv.''.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img5'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img5']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img5']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img5']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img5']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "400";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
$_SESSION[img5]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}
	
		if(!isset($show))
			$show = 'result';
	}



        srand();
        $overlay = $srv.'s'.$overimage.'.png';
	$srid = substr(md5(rand(0,1000000)),0,10); 
	$base_fs = $cache_fs . $srid;
	$base_uri = $cache_uri . $srid;
if($_REQUEST['view'] == 'source') {
		$source = str_replace(' ', ' ', htmlspecialchars(implode('', file('index.php'))));
		$show = 'source';
	}
	else if(!$overlay = imagecreatefrompng($overlay)) {
		$error = 'error opening overlay image';
		$show = 'error';
	}
	else if(isset($_FILES['img6'])) {
		/*
		 * open original (uploaded) image, based on type.
		 */
		switch($_FILES['img6']['type']) {
			case 'image/jpeg':
			case 'image/pjpeg':
				$orig = imagecreatefromjpeg($_FILES['img6']['tmp_name']);
				break;
			case 'image/png':
				$orig = imagecreatefrompng($_FILES['img6']['tmp_name']);
				break;
			case 'image/gif':
				$orig = imagecreatefromgif($_FILES['img6']['tmp_name']);
				break;
			default:
				$error = 'Unknown File Format or MIME Type';
				$show = 'error';
		}

		if($orig) {
			$orig_x = imagesx($orig);
			$orig_y = imagesy($orig);
			$overlay_x = imagesx($overlay);
			$overlay_y = imagesy($overlay);
			$image_x = "100";
			$image_y = round(($orig_y * $image_x) / $orig_x);
			$thumb_y = round(($orig_y * $thumb_x) / $orig_x);

				$offset_x = $image_x - $overlay_x;
					$offset_y = $image_y - $overlay_y;
			$image = imagecreatetruecolor($image_x, $image_y);
			imagecopyresampled($image, $orig, 0, 0, 0, 0, $image_x, $image_y, $orig_x, $orig_y);
if($overimage!=""){
			imagecolortransparent($overlay, imagecolorallocate($overlay, $trans_r, $trans_g, $trans_b));
			imagecolortransparent($overlay, imagecolorallocate($overlay, 0, 0, 0));
		        imagecopyresized($image, $overlay, 0, 0, 0, 0, $image_x, $image_y, $image_x, $image_y);
}
			imagepng($image, $base_fs . '-image.png');
			$image_uri = $base_uri . '-image.png';
$_SESSION[img6]=$srid.'-image.png';
		}
		else {
			if(!$error)
				$error = 'Error reading uploaded image';
			$show = 'error';
		}

	
		if(!isset($show))
			$show = 'result';
	}













 if($err_flag!=1)
  {
    $bid_starting_date=date("Y-m-d");
    $pic1=$_SESSION[img1];
   $pic2=$_SESSION[img2];
   $pic3=$_SESSION[img3];
    $pic4=$_SESSION[img4];
   $pic5=$_SESSION[img5];
   $pic6=$_SESSION[img6];
    $pic71=$_SESSION[img7];
   $pic8=$_SESSION[img8];
    if(strlen($pic1)==0)
  {
  $pic1=$image1;
  }
   if(empty($pic2))
  {
  $pic2=$image2;
  }
   if(empty($pic3))
  {
  $pic3=$image3;
  }
   if(empty($pic4))
  {
  $pic4=$image4;
  }
   if(empty($pic5))
  {
  $pic5=$image5;
  }
   if(empty($pic6))
  {
  $pic6=$image6;
  }
   if(empty($pic7))
  {
  $pic7=$image7;
  }
   if(empty($pic8))
  {
  $pic8=$image8;
  }

$edit2="select * from auction_details where productid=$productid";
$modifyres2=mysql_query($edit2);
$modifyrow2=mysql_fetch_array($modifyres2);

  $date2 = $modifyrow2[expire_date];
  $first = explode(" ", $date2); 
  $elts1 = explode("-", $first[0]);
  $elts2 = explode(":", $first[1]);
  $inter=$interval; 
  $dcour=mktime($elts2[0]+$hours,$elts2[1]+$mins,$elts2[2]+$secs,$elts1[1],$elts1[2]+$days,$elts1[0]); 
  $expire_date = date("Y-m-j G:i:s",$dcour);


  if($bid_permission!="no")
  {
  $up="update auction_details set producttitle='$producttitle',quantity='$qty',detailed_descrip='$itemdes', min_bid_amount='$min_amt',reserve_price='$rev_price',bidincrement='$bid_inc',quick_buy_price='$quick',picture1='$pic1',picture2='$pic2',picture3='$pic3',picture4='$pic4',picture5='$pic5',picture6='$pic6',picture7='$pic7',picture8='$pic8',size_of_quantity='$size_of_qty',expire_date='$expire_date',return_pol='$return_pol',or_price='$or_price' where productid=$productid";
  }
  else
  {
$up="update auction_details set producttitle='$producttitle',quantity='$qty',detailed_descrip='$itemdes', min_bid_amount='$min_amt',reserve_price='$rev_price',quick_buy_price='$quick',picture1='$pic1',picture2='$pic2',picture3='$pic3',picture4='$pic4',picture5='$pic5',picture6='$pic6',picture7='$pic7',picture8='$pic8',size_of_quantity='$size_of_qty',expire_date='$expire_date',return_pol='$return_pol',or_price='$or_price' where productid=$productid";
  }
  
 $res=mysql_query($up); 
 
   if($tablename)
  {
  $tab_sql="select * from $tablename";
  $tab_res=mysql_query($tab_sql);
  $i =2;
  $up_cat="update $tablename set ";
  $in_sql="insert into $tablename(productid,";
  $in_sql_value="values(' $productid ', ";
  while ($i < mysql_num_fields($tab_res))
 {
      $tab_col = mysql_fetch_field($tab_res, $i);
   	  $dummy=$tab_col->name;
      $table_sql="select * from $tablename where productid=$productid";
	  $table_res=mysql_query($table_sql);
      $var_value=$table_row[$tab_col->name];
	  if(mysql_num_rows($table_res)==0)
	  {
	    $in_sql.="$tab_col->name ,";
     	$in_sql_value.="'$_SESSION[$dummy]',";
	  }
	  else
	  {	   
	  $up_cat.=$tab_col->name.'='."'".$_SESSION[$tab_col->name] ."'".", ";
	  }
	  $i++;
} // while
if(mysql_num_rows($table_res) > 0)
{
$up_cat=rtrim($up_cat,", ");
$up_cat.=" where productid=".$productid;
$up_res=mysql_query($up_cat);
}
else
{
$in_sql=rtrim($in_sql,", "); 
$in_sql_value=rtrim($in_sql_value,", "); 
$in_sql.=")".$in_sql_value.")";
 $in_res=mysql_query($in_sql);
}
}
 
  if($modifyrow[selling_method]!="ads")
  {
  echo '<meta http-equiv="refresh" content="0;url=modifyauction_step2.php?productid='.$productid.'&mode='. $mode .'">';
  echo "$lang_675 <a href=modifyauction_step2.php?productid=$productid&mode=<?= $mode ?> >Click here</a>";  }
  else
  {
  echo '<meta http-equiv="refresh" content="0;url=myauction.php?productid='.$productid.'&mode='. $mode .'">';
  echo "$lang_675 <a href=myauction.php?productid=$productid&mode=<?= $mode ?> > Click here </a>";  
  }
  exit();
    }
} 
?>
<? require 'include/header.php'; ?>
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">	
  <link href="cssfiles/css.css" rel="stylesheet" type="text/css">
   <tr height=25>
<td class="ct" colspan=2><b>
  <? 
    echo "  Edit Your Item"; 
  ?> 
</b> </td></tr>
<tr><td>
<? if($err_flag==1)
{ 
?>
<table width="600" align="center">
<tr><td>
<img src="../images/xclabid.gif"></td>
<td><font size=2 color="red">The following must be corrected before continuing:</font></td></tr>
<? if(!empty($err_title))
 {
 ?>
<tr><td>&nbsp;</td>
<td><a href="modifyauction.php#txttitle">Item Title</a> - <?= $err_title; ?></td></tr>
<? 
}
?>
<? if(!empty($err_des))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#areades">Item Description</a> - <?= $err_des; ?></td></tr>
<? 
}
?>
<? if(!empty($err_min_amt))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#txt_min_amt">Minimum Bid Amount</a> - <?= $err_min_amt; ?></td></tr>
<? 
}
?>
<? if(!empty($err_fix_price))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#txt_quick">Quick Buy Price</a> - <?= $err_fix_price; ?></td></tr>
<? 
}
?>
<? if(!empty($err_rev_price))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#txt_rev_price">Reserve Price</a> - <?= $err_rev_price; ?></td></tr>
<? 
}
?>
<? if(!empty($err_qty))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#txt_qty">Quantity</a> - <?= $err_qty; ?></td></tr>
<? 
}
?>
<? if(!empty($err_dur))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#cbodur">Duration</a> - <?= $err_dur; ?></td></tr>
<? 
}
?>

<? if(!empty($err_size_qty))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#size_of_qty">Size of Quantity</a> - <?= $err_size_qty; ?></td></tr>
<? 
}
?>

<? if(!empty($err_bid_inc))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#txt_bid_inc">Bid Increment</a> - <?= $err_bid_inc; ?></td></tr>
<? 
}
?>
<? if(!empty($err_cur))
 {
 ?>
<tr><td>&nbsp;</td>
<td><a href="modifyauction.php#cbocurrency">Currency</a> - <?= $err_cur; ?></td></tr>
<? 
}
?>
<? if(!empty($err_img1))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#img1">Image1</a> - <?= $err_img1; ?></td></tr>
<? 
}
?>
<? if(!empty($err_img2))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#img2">Image2</a> - <?= $err_img2; ?></td></tr>
<? 
}
?>
<? if(!empty($err_img3))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#img3">Image3</a> - <?= $err_img3; ?></td></tr>
<? 
}
?>
<? if(!empty($err_img4))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#img4">Image4</a> - <?= $err_img4; ?></td></tr>
<? 
}
?>
<? if(!empty($err_img5))
 {
 ?>
<tr><td>&nbsp;</td><td><a href="modifyauction.php#img5">Image5</a> - <?= $err_img5; ?></td></tr>
<? 
}
?>


<? if($tablename)
		{
		$tab_sql="select * from $tablename";
        $tab_res=mysql_query($tab_sql);
        $i =2; 
 while ($i < mysql_num_fields($tab_res))
{
    $tab_col = mysql_fetch_field($tab_res, $i);
	$dummy=$tab_col->name;
if(empty($_SESSION[$tab_col->name]))
        {
     ?>
	  <tr><td>&nbsp;</td><td><a href="modifyauction.php#<?= $tab_col->name ?>"><?= $tab_col->name ?></a>-Please Enter this Information </td></tr>
	 <?
	    }
		else
		{
	    $var_type=$tab_col->type;
		if($var_type=="int" or $var_type=="tinyint")
		{
		if(!is_numeric($_SESSION[$tab_col->name]))
	    {
	    ?>
		 <tr><td>&nbsp;</td><td><a href="modifyauction.php#<?= $tab_col->name ?>"><?= $tab_col->name ?></a>-Please Enter this Information </td></tr>
		<?
		}
		}
		}
	$i++;
}
}  ?>
<tr><td colspan=2>
<hr size="1" noshade class="hr_color"></td></tr>
</table>

<?
}
 ?>
 
<form name="form1" action=<? echo $_SERVER['PHP_SELF'] ?> method=post enctype="multipart/form-data">
<table width="600" cellpadding="5" cellspacing="2" >
<tr height="20" valign="middle">
<td style="padding-top:4px;">&nbsp;&nbsp;&nbsp;&nbsp;Listed in Category :   
<?
if($cat_sql_row[category_head_id])
{
itechitems_11($cat_sql_row[category_head_id],$cat_string);
}
?>
<?= $cat_row[category_name] ?>&nbsp; <a href="#" id="dislink" onClick="ChildWin=window.open('modifycategory.php?productid=<?= $modifyrow[productid];?>&i=1','pop_up','toolbar=no, top=0,location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=600, height=800')">Edit Category</a> 
</td></tr>
 <?
  if($_SESSION[categoryid])
 {
  $sub_sql="select * from site_categories where category_head_id=$_SESSION[categoryid]";
  $sub_res=mysql_query($sub_sql);
  $sub_tot=mysql_num_rows($sub_res);
 }
if($sub_tot!=0)
{ 
?>
 <? 
 }
 else
 { ?>
  <?
  if($file_path)
 require "$file_path";
   ?>
<? 
 }
 ?>
<tr><td>
<? if(!empty($err_title))
 {?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_title ?></font>
 <br>
 <b><font size=2 color=red>Item title</font></b>
 <?
  }
 ?> </td></tr><TR><TD>
   <b><font size=2 >Item title</font></b>
 </td><td width=250><input type="text" class="bluetext"name="txttitle" class="txtbig" value="<?= $producttitle; ?>">
 </td></tr>
 <tr><td>
<? if(!empty($err_des))
 {
 ?>
 <img src="../images/xclabids.gif">&nbsp;
 <font size=2 color=red><?= $err_des; ?></font>
 <br>
 <b><font size=2 color=red>Item Description</font></b>
 <?
  }
   ?> </td></tr><TR><TD colspan="2">
   <b><font size=2 >Item Description</font></b>
 </td></TR><TR><td width="100%" colspan="2">
 <?php
include_once("../HTMLEditor/fckeditor.php") ;
?>
<?php
$oFCKeditor = new FCKeditor('htmlcontent') ;
$oFCKeditor->BasePath = '../HTMLEditor/' ;
$oFCKeditor->Value = $itemdes;
$oFCKeditor->Create() ;
?>

 <br>
<font size=2 class="hint_font">Describe your items features, benefits, 
and condition. Be sure to include in your description: Condition (new, used, etc.)</font></td>
</tr>
<tr>
                <td><font size=2 ><b>Item Hit Counter </b></font></td>
              <td>
<? 
if($item_counter_style==2)
{
 ?>
<input type="radio" name="item_counter_style" value=1 > 
 <b><font size=+1 color="#009900">
		    12345
			</font>
			</b> 
<input type="radio" name="item_counter_style" value=2 checked> 
<I><font size=+1 color="#003399">
		    12345
			</font>
			</I>  
<?
}
else
{
?>		 
<input type="radio" name="item_counter_style" value=1 checked> 
 <b><font size=+1 color="#009900">
		    12345
			</font>
			</b> 
<input type="radio" name="item_counter_style" value=2 > 
<I><font size=+1 color="#003399">
		    12345
			</font>
			</I>  
<?
}
?></td></tr>
  <tr><td>
 <? if(!empty($err_qty))
 {
 ?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_qty?></font>
 <br>
 <b><font size=2 color=red>Quantity</font></b>
 <?
  }
 ?> </td>
 </tr><TR><TD>
   <b><font size=2 >Add Time</font></b></td>
<td width=250>
<select name="cbodays">
<option value="0" selected>Days</option>
<?
for($days1=1;$days1<=30;$days1++)
{
?>
<option value="<?= $days1; ?>" <? if($days1==$days){ echo "selected";}?>><?= $days1; ?> Day(s)</option>
<?
} 
?>
</select>
<select name="cbohours">
<option value="0" selected>Hours</option>
<?
for($hours1=1;$hours1<=24;$hours1++)
{
?>
<option value="<?= $hours1; ?>"<? if($hours1==$hours){ echo "selected";}?>><?= $hours1; ?> Hour(s)</option>
<?
} 
?>
</select>
<select name="cbomins">
<option value="0" selected>Minutes</option>
<?
for($mins1=1;$mins1<=60;$mins1++)
{
?>
<option value="<?= $mins1; ?>"<? if($mins1==$mins){ echo "selected";}?>><?= $mins1; ?> Minute(s)</option>
<?
} 
?>
</select>
<select name="cbosecs">
<option value="0" selected>Seconds</option>
<?
for($secs1=1;$secs1<=60;$secs1++)
{
?>
<option value="<?= $secs1; ?>"<? if($secs1==$secs){ echo "selected";}?>><?= $secs1; ?> Second(s)</option>
<?
} 
?>
</select>
</tr>
<?
 if($modifyrow[selling_method]!="ads" and $modifyrow[selling_method]!="fix" )
{
?>
<tr><td width="250">
 <? if(!empty($err_min_amt))
 {
 ?>
 <img src="../images/xclabids.gif">
 &nbsp;<font size=2 color=red><?= $err_min_amt?></font>
 <br>
 <b><font size=2 color=red>Minimum Bid Amount</font></b>
 <?
 }
 ?></TD></TR><TR><TD>
 <b><font size=2 >Minimum Bid Amount</font></b>
 </td><td><input type="text" class="bluetext"name="txt_min_amt" class="txtsmall" value=<?= $min_amt; ?>></td></tr>

<tr><td>
<? if(!empty($err_bid_inc))
 {?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_bid_inc?></font>
 <br>
 <b><font size=2 color=red>Bid Increment</font></b>
 <?
  }
 ?> </td></tr><TR><TD>
   <b><font size=2>Bid Increment</font></b>
</td><td width=250><input type="text" class="bluetext"name="txt_bid_inc" class="txtsmall" value=<?= $bid_inc; ?>></td></tr>
 <?
 } 
 ?> 
<TR><TD>
   <b><font size=2>Reserve Price</font></b>
 </td>
 <td>

<input type="text" class="bluetext"name="txt_rev_price" class="txtsmall" value=<?= $rev_price; ?>></td></tr>
<? if($selling_method==5){ ?>
<tr><td>
<? if(!empty($err_fix_price) )
 {?>
 <img src="../images/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_fix_price; ?></font>
 <br>
 <b><font size=2 color=red>Quick Buy Price</font></b>
 <?
  }
 ?> </td></tr><TR><TD>
   <b><font size=2>Quick Buy Price</font></b>
 </td>
<td>
<input type="text" class="bluetext"name="txt_quick" class="txtsmall" value=<?= $quick; ?>></td></tr>
<? } ?>
<TR><TD>
   <b><font size=2>Original Price</font></b>
 </td>
 <td>

<input type="text" class="bluetext"name="txt_or" class="txtsmall" value=<?= $or_price; ?>></td></tr>

<TR><TD valign="top">
   <b><font size=2>Return Policy</font></b>
 </td>
 <td>

<textarea name="txt_return" class="txtsmall" rows="6" cols="31"><?= $return_pol; ?></textarea></td></tr>


 
<tr class="tr_border" width=758><td colspan="2"><font size="2"><b>Add Images</b></font></td></tr>
<tr><td colspan="2">
<? if(!empty($err_img3))
 {?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img3; ?></font>
 <br>
 <b><font size=2 color=red>Image</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Image</font></b>
   <? 
   }
   ?>
    <input type="file" name="img1" value="<?= $img1; ?>">
	<? if(!empty($_SESSION[img3]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img1] ?>" width=20 height=20>
	<?
	}
	?></td></tr>
	<tr><td colspan="2">
  <? if(!empty($err_img4))
  {
  ?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img4; ?></font>
 <br>
 <b><font size=2 color=red>Thumbnail</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Thumbnail</font></b>
   <? }
   ?>
    <input type="file" name="img2" value=<?= $img2; ?>>
	<? if(!empty($_SESSION[img4]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img2] ?>" width=20 height=20>
	<?
	}
	?></td></tr>

<tr><td colspan="2">
<? if(!empty($err_img5))
 {?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img5; ?></font>
 <br>
 <b><font size=2 color=red>Image</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Image</font></b>
   <? 
   }
   ?>
    <input type="file" name="img3" value="<?= $img3; ?>">
	<? if(!empty($_SESSION[img5]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img3] ?>" width=20 height=20>
	<?
	}
	?></td></tr>
	<tr><td colspan="2">
  <? if(!empty($err_img6))
  {
  ?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img6; ?></font>
 <br>
 <b><font size=2 color=red>Thumbnail</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Thumbnail</font></b>
   <? }
   ?>
    <input type="file" name="img4" value=<?= $img4; ?>>
	<? if(!empty($_SESSION[img6]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img4] ?>" width=20 height=20>
	<?
	}
	?></td></tr>
<tr><td colspan="2">
<? if(!empty($err_img7))
 {?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img7; ?></font>
 <br>
 <b><font size=2 color=red>Image</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Image</font></b>
   <? 
   }
   ?>
    <input type="file" name="img5" value="<?= $img5; ?>">
	<? if(!empty($_SESSION[img7]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img5] ?>" width=20 height=20>
	<?
	}
	?></td></tr>
	<tr><td colspan="2">
  <? if(!empty($err_img8))
  {
  ?>
 <img src="../uploads/xclabids.gif">&nbsp;<font size=2 color=red><?= $err_img8; ?></font>
 <br>
 <b><font size=2 color=red>Thumbnail</font></b>
 <?
  }
  else
  {
 ?>
   <b><font size=2 >Thumbnail</font></b>
   <? }
   ?>
    <input type="file" name="img6" value=<?= $img6; ?>>
	<? if(!empty($_SESSION[img8]))
	{
	?>
	<img src="../uploads/<?= $_SESSION[img6] ?>" width=20 height=20>
	<?
	}
	?></td></tr>



	<?  
        $mem_sql="select * from member_details where user_id=1";
        $mem_res=mysql_query($mem_sql);  
	    $mem_row=mysql_fetch_array($mem_res);
	    $member_account=$mem_row[member_account];
	if($member_account==1 or $member_account==2)
	{
	$sql="select * from site_fees";
	$exe=mysql_query($sql);
	$ret=mysql_fetch_array($exe);
	$gret=$ret['gallery_price'];
    $hret=$ret['homepage_price'];
	$sret=$ret['subtitle_price'];
	$bret=$ret['bold_price'];
	$highret=$ret['highlight_price'];
	$privateret=$ret['private_fee'];

	}
	?>

<input type="hidden" name=postformat value="<?=$postformat?>">
	<input type="hidden" name=flag value="1">
	<input type="hidden" name="cat_id" value=<?= $cat_id; ?>>
	<input type="hidden" name=mode value="<?= $mode; ?>">
		<input type="hidden" name=postformat value="<?= $postformat; ?>">
	<input type="hidden" name=productid value=<?= $productid; ?>>
    <tr><td colspan="2" align="center">
		<input type="submit" class="button"   name=detsub value=Continue>
</td></tr>
</table>
</form>
</td></tr>
<tr align="center">
<td><? require 'include/footer.php'?></td></tr>
</table>

<script language="javascript">
function sel_method()
{
document.form1.radselling.value="auction";
document.form1.flag.value=2;
document.form1.submit();
}
function getChildWinData()
{
ChildWin.close();
window.location.reload();
}
</script>
  </body>
</html>
