Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 2002
Posts: 12
Newbie
Newbie
Offline
Joined: May 2002
Posts: 12
We allow "special users" to download Multimedia files - which are kept outside "web root". We check if the users belong to special group "5" and then allow download through the following script. Now we want to to restrict download limit to 500MB a month per special member.

Current Code :
___________________________________________________________
<?
$threadspath = "/home/myhotboard.com/public_html/hotboard/";
include "{$threadspath}/main.inc.php";
$userob = new user;
$user = $userob -> authenticate("U_Groups");

$specialgroup = "5";
$redirectURL = "http://www.myhotboard.com/hbfriend/hbfriend.htm";
if (!preg_match("-$specialgroup-",$user['U_Groups'])) {

// Their not in the special group so we go elsewhere...
header("Location: $redirectURL");

}

define('FILEDIR', '/home/downloads/');
//storage directory outside the root
$path = FILEDIR . $file;


header("Content-type: application/force-download\n");
header("Content-disposition: attachment; filename="$file"\n");
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");
header ("Connection: close");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
fclose($fp);
?>
____________________________________________________________
Future Code : (Proposed changes in CAP)

<?
$threadspath = "/home/myhotboard.com/public_html/hotboard/";
include "{$threadspath}/main.inc.php";
$userob = new user;
$user = $userob -> authenticate("U_Groups");

$specialgroup = "5";
$redirectURL
= "http://www.myhotboard.com/hbfriend/hbfriend.htm";
if (!preg_match("-$specialgroup-",$user['U_Groups'])) {

// Their not in the special group so we go elsewhere...
header("Location: $redirectURL");

-- ELSE CHECK MYSQL TABLE
-- TOTAL(FILESIZE) THIS MONTH > 500MB
-- GO TO "YOU DOWNLOAD LIMIT HAS EXCEEDED" PAGE
-- SELECT STATEMENT from the TABLE

-- A NEW TABLE IN DATABASE WILL CONTAIN USER_ID,
--USER_NAME, DATE, FILESIZE
-- BASICALY DOWNLOAD HISTORY
}

define('FILEDIR', '/home/myhotboard.com/downloads/');
//storage directory outside the root
$path = FILEDIR . $file;

-- INSERT INTO MYSQLTABLE USERNAME, USER_ID, DATE, FILESIZE($PATH);

header("Content-type: application/force-download\n");
header("Content-disposition: attachment; filename="$file"\n");
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");
header ("Connection: close");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
fclose($fp);
?>


Let's say the table will be like

Hotclips_t

User_Id
User_Name
TimeStamp
FileSize

This gets inserted whenever a user downloads a file. This also is checked against before a user wants to download a file.

I am a novice in PHP-MySQL code. Any help?

Thanks,

hb

Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
*bump* for you You may need to consider hiring someone if you are unable to get an answer here... sometimes the answers that take forever require more than a short and simple answer and a good bit of time


- Allen wavey
- What Drives You?
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Yeah, this would probably be doable...but complicated.

We have to start by getting filesizes of uploads and potentially store that in the DB. Then record the cumulative download total in a new field in the user's table and stop them when they have downloaded 'x' amount of data. Then you'd need a cron script to probably clear out the download totals at the begining of the month so people could start fresh.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
hatter
hatter
USA
Posts: 69
Joined: January 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)