Location: PHPKode > projects > Online Fantasy Football League > offl-0.2.6/www/maintenance/processweeklywaivers.php
<?php
/**
 * Weekly waiver setting
 *
 * This file is intended to reset all players to waivers during games each week.  I lock out all players until Tuesday
 * (resulting in first processing on Wednesday) to give everybody a fair stab at the newest phenom.
 * *** NOTE ***
 * If you don't want this feature, don't enable this file in your crontab.  In that case, players will go on waivers
 * only when dropped.  I'm working on the code necessary to have inline configuration for different leagues.
 * 
 * This file should be run via cron.  I recommend once weekly on Sun at 12 noon, but you can pick.
 * 
 * that line would look like:
 * 
 * 0 12 * * 6 /path/to/php /path/to/processweeklywaivers.php
 * 
 * alternately, win32 servers can use pycron (http://www.kalab.com/freeware/pycron/pycron.htm)
 * and have a line like
 * 
 * 0 12 * * 6 "c:\path\to\php" "c:\path\to\processweeklywaivers.php"
 * 
 * Since you're not accessing this via the web, you should place it outside of your document root.
 * There are no permission checks; therefore, anyone could prematurely execute a waiver claim if the
 * file is public.  Security through obscurity is a poor substitute.
 * 
 * @author Stephen Rochelle <hide@address.com>
 * @version OFFL v0.2
 * @copyright Copyright (c) 2004 Stephen Rochelle.  Some rights reserved.
 * @package offl-maint
 */

$pageTitle = "Reset Waivers for Game Time";
$public = TRUE;
$maintenance = TRUE;
require_once("offlconfig.php");
require_once($DOC_ROOT . "/lib/header.php");

$x = new OFFL_League();
$leagues = $x->getAllLeagues();
$wp_lookup = new OFFL_WaiverPlayer();
foreach ($leagues as $league)
{
	// delete existing waivers first?
	$waiverplayers = $wp_lookup->getAllWaiverPlayers($league->getLeagueID());
	foreach ($waiverplayers as $wp)
	{	$wp->deleteWaiverPlayer();	}

	$players = $league->getPlayers(2); // all players not currently on rosters
	foreach ($players as $player)
	{
		$wp = new OFFL_WaiverPlayer();
		$wp->setLeagueID($league->getLeagueID());
		$wp->setPlayerID($player->getPlayerID());
		$wp->setWaiverDeadline(time());
		$wp->save();
	}
}

require($DOC_ROOT . "/lib/footer.php"); ?>
Return current item: Online Fantasy Football League