File Download Management Updater

If you happen to have a download link constantly changing due to version updates this should ideally help you. This script is designed to always point to the most recent file in a folder. Any file can then be stored in the folder, with the proper first few letters of the file name, allowing for a single link to be utilized and not constantly updated.

One can store files in a directory and the script will know which file is the most up to date. Parameters in the URL can be utilized to store multiple files in the same directory.

//lowercase for file name
$lc_lang = strtolower($_GET['lang']);
$lc_filename = strtolower($_GET['file']);
$lc_program = strtolower($_GET['program']);
 
//clean variables before processing validateVariable is a custom function built 
//for executing a regex to clean the variable
$clean_filename = validateVariable($lc_filename, 'regular', 255);
$clean_lang = validateVariable($lc_lang, 'regular', 2);
 
//initialize file time array
$filetimes=array();
 
//place the files in the same directory as this script
//can use sub directory for better organization
$files = scandir("./$clean_lang/");  // you can also specify further directories
 
//loop through each file in the directory
  foreach ($files as $file){
      //each file named with 3 letters in the beginning of the file name 
      //use this for identification of file itself ex: win05112010.zip 
      $type=substr($file, 0, 3);
      if($type==$clean_filename){
          //check when each file was created  - you can specify a further directories 
    $time=filemtime("./$clean_lang/"$file);  
    $filetimes[$file]=$time;
   }
}
Still need help? Let us know.