-
Notifications
You must be signed in to change notification settings - Fork 0
/
weekly_reminder.php
46 lines (42 loc) · 1.25 KB
/
weekly_reminder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/*This script goes through the text file generated with all emails and timestamps
*It gets each row, checks if date is within the week
*if the date is within the week, it creates a new file called daily.csv
*if the date is not within the week, it creates another file called weekly.csv
*the file then deletes the origial emails file*/
//check for the existance of the csv file with the emails
//if file exists, send email to each user every day with option to delete their account
include_once 'emailClass.php';
//read csv file and obtain the date';
$emailer = new EmailClass();
if(file_exists('/tmp/month_emails.csv'))
{
$file = fopen('/tmp/month_emails.csv','r');
while(!feof($file))
{
$data = fgetcsv($file,1024);
//check if file has records
if(0 != filesize('/tmp/month_emails.csv'))
{
//send email
$email = $data[0];
$id = $data[1];
$pw = $data[2];
$hash = strtolower($email);
$hash .= $pw;
$hash = md5($hash);
//echo $email;
echo $emailer->sendEmail($hash,$id,$email);
}
else
{
//if file is empty or doesnt exist, the log and exit
echo "Empty file";
}
}
}
else
{
//log file doesnt exist
}
?>