==================================
	Version History
==================================

12/98 V1.0 -- First official release.
V1.1 to V1.3 -- Bug fixes.
V1.4 -- Changed how descriptions and downloads are done to make life easier.  Descriptions are now stored as just the filename, and the downloads list is updated when the top downloads is re-compiled for accuracy.  (Update Users of v1.3 or lower:  The conversion to the new format is done when the list is re-compiled, so nothing needs to be done.)
V1.5 -- The des command now can accept parameters from the command line.  Also, some notices were quieted, and some messages were changed to look like P&P messages.


==================================
	Background
==================================

(If you don't want to know about this, please skip to the next session.)
This script is a basic rewrite of Hawkee's File Server script way back when.  (I got permission to rewrite the script like this from him, but I'm giving him credit, because this script wouldn't be here if it wasn't for him.)  After reading the help file of P&P's, I saw that it would be cool to use the features that pai has put for a file server.  All I did was make it look better.  I didn't rewrite the code, except the options window.  I just left most of the code the way it is, so I wouldn't have to spend a lot of time figuring out what I was doing; although, I could have.  I didn't have a lot of time to spend on this.

Also, throughout the time I have been using Hawkee's file server, I have made some changes to the script a little at a time.  I have incorporated these changes and allowed users to turn off options they didn't want.  Features I added:

Changed to allow users to decide which channels to display the join notice.
Allowed the file server to take over leeching.  There are many features with this, and they are explained in the options section below.
Made it so free credits were given to a user when they first open the fserve.
Allowed the owner of the fserve to tell users when they get credits and give them a quick and easy way to transfer credits from one user to another through an alias.
Put more information into the credit INI files, so those files aren't wasting too much space.  This is explained in the Credit Files section below.
Changed the security around a little bit.  This new security isn't a guarantee, but it's a little tougher.  This is explained in the Security section below.
Because the custom mode can cause some lag, I added a feature to where there is a delay between DIR commands.  This is explained in the Options below.

This doesn't work with the Zenith file server add-on--at least, as far as I have tested it.


==================================
	Options
==================================

Active:  Is the fserve on and ready to use?  (Default:  Off.)
Command:  Command that users type to activate the fserve.  (No default setting.)
Directory:  Which directory on your hard drive to use for the fserve.  (Default:  none.)
Welcome File:  This file is displayed when a user opens the fserve.  (Default:  none.)
Ratio:  This number is multiplied by the size of files that are uploaded.  For example, at a ratio of 5 and a file that's uploaded of 2,500 bytes will get 12,500 credits.  This can be turned off if you don't want to deal with credits; although, to me, it defeats the purpose of a fserve.  (Default:  2.)
Mode:  Normal or Custom.  There are two modes.  The normal mode is just a display of files and their sizes that mIRC does by default.  Custom mode allows you to attach a description to each file and to colorize the list.  Custom mode requires that a list is compiled, and it has to be compiled whenever you make changes if you want the changes to be displayed in the lists.  (This has its disadvantages and advantages.)  (Default:  Normal.)
Max Sends and Gets:  This limits how many file transfers a user can do.  (Default:  5 on each.)
Start Credits:  When users activate the fserve for the first time, they are given this many credits.  If you have the fserve handle leeching (explained below) on, you can specify what percentage of this number the user gets.  (Default:  1048576 (1 MB).)
Acceptable File Types:  This feature prevents you from getting files you don't need.  You can easily edit this list (thanks to P&P).  Make sure that each extension is separated by a comma.  (Default:  wav,mid,zip,jpg,txt,exe,gif,mp3)
Deny Files Starting with . . .:  This prevents files that start with a certain character from coming through.  The list is easy to edit, and a comma between each character isn't necessary.  (Default: !@)
Record Number of Top Downloads:  This determines of how many files are in the top downloads list.  (Default:  10.)
Join Notice:  This allows you to advertise your file server to people when they join a channel.  You can specify which channels you want it advertised to (all for all channels and none for none).  (Make sure that each channel name has a comma after it, including the last entry.  A comma will automatically be appended to the end if one isn't there.)  (Default:  None.)

Leeching

If you want, the file server can take over leeching.  If you allow leeching, people can get files from you without using any credits.  This feature makes it so they use credits.  With this option on, the file server DOESN'T have to be used.

Fserve Takes Over Leeching?:  This option should be self-explanatory.  (If this option is off, all the options that deal with leeching are off.)  (Default:  No.)
Show or Hide Leeching?:  This option is in case you don't have P&P's sound features installed.  All this feature does is prevents you from getting query windows with just sound requests and display a message to the active window saying which file was asked for.  If you use P&P's leech feature, I don't think it will matter which way you leave this feature.  (Default:  No.)
File Types to Leech:  This option allows you to decide which file types can be leeched.  The list is easy to edit.  (Make sure that each extension in the list is separated by commas.)  (Default: wav,mid,mp3)
Force Users to Have Account?:  With this option on, an fserve account is required for users to request files.  If the user doesn't have an account, one is created.  If the user requests a file and this option is off, credits will not be subtracted.  (Default:  No.)
If Yes, What Percentage of Free?:  If you have the above option on, this option specifies what percentage of free credits the user gets if an fserve account is created.  The user cannot get free credits twice.  If this option is at 50%, they only get half the credits they would get if they went to the fserve.  At 100%, the user gets all the credits they would normally get.  At 0%, they wouldn't get any free credits and makes it so they have to go into the fserve.  (Default:  50%.)
Leeched Files Cost More?:  This option is to encourage users to go to the fserve.  With this option on, the file types that can be leeched are half off in the fserve.  (Default:  Off.)

Custom Mode Options

Well, there is only one option so far on custom mode.
Delay between DIR commands:  This will help make the lag that comes with custom mode a little less.  This basically prevents users from typing DIR frequently in-a-row and lagging you.  If you don't want this option on, set it to 0.  The higher this number, the less frequently they can type DIR to get a list.  (This number resets when the user changes directories.)  (Default:  5 seconds.)

WARNING:  The file server will not properly give credits if the user isn't in a channel that you are in, because the script uses the $address identifier (see the Security section below for more information).


=============================================
	Custom Mode
=============================================

Custom mode is powerful with advantages and disadvantages.  I'm just going to list the features that custom mode adds:

Attaching descriptions to each file.
List is more friendly and colorized.
Files added and removed to the directory will not be in the list until the list is re-compiled.
Lag time on huge directories on slower computers.  (If you get too lagged up when someone does a DIR, you may want to consider splitting the directory into smaller directories.)

Just remember that the list needs to be recompiled whenever a change is made to the directory structure.


=============================================
	Descriptions
=============================================

Descriptions are now stored by just the filename, not the directory or full path.  It was a pain in the butt when the directory structure was changed, and the description file had to be changed manually.  Well, that's not the case, anymore.  Just the filename is recorded in the description file, so you can move the file all over the place in the fserve directory, and there will be a description.

When the fserve directory list structure is recompiled, the script will convert full path descriptions to the current, but it will only catch files that it finds as it compiles the list.  Because of this, a backup file of descbak.ini is created.  This is so descriptions of files that were moved but weren't updated aren't totally gone.

Bare in mind that a file can only have one description, so if there is one filename in more than one directory, there will be just one description for that file.

If you change the filename of a file, you better manually change the description's filename before re-compiling, or it will be removed from the describe.ini file.


=============================================
	Fserve Commands and Identifiers
=============================================

Warning:  The function key for P&P's e-mail is used, because I don't use the e-mail client script.  If you use P&P's e-mail script, this could cause problems.

FSCONFIG -- This command opens the fserve setup window.  Pressing F4 would have the same effect.  The directions for configuring the script should be pretty simple.
FSHELP -- This command opens this text file in your default TXT file viewing program--usually Notepad--for you to view.
AD -- Splats an ad to the current window.
TOP -- Displays the Top Downloads window for you to view.
ADD <nickname> <number> -- This command adds credits to a nickname's account.  (A negative number will subtract.)
DEL <nickname> <number> -- This subtracts with more intelligence.  This command prevents credits from going below one.  If you use add and a negative number, credits will go below one.  A credit of one means that they can't download anything, because a credit of zero means they don't have an account and they could leech files.
DES [filename] [description] -- This command will allow you to enter descriptions for one file at a time.  (I didn't change this feature because of time.)  You may enter a filename (path not required but makes a faster search) and/or a description from the command line, so you don't get the annoying prompts.
COMPILE -- This command will compile the fserve list.  During this process, the descriptions will get updated.
TRANS <nickname from> <credits to transfer> <nickname to> -- This command will transfer credits from one nick to another.  Now, be warned that this doesn't do any error checking.  If you transfer more than what a user has, the credits won't go in the hole, but the person that is receiving the credits will get extra credits.  (This command will display the transfer in a channel or query.)
TRANSQ <nickname from> <credits to transfer> <nickname to> -- Same thing as TRANS above, but the information is display through queries to both nicknames.
TRANSH <nickname from> <credits to transfer> <nickname to> -- Same thing as the two TRANS commands above, except it doesn't display any information.

Those commands above, except DES and COMPILE, can be accessed through some sort of popup.  Look under File Server.

Identifiers:

$byte.credits <nickname> -- This identifier returns the number of credits a person has.


==================================
	Popup Features
==================================

There are two popup features that are in the channel popups under File Server.  They are Advertise and Random File Offer.  Here's an explanation of each feature:  (These features can ONLY be accessed through the popup.)

Advertise Fserve:  This one is simple enough.  This will display an advertisement to any channel you wish saying how to get into your fserve (the command and ratio).  This ad will be displayed every 15 minutes.  (Now, that can be a long wait, but you can change the interval by changing the %fs.adtime variable.)

Random File Offer:  This feature will allow people to get a file from you for free.  This file is picked at random from a directory you specify at the specified interval.  (This feature will only work for one channel at a time.  There is no error checking, so if you activate it in one channel, and then activate it in another channel, it will only work in the second (or most recent) channel activated.)


==================================
	Commands IN Fserve
==================================

There are the default commands with the file server.  The following listed below are modified from the mIRC default by Hawkee:

GET <filename> -- Wildcards are accepted, but the user gets files until they hit their limit.
STATS [filename] -- Shows the stats of the user similar to what you would see in the Info Center, but the user just sees the ratio (if there is one), their credit status and the number of downloads and uploads.  If a filename is specified, they see the number of times a file has been downloaded.
TOP [number] -- Shows the top downloads of the fserve to the user.  A description is attached to the file, even if Custom mode isn't on.  (I didn't change this around.)  Specifying a number will allow the user to download the file without having to go the appropriate directory.
SRCH - This is a command that I added.  Users can type this command to find the directories of files.  Some wildcards are accepted.  (Note:  This command will NOT download the file(s).)


==================================
	Top Downloads
==================================

The script keeps track of the top downloads on the fserve for users to view and download.  You can view the list in a window with the TOP command.  Only files that are in the fserve are recorded in here.  In the original script, every single file that was downloaded was recorded, which made the file messy.

Every time the list is recompiled, the script will update the download.ini file at the same time.  This is so your top downloads are accurate.  Files that were deleted will be removed from the file and duplicate filenames will be combined into one.  With it this way, you don't have to worry about the file when you change the directory structure around.

To re-compile the top downloads, just type TOP, right-click on the window, and choose "Number of Files to Record."  After you enter that number, it will re-compile the list.

If the filename of file(s) is changed, make sure to change the filename in the download.ini file, or it will get deleted when the top download list is rebuilt.  There is no backup file of download.ini made.


==================================
	Credit Files
==================================

If you know how Hawkee's File Server works, then you pretty much know how they are set up, and it won't be hard to figure it out.  I'm just going to tell you what other information these files contain.  This is to make the space wasted on your hard drive less.  These files are in the CREDITS directory off your mIRC directory.

This script records each file that a user downloads and the date when a user last downloaded or uploaded.  This is so you can see what the user has uploaded or downloaded.  These files can be edited if you wish, but you edit them at your own risk.

==================================
	Info Center
==================================

This feature displays credit information for a nickname.

I have changed the Info Center around a bit.  I just added a couple of extra lines that includes the information that I have it record in the credit files.  You should see the difference.  I also changed the center around a bit and made the popups easier to use.

Some things I have changed that should be made known:  If you give users Unlimited or Banned credits, you'll have to clear the credits to turn it off.  When you clear credits of a user, the credits will appear as one credit.  This is because if the user has 0, they don't have an account and also prevents them from downloading anything if the file server handles leeching and the "force users to have an account" option is turned off.  (If you want to set someone's credits to 0, either use the DEL command or clear the credits and then remove the one credit.)

==================================
	Security
==================================

I have made some minor changes to the security to make it a little tighter.  Instead of using just the IP address (5.4.3.2), it uses the address that a user has in mIRC (through the $address identifier).  (Because of using the $address identifier, the user must be in a channel for the fserve to give them free credits and properly initialize the fserve.  I don't have much time to figure out a way around this at this time.  I may change this in future versions.)

The user's domain is recorded in their credit file to prevent people from using someone else's account.  If you are on DALnet or some other network where you can register your nicks and prevent other people from using a nickname, this feature isn't really necessary.  A level 3 address is recorded in the address.ini file in the DATA directory off your mIRC directory.  This is to prevent a user from using two or more nicks and possibly get more fserve credits.  If this security is breached, the credit file of the nickname the user is trying to access is deleted.  Because of this, I strongly recommend that you back up your credit files just in case a credit file is deleted.


==================================
	Files
==================================

The fserve creates two directories:  CREDITS and DATA.  The credit files are in the CREDITS directory.  Any other INI file the fserve needs is stored in the DATA directory.
ADDRESS.INI contains the addresses of nicknames for security.  You don't have to worry about this file, unless you have two users on the same address using your fserve.
CAT.INI contains the catalog of files in your fserve directory if you have the Custom mode on.  (Do not touch this file.  This file can be re-created, if necessary.)
DESCRIBE.INI contains the descriptions of files in your fserve directory.
DOWNLOAD.INI contains the number of downloads files in your fserve directory take.
(The last two files should be modified if you renmae any filename.)
TOP.INI contains the top downloaded files in your fserve directory.  This file can be updated when you change the number of files to record in the top downloads list.  (Do not touch this file, because this file can always be re-created.)

==================================
	Possible Problems
==================================

During testing of this script, there were some things that I noticed, and I'm going to warn you.

I can't talk in the fserve window.
mIRC has an option for listening for certain events in the DCC options.  To get around this, go to the DCC menu and choose Options (you could click the DCC icon in the toolbar, too).  Click Server.  In there, make sure there is a check box in the Fserve check box in "Listen for."  If that doesn't work, I don't know what could be causing it.  You could have a corrupted mIRC.  You can try to wipe out your mIRC stuff (after backing up important files) and install a fresh copy of P&P and the add-on.  (If you wipe out mIRC, and you back up certain files, the less you'll have to reconfigure.  My personal recommendation for which files to back up are the following extensions:  MRC, INI, DAT, and TXT.)

Users connected to my fserve can't change directories.
This fserve uses the CD command that comes with it.  One possible cause to this is that mIRC can't locate the directory, because it doesn't know where you are.  If this is the case, go into your DCC options (DCC, Options or clicking the DCC icon in the toolbar) and then click fserve.  In there, choose your directory.  You don't need a welcome file.  Another option is to go to Custom mode.  For reasons unknown to me, Normal mode sometimes doesn't work.

A directory won't show up in my custom list.
For some reason--whether Hawkee did this intentionally or not, I don't know--directories with no files in them will not show up in the compiled list.  The best way around this is to put a file in the directory that isn't showing up.  The file can be anything, even a 0-byte file, but a file has to be there.  (The root directory doesn't have to have files in there, but you can always put one in there, just in case.)

A file won't show up in the custom list.
This original script was written for use with Windows 3.x, so the script doesn't like spaces in filenames.  Just go through and get rid of any spaces in the filenames, and then re-compile the list.

A person that enters my fserve keeps getting a security breach, and they are using the right nick.  (A security breach, in this case, is when they get the message "free credits denied" when the fserve starts up.)
If two people under the same address are using your fserve, the script will write both of their nicks to the ADDRESS.INI file.  The $readini identifier will return the first one, and so it may cause a security breach.  To get rid of it, you can either just delete the ADDRESS.INI file, or you can open the file up in Notepad and search for the nicknames and then delete the line the nicknames are on.  I personally recommend just opening the file up in Notepad and deleting the lines, because you may delete other addresses and someone could get extra free credits.  This way, it will re-create the necessary data.  Also, tell the users that they can only have one account under that address.  One or both will have to change their address, usually just a username.

Someone is changing nicknames and usernames on their address to get into my fserve and get free credits.  (A username, in case you don't know, is the name that appears between the ! and the @ in an mIRC address, in this case.)
The best way to stop this is to turn off your fserve, go into the ADDRESS.INI file, and search for the nickname or address that is causing the problems.  Replace all characters between the ! and the @ with an *, so there is just an * there.  Then change the nickname listed to the first nickname.  After you have done that, you can set the number of credits on the nickname to Banned to prevent the person from getting in.  As of yet, I don't have a way to ban addresses, just nicknames.  After you tweak with the file and feel you got all the nicks he changed to, you can turn the fserve back on.  There are many other ways you can stop the person, too.  Just remember that the user has to be in a channel you are in, so the fserve can grab the address.

If you are having a problem that isn't listed above, please e-mail me or come into one of my chat rooms (listed below) and ask me.


==================================
	Author
==================================

If you have any questions about the script, please don't hesitate to drop me a line, and I can try to help you, if I know what the problem is.  My e-mail address is displayed when you install the add-on; however, just in case it was missed, it is jer@telcomplus.net.  This is my first attempt at an add-on script for distribution.  Please enjoy the script, and I hope it is something that is useful for you.

You can find me on DALnet in #mormon and #lds_chat.

JeremyX