here to sign up.
'; return 0; } if (strtotime($roster_lock) < strtotime('now')) { # $query = "SELECT * # FROM team_user_link tul INNER JOIN league # ON tul.I_LeagueID = league.I_LeagueID # WHERE I_UserID = $userid AND league.I_LeagueID = $leagueid AND # (E_Status = 'Active' OR D_Released > D_RosterLock)"; # $result = runQuery($query, 'functions.inc -- check roster lock signing'); # if (mysql_num_rows($result) > 0) { # $ineligible_reason = "You cannot accept an offer if you were on a squad at roster lock"; $ineligible_reason = "You cannot accept an offer after roster lock."; return 0; # } } if ($max_roster > 0) { # If non-zero check roster size against I_MaxRoster $query = "SELECT count(*) from team_user_link where I_TeamID = $teamid and E_Status='Active'"; $roster_result = runQuery($query, 'functions.php - max roster query'); list ($roster_size) = mysql_fetch_array($roster_result); if ($roster_size >= $max_roster) { $ineligible_reason = "The team already has the maximum number of pilots."; return 0; } } if ($cap == 0) { return 1; } if (($usalary == 0) && ($cap > 0)) { $ineligible_reason = "You cannot join a team in a salary-capped league until your salary has been established."; return 0; } $query = "SELECT I_Salary FROM team_user_link t INNER JOIN user_league_link u ON t.I_UserID = u.I_UserID AND t.I_LeagueID = u.I_LeagueID WHERE u.I_LeagueID = $leagueid AND I_TeamID = $teamid and E_Status='Active' ORDER BY I_Salary desc"; if ($num_pilots > 0) { $query .= " LIMIT 0,$num_pilots"; } $salary_result = runQuery($query, 'functions.php - salary query'); $total = 0; $minsal = 0; while (list($salary) = mysql_fetch_array($salary_result)) { $total += $salary; if ($minsal == 0 || $salary < $minsal) { $minsal = $salary; } } if ($usalary > $minsal) { $total -= $minsal; $total += $usalary; } if ($total > $cap) { $ineligible_reason = "The team salary, including yours, would be $total (with $num_pilots players). Salary cap is $cap. The team captain will have to make changes to the roster to make room for you under the cap."; return 0; } else { return 1; } } function closeOffer ($offerid, $message, $action) { ########################################################## # Get offer details ########################################################## $query = "SELECT user.I_UserID, C_PrimaryAlias, league.I_LeagueID, C_Team, I_CaptainID, team.I_TeamID FROM offer INNER JOIN user ON offer.I_UserID = user.I_UserID INNER JOIN team ON offer.I_TeamID = team.I_TeamID INNER JOIN team_league_link ON offer.I_TeamID = team_league_link.I_TeamID INNER JOIN league ON team_league_link.I_LeagueID = league.I_LeagueID WHERE I_OfferID = $offerid AND I_Active = 1"; $result = runQuery($query, 'functions.inc - offer info'); $offer = mysql_fetch_array($result) or die('Unable to fetch data'); ########################################################## # Close offer in DB ########################################################## $query = "UPDATE offer SET D_Response = NOW(), C_Response = '$message', E_Response = '$action' WHERE I_OfferID = $offerid"; runQuery($query, 'close offer'); ########################################################## # Send email notification to captain and user ########################################################## sendMail($offer['I_CaptainID'], 'Offer to ' . $offer['C_PrimaryAlias'] . " has been $action.",'','From: "Powerballzone" '); sendMail($offer['I_UserID'], 'Offer from ' . $offer['C_Team'] . " has been $action.",'','From: "Powerballzone" '); if ($action == 'accepted') { ########################################################## # Add to team if offer was accepted ########################################################## $query = 'INSERT INTO team_user_link(I_TeamID, I_UserID, I_LeagueID, I_OfferID, D_Signed, E_Status) VALUES (' . $offer['I_TeamID'] . ',' . $offer['I_UserID'] . ',' . $offer['I_LeagueID'] . ",$offerid, NOW(), 'Active')"; runQuery($query, 'functions.inc - add team link'); ########################################################## # Get other offer info in order to close ########################################################## $query = 'SELECT I_OfferID, I_CaptainID FROM offer INNER JOIN team ON offer.I_TeamID = team.I_TeamID INNER JOIN team_division_link ON offer.I_TeamID = team_division_link.I_TeamID INNER JOIN division ON team_division_link.I_DivisionID = division.I_DivisionID WHERE offer.I_UserID = ' . $offer['I_UserID'] . ' AND I_LeagueID = ' . $offer['I_LeagueID'] . ' AND D_Response IS NULL'; $result = runQuery($query, 'functions.inc - open offers'); while (list($tempofferid, $tempcaptainid) = mysql_fetch_array($result)) { # Close offer $query = "UPDATE offer SET D_Response = NOW(), C_Response = 'User accepted other offer', E_Response = 'Declined' WHERE I_OfferID = $tempofferid"; runQuery($query, 'functions.inc - close other offers'); # Send email notification to captain sendMail($tempcaptainid, $offer['C_PrimaryAlias'] . " has cancelled your offer", '', 'From: "Powerballzone" '); } } } function statDisplayLinks () { ############################################################################## # Takes no input, displays links for stat display (total, pergame, or pertime) # with the current display method solid (non-link) ############################################################################## global $PHP_SELF; global $statDisplayType; $STATS_URL = preg_replace('/statDisplayType=(total|pergame|pertime)/', 'statDisplayType=',$_SERVER['QUERY_STRING']); if ($STATS_URL == '') { # No vars passed, add statDisplayType= to end $STATS_URL = "$PHP_SELF?statDisplayType="; } else if (!isset($_REQUEST['statDisplayType'])) { # Vars passed, but not statDisplayType, add it to end $STATS_URL = "$PHP_SELF?$STATS_URL&statDisplayType="; } else { $STATS_URL = "$PHP_SELF?$STATS_URL"; } echo "
"; echo ($statDisplayType == 'total') ? "Total |" : "Total |", ($statDisplayType == 'pergame') ? " Per game average |" : " Per game average |", ($statDisplayType == 'pertime') ? " Per time average" : " Per time average"; echo "
"; } function columnSortLinks (&$COLUMNS) { ############################################################################## # $COLUMNS is an hash of columns, each has a hash of config values # $COLUMNS['goals']['label'] = 'Goals'; # 'label' is the text displayed for the link # This should NOT be the SQL Column name, but rather the SQL alias that you # use. SELECT SQLColumn as alias FROM .... # This lets you sort using GROUP BY functions SUM(), COUNT(), etc... # # $COLUMNS is passed as a reference, and 'url' is added as the column url. ############################################################################## global $PHP_SELF; global $sortColumn; global $sortDirection; # We need to make the query URL in canonical form so that we can do a # preg_replace to create each new URL. We do this by removing the variable # an just leaving the 'name=' string. If the variable wasn't passed we just # append 'varname=' to the end of the URL. if ($_SERVER['QUERY_STRING'] == '') { $COLUMN_URL = "$PHP_SELF?sortColumn=&sortDirection="; } else { $COLUMN_URL = "$PHP_SELF?" . $_SERVER['QUERY_STRING']; if (isset($_REQUEST['sortColumn'])) { $COLUMN_URL = preg_replace("/sortColumn=$sortColumn/", 'sortColumn=',$COLUMN_URL); } else { $COLUMN_URL .= '&sortColumn='; } if (isset($_REQUEST['sortDirection'])) { $COLUMN_URL = preg_replace("/sortDirection=($sortDirection)/", 'sortDirection=',$COLUMN_URL); } else { $COLUMN_URL .= '&sortDirection='; } } foreach ($COLUMNS as $columnName => $OPTIONS) { $TEMP_URL = "" . $OPTIONS['label'] . ''; if (isset($OPTIONS['orderby'])) { $orderColumn = $OPTIONS['orderby']; } else { $orderColumn = $columnName; } if ($orderColumn == $sortColumn) { # Change sort order for current column (asc to desc or vice versa) ($sortDirection == 'desc') ? $TEMP_URL = preg_replace('/sortDirection=/', 'sortDirection=asc', $TEMP_URL) : $TEMP_URL = preg_replace('/sortDirection=/', 'sortDirection=desc', $TEMP_URL); } else { $TEMP_URL = preg_replace('/sortDirection=/', 'sortDirection=desc', $TEMP_URL); } # Change sort column to show current column $TEMP_URL = preg_replace('/sortColumn=/', "sortColumn=$orderColumn", $TEMP_URL); $COLUMNS[$columnName]['url'] = $TEMP_URL; } } function showTableLines (&$result, $COLUMNS, $COLORS) { ############################################################################## # $result (taken by reference so we don't waste memory) # $COLUMNS is hash of columns queried, each has a hash of config values. # $COLUMNS['columnname']['align'] (HTML align -- default right) # $COLUMNS['columnname']['style'] (HTML style -- default none) # $COLUMNS['columnname']['display'] (0/1 boolean -- default 1) # $COLORS is an array of the TR bgcolors to iterate through # # Outputs a table row for each row in the query result. Output starts with # table needs to be started (possibly using columnSortLinks above) ############################################################################## global $sortColumn; $bgcount = count($COLORS); $bgindex = 0; while ($row = mysql_fetch_assoc($result)) { echo ''; foreach ($row as $column => $value) { $OPTIONS = $COLUMNS[$column]; if ((!isset($OPTIONS['display'])) || $OPTIONS['display'] == 1) { if (isset($OPTIONS['align'])) { $align = $OPTIONS['align']; } else { $align = 'right'; } #echo "

$column -- $sortColumn

"; if (isset($OPTIONS['style'])) { $style = "text-align: $align; " . $OPTIONS['style']; } else { $style = "text-align: $align"; } if ($column == $sortColumn) { $style .= "; font-weight: bold"; } echo "$value"; } } echo ''; $bgindex = ($bgindex + 1) % $bgcount; } } function sendMail ($userid, $subject, $message, $headers) { ########################################################## # Get email data ########################################################## $query = "SELECT C_Email FROM user WHERE I_UserID = $userid"; $result = runQuery($query, 'functions.inc - send query'); list ($email) = mysql_fetch_array($result); return mail($email, $subject, $message, $headers); } function GetXY_JPG($contents) { return array(0,0); } function GetXY_GIF($contents) { return array(0,0); } function GetXY_PNG($contents) { return array(0,0); } ?>