OFFL

Online Fantasy Football League

Installing OFFL

These instructions are current as of OFFL v0.2.3

1. Database

Once the archive is extracted, you'll see two main directories. We'll deal with the sql directory first.

*** IF YOU DO NOT HAVE SHELL ACCESS TO THE DATABASE SERVER, SKIP TO "Alternately," ***
You need to edit the sql/setupdb.sh script and change these lines:

HOST=localhost
USER=offl_user
PASS=offl_pass
DB=offl_db

to whatever values you created the database with. In some later version it will create the database for you. You must have a MySQL database named whatever $DB is, and $USER must have full permissions on that database. Other than that ensure that the mysql executable is in your path.
Then cd into the sql directory and run ./setupdb.sh. This will run all scripts in the sql/tables folder and then all scripts in the sql/load folder. You should be golden.

*** RESUME HERE ***
Alternately, if you're not running an environment that supports the .sh file, use phpMyAdmin or the like to load the SQL files manually. Do all files in the sql/tables folder, then all files in the sql/load folder.

These files are not needed after installation.

2. PHP

Copy/move the contents of the www directory to wherever you want to base OFFL.

PHP Step 2a

The www/offlconfig.php file must be moved to a directory within your PHP include path. Additionally, the file must be modified so that $WEB_ROOT is set to the absolute path of OFFL and $DOC_ROOT is set to the root directory from which your webserver serves documents. This is not automated as the environment variables behave erratically when PHP is called from the command line. It (the file) does not need to be in your web server's document root, although it is protected from direct access.

What's my include path?

Create a file consisting of <?php phpinfo(); ?> and view it. Search for "include_path" and you'll see two columns of comma-separated directories. Any listed directory (to which you have access) is acceptable. If none apply, leave offlconfig.php where it is now. You'll need to make a copy later.

PHP Step 2b

The www/lib/config.php file must be edited to match the database settings noted above in the DATABASE section. Additionally, the cookie name used to remember logins can be edited (not necessary, but a unique cookie name never hurts).

This file also contains a new "Troubleshooting" section, a collection point for fixes related to global PHP configurations. Check and see if relevant errors or situations are listed, and if so, uncomment the appropriate lines of code.

PHP Step 2c

The www/lib/css/stylesheet.css file needs minor modification. There are three references to url(/offl/..... Within that string, /offl needs to be replaced with the value of $WEB_ROOT from step 2a for all three instances.

PHP Step 2d

Log in. The initial login is user general, password tso. Then select the default league. This brings up the full navigation bar, which allows you to go to Admin -> Users to change your username and password for this login.

PHP Step 2e

Automatic NFL roster download is now available. Go to Admin -> Players and select "Download NFL Roster", confirm your decision, and get the current league roster! Fullbacks are brought into the league as RBs.
Note: this is a relatively slow script and you may need to bump up the maximum execution time of your PHP config. I've kicked mine to 300 seconds just to be on the safe side.

PHP Step 2f

Download the current NFL schedule from Admin->Schedules. This is needed for roster display and stats processing.

Optional: Integrating Phorum

Phorum Step 1

Download the latest version of Phorum from http://phorum.org/. Brad has tested with 5.0.9.

Phorum Step 2

Unpack this into the webroot of your OFFL site, so the phorum-X.X.X directory is a subdirectory of your
webroot. I would recommend renaming it to just "phorum" or whatever.

Phorum Step 3

Now follow the Phorum directions for installing Phorum. I just installed it into my existing OFFL database; table names are phorums_*, so there should be no overlaps. I recommend specifying a base name such as offlforums.

Phorum Step 4

Now, from the phorum directory, edit the templates/header.tpl file so it looks like this (and only this):

<?php  $pageTitle = "Chat Forum";

require_once("../lib/config.php");
require_once("../offlconfig.php");

include ("../lib/header.php");

?>

<?php echo '<?xml version="1.0" encoding="iso-8859-1"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html lang="<?php echo $PHORUM['locale']; ?>">
<head>
<title>{HTML_TITLE}</title>
<style type="text/css">
{include css}
</style>
{if URL->REDIRECT}
<meta http-equiv="refresh" content="5; url={URL->REDIRECT}" />
{/if}
{LANG_META}
{HEAD_TAGS}
</head>
<body>
<div align="{forumalign}">
<div class="PDDiv">
{IF notice_all}
<div class="PhorumNotificationArea PhorumNavBlock">
{IF PRIVATE_MESSAGES->new}<a class="PhorumNavLink" href="{PRIVATE_MESSAGES->inbox_url}">{LANG->NewPrivateMessages}</a><br />{/IF}
{IF notice_messages}<a class="PhorumNavLink" href="{notice_messages_url}">{LANG->UnapprovedMessagesLong}</a><br />{/IF}
{IF notice_users}<a class="PhorumNavLink" href="{notice_users_url}">{LANG->UnapprovedUsersLong}</a><br />{/IF}
{IF notice_groups}<a class="PhorumNavLink" href="{notice_groups_url}">{LANG->UnapprovedGroupMembers}</a><br />{/IF}
</div>
{/IF}
<span class="PhorumTitleText PhorumLargeFont">
{IF NAME}<a href="{URL->TOP}">{NAME}</a>&nbsp;:&nbsp;{/IF}{TITLE}</span>

Similarly, edit the templates/footer.tpl file so it reads thusly:

<div class="PhorumFooterPlug" align="center">This <a href="http://phorum.org/">forum</a> powered by <a href="http://phorum.org/">Phorum</a>.</div>
<!-- these are the two div's from header.tpl -->
</div>
</div>
</body>
</html>

<?php
require("../lib/footer.php"); ?>

Phorum Step 5

Now you just need to provide links. For now you'll have to manually edit the www/lib/header.php (from the OFFL install), copy one of the header links, and make one for your Phorum. Note that your actual Phorum will have a url ending in "list.php?f=1" or something like that.

3. Site Maintenance / Automatic Scripts

The www/maintenance directory contains files that periodically update the status of OFFL. They are intended to be run via cron. In each case, they should be placed OUTSIDE of your $DOC_ROOT. Details on the format of the crontab line are in each file as comments near the top or via the phpDocumentor-generated notes.

Windows users may use pycron as a cron replacement. Basic format is the same. Alternately, the Windows Task Scheduler can accomplish the same purpose, but you'll have to figure out its functionality yourself.

Mac users running OS X may use CronniX as a graphical user interface for the built-in cron.  A working crontab created with Cronnix is available here (although making a maintenance script world readable is a security risk).

Note: if you do not have access to a directory in PHP's include path (from step 2a), you must copy www/offlconfig.php to this directory (giving you two copies total).

4. Miscellaneous

The www/images/logos directory should be writable by PHP if you want to allow users to upload logos from their hard drives. Eventually, an OFFL control setting will be in place for this.

5. Party

w00t! You should be good to go. Fire up your server and go to your website in your browser of choice. OFFL looks particularly nice with Mozilla Firefox, by the way.

Stephen and Brad