source: trunk/inc/classes/BxDolCronNotifies.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 2.7 KB
Line 
1<?php
2/***************************************************************************
3* Dolphin Smart Community Builder
4* -------------------
5* begin : Mon Mar 23 2006
6* copyright : (C) 2007 BoonEx Group
7* website : http://www.boonex.com
8* This file is part of Dolphin - Smart Community Builder
9*
10* Dolphin is free software; you can redistribute it and/or modify it under
11* the terms of the GNU General Public License as published by the
12* Free Software Foundation; either version 2 of the
13* License, or any later version.
14*
15* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
16* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17* See the GNU General Public License for more details.
18* You should have received a copy of the GNU General Public License along with Dolphin,
19* see license.txt file; if not, write to marketing@boonex.com
20***************************************************************************/
21
22require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
23require_once('BxDolCron.php');
24
25class BxDolCronNotifies extends BxDolCron {
26
27 function processing() {
28 global $site;
29
30 set_time_limit( 36000 );
31 ignore_user_abort();
32
33 $sResult = "";
34 $iPerStart = getParam('msgs_per_start');
35
36 $iFullCount = (int)$GLOBALS['MySQL']->getOne('SELECT COUNT(*) FROM `sys_sbs_queue`');
37 if($iFullCount) {
38 $iProcess = $iFullCount < $iPerStart ? $iFullCount : $iPerStart;
39
40 $sResult .= "\n- Start email send -\n";
41 $sResult .= "Total queued emails: " . $iFullCount . "\n";
42 $sResult .= "Ready for send: " . $iProcess . "\n";
43
44 $aMails = $GLOBALS['MySQL']->getAll("SELECT `id`, `email`, `subject`, `body` FROM `sys_sbs_queue` ORDER BY `id` LIMIT 0, " . $iProcess);
45
46 $iSent = 0;
47 $aIds = array();
48 foreach($aMails as $aMail) {
49 $aIds[] = $aMail['id'];
50 if(sendMail($aMail['email'], $aMail['subject'], $aMail['body']))
51 $iSent++;
52 else
53 $sResult .= "Cannot send message to " . $aMail['email'] . "\n";
54 }
55 $GLOBALS['MySQL']->query("DELETE FROM `sys_sbs_queue` WHERE `id` IN ('" . implode("','", $aIds) . "')");
56
57 $sResult .= "Processed emails: " . $iSent . "\n";
58 sendMail($site['email'], $site['title'] . ": Periodic Report", $sResult);
59
60 periodic_check_ban();
61 }
62 }
63}
64
65?>
Note: See TracBrowser for help on using the repository browser.