5, December 2008

How to Limit the download every month. - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: How to Limit the download every month.
« previous next »
Pages: [1] Print

Author Topic: How to Limit the download every month.  (Read 459 times)
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« on: Jul 08, 2008, 12:19:55 PM »

I need to find a script that will let me set the download limit for each separate file per day, which will reset every 24 hours.

e.g Members can only download 3 video clips per day.

Thanks! Help will highly appreciated!
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #1 on: Jul 08, 2008, 12:25:03 PM »

I guess it wont be too hard to write such a script yourself. Just keep in a field in your db how many files a user downloaded, and then reset it everyday.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Google dot what?
*
Posts: 2
16 credits
Members referred : 0


« Reply #2 on: Jul 11, 2008, 07:13:18 AM »

how about this error i was encountering.. i try to upload the script on my webhost but the thumbnails doesn't appear because it is corrupt also the downloaded clips were also corrupt.. i was wondering if there is an error on the script that i've maid.. and how can i mask the download url of that files...

these are the script i made..

index.php

<?php
include ("../includes/connect.inc");
$vid_id = $_REQUEST['fileid'];
$dl_vid = mysql_query("SELECT * FROM tbl_videos WHERE vid_id = '$vid_id'") or die(mysql_error());
$file = mysql_fetch_array($dl_vid);
$loc = $file['vid_url'];
header ("Location: ../$loc");
?>

connect.inc

<?php
$db = mysql_connect("localhost","username","password")
   or die("Could not connect to the database!");
mysql_select_db("username_dbvideos",$db);
?>

download.php

  <?php
//fetch variables
$vid_id = $_REQUEST['id'];
$usr_ip = $_SERVER['REMOTE_ADDR'];
$state = "false";
$date = date("Y-m-d");

include ("includes/connect.inc");

//validation 1: if more that 10 dls
$ret_history = mysql_query("SELECT * FROM tbl_user WHERE usr_ip = '$usr_ip'") or die(mysql_error());
$count = mysql_num_rows($ret_history);

//validation 2: verify repeated downloads - di pede
$dl_file = mysql_query("SELECT * FROM tbl_user WHERE usr_ip = '$usr_ip' AND vid_id = '$vid_id'") or die(mysql_error());
$dl_count = mysql_num_rows($dl_file);

//validation 1
if ($count >= 10) {
?>
  <span class="style7">You have reached your maximum downloads for this month!</span>
<?php
//validation 2
} else if ($dl_count > 0) {
?>
<span class="style7">You have already downloaded this file!</span>
<?php
} else {


//get video url
$dl_vid = mysql_query("SELECT * FROM tbl_videos WHERE vid_id = '$vid_id'") or die(mysql_error());
$file = mysql_fetch_array($dl_vid);
?>
<div align="center"<a href="file/?fileid=<?php echo $file['vid_id']; ?>" class="style1 style2"><br /><br /><br /><br /><br />Download Now</a><br /><br />
<span class="style4">Warning !!! </span><br />
<span class="style3">Don't refresh this page or click back button while downloading.. The validation will expire after the download finish.</span>
<?php
//note this valid download to database

mysql_query("INSERT INTO tbl_user VALUES ('$usr_ip','$vid_id','$date')") or die(mysql_error());

}
?>

listvideos.php

  <?php
  include ("includes/connect.inc");
  $list_videos = mysql_query("SELECT * FROM tbl_videos");
  while($row = mysql_fetch_array($list_videos))
  { ?>
    <tr>
    <td><a href="download.php?id=<?php echo $row['vid_id']; ?>"><?php echo $row['vid_title']; ?></a></td>
    <td><?php echo $row['vid_desc']; ?></td>
    <td><img src="<?php echo $row['vid_thu']; ?>" width="200" border="0" /></td>
  </tr>
<?php }   ?>

Is there an error on that script?? but that script is running perfectly on my localhost server

help with this would highly appreciated thanks!
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #3 on: Jul 11, 2008, 10:36:59 AM »

Well, we can't help if you wont tell us what's the problem and the error you get Smiley

BTW the code you wrote is varnerable to SQL injection attacks. You should fix this with addslashes() or a similar function.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7836
Tags : php script Download Limit Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: How to Limit the download every month.
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 05, 2008, 04:46:06 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 38.000
Total Topics: 7.685
Total Members: 4.471
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: luismanco

36 Guests, 3 Users online :

9 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.