PHP Classes

File: download.php

Recommend this page to a friend!
  Classes of Vincenzo Di Biaggio   PHP Digital Download Script   download.php   Download  
File: download.php
Role: Application script
Content type: text/plain
Description: Application script
Class: PHP Digital Download Script
Serve files for download with codes given to users
Author: By
Last change: Update of download.php
Date: 5 months ago
Size: 976 bytes
 

Contents

Class file image Download
<?php

include(__DIR__.'/digitalDownload.php');
use
DigitalDownload\DigitalDownload;

$dd = new DigitalDownload();
$dd->install = 0;
$dd->downloadsAllowed = 1;

if (
1 == $dd->downloadsAllowed && 0 == $dd->install )
{
   
session_start();
    if (!isset(
$_SESSION['abracadabra']) || !isset($_REQUEST['code'])) { die('The spell has failed :(');}
   
   
$code = $_REQUEST['inputCode'];
   
    if (
$_SESSION['abracadabra'] !== $_REQUEST['code']) {
       
$f['result'] = 'ko';
       
$f['message'] = 'The spell has failed :(';
       
session_write_close();
       
header("HTTP/1.0 ".$dd->giveResponseCode());
        echo
json_encode($f);
       
    }
    else {
       
$_SESSION['ctrl'] = sha1($_SESSION['abracadabra']);
       
$dd->download($code);
       
$f['result'] = 'ok';
       
$f['message'] = $dd->giveReturn();
       
header("HTTP/1.0 ".$dd->giveResponseCode());
        echo
json_encode($f);
    }
   
}
else
{
   
$f['result'] = 'ko';
   
$f['message'] = 'Download not allowed';
   
session_write_close();
   
header("HTTP/1.0 203");
    echo
json_encode($f);
}