require_once "fch-lib.js"; $userID = getUserID(); $leagueID = leagueHandler($_POST, $userID); debug("League is {$leagueID}"); $season = getSeason(); ?> To join a league, choose the league you're looking to join, the password provided by its administrator, and the name of your team. You can only join a league once. If a league's registration deadline has passed, it does not appear on the list.<p/> <?php debug($_POST["action"]); if ($_POST["action"] == "leagueEnroll") { $pass = getSingleton("fch_leagues", "pw", " where id = " . $_POST['leagueID'] . " and season = \"" . getSeason() . "\""); debug("Criteria -- displName=" . $_POST["teamDisplayName"] . " pw=" . $_POST['password'] . " pass="******"teamDisplayName"]) > 0) { echo displayResults(addGMToLeague($_POST["leagueID"], $userID, $_POST["teamDisplayName"])); } else { echo displayResults(getReturnCode(0, "Sorry, your password was incorrect or you didn't enter a team name.")); } } ?> <div class="contact-form"> <form name="leagueEnroll" method="post" class="form-validate form-horizontal" > <input name = "action" value = "leagueEnroll" type = "hidden"> <fieldset> <legend>What League Would You Like to Join?</legend> <div class="control-group"> <div class="control-label"> <label id="jform_contact_name-lbl" for="jform_contact_name" class="hasTooltip required" title="<strong>Name</strong><br />Your name.">
function createLeague($leagueName, $pw, $displayName, $limit_f_a, $limit_f_b, $limit_d_a, $limit_d_b, $limit_g_a, $limit_g_b, $registrationDeadline, $draftTime, $invites) { $season = getSeason(); //echo "creating league $leagueName, $pw, $displayName, $registrationDeadline, $draftTime , $limit_f_a, $limit_f_b, $limit_d_a, $limit_d_b, $limit_g_a, $limit_g_b"; $r = getReturnCode(1, ""); if (selectCount("fch_leagues", " WHERE display_name = \"{$leagueName}\" and season = \"{$season}\"") > 0) { return getReturnCode(0, "Sorry, that league name is already taken."); } $user = getUserID(); if ($user === -1) { return getReturnCode(0, "Sorry, could not ascertain your user ID."); } if (intval($limit_f_a) > 12) { $r["status"] = 0; $r["msg"] .= " You have too many active roster forwards. "; } if (intval($limit_f_a) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few active roster forwards. "; } if (intval($limit_f_b) > 12) { $r["status"] = 0; $r["msg"] .= " You have too many reserve forwards. "; } if (intval($limit_f_b) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few reserve forwards. "; } if (intval($limit_d_a) > 8) { $r["status"] = 0; $r["msg"] .= " You have too many active roster defensemen. "; } if (intval($limit_d_a) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few active roster defensemen. "; } if (intval($limit_d_b) > 8) { $r["status"] = 0; $r["msg"] .= " You have too many reserve defensemen. "; } if (intval($limit_d_b) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few reserve defensemen. "; } if (intval($limit_g_a) > 4) { $r["status"] = 0; $r["msg"] .= " You have too many active roster goalies. "; } if (intval($limit_g_a) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few active roster goalies. "; } if (intval($limit_g_b) > 4) { $r["status"] = 0; $r["msg"] .= " You have too many reserve goalies. "; } if (intval($limit_g_b) < 1) { $r["status"] = 0; $r["msg"] .= " You have too few reserve goalies. "; } if (($regTimeStamp = strtotime($registrationDeadline)) === false) { $r["status"] = 0; $r["msg"] .= " There was an error reading the registration deadline. "; } if (($draftTimeStamp = strtotime($draftTime)) === false) { $r["status"] = 0; $r["msg"] .= " There was an error reading the draft time. "; } if ($r["status"] === 0) { return $r; } //YYYY-MM-DD HH:MM:SS $draftTimeSqlFormat = date("Y-m-d G:i:00", $draftTimeStamp); $regTimeSqlFormat = date("Y-m-d G:i:00", $regTimeStamp); $interval = $draftTimeStamp - $regTimeStamp; debug("Interval {$interval}"); if (intval($interval) < 86400) { $r["status"] = 0; $r["msg"] .= " Draft must be 24 hours after registration deadline. "; } $season = getSeason(); $sql = <<<SQL \tINSERT INTO fanta66_joomla.fch_leagues ( \t\tid , \t\tdisplay_name , \t\tseason , \t\tadmin_user, \t\tpw, \t\tlimit_f_a, \t\tlimit_f_b, \t\tlimit_d_a, \t\tlimit_d_b, \t\tlimit_g_a, \t\tlimit_g_b, \t\tregistrationDeadline, \t\tdraftTime, \t\tdraftStatus \t\t) \t\tVALUES ( \t\t\tNULL , "{$leagueName}", "{$season}", {$user}, "{$pw}", {$limit_f_a}, {$limit_f_b}, {$limit_d_a}, {$limit_d_b}, {$limit_g_a},{$limit_g_b}, DATE_ADD("{$draftTimeSqlFormat}", INTERVAL -1 HOUR), "{$draftTimeSqlFormat}", "0" \t\t); \t\t SQL; debug($sql); $leagueID = executeGenericInsertSQL($sql); //echo "Created league id = ". $leagueID; $r1 = addGMToLeague($leagueID, $user, $displayName); $body = "You have been invited to join a Fantasy College Hockey league!"; $body .= $leagueName . ' has just been created. To join, visit http://www.fantasycollegehockey.com, sign up or login, and click Join League in the menu.' . "\n\n"; if (strlen($pw) > 0) { $body .= "The password to join the league is {$pw}.\n\n"; } else { $body .= "There is no password to join the league. When prompted, leave the field blank.\n\n"; } $body .= "The registration deadline is {$regTimeSqlFormat} and the draft is at {$draftTimeSqlFormat}, Eastern time."; $inviteEmails = explode(",", $invites); debug("Invites {$invites}"); foreach ($inviteEmails as $email) { debug("Emailing " . $email); sendEmail($email, "You have been invited to join a Fantasy College Hockey league", $body); } sendEmail("*****@*****.**", "New League Created", "New League: {$leagueName}, {$leagueID}. Invites: {$invites}"); if ($r1["status"] === 1) { return getReturnCode(1, "Your league has been created and you are its manager. Please see the league control panel for more information."); } }