Login   Register  
PHP Classes
elePHPant
Icontem

File: README

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rémy Sanchez  >  uncentralizedDownloader  >  README  >  Download  
File: README
Role: Documentation
Content type: text/plain
Description: The documentation
Class: uncentralizedDownloader
Manage downloading of files from multiple servers
Author: By
Last change: * accent bug correction
Date: 7 years ago
Size: 5,255 bytes
 

Contents

Class file image Download
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~ Uncentralized Downloader ~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ by Rémy Sanchez ~~~~~~~

~~ INTRODUCTION ~~

	My website offers HTTP downloads to the users on a free host (free.fr)
then I was pretty limited in the server features I could use. Moreover, I had
to create several accounts because one was too small. But with time I faced
several problems

	* Accounts randomly goes offline for several hours with no reasons
	* Some sites were hotlinking (they proposed my content to download as if
	  it came from their site)

The solution for the first problem was the uncentrilized downloader : instead of
putting a file on a lonely account, I put it in several accounts, so if an
account goes offline the file is still availible. UD's role is to scan all the
accounts to produce a valid download link.
In order to solve the second problem, I first did kind of rewrite rule (but
using 404 errors instead of rewrite_mode since my host do not have rewrite_mod),
to a file that first checks if the referer is good (so it is not a hotlink),
then sends the file. This solution was good because transparent, but the use of
404 errors made download impossible on some browsers that prefer to show their
own 404 pages (and I could not change HTTP header to do as if it was a OK
answer), and with time we discovered it is pretty instable. Thus we had to find
another solution. The idea was to change the URL every hour so it is impossible
to link that file because the URL is never the same. To do so, I put the files
into a folder that UD renames every hours. Of course, the role of UD is to know
what the folder name is and to generate an URL the user can use to download the
file he asked. That solution is not fully efficient but prevent hotlinks made
by "bad" webmasters (mostly blogs).

~~ FEATURES ~~

	* Prevent bad referers to download
	* Repartition of load on several severs
	* Central configuration file auto-dispatched on slave servers
	* Pages and messages customizable

~~ COMPONENTS ~~

# dirname.php
That file contain the name of the files directory and the time it was changed.

# dl.php
It starts udManger. This file is the "user inteface"

# ud_config.class.php
Contain the configuration variable and the function that fetch the configuration

# ud_fs_interact.class.php
The functions in udFsInteract are the exlusive functions used by udManager to
interact with the file system. It may allow to create virtual file systems (like
files stored in the database)

# ud_manager.class.php
The main component of UD. It includes and loads the other components, and starts
the download process.

# ud_talk.class.php
That class is used to talk between different servers.

~~ INSTALLATION ~~
You must have at least 1 server to install UD. Between all your servers you must
chose a master, the other servers will be the slaves. The master distributes
the configuration to the slaves. That allows you to change the configuration of
your servers very fast. This can be useful when, by example, a new server comes
online. You just have to add its URL in the master's config, and then it will be
automaticaly propagated.
The disavantage of that is that if your master server goes offline, your whole
system is down, so chose your master carefully, or you can set all your servers
as masters (but in that case you lose advantages of auto-propagated
configuration)

    o) Master setup

To set the master server up, you must upload the files into your server. Now you
must configure the server. In that purpose, edit ud_config.class.php file and
change the variables as you wish (each var come with a complete comment about
its use and effects). $_mode MUST be set to UD_CONFIG_MODE_MASTER.

Files to be uploaded

	- dirname.php (server must be able to read/write it)
	- dl.php
	- ud_config.class.php
	- ud_fs_interact.class.php
	- ud_manager.php
	- ud_talk.php
	- files (it is a directory that will be renamed by UD + server must be
	  able to read/write it)

    o) Slaves setup

The process is the same that for master, excepted that most of the configuration
options are downloaded from the master, so you do not need to set them all.
The comments in ud_config.class.php will tell you what variables will be
downloaded from the master. $_mode MUST be set to UD_CONFIG_MODE_SLAVE.

    o) Uploading files

There should be a directory named "files" in the files you uploaded. It is the
directory in witch you can put the files. UD will rename it on its first launch.

    o) Make links

Now you can make links. If your dl.php file URL is http://myserv.com/dl.php,
and  you want to download the file myfile.txt, then your download link will
be http://myserv.com/dl.php?file=myfile.txt
Then dl.php will ask all the servers you have put in your configuration and then
will show to the user a valid download link to one of the servers that have the
file (or to none of the servers if the file cannot be found).

~~ LICENCE ~~

uncentralizedDownloader is licensed under GPL v2 (see GPL file).