paFileDB 2 Documentation
Version 2.0.3

Server Requirements
Here are the server requirements to run paFileDB 2

-Linux or Windows Server*
-PHP4 or higher
-MySQL Database Access
-About 200k of space for the scripts (The data in the MySQL DB will require more space)
*paFileDB 2 has been tested on Windows 2000 and Red Hat Linux 7.1 (Both running the Apache server) It should work without a problem on Windows NT, 9x, and ME and any distribution of UNIX or Linux as well as the Micro$oft IIS server or any other web server software that supports PHP

New in v 2.0.3
Version 2.0.3 just changes a few lines of code to prevent PHP from giving you an error message similar to "Warning: Cannot send session cache limiter - headers already sent" which occurs if you either put HTML data in pafileconfig.php  or pafileconfig.php contains empty whitespace at the end of the file (After the " ?> ") This problem is fixed in paFileDB 2.0.3 and you can then put whatever you want in pafileconfig.php :)

Installation
There are instructions for upgrading from various versions of paFileDB in this section. Please make sure you use the correct instructions
---Installing a brand new copy of paFileDB
These instructions apply if you're installing a brand new copy of paFileDB. If you will be upgrading from 1.x or installing over the first beta (which isn't upgradeable) please see the instructions below this set of instructions.

1. Open pafileconfig.php in a text editor and change the variables to how you need them. Make sure you don't remove the quotes (") or the semi-colons (;) so it still looks like this:

$variable = "value";

2. To install a brand-new copy of paFileDB, upload these files:
--admin.php
--adminmain.php
--adminnav.php
--admintop.php
--install.php
--pafileconfig.php
--pafiledb.php
--toplists.php
--header.html
--footer.html

--Everything in the images directory
--Everything in the posticons directory
--Everything in the sessions directory
*Not needed if you changed the header and footer files in pafileconfig.php
3. CHMOD the "sessions" directory 777 so paFileDB will be able to write the sessions to the directory. If you are using a Windows server, you do not need to do this
4. Make sure all your settings in pafileconfig.php for the MySQL database are correct, and run install.php to create the MySQL tables. You will need the admin pass you changed in pafileconfig.php
5. Done! Although the install is password-protected, you should delete install.php from the server to make paFileDB more secure. You can access your admin center by running install.php and you can access your file database by going to pafiledb.php

---"Upgrading" From Beta 1
Because the database format was changed in the final version, you cannot upgrade to this version from Beta 1 without losing your data.

1. Open pafileconfig.php in a text editor and change the variables to how you need them. Make sure you don't remove the quotes (") or the semi-colons (;) so it still looks like this:

$variable = "value";

2. To upgrade to this final version, upload these files to the same directory as Beta 1:
--admin.php
--adminmain.php
--adminnav.php
--admintop.php
--install.php
--pafileconfig.php
--pafiledb.php
--toplists.php
--uninstall.php

--Everything in the images directory
--Everything in the posticons directory
--Everything in the sessions directory
3. CHMOD the "sessions" directory 777 so paFileDB will be able to write the sessions to the directory. If you are using a Windows server, you do not need to do this
4. Run uninstall.php. This will delete the paFileDB tables in the MySQL database and delete all the data (for paFileDB 2, other script's data in the DB won't be affected.) This is necessary because of the DB format change.
5. Run install.php to create the new tables with the updated format.
6. Done! The URLs for the main database and admin center are still the same.

---Upgrading From Beta 2
If you will be upgrading from Beta 2, follow these instructions

1. Open pafileconfig.php in a text editor and change the variables to how you need them. Make sure you don't remove the quotes (") or the semi-colons (;) so it still looks like this:

$variable = "value";
The Beta 2 config file IS NOT compatible with the final version config file, so this step is necessary

2. To upgrade to this latest beta, upload these files to the same directory as Beta 1:
--admin.php
--adminmain.php
--adminnav.php
--admintop.php
--pafileconfig.php
--pafiledb.php
--toplists.php
--upgrade.php
--Everything in the images directory
--Everything in the posticons directory
--Everything in the sessions directory
3. CHMOD the "sessions" directory 777 so paFileDB will be able to write the sessions to the directory. If you are using a Windows server, you do not need to do this
4. Run upgrade.php. This will update the MySQL database to work with the final version. For maximum security, delete upgrade.php when you are done using it
5. Done! The URLs for the main database and admin center are still the same.

---Upgrading From v2.0 or v 2.0.1
If you will be upgrading from version 2.0 or 2.0.1, follow these instructions

1. To upgrade to this latest beta, upload these files to the same directory as Beta 1:
--adminmain.php
--adminnav.php
--admintop.php
--admin.php
--pafiledb.php
--Everything in the sessions directory
2. CHMOD the "sessions" directory 777 so paFileDB will be able to write the sessions to the directory. If you are using a Windows server, you do not need to do this
3. Done! The URLs for the main database and admin center are still the same.

---Upgrading From v2.0.2
If you will be upgrading from version 2.0 or 2.0.1, follow these instructions

1. To upgrade to this latest beta, upload these files to the same directory as Beta 1:
--adminmain.php
--adminnav.php
--pafiledb.php
2. Done! The URLs for the main database and admin center are still the same.

---Upgrading from 1.x
It is possible to upgrade from version 1.x without losing your data. Please read these instructions carefully because they are confusing.

1. Open pafileconfig.php in a text editor and change the variables to how you need them. Make sure you don't remove the quotes (") or the semi-colons (;) so it still looks like this:

$variable = "value";

2. To upgrade from 1.x, upload these files in the same directory as paFileDB 1.x:
--admin.php
--adminmain.php
--adminnav.php
--admintop.php
--install.php
--pafileconfig.php
--pafiledb.php
--toplists.php

--catconvert.php
--fileconvert.php
--header.html*
--footer.html*
--Everything in the images directory
--Everything in the posticons directory
--Everything in the sessions directory
*Not needed if you changed the header and footer files in pafileconfig.php
3. CHMOD the "sessions" directory 777 so paFileDB will be able to write the sessions to the directory. If you are using a Windows server, you do not need to do this
4. Run install.php to create the tables in the database.
5. Run catconvert.php. This will convert the categories from 1.x and add them to the MySQL database.
6. Run fileconvert.php. You will be given a list of the categories you imported in the last step. Click a category to import it's files The script will go through the 1.x data and find all the files in the category you chose, then import them into the database.
7. Repeat step 5 for each category.
8. You may need to recount the categories if the file count is incorrect (explained later in this file)
9. DELETE FILECONVERT.PHP AND CATCONVERT.PHP BECAUSE THEY ARE NOT PASSWORD PROTECTED AND ANYONE CAN SCREW UP YOUR DB BY RUNNING THOSE FILES IF YOU DON'T DELETE THEM!
10. Done! Although the install is password-protected, you should delete install.php from the server to make paFileDB more secure. You can access your admin center by running admin.php and you can access your file database by going to pafiledb.php

Administration
---Accessing Your Admin Center
You can access your admin center by running admin.php in your browser and entering your admin password. If you successfully logged in, you will see a menu with administrator options. You will need a cookie-enabled browser. Check your browser's documentation for enabling cookies.

---Category Options
The category administration allows you to add, edit, delete, and recount categories.
------Add Category

This allows you to add a category to your database. Simply fill out the form and it will be added.
------Delete Category
This will allow you to delete a category from the database. Although this will not delete the files in this category, the files in this category will not be able to be viewed any more.
------Edit Category
This will allow you to change a category's name and description.
------Recount Category
If paFileDB is displaying the wrong file count for a category (For example, there are 20 files in the category but paFileDB says there are only 12) the Recount a Category will correct the count and make paFileDB display the right number.

---File Options
The File Administration lets you manage the files in your database
------Add File
This will allow you to add a file to the database. Just fill out the form and the file will be added!
------Editing and Deleting Files
To edit and delete a file, remain logged in as an admin and browse to the file in the database (as a normal user would) and you will have admin options at the top of the page to edit and delete the file.

---License Options
The license administration lets you manage the license agreements in your DB. If you choose a license agreement for a file, a user will be shown the license agreement and must agree to it before being able to download the file.
------Add License

This will allow you to add a license to the DB.
------Delete License
This will allow you to delete a license from the DB. Please see the Known Bugs section before deleting a license...
------Edit License
This will allow you to change a license's title and text.

---Other Options
There are more options available in the paFileDB admin center. This section explains what they are.
------View Manual
This will show this manual you are reading right now.
------View License
This will show the paFileDB license agreement that you must accept to use this script.
------Version Check
This will take you to a page on the PHP Arena servers that will check the version of paFileDB you are using and see if there is a newer version, and if there is, let you know about it.
------Logout
This will delete your browser's cookies and log you out of the admin center. If you don't log out, you will automatically be logged out after an hour of logging in.

Top Lists
The Top List feature allows you to show top downloaded files or top newest files. You can use SSI or the PHP include(); command to include these lists anywhere on your site.

---Top Newest Files
You can view the Top X Newest files by running toplists.php?list=newest in your browser, or you can include it with SSI or PHP. You can set how many files to show in pafileconfig.php

---Top Downloaded Files
You can view the Top X Downloaded files by running toplists.php?list=downloads in your browser, or you can include it with SSI or PHP. You can set how many files to show in pafileconfig.php

Other Features
This explains some of the other features in paFileDB.

---Pinned Files
If a file is pinned, it will always be displayed at the top of the file listing, regardless of how the list is sorted. You can choose to pin a file or not when you add the file or edit it.

---New Files
Files will be marked as New on the file list page if they are X or less days old. You can set X in pafileconfig.php (5 days is the default)

---Time Offset
You can set a time offset feature to change the time of the files. For example, if the server time is GMT, but you want the times on the files displayed in Central Time (GMT -6) you can do that. You can set the time offset in pafileconfig.php

---Encrypted Cookie/Session Passwords
The administrator logging system uses cookies and sessions with the password stored in them. In Beta 1 and 2 of paFileDB, these passwords were stored in the cookie unencrypted, but in this final version, the passwords are encrypted using md5() so no one can find your password.

FAQ
This section answers some of the frequently asked questions.

Q: When I log into my admin center and click a link such as File Administration, it takes me back to the login page. Why?
A: Check to make sure cookies are enabled in your browser.

Q: How do I add post icons?
A: Just upload them in .gif format to the posticons directory and they will be displayed on the add/edit file page!

Q: How do I report bugs?
A: E-mail details to todd@phparena.uni.cc or post on the PHP Arena Support Forums

Q: Can I move the copyright at the bottom of the script?
A: Yes, as long as you have the Powered by paFileDB part and the link to PHP Arena and it's visible (Don't make the text white on a white background or whatever) you can move it.

Q: Will there ever be a flat-file version of paFileDB 2?
A: Probably not.

Q: Will there ever be a Perl or ASP version of paFileDB 2?
A:
---Code---
<?
$me = hate("Perl");
$me = hate("ASP");
$me = kill("Perl");
$me = kill("ASP");
?>

---Code---
Does that answer your question?

Q: How do I uninstall paFileDB 2?
A: I don't know why anyone would want to uninstall this wonderful script, but if you are that dumb :-), just upload uninstall.php from the paFileDB zip file and run it. It will delete all of paFileDB 2's tables from the MySQL DB and then you can delete the paFileDB 2 files from the server with FTP (Or whatever you use)

Q: Is paFileDB open source?
A: No. You are allowed to modify it to fit your needs, but it's not open source where you can do what you please with the script and release it with your name on it.

Q: My server doesn't support/allow .htaccess files, so people can view my "sessions" directory. Is this a security risk?
A: Until someone figures out how to decrypt md5 encryption (which will probably never happen) it isn't a security risk. The admin password and IP address that are stored in the session file are encrypted using md5 and probably never will be decrypted.

Q: Can I delete all those files in the "sessions" directory?
A: Yes you can. If someone is currently logged in as admin and you delete the files, all that will happen is they will be logged out and will have to log back in. In fact, you should delete the files once every week or so (Set a Cron job if possible) because the amount of files can get quite large, depending on traffic to your DB and how many times someone logs in as admin.

Q: Am I allowed to hack and distribute the script?
A: You are allowed to hack it as much as you want. As for distributing hacks, you are not allowed to distribute already-hacked files, but you may give instructions on adding the hack (Example: "On line 5, find the code ABC(); and replace it with XYZ();" or something similar is allowed)

Q: What if I do something great with the script like translate it to another language or make a flat-file version? Can I distribute that?
A: No, but if you e-mail a copy of the script to todd@phparena.uni.cc then I will be more than happy to add it to the PHP Arena file database to make it available for download and give you credit for doing whatever you did to the script.

Known Bugs/Issues
This explains some of the known bugs and issues with paFileDB.

If you delete a license and you still have a file with that license selected, a user will be asked to agree to a blank license when they download the file. To fix this, edit the file and either select no license or a different license.

Deleting a category doesn't delete the files in the category.

Sometimes the PHP Session ID (PHPSESSID) appears 2 times in the URL. Just simply ignore this, as long as it appears, there shouldn't be a problem.

License Agreement
Please read this whole file before installing paFileDB.

paFileDB is free to use and modify for almost all websites as long as you do not remove the paFileDB copyright and link to the PHP Arena homepage on the bottom of scripts.

paFileDB can not be used on the following types of sites:
-Warez Sites
-Hacking/Cracking Sites
-Pornographic Sites
-Any other sites that promote illegal activity

If your site is not included in that list and you keep the copyright info in the script, you may use and modify paFileDB.

You may distribute paFileDB as long as:
-You receive no payment for it except for costs such as internet fees (ISP, hosting, ect) and disc duplication and distribution.
-You do not modify it in any way.
-You distribute in the original zip file from PHP Arena's website (http://www.phparena.uni.cc) with all the files, including this license file.

You may use paFileDB on any number of websites you like as long as all those websites are not included in the above list of websites paFileDB can't be used on.

You may freely distribute any modifications you make for paFileDB, but you can not distribute a whole copy of paFileDB with your modifications in it. Modifications made available must contain instructions on modifying the file, not the already-modified file.

In no event will PHP Arena be liable to you for any consequential, incidental, or indirect damages (including damages for loss of business profits, business interruption, loss of business information, and the like) arising out of the use or inability to use paFileDB.

If this license agreement is broken, you must cease to use and destroy any copies of paFileDB you have installed.

If a PHP Arena staff member finds you breaking this agreement, s/he will send you an e-mail asking you to cease using and destroy the copy of paFileDB that is breaking the agreement. You will have 24 hours after the e-mail is sent to destroy the copy. If paFileDB is still up and running after 24 hours, legal action will be taken.

PHP Arena has the right to change this agreement at any time. Any changes will be posted on the PHP Arena website (http://www.phparena.uni.cc) and it is your responsibility to check for changes. If the agreement changes and then causes your copy of paFileDB to break this agreement, PHP Arena still has the right to take legal action.

Other Stuff
It is against the license agreement to do one of the following things with paFileDB:
-Remove the copyright at the bottom of the script
-Use it on a warez, porn, hacking, or other illegal site
-Sell it

Do you have a question that wasn't answered here? Feel free to post a message on the PHP Arena Support Forums to get an answer!

The post icons included with paFileDB were created by Matt Mecham and ©2001 Ikonboard.com and used with permission. You may use them on your copy of paFileDB, but must obtain permission at ikonboard.com to use them on another script.

Thanks
Thanks to Daniel from the PHP Arena team for putting up with me asking him stupid questions about MySQL every 5 minutes on AOL Instant Messenger
Thanks to Matt from Ikonboard for making the wonderful post icons and allowing me to use them.
Thanks to everyone who developed PHP for making a programming language that kicks ass
Thanks to the people a 105.7 FM The Point in St. Louis for playing good music while programming this (and all the other time)
Thanks to Coca-Cola for making soda with a lot of caffeine to keep me awake to program this script
<sarcasm>Thanks</sarcasm> to Gateway for giving me a crappy deal on a crappy computer to program this script on and then (probably) voiding my warranty since I upgraded to Windows 2000 and opened up my case to add a network card, CD burner, and second hard drive. (Please do yourself a favor and never buy a computer from them. You can find good computers here!)
Thanks to everyone who develops Linux and Red Hat Linux for making an operating system that not only kicks window's ass but makes programming easier
Thanks to Charter Pipeline for providing the cable internet to download Red Hat
Thanks to my neighbors for not getting pissed at me because I'm the cable bandwidth hog
And last but not least, thanks to everyone who downloaded this script (or any PHP Arena script) and supports PHP Arena

©2001 PHP Arena
paFileDB was developed by Todd from the PHP Arena team