4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on April 30, 2005, 07:03:23 PM

Title: [MOD] Download limit v1.0.1
Post by: V@no on April 30, 2005, 07:03:23 PM
Before the hack we had "Download limit" mod, I belive it was made by rproctor :?: At that time I didnt need such mod, so I didnt install it, and now its lost after the hack...

Here is my version of that mod. With this mod admin can set download limit per XX hours. The XX time begin count after first image download.

Tested on 4images v1.7 - v1.7.6


----------- [ Changed files ] -------------

details.php
download.php
admin/settings.php
includes/db_field_definitions.php
includes/page_header.php
includes/sessions.php
lang/<your language>/admin.php
lang/<your language>/main.php
templates/<your template>/details.html
(or any other template)


------------- [ Installation ] --------------

NOTE: if you see a 4images version number next to a step, it means, that particular step meant for that 4images version only and if you have different version, you should skip this step and see if next step is for your version.

Step 1
Open details.php
Find:
Code: [Select]
show_image($image_row, $mode, 0, 1);Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
if ($msg_error = $site_sess->get_session_var("msg_error"))
{
  $msg .= ((empty($msg)) ? "" : "<br />").stripslashes($msg_error);
  $site_sess->drop_session_var("msg_error");
}
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2
Open download.php
Find:
Code: [Select]
$user_access = get_permission();Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$dl = 0;
function check_dl_limit($dl)
{
  global $user_info, $config;
  if ($user_info['user_level'] != ADMIN && $user_info['user_dl_limit'] != -1 && $user_info['user_dl_limit'] && time() - $user_info['user_dl_time'] <= 60*60*$config['user_dl_time'] && $user_info['user_dl_count'] + $dl >= $user_info['user_dl_limit'])
  {
    return false;
  }
  elseif ($user_info['user_level'] != ADMIN && $user_info['user_dl_limit'] != -1 && $user_info['user_dl_limit'] && time() - $user_info['user_dl_time'] > 60*60*$config['user_dl_time'] && $dl >= $user_info['user_dl_limit'])
  {
    return false;
  }
  return true;
}
function update_dl_limit($dl)
{
  global $user_info, $site_db, $site_sess, $config;
  if ($user_info['user_level'] == ADMIN) return;
  $time = time();
  if (!$user_info['user_dl_time'] || $time - $user_info['user_dl_time'] > 60*60*$config['user_dl_time'])
  {
    $time_sql = ", user_dl_time = ".$time;
    $user_info['user_dl_count'] = $dl;
    $user_info['user_dl_time'] = $time;
  }
  else
  {
    $time_sql = "";
    $user_info['user_dl_count'] += $dl;
  }
  if ($user_info['user_level'] > GUEST)
  {
    $sql = "UPDATE ".USERS_TABLE."
            SET user_dl_count = ".$user_info['user_dl_count'].$time_sql."
            WHERE user_id = ".$user_info['user_id'];
    $site_db->query($sql);
  }
  $site_sess->set_cookie_data('data', base64_encode($user_info['user_dl_count']." ".$user_info['user_dl_time']), 1, 60*60*$config['user_dl_time']);
}
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.1
Find:
Code: [Select]
    while ($image_row = $site_db->fetch_array($result)) {Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
      if (!check_dl_limit($dl)) break;
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.2
Find:
Code: [Select]
        $file_added = 1;Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
        $dl++;
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.3 (v1.7/v1.7.1)
Find:
Code: [Select]
      $file['file_size'] = strlen($file['file_data']);
    }
    else {
      header("Location: ".$site_sess->url($url, "&"));
Replace it with:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  END ORIGINAL CODE BLOCK
*/

/*
  MOD DOWNLOAD LIMIT
  BEGIN REPLACE
*/
      $file['file_size'] = strlen($file['file_data']);
    }
    else {
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
      header("Location: ".$site_sess->url($url, "&"));
/*
  MOD DOWNLOAD LIMIT
  END REPLACE
*/


Step 2.3 (v1.7.2)
Find:
Code: [Select]
      $file['file_data'] = $zipfile->send(time().".zip");
      exit;
    }
    else {
      redirect($url);
Replace with:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN REPLACE
*/
      $file['file_data'] = $zipfile->send(time().".zip");
      exit;
    }
    else {
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
      redirect($url);
/*
  MOD DOWNLOAD LIMIT
  END REPLACE
*/


Step 2.3 (v1.7.6)
Find:
Code: [Select]
      redirect("lightbox.php?empty=1");Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT ABOVE
*/
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
/*
  MOD DOWNLOAD LIMIT
  END INSERT ABOVE
*/


Step 2.4 (v1.7/v1.7.1)
Find:
Code: [Select]
  $remote_url = 0;Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  if (!check_dl_limit(0))
  {
    $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/


Step 2.4 (v1.7.2 - v1.7.x)
Find:
Code: [Select]
  $remote_url = 0;Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  if (!check_dl_limit(0))
  {
    $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
    redirect($url);
    exit;
  }
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/


Step 2.5 (v1.7/v1.7.1)
Find:
Code: [Select]
  if (!empty($file['file_path'])) {Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  $dl++;
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.5 (v1.7.2 - v1.7.x)
Find:
Code: [Select]
  if (!empty($file['file_path'])) {Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  $dl++;
  update_dl_limit($dl);
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.6 (v1.7/v1.7.1)
Find:
Code: [Select]
    if ($remote_url) {Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  START INSERT
*/
      update_dl_limit($dl);
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/


Step 2.7 (v1.7/v1.7.1)
Find:
Code: [Select]
if (!empty($file['file_data'])) {Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  START INSERT
*/
   update_dl_limit($dl);
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/


Step 2.8
Find:
Code: [Select]
    if ($file_added) {Insert below::
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
      update_dl_limit($dl);
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/



Step 3
Open admin/settings.php
Find:
Code: [Select]
  show_form_footer($lang['save_changes'], "", 2);Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  show_table_separator($setting_group[XX], 2, "#setting_group_XX");
  show_setting_row("user_dl_limit");
  show_setting_row("user_dl_time");
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/
Replace XX with 8 if u havent install any mods that changed this file, othwise look up the number in the the last section that starts with   show_table_separator($setting_group[ and add one to that number.
Write down that number, you will needed it in another step!



Step 4
Open includes/db_field_definitions.php
At the end, ↑ABOVE↑ closing ?> insert:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$additional_user_fields['user_dl_limit'] = array(&$lang['user_dl_limit'], "text", 0);
$additional_user_fields['user_dl_time'] = array($lang['user_dl_time'], "text", 0);
$additional_user_fields['user_dl_count'] = array($lang['user_dl_count'], "text", 0);
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/



Step 5
Open includes/page_header.php
Find first entry of:
Code: [Select]
$site_template->register_vars(array(Insert ↑ABOVE↑:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$left = "";
if ($user_info['user_level'] == ADMIN || $user_info['user_dl_limit'] == -1)
{
  $dl_limit = $lang['user_dl_limit_unlimited'];
}
else
{
  $t = ($config['user_dl_time']*60*60) - (time() - $user_info['user_dl_time']);
  if ($t > 0)
  {
    $years = floor($t/31536000);
    $days = floor(($t %= 31536000)/86400);
    $hours = floor(($t %= 86400)/3600);
    $minutes = floor(($t %= 3600)/60);
    $seconds = $t %= 60;
    $t = array($years, $days, $hours, $minutes, $seconds);
    $s = 0;
    for ($i = 0; $i < 5; $i++) {
      if ($t[$i]) {
        $left .= $t[$i]." ".$lang['dates_short'][($t[$i] != 1)][$i];
        $s++;
        $c = 0;
        for ($j = $i + 1; $j < 5; $j++) {
          if ($t[$j]) $c++;
        }
        $left .= " ";
      }
    }
    $left = trim ($left, " ");
  }
  if ($user_info['user_dl_limit'] > $user_info['user_dl_count'] || !$left)
  {
    $dl_limit = preg_replace("/".$site_template->start."dlcount".$site_template->end."/siU", $user_info['user_dl_count'], preg_replace("/".$site_template->start."dltottal".$site_template->end."/siU", $user_info['user_dl_limit'], preg_replace("/".$site_template->start."dltime".$site_template->end."/siU", $left, $lang['user_dl_limit_status'])));
  }
  else
  {
    $dl_limit = preg_replace("/".$site_template->start."dltime".$site_template->end."/siU", $left, $lang['user_dl_limit_reached']);
  }
}
$site_template->register_vars(array(
  "user_dl_count" => ($user_info['user_dl_limit'] == -1) ? 0 : $user_info['user_dl_count'],
  "user_dl_time" => $left,
  "user_dl_limit" => $dl_limit
));
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/



Step 6
Open includes/sessions.php
Find:
Code: [Select]
        $this->delete_old_sessions();
      }
    }
Insert ↓BELOW↓:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
    global $config;
    if ($this->user_info['user_level'] > GUEST)
    {
      if (!$this->user_info['user_dl_limit'] && $this->user_info['user_dl_limit'] != -1)
      {
        $this->user_info['user_dl_limit'] = $config['user_dl_limit'];
      }
      if (!$this->user_info['user_dl_time'])
      {
        $this->user_info['user_dl_time'] = 0;
      }
    }
 
    if ($dl = $this->read_cookie_data('data'))
    {
      $dl = explode(" ", base64_decode($dl));
      if (isset($dl[1]) && $dl[1] && $config['user_dl_time']*60*60 > (time() - $dl[1]))
      {
        $this->user_info['user_dl_time'] = $dl[1];
        $this->user_info['user_dl_count'] = (isset($dl[0]) && $dl[0]) ? $dl[0] : 0;
      }
      else
      {
        $this->user_info['user_dl_time'] = 0;
        $this->user_info['user_dl_count'] = 0;
      }
    }
    elseif ($this->user_info['user_level'] == GUEST)
    {
      $this->user_info['user_dl_count'] = 0;
      $this->user_info['user_dl_time'] = 0;
    }
    if ($this->user_info['user_level'] == GUEST)
    {
      $this->user_info['user_dl_limit'] = $config['user_dl_limit'];
    }
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/
Make sure you inserted the code below two closing brackets and one last (third) bracket must be at the end of the inserted code!



Step 7
Open lang/<your language>/admin.php
At the end, ↑ABOVE↑ closing ?> insert:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
/*-- Setting-Group XX --*/
$setting_group[XX]="User download limit";
$setting['user_dl_limit'] = "Download limit<span class=\"smalltext\"><br />set to <font color=red><b>0</b></font> for unlimited</span>";
$setting['user_dl_time'] = "Reset time<span class=\"smalltext\"><br />(in hours)</span>";
$lang['user_dl_limit'] = "Download limit<span class=\"smalltext\"><br />set to <font color=red><b>0</b></font> to use global settings<br>or <font color=red><b>-1</b></font> for unlimited</span>";
$lang['user_dl_time'] = "Start time";
$lang['user_dl_count'] = "Download count";
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/
Replace XX with the number from Step 3



Step 8
Open lang/<your language>/main.php
At the end, ↑ABOVE↑ closing ?> insert:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$lang['user_dl_limit'] = "Download limit";
$lang['user_dl_time'] = "Start time";
$lang['user_dl_count'] = "Downloads count";
$lang['user_dl_limit_reached'] = "Your download quota per ".$config['user_dl_time']." hours has been reached. You won't be able download for next {dltime}";
$lang['user_dl_limit_unlimited'] = "Your download quota is unlimited";
$lang['user_dl_limit_status'] = "You have downloaded {dlcount} of {dltottal} files, allowed per ".$config['user_dl_time']." hours";
$lang['dl_limit_reached'] = "Sorry, you've reached the download limit per ".$config['user_dl_time']." hours";
$lang['dates_short'] = array(
  array("yr", "day", "hr", "min", "sec"),
  array("yrs", "days", "hrs", "min", "sec")
);
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/



Step 9
Open templates/<your template>/details.html (or any other template, i.e. user_loginform.html/user_logininfo.html)
Insert {user_dl_limit} tag in the place you want to display to the visitors the information about their download limit status. (design is your job :P)



Step 10
Download this (http://www.4homepages.de/forum/index.php?action=dlattach;topic=7701.0;attach=958) installer.
Unpack it and upload dl_limit_install.php file into your 4images root dir.
Execute the installer by typing in your browser's address bar: http://yoursiteaddress/path/to/4images/dl_limit_install.php (make sure you've logged in as admin, otherwise it will not work)

NOTE: during the database installation u might see some "warning" messages on top of the page, that is normal and they should go away after the database updated.
Title: Re: [MOD] Download limit
Post by: ascanio on April 30, 2005, 07:17:05 PM
Nice MOD!!! So if we install this MOD it will work for the MOD of Files list ?
Title: Re: [MOD] Download limit
Post by: renicolay on April 30, 2005, 08:28:51 PM
What can I say but V@no you really are a Hero Member.  Again and again you come through.  This  is a feature I truly need.  Thanks for recovering this lost MOD? I do have one question you may know the answer too.

Is it easy to switch the download limit by hours to limit by days? Or would it be easier to just calculate hours per day X the days I need.  In my case one month. 

Title: Re: [MOD] Download limit v1
Post by: V@no on April 30, 2005, 08:44:37 PM
So if we install this MOD it will work for the MOD of Files list ?
sorry, "the MOD of Files list"? what do u mean?
This mod is an addon to 4images, not an addon to a mod ;)


Is it easy to switch the download limit by hours to limit by days? Or would it be easier to just calculate hours per day X the days I need. In my case one month.
it's easier to calculate it yourself ;)
but if u reall, REALLY want it to, u can replace 60*60 with 60*60*24 in includes/page_header.php and download.php files (obviosly I'm only talking about the new code added from this mod)
Title: Re: [MOD] Download limit v1
Post by: ascanio on April 30, 2005, 09:10:30 PM
Quote
templates/<your template>/details.html  (or any other template)

That's why i said that  :?
Title: Re: [MOD] Download limit v1
Post by: V@no on April 30, 2005, 09:57:52 PM
it will only show on your files page, this mod is not ment to be used for files mod.
Title: Re: [MOD] Download limit v1
Post by: JensF on April 30, 2005, 10:32:14 PM
Hi,

i have insert the Mod and i think it works.

But i have 2 Problems found...

1. I have insert the tag {user_dl_limit} in details.html and in user_logininfo.html but i see nothing!

2. When i have the limit of download i come to the index site. Is there a way to say "You must wait 24 hours to Download more images" ???

*EDIT*

Found anyone:

When i work with the Internet Explorer and i have reached the limit they say me "Sorry, your limit is.....", OK. But they don´t say me "You have downloaded 12 of 20 files, allowed per 24 hours";
Title: Re: [MOD] Download limit v1
Post by: V@no on May 01, 2005, 12:10:34 AM
1. I have insert the tag {user_dl_limit} in details.html and in user_logininfo.html but i see nothing!
some how the tag was altered when I was publishing the mod.
In Step 5 replaced
Code: [Select]
  "dl_limit" => $dl_limit with
Code: [Select]
  "user_dl_limit" => $dl_limit
2. When i have the limit of download i come to the index site. Is there a way to say "You must wait 24 hours to Download more images" ???

*EDIT*

Found anyone:

When i work with the Internet Explorer and i have reached the limit they say me "Sorry, your limit is.....", OK. But they donґt say me "You have downloaded 12 of 20 files, allowed per 24 hours";
just edit language file (main.php) and insert whatever u want it to display.
Title: Re: [MOD] Download limit v1
Post by: JensF on May 01, 2005, 01:01:40 AM
It works. Thanks for this....
Title: Re: [MOD] Download limit v1
Post by: stoneFireX on May 05, 2005, 04:37:52 PM
could anyone help me with this?
I got this message error, and it also said "Your download quota per 24 hours has been reached. You won't be able download for next 23 hrs 44 min 29 sec" when user hasn't download any image yet.

Fatal error: Call to undefined function: set_cookie_data() in /home/vietori/public_html/forums/4images/download.php on line 75


Title: Re: [MOD] Download limit v1
Post by: V@no on May 05, 2005, 08:19:05 PM
if u are using any sort of integrations (phpbb, vbulletin, etc) u are on your own there.
Title: Re: [MOD] Download limit v1
Post by: Xandra on May 17, 2005, 04:06:44 PM
Hi V@no

Thank you so much for this mod (the only 1 that went without a hitch  :) - so far)

I do have a question though - is there a way to set various download limits per usergroup? Because this MOD only applies to ALL registered users (guests do have the limit but once they clear their cookies, their limit is back again - but this is not a problem :))

I really hope you could help me with this one.

TYVM in advance.

Xandra
Title: Re: [MOD] Download limit v1
Post by: V@no on May 18, 2005, 12:39:25 AM
sorry, usergroups are not supported, only per-user.
Title: Re: [MOD] Download limit v1
Post by: Xandra on May 18, 2005, 12:40:51 PM
sorry, usergroups are not supported, only per-user.

thanks for replying. Do you mean it is possible to set different download limits PER USER though? All I could see is the same limit for ALL users.
Title: Re: [MOD] Download limit v1
Post by: V@no on May 18, 2005, 02:43:11 PM
if u installed the mod properly and go to edit a user in ACP, then u should be able see new fields for download limit.
Title: Re: [MOD] Download limit v1
Post by: Xandra on May 18, 2005, 03:25:43 PM
if u installed the mod properly and go to edit a user in ACP, then u should be able see new fields for download limit.

I am pretty sure I did it right. When I go to "edit user" I have the following fields with the options:

Quote
Download limit
set to 0 to use global settings
or -1 for unlimited

so 2 options are available - if I use 0, the user will have the global settings for the dl limit and -1 for unlimited

now let us say,

I would like User X to have 30 downloads per day as limit and User Z to have 50 downloads per day - is there a way to do this? (hoping badly there is lol)
Title: Re: [MOD] Download limit v1
Post by: V@no on May 19, 2005, 12:11:45 AM
Thats a tricky question! :lol:
but seriosly if u set it to 30 the user will have max of 30 downloads, if u set to 50, then max of 50 downloads...
Title: Re: [MOD] Download limit v1
Post by: Xandra on May 19, 2005, 12:17:18 AM
Thats a tricky question! :lol:
but seriosly if u set it to 30 the user will have max of 30 downloads, if u set to 50, then max of 50 downloads...

Hehe, not really a tricky one. I thought I only have TWO choices: 0 or -1. Never attempted to set a diff number. TYVM I will try that out. :mrgreen:
Title: Re: [MOD] Download limit v1
Post by: dj9live on July 19, 2005, 11:31:52 PM
could it be easy to change this mod to set the download limit with the number of uploaded files

when user a upload 1 pic the download limit gets bigger like a ratio or a credit system, i have seen some pepople asking about this, but i didtn find a solution 4 this. but i guess a little modification of the mod will bring the effect. what do you mean?

thnx kai
Title: Re: [MOD] Download limit v1
Post by: V@no on July 20, 2005, 12:43:58 AM
could it be easy to change this mod to set the download limit with the number of uploaded files
that would be a completly different mod.
Title: Re: [MOD] Download limit v1
Post by: dj9live on July 20, 2005, 01:10:55 PM
i know, but is there a way to do it together ???
Title: Re: [MOD] Download limit v1
Post by: ID25 on August 11, 2005, 04:50:12 PM
Nice mod, but those limitations work with sessions/cookies,
maybe who know, how to made with IP adresses?
there is better thing :!:
Title: Re: [MOD] Download limit v1
Post by: ID25 on August 14, 2005, 05:39:48 PM
at first: there is no "detail.php" --> "details.php"
in details.php i dont found:
show_image($image_row, $mode, 0, 1, 1);
there is:
Code: [Select]
show_image($image_row, $mode, 0, 1);

in 1.7 and 1.7.1 versions
Title: Re: [MOD] Download limit v1
Post by: V@no on August 14, 2005, 05:45:40 PM
thank you. I've fixed the tutorial :)
Title: Re: [MOD] Download limit v1
Post by: ID25 on August 14, 2005, 07:01:38 PM
But you don't made this MOD with IP :)
just sessions, you know... sessions or cookies bad idea..
Title: Re: [MOD] Download limit v1
Post by: V@no on August 14, 2005, 07:17:17 PM
trust me, if one knows how to manipulate with cookies, they would know how to use proxy, wich makes restrictions by IP useless as well ;)
Title: Re: [MOD] Download limit v1
Post by: ID25 on August 14, 2005, 09:13:02 PM
but found many working proxies is harder, than clear cookies
need many time to change proxy and etc...
Title: Re: [MOD] Download limit v1
Post by: srijit on August 25, 2005, 08:29:36 AM
dear v@no thank you very much for this mod. i do have a doubt though. if the user adds the pics to his lightbox, will that also be counted when he downloads all images in lightbox at a time? and also when he downloads from lightbox as zip? thanks for all the trouble :)
Title: Re: [MOD] Download limit v1
Post by: miralin on August 26, 2005, 10:14:06 PM
Great mod!
Unfortunately  though I'm having trouble installing it...
I get to the step 10 in the tutorial but I cant get the installation to start.
When I type in the address for the 'dl_limit_install.php' file nothing happens,
I just get redirected to my index page...

I have double checked
1.) that I have made all the changes required for the mod to work
2.) that I have uploaded all the modified files =)
3.) that the 'dl_limit_install.php’ file is unziped and uploaded where it should be.
4.) and yes I’m logged in as admin

I cant seem to figure out what I’m missing or what I’m doing wrong.

/Malin
Title: Re: [MOD] Download limit v1
Post by: Xyu BAM on August 27, 2005, 01:05:22 AM
when u browse your site while being logged in as admin, do u see sessionid=j3h4k23h4l2 in the address bar and all links on the page?
if so, then u must also include that sessionid to the url for dl_limit_install.php
like this: http://example.com/4images/dl_limit_install.php?sessionid=3k4jh23k4h32k4h2
Title: Re: [MOD] Download limit v1
Post by: miralin on August 27, 2005, 09:39:24 AM
when u browse your site while being logged in as admin, do u see sessionid=j3h4k23h4l2 in the address bar and all links on the page?
if so, then u must also include that sessionid to the url for dl_limit_install.php
like this: http://example.com/4images/dl_limit_install.php?sessionid=3k4jh23k4h32k4h2


Yes I see session id in the addressbar.
I tried to include it in the url but it hasn't helped
I still get redirected to the index page...


/Malin
Title: Re: [MOD] Download limit v1
Post by: V@no on September 22, 2005, 02:51:33 AM
and when you get redirected, do u remain logged in as admin? if not - that' is the problem.
Title: Re: [MOD] Download limit v1
Post by: kief24 on October 09, 2005, 09:22:37 PM
Hello,

the mod works fine. ... thanks again  !

I was just wondering,
if a user makes two accounts, and activates them trough email, he can download 2X the limit set by administrator ?

 
Title: Re: [MOD] Download limit v1
Post by: V@no on October 09, 2005, 10:32:27 PM
yes
Title: Re: [MOD] Download limit v1
Post by: kief24 on October 12, 2005, 11:18:51 PM
on my site, the limiter doesn't count the files downloaded from the lightbox.
Is this normal ?
Title: Re: [MOD] Download limit v1
Post by: V@no on October 13, 2005, 12:01:39 AM
maybe missed step 2.2 or 2.7 ?
Title: Re: [MOD] Download limit v1
Post by: kief24 on October 13, 2005, 11:02:38 AM
reinstalled it, and now it works.

thx !

but i think i found a "backdoor" in the system

let's say the downloadlimit is 30 pics in 24 hrs.
I download 25 pics
and i put 20 pics in my lightbox

I am able to download the 20 pics in the lightbox.

(After that, i can't download anymore.)

But so i still can download 45 pics. ( or any number if i download them from the lightbox before the limit is reached )

am i right ?

Title: Re: [MOD] Download limit v1
Post by: V@no on October 13, 2005, 02:27:13 PM
Mmmm...not supposed to happend. If mod installed properly, it would only add 5 images in the zip when you download your lightbox (in this example)
Title: Re: [MOD] Download limit v1
Post by: kief24 on October 13, 2005, 06:06:42 PM
Logged in as administrator it seems that i can download more than limited
normal registered users can't.
So for me the problem is solved !
thx !
Title: Re: [MOD] Download limit v1
Post by: V@no on October 13, 2005, 11:52:04 PM
Logged in as administrator it seems that i can download more than limited
normal registered users can't.
So for me the problem is solved !
thx !
yes, that is normal, IMO admins should not have any restrictions on their sites ;)
Title: Re: [MOD] Download limit v1
Post by: marius26 on November 06, 2005, 11:29:07 PM
it seems to be a good script please sign up so i can test it  :lol: limit is curently 10 so you can test it guys. any feedback is welcome.
Title: Re: [MOD] Download limit v1
Post by: sigma on November 13, 2005, 04:44:47 PM
I have a question.

Insted of 24 hour limit would it be possible to set a total download number limit. After they have downloaded the alloted number of images they need to subscribe to a different service. Is there an easy adjustment for this sort of method? not time based, just number based?
Title: Re: [MOD] Download limit v1
Post by: V@no on November 13, 2005, 05:04:09 PM
mmmmm...add 99999999 minutes?
Title: Re: [MOD] Download limit v1
Post by: sigma on November 13, 2005, 05:10:14 PM
lol. i guess i should of installed it before askin the question.
Title: Re: [MOD] Download limit v1
Post by: sigma on November 13, 2005, 09:35:10 PM
hmm.

So heres what I want to do.

- Registered users get 50 free downloads.
- After they reach 50 they are asked to Subscribe to another service which gives them unlimited Downloads for 3 months.

1. How can I remove the 'time' value and just display the number of downloads still available.
2. How can I setup an unlimited download option for a certain user group.

Is this too much for this mod? I can live without #2 but #1 would be a nice to have.
Title: Re: [MOD] Download limit v1
Post by: V@no on November 13, 2005, 10:18:45 PM
edit language file (main.php)
Title: Re: [MOD] Download limit v1
Post by: binuj01 on November 14, 2005, 04:08:26 AM
HAi V@no,
 Can you design a mode that allows a specific number of downloads with user groups.

For example:= I set up a usergroup in 4images that allows 10 downloads from any category. Another usergroup allows 20 downloads from any category.

As soon as the downloads are used up the mebership expires.

This would be a great useful MOD.

CAn u help,

Regards
Binu
Title: Re: [MOD] Download limit v1
Post by: Pop_Black on November 17, 2005, 01:51:09 AM
Hi V@no,
I want to change default download = 5 (Not 50)
Please help Me :wink:
Title: Re: [MOD] Download limit v1
Post by: V@no on November 17, 2005, 03:49:10 AM
Please help Me :wink:
with what? :?
Did u look in the settings? ;)
Title: Re: [MOD] Download limit v1
Post by: kj_4fire on December 03, 2005, 03:13:37 AM
how can't i change the global setting? I can't change the # 50 dl limits :roll: Please help, thanks  :P
Title: Re: [MOD] Download limit v1
Post by: V@no on December 03, 2005, 04:02:11 AM
then obviously you did something wrong. Now, put yourself on our possition and read your "description" of the problem again - would you able to help someone with as much information as you've provided? - doubtfull.
Title: Re: [MOD] Download limit v1
Post by: kj_4fire on December 03, 2005, 05:58:25 AM
Well, i have rechecked the problem many times and everything has worked fine except not being able to change the global setting. I went to Admin CP-->setting-->limit dowload setting-->changing #50 to other number-->save changes. Unfortunately, after i submit, #50 is still there. That is exactly what my problem is. Thanks for your help.   :wink:


(http://www.cafequan.net/upload/data/media/1/gallery_.jpg)
Title: Re: [MOD] Download limit v1
Post by: V@no on December 03, 2005, 09:39:33 AM
hmmm...are you absolutly sure that the database was updated? try run the installer again...

P.S. just in case, clear your browser cache and cookies ;)
Title: Re: [MOD] Download limit v1
Post by: fult5000 on December 12, 2005, 05:05:48 PM
hallihallo,

ich habe eine kleine fotodatenbank. http://www.fult.de.
jetzt habe ich den mod installiert und wie im forum die php dateien geändert. leider ging alles voll daneben.

so sieht meine änderung aus. was habe ich falsch gemacht?

//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
$image_allow_comments = (check_permission("auth_readcomment", $cat_id)) ? $image_row['image_allow_comments'] : 0;
$image_name = htmlspecialchars($image_row['image_name']);
show_image($image_row, $mode, 0, 1);
/*
MOD DOWNLOAD LIMIT
BEGIN INSERT
*/
if ($msg_error = $site_sess->get_session_var("msg_error"))
{
$msg .= ((empty($msg)) ? "" : "<br />").stripslashes($msg_error);
$site_sess->drop_session_var("msg_error");
}
/*
MOD DOWNLOAD LIMIT
END INSERT
*/
$in_mode = 0;
Title: Re: [MOD] Download limit v1
Post by: fult5000 on December 12, 2005, 06:08:21 PM
so, jetzt bekomme ich die fehlermeldung :


Parse error: parse error, expecting `')'' in /home/imorde.com/htdocs/images/4images/includes/page_header.php on line 90

ich wüsste nicht was ich bei der änderung falsch gemacht haben soll?
Title: Re: [MOD] Download limit v1
Post by: mawenzi on December 12, 2005, 06:12:38 PM
@ fult5000

... na vergleiche doch nochmals in page_header.php in der Zeile 90 deinen Code mit dem Original des MODs ... `')''

mawenzi
Title: Re: [MOD] Download limit v1
Post by: fult5000 on December 12, 2005, 07:53:55 PM
super, ich hatte den fehler gemacht es drunter ein zu fühgen statt wie beschrieben drüber  :mrgreen:

jetzt hätte ich noch ne frage. z.z wird mir angezeit das ich 1 von 5 bilder heruntergelanden haben. dann 2 von 5 u.s.w. . besteht die möglichkeit das mir die differenz angezeigt wird. sie können noch "x" bilder herunter laden?

mfg,

markus!
Title: Re: [MOD] Download limit v1
Post by: kj_4fire on December 23, 2005, 02:55:46 AM
hmmm...are you absolutly sure that the database was updated? try run the installer again...

P.S. just in case, clear your browser cache and cookies ;)

Thanks V@no, i figure it out now  :wink:
Title: Re: [MOD] Download limit v1
Post by: fult5000 on December 31, 2005, 01:18:57 AM
try run the installer again...

   1. Error: Duplicate column name 'user_dl_limit'

   2. ALTER TABLE `imorde_com_users` ADD `user_dl_limit` mediumint(5) NOT NULLError: Duplicate column name 'user_dl_time'

   3. ALTER TABLE `imorde_com_users` ADD `user_dl_time` int(11) NOT NULL default '0'Error: Duplicate column name 'user_dl_count'

   4. ALTER TABLE `imorde_com_users` ADD `user_dl_count` mediumint(5) NOT NULLError: Duplicate entry 'user_dl_limit' for key 1

   5. INSERT INTO `imorde_com_settings` ( `setting_name` , `setting_value` ) VALUES ('user_dl_limit', '50')Error: Duplicate entry 'user_dl_time' for key 1

      INSERT INTO `imorde_com_settings` ( `setting_name` , `setting_value` ) VALUES ('user_dl_time', '24')
Title: Re: [MOD] Download limit v1
Post by: JensF on December 31, 2005, 01:26:06 AM
Delete the ´user_dl_limit´ manuell in your database and then run the installer again ;)
Title: Re: [MOD] Download limit v1
Post by: V@no on December 31, 2005, 01:31:42 AM
Nothing needs to be deleted or updated...the database is ready now.
Title: Re: [MOD] Download limit v1
Post by: fult5000 on December 31, 2005, 01:55:03 AM
 :twisted: super!
Title: Re: [MOD] Download limit v1
Post by: Agreed2it on January 05, 2006, 09:07:54 AM
I got kind of lost. I want to set the download limit to be by the week. So they only say get 100 downloads per week. How would I do this? Does it have to be by how many hours are in a week, how many minutes? And where do I put the number I have calculated once I have it.
Title: Re: [MOD] Download limit v1
Post by: V@no on January 05, 2006, 02:46:17 PM
In the settings you put number 7 (7 days a week)
Title: Re: [MOD] Download limit v1
Post by: Agreed2it on January 07, 2006, 01:36:01 PM
Which settings? Oh boy sorry I installed this awhile ago, and I've completely blanked on it's set up.
Title: Re: [MOD] Download limit v1
Post by: renicolay on January 07, 2006, 05:06:14 PM
Which settings? Oh boy sorry I installed this awhile ago, and I've completely blanked on it's set up.

Open your 4Images control panel and click settings.  From there scroll down to User Download Limit and set the Reset Time to 168 (which is 24*7) then set Download limit to 100.  The time should begin after their first download.  That should do the trick.

Title: Re: [MOD] Download limit v1
Post by: binuj01 on January 17, 2006, 06:19:35 AM
Hai Vano,
 I installed this MOD and everything seems to work fine.except when I change the no: of files to be downloaded ( example..7) , and after I log in as that user the Download button is ghosted and the download tag message says" You have downloaded 7 out of 50 files allowed.". This happens just after signing and and even without downloading a single file.
What could be wrong?
Thanks
Binu
Title: Re: [MOD] Download limit v1
Post by: V@no on January 17, 2006, 06:24:13 AM
hmmm....can you confirm one more time with another user?
I'd like to see it in action...
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 20, 2006, 03:14:38 AM
Hi,

I haven’t installed this Mod yet but by reading the while thread, what I got is it set limits of download by per registered user.

Can it be done the following way??

Limit Guest to download only 10 Images per 24 hours and unlimited downloads for registered member. 

If the limit can be set by group not by member it will be the best option.

Would it be too difficult to do that ?? 
Title: Re: [MOD] Download limit v1
Post by: V@no on January 20, 2006, 05:13:36 AM
This mod does not support usergroups.
You can give unlimited downloads for registered members by replacing in includes/funcitons.php:
Code: [Select]
  if ($user_info['user_level'] == ADMIN) return;with this:
Code: [Select]
  if ($user_info['user_level'] >= USER) return;
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 20, 2006, 08:18:09 AM
Group thing was not that important. I just thought it would make things easier.

The important thing to me is
Limit Guest to download only 10 Images per 24 hours  ??

Would it be possible ??  How ?
Title: Re: [MOD] Download limit v1
Post by: V@no on January 20, 2006, 02:03:58 PM
just set the settings you want and do the modification I've posted above.
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 20, 2006, 11:16:44 PM
Hi V@no

Just a little issue  i came up with.
In my download.php file

The code from step 2.1
Code: [Select]
while ($image_row = $site_db->fetch_array($result)) {  I have this code three times.

From step 2.2
Code: [Select]
$file_added = 1;  I have this code two times.

From step 2.3
Code: [Select]
  $file['file_size'] = strlen($file['file_data']);
    }
    else {
      header("Location: ".$site_sess->url($url, "&")); 
I have this code two times.

Now should i apply the changes to all of them or is it a particular one ??
 
I am attaching my download.php if u would like to have a look.
Title: Re: [MOD] Download limit v1
Post by: V@no on January 21, 2006, 01:25:05 AM
Now should i apply the changes to all of them or is it a particular one ??
In your particular case, yes, apply to all of them. Its your "page download" mod interferencing ;)
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 21, 2006, 03:45:36 AM
Thanks V@no, Its working fine except for two things.

1) When user is off the limit but he still try to download a file, he get redirect back to home page when using IE.
    I tried it with Fire Fox and I get blank page after that.
   Is it possible that instead of redirect back to home page, a message box appear saying that u must be a register member.
   (Or something else)

2) Now the big issue, I installed your Mod [MOD]-BETA Whole/part category download two days back and it is working just fine.
 Now the problem is, when being off limit, I try to download a page it gives database error.
Quote
DB Error: Bad SQL Query: SELECT cat_id, image_media_file, image_download_url FROM 4images_images WHERE image_active = 1 AND image_id IN () AND cat_id IN (0, 22, 13)
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND cat_id IN (0, 22, 13)' at line 3

I tested it with download limit of three. First it download a zip file with three files which is good. But with second attempt it gives this error.

I have gone throw all the steps of these two mods but still the same situation. That means these two mods have some trouble with each other.

//Edited (Posted In Next Post)
Title: Re: [MOD] Download limit v1
Post by: TheOracle on January 21, 2006, 03:55:12 AM
The issue is from your download.php file where :

Quote

$sql = "SELECT cat_id, image_media_file, image_download_url
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id IN (".get_auth_cat_sql("auth_download").")";
  $result = $site_db->query($sql);


Would it be possible to post your paragraph to see where the error could be specificly ? ;)

Note: Post modified above from user after this one was posted.
Title: Re: [MOD] Download limit v1
Post by: V@no on January 21, 2006, 04:17:14 AM
1) 4images is using HTTP_REFERER header and if you have a privacy control software that is blocking referral page you came from, 4images will not work properly on 100%. It sounds like your case.

2) Try to insert in download.php above
Code: [Select]
  $sql = "SELECT cat_id, image_media_file, image_download_url this line:
Code: [Select]
  if (empty($image_id_sql))
  {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 21, 2006, 09:57:28 AM
With above modification, I m no more getting this DB error while using IE. That means for IE its now working fine.
But with Firefox, its still there. I tried many times clearing my internet history, clearing cache but no change.
Its strange but its happening.

I don’t have any privacy software, no proxy thing not even any anti virus software.
What could be the reason if its not by the script ?

Secondly, Is it possible to show a Message box to user instead of redirecting to the main page ? They will never know what caused them redirect to main page if using page download Mod.

One more thing. As you suggested before to change this line
Code: [Select]
if ($user_info['user_level'] == ADMIN) return; in functions.php to give Register users unlimited downloads.

The only closest thing that i have in my functions.php is this
Code: [Select]
if ($user_info['user_level'] == ADMIN)
  {
    $return = true;
    foreach ($types as $key)
    {
      if (isset($HTTP_GET_VARS[$key]) && $$key = $HTTP_GET_VARS[$key]) $return = false;
      else $$key = "";
    }
    if ($return) return false;
    $force = true;
  }
Which is inside check_ban() function.  (From "[MOD] Ban v1.6.1" by U )
Dont you think changing this will remove the ban from user ??? Or cause any trouble ? 

@ TheOracle 
My whole download.php file is attached.
Title: Re: [MOD] Download limit v1
Post by: V@no on January 21, 2006, 05:58:58 PM
Ok
1) if you are trying download single image while your download limit is reached (from details page), does it redirects you to index.php too?
2) you can try insert below
Code: [Select]
elseif ($action == "page") {this line:
Code: [Select]
  $url = (empty($url)) ? ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id : $url;Then in categories.php above
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
insert this:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
if ($msg_error = $site_sess->get_session_var("msg_error"))
{
  $msg .= ((empty($msg)) ? "" : "<br />").stripslashes($msg_error);
  $site_sess->drop_session_var("msg_error");
}
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 21, 2006, 08:47:46 PM
Quote
1) if you are trying download single image while your download limit is reached (from details page), does it redirects you to index.php too?
Yes It deos. Infect in all three cases ( WIth Lightbox, SIngle file download or with category page download) it redirects to the main page when users is off the limit. BUT this happen only with IE

WIth FireFox, it gives a blank page In first two cases and for page download it still gives the DB error message.

I have done the changes u mentioned above (The last one) But still its the same no difference at all.
Title: Re: [MOD] Download limit v1
Post by: ato on January 22, 2006, 08:25:10 PM
Hi V@no,

das funktioniert sehr gut.
aber was muss ich machen,um das Automatische nicht mehr zu entsteht (sieht link) ?, und die Mitglieder kann nur ein *.gif Bild speichern (wie deine Seite)

http://fire.prohosting.com/nlminh/img/123.jpg oder http://nlminh.com.co.nr/img/123.jpg
Title: Re: [MOD] Download limit v1
Post by: V@no on January 22, 2006, 08:31:47 PM
find a topic "pic security" its all there ;)
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 22, 2006, 10:40:33 PM
I am stuck with it. Still redirecting using IE and still giving DB error message with FireFox. I don’t know what’s the big difference between the two explorers but I cant understand why its showing DB error message.

If for now, I put aside the redirect issue (Its important but not that much)
V@no could you please have a look and see why its giving DB error message?? 

Can I PM you the URL  (If u need) ?
Title: Re: [MOD] Download limit v1
Post by: V@no on January 22, 2006, 10:49:43 PM
Can I PM you the URL (If u need) ?
Please do
Title: Re: [MOD] Download limit v1
Post by: V@no on January 23, 2006, 12:31:41 AM
With above modification, I m no more getting this DB error while using IE. That means for IE its now working fine.
But with Firefox, its still there. I tried many times clearing my internet history, clearing cache but no change.
Its strange but its happening.
Actualy the error showed in both browser, its just IE was obeying the redirect header, while FF ignoring it. I've updated the code above that should fix it.

There something else you did in global.php (I asume) that causes the wrong redirection.
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 23, 2006, 12:02:10 PM
Here is the update.

By adding this
Code: [Select]
  if (empty($image_id_sql))
  {
    header("Location: ".$site_sess->url($url, "&"));
    exit;
  }
I no more get DB error message. Thanks V@no for helping me out.

Now could please guide me here, where should I start digging into this problem.
Why it get redirect to main page using IE? And get a Blank page using any other browser. ( I just found out that it happens with Opera as well)
I just want to show an error message just like when u right click on the pic.

What exactly the code statement that is used to redirect (so that i can double check it)??
By the way, Is it the default way or I m the only victim here?

Quote
There something else you did in global.php (I asume) that causes the wrong redirection.

V@no I compared it with the new 1.7.1 version file. It’s exactly the same.  I haven’t changed anything is this file.

Title: Re: [MOD] Download limit v1
Post by: V@no on January 23, 2006, 02:29:26 PM
V@no I compared it with the new 1.7.1 version file. It’s exactly the same.  I haven’t changed anything is this file.
Then I see you are using the "search engine friendly url" mod. Did you change it's code so it would replace index.php with empty string? if so, try make it replace index.php with ./ instead.
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 23, 2006, 04:14:07 PM
V@no, Thanks a million

Its been two days now and I was trying everything, looking into page_header.php and function.php files, finding some clue that could solve the issue.
Mainly I was looking for this line and trying to get some idea. I believe this calls for redirect. 
Code: [Select]
header("Location: ".$site_sess->url($url, "&")); But I guess I was looking in wrong place with wrong code.

Just incase, if someone is interested (got the same issue) ,
 I replaced
Code: [Select]
if (strstr($url, 'index.php')) {
        $url = str_replace('index.php', '', $url);
With
Code: [Select]
if (strstr($url, 'index.php')) {
        $url = str_replace('index.php', './', $url);
in include/sessions.php file and now i am no more getting blank page with FF and Opera. (Both now redirect to main page)

Once again, Thanks for helping me out.
Title: Re: [MOD] Download limit v1
Post by: TheOracle on January 23, 2006, 04:55:37 PM
@Fastian:

It could also be stated like this :

Code: [Select]

if (strstr($url, 'index.php')) {
        $url = str_replace('index.php', ROOT_PATH, $url);


;)
Title: Re: [MOD] Download limit v1
Post by: V@no on January 24, 2006, 02:42:50 AM
@Fastian:
You've solved only half of the mistery..the another half is - why it redirects to index page and not to the last visited...
For testing purpose, in download.php below <?php insert this:
Code: [Select]
echo "<pre>";
print_r($_SERVER);
exit;
Now, open image details page and click download button. It should show you some stuff on blank page, check if you get [HTTP_REFERER] => some address
If you do, then in global.php above
Code: [Select]
if (defined("SCRIPT_URL") && SCRIPT_URL != "") { insert:
Code: [Select]
echo $url;
Then on every page you go, it should show you on top the previous page URL and not url to index.php
If all that is correct, then there is somewhere in other files you've modified, variable $url is being altered...that what you should start digging ;)


@Fastian:

It could also be stated like this:
Its not recommended, because in ACP ROOT_PATH is different.
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 26, 2006, 03:22:12 PM
First of all, Sorry for replying that late.
@Fastian:
For testing purpose, in download.php below <?php insert this:
Code: [Select]
echo "<pre>";
print_r($_SERVER);
exit;

Yes I do see [HTTP_REFERER] => some address With some other info. And that address is the one from where i click the download button.

@Fastian:
If you do, then in global.php above
Code: [Select]
if (defined("SCRIPT_URL") && SCRIPT_URL != "") { insert:
Code: [Select]
echo $url;
Then on every page you go, it should show you on top the previous page URL and not url to index.php

When i do this, i get
Code: [Select]
index.php
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/domain/public_html/wallpapers/global.php:232) in /home/domain/public_html/wallpapers/includes/sessions.php on line 100
And then on every page i Visit that index.php is there along with the warning message.

Quote
If all that is correct, then there is somewhere in other files you've modified, variable $url is being altered...that what you should start digging ;)
Now should i start digging  ?? If so, give me some idea, what kind of modification it could be ?
Title: Re: [MOD] Download limit v1
Post by: TheOracle on January 26, 2006, 03:24:21 PM
Quote

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/domain/public_html/wallpapers/global.php:232) in /home/domain/public_html/wallpapers/includes/sessions.php on line 100


It looks like you uploaded your files in binary mode (or perhaps on auto-mode but was automatically considered as binary mode during the transfer of your files). If it's the case, you might want to manually switch to ASCII mode in order to get rid of these errors in the future. ;)
Title: Re: [MOD] Download limit v1
Post by: V@no on January 26, 2006, 03:33:41 PM
Try add the echo $url; above:
Code: [Select]
if ($url == $self_url || $url == "" || !preg_match("/\.php/", $url)) {
Still, I'd like to test it myself ;)


It looks like you uploaded your files in binary mode (or perhaps on auto-mode but was automatically considered as binary mode during the transfer of your files). If it's the case, you might want to manually switch to ASCII mode in order to get rid of these errors in the future. ;)
Please, stop guessing! you are not following this disscussion and your input is not neccery, especialy when you dont realy know what's goin on.
Title: Re: [MOD] Download limit v1
Post by: TheOracle on January 26, 2006, 03:37:16 PM
Quote

you are not following this disscussion and your input is not neccery


http://www.4homepages.de/forum/index.php?topic=11326.msg58688#msg58688

 :roll:
Title: Re: [MOD] Download limit v1
Post by: V@no on January 26, 2006, 03:46:23 PM
http://www.4homepages.de/forum/index.php?topic=11326.msg58688#msg58688
Thank you for confirming my point - you dont know what is going on here. And one more time emmberassed yourself.
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 26, 2006, 04:11:59 PM
V@no
I just send u a PM  :)
Title: Re: [MOD] Download limit v1
Post by: TheOracle on January 26, 2006, 04:22:29 PM
Quote

And one more time emmberassed yourself.


If I were really embarassed, I wouldn't quite resolved the same issue on that other topic.  :mrgreen:
Title: Re: [MOD] Download limit v1
Post by: V@no on January 27, 2006, 12:37:28 AM
V@no
I just send u a PM :)
Ok, I found the problem. The mod_rewrite mod you are using has a side effect...I didnt even know about it till now.
So, since you are using .htm instead of .php extensions, you'll need replace in global.php:
Code: [Select]
if ($url == $self_url || $url == "" || !preg_match("/\.php/", $url)) {with this:
Code: [Select]
$ext = strtolower(substr(strrchr($url,"."), 1));
$ext = substr($ext,0,(strlen($ext)-strlen(strrchr($ext,"?"))));
if ($url == $self_url || $url == "" || ($ext != "php" && $ext != "htm")) {

P.S.
you can remove the echo thingie ;)

If I were really embarassed, I wouldn't quite resolved the same issue on that other topic. :mrgreen:
So, the only reason you showed that URL was to show that once you were actualy correct? man, you have issues...
STOP THE SPAM!
Title: Re: [MOD] Download limit v1
Post by: Fastian on January 27, 2006, 06:13:01 AM
Thanks V@no
Now its working just fine. No more redirects to home page. The above code works well.

Ok, I found the problem. The mod_rewrite mod you are using has a side effect...I didnt even know about it till now.
So, since you are using .htm instead of .php extensions, you'll need replace in global.php:

Well I guess changing the default way of displaying pages has it's price. I hope nothing more is coming from that mod  :)
Title: Re: [MOD] Download limit v1
Post by: kj_4fire on January 30, 2006, 08:36:03 AM
I have problem here. Sometime, the download limit doesn't work due to the cookie. It means users can download as many as they want although i set the limit. I have tested it myself. After I clear the cookie, the download limit works again. Is there anyway to prevent it? :D thanks
Title: Re: [MOD] Download limit v1
Post by: V@no on January 30, 2006, 02:21:50 PM
Is there anyway to prevent it?
No, untill you write detailed step-by-step instructions how to reproduce it...
Title: Re: [MOD] Download limit v1
Post by: ladyoz on March 15, 2006, 06:55:57 PM
Will this mod work in the new 1.7.2? Thanks  :D
Title: Re: [MOD] Download limit v1
Post by: renicolay on March 18, 2006, 06:01:24 PM
I'm also wondering if this mod will work with 1.7.2.  I would like to upgrade.  Does anyone know?
Title: Re: [MOD] Download limit v1- is there an update for v1.7.2?
Post by: ladytaz on March 22, 2006, 08:37:46 PM
Nevermind ..... I got it to work, I figured it out myself.   :D :wink:



Enquiring minds would really like to know ...  :wink:

I attempted to add it to v1.7.2, but at least one of the files is a bit different.  I tried to improvise, but it did not fully work.
The mod shows up, but does not count down, downloads stays at 0, nor will it stop downloads at the cut off limit.  :?
Title: Re: [MOD] Download limit v1
Post by: antonio2005 on March 25, 2006, 08:31:16 PM
Hi,

Cant find code at step Step 2.3.
I'm running version 1.7.2.

Is there a problem with my php file, or the mod was designed to another version?

Regards
Title: Re: [MOD] Download limit v1
Post by: V@no on March 25, 2006, 09:27:45 PM
Sorry, this mod does not support v1.7.2 (yet) download.php files was significaly changed in that version...
Title: Re: [MOD] Download limit v1
Post by: renicolay on March 26, 2006, 04:37:36 AM
OK, thanks V@no!
Title: Re: [MOD] Download limit v1
Post by: wallpapers on March 26, 2006, 05:42:55 PM
Hello V@no

I can't find the code in step 2.3
Code: [Select]
      $file['file_size'] = strlen($file['file_data']);
    }
    else {
      header("Location: ".$site_sess->url($url, "&"));
I will use on my new site,
it is version 1.7.2 i know there are some changes.
mayby you can update the mod to 1.7.2  :roll:

thanks  :D
Title: Re: [MOD] Download limit v1
Post by: V@no on March 26, 2006, 07:06:34 PM
Ok guys, I've added new steps 2.3.1, 2.4.1 and 2.5.1 for 4images v1.7.2 only (I did not have time to fully test it, but I'm pretty sure it should work fine ;))

Also, please note, if a step specifyed 4images version, then you should use that step only if your version is matching, otherwise skip that step.
Title: Re: [MOD] Download limit v1
Post by: binuj01 on March 28, 2006, 05:36:06 PM
I have done this MOD for ver 1.72. Everything is working fine, except that when  I give the dowload limit as 5, it takes only four.
What could be the problem?
Thanks
Binu
Title: Re: [MOD] Download limit v1
Post by: V@no on March 29, 2006, 02:02:57 AM
and if you set it to 10? how do you download the files when testing? how much does it show before you start download? pay attention to the download counter, does it show the correct number all the time?
Title: Re: [MOD] Download limit v1
Post by: binuj01 on March 29, 2006, 06:31:24 AM
Ok. I think that was a problem with the cookies in my computer. When I tried that from another computer, it was working fine.

But I need one help. I think that many users may click on the download link of an image, more than once . Can we make the script allow the same file to be clicked more than once, or even download more than once without affecting the counter. It is because a user may have a broken download, in that case he can download the same image again.
Thanks
Binu
Title: Re: [MOD] Download limit v1
Post by: V@no on March 29, 2006, 07:17:02 AM
hmmmm...this is a very good idea, I'll see what I can do ;)
Title: Re: [MOD] Download limit v1
Post by: binuj01 on April 12, 2006, 08:22:10 AM
hmmmm...this is a very good idea, I'll see what I can do ;)
Hai Vano,
Is there any progress? Just curious?
Thanks
Binu
Title: Re: [MOD] Download limit v1
Post by: True4 on June 04, 2006, 03:53:25 PM
by the admin tool for user
what time is "Start time"
$lang['user_dl_time'] = "Start time";

Should I write in the Start Time (in Admin Tool)
2006-06-04
because the user started at this time
or what

but if i write this, than by the next time the field is only "2006"

I'm confused, what ist Start Time?
Title: Re: [MOD] Download limit v1
Post by: V@no on June 04, 2006, 07:44:22 PM
You should not change the start time, its only used by the script to store when the first image downloaded. basicaly it holds PHP time stamp http://php.net/manual/en/function.time.php
Title: Re: [MOD] Download limit v1
Post by: Ch*yeuk on July 17, 2006, 11:08:17 PM
Awesome mod and clear instructions. Installed it and everything's working.
Title: Re: [MOD] Download limit v1
Post by: sajwal on July 19, 2006, 03:20:40 PM
Hi v@no,
           I downloaded this mod and applied to 1.7.3 , but i cannot see anything when i paste {user_dl_limit} in
userlogininfo.html or
userloginform.html or
 details.html .

i have seen you solving smilar query for other : u said u changed step 5



          I used to have this mod perfectly working with 1.7.2 two days back but now its not working . ... it redirects me to the indexpage when i try downloading and on clicking again it shows me just a message that :
Sorry, you've reached the download limit per hours

But in 1.7.2 i used to see the no. of downloads done and time left for more downloads..

IS THIS MOD NOT FOR 1.7.3?

Please help
Title: Re: [MOD] Download limit v1
Post by: V@no on July 20, 2006, 07:16:51 AM
I dont see anything in the code that would affect as you've discribed...
Perhaps you missed a step, or made a mistake in a step...make sure you use the changes for v1.7.2 (if marked)

P.S. in step 5 make sure you added the code above FIRST instance of the line you are supposed to find (there are more then one instance of that line)
Title: Re: [MOD] Download limit
Post by: macmaster_it on August 31, 2006, 02:05:31 PM
hi, i've installed tihis mod to 1.7.3 it works, but not fine  :?

1. files in zip-files (lightbox) not counted
2. total download (from the statistic-mod) show more then downloaded, why??

Plaese have a look at my files, what is going wrong....
Title: Re: [MOD] Download limit v1
Post by: andreas00 on September 15, 2006, 02:49:47 PM
The link for downloading the installation doesn't work  :?
Title: Re: [MOD] Download limit v1
Post by: andreas00 on September 18, 2006, 09:56:14 AM

THE DOWNLOAD LINK FOR INSTALLATION IS NOT WORKING
Title: Re: [MOD] Download limit v1
Post by: mawenzi on September 18, 2006, 12:11:08 PM
... until v@nos website is online ...
... please wait and try it again ...
Title: Re: [MOD] Download limit v1
Post by: V@no on September 18, 2006, 02:34:24 PM
file attached to the original post.
Title: Re: [MOD] Download limit v1
Post by: andreas00 on September 19, 2006, 08:03:36 PM
Thanks boss

you are the man!
Title: Re: [MOD] Download limit v1
Post by: antonio2005 on November 17, 2006, 02:20:04 AM
Hi,

I have an interesting question for V@no. (If you have time and patience  :wink:)

First you set a category permitions to: download --> private

Then you create an usergroup, and set this usergroup to access the private category.

Finally you create 2 users. One simple, and another belonging to the usergroup.


The simple user should be able to download XX files on the entire category, except files within the private category, right?

The second user should be able to download xx files within the ALL gallery, right?

Whats happennig is that both users are able to downlaod files from the "private" category, if they use a small trick: they move the images in "private" category to the lightbox, and then they can download them.

Did i make myself clear?

V@no, can you give some indications on how to solve that?


Thanks in advance,
António
Title: Download limit v1, for Version 1.7.4
Post by: laurent68 on January 06, 2007, 09:32:50 AM
------English---

Hello with all, I would like to know if somebody with already used the following MOD: http://www.4homepages.de/forum/index.php?topic=7701.0 (http://www.4homepages.de/forum/index.php?topic=7701.0)
with the version 1.7.4.

Because at home after several tests and research I always have this error message according to which is posted:
Fatal error: Call to undefined function: update_dl_limit() in /home/xxx/domains/xxx/public_html/xxx/download.php on line 373

line 373 correspond to:

/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  $dl++;
  update_dl_limit($dl); !(line:373)!
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/

I however respected all the instructions of scripts strictly (being unaware of the modifications specific to the versions v1.7/v1.7.1)

I thank you by advance for your assistance.

Well cordially, Laurent.

------French---

Bonjour à tous
J'aimerais savoir si quelqu'un à déjà utilisé le mod suivant: http://www.4homepages.de/forum/index.php?topic=7701.0
avec la version 1.7.4.

Car chez moi après plusieurs tests et recherches j'ai toujours ce message d'erreur suivant qui s'affiche:
Fatal error: Call to undefined function: update_dl_limit() in /home/xxx/domains/xxx/public_html/xxx/download.php on line 373

la ligne 373 corresponds à:

/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  $dl++;
  update_dl_limit($dl); !(line:373)!
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/

J'ai pourtant bien respecté toutes les consignes du scripts (ignorant les modifications spécifiques aux versions v1.7/v1.7.1)

Je vous remercie par avance pour votre aide.

Bien cordialement,
Laurent.
Title: Re: [MOD] Download limit v1 with version 1.7.4
Post by: laurent68 on January 07, 2007, 09:24:19 AM
Can somebody say to me if this modification functions with this version? (1.7.4)
Thank you very much.

Laurent.
Title: Re: [MOD] Download limit v1 with version 1.7.4
Post by: m.a on January 08, 2007, 04:19:25 PM
Can somebody say to me if this modification functions with this version? (1.7.4)
Thank you very much.

Laurent.

Hi,
I have this version (1.7.4).
I build this Mod.  ## The Mod. funktion with this verison!

Best Regards
m.a
Title: Re: [MOD] Download limit v1
Post by: ch€ri{Bi}² on January 11, 2007, 08:42:39 AM
Fatal error: Call to undefined function: update_dl_limit() in /home/xxx/domains/xxx/public_html/xxx/download.php on line 373
this means your script did not find the mentioned function... :?
are you sure to have this function ( :arrow: function update_dl_limit($dl)  ) in your download.php file (or in your functions.php file) in the right place?
Title: Re: [MOD] Download limit v1
Post by: renicolay on February 05, 2007, 10:26:37 PM
Quote
Hi,
I have this version (1.7.4).
I build this Mod.  ## The Mod. funktion with this verison!

Best Regards
m.a

Hello, It looks like you are saying that it works for 1.7.4...is that true? Just checking. Thanks!
Title: Re: [MOD] Download limit v1
Post by: CeJay on February 05, 2007, 11:15:00 PM
Quote
Hi,
I have this version (1.7.4).
I build this Mod.  ## The Mod. funktion with this verison!

Best Regards
m.a

Hello, It looks like you are saying that it works for 1.7.4...is that true? Just checking. Thanks!
Thats what they said  :wink:
Title: Re: [MOD] Download limit v1
Post by: Jacob on March 21, 2007, 08:46:04 AM
Thanks for the beautiful mod but i have one request regarding this:

Is this possible to redirect user (when his/her download limit has reached) to a specific page instead redirecting the user to site's main page?

Can anybody help me?
Title: Re: [MOD] Download limit v1
Post by: Jacob on March 23, 2007, 12:35:03 PM
Thanks for the beautiful mod but i have one request regarding this:

Is this possible to redirect user (when his/her download limit has reached) to a specific page instead redirecting the user to site's main page?

Can anybody help me?
Bummp bump  :roll:
Title: Re: [MOD] Download limit v1
Post by: trez on March 23, 2007, 12:52:31 PM
MOD works  for 1.7.4, with some adjustments
Title: Re: [MOD] Download limit v1
Post by: shadowhunter on March 31, 2007, 10:52:00 PM
@trez:
What have you done in your adjustments?

I use 1.7.4, but it don't run perfectly.
When I click on the button "download" and I haven't more download-credits, then will be loaded the "home"-page of my gallery. The error will not be displayed in this moment.
I will show the image with the download-error in my gallery where I clicked on the button.
Thanks for help... ;)
Title: Re: [MOD] Download limit v1
Post by: Buggy Driver on April 16, 2007, 02:12:56 AM


Same problem hire  1.7.4  --> redirect to the index.php  --> no error no message.

it looks like the redirect($url); is wrong
so after a couple try and error I reached this solution

Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
  if (!check_dl_limit(0))
  {
    $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
//    redirect($url);
    redirect("details.php?image_id=".$image_id);
    exit;
  }
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/


but there are 2 places in the download limit where a redirect($url); occurs
the other is always bin there but now after the redirect there is a error message so……

in the index php look for

Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));

above insert the same code as in details.php
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
if ($msg_error = $site_sess->get_session_var("msg_error"))
{
  $msg .= ((empty($msg)) ? "" : "<br />").stripslashes($msg_error);
  $site_sess->drop_session_var("msg_error");
}
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/

now the message will be on the index page to.

Title: Re: [MOD] Download limit v1
Post by: shadowhunter on April 18, 2007, 11:26:09 AM
Thanks a lot, Buggy Driver!!!
It works great!
Have a nice time...
best wishes!
Title: Re: [MOD] Download limit v1
Post by: kira2oo2 on May 25, 2007, 01:55:24 AM
Hallo zusammen

habe den Mod in meinem 1.7.4 eingebaut, funktioniert einwandfrei!! Noch zusagen ist, als typ für andere, dass ich den Mod für 1.7.2 genommen habe, ich hatte keine Probleme oder Fehlermeldungen. Danke V@no und alle die da mitgemacht haben. Alles in allem ein super Mod!

Hier noch was für Deutsch sprechende.... ich habe versucht den Step 8
Open lang/<your language>/main.php zu übersetzten:

Quote
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$lang['user_dl_limit'] = "Download limit";
$lang['user_dl_time'] = "Start time";
$lang['user_dl_count'] = "Downloads count";
$lang['user_dl_limit_reached'] = "Deine Downloadquote pro ".$config['user_dl_time']." Stunden ist erreicht worden. Du kannst nicht mehr downloaden bis in {dltime}";
$lang['user_dl_limit_unlimited'] = "Dein Downloadlimit ist unbegrenzt";
$lang['user_dl_limit_status'] = "Du hast {dlcount} von {dltottal} Bilder, runtergeladen in ".$config['user_dl_time']." hours";
$lang['dl_limit_reached'] = "Sorry, Du hast die Downloadbegrenzung erreicht für ".$config['user_dl_time']." hours";
$lang['dates_short'] = array(
  array("yr", "day", "hr", "min", "sec"),
  array("yrs", "days", "hrs", "min", "sec")
);
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/

 Vieleicht kann es ja jemand brauchen........  :oops:
Title: Re: [MOD] Download limit v1 and phpbb integration
Post by: nic_bck on October 06, 2007, 12:26:13 PM
I'm trying to use [MOD] Download limit v1 and phpbb integration

When I install the MOD I have this error:
Fatal error: Call to undefined function: set_cookie_data() in /home/web/public_html/4images/download.php on line 75

I think that the problem is in sessions.php.

Can somebody help me to use [MOD] Download limit v1 and phpbb integration??

Sorry, my english... XD

Thanks!
nic_bck
Title: Re: [MOD] Download limit v1
Post by: thunderstrike on October 06, 2007, 01:33:11 PM
Your sessions file is alter. If no MOD install on file, re-upload file and is work. If MOD install on that file, use compare tool (Beyond Compare 2 or Winmerge). Look like the file is bad upload in FTP / cPanel.
Title: Re: [MOD] Download limit v1
Post by: nic_bck on October 06, 2007, 06:10:41 PM
Hi, first thanks for your reply.

The problem is in sessions.php becouse I have the sessions.php of the phpbb integration.
You can see it here:
http://www.4homepages.de/forum/index.php?topic=14852.0

My 4images version: 1.74.

The problem is on the 6th step:

Quote
Step 6
Open includes/sessions.php
Find:
Code:

Code: [Select]
        $this->delete_old_sessions();
      }
    }
Insert ↓BELOW↓:
Code:
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
    global $config;
    if ($this->user_info['user_level'] > GUEST)
    {
      if (!$this->user_info['user_dl_limit'] && $this->user_info['user_dl_limit'] != -1)
      {
        $this->user_info['user_dl_limit'] = $config['user_dl_limit'];
      }
      if (!$this->user_info['user_dl_time'])
      {
        $this->user_info['user_dl_time'] = 0;
      }
    }
 
    if ($dl = $this->read_cookie_data('data'))
    {
      $dl = explode(" ", base64_decode($dl));
      if (isset($dl[1]) && $dl[1] && $config['user_dl_time']*60*60 > (time() - $dl[1]))
      {
        $this->user_info['user_dl_time'] = $dl[1];
        $this->user_info['user_dl_count'] = (isset($dl[0]) && $dl[0]) ? $dl[0] : 0;
      }
      else
      {
        $this->user_info['user_dl_time'] = 0;
        $this->user_info['user_dl_count'] = 0;
      }
    }
    elseif ($this->user_info['user_level'] == GUEST)
    {
      $this->user_info['user_dl_count'] = 0;
      $this->user_info['user_dl_time'] = 0;
    }
    if ($this->user_info['user_level'] == GUEST)
    {
      $this->user_info['user_dl_limit'] = $config['user_dl_limit'];
    }
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


I need to adapt the sixth step to integrate with the sessions.php of [MOD] phpbb integration

Can you help me?

Thanks!
nic_bck
Title: Re: [MOD] Download limit v1
Post by: thunderstrike on October 06, 2007, 06:59:55 PM
Sorry, I no support other authors MOD for integrate.
Title: Re: [MOD] Download limit v1
Post by: casper01 on November 03, 2007, 05:01:58 PM
Hello I use 4image  1.74 scrip its very cool but i have some problem with this mod.I go button in cp "Apply to all subcategories" but when I check "Yes" , it dident change the subdirectories pemisson.Same problem with download limit...I got download limit in cp.for ex. I put 2 downloads file in 24 h.When I get in download secssion I see this "You have downloaded 0 of 2 files, allowed per hours".When I trai do download another time I see the same "You have downloaded 0 of 2 files, allowed per hours" and it allowed me tu download how many times I want. I was trai this when I not registred user and when Im registred user NOT ADMIN .
PLESE HELP
Title: Re: [MOD] Download limit v1
Post by: renicolay on April 13, 2008, 05:12:51 PM
Has anyone tested this on 1.7.6 yet?
Title: Re: [MOD] Download limit v1
Post by: silentg on June 10, 2008, 02:15:48 AM
Running V1.7.6.

Has anyone tried it?


thanks
Title: Re: [MOD] Download limit v1
Post by: sigma. on August 09, 2008, 11:38:30 PM
I cant install on 1.7.6 because the download.php code has changed. cant match up what needs to be changed or replaced.

Im stuck on Step 2. Cant find this code in download.php
Code: [Select]
function get_remote_file($url) {
anyone know the equivalent in 1.7.6?
Title: Re: [MOD] Download limit v1
Post by: sigma. on August 10, 2008, 12:09:14 AM
Just tried my best and got it to work. Some of the code in download.php 1.7.6 doesn't match.
Follow this step 2 insted of the first post

Step 2
Open download.php
Find:
Code: [Select]
$user_access = get_permission();
Insert Below
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT
*/
$dl = 0;
function check_dl_limit($dl)
{
  global $user_info, $config;
  if ($user_info['user_level'] != ADMIN && $user_info['user_dl_limit'] != -1 && $user_info['user_dl_limit'] && time() - $user_info['user_dl_time'] <= 60*60*$config['user_dl_time'] && $user_info['user_dl_count'] + $dl >= $user_info['user_dl_limit'])
  {
    return false;
  }
  elseif ($user_info['user_level'] != ADMIN && $user_info['user_dl_limit'] != -1 && $user_info['user_dl_limit'] && time() - $user_info['user_dl_time'] > 60*60*$config['user_dl_time'] && $dl >= $user_info['user_dl_limit'])
  {
    return false;
  }
  return true;
}
function update_dl_limit($dl)
{
  global $user_info, $site_db, $site_sess, $config;
  if ($user_info['user_level'] == ADMIN) return;
  $time = time();
  if (!$user_info['user_dl_time'] || $time - $user_info['user_dl_time'] > 60*60*$config['user_dl_time'])
  {
    $time_sql = ", user_dl_time = ".$time;
    $user_info['user_dl_count'] = $dl;
    $user_info['user_dl_time'] = $time;
  }
  else
  {
    $time_sql = "";
    $user_info['user_dl_count'] += $dl;
  }
  if ($user_info['user_level'] > GUEST)
  {
    $sql = "UPDATE ".USERS_TABLE."
            SET user_dl_count = ".$user_info['user_dl_count'].$time_sql."
            WHERE user_id = ".$user_info['user_id'];
    $site_db->query($sql);
  }
  $site_sess->set_cookie_data('data', base64_encode($user_info['user_dl_count']." ".$user_info['user_dl_time']), 1, 60*60*$config['user_dl_time']);
}
/*
  MOD DOWNLOAD LIMIT
  END INSERT
*/


Step 2.3
Find:
Code: [Select]
else {
      redirect("lightbox.php?empty=1");
    }
  }
}

Insert Below
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN REPLACE
*/
      $file['file_data'] = $zipfile->send(time().".zip");
      exit;
    }
    else {
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
      redirect($url);
/*
  MOD DOWNLOAD LIMIT
  END REPLACE
*/

worked for me.
Title: Re: [MOD] Download limit v1
Post by: sigma. on August 11, 2008, 02:11:13 PM
ok so i was wrong. the last bit is giving me an error

Code: [Select]
Parse error: syntax error, unexpected '}' in /home/cydonian/public_html/photos/download.php on line 231
In my download.php i find this between lines 225 and 241
Code: [Select]
/*
  MOD DOWNLOAD LIMIT
  BEGIN REPLACE
*/
      $file['file_data'] = $zipfile->send(time().".zip");
      exit;
    }
    else {
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
      redirect($url);
/*
  MOD DOWNLOAD LIMIT
  END REPLACE
*/

lines 230,231,232
Code: [Select]
      exit;
    }
    else {

Anyone know whats missing here?
Title: Re: [MOD] Download limit v1
Post by: V@no on August 11, 2008, 02:25:15 PM
Step 2.3
Find:
      redirect("lightbox.php?empty=1");


Insert above:
/*
  MOD DOWNLOAD LIMIT
  BEGIN INSERT ABOVE
*/
      if (!check_dl_limit(0))
      {
        $site_sess->set_session_var("msg_error", addslashes($lang['dl_limit_reached']));
      }
/*
  MOD DOWNLOAD LIMIT
  END INSERT ABOVE
*/
Title: Re: [MOD] Download limit v1
Post by: sigma. on August 11, 2008, 02:38:02 PM
very nice. thanks again V@no.
I wish I had your php knowledge. I feel bad buggin you guys all the time.
Title: Re: [MOD] Download limit v1.0
Post by: Sunny C. on August 21, 2008, 12:37:52 AM
V@no,

can you make a Uploadlimit Script?
Title: Re: [MOD] Download limit v1.0
Post by: HowdoI on August 21, 2008, 05:27:51 AM
Good Day,

I do not know if this has been mentioned in the 11 pages but when I first installed the MOD it would not work at all and when I tried to download a picture I got an error.  The problem was that I used th install.zip from "Download this installer" and not the link that actually says .zip in (the second and last link)  if you use the first one the database will not be updated and therefor cause the errors.  When used the link  dl_limit_install.zip (1.96 KB - downloaded xxx times.) it worked like a charm on V.1.7.6 so why does one work and not the other?  Is one for one version and the other for another?

I got it to work so if you are having the same problem that when you point your browser to the install file and all that happens is the screen reloads than try the other one, worked for me.
Title: Re: [MOD] Download limit v1.0
Post by: RatedRWHC on August 30, 2008, 12:58:27 AM
is it possible to remove the download limit for specific users?
Title: Re: [MOD] Download limit v1.0
Post by: V@no on August 30, 2008, 02:46:54 AM
is it possible to remove the download limit for specific users?
Yes, you can.
This mod allows set per user and/or per group download limit.
Title: Re: [MOD] Download limit v1.0
Post by: RatedRWHC on August 30, 2008, 08:37:49 PM
i installed it but when i download a file it jus stays at saying u have downloaded 0 files :S whats wrong
Title: Re: [MOD] Download limit v1.0
Post by: V@no on August 30, 2008, 09:49:57 PM
Admin downloads don't count ;)
Title: Re: [MOD] Download limit v1.0
Post by: RatedRWHC on August 30, 2008, 11:01:58 PM
i created a user that was jus registered user and it still wasnt going up
Title: Re: [MOD] Download limit v1.0
Post by: V@no on August 30, 2008, 11:05:30 PM
Check steps 2.x , my guess would be you missed step 2.5
Title: Re: [MOD] Download limit v1.0
Post by: RatedRWHC on August 30, 2008, 11:20:06 PM
i cant do 2.5 i have 1.7.6 lol

neway dw its more trouble than its worth lol
Title: Re: [MOD] Download limit v1.0
Post by: V@no on August 30, 2008, 11:23:47 PM
Well, if you read more closely the installation instructions, you would find step 2.5 for version 1.7.2 and newer. Same goes for step 2.4
Title: Re: [MOD] Download limit v1.0
Post by: RatedRWHC on August 31, 2008, 05:54:37 AM
oh ok lol i fort only the ones that said 1.7.6 were for 1.7.6 lol
Title: Re: [MOD] Download limit v1.0
Post by: nic_bck on September 03, 2008, 11:55:57 AM
Hi V@no and friends!

Can anyone help me to modify this mod? I want to use this with the vbulletin integration.

Download limit can reduce the server load and can make back the users to your website (making affinity).

I want to request this modification, I would colaborate if it is necesary (and if I can XD ).

Please help me, I can do it alone :(
Thanks!
Title: Re: [MOD] Download limit v1.0
Post by: V@no on September 03, 2008, 03:05:36 PM
I think you'd have more chances get this done if you ask this question at vbulletin support forum ;)
Title: Re: [MOD] Download limit v1.0
Post by: sigma. on September 09, 2008, 04:31:55 PM
How difficult would it be to show a status bar type graphic instead of text?

something like this.

Title: Re: [MOD] Download limit v1.0
Post by: SnaFy on November 20, 2008, 01:42:28 AM
it work with 1.7.6?? :?:
Title: Re: [MOD] Download limit v1.0
Post by: alekinna on November 20, 2008, 06:53:01 AM
it work with 1.7.6?? :?:

Work fine!
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on December 23, 2008, 10:07:39 PM
When there is NO USER loged in, i although see the Message "You have 2 from 10 Pictures downloaded".
Can i deactivated is when NO USER is logged in?
I only want see it when a user is logged in.

thanks
Title: Re: [MOD] Download limit v1.0
Post by: Nicky on December 23, 2008, 11:15:26 PM
hi Blesi,

i don't see the point, registered users are limited and guests can download how much they want  :roll:
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on December 24, 2008, 02:15:49 PM
So this is right. When you klick as unregistered user at n picture, also the text is there. You understnad what i mean? A registered user have a limit, but this limit is by an unregistered user there, too. Look at my page.
Sorry for my bad english.

http://www.christian-blesinger.com/gallery

thanks
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on December 24, 2008, 02:18:05 PM
I tested just in that moment and is found a bug, maybe. When the downloadlimit is reached, i can although download pictures. please login as "demo" and "demo" / "user" and "password an try to download a picture.
Title: Re: [MOD] Download limit v1.0
Post by: V@no on December 24, 2008, 03:08:22 PM
it let me download only 1 picture
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on December 24, 2008, 11:01:40 PM
1 Picture is 1 Picture too much. The upoadlimit should be reached.
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on December 24, 2008, 11:15:19 PM
May it be, that the account for the downloaded pictures is after 24h back to "0"? So you can download again until the limit?
Title: Re: [MOD] Download limit v1.0
Post by: V@no on December 25, 2008, 02:15:28 AM
I just installed this mod on a fresh 4images and it showed 0 as it should. Perhaps you made a mistake somewhere?
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 07, 2009, 04:12:33 PM
Ich musste auf Grund einer neuen Datenbank/Wabspace alles neu machen. Nun habe ich ein Problem.

Kann ich das so einbinden? So correct? At the site there is nothing!

<div align="center"><br />
{user_dl_limit}
</div>
Title: Re: [MOD] Download limit v1.0
Post by: V@no on January 07, 2009, 04:36:11 PM
Re-do step 7
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 07, 2009, 04:50:33 PM
The picture is from the USER-Menu. Step 7 is correct, i checked it

I found the problem. main.php was not correct.

Thanks for your help.
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 10, 2009, 05:11:51 PM
Hallo,
ich habe folgendes Problem. Wenn ich einen Benutzer erstellem hier als Beispiel BenutzerPasswort:"demo10/demo10" und diesem 10 Bilder zum Download frei geben, dann ist die Ansicht (bei mir links unter dem Zufallsbild) nicht korrekt wie sie sein sollte. An was kann das liegen?
Eingebunden habe ich es mit dem folgenden Code. Bitte um Hilfeeeee.
An meinem anderen Computer hat es funktioniert. Was zeigt es bei euch an? Geht es oder nicht?
Dann ein zweites Problem. Wenn ich mehrere Bilder über die Lightbox-Funktion downloade, werden diese NICHT vom Konto abgezogen. Ist da ein Fehler im Script oder???

<div align="center"><br />
{user_dl_limit}
</div>


www.christian-blesinger.com
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 13, 2009, 12:41:01 PM
When download some pictures with LIGHTBOX, they wont removed from the account.
You understnad my problem? If i download ONE picture per "Download" then it will be removed. But not per "Lightbox".

I hope anybody can help me.
Title: Re: [MOD] Download limit v1.0
Post by: V@no on January 13, 2009, 04:07:20 PM
Step 2.3 done?




P.S.
If you want, zip your modified download.php and attach with your reply
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 14, 2009, 11:31:27 AM
I checked STEP 2.3. Everything is correct. I used WinRAR, i hope its okay. I dont have WinZip. If you dont have WinRar, i can download WinZip.
I checked ALL Steps, and every Step is correct. But the prolblem is still here.
If you want i cant send you a login per PM then you can see it.
Title: Re: [MOD] Download limit v1.0
Post by: V@no on January 14, 2009, 04:18:47 PM
Strange, your download.php looks fine. At the moment I don't have anywhere to test it, but for now, please lower on your site the limit time to 5 minutes or so.
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 15, 2009, 08:18:03 AM
I set the Time Limit to "1" hour. If you want i can give you a login. Then you can test it. In the Details Page are usual the Download-Buttons. The normale und the ZIP Button. The Zip Button i deleted from the Details Page becaus he was out of order too. I that the problem? The normal was ok, but the zip not ok. At the Lightbox is a zip button.

thanks
Title: Re: [MOD] Download limit v1.0
Post by: Blesi on January 20, 2009, 08:17:20 PM
V@no, you have a new idea? Can i help you, that you can test more? If you cant help me, i have to delete the ZIP-Downloadbutton at the lightbox.

Thanks Blesi
Title: Re: [MOD] Download limit v1.0
Post by: V@no on January 21, 2009, 01:24:10 AM
I'll need FTP access and an admin account for your gallery if you want any further help on this issue. PM me if you up to it.
Title: Re: [MOD] Download limit v1.0.1
Post by: V@no on January 22, 2009, 01:26:46 AM
I guess some code was missing in my instructions...I added Step 2.8
Title: Re: [MOD] Download limit v1.0.1
Post by: Blesi on January 22, 2009, 09:22:07 AM
THANK YOU FOR YOUR HELP!!!!
I saw just at the moment that you did something. But there are still two problems.
The first is, when i download three pictures in the lightbox, it counts six pictures. It counts always the double of the pictures.
The second problem is, when i set the download count in the users menu to zero, it doesnt set it to zero. It adds to the old count.
Title: Re: [MOD] Download limit v1.0.1
Post by: Blesi on January 22, 2009, 07:42:04 PM
When i set all settings to zero its okay.
But the problem is still the counter who counts wrong.

Title: Re: [MOD] Download limit v1.0.1
Post by: V@no on January 23, 2009, 03:26:49 AM
The new step 2.8 is ok, it's in your download.php for some reason the last change I made wasn't saved...it should work now.
Title: Re: [MOD] Download limit v1.0.1
Post by: Blesi on January 23, 2009, 12:10:22 PM
I checked it and it works perfect.

!!!!!!!!!!!!!Thank you very much!!!!!!!!!!!!!

 :P  :thumbup: :thumbup:
Title: Re: [MOD] Download limit v1.0.1
Post by: Jan-Lukas on June 07, 2012, 06:17:49 PM
Kann man diesen Mod evtl. noch erweitern ?

Möchte nur diese User begrenzen, die den ganzen Tag in unserem Katalog hocken, und sich fleißig Bilder saugen.
User die also auch fleißig Bilder hochladen, dürfen downloaden, die anderen (faulen) halt nur eine von mir begrenzte Anzahl am Tag,Woche etc.
danach wird der Download deaktiviert (evtl. ein Popup das erst nach ???? wieder freigeschaltet wird)

Oder kann das dieser Mod schon, ihr wisst, mein englisch  :oops: (bitte, sagt jetzt nicht diesen Translator hier oben im Kopf, dann lieber Englisch  :wink:)

LG
Title: Re: [MOD] Download limit v1.0.1
Post by: kiki on May 21, 2013, 10:28:32 PM
Hello  :D

Can you tell me if this mod works with the 1.7.11 release?
Or if there is another way / MOD Block number of downloads per day (24 hours)

thank you very much