PHP Classes

PHP Digital Download Script: Serve files for download with codes given to users

Recommend this page to a friend!
  Info   View files View files (53)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-06-15 (Yesterday) RSS 2.0 feedNot enough user ratingsTotal: 1,092 This week: 3All time: 3,427 This week: 25Up
Version License PHP version Categories
digital-download 1.0.10BSD License5.3PHP 5, Files and Folders, Content man...
Description 

Author

This class can serve files for download with codes given to users.

It looks up in database for codes associated to files to be made available for download to users that enter such codes in the Web site.

The class serves the file associated to a code and it keeps track of the number of downloads.

The files may optionally be served only a limited number of times or for a limited period of time.

The class can also generate PDF documents as labels with the download codes written in them over custom logo images.

The labels can be printed so they can be used to distribute the download codes to the users in printed materials.

Innovation Award
PHP Programming Innovation award nominee
April 2013
Number 2


Prize: One downloadable copy of Komodo IDE
Many people work on producing digital content that is meant to be sold to people that access it by downloading the content from a Web site.

This class can implement a digital download system to make exclusive content available certain users.

Manuel Lemos
Picture of Vincenzo Di Biaggio
  Performance   Level  
Name: Vincenzo Di Biaggio <contact>
Classes: 1 package by
Country: Italy Italy
Innovation award
Innovation award
Nominee: 1x

Recommendations

What is the best PHP download class?
Create download link for file

How to hide the download URL
Script to hide download url

Details

digitalDownload ============== ## Short description With this class you can manage downloads of file by your website visitors with a code optionally limited by number of use and/or limited by time. You can also create a label with your code printed over an image and download it using a pdf file. I also provided a simple system with a form to use this class if you don't have specific necessities ## Requirements * > PHP 5.3 * MySql database * PDO support by PHP * writeOverImage class - https://github.com/vincenzodibiaggio/writeOverImage - provided * FPDF class - http://www.fpdf.org/ - provided * png, jpeg, gif, bmp image type for labels * ttf fonts for labels - A lot of free fonts are here: http://www.free-fonts-ttf.org/true-type-fonts/ ## To-do: support various pdf formats, support download resume. ## Usage The file 'index.php' is used to provide a public form to insert the code and for the installation (see usage below). ## Settings: File 'digitalDownload.php': #### Installation * Set your host: protected $host = 'general.dev'; // change this with your domain name * If you do install digitalDownload set to 1: public $install = 1; // Set to 1 to reinstall and regenerate the codes, 0 otherwise * Set 1 to create labels : public $createLabel = 1; // Create labels at the end of installation * Set 1 to create Pdf with all the labels: public $createPdf = 0; // Create a pdf with the labels at the end of installation * Set your database data on const DD_DB_HOST, const DD_DB_USER, const DD_DB_PASS, const DD_DB_DATABASE, const DD_DB_CODES_TABLE, const DD_DB_LOG_TABLE * Set the filename can be downloaded listed in the 'download' diretctory: public $fileToDownload * Set the lenght of codes used to download the file: public $codeLenght * Set the number of codes will be generated: public $codeNum * Set the number (if you want) to set the limit the number of downloads using a single code: public $limitNumDownload (0 = unlimited) * Set the number (if you want) to set the limit in hours for the validity of the code after the first download: public $limitByHour (0 = unlimited) #### Label creation * Set the image path where it found the background file and where the labels will be saved: public $backgroundImagePath * Set the RGB color of string will be writed over the background: public $stringColorRed, public $stringColorGreen, public $stringColorBlue * Set the fontsize of string: public $fontSize * Set the angle of string: public $stringAngle (0 = horizontal, 90 = vertical, etc) * Set the point x where the string will be written: public $startX * Set the point y where the string will be written: public $startY * Set the font file will be used: public $fontName * Set the string will be written: public $stringToWrite * Set the background file will be used for the labels: public $backgroundFileName #### PDF creation Will be generated a pdf with A4 format * Set the orientation: public $pdfOrientation * Set the DPI: public $pdfDpi * Set if ONLY the PDF will be regenerated during installation (NOT labels and codes): public $regeneratePdf * Set if you want download directly the pdf after installation: public $downloadPdf = 0; // At the end of installation, or regeneration of pdf: 0 = download directly the pdf, 1 = save pdf in labels directory with name 'labels.pdf' * Set the left margin: public $pdfMarginX * Set the top margin: public $pdfMarginY #### Output * Set EOF: public $eof * Set title's prefix: public $titleOpen * Set title's postfix public $titleClose #### Let's go! After installation, to permit file download, set to '0' public $install and to '1' public $downloadsAllowed

  Files folder image Files  
File Role Description
Files folder imagedownload (3 files)
Files folder imageextSrc (4 files, 2 directories)
Files folder imagehtmlSrc (2 files)
Files folder imagelabels (1 file)
Plain text file digitalDownload.php Class Class source
Accessible without login Plain text file download.php Appl. Application script
Accessible without login Plain text file georgia_italic.ttf Data Auxiliary data
Accessible without login Plain text file giveMeTheFile.php Appl. Application script
Accessible without login Plain text file helvetica.ttf Data Auxiliary data
Accessible without login Plain text file index.php Appl. Application script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  download  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Accessible without login Image file ajax-loader.gif Icon Icon image
  Accessible without login Plain text file prova.txt Data Documentation

  Files folder image Files  /  extSrc  
File Role Description
Files folder imagefont (14 files)
Files folder imagemakefont (22 files)
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Plain text file fpdf.php Class Class source
  Plain text file taylorPdf.php Class Class source
  Plain text file writeOverImage.php Class Class source

  Files folder image Files  /  extSrc  /  font  
File Role Description
  Accessible without login Plain text file courier.php Aux. Auxiliary script
  Accessible without login Plain text file courierb.php Aux. Auxiliary script
  Accessible without login Plain text file courierbi.php Aux. Auxiliary script
  Accessible without login Plain text file courieri.php Aux. Auxiliary script
  Accessible without login Plain text file helvetica.php Aux. Auxiliary script
  Accessible without login Plain text file helveticab.php Aux. Auxiliary script
  Accessible without login Plain text file helveticabi.php Aux. Auxiliary script
  Accessible without login Plain text file helveticai.php Aux. Auxiliary script
  Accessible without login Plain text file symbol.php Aux. Auxiliary script
  Accessible without login Plain text file times.php Aux. Auxiliary script
  Accessible without login Plain text file timesb.php Aux. Auxiliary script
  Accessible without login Plain text file timesbi.php Aux. Auxiliary script
  Accessible without login Plain text file timesi.php Aux. Auxiliary script
  Accessible without login Plain text file zapfdingbats.php Aux. Auxiliary script

  Files folder image Files  /  extSrc  /  makefont  
File Role Description
  Accessible without login Plain text file cp1250.map Data Auxiliary data
  Accessible without login Plain text file cp1251.map Data Auxiliary data
  Accessible without login Plain text file cp1252.map Data Auxiliary data
  Accessible without login Plain text file cp1253.map Data Auxiliary data
  Accessible without login Plain text file cp1254.map Data Auxiliary data
  Accessible without login Plain text file cp1255.map Data Auxiliary data
  Accessible without login Plain text file cp1257.map Data Auxiliary data
  Accessible without login Plain text file cp1258.map Data Auxiliary data
  Accessible without login Plain text file cp874.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-1.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-11.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-15.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-16.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-2.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-4.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-5.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-7.map Data Auxiliary data
  Accessible without login Plain text file iso-8859-9.map Data Auxiliary data
  Accessible without login Plain text file koi8-r.map Data Auxiliary data
  Accessible without login Plain text file koi8-u.map Data Auxiliary data
  Accessible without login Plain text file makefont.php Aux. Auxiliary script
  Accessible without login Plain text file ttfparser.php Aux. Auxiliary script

  Files folder image Files  /  htmlSrc  
File Role Description
  Accessible without login Image file ajax-loader.gif Icon Icon image
  Accessible without login Plain text file style.css Data Auxiliary data

  Files folder image Files  /  labels  
File Role Description
  Accessible without login Image file digitaldownload.gif Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:1,092
This week:3
All time:3,427
This week:25Up