Part: 5
- ADD Requested to store secure links into database
<?php include_once('db.php');
$file=$_GET['file'];
$name=$_GET['name'];
$size=$_GET['size'];
$user=$mysite_username;
$hits="1";
$datetime = date("Y-m-d") ." : ". date("H:i:s A");
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
}
$sql="SELECT * FROM download WHERE f_file='". $file ."'";
$result = mysql_query($sql);
if(mysql_num_rows($result) >0) {
while($row = mysql_fetch_array($result)) {
echo "Already Exists in DataBase <span class='error'>". $row['f_name']
."</span>";
}
} else {
mysql_select_db("my_db", $con);
$sql="INSERT INTO download (f_file, f_name, f_size, f_user, f_mby, f_dmby,
f_hits, f_ip, f_date)VALUES('$file','$name','$size','$user','$user','$datetime','$hits','$ip','$datetime')";
if (!mysql_query($sql,$con)){
die('Error: ' . mysql_error());
}
echo "Successfully Added new File : <span class='error'>". $files
."</span>";
header("Location:index.php?axn=upload");
}
mysql_close($con);
?>
Part: 6
- DELETE Requested secure links from database
<?php include_once('db.php');
$file=$_GET['file'];
$id=$_GET['id'];
$queryDel = "DELETE from download WHERE no='$id' && f_file='$file' ";
$result = mysql_query($queryDel) or die("ERROR");
echo "<span class='error'>Sucessfully Deleted File</span>";
header("Location:index.php?axn=upload");
?>
Part: 7
- DOWNLOAD files lists from database
<?php
include_once('db.php');
$sqlAll= mysql_query("SELECT * FROM download ORDER BY no");
$_SESSION['download_file']="true";
while($files= mysql_fetch_array($sqlAll))
{
echo "<li><b>Download : </b><tt>:".$files['f_size'] . "</tt><br> ";
echo "<a href='".$seo."download&file=".$files['f_file']."&id=".$files['no']."'
>".$files['f_name'] . "</a></li>";
}
?>
Part: 8
- Permission to download files & download Tracking
<?php include_once('db.php');
$file=$_GET['file'];
$id=$_GET['id'];
$datetime= date("Y-m-d") ." : ". date("H:i:s A");
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
}
if($_SESSION['download_file']=="true"){
$sql="SELECT * FROM download WHERE f_file='". $file ."' && no='". $id ."' ";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$filedown=$row['f_name'];
$filehits=$row['f_hits'];
if ($filehits==""){
$hits=1;
}else{
$hits= $filehits+1;
}
$trackDownload="UPDATE download SET f_hits='$hits', f_ddate='$datetime', f_ip='$ip'
WHERE no='$id'";
$result = mysql_query($trackDownload) or die("ERROR");
$file="download/".$filedown;
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename=\"".basename($file)."\"");
readfile("$file");
}
}
?>
Part: 9
- Create index.php file
<?php
$do = $_GET['axn'];
switch ($do){
case "download":
if(($_GET['file']!='') && ($_GET['id']!='')){
require('download_ok.php');
}
require("download.php");
break;
case "upload":
require("upload.php");
break;
default:
require("details.php");
break;
}
?>
Powered by
technicguy [ eSanshar IT Experts ]
A complete IT Solutions & services
|