-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcronjob.php.save
executable file
·60 lines (45 loc) · 1.67 KB
/
cronjob.php.save
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
ini_set('display_errors',true);
require("components.php");
require "sent.php";
date_default_timezone_set("Africa/Johannesburg");
$day = strtolower(date("D"));
$time = intval( strtolower(date("G")) );
echo $time." ".$day;
$status = "verified";
$out = fopen("debug.txt","a+");
$msg = "";
$db = new mysqli("email.c9ssouqvesbm.us-west-2.rds.amazonaws.com","root","email123","Email Subscription");
if($db->connect_error){
echo $db->connect_error."<br>"."connection not successfull<br>";
}
$stm = $db->prepare("SELECT email, category from users where ".$day." = ? and status = ?");
$stm->bind_param("is",$time,$status);
$response = $stm->execute();
if($response){
echo "successfull prepared statement<br>";
}
else{
echo "unsuccessful prepared statement<br>";
}
$result = $stm->get_result();
//var_dump($result->fetch_assoc());
/* now you can fetch the results into an array - NICE */
while ($myrow = $result->fetch_assoc()) {
// use your $myrow array as you would with any other fetch
$questions=get_questions( $myrow["category"]);
$email_html = generate_email($questions, $myrow["category"],$myrow["email"]);
$status = send_questions($myrow["email"], $email_html);
if ($status){
//echo "email sent";
$msg.="\nemail sent successfully to ".$myrow["email"]." \t for category ".$myrow["category"]."\n";
// echo "email sent successfully to ".$myrow["email"]." \t for category ".$myrow["category"]."\n";
}
else{
$msg.="\nemail unsuccessfully to ".$myrow["email"]." \t for category ".$myrow["category"]."\n";
}
sleep(1);
}
fwrite($out,$msg);
fclose($out);
?>