File: shortcut.php

Recommend this page to a friend!
  Classes of Chouchen  >  Shiki PHP Proxy Request to Another Server  >  shortcut.php  >  Download  
File: shortcut.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Shiki PHP Proxy Request to Another Server
Retrieve and zip a file from a remote server
Author: By
Last change:
Date: 1 year ago
Size: 683 bytes
 

 

Contents

Class file image Download
<?php
/**
We need to find the matching file thanks to the todl.txt file
Read it, send it then delete it from the txt file
*/
$idx = new ToDownloadIndex();

$shortcut = !empty($_GET['sc']) ? $_GET['sc'] : '';

if(
$shortcut == ''){
   
header('HTTP/1.0 404 Not Found');
    exit;
}

$file = $idx->readLine($shortcut);

if(
$file == null || !is_readable(dirname(__FILE__).'/'.$file)){
   
header('HTTP/1.0 404 Not Found');
    exit;
}

header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=".$file);
header("Pragma: no-cache");
header("Expires: 0");
readfile(dirname(__FILE__).'/'.$file);
unlink(dirname(__FILE__).'/'.$file);

$idx->deleteLine($shortcut);

exit;


For more information send a message to info at phpclasses dot org.