<?php
ob_start();session_start();
if($_SESSION['lang']=='')
{
	$_SESSION['lang'] = "en";
}
include 'languages/lang.'.$_SESSION['lang'].'.php';
include 'languages/lang_common_'.$_SESSION['lang'].'.php';
include("include/db.inc.php");
include("include/bit_functions.inc.php");
include("include/functions.php");
	include("include/banner_inc.php");

$db1=new db;
$db1->open();
mysql_query("SET NAMES 'utf8'");
$currency_symbol_new=symbol_currency();
check_login();

$uid = trim($_SESSION['uid']);

if($uid<>"")
{
    $user_sql = "SELECT first_name , last_name , email FROM user WHERE id = '$uid'";
    $user_rel = mysql_query($user_sql) or die(mysql_error());
    if(mysql_num_rows($user_rel)){
       $user_data = mysql_fetch_row($user_rel);

       $user_fname = $user_data[0];
       $user_lname = $user_data[1];
       $user_email = $user_data[2];
    }
}

 if(isset($_POST['submit_pay']))
 {
        $package_name = "Product Payment";
	    $total = $_POST['pay_value'];
		if(is_array($_POST['productIdArr']))
		{
			 foreach($_POST['productIdArr'] as $key=>$payid) {
				$oid.=$payid."_";
			 }
			$inid = substr($oid,0,-1);
		}

        $expdate=$_POST['ccexpdatemonth']."-".$_POST['ccexpdateyear'];

		echo "Payment in progress.....<form name='paymentfrm' action='authorize_product.php' method='post'>
		<input type='hidden' name='x_amount' value='".$total."'>
		<input type='hidden' name='x_order_id' value='".$inid."'>
		<input type='hidden' name='x_company' value=''>
		<input type='hidden' name='x_invoice_num' value='".$inid."'>
		<input type='hidden' name='x_description' value='".$package_name."'>
		<input type='hidden' name='x_email' value='".$user_email."'>
		<input type='hidden' name='x_card_num' value='".$_POST['ccnum']."'>
		<input type='hidden' name='x_card_code' value='".$_POST['cc_cvc']."'>
		<input type='hidden' name='x_expiry_date' value='".$expdate."'>
		<input type='hidden' name='x_cust_id' value='".$uid."'>
		<input type='hidden' name='x_name' value='".$_POST['ccname']."'>
		<input type='hidden' name='x_first_name' value='".$user_fname."'>
		<input type='hidden' name='x_last_name' value='".$user_lname."'>
		<input type='hidden' name='x_address' value='".$_POST['ccstreet']." ".$_POST['cccity']."'>
		<input type='hidden' name='x_city' value='".$_POST['cccity']."'>
		<input type='hidden' name='x_state' value='".$_POST['ccstate']."'>
		<input type='hidden' name='x_zip' value='".$_POST['cczip']."'>
		<input type='hidden' name='x_phone' value='".$_POST['ccphone']."'>
		<input type='hidden' name='x_country' value='".$_POST['cccountry']."'>
		<input type='hidden' name='x_ship_to_first_name' value=''>
		<input type='hidden' name='x_ship_to_last_name' value=''>
		<input type='hidden' name='x_ship_to_address' value=''>
		<input type='hidden' name='x_ship_to_city' value=''>
		<input type='hidden' name='x_ship_to_state' value=''>
		<input type='hidden' name='x_ship_to_zip' value=''>
		<input type='hidden' name='x_ship_to_country' value=''>
		<input type='hidden' name='x_ord_ref' value='".$inid."'></form>";

		echo "<script>document.paymentfrm.submit();</script>";
 }

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<?=_BASEURL_?>/" />
<meta content="<?=_TITLE1_?> offers bargain auctions of new brand products. Save up to 70% for every product almost. Bid and Win high quality products.<?=_TITLE1_?> offers amazing bargains." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Info-Tech Ltd. | We simplify web 2.0"/>
<title><?=_TITLE_?>Finalize a BidBox</title>
<link href="<?=_BASEURLCSSNEW_?>/index.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/index_sec.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/personal_acc.css" rel="stylesheet" type="text/css" />
<link href="<?=_BASEURLCSSNEW_?>/user_add.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURLCSSNEW_?>/ie6.css?0:102290); /* ]]> */</style><![endif]-->
<!--[if gte IE 7]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(<?=_BASEURLCSSNEW_?>/ie7.css?0:99961); /* ]]> */</style><![endif]-->
<script type="text/javascript">
function validpayfrm()
{
	var msg="";
	var ctr=0;
        if(document.payfrm.ccnum.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Card number is left blank.\r\n";
		}
        if(isNaN(document.payfrm.ccnum.value))
		{
            ctr+=1;
    		msg=msg+ctr+"). Please fill numbers for Card number.\r\n";
		}
        if(document.payfrm.ccnum.value.length<12 || document.payfrm.ccnum.value.length>20)
		{
            ctr+=1;
    		msg=msg+ctr+"). Check Card number.\r\n";
		}
		if(document.payfrm.ccexpdatemonth.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Select Card Expiry month.\r\n";
		}
        if(document.payfrm.ccexpdateyear.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Select Card Expiry year.\r\n";
		}
		if(document.payfrm.cc_cvc.value=="")
		{
			ctr+=1;
			msg=msg+ctr+"). CVC number is left blank.\r\n";
		}
		if(isNaN(document.payfrm.cc_cvc.value))
		{
			ctr+=1;
			msg=msg+ctr+"). Please fill numbers for CVC number.\r\n";
		}
		if(document.payfrm.cc_cvc.value.length<3 || document.payfrm.cc_cvc.value.length>4)
		{
			ctr+=1;
			msg=msg+ctr+"). Check CVC number.\r\n";
		}

        if(document.payfrm.ccname.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Name is left blank.\r\n";
		}
        if(document.payfrm.ccphone.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Phone No is left blank.\r\n";
		}
		 if(isNaN(document.payfrm.ccphone.value))
		{
            ctr+=1;
    		msg=msg+ctr+"). Enter numbers for phone number.\r\n";

		}
        if(document.payfrm.ccstreet.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Street is left blank.\r\n";

		}
         if(document.payfrm.cccity.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). City is left blank.\r\n";

		}
        if(document.payfrm.ccstate.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). State is left blank.\r\n";
		}
		if(document.payfrm.cczip.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Zip code is left blank.\r\n";
        }
		if(isNaN(document.payfrm.cczip.value))
		{
            ctr+=1;
    		msg=msg+ctr+"). Enter numbers for Zip code.\r\n";
        }
        if(document.payfrm.cccountry.value=="")
		{
            ctr+=1;
    		msg=msg+ctr+"). Country is left blank.\r\n";
        }

        if(ctr>0)
	    {
			alert(msg);
			return false;
	    }
	    else
	    {
	    	return true;
	    }

}
</script>
</head>

<body>
<div id="container">
<? include("header.php");?>
  <div id="accountleft_bar">
    <? include("view.php");?>
  </div>
<div id="accountright_bar">
    <div id="use_add">
      <div class="buygreen1" >
        <div class="buygreen2"><div>Credit Card </div></div>
        <div class="buygreen3"></div>
      </div>
	  <div class="allm100px">
        <div class="allm5px">
      <? if($_GET['payment']=="success"){?>
       <table align="center" width="70%" cellpadding="0" cellspacing="0" border="0">
	   <tr>
		 <td><p><b>Your order has been placed successfully.</b></p></td>
	   </tr>
	   </table>
      <? } else if($_GET['payment']=="declined"){?>
	   <table align="center" width="70%" cellpadding="0" cellspacing="0" border="0">
	   <tr>
		 <td><p><b>Your order is failed. Reason for failure is: <?=$_GET['respreason'];?></b></p></td>
	   </tr>
	   </table>

      <? } else if($_GET['payment']=="cancel"){?>

	   <table align="center" width="70%" cellpadding="0" cellspacing="0" border="0">
	   <tr>
		 <td><p><b>Your order could not be placed because of incorrect payment details.Please check your credit card data and try again.</b></p></td>
	   </tr>
	   </table>

      <? } else { ?>
	  <div id="main_blue_screen">
            <div class="problue">
              <div class="probluemid"><div>Enter your Card Details</div></div>
              <div class="probel"></div>
            </div>
        <form name="payfrm" method="post" action="" onSubmit="return validpayfrm();">
        <input type="hidden" name="pay_value" value="<?=$_POST['pay_value'];?>">
      <? foreach($_POST['productIdArr'] as $key=>$value){?>
      	 <input type="hidden" name="productIdArr[]" value="<?=$value;?>">
      <? } ?>
             
        <table align="center" width="100%" cellpadding="2" cellspacing="2" border="0">
           <tr>
               <td width="29%">Card Number :</td>
               <td width="47%"><input type="text" name="ccnum" size="16" class="inputtext" ></td>
               <td width="24%" rowspan="10" valign="middle" align="center">  &nbsp;
      </td>
           </tr>
           <tr>
           <td>Card Type :</td>
           <td><select name="cctype" >
                 <option value="VisaCard">Visa</option>
                 <option value="MasterCard">Mastercard</option>
                 <option value="AmExCard">American Express</option>
                 <option value="DiscoverCard">Discover</option>
               </select></td>
           </tr>

           <tr>
               <td>Expiration Date :</td>
               <td>
               <select name="ccexpdatemonth"  style="width:75px">
               <option value="">Month</option>
               <?
               for($i=1;$i<=12;$i++)
               {
               echo "<option value='$i'>".($i<10?"0$i":"$i")."</option>";
               }
               ?>
               </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <select name="ccexpdateyear" style="width:75px" >
                   <option value="">Year</option>
                    <?
                    for($i=date("Y");$i<=date("Y")+15;$i++)
                    {
                     echo "<option value='$i'>$i</option>";
                    }
                    ?>
                    </select>
                    </td>
               </tr>

                   <tr>
                        <td>CVC:</td>
                        <td><input type="text" name="cc_cvc" maxlength="4" class="inputtext" style="width:75px"></td>
                   </tr>

                   <tr>
                        <td>Name (as it appears on your CC):</td>
                        <td><input type="text" name="ccname"  class="inputtext"></td>
                    </tr>

                   <tr>
                        <td>Phone # for card :</td>
                        <td><input type="text" name="ccphone" class="inputtext"></td>
                        </tr>
                   <tr>
                        <td>Street (your statement address):</td>
                        <td><input type="text" name="ccstreet" class="inputtext"></td>
                        </tr>
                   <tr>
                        <td>City :</td>
                        <td><input type="text" name="cccity" class="inputtext"></td>
                        </tr>
                   <tr>
                        <td>State :</td>
                        <td><input type="text" name="ccstate" class="inputtext"></td>
                        </tr>
                   <tr>
                        <td>Zip/Postal code :</td>
                        <td><input type="text" name="cczip" class="inputtext"></td>
                        </tr>
                   <tr>
                        <td>Country :</td>
                        <td>
                        <select name="cccountry" >
                          <option value="">Select country</option>
              <?          $country=mysql_query("select * from country order by state ");
					      while($row_c=mysql_fetch_array($country)) {?>
						 	<option value="<?=$row_c['state'];?>" <? if($row_c['state']=="United States"){echo "selected";}?>><?=$row_c['state'];?></option>
			  <?    	  }  ?>
                        </select>
                        </td>
                        </tr>
                 <tr height="30px">
                          <td style="padding-left:300px;" colspan="3">
                          <input type="submit" name="submit_pay" value="Continue&nbsp;&raquo;" >                          </td>
                 </tr>
        </table>
                   
        </form>
		 <div class="tf1">
              <div class="tf2"></div>
              <div class="tf3"></div>
            </div>
          </div>
      <? } ?>
 </div>
      </div>
<div class="tft1">
        <div class="tft2"></div>
        <div class="tft3"></div>
      </div>
    </div>

 
       
<div  class="w99">
<h3 class="tac tm40px"><div class="tm40px tac"><br /><br /><br /><br /><br />Advertisment Sponsors</div></h3>

  <? 
  $page='innerpage';
  $query_num=mysql_query("select bid from zb_banners where `status`='1' and pagename='$page' order by rand() limit 0,4");
 while($brow=mysql_fetch_array($query_num))
  {
  ?>
<?=banner_home("innerpage","bottom",158,103,$brow['bid']);?>
<? }?>
</div>
</div>
  <div style="clear:both">
    <? include("footer.php");?>

