<?php
if (basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)){
echo "<p align=center><br><br><br><br><br><br><font size=\"6\" color=\"#FF0000\">ILLEGAL ACCESS !!";
echo "<meta http-equiv=\"refresh\" content=\"2; url=../index.php\">";
exit();} 
// // #-----------------------------------------------------------------------------#
// // #-------------------------------.*PRIMADESAIN*.-------------------------------#
// // #-------------------------------: Script MMM3 :-------------------------------#
// // #------------------- Copyright 2009-2015 Primadesain.com ---------------------#
// // #----------- Email: primapc57@gmail.com Phone: +62 852 2865 7360 -------------#
// // #--------- http://www.primadesain.com - http://www.primadesain.net -----------#
// // #-----------------------------------------------------------------------------#
// // #------------- Primadesain.Com | Jasa Webdesain Bisnis Online ----------------#
// // #--- Website Bisnis MLM, Bisnis Investasi, Forex, Hyip, Binary, Trinary, -----#
// // #------- Matrix 4 -- 10, Toko Online, Iklan Baris, Profil, Reseller. ---------#
// // #-----------------------------------------------------------------------------#
// // # This software is  furnished  under a  license and may  be used and   copied #
// // # only  in accordance with the terms of such  license and with  the inclusion #
// // # of  the above copyright notice.  This software or any other  copies thereof #
// // # may not be  provided or otherwise made available  to any other person.   No #
// // # title to and  ownership of the software is hereby transferred.              #
// // #                                                                             #
// // # You  may  not  reverse   engineer,  decompile,  defeat  license  encryption #
// // # mechanisms, or  disassemble  this  software  product  or software   product #
// // # license. We  may terminate  this license if you  don't comply  with any  of #
// // # the terms and   conditions set forth   in our  End  User  License Agreement #
// // # (EULA). In  such event, licensee  agrees to return licensor or  destroy all #
// // # copies of software upon termination  of the license.                        #
// // # Please see the EULA file for the full End User License Agreement.           #
// // ###############################################################################
?>
    <section class="content-header">
      <h1>
        Download
      </h1>
      <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="breadcrumb-item active">Download</li>
      </ol>
    </section>


    <section class="content">
<?php
if($db->dataku("status", $user_session) == 0 || $db->dataku("blokir", $user_session) == 1) {
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".$LANG["status0"]."</div>";
}else{
?>
<!-- BEGIN PAGE CONTENT-->
<?php
 if(isset($_GET['result'])&&$_GET['result']=="no_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_NO_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="wrong_pin"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_WRONG_PIN."</div>";
}
?>  
 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_lock"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_BLOCK_PIN."</div>";
}
?>  

 <?php
 if(isset($_GET['result'])&&$_GET['result']=="pin_off"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>".LANG_FORGOT_OFF_PIN."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="min_wd"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Minimal WD is ".rupiah($bataswdnya1)."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="max_wd"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Max WD is ".rupiah($bataswdnya2)."</div>";
}
?>
<?php
 if(isset($_GET['result'])&&$_GET['result']=="err_balance"){
echo "<div class='alert alert-danger alert-dismissable'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'></button>Your balance is insufficient</div>";
}
?>

<?php
if (isset($_GET['page']) && $_GET['page'] == "detail") {
if(isset($_GET["co"])){ $co = $_GET["co"]; }
?>
  <div class="row">
            	<div class="col-md-12">
                
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Detail Download <?php echo $co;?></h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">            

                    
							<thead>
							<tr>
						 <th>Tanggal</th>
                                    <th>Kode</th>
                                    <th>User</th>
                                    <th>Nama File</th>
                                  
							</tr>
							</thead>
							<tbody>
	<?
$db->select("id, kode, judul, username, date", "product3_down", "kode='".$co."' and username='".$user_session."'", "date desc");
		while($row=$db->fetch_row()) {

?>				             
                     <tr> 
                          <td align="center"><?php echo formatgl($row[4]); ?></td>
                            <td align="center"><?php echo $row[1]; ?></td>
                            <td align="center"><?php echo $row[3]; ?></td>
                            <td align="center"><?php echo $row[2]; ?></td>
                        </tr>
                                                                    
        
	<?
		}
	?>
							</tbody>
							</table>
						</div>
                    </div>
                </div>
                </div>
			</div>
			<!-- END PAGE CONTENT -->   

<?php } else { ?>


<script>
  function confirmActionbatasdown(){
   swal('Oops...', 'Batas download file hanya <?php echo $batasdownload;?> kali tiap file.', 'error').done();
 
}
</script> 


   <script>
  function confirmActiondownloads(){
   swal('Oops...', 'Status Anda belum aktif! Silahkan kontak admin untuk dapat download.', 'error').done();
 
}
</script> 

  <div class="row">
            	<div class="col-md-12">
                
                  <div class="box box-solid bg-dark">
            <div class="box-header with-border">
              <h3 class="box-title">Download</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
				<div class="table-responsive">
				  <table id="example" class="table table-bordered table-hover display nowrap margin-top-10 w-p100">            


							<thead>
							<tr>
                                    <th>Judul</th>
                                    <th>Info</th>
                                    <th>Hits</th>
                                    <th>Download</th>
                                    <th>File</th>
                                  
							</tr>
							</thead>
							<tbody>
	<?
$db->select("id, nama, harga, gambar, deskripsi, hit, kode, hargab, hargac, hargad, file, created, download, member", "product3", "published=1", "created desc");
	
		while($row=$db->fetch_row()) {
			
$cekadadownloade = mysql_query("select * from product3_down where username='".$user_session."' and kode='".$row[6]."'");
$totldownloade = mysql_num_rows($cekadadownloade);
if($totldownloade>0){
	$ttldwnlde="<a href='index.php?go=download&page=detail&co=".$row[6]."'><span class='label label-primary'>".$totldownloade." Kali</label>";
}else{
	$ttldwnlde="<span class='label label-danger'>Belum Download</label>";
}			
			

$mngremember = "SELECT * FROM member WHERE username='$user_session'"; 
$resultmngere = mysql_query($mngremember);
$rownmngree = mysql_fetch_array($resultmngere);

//if($row[13] == 1 && $rownmngree['act'] == 1){ 

if($totldownloade >= $batasdownload){
$linknya="<a href='#'><button type='button' class='btn btn-warning' onclick='return confirmActionbatasdown()'><i class='fa fa-download'></i>&nbsp;Download</button></a>";
	$stylnya=" style='color:#FF915B'";
}else{
         
if($row[7] == 1){
	$linknya="<a href='download.php?u=".base64_encode($user_session)."&d=".$row[6]."' target='_blank'><button type='button' class='btn btn-success'><i class='fa fa-download'></i>&nbsp;Download</button></a>";
	$stylnya="";
}else{
	$linknya="<a href='download.php?u=".base64_encode($user_session)."&d=".$row[6]."' target='_blank'><button type='button' class='btn btn-success'><i class='fa fa-download'></i>&nbsp;Download</button></a>";
	$stylnya="";
}
}
//}else{
//	$linknya="<a href='#'><button type='button' class='btn btn-danger' onclick='return confirmActiondownloads()'><i class='fa fa-download'></i>&nbsp;Download</button></a>";
//	$stylnya=" style='color:#D00'";
//}
	
if($row[5] > 0){
	$hitse=$row[5];
}else{
	$hitse="0";
}
?>				             
                     <tr> 
                            <td align="left"<?php echo $stylnya; ?>><?php echo $row[1]; ?></td>
                            <td align="left"<?php echo $stylnya; ?>><?php echo $row[4]; ?></td>
                            <td align="center"<?php echo $stylnya; ?>><?php echo $hitse; ?></td>
                            <td align="center"<?php echo $stylnya; ?>><?php echo $ttldwnlde; ?></td>
                            <td align="center"<?php echo $stylnya; ?>><?php echo $linknya; ?></td>
                        </tr>
                                                                    
        
	<?
		}
	?>
							</tbody>
							</table>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</div>
			</div>
			                                     
                            
                    <?php } ?>
 <?php } ?>

</section>
