get_row( $wpdb->prepare(“select LM.home_team, LM.away_team, LM.league_id,,Home.title as ‘homeTitle’,Away.title as ‘awayTitle’,LL.title as ‘divisionTitle’ from 4Ao_leaguemanager_matches LM join 4Ao_leaguemanager_teams Home on LM.home_team = join 4Ao_leaguemanager_teams Away on LM.away_team = join 4Ao_leaguemanager_leagues LL on = LM.league_id where”,$gameID), ARRAY_A, 0 );

$homeID = $singlerow[home_team];
$awayID = $singlerow[away_team];
$leagueID = $singlerow[league_id];
$gameDate = $singlerow[date];

$homeTitle = $singlerow[homeTitle];
$awayTitle = $singlerow[awayTitle];
$divisionTitle = $singlerow[divisionTitle];


//$qry = $wpdb->prepare( “select hash from wp_mysl_teamRegCodes where (teamID = %d or teamID = %d) and regCode = %d LIMIT 1”,$homeID,$awayID, $_POST[‘teamPIN’] );
$qry = $wpdb->prepare( “select hash from wp_mysl_teams where (id = %d or id = %d) and teamPIN = %d LIMIT 1”,$homeID,$awayID, $_POST[‘teamPIN’] );

$validated = $wpdb->get_var( $qry );

echo(“I’m sorry, that number does check out. If you are repeatedly unable to validate, please contact MYSL here“);

if ($_POST[‘validated’] || $validated) :

if($_POST[‘submit’] && isset( $_POST[contactName] ) && ( isset( $_POST[contactEmail] ) || isset( $_POST[contactPhone] ) ) )
$exists = 0;
$exists = $wpdb->get_var($wpdb->prepare(“select gameID from wp_mysl_gameCancelations where gameID = %d and DATEDIFF(NOW(),dateSubmitted) = 0”,$gameID));

$qry = $wpdb->prepare(“insert into wp_mysl_gameCancelations (gameID, cancelationReason, cancelationDetails, contactName, contactEmail, contactPhone, dateSubmitted, scheduleDate)
values (%d, %s, %s, %s, %s, %s, %s,%s)”,
date(‘Y-m-d H:i:s’),

if ($wpdb->query($qry) && !$exists) //only send emails & post to twitter if the cancelation did not previously exist.

// Twitter Class

// Twitter Connection Info
$twitter_access_token = ‘800535360-Zl6zrx8C9aPaouObV7BUe7LfvHmslalQDdnXZX7l’;
$twitter_access_token_secret = ‘EB2PHjZCxpF7idW8qqTkLNEAbPd93nCQnazxBuNLo’;
$twitter_consumer_key = ‘ZYnhqK6QOnY8A1jPl7Jlw’;
$twitter_consumer_secret = ‘nNU7WVjpqp4SoKz61VKWfiJZZMO9nn31oBeUD5fzCxE’;

// Connect to Twitter
$connection = new TwitterOAuth($twitter_consumer_key, $twitter_consumer_secret, $twitter_access_token, $twitter_access_token_secret);

$thisTweet = ‘Cancelation: ‘.date(‘M j’,strtotime($gameDate)).’ ‘.$divisionTitle.’ -> ‘.$awayTitle.’ at ‘.$homeTitle.’′;

// Post Update
$content = $connection->post(‘statuses/update’, array(‘status’ => $thisTweet));

//Send emails to people
$emailAddresses = $wpdb->get_results($wpdb->prepare(“select distinct emailAddress from
4Ao_leaguemanager_matches LM
join wp_mysl_alertEmails MAE on ( MAE.teamID = LM.home_team or MAE.teamID = LM.away_team)
where = %d
and = 1”,

$headers = ‘From:’ . “rn” .
‘Reply-To:’ . “rn” .
‘MIME-Version: 1.0’ . “rn” .
‘Content-Type: text/html; charset=ISO-8859-1’ . “rn”;

foreach($emailAddresses as $email)

$body = ‘The following game has had a cancelation notice submitted to MYSL:

Division: ‘.$divisionTitle.’

Game Number: ‘.$gameID.’

Game Date: ‘.date(‘M j g:i a’,strtotime($gameDate)).’

Home Team: ‘.$homeTitle.’

Away Team: ‘.$awayTitle.’

Contact Name: ‘.$_POST[contactName].’

Contact Email: ‘.$_POST[contactEmail].’

Contact Phone: ‘.$_POST[contactPhone].’

Cancelation Reason: ‘.$_POST[cancelReason].’

Further Canceltation Details: ‘.$_POST[cancelationDetails].’

We recommend contacting your team representatives and/or the contact person listed in this email to confirm the cancelation.

Thank you,


Sent via MYSL automated notifications. To manage your notification subscriptions, please click “>
Contact Name*: Contact Email*: Contact Phone*: Cancelation Reason: Further Cancelation Details (if any):

In order to proceed to the game cancelation notice form for game number , in the division, please enter either a valid reg code for either the home () or away () team.