source: trunk/www/scripts/db2mail.php @ 74

Last change on this file since 74 was 74, checked in by guyru, 6 years ago

work on screen shot page and initial import of the open yahtzee site
files to the svn

File size: 1.3 KB
Line 
1#!/usr/bin/php -q
2<?php
3$link = mysql_connect('mysql4-o', 'o175453rw', 'OvRzHf2M')
4   or die('Could not connect: ' . mysql_error());
5mysql_select_db('o175453_general') or die('Could not select database');
6
7$query = 'SELECT ID, recipient, subject, message, headers FROM mailer WHERE processor&1=0 limit 20';
8$result = mysql_query($query) or die('Query failed: ' . mysql_error());
9
10
11$total = 0;
12while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
13  $line['ID'] = breakapart ($line['ID']);
14  $line['subject'] = breakapart ($line['subject']);
15  $line['recipient'] = breakapart ($line['recipient']);
16  $line['headers'] = breakapart ($line['headers']);
17  $line['headers'] .= "Message-DBID: ". $line['ID'] ."\n";
18
19  echo ("Processing item ". $line['ID'] ." to '". $line['recipient'] ."', Subject '". $line['subject'] ."'\n");
20  @mail($line['recipient'], $line['subject'], $line['message'], $line['headers']);
21  $total++;
22}
23if ($total) {
24  echo ("$total item(s) processed.\n");
25  $query = 'UPDATE mailer SET processor=processor|1 WHERE processor&1=0 limit 20';
26  $result = mysql_query($query) or die('Query failed: ' . mysql_error());
27}
28
29function breakapart (&$string) {
30  $string = str_replace ('\\\"', '"', $string);
31  $string = str_replace ('\\\`', '`', $string);
32  return $string;
33}
34?>
35
Note: See TracBrowser for help on using the repository browser.