Skip to content
Permalink
Browse files

Fixed reported timezone issues.

  • Loading branch information...
Kevin Roth
Kevin Roth committed Jul 12, 2016
1 parent 7df765e commit 584288349122e7ac654ea67c5c857ec07098c057
Showing with 140 additions and 122 deletions.
  1. +5 −0 CHANGELOG.md
  2. +98 −98 includes/column_right.php
  3. +36 −23 includes/config.php
  4. +1 −1 install/install.sql
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## 2.2.2 - 7/12/2016
### Changed/Fixed
- Time zone offset is now set automatically, based on new SERVER_TIMEZONE constant. This should fix [issue #2](https://github.com/rothkj1022/phppickem/issues/2) and [issue #16](https://github.com/rothkj1022/phppickem/issues/16)
- Fixed [issue #17](https://github.com/rothkj1022/phppickem/issues/17)

## 2.2.1 - 7/7/2016
### Changed
- Fixed for LA Rams
@@ -1,98 +1,98 @@
<p class="skip2content"><a href="<?php echo $_SERVER['REQUEST_URI']; ?>#content">Skip to content &raquo;</a></p>

<div class="bg-primary">
<b>Current Time (Eastern):</b><br />
<span id="jclock1"></span>
<script type="text/javascript">
$(function($) {
var optionsEST = {
timeNotation: '12h',
am_pm: true,
utc: true,
utc_offset: -<?php echo 4 + SERVER_TIMEZONE_OFFSET; ?>
}
$('#jclock1').jclock(optionsEST);
});
</script>
</div>

<!-- start countdown code - http://keith-wood.name/countdown.html -->
<?php
if ($firstGameTime !== $cutoffDateTime && !$firstGameExpired) {
?>
<div id="firstGame" class="countdown bg-success"></div>
<script type="text/javascript">
//set up countdown for first game
var firstGameTime = new Date("<?php echo date('F j, Y H:i:00', strtotime($firstGameTime)); ?>");
firstGameTime.setHours(firstGameTime.getHours() -1);
$('#firstGame').countdown({until: firstGameTime, description: 'until first game is locked'});
</script>
<?php
}
if (!$weekExpired) {
?>
<div id="picksLocked" class="countdown bg-danger"></div>
<script type="text/javascript">
//set up countdown for picks lock time
var picksLockedTime = new Date("<?php echo date('F j, Y H:i:00', strtotime($cutoffDateTime)); ?>");
picksLockedTime.setHours(picksLockedTime.getHours() -1);
$('#picksLocked').countdown({until: picksLockedTime, description: 'until week <?php echo $currentWeek; ?> is locked'});
</script>
<?php
} else {
//current week is expired
}
?>
<!-- end countdown code -->

<?php
$weekStats = array();
$playerTotals = array();
$possibleScoreTotal = 0;
calculateStats();
$tmpWins = 0;
$i = 1;
if (is_array($playerTotals) && sizeof($playerTotals) > 0) {
//show top 3 winners
echo ' <div class="bg-success">' . "\n";
echo ' <b>Current Leaders (# wins):</b><br />' . "\n";
arsort($playerTotals);
foreach($playerTotals as $playerID => $stats) {
if ($tmpWins < $stats[wins]) $tmpWins = $stats[wins]; //set initial number of wins
//if next lowest # of wins is reached, increase counter
if ($stats[wins] < $tmpWins ) $i++;
//if wins is zero or counter is 3 or higher, break
if ($stats[wins] == 0 || $i > 3) break;
echo ' ' . $i . '. ' . $stats[name] . ' - ' . $stats[wins] . (($stats[wins] > 1) ? ' wins' : ' win') . '<br />';
$tmpWins = $stats[wins]; //set last # wins
}
echo ' </div>' . "\n";
}
$tmpScore = 0;
$i = 1;
if (is_array($playerTotals) && sizeof($playerTotals) > 0) {
//show top 3 pick ratios
echo ' <div class="bg-success">' . "\n";
echo ' <b>Current Leaders (pick %):</b><br />' . "\n";
$playerTotals = sort2d($playerTotals, 'score', 'desc');
foreach($playerTotals as $playerID => $stats) {
if ($tmpScore < $stats[score]) $tmpScore = $stats[score]; //set initial top score
//if next lowest score is reached, increase counter
if ($stats[score] < $tmpScore ) $i++;
//if score is zero or counter is 3 or higher, break
if ($stats[score] == 0 || $i > 3) break;
$pickRatio = $stats[score] . '/' . $possibleScoreTotal;
$pickPercentage = number_format((($stats[score] / $possibleScoreTotal) * 100), 2) . '%';
echo ' ' . $i . '. ' . $stats[name] . ' - ' . $pickRatio . ' (' . $pickPercentage . ')<br />';
$tmpScore = $stats[score]; //set last # wins
}
echo ' </div>' . "\n";
}
if (COMMENTS_SYSTEM !== 'disabled') {
echo ' <p class="bg-info"><b>Taunt your friends!</b><br /><a href="'.$_SERVER['REQUEST_URI'].'#comments">Post a comment</a> now!</p>'."\n";
}
//include('includes/comments.php');
<p class="skip2content"><a href="<?php echo $_SERVER['REQUEST_URI']; ?>#content">Skip to content &raquo;</a></p>

<div class="bg-primary">
<b>Current Time (Eastern):</b><br />
<span id="jclock1"></span>
<script type="text/javascript">
$(function($) {
var optionsEST = {
timeNotation: '12h',
am_pm: true,
utc: true,
utc_offset: <?php echo -1 * (4 + SERVER_TIMEZONE_OFFSET); ?>
}
$('#jclock1').jclock(optionsEST);
});
</script>
</div>

<!-- start countdown code - http://keith-wood.name/countdown.html -->
<?php
if ($firstGameTime !== $cutoffDateTime && !$firstGameExpired) {
?>
<div id="firstGame" class="countdown bg-success"></div>
<script type="text/javascript">
//set up countdown for first game
var firstGameTime = new Date("<?php echo date('F j, Y H:i:00', strtotime($firstGameTime)); ?>");
firstGameTime.setHours(firstGameTime.getHours() -1);
$('#firstGame').countdown({until: firstGameTime, description: 'until first game is locked'});
</script>
<?php
}
if (!$weekExpired) {
?>
<div id="picksLocked" class="countdown bg-danger"></div>
<script type="text/javascript">
//set up countdown for picks lock time
var picksLockedTime = new Date("<?php echo date('F j, Y H:i:00', strtotime($cutoffDateTime)); ?>");
picksLockedTime.setHours(picksLockedTime.getHours() -1);
$('#picksLocked').countdown({until: picksLockedTime, description: 'until week <?php echo $currentWeek; ?> is locked'});
</script>
<?php
} else {
//current week is expired
}
?>
<!-- end countdown code -->

<?php
$weekStats = array();
$playerTotals = array();
$possibleScoreTotal = 0;
calculateStats();
$tmpWins = 0;
$i = 1;
if (is_array($playerTotals) && sizeof($playerTotals) > 0) {
//show top 3 winners
echo ' <div class="bg-success">' . "\n";
echo ' <b>Current Leaders (# wins):</b><br />' . "\n";
arsort($playerTotals);
foreach($playerTotals as $playerID => $stats) {
if ($tmpWins < $stats[wins]) $tmpWins = $stats[wins]; //set initial number of wins
//if next lowest # of wins is reached, increase counter
if ($stats[wins] < $tmpWins ) $i++;
//if wins is zero or counter is 3 or higher, break
if ($stats[wins] == 0 || $i > 3) break;
echo ' ' . $i . '. ' . $stats[name] . ' - ' . $stats[wins] . (($stats[wins] > 1) ? ' wins' : ' win') . '<br />';
$tmpWins = $stats[wins]; //set last # wins
}
echo ' </div>' . "\n";
}
$tmpScore = 0;
$i = 1;
if (is_array($playerTotals) && sizeof($playerTotals) > 0) {
//show top 3 pick ratios
echo ' <div class="bg-success">' . "\n";
echo ' <b>Current Leaders (pick %):</b><br />' . "\n";
$playerTotals = sort2d($playerTotals, 'score', 'desc');
foreach($playerTotals as $playerID => $stats) {
if ($tmpScore < $stats[score]) $tmpScore = $stats[score]; //set initial top score
//if next lowest score is reached, increase counter
if ($stats[score] < $tmpScore ) $i++;
//if score is zero or counter is 3 or higher, break
if ($stats[score] == 0 || $i > 3) break;
$pickRatio = $stats[score] . '/' . $possibleScoreTotal;
$pickPercentage = number_format((($stats[score] / $possibleScoreTotal) * 100), 2) . '%';
echo ' ' . $i . '. ' . $stats[name] . ' - ' . $pickRatio . ' (' . $pickPercentage . ')<br />';
$tmpScore = $stats[score]; //set last # wins
}
echo ' </div>' . "\n";
}
if (COMMENTS_SYSTEM !== 'disabled') {
echo ' <p class="bg-info"><b>Taunt your friends!</b><br /><a href="'.$_SERVER['REQUEST_URI'].'#comments">Post a comment</a> now!</p>'."\n";
}
//include('includes/comments.php');
@@ -1,23 +1,36 @@
<?php
//modify vars below
// Database
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'dbuser');
define('DB_PASSWORD', 'dbpass');
define('DB_DATABASE', 'nflpickem');
define('DB_PREFIX', 'nflp_');
define('SITE_URL', 'http://localhost/personal/applications/phppickem/');
define('ALLOW_SIGNUP', true);
define('SHOW_SIGNUP_LINK', true);
define('USER_NAMES_DISPLAY', 3); // 1 = real names, 2 = usernames, 3 = usernames w/ real names on hover
define('COMMENTS_SYSTEM', 'basic'); // basic, disqus, or disabled
define('DISQUS_SHORTNAME', ''); // only needed if using Disqus for comments
define('SEASON_YEAR', '2015');
//set timezone offset, hours difference between your server's timezone and eastern
define('SERVER_TIMEZONE_OFFSET', 0);
// ***DO NOT EDIT ANYTHING BELOW THIS LINE***
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
<?php
//modify vars below
// Database
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'dbuser');
define('DB_PASSWORD', 'dbpass');
define('DB_DATABASE', 'nflpickem');
define('DB_PREFIX', 'nflp_');
define('SITE_URL', 'http://localhost/personal/applications/phppickem/');
define('ALLOW_SIGNUP', true);
define('SHOW_SIGNUP_LINK', true);
define('USER_NAMES_DISPLAY', 3); // 1 = real names, 2 = usernames, 3 = usernames w/ real names on hover
define('COMMENTS_SYSTEM', 'basic'); // basic, disqus, or disabled
define('DISQUS_SHORTNAME', ''); // only needed if using Disqus for comments
define('SEASON_YEAR', '2016');
define('SERVER_TIMEZONE', 'America/Chicago'); // Your SERVER's timezone. NOTE: Game times will always be displayed in Eastern time, as they are on NFL.com. This setting makes sure cutoff times work properly.
// ***DO NOT EDIT ANYTHING BELOW THIS LINE***
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
//automatically set timezone offset (hours difference between your server's timezone and eastern time)
date_default_timezone_set(SERVER_TIMEZONE);
/*$timeZoneCurrent = @date_default_timezone_get();
if (ini_get('date.timezone')) {
$timeZoneCurrent = ini_get('date.timezone');
}*/
$dateTimeZoneCurrent = new DateTimeZone(SERVER_TIMEZONE);
$dateTimeZoneEastern = new DateTimeZone("America/New_York");
$dateTimeCurrent = new DateTime("now", $dateTimeZoneCurrent);
$dateTimeEastern = new DateTime("now", $dateTimeZoneEastern);
$offsetCurrent = $dateTimeCurrent->getOffset();
$offsetEastern = $dateTimeEastern->getOffset();
$offsetHours = ($offsetEastern - $offsetCurrent) / 3600;
define('SERVER_TIMEZONE_OFFSET', $offsetHours);
@@ -88,7 +88,7 @@ DROP TABLE IF EXISTS `nflp_picksummary`;
CREATE TABLE `nflp_picksummary` (
`weekNum` int(11) NOT NULL DEFAULT '0',
`userID` int(11) NOT NULL DEFAULT '0',
`tieBreakerPoints` int(11) NOT NULL,
`tieBreakerPoints` int(11) NOT NULL DEFAULT '0',
`showPicks` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`weekNum`,`userID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;

0 comments on commit 5842883

Please sign in to comment.
You can’t perform that action at this time.