diff -ru maia-1.0.0-prepatch/scripts/send-quarantine-digests.pl maia-1.0.0/scripts/send-quarantine-digests.pl
|
old
|
new
|
|
| 121 | 121 | # anything below this point. # |
| 122 | 122 | ######################################################################## |
| 123 | 123 | |
| | 124 | # The organization of this file makes this a bit obtuse |
| | 125 | my $isPg = 0; |
| | 126 | |
| 124 | 127 | # Retrieve the string value associated with a key in the database.cfg file. |
| 125 | 128 | sub get_string_key($$) |
| 126 | 129 | { |
| … |
… |
|
| 182 | 185 | my $unique_string = phrase_generate(); |
| 183 | 186 | |
| 184 | 187 | my $insert = "INSERT INTO maia_tokens (token_system, token, data, expires) " . |
| 185 | | "VALUES ('digest',?,?, DATE_ADD(NOW(), INTERVAL ? DAY))"; |
| | 188 | "VALUES ('digest',?,?, " . |
| | 189 | ($isPg ? "NOW() + INTERVAL ? DAY" |
| | 190 | : "DATE_ADD(NOW(), INTERVAL ? DAY)") . |
| | 191 | ")"; |
| 186 | 192 | my $sth = $dbh->prepare($insert); |
| 187 | 193 | $sth->execute($unique_string, $maia_user_id,$days) or die (sprintf("Maia: [send-quarantine-reminders] Couldn't execute query: %s", $dbh->errstr));; |
| 188 | 194 | |
| … |
… |
|
| 201 | 207 | |
| 202 | 208 | # Connect to the database |
| 203 | 209 | my $dsn = get_string_key($db_cfg, "dsn"); |
| | 210 | # The organization of this file makes this a bit obtuse |
| | 211 | $isPg = $dsn =~ /^dbi:Pg/; |
| 204 | 212 | my $username = get_string_key($db_cfg, "username"); |
| 205 | 213 | my $password = get_string_key($db_cfg, "password"); |
| 206 | 214 | my $dbh = DBI->connect($dsn, $username, $password) |
| … |
… |
|
| 240 | 248 | "WHERE maia_users.primary_email_id = users.id " . |
| 241 | 249 | "AND maia_users.quarantine_digest_interval > 0 " . |
| 242 | 250 | "AND (maia_users.quarantine_digest_interval <= " . |
| 243 | | "((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(maia_users.last_digest_sent)) / 60) " . |
| | 251 | ($isPg ? "(( ROUND(DATE_PART('epoch', NOW())) - ROUND(DATE_PART('epoch', maia_users.last_digest_sent))) / 60)" |
| | 252 | : "((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(maia_users.last_digest_sent)) / 60) ") . |
| 244 | 253 | "OR maia_users.last_digest_sent IS NULL) " . |
| 245 | 254 | "ORDER BY maia_users.id ASC"; |
| 246 | 255 | my $sth3 = $dbh->prepare($select) |