Skip to content

Instantly share code, notes, and snippets.

@scoutman57
Created February 12, 2015 14:59
Show Gist options
  • Save scoutman57/5bdc99e8373e3b275484 to your computer and use it in GitHub Desktop.
Save scoutman57/5bdc99e8373e3b275484 to your computer and use it in GitHub Desktop.
Restructure for gist.github.com/LinuxPhreak/30e6a71da2ef5fb27514
function getLawyers() {
$query = mysqli_query($con,"SELECT * FROM lawyers");
$lawyers = mysqli_fetch_assoc($query);
return $lawyers;
}
if (strtotime($lawyers['day']) < strtotime('-30 days') && $lawyers['paid'] = 1)
{
setPaid(0);
setAds(0);
}
//$renewyear = mysqli_query($con,"SELECT * FROM lawyers WHERE paid=2 AND day > NOW() - INTERVAL 1 YEAR");
if (strtotime($lawyers['day']) < strtotime('-365 days') && $lawyers['paid'] = 2)
{
setPaid(0);
setAds(0);
}
if (strtotime($lawyers['day']) < strtotime('-90 days') && $lawyers['paid'] = 3)
{
setAds(0);
}
//$remind = mysqli_query($con,"SELECT * FROM lawyers WHERE paid=1 AND day > NOW() - INTERVAL 22 DAY");
if (strtotime($lawyers['day']) < strtotime('-20 days') && $lawyers['paid'] = 1)
{
$subject = 'Subscription Renewal';
$message = "Hello $fname $lname this is the site owners, notifying you that your account is up for renewal. If you have auto payment enabled we will charge you";
notify($lawyers['email'], $subject, $message, $headers);
}
//$remindyear = mysqli_query($con,"SELECT * FROM lawyers WHERE paid=2 AND day > NOW() - INTERVAL 360 DAY");
if (strtotime($lawyers['day']) < strtotime('-360 days') && $lawyers['paid'] = 2)
{
$subject = 'Subscription Renewal';
$message = "Hello $fname $lname this is the site owners, notifying you that your account is up for renewal. If you have auto payment enabled we will charge you";
notify($lawyers['email'], $subject, $message);
}
//$remind = mysqli_query($con,"SELECT * FROM lawyers WHERE paid=1 AND day > NOW() - INTERVAL 22 DAY");
if (strtotime($lawyers['day']) < strtotime('-85 days') && $lawyers['paid'] = 3)
{
$subject = 'Trial Expiration';
$message = "Hello $fname $lname this is the site owners, notifying you that your trial period is almost over. Your card will be charged when your trial ends";
notify($lawyers['email'], $subject, $message);
}
function setPaid($value) {
mysqli_query($con,"UPDATE lawyers SET paid = $value");
}
function setAds($value) {
mysqli_query($con,"UPDATE ads SET active = $value");
}
function notify($to, $subject, $message) {
$message = wordwrap($message, 70, "\r\n");
$headers = "From: noreply@$website\r\n Reply-To: noreply@$website \r\n X-Mailer: PHP/" . phpversion();
$headers .= "To: $fname $lname <$email>\r\n";
mail($to, $subject, $message, $headers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment