does anyone have a fix for this?
1: <?
2:
3: /***************************************************************************
4: * Dolphin Smart Community Builder
5: * -----------------
6: * begin : Mon Mar 23 2006
7: * copyright : (C) 2006 BoonEx Group
8: * website : http://www.boonex.com/
9: * This file is part of Dolphin - Smart Community Builder
10: *
11: * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12: * http://creativecommons.org/licenses/by/3.0/
13: *
14: * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16: * See the Creative Commons Attribution 3.0 License for more details.
17: * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18: * see license.txt file; if not, write to marketing@boonex.com
19: ***************************************************************************/
20:
21: require_once( '/home/dailaan2/public_html/inc/header.inc.php' );
22: require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
23: require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
24: require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
25:
26: // -------------
27:
28: // - Always finish
29: set_time_limit( 36000 );
30: ignore_user_abort();
31:
32: // - Defaults -
33: $MODE = "_MAIL_";
34: $DAY = "_OBEY_";
35:
36: // - Parameters check -
37: for ( $i = 0; strlen( $argv[$i] ); $i++ ) {
38: switch( $argv[$i] ) {
39: case '--live': $MODE = "_LIVE_"; break;
40: case '--mail': $MODE = "_MAIL_"; break;
41: }
42: }
43:
44: // - Begin -
45: if ( $MODE == '_MAIL_' )
46: ob_start();
47:
48: $msgs_per_start = getParam( 'msgs_per_start' );
49:
50: $iFullCount = (int)db_value( 'SELECT COUNT(*) FROM NotifyQueue', 0 );
51: if ( !$iFullCount ) exit;
52:
53: echo "\n- Start email send -\n";
54: echo "Total queued emails: $iFullCount\n";
55: $total_count = ($iFullCount < $msgs_per_start ? $iFullCount : $msgs_per_start);
56: $total_per_query = round( $total_count / 3 ) + 1;
57: echo "Ready for send: ". $total_count ."\n";
58:
59: if ( $iFullCount ) {
60: $count_ok = 0;
61: $err = 0;
62:
63: if ( $count_ok $total_count ) {
64: // Notify Messages
65: $nfs_res = db_res("
66: SELECT
67: NotifyQueue.Email as ID1,
68: NotifyQueue.Msg as ID2,
69: NotifyEmails.Name as Name,
70: NotifyEmails.Email,
71: NotifyMsgs.Subj,
72: NotifyMsgs.HTML as Body
73: FROM NotifyQueue
74: INNER JOIN NotifyMsgs ON
75: (NotifyMsgs.ID = NotifyQueue.Msg)
76: INNER JOIN NotifyEmails ON
77: (NotifyEmails.ID = NotifyQueue.Email)
78: WHERE
79: NotifyQueue.`From` = 'NotifyEmails' AND
80: NotifyEmails.EmailFlag = 'NotifyMe'
81: LIMIT $total_per_query
82: ",0 );
83:
84: while( $row = mysql_fetch_array( $nfs_res ) )
85: {
86: $headers = "From: {$site['title']} {$site['email_notify']}>";
87: $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers;
88: if ( !mail( $row['Email'], $row['Subj'], $row['Body'], $headers, "-f{$site['email_notify']}") )
89: ++$err;
90: if ( $row[ID1] && $row[ID2] )
91: db_res("DELETE FROM NotifyQueue WHERE `Email` = $row[ID1] AND `Msg` = $row[ID2] AND `From` = 'NotifyEmails'", 0 );
92: else
93: echo "ERROR: while deleting from 'NotifyQueue' ( Email ID: $row[ID1], Msg ID: $row[ID2] )\n";
94: ++$count_ok;
95: if ( $count_ok >= $total_count ) break;
96: }
97: }
98:
99:
100: if ( $count_ok < $total_count ) {
101: // Profiles Messages
102: $nfs_res = db_res("
103: SELECT
104: NotifyQueue.Email as ID1,
105: NotifyQueue.Msg as ID2,
106: Profiles.NickName as Name,
107: Profiles.Email,
108: NotifyMsgs.Subj,
109: NotifyMsgs.HTML as Body
110: FROM NotifyQueue
111: INNER JOIN NotifyMsgs ON
112: (NotifyMsgs.ID = NotifyQueue.Msg)
113: INNER JOIN Profiles ON
114: (Profiles.ID = NotifyQueue.Email)
115: WHERE
116: NotifyQueue.`From` = 'Profiles' AND
117: Profiles.EmailNotify = '1'
118: ",0 );
119:
120: while( $row = mysql_fetch_array( $nfs_res ) )
121: {
122: $headers = "From: {$site['title']} <{$site['email_notify']}>";
123: $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers;
124: if ( !mail( $row['Email'], $row['Subj'], $row['Body'], $headers, "-f{$site['email_notify']}") )
125: ++$err;
126: if ( $row[ID1] && $row[ID2] )
127: db_res("DELETE FROM NotifyQueue WHERE Email = $row[ID1] AND Msg = $row[ID2] AND NotifyQueue.`From` = 'Profiles'", 0 );
128: else
129: echo "ERROR: while deleting from 'NotifyQueue' ( Email ID: $row[ID1], Msg ID: $row[ID2] )\n";
130: ++$count_ok;
131: if ( $count_ok >= $total_count ) break;
132: }
133: }
134:
135:
136:
137: if ( $count_ok < $total_count ) {
138: // Profiles Messages
139: $nfs_res = db_res("
140: SELECT
141: NotifyQueue.Email as ID1,
142: NotifyQueue.Msg as ID2,
143: NotifyQueue.MsgText as Body,
144: NotifyQueue.MsgSubj as Subj,
145: Profiles.NickName as Name,
146: Profiles.Email
147: FROM NotifyQueue
148: INNER JOIN Profiles ON
149: (Profiles.ID = NotifyQueue.Email)
150: WHERE
151: NotifyQueue.`From` = 'ProfilesMsgText' AND
152: Profiles.EmailNotify = '1'
153: ",0);
154:
155: while( $row = mysql_fetch_array( $nfs_res ) )
156: {
157: $body = $row['Body'];
158: $headers = "From: {$site['title']} <{$site['email_notify']}>";
159:
160: $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers;
161:
162: if ( !mail( $row['Email'], $row['Subj'], $body, $headers, "-f{$site['email_notify']}") )
163: ++$err;
164: if ( !db_res("DELETE FROM NotifyQueue WHERE Email = $row[ID1] AND NotifyQueue.`From` = 'ProfilesMsgText'", 0 ) )
165: echo "ERROR: while deleting from 'NotifyQueue' ( Email ID: $row[ID1], Msg ID: $row[ID2] )\n";
166: ++$count_ok;
167: if ( $count_ok >= $total_count ) break;
168: }
169: }
170:
171: echo "Processed emails: $count_ok\n";
172: echo "Processed emails with errors: $err\n";
173: }
174:
175: if( $err and $MODE == '_MAIL_' ) {
176: $output = ob_get_clean();
177: mail( $site['email'], "{$site['title']}: Periodic Report (Notify Letters)", $output, "From: Periodic(Notify Letters) <$site[email]>", "-f$site[email]" );
178: }
179:
180: periodic_check_ban();
181: