get_row( $wpdb->prepare(“select LL.title as ‘divisionName’, LT.title as ‘teamName’ from 4Ao_leaguemanager_teams LT join 4Ao_leaguemanager_leagues LL on LT.league_id = LL.id where LT.id = %d”, $_GET[teamID]), ARRAY_A, 0 );

$divisionName = $singlerow[divisionName];
$teamName = $singlerow[teamName];

}

if(isset($_GET[email]) && isset($_GET[activate]))
{
$qry = $wpdb->prepare(“Update wp_mysl_alertEmails set active = 1, dateLastActivated = %s where emailAddress = %s and activityHash = %s”,
date(‘Y-m-d H:i:s’),
$_GET[email],
$_GET[activate]);

if($wpdb->query($qry))
{
echo(“

Subscription successfully activated.

“);
}
}
else if( isset($_GET[teamID]) && $_POST[email])
{
$emailIN = str_replace(‘,’,’;’,$_POST[email]);

$emailStrings = explode(“;”,$emailIN);

foreach($emailStrings as $email)
{
$email = trim($email);

$hash = md5($email.date(‘Y-m-d H:i:s’));

$maeID = 0;
$maeID = $wpdb->get_var ( $wpdb->prepare(“select id from wp_mysl_alertEmails where emailAddress= %s and teamID = %d”,$email,$_GET[teamID]) );

if($maeID >= 1)
{
//update the existing record
$success = $wpdb->query($wpdb->prepare(“update wp_mysl_alertEmails set activityHash = %s, dateLastActivationRequest = %s where id = %d”,$hash,date(‘Y-m-d H:i:s’),$maeID));
}
else
{
//insert a new record
$success = $wpdb->query($wpdb->prepare(“insert into wp_mysl_alertEmails (emailAddress,teamID,active,dateLastActivationRequest,activityHash) values (%s,%d,%d,%s,%s)”,
$email,
$_GET[teamID],
0,
date(‘Y-m-d H:i:s’),
$hash));
}

if($success)
{

$emailBody = ‘A request has been made to activate the following MYSL alert subscriptions for email address: ‘.$email.’

‘.$divisionName.’ -> ‘.$teamName.’

To finalize this activation, please CLICK HERE.’;

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

if(mail($email,’MYSL Email Subscription Activation’,$emailBody,$headers))
{
echo(“

An email has been sent to: “.$email.” requesting activation confirmation. Please click the link provided in the email to activate this email alert subscription.

“);
}
}
}
}
else if (isset($_GET[teamID]))
{
?>

Please enter the email address(es) which you’d like to subscribe to alerts for: ‘.$teamName); ?> (separate multiple addresses with a comma or semicolon).