<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | 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.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";
if(isset( $_SESSION["sess_userid"]) and $_SESSION["sess_userid"]!= ""){
	$userid = $_SESSION["sess_userid"];
}

if($userid!='')
    {

    $sql=" SELECT user_name,password,first_name FROM ".$tableprefix."users
				WHERE user_id='".addslashes($userid)."' ";
		$result=mysql_query($sql) or die(mysql_error());
		if(mysql_num_rows($result) > 0 )
		{
			$row = mysql_fetch_array($result);
			
                        $txtUserName = $row['user_name'];

                        $txtPassword = trim($row['password']);
                        
                        $txtFirstName = $row['first_name'];

                        
                }
}

/*display the active template*/

$active_template = displayTemplate();


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

?>

<script src="js/product_download_check_ajax.js"></script>
<script src="js/javascript_check_userside.js"></script>
<script>
function downloadAuthenticate()
{

  var form_name = new Array('txtUserName','txtPassword');		
  var display_name = new Array('UserName','Passsword');
  var count = 2;	
  
  if(document.frmDigitalProductDownload.txtUserName.value=="")
  {
  		alert('<?php echo ENTER_NAME_TEXT;?>');
		document.frmDigitalProductDownload.txtUserName.focus();
		return false;
  }	
  
  if(document.frmDigitalProductDownload.txtPassword.value=="")
  {
  		alert('<?php echo ENTER_PWD_TEXT;?>');
		document.frmDigitalProductDownload.txtPassword.focus();
		return false;
  }	
  else
  {
      
	if(confirm(DIGITAL_PRODUCT_DOWNLOAD_CONFIRM)) {
	showListCheckDownload(document.frmDigitalProductDownload.txtUserName.value,
	document.frmDigitalProductDownload.txtPassword.value,document.frmDigitalProductDownload.txtDownloadCode.value,
	document.frmDigitalProductDownload.txtPasswordFlag.value);
      }
      else {
          return false;
      }
    
  }
 
   
}

</script>

<!--mainbody area start -->
<div class="main_body">
	<div class="container">
		<div class="row">				
		<!--center content area start-->		
		
		<div id="item_details">
	
	
		<!--items display area start -->
	
		
		<div>&nbsp;</div>
		
		<div class="col-sm-12 col-lg-4 col-md-4"></div>
		<div class="col-sm-12 col-lg-4 col-md-4">
			<div align="left" id="items_top_area">
				<div align="center" id="items_top_area_ttl">
					<?php echo DIGITAL_DOWNLOAD_TEXT;?>
					<div class="clear"></div>
				</div>
			</div>
			<div class="text_information" align="center"><?php echo $message?></div>
			<div class="clear"></div>
			<div id="download_dig">
			<div class="form_wrapper">
				<div class="register_form_outer">
					<form name="frmDigitalProductDownload" method="post">
					<div class="registrationform_container">
						 <?php if($userid==''){ ?>
						 <div class="field_wrapper formfield_row">
						 	<span class="text_information">*</span>&nbsp;<?php echo ENTER_NAME_PWD_TEXT;?>
						 </div>
						<div class="field_wrapper formfield_row">
							<label><?php echo USER_NAME_TEXT;?></label>
							<input class="form-control" type="text" name="txtUserName" value="<?php echo $txtUserName;?>">
                         </div>
						 <div class="field_wrapper formfield_row">
							<label><?php echo PASSWORD_TEXT;?></label>
							<input class="form-control"  type="password" name="txtPassword" value="<?php echo $txtPassword;?>">
                         </div>
						  <?php


                        }
                        else
                            {
                            ?>
                                <input type="hidden" name="txtUserName" value="<?php echo $txtUserName;?>">
				<input type="hidden" name="user_name" value="<?php echo $txtFirstName?>">
				<input type="hidden" name="txtPassword" value="<?php echo $txtPassword?>">
                        <?php
                        }
                        ?>
						<div class="field_wrapper formfield_row">
							<input type="hidden" name="txtPasswordFlag" value="Y">
							<!--<input type="hidden" name="txtUserName" value="<?php echo $user_name_row['first_name']?>">
							<input type="hidden" name="user_name" value="<?php echo $user_name_row['first_name']?>">
							<input type="hidden" name="txtPassword" value="<?php echo $user_name_row['password']?>">-->
							<span class="text_information">*</span>&nbsp;<?php echo CLICK_DOWNLOAD_TEXT;?>
						</div>
						<div class="field_wrapper formfield_row">
							<input type="hidden" name="txtPasswordFlag" value="N">
							<input type="hidden" name="txtDownloadCode" value="<?php echo $_GET['download_code']?>">
						</div>
						<div class="field_wrapper formfield_row">
							<input type="button" name="btnDownload" value="<?php echo DOWNLOAD_BUTTON;?>" class="button" onClick="return downloadAuthenticate();"></td>
						</div>
					</div>
					</form>
				</div>
			</div>
			</div>
		</div>
		<div class="col-sm-12 col-lg-4 col-md-4"></div>
		<div class="clear"></div>
				
	 <!--items display area end -->
	  </div>
	
		
	<!--center content area end-->	


	<div align="left" class="clear"></div>		
	</div>
	</div>
</div>		
<!--mainbody area end -->
<div align="left" class="clear"></div>


<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>																									               



