- bugfixing function getNextCronjobs()

- fixed database-field-names in customer_autoresponder.php
- added date-pattern in autoresponder_add and _delete templates
- corrected $cronlog->logAction()-calls in cron_autoresponder.php
- corrected time-cycle-check in cron_autoresponder.php
This commit is contained in:
Michael Kaufmann (d00p)
2010-01-28 10:02:14 +00:00
parent 8924a43172
commit 3ef5cba67b
5 changed files with 34 additions and 22 deletions

View File

@@ -34,7 +34,7 @@ if($action == "add")
$message = trim($_POST['message']); $message = trim($_POST['message']);
$date_from_off = isset($_POST['date_from_off']) ? -1 : 0; $date_from_off = isset($_POST['date_from_off']) ? -1 : 0;
$date_until_off = isset($_POST['date_from_off']) ? -1 : 0; $date_until_off = isset($_POST['date_until_off']) ? -1 : 0;
/* /*
* @TODO validate date (DD-MM-YYYY) * @TODO validate date (DD-MM-YYYY)
@@ -82,8 +82,8 @@ if($action == "add")
SET `email` = '" . $db->escape($account) . "', SET `email` = '" . $db->escape($account) . "',
`message` = '" . $db->escape($message) . "', `message` = '" . $db->escape($message) . "',
`enabled` = '" . (int)$_POST['active'] . "', `enabled` = '" . (int)$_POST['active'] . "',
`ts_from` = '" . (int)$ts_from . "', `date_from` = '" . (int)$ts_from . "',
`ts_until` = '" . (int)$ts_until . "', `date_until` = '" . (int)$ts_until . "',
`subject` = '" . $db->escape($subject) . "', `subject` = '" . $db->escape($subject) . "',
`customerid` = '" . $db->escape((int)$userinfo['customerid']) . "' `customerid` = '" . $db->escape((int)$userinfo['customerid']) . "'
"); ");
@@ -126,7 +126,7 @@ if($action == "edit")
$message = trim($_POST['message']); $message = trim($_POST['message']);
$date_from_off = isset($_POST['date_from_off']) ? -1 : 0; $date_from_off = isset($_POST['date_from_off']) ? -1 : 0;
$date_until_off = isset($_POST['date_from_off']) ? -1 : 0; $date_until_off = isset($_POST['date_until_off']) ? -1 : 0;
/* /*
* @TODO validate date (DD-MM-YYYY) * @TODO validate date (DD-MM-YYYY)
@@ -181,8 +181,8 @@ if($action == "edit")
$db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "` $db->query("UPDATE `" . TABLE_MAIL_AUTORESPONDER . "`
SET `message` = '" . $db->escape($message) . "', SET `message` = '" . $db->escape($message) . "',
`enabled` = '" . (int)$ResponderActive . "', `enabled` = '" . (int)$ResponderActive . "',
`ts_from` = '" . (int)$ts_from . "', `date_from` = '" . (int)$ts_from . "',
`ts_until` = '" . (int)$ts_until . "', `date_until` = '" . (int)$ts_until . "',
`subject` = '" . $db->escape($subject) . "' `subject` = '" . $db->escape($subject) . "'
WHERE `email` = '" . $db->escape($account) . "' WHERE `email` = '" . $db->escape($account) . "'
AND `customerid` = '" . $db->escape((int)$userinfo['customerid']) . "' AND `customerid` = '" . $db->escape((int)$userinfo['customerid']) . "'
@@ -281,21 +281,21 @@ else
while($row = $db->fetch_array($result)) while($row = $db->fetch_array($result))
{ {
if($result['date_from'] == -1 && $result['date_until'] == -1) if($row['date_from'] == -1 && $row['date_until'] == -1)
{ {
$activated_date = $lng['panel']['not_activated']; $activated_date = $lng['panel']['not_activated'];
} }
elseif($result['date_from'] == -1 && $result['date_until'] != -1) elseif($row['date_from'] == -1 && $row['date_until'] != -1)
{ {
$activated_date = $lng['autoresponder']['date_until'].': '.date('d-m-Y', $result['date_until']); $activated_date = $lng['autoresponder']['date_until'].': '.date('d-m-Y', $row['date_until']);
} }
elseif($result['date_from'] != -1 && $result['date_until'] == -1) elseif($row['date_from'] != -1 && $row['date_until'] == -1)
{ {
$activated_date = $lng['autoresponder']['date_from'].': '.date('d-m-Y', $result['date_from']); $activated_date = $lng['autoresponder']['date_from'].': '.date('d-m-Y', $row['date_from']);
} }
else else
{ {
$activated_date = $date('d-m-Y', $result['date_from']) . ' - ' . date('d-m-Y', $result['date_until']); $activated_date = date('d-m-Y', $row['date_from']) . ' - ' . date('d-m-Y', $row['date_until']);
} }
eval("\$autoresponder.=\"" . getTemplate("email/autoresponder_autoresponder") . "\";"); eval("\$autoresponder.=\"" . getTemplate("email/autoresponder_autoresponder") . "\";");
} }

View File

@@ -36,9 +36,9 @@ function getNextCronjobs()
if($name == '0') continue; if($name == '0') continue;
if($x == 0) { if($x == 0) {
$query.= 'DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.') <= UTC_TIMESTAMP()'; $query.= 'UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP()';
} else { } else {
$query.= ' OR DATE_ADD(UNIX_TIMESTAMP(`lastrun`), INTERVAL '.$ival.') <= UTC_TIMESTAMP()'; $query.= ' OR UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP()';
} }
$x++; $x++;
} }

View File

@@ -79,13 +79,25 @@ if($db->num_rows($result) > 0)
if($ts_end != -1 && $ts_end < $ts_now) continue; if($ts_end != -1 && $ts_end < $ts_now) continue;
$path = $row['homedir'] . $row['maildir'] . "new/"; $path = $row['homedir'] . $row['maildir'] . "new/";
if(!is_dir($paht) || !is_readable($path))
{
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Error accessing maildir: " . $path);
continue;
}
$files = scandir($path); $files = scandir($path);
foreach($files as $entry) foreach($files as $entry)
{ {
if($entry == '.' if($entry == '.'
|| $entry == '..')continue; || $entry == '..')continue;
if(time() - filemtime($path . $entry) - $cycle <= 0) /*
* is the time passed between now and
* the time we received the mail lower/equal
* than our cycle-seconds?
*/
if(time() - filemtime($path . $entry) <= $cycle)
{ {
$content = file($path . $entry); $content = file($path . $entry);
@@ -93,7 +105,7 @@ if($db->num_rows($result) > 0)
if(count($content) == 0) if(count($content) == 0)
{ {
$cronlog->logAction(LOG_ERROR, LOG_WARNING, "Unable to read mail from maildir: " . $entry); $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Unable to read mail from maildir: " . $entry);
continue; continue;
} }
@@ -174,7 +186,7 @@ if($db->num_rows($result) > 0)
if($to == '' if($to == ''
|| $from == '') || $from == '')
{ {
$cronlog->logAction(LOG_ERROR, LOG_WARNING, "No valid headers found in mail to parse: " . $entry); $cronlog->logAction(CRON_ACTION, LOG_WARNING, "No valid headers found in mail to parse: " . $entry);
continue; continue;
} }
@@ -219,7 +231,7 @@ if($db->num_rows($result) > 0)
$mailerr_msg = $from; $mailerr_msg = $from;
} }
$cronlog->logAction(LOG_ERROR, LOG_WARNING, "Error sending autoresponder mail: " . $mailerr_msg); $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Error sending autoresponder mail: " . $mailerr_msg);
} }
$mail->ClearAddresses(); $mail->ClearAddresses();

View File

@@ -15,11 +15,11 @@ $header
<td class="main_field_display" nowrap="nowrap"><input type="checkbox" name="active" value="1" checked="checked" /></td> <td class="main_field_display" nowrap="nowrap"><input type="checkbox" name="active" value="1" checked="checked" /></td>
</tr> </tr>
<tr> <tr>
<td class="main_field_name">{$lng['autoresponder']['date_from']}:</td> <td class="main_field_name">{$lng['autoresponder']['date_from']} (dd-mm-yyyy):</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" name="date_from" maxlength="10" />&nbsp;{$date_from_off}</td> <td class="main_field_display" nowrap="nowrap"><input type="text" name="date_from" maxlength="10" />&nbsp;{$date_from_off}</td>
</tr> </tr>
<tr> <tr>
<td class="main_field_name">{$lng['autoresponder']['date_until']}:</td> <td class="main_field_name">{$lng['autoresponder']['date_until']} (dd-mm-yyyy):</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" name="date_until" maxlength="10" />&nbsp;{$date_until_off}</td> <td class="main_field_display" nowrap="nowrap"><input type="text" name="date_until" maxlength="10" />&nbsp;{$date_until_off}</td>
</tr> </tr>
<tr> <tr>

View File

@@ -16,11 +16,11 @@ $header
<td class="main_field_display" nowrap="nowrap"><input type="checkbox" name="active" value="1"{$checked} /></td> <td class="main_field_display" nowrap="nowrap"><input type="checkbox" name="active" value="1"{$checked} /></td>
</tr> </tr>
<tr> <tr>
<td class="main_field_name">{$lng['autoresponder']['date_from']}:</td> <td class="main_field_name">{$lng['autoresponder']['date_from']} (dd-mm-yyyy):</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" name="date_from" maxlength="10" value="{$date_from}" />&nbsp;{$date_from_off}</td> <td class="main_field_display" nowrap="nowrap"><input type="text" name="date_from" maxlength="10" value="{$date_from}" />&nbsp;{$date_from_off}</td>
</tr> </tr>
<tr> <tr>
<td class="main_field_name">{$lng['autoresponder']['date_until']}:</td> <td class="main_field_name">{$lng['autoresponder']['date_until']} (dd-mm-yyyy):</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" name="date_until" maxlength="10" value="{$date_until}" />&nbsp;{$date_until_off}</td> <td class="main_field_display" nowrap="nowrap"><input type="text" name="date_until" maxlength="10" value="{$date_until}" />&nbsp;{$date_until_off}</td>
</tr> </tr>
<tr> <tr>