<?php /** * Example file for class Download * * This is an example file to show the class Download works. * * @author Marko Schulz <info@tuxnet24.de> * @copyright Copyright (c) 2012 tuxnet24.de * @license http://www.php.net/license/3_01.txt PHP License 3.01 * @date $Date: 2012-05-15 14:21:16 +0100 (Di, 15 Mai 2012) $ * @version $HeadURL: http://svn.tuxnet24.de/php/classes/download.php $ - $Revision: 7 $ * @package */
// Program variables (array) $cfg = array();
// Class properties $cfg['download'] = array( 'statistic' => True, 'couterfile' => './download-counter.txt' );
/** * /download.php?file=./path/to/your/file.tar.gz&do=1 * /download.php?file=./path/to/your/file.tar.gz * /download.php */
// Include the Download class file include_once('download.class.php');
try {
// Create the $download object (object) $download = new Download($cfg['download']);
// Execute the download if (isset($_REQUEST['file']) && isset($_REQUEST['do'])) { if (file_exists($_REQUEST['file'])) $file = $_REQUEST['file']; $download->getFile($file); // Print out the download count of the defined files } else if (isset($_REQUEST['file']) && !isset($_REQUEST['do'])) { if (file_exists($_REQUEST['file'])) $file = $_REQUEST['file']; echo "File ".basename($file)." was downloaded ".$download->getCounter($file)." times."; // Print out download counts of all files } else { (array) $counts = $download->getCounter(); foreach ($counts as $count) { echo $count['name'].": ".$count['count']."<br/>\n"; } } } catch ( Exception $error ) { // Print out the exception message echo "Error: ".$error->getMessage()." on Line: ".$error->getLine()." in ".$error->getFile()."<br/>\n"; }
// vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: // EOF ?>
|