<?php
/**
* Miscellaneous Functions
*
* @author Stephen Rochelle <hide@address.com>
* @version OFFL v0.2
* @copyright Copyright (c) 2004 Stephen Rochelle. Some rights reserved.
* @package offl
*/
require_once($DOC_ROOT . "/lib/classes/offl_control.php");
function GMTOffsetTime($timestamp)
/*
Takes a Unix timestamp, returns the stamp plus offset from $_SESSION["offset"]
such that gmdate("", return) gives data in client's timezone.
*/
{
if (!isset($_SESSION["offset"]))
{
return $timestamp;
}
else
{
return $timestamp - $_SESSION["offset"];
}
}
function getThisYear()
{
$today = getdate();
$year = $today["year"];
if ( ($today["month"] == "January") || ($today["month"] == "February") )
$year--;
return $year;
}
/**
* Returns the current week of the FFL season based on league-invariant control value "MISC_SEASON_START_YYYY"
*
* Formerly associated with Game class, but doesn't really need to be there. Maybe relocate to {@link functions.php}.
* @return integer Current week of the FFL season
*/
function getCurrentWeek($year)
{
global $localtest;
$ctrl = new OFFL_Control();
$season_start = $ctrl->getValue("MISC_SEASON_START_" . $year);
@list($date, $time) = explode(" ", $season_start);
@list($Y, $M, $D) = explode("-", $date);
@list($h, $i, $s) = explode(":", $time);
$time = gmmktime($h, $i, $s, $M, $D, $Y);
$curr_time = time() - $time - (3600*24*7);
$week = 1;
while ($curr_time > 0)
{
$curr_time -= 3600 * 24 * 7; // one week in seconds
$week++;
}
return $week;
}
function debugPrint($string)
{
global $localtest;
if (!$localtest)
return;
if (is_array($string))
{
foreach($string as $i=>$stringline)
{
if (!is_object($stringline))
{
$string[$i] = str_replace("<", "<", $string[$i]);
$string[$i] = str_replace(">", ">", $string[$i]);
}
}
echo "\n\n<pre>";
var_dump($string);
echo "</pre>\n\n";
return;
}
$string = str_replace("<", "<", $string);
$string = str_replace(">", ">", $string);
echo "\n\n<pre>$string</pre>\n\n";
}
?>