Added Feature: Minimum time between downloads (DL Manager)

If you would like to post a coding tip or change, or if you would like to help us develope Download Tracker post here.

Added Feature: Minimum time between downloads (DL Manager)

Postby Revaro » Sun Aug 05, 2007 12:36 pm

Hi Todd Horst

You have made a good and simple script.

I made a modification to your script. I added the feature to require a minimum amount of time between downloads. This will enable you to:

  • Keep your bandwidth exactly within your monthly download quotum (without manually having to intervene). Just set the interval to ("seconds in a month"/"allowed downloads per month" = "interval in seconds")
  • Don't get all users on the same server, which results in slow downloads for all users.
  • Temporarily remove a server as a download mirror. Which is useful if you are reaching your download quotum. Just set the interval to a 100 million seconds to do this.
  • Smart conditioning. You can add a server twice in the list. First with a very thight condition and also last with no condition on the time in case all the other servers bail out.

SCREENSHOTS:

Image

Image

Note that the modified script is not compattible with the original script since I had to add two fields in the mysql database for each download file (time interval, last download time). If you just add the downloads again, they will just work fine.

The modified files are linked in this post below. All lines of code that are changed are marked with: "Revaro 040807".

INSTALL:

DOWNLOAD Download_Tracker_Mod.zip
To install the modification download "Web Download Tracker 1.4.R.2" from
http://www.checkndo.com/index.php?optio ... &Itemid=44
and replace the files with the files from within the zip-archive.
Continue by using the install instructions from Web Download Tracker 1.4.R.2.

Disclaimer:
I am not a professional PHP-coder. I know c-code very well so I am not a compete idiot. However this is probably only my 10th PHP file I used to edit so it is not guaranteed to be bug free.

Enjoy :) !
Play my multiplayer 2D-shooter Reactive (OSX).
User avatar
Revaro
 
Posts: 6
Joined: Sun Aug 05, 2007 10:57 am

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby thorst » Mon Aug 06, 2007 12:34 pm

If you have already installed DT 1.4 R2 and you do not want to do a clean install AND you don't know how to manually add these fields then you can run the following code to get your install working. I havent tested this but it really cant hurt anything if it didnt work since its just adding fields, it either works or it doesnt so there is NO RISK.

Simply add the text to a text file and rename it to "mod_upgrade.php". Then upload the file to the root directory of your DT installation and open it in a web browser. Then, once it says it has added to two fields, simply delete the file from your server.

Code: Select all
<?php
//Declare the basic variables
include("header.php");
include("structure.php");

//Get where they came from
if (isset($_SERVER['HTTP_REFERER'])){
   $Refered= $_SERVER['HTTP_REFERER'];
}else{
   $Refered='';
}

//Create the header
Blank_Menu ($Refered);

//Connect to the sever
mysql_connect($db_host,$MySqlUN,$MySqlPW);

//Connect to the database, else error out
@mysql_select_db($database) or die( "Unable to select database");

//Add to files table: fMinDLIntervalSeconds INT(1)
$querys   = "ALTER TABLE $dTbl ADD `fMinDLIntervalSeconds` INT( 1 )";
mysql_query($querys) or die('Error, query failed: ' . mysql_error());
echo "interval field created";

//Add to files table: fLastDLSeconds INT(1)
$querys   = "ALTER TABLE $dTbl ADD `fLastDLSeconds` INT( 1 )";
mysql_query($querys) or die('Error, query failed: ' . mysql_error());
echo "Last dl field created";

?>
User avatar
thorst
Site Admin
 
Posts: 146
Joined: Mon Jun 25, 2007 3:14 pm

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby thorst » Mon Aug 06, 2007 1:06 pm

Now to post about your mod.

You have made a good and simple script.

Thanks, I try to make good, simple, relevant products that I need, I know if I need it someone else does too.

Keep your bandwidth exactly within your monthly download quotum (without manually having to intervene). Just set the interval to ("seconds in a month"/"allowed downloads per month" = "interval in seconds")
Don't get all users on the same server, which results in slow downloads for all users.
Temporarily remove a server as a download mirror. Which is useful if you are reaching your download quotum. Just set the interval to a 100 million seconds to do this.
Smart conditioning. You can add a server twice in the list. First with a very thight condition and also last with no condition on the time in case all the other servers bail out.


This is a very cool feature and I can completely understand why this would be needed. I commend you for not only making a mod, but for also releasing it only a week after the 1.4.R2 has been released. Im surprised you could get in there and read through all my comments and understand what I was doing (I always hate modifying other peoples code).

I was planning on releasing a random mirror picker feature within the next couple of versions to spread the load out (it wouldn’t be completely random, it would ensure that all mirrors were used 1 time before cycling over to the beginning again). But this time-out feature almost replaces that. Now that you've written this I’d like to combine the two features and incorporate that as soon as i can.

With your permissions, I’d like to at least include this mod (meaning i may not have time to write the random picker) in the next version. I'd like to edit your comments in the code (removing your name & rewording some text) and move things a little (maybe). In exchange for that id have a "thanks to contributors list" in the admin panel where your name could clearly be displayed in the program with what you added (not just in the code as it is now). How’s that sound? I really just want to do this to keep the code as clean as possible (in a couple versions im going to over haul the code base to hopefully improve efficiency and readability).

Disclaimer:
I am not a professional PHP-coder. I know c-code very well so I am not a complete idiot. However this is probably only my 10th PHP file I used to edit so it is not guaranteed to be bug free.

Aren't we all beginners?
This is my first open source project & my first public php project. This is only my second php project, and some may even consider it to be my first. Download Tracker was called Version Tracker in versions .1-.5. If you look in the change log before .6 you won’t see any mention about downloads or files. Just a tid bit of info there. I too came from desktop programming and that’s really what inspired this entire project.

Have you checked out the C# Desktop Sample Program? A port to C would be nice :)
User avatar
thorst
Site Admin
 
Posts: 146
Joined: Mon Jun 25, 2007 3:14 pm

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby Revaro » Tue Aug 07, 2007 5:55 am

thorst wrote:Im surprised you could get in there and read through all my comments and understand what I was doing (I always hate modifying other peoples code).
It was just a bit of guessing and a lot of copy and paste. But working on other people's code is prone to give bugs. I have used other people's code before, which gave the most annoying bugs. But I hope that a simple small script will not give problems. It seems to work, but I have not checked if it is idiot proof. It doesn't have to be for me because I am happy as long as it works.
thorst wrote:I was planning on releasing a random mirror picker feature within the next couple of versions to spread the load out (it wouldn’t be completely random, it would ensure that all mirrors were used 1 time before cycling over to the beginning again). But this time-out feature almost replaces that. Now that you've written this I’d like to combine the two features and incorporate that as soon as i can.
That would be an option too. Both methods can actually works side by side. I made this specific implementation to balance loads better over different servers with different capacities. I have monthly bandwidth limits and actually only one file that consumes all bandwidth, so this functionality completely satisfies my needs. Other people may have other needs, but this functionality can be smartly configured to achieve some different results.
thorst wrote:With your permissions, I’d like to at least include this mod (meaning i may not have time to write the random picker) in the next version.
You got my permission and I actually prefer this, because this means I don't have to administer the code.
thorst wrote:I'd like to edit your comments in the code (removing your name & rewording some text) and move things a little (maybe).
Not a problem at all. I made the comments especially so that other coders (Meaning you) could see the changes and easily clean up the code and check sanity.
IIn exchange for that id have a "thanks to contributors list" in the admin panel where your name could clearly be displayed in the program with what you added (not just in the code as it is now). How’s that sound?
Appreciated, but I don't need that much recognition. I don't need any official mention, but if you want to just add my name in a readme or something. If you like to add my name, I'm ok with it.
I really just want to do this to keep the code as clean as possible (in a couple versions im going to over haul the code base to hopefully improve efficiency and readability).
Sounds good.
Download Tracker was called Version Tracker in versions .1-.5.
That got me confused. I still read "Version Tracker" somewhere in the documentation and thought it had something to do with versiontracker.com.
Have you checked out the C# Desktop Sample Program? A port to C would be nice :)
C#?, I have never even seen c++++. I did some c+ though.

Finally I want to mention that the automatic database creation did not work (completely) for me. I had to manually create the database. But that might be because my website is on a shared server and my databases have to have a specific prefix. After I created a database and user I clicked a few times on create database (and maybe fiddled around some more with the database and configuration) and then suddenly it worked.

PS: was your server on a DOS-attack yesterday? I could hardly get any pages that I requested on the forum.
Play my multiplayer 2D-shooter Reactive (OSX).
User avatar
Revaro
 
Posts: 6
Joined: Sun Aug 05, 2007 10:57 am

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby thorst » Tue Aug 07, 2007 12:08 pm

It was just a bit of guessing and a lot of copy and paste. But working on other people's code is prone to give bugs. I have used other people's code before, which gave the most annoying bugs. But I hope that a simple small script will not give problems. It seems to work, but I have not checked if it is idiot proof. It doesn't have to be for me because I am happy as long as it works.


Yep, when I include it I will try to test for idiots, lol, I had a couple of small tweaks that I thought of but most will be the same. It helps a lot that the code is all there and working as far as we know.

That got me confused. I still read "Version Tracker" somewhere in the documentation and thought it had something to do with versiontracker.com.

Yeah hopefully I will get that all cleaned up in the re-write, there wasn’t to many pages that got ported over into DT but there are enough small notes in there that it’s hard to replace everything.

Finally I want to mention that the automatic database creation did not work (completely) for me. I had to manually create the database. But that might be because my website is on a shared server and my databases have to have a specific prefix. After I created a database and user I clicked a few times on create database (and maybe fiddled around some more with the database and configuration) and then suddenly it worked.


Yeh, some hosts (including my hosting software) requires a prefix for both the username and database. For these users I would recommend creating the user and database and then setting the settings file accordingly, the way the install script works is that if it DOESNT already exist it will create it, so in your instance, it noticed when you created it and then added the needed tables. This is intended and sounds like it performed as expected. Personally I over ride that because I have complete control over my server but other users that i host use it the way you have.

I guess i should publish that note in the installer. Ps the next version will have a completely online setup for both upgrades and installs. Neat I think.

PS: was your server on a DOS-attack yesterday? I could hardly get any pages that I requested on the forum.

Not sure what all the fuss was about yesterday. My server was actually working fine, it was the isp.... there comcastic. </sarcasm> (sorry that was a cheap comcast joke, not sure if they have comcast where you are). Someday, when these projects generate a little (and when I say a little I mean a lot) more income, or my hosting peoples websites pays off more than just the cost of my server, I will be able to afford a better isp package and have higher speeds and better priority of getting up when things go wrong, in the meantime though I fear we will periodically see these hiccups.
User avatar
thorst
Site Admin
 
Posts: 146
Joined: Mon Jun 25, 2007 3:14 pm

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby Revaro » Tue Aug 07, 2007 6:22 pm

I posted a bug I encountered, but it might be related to my modification (I never used the original version, but modded it straight away). I add a crosslink for reference.
viewtopic.php?f=34&t=34
Play my multiplayer 2D-shooter Reactive (OSX).
User avatar
Revaro
 
Posts: 6
Joined: Sun Aug 05, 2007 10:57 am

Re: Added Feature: Minimum time between downloads (DL Manager)

Postby thorst » Wed Dec 05, 2007 9:07 pm

This mod has been added to the program as of version 1.5 There is no longer a need to download it.

Thanks Revaro for your time and hosting the file while we got it incorperated.
User avatar
thorst
Site Admin
 
Posts: 146
Joined: Mon Jun 25, 2007 3:14 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron