From: Brad S. <sc...@us...> - 2007-09-06 03:34:05
|
Update of /cvsroot/offl/offl/www In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv27069 Modified Files: Tag: 1.10 games.php Log Message: Pulls updated schedule from CBS Sportsline. Index: games.php =================================================================== RCS file: /cvsroot/offl/offl/www/games.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** games.php 3 Jul 2006 17:34:03 -0000 1.9 --- games.php 6 Sep 2007 03:34:05 -0000 1.10 *************** *** 63,175 **** $result = mysql_query($sql,$dbconn) or die (mysql_error() . ": $sql"); ! foreach ($schedulearray as $line) ! { ! $schedule .= $line; ! } ! ! list ($beforesched, $aftersched) = explode("<div class=\"SLTables1\">", $schedule, 2); ! list ($schedule, $aftersched) = explode("<a name=\"post\">", $aftersched, 2); ! $weeks = explode ("<a name=\"week", $schedule); ! foreach ($weeks as $j=>$week) ! { ! if ($j == 0) ! continue; ! echo "<h2>Week $j</h2>\n\n"; ! $days = explode ("<font class=bg1font><b>", $week); ! foreach ($days as $n=>$day) ! { ! if ($n == 0) ! continue; ! debugprint($day); ! $game_date_array = explode("</b></font>", $day); ! debugprint($game_date_array[1]); ! $day_date = explode(",", $game_date_array[0]); ! $date = ltrim($day_date[1]); ! $games = $game_date_array[1]; ! $weekstd = explode("</tr>", $games); // break apart all games for the week ! foreach ($weekstd as $i=>$thisgame) ! { ! if ($i > 0) ! { ! @list($rest, $thisgame) = explode("<td align=left>", $thisgame, 2); ! } ! debugprint($thisgame); ! $thisgamedata = explode("<td align=left>", $thisgame); ! @list ($vTeam, $rest) = explode(" at ", $thisgamedata[0], 2); ! @list ($hTeam, $rest) = explode("<", $rest, 2); ! @list ($time, $rest) = explode("<", $thisgamedata[1], 2); ! $time = ltrim(strip_tags($time)); ! ! if ($hTeam != "") ! { ! unset($home_team); ! unset($visiting_team); ! foreach ($nfl_teams as $team) ! { ! if (($team->getNFLTeamCity() == $hTeam) || (strstr($hTeam, $team->getNFLTeamName()))) ! $home_team = $team; ! if (($team->getNFLTeamCity() == $vTeam) || (strstr($vTeam, $team->getNFLTeamName()))) ! $visiting_team = $team; ! } ! if (!isset($home_team) || !isset($visiting_team)) ! { ! echo "couldn't look up teams!"; ! } ! else ! { ! $full_datetime = "$date " . $_GET["year"] . " $time"; ! $datetime_str = strtotime(str_replace(".", "", $full_datetime)); // remove period from month abbr if applicable, convert to timestamp ! echo "<p>" . $visiting_team->getNFLTeamName() . " at " . $home_team->getNFLTeamName() . ", " . date("g:i A, D M j, Y", $datetime_str) . "</p>\n\n"; ! $thisGame = new OFFL_NFLGame(); ! $thisGame->setYear($_GET["year"]); ! $thisGame->setWeek($j); ! $thisGame->setGametime($datetime_str); ! $thisGame->setHNFLTeamID($home_team->getNFLTeamID()); ! $thisGame->setVNFLTeamID($visiting_team->getNFLTeamID()); ! $thisGame->save(); ! } ! } ! else // other data to extract ! { ! @list ($junk, $offteams) = explode("Open date:</b> ", $weekstd[$i], 2); ! if ($offteams != "") ! { ! list ($tm1, $tm2, $tm3, $tm4raw) = explode(", ", $offteams, 4); ! list ($tm4, $junk) = explode("<", $tm4raw, 2); ! foreach ($nfl_teams as $team) ! { ! if (($team->getNFLTeamCity() == $tm1) || (strstr($tm1, $team->getNFLTeamName()))) ! $team_1 = $team; ! if (($team->getNFLTeamCity() == $tm2) || (strstr($tm2, $team->getNFLTeamName()))) ! $team_2 = $team; ! if (($team->getNFLTeamCity() == $tm3) || (strstr($tm3, $team->getNFLTeamName()))) ! $team_3 = $team; ! if (($team->getNFLTeamCity() == $tm4) || (strstr($tm4, $team->getNFLTeamName()))) ! $team_4 = $team; ! } ! // echo "<p>Bye Teams: $tm1, $tm2, $tm3, $tm4</p>\n\n"; ! echo "<p>Bye Teams: " . $team_1->getNFLTeamName(); ! echo ", " . $team_2->getNFLTeamName(); ! echo ", " . $team_3->getNFLTeamName(); ! echo ", " . $team_4->getNFLTeamName(); ! echo "</p>\n\n"; ! ! } ! } ! } } ! } } // end step 2 --- 63,133 ---- $result = mysql_query($sql,$dbconn) or die (mysql_error() . ": $sql"); ! include ("./lib/inc/htmlparser.inc"); ! ! // require_once("offlconfig.php"); ! // require_once($DOC_ROOT . "/lib/header.php"); ! //this retrieves the game page ! $filename = "http://www.sportsline.com/nfl/schedules/regular"; ! $sched = file($filename); ! $schedstring = ""; ! //appends ! foreach ($sched as $schedline) { ! $schedstring .= $schedline . "\n\n"; ! } ! ! list($junk, $schedstring) = explode("<font class=\"lead\"><b>All times are US/Eastern</b></font><p>", $schedstring, 2); ! list($schedstring, $junk) = explode("<div class=\"spacer10\"> </div>", $schedstring, 2); ! //echo $schedstring; ! ! $parser = new HtmlParser ($schedstring); ! while ($parser->parse()) { ! //echo "iNodeName: " . $parser->iNodeName . ", iNodeValue: " . $parser->iNodeValue . ", iNodeType: " . $parser->iNodeType . "<br/>"; ! $attrValues = $parser->iNodeAttributes; ! if (strpos(trim($parser->iNodeValue), "WEEK") !== false) { ! list($junk, $gameweek) = explode("WEEK ", $parser->iNodeValue, 2); ! echo "Week Nbr: " . $gameweek . "<br/>"; ! } ! if (strpos(trim($parser->iNodeValue), "y,") !== false) { ! echo "<br/>--" . $parser->iNodeValue; ! } ! if (strpos(trim($parser->iNodeValue), " at ") !== false) { ! list($vteam, $hteam) = explode(" at ", $parser->iNodeValue, 2); ! echo "<br/>----" . $parser->iNodeValue; ! $x = new OFFL_NFLTeam(); ! $vabbv = $x->getNFLTeamBySchedName($vteam); ! $habbv = $x->getNFLTeamBySchedName($hteam); ! } ! ! if (strpos(trim($parser->iNodeValue), "document.write(formatTime") !== false) { ! list($junk, $gametime) = explode("document.write(formatTime('%I:%M %p', ", $parser->iNodeValue, 2); ! list($gametime, $junk) = explode("))", $gametime, 2); ! echo " -- " . date("g:i A, D M j, Y", $gametime); ! ! $gamedate = date('Ymd', $gametime); ! //http://www.sportsline.com/nfl/gamecenter/live//NFL_20070817_MIN@NYJ ! echo " -- " . "http://www.sportsline.com/nfl/gamecenter/live/NFL_" . $gamedate . "_" . $vabbv->getNFLTeamAbbv() . "@" . $habbv->getNFLTeamAbbv(); ! ! $thisGame = new OFFL_NFLGame(); ! $thisGame->setYear($_GET["year"]); ! $thisGame->setWeek($gameweek); ! $thisGame->setGametime($gametime); ! $thisGame->setHNFLTeamID($habbv->getNFLTeamID()); ! $thisGame->setVNFLTeamID($vabbv->getNFLTeamID()); ! //echo "Save game: " . $thisGame->getYear() . ", " . $thisGame->getWeek() . ", " . $thisGame->getGametime() . ", " . $thisGame->getHNFLTeamID() . ", " . $thisGame->getVNFLTeamID() . "<br/>"; ! $thisGame->save(); } ! } } // end step 2 |