Sublime directory Surf the web anonymous Pagerank Monitor


How to Limit the download every month.

coated_pill
Tue 8 July 2008, 11:19 am GMT +0200
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!

Nikolas
Tue 8 July 2008, 11:25 am GMT +0200
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.

coated_pill
Fri 11 July 2008, 06:13 am GMT +0200
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!

Nikolas
Fri 11 July 2008, 09:36 am GMT +0200
Well, we can't help if you wont tell us what's the problem and the error you get :)

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

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional