<?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>

			<div align="left" class="main_body">
			
			<!--mainbody area start -->
			
		<!--center content area start-->		
		
		<div align="left" id="item_details">
	
	
		<!--items display area start -->
	
		<div align="left" id="items_top_area">
				<div align="left" id="items_top_area_ttl"><?php echo DIGITAL_DOWNLOAD_TEXT;?></div>
				
		</div>
		
		<div>&nbsp;</div>
		
		<div class="text_information" align="center"><?php echo $message?></div>
		
		<div id="login_area" style="width:600px;">
		<form name="frmDigitalProductDownload" method="post">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>

                        <?php if($userid==''){ ?>
			<tr>
				<td colspan="2"><span class="text_information">*</span>&nbsp;<?php echo ENTER_NAME_PWD_TEXT;?></td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			
			<tr>
				<td width="20%" class="maintext" align="left" valign="top" ><?php echo USER_NAME_TEXT;?></td>
                                <td width="80%" align="left" valign="top"><input type="text" name="txtUserName" class="textfield" value="<?php echo $txtUserName;?>"></td>
			</tr>
			<tr><td colspan="2">&nbsp;</td></tr>
			<tr>
				<td align="left" valign="top" class="maintext"><?php echo PASSWORD_TEXT;?></td>
				<td align="left" valign="top">
					<input type="password" name="txtPassword" class="textfield" value="<?php echo $txtPassword;?>">
				</td>
			</tr>

                                
                        <?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
                        }
                        ?>
			
			<tr>
				<td colspan="2">
				<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;?></td>
			</tr>
			<tr>
				<td colspan="2"><input type="hidden" name="txtPasswordFlag" value="N">
				<input type="hidden" name="txtDownloadCode" value="<?php echo $_GET['download_code']?>"></td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td align="left"><br><input type="button" name="btnDownload" value="<?php echo DOWNLOAD_BUTTON;?>" class="button" onClick="return downloadAuthenticate();"></td>
			</tr>
		</table>
		</form>
			
		</div>					
		
		<div align="left" class="float_clear1"></div>
				
				
	 <!--items display area end -->
	  </div>
	
		
	<!--center content area end-->	


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


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



