include('connect.php');
$webroot = "http://www.livebycampus.com/"; //change this for production
function sendWelcomeEmail($userid){
}
function sendManagerContactEmail($emailaddress, $message, $fromemail, $fromname, $fromphone){
$emailheaders = "From: LiveByCampus \n";
$emailheaders .= "Reply-To: LiveByCampus Support \n";
$emailheaders .= "MIME-Version: 1.0\n";
$emailheaders .= "Content-Type: text/html; charset=UTF-8\n";
$emailsubject = "LiveByCampus Contact Form Results";
$emailbody = "A LiveByCampus has sent you a message using our contact form: ";
$emailbody.= "Name: " . $fromname . " ";
$emailbody.= "Email: " . $fromemail . " ";
$emailbody.= "Phone #: " . $fromphone . " ";
$emailbody.= "Message: " . $message;
mail($emailaddress, $emailsubject, $emailbody, $emailheaders) or die("couldn't send email");
}
function sendNewsletter($userid){
//get the user's email address
$results = mysql_query("select * from users where userid='$userid'") or die(mysql_error());
$row = mysql_fetch_array($results, MYSQL_ASSOC);
$emailaddress = $row['email'];
$emailname = $row['firstname'] . " " . $row['lastname'];
$newsletternumber = $row['newsletter'];
//get the newsletter info
$results = mysql_query("select * from newsletters where week ='$newsletternumber'") or die(mysql_error());
if(mysql_num_rows($results) < 1){
//no more newsletters, or newsletter not found, set user to unsubscribed
mysql_query("update users set newsletter = '-2' where userid = '$userid'");
return;
} else{
$row = mysql_fetch_array($results, MYSQL_ASSOC);
//setup newsletter
$emailbody = $row['body'];
//insert variables into the body of the email, only name for now
$emailbody = str_replace("#name", $emailname, $emailbody);
$emailsubject = $row['subject'];
$emailheaders = 'From: ' . $row['fromemail'];
mail($emailaddress, $emailsubject, $emailbody, $emailheaders) or die("couldn't send email");
//update user's newsletter column in db
mysql_query("update users set newsletter = '".($newsletternumber+1)."' where userid = '$userid'");
}
}
function sendNewPropertyEmail($propertyid){
$webroot = "http://www.livebycampus.com/";
$emailheaders = "From: LiveByCampus Support \n";
$emailheaders .= "Reply-To: LiveByCampus Support \n"; $emailheaders .= "MIME-Version: 1.0\n";
$emailheaders .= "Content-Type: text/html; charset=UTF-8\n";
//get property and admin info
$results = mysql_query("select p.name, c.shortname, c.adminemail from propertyinfo p, campus c, property_campuses pc where p.propertyid = pc.propertyid and p.propertyid = '$propertyid' and pc.campusid = c.campusid") or die(mysql_error());
while($row = mysql_fetch_array($results, MYSQL_ASSOC)){
$propertyname = $row['name'];
//$emailaddress =support@livebycampus.com $row['adminemail'];
$emailaddress = '';
$emailsubject = "New LiveByCampus Property Pending Approval";
$emailbody = "Dear LiveByCampus Administrator, ";
$emailbody.= "A new property has been created and is pending approval. ";
$emailbody.= "Please review the following property: ";
$emailbody.= '';
$emailbody.= $propertyname . ' ';
$emailbody.= '. You can appprove or delete the property at the ';
$emailbody.= 'admin section . ';
$emailbody.= "Sincerely, The LiveByCampus Automated Property Robot";
mail($emailaddress, $emailsubject, $emailbody, $emailheaders) or die("couldn't send email");
}
}
function sendRewardClaimEmail($_POST){
//if the property address is the same as the users' just use that
if($_POST['propertyaddress']==''){
$propertyaddress = $_POST['useraddress'];
} else {$propertyaddress = $_POST['propertyaddress'];}
if($_POST['propertycity']==''){
$propertycity = $_POST['usercity'];
} else {$propertycity = $_POST['propertycity'];}
if($_POST['propertystate']==''){
$propertystate = $_POST['userstate'];
} else {$propertystate = $_POST['propertystate'];}
if($_POST['propertyzip']==''){
$propertyzip = $_POST['userzip'];
} else {$propertyzip = $_POST['propertyzip'];}
$emailaddress = "support@livebycampus.com";
$emailsubject = "Email Reward Claim Sent";
$emailheaders = "From: LiveByCampus Support \n";
$emailheaders .= "Reply-To: LiveByCampus Support \n"; $emailheaders .= "MIME-Version: 1.0\n";
$emailheaders .= "Content-Type: text/html; charset=UTF-8\n";
$emailbody = "Dear Admin, A user has sent a reward claim via email.";
$emailbody .= " Here is the information they filled out: ";
$emailbody .= "User Name: " . $_POST['firstname'] . " " . $_POST['lastname'] . " ";
$emailbody .= "User Phone #: " . $_POST['userphone'] . " ";
$emailbody .= "User Email: " . $_POST['useremail'] . " ";
$emailbody .= "User Address: ";
$emailbody .= $_POST['useraddress'] . " " . $_POST['usercity'];
$emailbody .= ", " . $_POST['userstate'] . " " . $_POST['userzip'] . " ";
$emailbody .= "Lease Length: " . $_POST['leaselength'] . " ";
$emailbody .= "Move in Date: " . $_POST['Month'] . "/" . $_POST['Day'] .
"/" . $_POST['Year'] . " ";
$emailbody .= "Lease Sign Date: " . $_POST['SignMonth'] . "/" .
$_POST['SignDay'] . "/" . $_POST['SignYear'] . " ";
$emailbody .= "Monthly Rent: " . $_POST['monthlyrent'] . " ";
$emailbody .= "Property Name: " . $_POST['propertyname'] . " ";
$emailbody .= "Property Phone #: " . $_POST['propertyphone'] . " ";
$emailbody .= "Property Address: ";
$emailbody .= $propertyaddress . " " . $propertycity . ", " . $propertystate . " " . $propertyzip . " ";
$emailbody .= "Referred By: " . $_POST['referredby'];
echo $emailbody;
mail($emailaddress, $emailsubject, $emailbody, $emailheaders) or die("couldn't send email");
}
function sendManagerReminder($managerid){
$query="select p.propertyid,p.name,p.propertytype,p.companyid,p.displaystatus,m.firstname,m.lastname,m.email, p.location from propertyinfo p , managers m where p.managerid=m.managerid and m.managerid = '$managerid' order by datecreated desc";
$results = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($results) == 0) return;
$row = mysql_fetch_array($results, MYSQL_ASSOC);
//setup the email
$name = $row['firstname'] . " " . $row['lastname'];
$emailheaders = "From: LiveByCampus Reminders \n";
$emailheaders .= "Reply-To: LiveByCampus Support \n";
$emailheaders .= "MIME-Version: 1.0\n";
$emailheaders .= "Content-Type: text/html; charset=UTF-8\n";
$emailaddress = $row['email'];
$emailsubject = 'LiveByCampus Property Reminder';
$emailbody = "Hi $name,\n\n ";
$emailbody.= "Please take a moment to make sure your listings on LiveByCampus are still up-to-date:\n\n ";
$emailbody.= ''. $row['name'] .' - ';
$emailbody.= $row['location'] . " ";
while($row = mysql_fetch_array($results, MYSQL_ASSOC)){
$emailbody.= ''. $row['name'] .' - ';
$emailbody.= $row['location'] . " ";
}
$emailbody.= ' To edit your listings, click here .';
$emailbody.= " Thank You, ";
$emailbody.= "The LiveByCampus Team www.LiveByCampus.com";
echo $emailbody;
//mail($emailaddress, $emailsubject, $emailbody, $emailheaders) or die("couldn't send email");
}
?>