I'm building a package for managing download action. The package will be equipped with ability to limit download bandwith on individual, daily, and monthly basis.
Below, I will show the code snippet for the download class, which is the main part of the download manager. If any of you is interested in this package, you can support me by giving donation, joining the developer team, or providing hosting.
Here is the code snippet
PHP Code:
<?php
/**************************************************************\
* File :download-class.php *
* Version :0.1a *
* Desc. :A class for bandwidth managing in server side *
* download *
* Compat. :PHP4 > 4.1.0, UNIX *
* Author :moron_moronovich [at] yahoo.com *
\**************************************************************/
class download {
/*private*/ var $delayTime = 0;
/*private*/ var $fieldSep, $crLf, $myDateFormat;
/*private*/ var $logFileName,$logFileContent;
/*private*/ var $unixTime,$curDate,$curMonth,$curYear = 0;
/*private*/ var $curMonthBw,$curDayBw,$curLogMonthSpentBw, $curLogDaySpentBw, $curLogDate,$curLogMonth,$curLogYear, $todayLastSpentBw = 0;
/*private*/ var $accRestBw; //boolean
/*private*/ var $todayDownload, $indivDlLimit = 0;
/*Access public
*Contructor
*/
function download() {
session_start();
error_reporting(0);
//Set up session name
if(isset($_SESSION['dlCount']) && preg_match('/[0-9]+/',$_SESSION['dlCount'])) {
$dlCount = $_SESSION['dlCount'];
}
else {
$dlCount = $_SESSION['dlCount'] = 0;
}
$this->todayDownload = $dlCount;
}