#!/usr/bin/php -q '$lastid' and a.`memid` = u.`id` and a.`general` = 1 ) union distinct ( select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language` from `users` as u, `domains` as d, `domaincerts` as dc where u.`deleted` = 0 and u.`id` > '$lastid' and dc.`domid` = d.`id` and d.`memid` = u.`id` and dc.`expire` >= '2011-12-01' ) union distinct ( select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language` from `users` as u, `domains` as d, `domlink` as dl, `domaincerts` as dc where u.`deleted` = 0 and u.`id` > '$lastid' and dc.`id` = dl.`certid` and dl.`domid` = d.`id` and d.`memid` = u.`id` and dc.`expire` >= '2011-12-01' ) union distinct ( select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language` from `users` as u, `org` as o, `orgdomaincerts` as dc where u.`deleted` = 0 and u.`id` > '$lastid' and dc.`orgid` = o.`orgid` and o.`memid` = u.`id` and dc.`expire` >= '2011-12-01' ) union distinct ( select u.`id`, u.`fname`, u.`lname`, u.`email`, u.`language` from `users` as u, `org` as o, `orgdomains` as d, `orgdomlink` as dl, `orgdomaincerts` as dc where u.`deleted` = 0 and u.`id` > '$lastid' and dc.`id` = dl.`orgcertid` and dl.`orgdomid` = d.`id` and d.`orgid` = o.`orgid` and o.`memid` = u.`id` and dc.`expire` >= '2011-12-01' ) order by `id`"; $res = mysql_query($query); while($row = mysql_fetch_assoc($res)) { $mailtxt = "Dear ${row["fname"]} ${row["lname"]},\n".$lines_EN."\n\n"; switch ($row["language"]) { case "de_DE": case "de": $mailtxt .= $lines_DE; break; } sendmail($row['email'], "[CAcert.org] Information about Heartbleed bug in OpenSSL 1.0.1 up to 1.0.1f", $mailtxt, "support@cacert.org", "", "", "CAcert", "returns@cacert.org", ""); $fp = fopen("send_heartbleed_lastid.txt", "w"); fputs($fp, $row["id"]."\n"); fclose($fp); $count++; echo "Sent ${count}th mail. User ID: ${row["id"]}\n"; sleep (1); }