<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-04-2008                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("../config.inc.php");
//require_once ("includes/userlogincheck.inc.php");
require_once ("../includes/adminlogincheck.inc.php"); 
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/settings.class.php");
require_once ("../classes/userside.class.php");

$message	= "";
$script		= "";
$product	= isset($_REQUEST['product'])	?	trim($_REQUEST['product'])	:	"0";
$amount		= 0;
$_SESSION['sess_product']=$product;
$_SESSION['user_id']=$_GET['id']!=''?$_GET['id']:$_POST['hid_id'];

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objU			= new userside($objDB);
	$objS			= new settings($objDB);
	$objS->set_variables();
	//echo "<pre>";print_r($_SESSION);
	if (isset($_POST['PYN'])) {
             //echo "<pre>";print_r($_SESSION);exit;
		$objU->set_values($_POST);
                
		$objU->set_BCIDV($_SESSION['idverify']);
		
		//for payment process
		$_SESSION['sess_register_stype']=$_POST['chkMethod'];
		
		$message	= $objU->buy_product($_SESSION['user_id'], $product);
		if ($message == "") {
			header("Location:purchase_success.php?product=$product");
			exit();
		}
	} else {
		$objU->set_creditcard($_SESSION['user_id']);
		//fetch user details
		$user_array=$objU->select($_SESSION['user_id']);
		$objU->set_values($user_array);
	}
	$amount		= $objU->get_amount($product);
        $objU->set_creditcard($_SESSION['user_id']);
	$script		= $objU->get_script($message);
	$message	= $objU->remove_script($message);
}

//setting variable
$showmsgtype2=($_POST['showmsgtype2']!='')?$_POST['showmsgtype2']:$_GET['showmsgtype2'];

//seting messgae to show payment made for which
switch($showmsgtype2)
{
	case "idvery";
	$ShowMsg='Click below to complete the purchase of your id verification';
	break;
	
	case "bckchek";
	$ShowMsg='Click below to complete the purchase of your background check';
	break;
	
	case "profile_feature";
	$ShowMsg='Click below to complete the purchase of your featured membership';
	break;
	
	case "profile_renew";
	$ShowMsg='Click below to complete the purchase of your membership renewed';
	break;
}//end switch

//storing user dob
$_SESSION['sess_echeck_dob']=$objU->dDob;

if($showmsgtype2=='profile_renew')
{
	$_SESSION['show_credit_balance']=true;
	//checking credits avilable
	$sql_check2=mysql_query("select nCredits from ".TABLEPREFIX."user where nUser_Id='".$_SESSION['user_id']."' and nCredits!='0'") or die(mysql_error());

	if(mysql_num_rows($sql_check2)>0)
	{
		$objU->set_values($_POST);
		$objU->set_BCIDV($_SESSION['idverify']);
		
		//for payment process
		$_SESSION['sess_register_stype']=$_POST['chkMethod'];
		$_SESSION['sess_check_validation']='not';
	
		$message	= $objU->buy_product($_SESSION['user_id'], $product);
		if ($message == "") 
		{
			header("Location:purchase_success.php?product=$product");
			exit();
		}//end if
	}//end if
}//end if
include_once ("title.inc.php");
include_once ("tophtml.php");
$siteSettings=$objST->select();
//storing payment type
//echo"<pre>";print_r($siteSettings);
$checktypemode=($_POST['chkMethod']!='')?$_POST['chkMethod']:$siteSettings["paymentmethod"];

$txtPaypalEmail = $siteSettings["paypalemail"];
$txtPaypalSandbox = $siteSettings["enablepaypalsandbox"];
$chkPaypal = $siteSettings["enablepaypal"];
$ddlPaymentMethod = $siteSettings["paymentmethod"];
$chkGoogle = $siteSettings["enablegoogle"];
//worldpay details
$txtWorldInstId = $siteSettings["worldpayid"];
$txtWorldEmailId = $siteSettings["worldpayemail"];
$txtWorldTransMode = $siteSettings["worldpaytransmode"];
$txtWorldpaySandbox = $siteSettings["worldpaydemo"];

$ProductOrderId=rand('100','345');



//for authorize
if($checktypemode=='CC')
{
	$display='style="display:;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end if
else //for authorize
if($checktypemode=='UP')
{
	$display='style="display:;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end if
else if($checktypemode=='WP')
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:;"';
}//end if
else if($checktypemode=='ECHECK')
{
	$display='style="display:none;"';
	$display2='style="display:;"';
	$display3='style="display:none;"';
	$display4='style="display:none;"';
	$display5='style="display:none;"';
}//end else if
else if($checktypemode=='GOOGLE')
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display3='style="display:none;"';
	$display4='style="display:;"';
	$display5='style="display:none;"';
}//end else if
else
{
	$display='style="display:none;"';
	$display2='style="display:none;"';
	$display4='style="display:none;"';
	$display3='';
	$display5='style="display:none;"';
}//end else
?>
<script language="javascript" type="text/javascript">
function changeCSS(obj, type)
{
	
}
function clickConfirm(){
	var frm = document.frmPayment;
	var flag = false;
	if (frm.vFirstName.value == "") {
		alert("Please enter your firstname.");
		frm.vFirstName.focus();
		
		return false;
	}
	if (frm.vLastName.value == "") {
		alert("Please enter your lastname.");
		frm.vLastName.focus();
		
		return false;
	}
	//for authorize.net
if(document.getElementById('chkMethodC').checked==true)
{
	if (frm.nNumber.value == "") {
		alert("Please enter your cardnumber.");
		frm.nNumber.focus();
		
		return false;
	}
	if (frm.nCvv2.value == "") {
		alert("Please enter validation code of your card.");
		frm.nCvv2.focus();
		
		return false;
	}
	if (frm.vMM.value == "") {
		alert("Please enter month of expiry date of your card.");
		frm.vMM.focus();
		frm.vMM.className ='select-small';
		return false;
	}
	if (frm.vYYYY.value == "") {
		alert("Please enter year of expiry date of your card.");
		frm.vYYYY.focus();
		frm.vYYYY.className ='select-small';
		return false;
	}
}//end if
//for echeck

	if (frm.vAddress.value == "") {
		alert("Please enter your billing address.");
		frm.vAddress.focus();
		
		return false;
	}
	
	if (frm.vCity.value == "") {
		alert("Please enter your city address.");
		frm.vCity.focus();
		
		return false;
	}
	if (frm.vState.value == "") {
		alert("Please enter your state address.");
		frm.vState.focus();
		
		return false;
	}
	if (frm.vCountry.value == "") {
		alert("Please enter your country.");
		frm.vCountry.focus();
		
		return false;
	}
	if (frm.vPostCode.value == "") {
		alert("Please enter your postalcode.");
		frm.vPostCode.focus();
		
		return false;
	}
	if (frm.vPhone.value == "") {
		alert("Please enter your phone number.");
		frm.vPhone.focus();
		
		return false;
	}
	if (frm.vEmail.value == "") {
		alert("Please enter your email address.");
		frm.vEmail.focus();
		
		return false;
	}
	
	return true;
}
function checkValue(t) {
  if(isNaN(t.value) || t.value.substring(0,1) == " " || t.value.length == 0 || parseFloat(t.value) < 0 ) {
	 if(t.name == "nNumber") {
		 t.value = "";
	 } else{
		t.value = "000";
	 }
  }
}

function checkMethod(ttype)
{
	if(ttype=='c')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='';
			if(i>=4 && i<=10)
			{
				document.getElementById('showVal'+i).style.display='none';
			}//end if
			if(i>=23 && i<=25)
			{
				document.getElementById('showVal'+i).style.display='none';
			}//end if
		}//end for loop
	}// end if
	if(ttype=='e')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=4 && i<=8)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
			if(i>=11 && i<=23)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
	if(ttype=='p')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=9 && i<=10)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
	if(ttype=='g')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i==23)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
	if(ttype=='w')
	{
		for(var i=1;i<26;i++)
		{
			document.getElementById('showVal'+i).style.display='none';
			if(i>=24 && i<=25)
			{
				document.getElementById('showVal'+i).style.display='';
			}//end if
		}//end for loop
	}//end else
}//end function
</script>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td width="72%" valign="top"><div class="search-rslts"><table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                <tr>
                                    <td>
                                        <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                            <tr>
                                                <td width="100%" class="inenr-hd"><h2>Make Payment </h2></td>

                                            </tr>
                                        </table>
                                        <table width="100%"  border="0" cellspacing="0" cellpadding="10">
                                            <tr>
                                                <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td class="headings2"><?php echo $ShowMsg; //echo "<pre>";print_r($objU);//exit; ?></td>
                                                        </tr>
                                                    </table>
                                                    <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                        <tr>
                                                            <td><img src="images/spacer.gif" width="1" height="10"></td>
                                                        </tr>
                                                    </table>
                                                    <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                                                        <form name="frmPayment" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onSubmit="return clickConfirm();">
                                                            <?php
                                                            if (isset($message) && trim($message) != '') {
                                                                ?>
                                                                <tr align="center">
                                                                    <td colspan="3" class="maintext1 warning"><?php echo $message; ?></td>
                                                                </tr>
                                                            <?php }//end if?>
                                                            <tr>
                                                                <td width="35%" class="maintext1">Payment Method</td>
                                                                <td colspan="2" class="maintext1"><?php
                                                            if ($ddlPaymentMethod == "CC") {
                                                                ?>
                                                                        <input type="radio" name="chkMethod" value="CC" onClick="checkMethod('c');"<?php
                                                                    if ($_POST['chkMethod'] == 'CC') {
                                                                        echo 'checked';
                                                                    }if ($_POST['chkMethod'] == '') {
                                                                        echo 'checked';
                                                                    }
                                                                ?> id="chkMethodC">Credit Card
                                                                               <?php
                                                                           }//end if
                                                                           //end if
                                                                           //end if 
                                                                           ?></td>
                                                            </tr>
                                                            <tr>
                                                                <td class="maintext1">Amount to Pay</td>
                                                                <td colspan="2" class="maintext1">$ <?php echo $amount ?></td>
                                                            </tr>
                                                            <tr id="showVal12" <?php echo $display; ?>>
                                                                <td class="maintext1">First Name <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vFirstName" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vFirstName) ?>" size="30" maxlength="200"></td>
                                                            </tr>
                                                            <tr id="showVal13" <?php echo $display; ?>>
                                                                <td class="maintext1">Middle Name</td>
                                                                <td colspan="2" class="maintext1"><input name="vMiddleName" type="text" class="textbox txt-bx01" value="<?php echo htmlspecialchars($objU->vMiddleName) ?>" size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal14" <?php echo $display; ?>>
                                                                <td class="maintext1">Last Name <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vLastName" type="text" class="textbox txt-bx01"  onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vLastName) ?>" size="30" maxlength="200"></td>
                                                            </tr>
                                                            <tr id="showVal1" <?php echo $display; ?>>
                                                                <td class="maintext1">Card Number <span class="warning">*</span></td>
                                                                <td width="30%" class="maintext1"><input name="nNumber" type="text" class="textbox txt-bx01" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nNumber ?>" size="30" maxlength="16"></td>
                                                                <td width="35%" class="maintext1"> <img src="images/logo_ccAmex.gif" width="37" height="23" border="0" alt="Amex" title="Amex">
                                                                    <img src="../images/logo_ccBank.gif" width="37" height="23" border="0" alt="Bank" title="Bank">
                                                                    <img src="../images/logo_ccDiscover.gif" width="37" height="23" border="0" alt="Discover" title="Discover">
                                                                    <img src="../images/logo_ccMC.gif" width="37" height="23" border="0" alt="MC" title="MC">
                                                                    <img src="../images/logo_ccVisa.gif" width="37" height="23" border="0" alt="Visa" title="Visa"></td>
                                                            </tr>
                                                            <tr id="showVal2" <?php echo $display; ?>>
                                                                <td class="maintext1">Card Validation Code <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="nCvv2" type="text" class="textbox txt-bx01"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nCvv2 ?>" size="30" maxlength="3"></td>
                                                            </tr>
                                                            <tr id="showVal3" <?php echo $display; ?>>
                                                                <td class="maintext1">Expiration Date (MM/YYYY) <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vMM" type="text" class="select-small" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->vMM) ?>" size="2" maxlength="2">
                                                                    /
                                                                    <input name="vYYYY" type="text" class="select-small" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->vYYYY) ?>" size="4" maxlength="4"></td>
                                                            </tr>
                                                            <tr id="showVal4" <?php echo $display2; ?>>
                                                                <td class="maintext1">Routing Number of a Bank <span class="warning">*</span>.</td>
                                                                <td colspan="2" class="maintext1"><input name="rBank" type="text" class="textbox txt-bx01" onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->rBank ?>" size="30" maxlength="16"></td>
                                                            </tr>
                                                            <tr id="showVal5" <?php echo $display2; ?>>
                                                                <td class="maintext1">Bank Account Number <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="nAccountNumber" type="text" class="textbox txt-bx01"  onBlur="javascript:checkValue(this);"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->nAccountNumber ?>" size="30" maxlength="50"></td>
                                                            </tr>
                                                            <tr id="showVal6" <?php echo $display2; ?>>
                                                                <td class="maintext1">Account Type <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="txtAccountType" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo addslashes($objU->txtAccountType) ?>" size="25" maxlength="50"></td>
                                                            </tr>
                                                            <tr id="showVal7" <?php echo $display2; ?>>
                                                                <td class="maintext1">Bank Name <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="txtBankName" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankName ?>" size="30" maxlength="50"></td>
                                                            </tr>
                                                            <tr id="showVal8" <?php echo $display2; ?>>
                                                                <td class="maintext1">Bank Holder Name <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="txtBankHolderName" type="text" class="textbox txt-bx01"  onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->txtBankHolderName ?>" size="30" maxlength="50"></td>
                                                            </tr>
                                                            <tr id="showVal15" <?php echo $display; ?>>
                                                                <td class="maintext1">Address <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vAddress" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vAddress ?>" size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal16" <?php echo $display; ?>>
                                                                <td class="maintext1">City <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vCity" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo htmlspecialchars($objU->vCity) ?>" size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal17" <?php echo $display; ?>>
                                                                <td class="maintext1">State/Province <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vState" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vState ?>"  size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal18" <?php echo $display; ?>>
                                                                <td class="maintext1">Country <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><select name="vCountry" class="textbox txt-bx01">
                                                                            <?php foreach ($arrCountry as $key => $value) { ?>
                                                                            <option value="<?php echo $value ?>" <?php echo $objU->vCountry == $value ? "selected" : "" ?>>
                                                                            <?php echo $value ?>
                                                                            </option>
                                                                            <?php } ?>
                                                                    </select></td>
                                                            </tr>
                                                            <tr id="showVal19" <?php echo $display; ?>>
                                                                <td class="maintext1">Postal Code <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vPostCode" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPostCode ?>"  size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal20" <?php echo $display; ?>>
                                                                <td class="maintext1">Phone <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vPhone" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vPhone ?>" size="30" maxlength="100"></td>
                                                            </tr>
                                                            <tr id="showVal21" <?php echo $display; ?>>
                                                                <td class="maintext1">Email <span class="warning">*</span></td>
                                                                <td colspan="2" class="maintext1"><input name="vEmail" type="text" class="textbox txt-bx01" onKeyDown="changeCSS(this, 'text');" value="<?php echo $objU->vEmail ?>" size="30" maxlength="200"></td>
                                                            </tr>
                                                            <tr id="showVal22" <?php echo $display; ?>>
                                                                <td>&nbsp;</td>
                                                                <td colspan="2">&nbsp;</td>
                                                            </tr>
                                                            <tr id="showVal11" <?php echo $display; ?>>
                                                                <td>&nbsp;</td>
                                                                <td colspan="2"><input name="PYN" type="submit" class="loginbutton" value="Pay Now"><input type="hidden" name="step" value="3"><input type="hidden" name="product" value="<?php echo $product ?>"><input type="hidden"  name="hid_id" value="<?php echo $_GET['id'] ?>"></td>
                                                        </tr></form>
                                                     </table>
                                                </td>
                                            </tr>
                                        </table>
                                        <div id="hide"><?php echo $script ?></div>
                                    </td>
                                </tr>
                    </table></div></td>
                                
                </tr>
            </table>      
        </td>
    </tr>
</table>
<?php include_once('bottomhtml.inc.php');?>
