Permalink
Browse files

Initial Commit, starting with version 1.0.10

  • Loading branch information...
Kevin Roth Kevin Roth
Kevin Roth authored and Kevin Roth committed Aug 27, 2013
1 parent 87b9b33 commit b131f6546cabba3046111b979bf6be9331aab457
Showing 679 changed files with 39,986 additions and 2 deletions.
@@ -1,4 +1,24 @@
phppickem
=========
# PHP Pick 'Em
PHP Pick 'Em is a free php web application that allows you to host a weekly NFL pick 'em football pool on your website.
## Minimum Requirements
* PHP version 4.3 or greater
* MySql version 4.0 or greater
## Installation Instructions
1. Extract files
2. Create a MySQL database on your web server, as well as a MySQL user who has all privileges for accessing and modifying it.
3. Edit /includes/config.php and update database connection variables accordingly
4. Upload files to your web server
5. Run installer script at http://www.your-domain.com/phppickem/install. The installer will assist you with the rest.
## Logging In
Log in for the first time with admin / admin123. You may change your password once you are logged in.
## Troubleshooting
For help, please visit: http://www.phppickem.com/
@@ -0,0 +1,121 @@
<?php
require('includes/application_top.php');
$season = date('Y');
$games = 17;
$teamCodes = array(
'GNB' => 'GB',
'JAC' => 'JAX',
'KAN' => 'KC',
'NWE' => 'NE',
'NOR' => 'NO',
'SDG' => 'SD',
'SFO' => 'SF',
'TAM' => 'TB'
);
$schedule = array();
for ($week = 1; $week <= $games; $week++) {
$url = 'http://scores.espn.go.com/nfl/scoreboard?seasonYear='.$season.'&seasonType=2&weekNumber='.$week;
$raw = file_get_contents($url);
$newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");
$content = str_replace($newlines, "", html_entity_decode($raw));
//trim down to just the data section of the page
$startStr = 'espn.video.embeded.play(); }</script>';
$endStr = '<!-- begin sponsored links2';
$content = getInnerString($content, $startStr, $endStr);
//let's make it easier to match the game days
$markerStart = '<!-- start gameDay -->';
$markerEnd = '<!-- end gameDay -->';
//strip off the first character and add it back so first instance of pattern doesn't match during replace
$content = substr($content, 1, strlen($content));
$content = '<'.str_replace('<h4 class="games-date">', $markerEnd.'<h4 class="games-date">', $content) . $markerEnd;
$content = str_replace('<h4 class="games-date">', $markerStart.'<h4 class="games-date">', $content);
$gameDayHtml = explode($markerEnd.$markerStart, $content);
//print_r($gameDayHtml);
//exit;
for ($i = 0; $i < sizeof($gameDayHtml); $i++) {
//get the date
$matches = array();
$startStr = '<h4 class="games-date">';
$endStr = '</h4>';
$find = '|'.$startStr.'(.*?)'.$endStr.'|is';
preg_match_all($find, $gameDayHtml[$i], $matches);
$gameDate = getInnerString($matches[0][0], $startStr, $endStr);
$matches = array();
$find = '|<p id=".*?-statusText">(.*?)</p>.*?<a href="/nfl/clubhouse\?team=(.*?)">(.*?)</a>.*?<li class="final" id=".*?-aTotal">(.*?)</li>.*?<a href="/nfl/clubhouse\?team=(.*?)">(.*?)</a>.*?<li class="final" id=".*?-hTotal">(.*?)</li>|is';
preg_match_all($find, $gameDayHtml[$i], $matches);
//print_r($matches);
//exit;
$count = count($matches[1]);
for ($j = 0; $j < $count; $j++) {
$gameTimeEastern = $gameDate.' '.$matches[1][$j];
$gameTimeEastern = str_replace(' ET', '', $gameTimeEastern);
$gameTimeEastern = date('Y-m-d H:i:00', strtotime($gameTimeEastern));
//$overtime = (($matches[1][$j] == 'Final/OT') ? 1 : 0);
$away_team = strtoupper($matches[2][$j]);
$away_team_name = $matches[3][$j];
$home_team = strtoupper($matches[5][$j]);
$home_team_name = $matches[6][$j];
foreach ($teamCodes as $espnCode => $nflpCode) {
if ($away_team == $espnCode) $away_team = $nflpCode;
if ($home_team == $espnCode) $home_team = $nflpCode;
}
$away_score = (int)$matches[4][$j];
$home_score = (int)$matches[7][$j];
if ($away_score == 0 && $home_score == 0) {
$schedule[] = array(
'weekNum' => $week,
'gameTimeEastern' => $gameTimeEastern,
'homeID' => $home_team,
'homeTeam' => $home_team_name,
'visitorID' => $away_team,
'visitorTeam' => $away_team_name
);
}
}
//echo '<pre>';
//echo $gameDate;
//print_r($matches);
//echo $gameDayHtml[$i]."\n\n\n\n";
//echo '</pre>';
}
}
//output to excel
$output = '<table>'."\n".
'<tr><td>weekNum</td><td>gameTimeEastern</td><td>homeID</td><td>homeTeam</td><td>visitorID</td><td>visitorTeam</td></tr>'."\n";
for ($i = 0; $i < sizeof($schedule); $i++) {
$output .= '<tr><td>'.$schedule[$i]['weekNum'].'</td><td>'.$schedule[$i]['gameTimeEastern'].'</td><td>'.$schedule[$i]['homeID'].'</td><td>'.$schedule[$i]['homeTeam'].'</td><td>'.$schedule[$i]['visitorID'].'</td><td>'.$schedule[$i]['visitorTeam'].'</td></tr>'."\n";
}
$output .= '</table>';
// fix for IE catching or PHP bug issue
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
header('Content-Type: application/vnd.ms-excel;');
//header("Content-type: application/x-msexcel");
//header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=nfl_schedule_".$season.".xls");
echo $output;
//echo '<pre>';
//print_r($schedule);
//echo '</pre>';
exit;
function getInnerString($content, $startStr, $endStr) {
$startPos = strpos($content, $startStr);
$endPos = strpos($content, $endStr, $startPos) + strlen($endStr);
$content = substr($content, $startPos + strlen($startStr), $endPos-$startPos-(strlen($endStr)+strlen($startStr)));
return $content;
}
Oops, something went wrong.

0 comments on commit b131f65

Please sign in to comment.