<?
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("cache-control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
$pid=$_GET[id];
 function getDateDifference($dateFrom, $dateTo, $unit = 'd') // User defined function 
     {
     $difference = null;
     $dateFromElements = split(' ', $dateFrom);
     $dateToElements = split(' ', $dateTo);
     $dateFromDateElements = split('-', $dateFromElements[0]);
     $dateFromTimeElements = split(':', $dateFromElements[1]);
     $dateToDateElements = split('-', $dateToElements[0]);
     $dateToTimeElements = split(':', $dateToElements[1]); 
     // Get unix timestamp for both dates
     $date1 = mktime($dateFromTimeElements[0], $dateFromTimeElements[1], $dateFromTimeElements[2], $dateFromDateElements[1], $dateFromDateElements[0], $dateFromDateElements[2]);
     $date2 = mktime($dateToTimeElements[0], $dateToTimeElements[1], $dateToTimeElements[2], $dateToDateElements[1], $dateToDateElements[0], $dateToDateElements[2]); 
     if( $date1 > $date2 )
     {
         return null;
     }

     $diff = $date2 - $date1;

     $days = 0;
     $hours = 0;
     $minutes = 0;
     $seconds = 0;

     if ($diff % 86400 <= 0)  // there are 86,400 seconds in a day
     {
         $days = $diff / 86400;
     }

     if($diff % 86400 > 0)
     {
         $rest = ($diff % 86400);
         $days = ($diff - $rest) / 86400;

         if( $rest % 3600 > 0 )
         {
             $rest1 = ($rest % 3600);
             $hours = ($rest - $rest1) / 3600;

             if( $rest1 % 60 > 0 )
             {
                 $rest2 = ($rest1 % 60);
                 $minutes = ($rest1 - $rest2) / 60;
                 $seconds = $rest2;
             }
             else 
             {
                 $minutes = $rest1 / 60;
             }
         }
         else
         {
             $hours = $rest / 3600;
         }
     }

     switch($unit)
     {
         case 'd':
         case 'D':

             $partialDays = 0;

             $partialDays += ($seconds / 86400);
             $partialDays += ($minutes / 1440);
             $partialDays += ($hours / 24);

             $difference = $days + $partialDays;

             break;

         case 'h':
         case 'H':

             $partialHours = 0;

             $partialHours += ($seconds / 3600);
             $partialHours += ($minutes / 60);

             $difference = $hours + ($days * 24) + $partialHours;

             break;

         case 'm':
         case 'M':

             $partialMinutes = 0;

             $partialMinutes += ($seconds / 60);

             $difference = $minutes + ($days * 1440) + ($hours * 60) + $partialMinutes;

             break;

         case 's':
         case 'S':

             $difference = $seconds + ($days * 86400) + ($hours * 3600) + ($minutes * 60);

             break; 

         case 'a':
         case 'A':

             $difference = array (
                 "days" => $days,
                 "hours" => $hours,
                 "minutes" => $minutes,
                 "seconds" => $seconds 
             );

             break;
     }
     return $difference;
  }
 
  function AddDays($date,$interval) 
{ 
  if (!isset($date)) 
  $date = date("Y-m-d"); 
  $elts = explode("-", $date); 
  $inter=$interval*24*3600; 
  $dcour=mktime(1,0,0,$elts[1],$elts[2],$elts[0]); 
  $dres=$dcour+$inter; 
  $date1=date("Y-m-d",$dres);
  $sec=date("G:i:s");
  $ret_date="$date1"." "."$sec";
  return $ret_date; 
}



function word_count($string)
 {
													
					$string_array_1 =explode(" ",$string);
					if(!empty($string_array_1[5]))
					$break="$string_array_1[0]"." "."$string_array_1[1]"." "."$string_array_1[2]"." "."$string_array_1[3]"." "."$string_array_1[4]"."...";
					else if(!empty($string_array_1[4]))
					$break="$string_array_1[0]"." "."$string_array_1[1]"." "."$string_array_1[2]"." "."$string_array_1[3].";
					else if(!empty($string_array_1[3]))
                    $break="$string_array_1[0]"." "."$string_array_1[1]"." "."$string_array_1[2]"." "."$string_array_1[3].";
					else if(!empty($string_array_1[2]))
                    $break="$string_array_1[0]"." "."$string_array_1[1]"." "."$string_array_1[2].";
					else if(!empty($string_array_1[1]))
					$break="$string_array_1[0]"." "."$string_array_1[1].";
					else
					$break="$string_array_1[0]."; 
					return $break;
}
	
	
			

  ?>




<?
require 'include/configurations.php'; // ITECHBIDS Configuration File
 	$feature_sql="select * from auction_details where productid=$pid";
	$feature_res=mysql_query($feature_sql);
$feature_row=mysql_fetch_array($feature_res);
 $expire_date = $feature_row['expire_date']; 
?>
<? 
        $date1 = strtotime(now);
		$date2=strtotime($expire_date);
       $date1 = date("d-m-Y H:i:s",$date1);
      $date2 = date("d-m-Y H:i:s",$date2); 

      $dateFrom=$date1;
      $dateTo = $date2;

      $diffd = getDateDifference($dateFrom, $dateTo, 'd'); //user defined  function 
      $diffh = getDateDifference($dateFrom, $dateTo, 'h');
      $diffm = getDateDifference($dateFrom, $dateTo, 'm');
      $diffa = getDateDifference($dateFrom, $dateTo, 'a');

      
         $string_difference = $diffa['hours'] . ':'. $diffa['minutes'] . ':' . $diffa['seconds'] . ''; 


$bid_sql2="select * from site_bids where productid=".$pid." order by bidding_amount desc";
$bid_res2=mysql_query($bid_sql2);
$bid_row2=mysql_fetch_array($bid_res2);

$highest_bidder_sql="select * from member_details where user_id=".$bid_row2['user_id'];
   $highest_bidder_res=mysql_query($highest_bidder_sql);
   $highest_bidder_res=mysql_fetch_array($highest_bidder_res);
  $user_bid_name=$highest_bidder_res[user_name];

if($user_bid_name=="")
{
$user_bid_name = "None";
}
?>
<?
 echo "$user_bid_name";
?>