# Web tracker admin

The following can be accessed via <your tracker directory>/admin by default. It is recommended that either the directory is passworded via .htacces, or renamed.

## Contents

1. Race Control
2. Team Data
   1. teams.yaml
   2. teams.csv
3. Track status
4. Configuration options
   1. Tracker settings
   2. Championship information
   3. Race information
   4. Qualifying information
   5. Server Settings
   6. Twitter Settings
5. Database server
6. Update tracker

## Racecontrol

A listing of all server events that are stored in the database, including server/LFS messages, users leaving/pitting in the race, errors, penalties, etc. with a timestamp and also the time elapsed since the start of the race. These are colour coded to make it easy to spot, for example, driver chat (where the first 3 digits of the message are a number). You can also link directly to an event ID by appending "#ID" to the url.

type | lfsworld | example value | filtered | description
--- | --- | --- | --- | ---
RACE_START | - | 1 |  |
LEAVE | yes | 248 (time in seconds since the race start) |  | Produced when a driver leaves the race, e.g. loses connection, spectates
SHIFTS | yes | 3708 (time in seconds since the race start) |  | Produced when a driver telepits
MSG | - | 27 - N. Kiss : :-( | driver chat | Counts as driver chat when the first 3 characters of the message are > 0
MSG | - | MoE|B.Keough : GT1, double file now | admin chat | Matches names or admin name prefixes
MSG | - | Can't load skin : FZR_sraston24_gt2 | chat | All other messages containing " : " count as chat
MSG | - | SAFETY CAR DEPLOYED | rcm / msg | Messages which match common race director phrases
MSG | - | Fastest lap : 2:39.43 by 21 - M. Gassner (FZR) | fastest lap | Fastest lap (does not work on replays)
MSG | - | 44 - T. Nogieć : DRIVE-THROUGH PENALTY | dt penalty | Drive-through penalty
MSG | - | 44 - T. Nogieć : completed drive-through penalty | dt complete | Drive-through penalty completed
MSG | - | 11 R. Mroz : STOP-GO PENALTY | sg penalty | Stop-go penalty
MSG | - | 11 R. Mroz : completed stop-go penalty | sg complete | Stop-go penalty completed
MSG | - | MoE|J.Palmer blocked messages | msg blocked | User blocked messages
MSG | - | MoE|J.Palmer unblocked messages | msg unblocked | User unblocked messages
MSG | - | FATAL TCP ERROR : CONNRESET | tcp error | TCP Error
MSG | - | › MoE|C.Wilkinson : JOOS - CAR ENG | joos error | JOOS error

## Team data

Information about each of the teams is stored in teams.yaml, using YAML markup or in teams.csv, using CSV.

### teams.yaml

Indentation must be preserved otherwise it will break the tracker. Blank values will be ignored; however, teamName, car, number (leading zeros may be added by the tracker), and drivers are mandatory values. To enable multi-class tracking, class must also be filled in. To show positions gained and the grid before the race, grid needs to be filled in. Also, where the team's class is GT2 or GT3, or where GT1 is not the fastest class, the final "R" in the car code will be replaced by numbers 1, 2 or 3 - e.g. FZR will become FZ2 for GT2.

It is advisable to keep the teams in numerical order, to find them easily to make changes or mark them as retired for instance. Also, if any text contains spaces and does not display correctly in the tracker, you may need to add quotation marks around the "text".

The tracker also uses the names (and numbers) to work out who has finished the race, and to count pit stops and DT/SG from each team by reading the server messages - therefore numbers and names should be exactly as they appear in LFS, and vice-versa.

`

    # This is a comment, useful for noting which race these teams are for

    -
     teamName: Example Motorsports
     class: 3 letter class code
     car: 3 letter car code
     number: Number
     server: Number
     grid: Number
     penaltyLaps: -/+ Number
     penaltyTime: -/+ Number
     teamStatus: RET/DQ/DNS
     drivers:
      - {username, Forename Surname, Country}
      - {srdjanmilasinovic, Srđan Milašinović, Serbia}

`

List of countries (84) as of 10/11/2012: albania, andorra, argentina, armenia, australia, austria, azerbaijan, bangladesh, belarus, belgium, bolivia, bosnia and herzegovina, brazil, bulgaria, canada, chile, china, colombia, croatia, cyprus, czech republic, denmark, ecuador, england, estonia, finland, france, georgia, germany, greece, grenada, hong kong, hungary, iceland, india, indonesia, ireland, italy, jamaica, japan, kazakhstan, latvia, lebanon, liechtenstein, lithuania, luxembourg, macedonia, malta, mexico, moldova, montenegro, netherlands, new zealand, northern ireland, norway, pakistan, paraguay, peru, philippines, poland, portugal, romania, russia, san marino, saudi arabia, scotland, serbia, slovakia, slovenia, south africa, south korea, spain, sri lanka, sweden, switzerland, taiwan, turkey, ukraine, united kingdom, uruguay, usa, uzbekistan, vietnam, wales

3 letter ISO 3166-1 alpha-3 country names can also be used.

UTF-8 characters can be used. With the encoding of the input page and the tracker set as utf-8 this should work without a problem; if utf-8 characters are not displayed correctly, you may have to create the file in a text editor, save as UTF-8, and upload to the tracker directory.

### teams.csv

To use a csv file, $useTeamsCSV must be set to true in the config. All columns must be in place, regardless of whether they are used or not - they must still be kept blank to preserve the CSV file structure. The CSV option is especially useful for exporting from a spreadsheet. A header must be present for each column.

`teamName,class,car,number,server,grid,penaltyLaps,penaltyTime,teamStatus,username #1,driver name #1,country #1,username #2,driver name #2,country #2`

## Track status

Used to manually set the track status. The tracker will automatically get the track status from the GREEN FLAG, SAFETY CAR DEPLOYED, SAFETY CAR IN THIS LAP, RED FLAG and CHEQUERED FLAG server messages, and check the timecode of these against the last modified timestamp of the trackstatus.txt file - using the most recent update. The tracker does not refresh on PRE-RACE or CHEQUERED FLAG, but should once it receives a server message - if not you may have to set it to GREEN FLAG as the race starts.

## Configuration options

The configuration options have been set up so that most, if not all, of the tracker's features and settings can be changed without editing any of the PHP files. Config.php is loaded when the tracker is updated, so can also be used to run execute PHP code. There are 76 config items in total.

### Session switch

variable | type | description | example/default value
--- | --- | --- | ---
$trackerMode | text | Switches between race, qualifying and practice modes, defaults to race mode if empty | race/qual/prac

### Tracker settings

variable | type | description | example/default value
--- | --- | --- | ---
$useTeamsCSV | boolean | Use teams.csv instead of teams.yaml | false
$addZeros | boolean | Add zeros to car numbers 0 to 9 | false
$trimFinished | boolean | Match drivers names to "xxx has finished" and cut off laps, splits and pit stops after that point | true
$refreshTime | number | Meta refresh time in the html pages - minimum of 30 seconds | 45
$raceFinishOffset | integer | Offset in minutes, to move the countdown, usually in the case of a server crash | 0
$timeOffset | integer | Time offset in hours, if the last pit column is say, an hour out | 0
$sortStatus | boolean | Sort by RUN, NC, RET, DQ, DNS if true; DQ and DNS are always behind all other statuses | false
$inactiveTime | integer | Number of seconds since a team's last lap to mark them as not completing laps | 300
$driverPercentMax | integer | Maximum percentage allowed to be completed by one driver | 75
$driverTimeMax | integer | Maximum time in seconds allowed to be completed by one driver | 3600
$standingStart | text | Indicate a rolling start on the race status display | false/true/"formation"/# of rolling laps
$showServer | boolean | Show the server value for each team, if set | false
$showCars | boolean | Show the Car column | true
$showStatus | boolean | Show the teamStatus column | true
$showPrev | boolean | Show the previous lap column | true
$showSector | boolean | Show the sector graphics | true
$showHourly | boolean | Show links to hourly standings pages - remember to delete the hour_xx files before each race | true
$teamstatsComparisonLaps | integer | Number of laps for the teamstats pages | 10
$teamstatsComparisonNumber | integer | Number of teams above/below on the teamstats pages | 3
$updateNumber | integer | Number to prefix update.php for added security | random 6 digit number
$showCar | boolean | Show small car images for each team in this format: <number><class>.png | false
$showCarBaseUrl | text | Base url to the small car images | "http://mastersofendurance.eu/images/cars/thumb_";
$thumbCar | array | Used to add a suffix to a specific car image | [23] = "r3";
$dbServers | array | List IPs that will be shown in the DB server page | array("127.0.0.1 - my IP");
$debugArrays | boolean | Displays print_r($XMLRACE) and print_r($XMLTEAM) - the main arrays in the tracker for debugging purposes | false
$debugStats | boolean | Displays time taken to process the tracker data, the main loop and memory usage | false
$averagelap | percentage | Displays an average time for each driver if true, excludes laps over the percentage value, or does not display if false | 107
$raceControl | boolean | Produce the racecontrol.html file | true

### Page / Header / Footer design

variable | type | description | example/default value
--- | --- | --- | ---
$trackerRoot | text | Value prepended to the image sources for the flags, sector and expand images. | false, "/" or URL
$windowTitle | text | Title for all of the tracker pages - team/lapchart and #xx will be added | "Tracker - Round 0: 2 hours of Rockingham"
$faviconFilepath | option | Not required if favicon is in tracker directory | false, leader, or "faviconTracker.ico"
$jsFilepath | option | Not required as JavaScript is in the HTML | false
$cssFilepath | option | Filepath to the tracker's CSS stylesheet | false, "css/tracker.css" or "http://file.path/style.css"
$mainLogoSrc | text | Filepath of the main logo | false or "images/tracker_logo.png"
$mainLogoLink | text | Where the main logo should link to | false or "http://lfs.net"
$topInfoCars | text | Car class information | "<strong class='gt2dd'>GT2: </strong><a href='http://en.lfsmanual.net/wiki/Cars:RWD_GTR'>FXR+24%, XRR+25%, FZR+21%</a>"
$topInfoTrack | text | Track name/weather | "<a href='http://en.lfsmanual.net/wiki/Tracks:Aston#Cadet'>Aston Cadet</a>, Clear Day, High Wind"
$showtoplinksbar | boolean | show-hide the top links bar | true
$numtoplinksbar | number | number of links | 1
$toplinksbar[] | array | Name of the link | [1] = "LFS IRC"
$toplinksbarhref[] | array | URL of the link | [1] = "irc://irc.gamesurge.net/liveforspeed"
$showfooterlinks | boolean | show-hide the footer links | true
$numfooterlinks | number | number of links | 1
$footerlinkshref[] | array | URL of the link | [1] = "http://www.lfs.net"
$footerlinksimg[] | array | Filepath to the link image | [1] = "/images/LFS_S2_logo.png"
$footerlinksalt[] | array | Alternative text for the image | [1] = "Logo: Live For Speed"

### Championship information

variable | type | description | example/default value
--- | --- | --- | ---
$eventFull | text | Full event name, used for the grid/points standings links | "LFS Endurance Event 2011"
$h2eventName | text | Text shown above the main standings table (race/qualifying/practice will be appended) | "LFS Endurance Championship 2011 - Round 1 of 3"
$finalGrid | text | Link to final grid | false or "http://linkto.com/final/grid/image.png"
$championshipStandings | text | Link to championship standings | false or "http://lfsec.net/standings"
$championshipRound | integer | Number of previous championship rounds | 2

### Race information

variable | type | description | example/default value
--- | --- | --- | ---
$raceFocus | text | Chooses whether to show driver or team name first | "team" or "driver"
$futureRaceStart | timestamp | Timestamp for race start - see http://4webhelp.net/us/timestamp.php | 1287244800
$raceNumSectors | integer | Number of sector in the lap, to show the correct split position graphic | 3
$raceTrackLengthKm | number | Used for fastest lap speed, and for distance countdown | 7.4
$raceHours | integer | Number of hours in the race - $raceMins must be set to 0 | 6
$raceMins | integer | Number of mins in the race | 6
$raceLaps | integer | Number of laps in the race - $raceHours must be set to 0 | 0
$raceClasses | integer | Number of classes in the race | 1
$raceClassName[] | array | Name of each class | [1] = "GT1";

### Qualifying information

variable | type | description | example/default value
--- | --- | --- | ---
$qualifyingFocus | text | Chooses whether to show driver or team name first | "team" or "driver"
$distanceUnits | text | Units for display of speed | "kph" or "mph"
$percentLimit | number | Will highlight drivers/teams outside this percentage | 107
$futureQualStart | timestamp | Timestamp for qualifying start - see http://4webhelp.net/us/timestamp.php | 1287244800
$qualMins | integer | Session length in minutes | 30
$qualElimination | boolean | Sorts standings by each team's max race_id (i.e. F1-style knockout qualifying) | false
$showUnqualified | boolean | If the track status is not pre-race, show teams/drivers who have not completed a lap | true
$driverName | text | If $qualifyingFocus = "team", choose whether to display the name of the current or fastest driver | "fastest" or "current"

### Server settings

variable | type | description | example/default value
--- | --- | --- | ---
$numServers | integer | Number of servers the local tracker is connected to (unlimited) | 1
$manualIdServer1 | integer | Race_id in the database of server 1 (not normally set unless there are problems) | 3
$manualIdServer2 | integer | Race_id in the database of server 2 | 7
$manualIdServer3 | integer | Race_id in the database of server 3 etc. | 5
$serverCrash | boolean | - | false
$allRaceids | boolean | If $numServers = 1, use all available race_ids (not available in race mode) | false

Since the number of servers is unlimited, you can create however many $mannualIdServerXX variables as you require.

### Twitter settings

variable | type | description | example/default value
--- | --- | --- | ---
$twitterPositions | boolean | BETA feature, outputs top 3 in GT1/GT2 classes to twitter, edit stats2array.php to add authentication details | false

## Database server

Set the IP address of the database to access; you may also add the default MySQL port (:3306) and a prefix if necessary.

The page will display the contents of the race table in the database if it is able to connect to the IP/port.

## Update tracker

This will update the tracker at most every 30 seconds, and links to the update page including any security numbers in the filename to prevent just anyone running update.php.