ASP Football Pool
Version 2.3
Copyright 1999-2009 by Mike Hall.
Contents
License and Disclaimer
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
This software includes a copy of TinyMCE, used under the GNU Library General Public License. See the LGPL license for more details.
Description
This web application allows you to host a weekly pick'em football pool for your friends and acquaintances. In addition, you can run a survivor pool, a margin pool or a combination of both. It is designed to be easy to set up and run with minimal maintenance. Some notable features:
- Options to use point spreads and/or confidence points.
- Includes an optional pool covering the playoff games.
- Has the option to run a survivor, margin or a combined pool on the side.
- Password-protected access for users.
- Easy, online sign up for players.
- Entries may be made for weeks in advance.
- Picks are automatically locked based on the game schedule.
- For the survivor/margin pool, players are automatically prevented from using a team more than once.
- Players can be prevented from seeing other's picks until games are locked.
- Players may edit or delete their entries up until games are locked.
- Administrator can modify player entries (even after games are locked).
- Results are automatically updated as soon as game scores are entered by the Administrator.
- Players can update their profiles to provide contact information for the Administrator.
- Players may choose receive email notifications for different types of updates (game scores, scheduling changes, etc.).
- Entry fees and pool winnings are automatically tracked.
- Administrator can enter payment information and view account balances.
- Players can view their own account history/balance and winnings.
- Displays weekly and team schedules as well as division and conference standings.
- Provides overall player statistics.
- Optional message board for users, with rich text editing.
A designated Administrator manages the pool: setting the point spreads (if used), entering game scores and updating the game schedule as necessary. The Administrator also manages user accounts and can update the home page with news, announcements, etc.
Pool Formats
Here is a brief description of the available pools and options.
Weekly Pool
Each week, players enter by guessing the winner in each of the week's games. Whoever scores the highest in that week wins. Players are also asked to guess the total number of points that will be scored in the Monday Night game. In the event of a tie, the player or players who guess closest to that total win.
You can choose to use point spreads, in which case players must pick teams to win against the spread, rather than straight up.
You can also choose to use confidence points, where players must rank each pick from one to however many games there are that week. Players are scored by totaling the points assigned to each correct pick.
Playoffs Pool
This pool is similar to a weekly pool, except that it covers all the postseason games and there is no tiebreaker. If point spreads and/or confidence points were used in the weekly pool, they will be used in the playoffs pool as well.
Survivor Pool
This pool is separate from the weekly pools and runs the length of the regular season. Players are asked to pick a team each week and cannot use any team more than once. If their team wins, they continue on to the next week. If their team loses, they are eliminated. The last player left standing wins.
Should all active players be eliminated in a given week, they are automatically reinstated and continue on to the next week. If more than one player survives the entire season, the number of correct picks is used as a tiebreaker.
If desired, you can configure this pool to allow two or more losses before elimination. You can also choose whether to count a tie game as a win or a loss.
Margin Pool
This pool is played much like the survivor pool: players try to pick a winning team each week and cannot use the same team more than once. Unlike the survivor pool, however, players are not eliminated for losing picks. Instead, the goal is pick the team that will win by the most points each week.
When a player's team wins, the number of points the team won by is added to his or her total. When a team loses, the player's total is deducted by the number of points the team lost by. The player with the highest total score at the end of the regular season wins. Should two or more players tie for the highest score, the number of correct picks is used as a tiebreaker.
Optionally, you can choose not to deduct points for a losing pick. Instead, the player will receive zero points for that week.
Combined Survivor/Margin Pool
You can also combine the survivor and margin pools. Players pick one team each week and that team is used in both pools. Players eliminated from the survivor pool can continue playing in the margin pool.
You can specify how to divide the pot between each pool. For example, you might award 75% to the winner of the survivor pool and give the remaining 25% to the margin pool winner.
Note: By default, the survivor, margin or combined pool begins on the first week of the season. You can set it to start on a later week, if desired.
The application includes a help page that explains the pool rules in more depth. It is automatically tailored to cover the specific pool options you have set. Be sure to read the special Administration sections before attempting to run a pool.
Requirements
This application is designed to run on Internet Information Server (IIS) web servers, using Active Server Pages (ASP) and a Microsoft Access database. To host it, your web server must support ASP and have the appropriate database drivers installed.
You may also need the ability to modify directory permissions on your site in order to allow updates to the database. Check with your hosting provider to ensure your site meets these requirements.
Some ASP programming knowledge is required in order to use the email notification feature. ASP has no built-in functionality for sending email. However, most hosting services provide some facility for sending emails via script. To make use of whatever your host provides, you will need to add the appropriate code as described below.
How to Set Up Your Pool
Please carefully review all the following steps before attempting to install the Football Pool on your own web site.
1. Configure Your Pool Settings
The includes/common.asp file contains several constant definitions that you need to customize.
The first section relates to your site.
'--------------------------------------------------------------------------
' Site settings.
'--------------------------------------------------------------------------
'Site URL, used for the emails sent to users.
const POOL_URL = "http://www.example.net/FootballPool"
'Page title.
const PAGE_TITLE = "2009 Football Pool"
'Administrator email address.
const ADMIN_EMAIL = "admin@example.net"
'Flag indicating whether the server can send email or not.
const SERVER_EMAIL_ENABLED = true
'Sign up invitation code.
const SIGN_UP_INVITATION_CODE = ""
'Time zone difference between host server and database schedule (Eastern).
const TIME_ZONE_DIFF = 0
'Location of the database.
const DATABASE_FILE_PATH = "./data/NFL.mdb"
'Key used for encrypting private player data.
const DATA_ENCRYPTION_KEY = "4k0s*b92mqld:pdw7d4sklda8adz@d{a"
'Username session variable.
const SESSION_USERNAME_KEY = "FootballPoolUsername"
POOL_URL
Set this to the web address of your pool.
PAGE_TITLE
This is used on the top banner and title of all pages.
Each individual page also has a subtitle.
ADMIN_EMAIL
Set this to the email address you'd like players to use to contact you.
SERVER_EMAIL_ENABLED
Indicates whether email send capability is available or not.
If your host does not permit you to send email via ASP set this to false.
Note that email notifications will not be available in this case and there will be no email confirmation for user sign ups.
SIGN_UP_INVITATION_CODE
You can use this to restrict user sign ups.
If left as an empty string, anyone may use the sign up page to create a user account.
To prevent just anyone from signing up, you can set this to a simple character string (e.g., a four-digit number, a password, etc.) which you would then give out to those you wish to invite to the pool. Users trying to sign up will be required to enter that string on the sign up form. Note that if used, the invitation code is case-sensitive.
TIME_ZONE_DIFF
Set this to compensate for the time zone difference between your web server and the Eastern time zone.
For example, if your web server is located in the Central time zone, set the value to -1.
If your web server is located in the Pacific time zone, you should set the value to -3
DATABASE_FILE_PATH
This is used to set up the database connection.
Initially, the database file (NFL.mdb)is located in a subdirectory named data.
If you move or rename that database file, you will need to update this constant accordingly.
Note that some hosts provide a specific location on their server for databases. If that is the case, see below.
DATA_ENCRYPTION_KEY
This character string is used to encrypt and decrypt user profile data (email address and contact information).
It is recommended that you change this key so that it is unique to your installation.
Any string of 20 to 40 random characters will do.
SESSION_USERNAME_KEY
This is the name used for the ASP Session variable that tracks users when they log in.
Normally, you can leave it alone.
But, if you have multiple instances of the pool installed on your site, you should make this value unique in each.
Any name can be used.
The next section defines the options for the weekly pool.
'-------------------------------------------------------------------------- ' Pool settings. '-------------------------------------------------------------------------- 'Cost of a weekly pool entry. const BET_AMOUNT = 5 'Allow tie picks flag. const ALLOW_TIE_PICKS = false 'Hide other players picks until the games are locked flag. const HIDE_OTHERS_PICKS = false 'Use confidence points flag. const USE_CONFIDENCE_POINTS = false 'Use point spreads flag. const USE_POINT_SPREADS = false
BET_AMOUNT
The cost for each weekly entry, in dollars.
ALLOW_TIE_PICKS
If true, any games that end in a tie will only count towards a player's score if the player actually picked a tie for that game.
If false, players may not pick games to end in a tie.
Instead, all players will receive half the normal points awarded for a correct pick on any game that ends in a tie.
HIDE_OTHERS_PICKS
If true, players cannot see picks made by other players for games until they have been locked.
The Administrator can still see all picks, however.
If false, players can see other player's picks as soon as they are made.
USE_CONFIDENCE_POINTS
If true, players must assign confidence points to each pick.
For a given week, the point values range from one to the number of games that week and each number can be used only once.
The player's score for that week will be the total of the points assigned to each correct pick.
If false, a player's score is simply the number of correct picks he or she made that week.
USE_POINT_SPREADS
If true, the outcome of each game is based on a point spread, set by the Administrator.
If false, picks are straight-up.
Next are the options for the playoffs pool.
'-------------------------------------------------------------------------- ' Playoffs pool settings. '-------------------------------------------------------------------------- 'Enable playoffs pool pages flag. const ENABLE_PLAYOFFS_POOL = false 'Cost of a playoffs pool entry. const PLAYOFFS_BET_AMOUNT = 20
ENABLE_PLAYOFFS_POOL
Set this to true to make the playoffs pool available.
You can set this to false during the regular season to trim down the number of items shown on the site menu.
Just set it back to true when the playoffs begin.
Note that the playoffs pool is played much like a regular weekly pool. If the weekly pool is set to use point spreads and/or confidence points, the playoffs pool will be too.
PLAYOFFS_BET_AMOUNT
The entry cost for the playoffs pool, in dollars.
Next are the setting for the optional side pool. This pool is separate from the weekly pools and runs over the course of the regular season.
'-------------------------------------------------------------------------- ' Side pool options. ' ' Note: You can choose to add a survivor pool, a margin pool or both. Note ' that if both are enabled, users make a single pick each week which will ' apply to both pools. '-------------------------------------------------------------------------- 'Enable survivor pool. const ENABLE_SURVIVOR_POOL = false 'Enable margin pool. const ENABLE_MARGIN_POOL = false 'Cost of a survivor/margin pool entry. const SIDE_BET_AMOUNT = 10 'Starting week of the side pool. const SIDE_START_WEEK = 1 'Amount of pot that goes to the survivor pool winner(s). '(Applies only when a combined survivor/margin pool is used, the winner(s) 'of the margin pool get the remainder.) const SURVIVOR_POT_SHARE = .75 'Number of losing picks that will eliminate a player. const SURVIVOR_STRIKE_OUT = 1 'Tie game counts as a losing survivor pick flag. const SURVIVOR_STRIKE_ON_TIE = true 'Deduct points on a missing margin pick flag. const MARGIN_DEDUCT_LOSS = true
ENABLE_SURVIVOR_POOL
Set to true to enable the survivor pool.
ENABLE_MARGIN_POOL
Set to true to enable the margin pool.
Note that if both pools are enabled, it is considered a combined survivor/margin pool.
Players pay one entry fee for this combined pool and make one pick each week which will be applied toward both pools.
You will want to set SURVIVOR_POT_SHARE (see below) to determine how to split the pot between the two pools.
SIDE_BET_AMOUNT
The entry cost for the side pool, in dollars.
SIDE_START_WEEK
The week that the side pool begins.
This is useful if you initially disabled the side pool but later on, after the season has begun, decide you'd like to include it.
SURVIVOR_POT_SHARE
Applies only if you combine the survivor and margin pools.
This value determines how much of the total pot is awarded to the winner(s) of the survivor pool.
The remainder will be awarded to the winner(s) of the margin pool.
It should be a number between zero and one.
For example, if set to .50, the pot will be split evenly between the two pools.
SURVIVOR_STRIKE_OUT
For the survivor pool, this number determines how many incorrect picks it takes to eliminate a player.
Setting it to one means a player is eliminated with a single loss,
setting it to two means a player is eliminated on their second loss, etc.
SURVIVOR_STRIKE_ON_TIE
Set to true to count a tie game as a loss in the survivor pool.
If set to false, tie games will be counted as a win.
MARGIN_DEDUCT_LOSS
If set to true, players will lose points in the margin pool when their pick loses.
Note that if a player does not submit a pick for a given week, their score will be deducted using whichever game had the greatest scoring difference that week.
Setting this to false means that players will receive zero points for a losing or missing pick.
The next section controls the message board.
'-------------------------------------------------------------------------- ' Message board settings. '-------------------------------------------------------------------------- 'Enable message board flag. const ENABLE_MESSAGE_BOARD = true 'Define maximum message length allowed. const MAX_MESSAGE_LENGTH = 2000 'Define the number of days to keep posts. Set to zero to keep posts 'indefinitely. const MAX_POST_AGE = 30 'Define the maximum number of posts to keep (when this limit is exceeded, 'the oldest posts will be removed first). Set to zero to keep an unlimited 'number of posts. const MAX_POST_COUNT = 250 'Number of posts displayed per page. const POST_PAGE_SIZE = 10
ENABLE_MESSAGE_BOARD
Set to true to enable the message board.
If set to false, users will not be able to post or view
messages.
By default, messages posted on the message board are removed after a certain number of days, or if the total number of messages exceeds a certain limit. There is also a limit on the size of any one message. All this is intended to keep the database from growing too large and possibly impacting performance. You can adjust these limits to suit your particular installation.
MAX_MESSAGE_LENGTH
Defines the maximum number of characters that can be used in a single post.
Note that this includes HTML markup characters.
MAX_POST_AGE
Defines the maximum number of days that a post will be kept.
Posts older than this will be deleted.
MAX_POST_COUNT
Defines the maximum number of posts that will be kept in the database.
When this limit is reached, posting a new message will cause the oldest post in the database to be removed (regardless of its age).
POST_PAGE_SIZE
This simply defines how many posts will be shown per page when viewing the message board.
It does not affect the size of messages or how long they are kept.
The final section defines some images that are used on various pages. You can generally leave these as is, even if you edit or replace the images they refer to. The only time you'd need to change these values is if you change an image's location or filename (for example, replacing a GIF image with a PNG image).
'-------------------------------------------------------------------------- ' Defines images used on forms. '-------------------------------------------------------------------------- 'Pop-up calendar and clock button image sources. const CALENDAR_BUTTON_SRC = "graphics/calendar.gif" const CLOCK_BUTTON_SRC = "graphics/clock.gif" 'Locked game image tag. const LOCKED_IMG_TAG = "<img src=""graphics/locked.gif"" alt=""Locked"" width=""13"" height=""13"" />"
CALENDAR_BUTTON_SRC
Defines the source URL for the calendar image button on the schedule update pages.
CLOCK_BUTTON_SRC
Defines the source URL for the clock image button on the schedule update pages.
LOCKED_IMG_TAG
Defines the <img> tag for the locked image used on entry form pages.
Note that the tag includes the image's dimensions.
2. Code Your Email Function (Optional)
The includes/email.asp file contains a function stub named SendMail().
This is intended to programmatically send emails to players, such as when a new user signs up or when the Administrator sends email notifications regarding point spreads updates, scheduling changes, etc.
Because each web host is different, you'll need to edit this function to provide working code for your particular installation.
Check with your host provider regarding how to send email via ASP.
Most provide sample code which you can tailor to your needs.
If your host does not provide this functionality, set the SERVER_EMAIL_ENABLED option to false in your configuration settings.
Your implementation should use the function arguments defined in the code stub. It should return an empty string if the email was successfully sent or an error message if it fails.
Below is an example using CDOSYS (commonly found on Windows servers) showing how to use the function arguments and set the return a value:
function SendMail(toAddr, subjectText, bodyText)
dim mailer
dim cdoMessage, cdoConfig
'Assume all will go well.
SendMail = ""
'Configure the message.
set cdoMessage = Server.CreateObject("CDO.Message")
set cdoConfig = Server.CreateObject("CDO.Configuration")
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
cdoConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.example.net"
cdoConfig.Fields.Update
set cdoMessage.Configuration = cdoConfig
'Create the email.
cdoMessage.From = ADMIN_USERNAME & " <" & ADMIN_EMAIL & ">"
cdoMessage.To = toAddr
cdoMessage.Subject = subjectText
cdoMessage.TextBody = bodyText
'Send it.
on error resume next
cdoMessage.Send
'If an error occurred, return the error description.
if Err.Number <> 0 then
SendMail = Err.Description
end if
'Clean up.
set cdoMessage = Nothing
set cdoConfig = Nothing
end function
3. Upload the Files and Test the Database Connection
Upload all files to your web site.
You should then be able to browse to the site and login as the
Admin using the default password admin.
If not, the problem is probably with the database connection. Check that you set the database file path correctly in step 1 and that the database file has been uploaded to that location.
If all looks correct, check with your host provider.
They may have specific requirements for setting up a database connection, such as storing the database in a special location, defining a datasource name, etc.
If that is the case, make the necessary configuration changes and/or move the database.
You may also need to modify the code for the OpenDB() subroutine in the includes/common.asp file to match what your host provider specifies.
Once you have the database connection working, login as the Admin and try updating the database, say by adding a new user. If you see an error like the following:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
It means you'll need to set up access permissions for the database file. Again, this is host-specific so check with your provider regarding how to set permissions to allow your database to be updated by web application..
4. Test Your Email Function (Optional)
If you've set your pool up to use email, you can test it by first editing the Administrator profile to add a working email address and check the "New announcements" notification option.
Then go to the "Edit News" page, check the "Send update notification to users." option and click on Save.
If all is well, you should receive an email at the address you specified within a few minutes.
5. Invite Some Friends to Play
Once installed and tested, you can start inviting your friends to play.
You can either manually add users (don't forget to give them the password you have assigned to them) or send them to the sign up form (remember to give them the invitation code, if you specified one in the pool configuration).
Release Notes
- 2.3 - Code clean-up, improved handling of survivor/margin pool status, updated display for entry form and result pages.
- 2.2 - Updated email notifications to include relevant data.
- 2.1 - Added the option to start the survivor/margin pool after the first week.
- 2.0 - Survivor/margin pool added, more performance enhancements, restructured site pages.
- 1.2 - Moved all configuration settings to the
includes/common.aspfile. - 1.1 - Modified to store calculated values for weekly results in the database for improved performance.
- 1.0 - Initial release.