My main download page passes an id number for the file to be downloaded. In the mydloader.php (located in the download folder), I have a pdo sql query to set $l_filename to the filename in the database. I need to use $l_filename in <a href to download the file. My code follows:
<?php
$php_scripts = '../../php/';
require $php_scripts . 'PDO_Connection_Select.php';
require $php_scripts . 'GetUserIpAddr.php';
function mydloader($id=NULL)
{
$ip = GetUserIpAddr();
if (!$pdo = PDOConnect("foxclone_data"))
{
exit;
}
$stmt = $pdo->prepare('SELECT filename FROM files WHERE id =?');
$stmt->execute([$id]);
$l_filename = $stmt->fetch();
if( isset( $l_filename ) ) {
<a href="">
$ext = pathinfo($l_filename, PATHINFO_EXTENSION);
$stmt = $pdo->prepare("INSERT INTO download (address, filename,ip_address) VALUES (?, ?, inet_aton('$ip'))");
$stmt->execute([$ip, $ext]) ;
$test = $pdo->query("SELECT id FROM lookup WHERE INET_ATON('$ip') BETWEEN start AND end ORDER BY start DESC, end DESC");
$ref = $test->fetchColumn();
$ref = intval($ref);
$stmt = $pdo->prepare("UPDATE download SET ref = '$ref' WHERE address = '$ip'");
$stmt->execute() ;
}
else {
echo "isset failed";
}
}
mydloader($_GET["f"]);
exit;
Thanks in advance