From StatsLab Wiki
Revision as of 16:09, 12 February 2020 by Frank Esselink (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page contains instructions for installing the 3.x version of StatsLab. Installation is the same regardless of which version of OOTP you are using.

These installation instructions assume that you already have the following installed on your server:

  • PHP 7.2 or later 7.x version (must be on OOTP20 and StatsLab 3.20.09 or later)
  • PHP 5.2 or later 5.x version with mcrypt extension (all StatsLab versions 3.20.08 and earlier)
  • MySQL 5.2 or later installed.


Installation of StatsLab consists of a few basic steps:

  • Preparing the server
  • Installing StatsLab software
  • Configuring StatsLab
  • Generating the data out of OOTP
  • Uploading the data to StatsLab

Preparing the Server

Server preparation involves the following:

  • Validating PHP
  • Validating MySQL
  • Creating the database
  • Creating the StatsLab install directory
  • Creating the SQL upload directory

Validating PHP

StatsLab requires PHP version 5.2 or later with the mcrypt extension enabled. Most installations of PHP enable mcrypt by default these days. If you're not sure you can either ask your web host or install and hope things work. If mcrypt is not enabled, StatsLab will not be able to create user accounts and

Validating MySQL

Most web hosts provide some form of web portal to manage your website, and this almost always includes a recent version of MySQL. You should be able to identify the installed version of MySQL in this way. Make sure it's version 5.2 or later.

Creating The Database

From your website's admin console, be it cPanel or some other tool, you'll need to create a new MySQL database. Name it something like "StatsLab", and create a new user with access to the database. Make a note of the database name, the MySQL user name, and the password, as you'll need them later when configuring StatsLab to connect to the database.

MySQL User Permissions

In order for StatsLab to work properly, the MySQL user that StatsLab uses to access your StatsLab database must be configured to perform all the tasks that StatsLab needs to do. At minimum, the user needs to have the following permissions for the StatsLab database:


Creating the StatsLab Install Directory

The StatsLab install directory is the folder on your web server where you will install the StatsLab software itself. This folder must be accessible from the internet. Typically, your website will have the publicly visible pages all located within a folder called "public_html", so put your SQL upload directory within the public_html folder. It does not need to be in a cgi enabled folder such as the cgi-bin folder.

StatsLab does not need to be installed on the same server as the one that hosts your MySQL database, your OOTP generated HTML reports, your league file, your team exports, or your league website. Having them all on the same server does simplify configuration, but it's not a requirement.

To install, download the correct version of StatsLab for the version of OOTP that your league is running. Upload the archive to your servers new StatsLab install directory, and unzip the contents there. If you prefer to have a little more control, you can unzip the contents on your local machine and upload the files individually.

You will need to modify some of the files contained in the StatsLab archive, so keep a copy on your local machine.

Creating the SQL Upload Directory

The SQL upload directory is a folder on your StatsLab server where you will upload the MySQL data files that OOTP generates before loading them into the database with StatsLab. Since the raw SQL data can include true ratings and other information you may not wish for your league's GM's to have, it's a good idea to put it in a folder that is not accessible from the internet. Typically, your website will have the publicly visible pages all located within a folder called "public_html", so put your SQL upload directory above or at the same level as public_html.

Your SQL upload directory must be located on the same server as your StatsLab install directory.

Generating the MySQL Files

In order to generate the MySQL files required by StatsLab, you'll need to fire up OOTP, go into the game menu and find the Database Options screen. Once there, in in a corner of the screen is a button that pulls up a menu which allows you several options for dumping OOTP data out of the game for external use. The three methods of extracting data are CSV files, MS Access files, and MySQL files. For each type of data dump, there is an option to configure the data dump which is separate from the option to generate the data dump. For StatsLab, you'll always want the MySQL dump.

Configuring the MySQL dump in OOTP is a simple matter of checking and unchecking the correct boxes for the version of OOTP that you're running. Make sure that you are NOT using a Table Name Prefix. Leave that field blank.

These settings will be saved specific to the saved_game that you configured them in, so if you have multiple leagues that you are using StatsLab with, you'll need to do this with each league. Fortunately, the settings are saved with your saved game, so once you've configured the MySQL dump correctly, you won't need to make changes to it.

After configuring the MySQL dump, choose the option to generate the MySQL dump. A dialog box will appear indicating the progress made as each file is generated. The SQL files will all end up in your saved game's import_export folder.

Once there, you can FTP them to your SQL upload directory on your server.

Configuring StatsLab

You've got your server prepped and ready, and you've got your SQL data in your SQL upload directory waiting to be loaded. There are just a few more steps to getting StatsLab up and running:

  • Telling StatsLab where the SQL files are located
  • Configuring the database connection
  • Checking your work

Locating the SQL Files

You need to tell StatsLab where to find the SQL files that you uploaded to your server, and there's a simple text file that needs to be edited to tell it this. In your local copy of the StatsLab archive, in the StatsLab directory will be a file called config.txt.sample. This is a simple, one-line text file that StatsLab will use to identify where your SQL upload directory is.

Edit config.txt.sample in a text editor like Notepad or TextEdit. The file contains the keyword "ADMINPATH", followed by a pipe characer, "|", and then the full server path to your SQL upload directory. Typically, your full server path will include your web host assigned account name.

e.g. If your account name is "commish_bud", and you created the SQL upload directory for your major league as "/sql/mlb", then the contents of your file should look like this: ADMINPATH|/home/commish_bud/sql/mlb

Do not put a closing slash at the end of the line.

Save this file as "config.txt", then FTP it to your StatsLab installation directory. It should be in the same folder as the StatsLab PHP files.

Connecting to the Database

Similarly to editing the config.txt.sample file to config.txt, you'll need to edit dbopen.php.sample. This is a brief PHP script that will contain your database host, MySQL user for that database, the password, and the database you wish to connect to.

Replace "" with your database's host, in quotes. If your database is hosted on the same server that you installed StatsLab on, you can usually use "localhost" as the host.

Replace "sqluser" with the MySQL user you created for your StatsLab database.

Replace "sqlpassword" with your MySQL user's password.

Replace "sqldb" with the name of the StatsLab database you created.

Save this file as dbopen.php, then FTP it to your SQL upload directory.

IMPORTANT: Do not put this file in the StatsLab install directory. Because this file contains your database user and password, it's important that your SQL upload folder is not accessibly publicly.

Checking Your Work

Once you've got config.txt in your StatsLab directory and dbopen.php in your SQL upload directory, you can go ahead and try to connect to StatsLab from the web. Open up a web browser and point it to your StatsLab directory's validator.php file.


The validator page will validate the following for you:

  • You have the right version of PHP
  • The mcrypt PHP extension is enabled
  • The config.txt file is found
  • The dbopen.php file is found
  • The SQL upload directory contains all the required MySQL files
  • The connection with the database works

At the bottom of the validation page are links to the Admin page and the SQL File Load page

Troubleshooting Validation Failures

If PHP or mcrypt fail their checks, you'll need to contact your web host to get PHP configured correctly.

If the config.txt file is not found, make sure you've uploaded a renamed copy of the file, and not config.txt.sample.

If the dbopen.php file is not found, you have one of two issues:

  • The dbopen.php file isn't in the SQL upload directory. Perhaps you uploaded it as dbopen.php.sample.
  • The config.txt file doesn't contain the absolute path to the SQL upload directory (this is more common).

If the SQL upload directory is missing some required MySQL files, go into OOTP, generate the missing ones, and FTP them to your server. Note that including non-required MySQL files will cause slower updates with each sim, more server disk space used, and possibly generate unexpected errors in the upload process.

If you have a problem with your database connection despite dbopen.php being found, that means that you've got one of several problems:

  • The database host is incorrect.
  • The SQL user doesn't exist.
  • The SQL user's password is incorrect.
  • The SQL database doesn't exist.
  • The SQL user you've defined doesn't have access to the database you specified.
  • The SQL user yuu've defined doesn't have sufficient privileges for the database you've defined.

Next Steps

Once you've installed StatsLab, it's time to go configure it from the Admin screen.

OOTP doesn't export passwords, so the default password for StatsLab is 'baseball'. Be sure to change this for the commish account the first time you log in.