Icy Phoenix is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

Commit 199

User picture
  • Author: Mighty Gorgon
  • 2010-04-04 19:13 (about 4 years ago)

Other bugs fixed about UTF-8:

  • Emailer class has been rewritten (some parts of code taken from phpBB 3)
  • All files which uses emailer have been edited to reflect new changes
  • Some files had wrong encoding

Added jQuery and jQuery UI for future use

Files Affected

 
198199
123
 
123
 
124
# This ruleset is to "stop" stupid attempts to use MS IIS expolits on us
124
# This ruleset is to "stop" stupid attempts to use MS IIS expolits on us
125
# NIMDA
125
# NIMDA
126
RewriteCond %{REQUEST_URI} /(admin圭md多ttpodbc好siislog字oot存hell)\.(dll圯xe) [NC]
126
RewriteCond %{REQUEST_URI} /(admin¦cmd¦httpodbc¦nsiislog¦root¦shell)\.(dll¦exe) [NC]
127
RewriteRule !(error\.php|robots\.txt) /error.php?mode=nimda [L,E=HTTP_USER_AGENT:NIMDA_EXPLOIT,T=application/x-httpd-cgi]
127
RewriteRule !(error\.php|robots\.txt) /error.php?mode=nimda [L,E=HTTP_USER_AGENT:NIMDA_EXPLOIT,T=application/x-httpd-cgi]
128
 
128
 
129
# CODERED
129
# CODERED
130
RewriteCond %{REQUEST_URI} /default\.(idaidq)$ [NC,OR]
130
RewriteCond %{REQUEST_URI} /default\.(ida¦idq)$ [NC,OR]
131
RewriteCond %{REQUEST_URI} /.*\.printer$ [NC]
131
RewriteCond %{REQUEST_URI} /.*\.printer$ [NC]
132
RewriteRule !(error\.php|robots\.txt) /error.php?mode=codered [L,E=HTTP_USER_AGENT:CODERED_EXPLOIT,T=application/x-httpd-cgi]
132
RewriteRule !(error\.php|robots\.txt) /error.php?mode=codered [L,E=HTTP_USER_AGENT:CODERED_EXPLOIT,T=application/x-httpd-cgi]
133
### VIRUS - EXPLOITS - END
133
### VIRUS - EXPLOITS - END
...
 
...
 
174
 
174
 
175
# This ruleset is for formmail script abusers...
175
# This ruleset is for formmail script abusers...
176
# We don't use Perl for Postnuke so this is not really needed.
176
# We don't use Perl for Postnuke so this is not really needed.
177
RewriteCond %{REQUEST_URI} (mail.?form|form|form.?mail|mail|mailto)\.(cgi圯xe如l)$ [NC]
177
RewriteCond %{REQUEST_URI} (mail.?form|form|form.?mail|mail|mailto)\.(cgi¦exe¦pl)$ [NC]
178
 
178
 
179
# Used to send these bots to someplace else you can change the url to whatever you would like
179
# Used to send these bots to someplace else you can change the url to whatever you would like
180
#RewriteRule .* http://www.microsoft.com/ [F,R,L]
180
#RewriteRule .* http://www.microsoft.com/ [F,R,L]
198199
93
            }
93
            }
94
 
94
 
95
            include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
95
            include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
96
            $emailer = new emailer($config['smtp_delivery']);
96
            $emailer = new emailer();
97
            $emailer->from($config['board_email']);
 
 
98
            $emailer->replyto($config['board_email']);
 
 
99
            $emailer->use_template('admin_account_action', stripslashes($mail['user_lang']));
97
            $emailer->use_template('admin_account_action', stripslashes($mail['user_lang']));
100
            $emailer->email_address($mail['user_email']);
98
            $emailer->to($mail['user_email']);
101
            $emailer->set_subject($subject);
99
            $emailer->set_subject($subject);
102
 
100
 
103
            $emailer->assign_vars(array(
101
            $emailer->assign_vars(array(
198199
259
            include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
259
            include_once(IP_ROOT_PATH . 'includes/class_pm.' . PHP_EXT);
260
            $privmsg = new class_pm();
260
            $privmsg = new class_pm();
261
        }
261
        }
 
 
262
        $bcc_list_array = array();
262
        $bcc_list = '';
263
        $bcc_list = '';
263
        do
264
        do
264
        {
265
        {
...
 
...
 
267
                $privmsg->send($userdata['user_id'], $row['user_id'], $subject, $pm_message);
268
                $privmsg->send($userdata['user_id'], $row['user_id'], $subject, $pm_message);
268
            }
269
            }
269
            $bcc_list .= (($bcc_list != '') ? ', ' : '') . $row['user_email'];
270
            $bcc_list .= (($bcc_list != '') ? ', ' : '') . $row['user_email'];
 
 
271
            $bcc_list_array[] = $row['user_email'];
270
        }
272
        }
271
        while ($row = $db->sql_fetchrow($result));
273
        while ($row = $db->sql_fetchrow($result));
272
        $db->sql_freeresult($result);
274
        $db->sql_freeresult($result);
...
 
...
 
296
            $config['smtp_host'] = @$ini_val('SMTP');
298
            $config['smtp_host'] = @$ini_val('SMTP');
297
        }
299
        }
298
 
300
 
299
        $emailer = new emailer($config['smtp_delivery']);
301
        $emailer = new emailer();
300
 
302
 
301
        $email_headers = 'X-AntiAbuse: Board servername - ' . trim($config['server_name']) . "\n";
303
        $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
302
        $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
304
        $emailer->headers('X-AntiAbuse: User_id - ' . $userdata['user_id']);
303
        $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
305
        $emailer->headers('X-AntiAbuse: Username - ' . $userdata['username']);
304
        $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
306
        $emailer->headers('X-AntiAbuse: User IP - ' . decode_ip($user_ip));
305
 
307
 
306
        if ($email_format == 2)
308
        if ($email_format == 2)
307
        {
309
        {
...
 
...
 
311
        {
313
        {
312
            $emailer->use_template('admin_send_email', $config['default_lang']);
314
            $emailer->use_template('admin_send_email', $config['default_lang']);
313
        }
315
        }
314
        $emailer->bcc($bcc_list);
316
        foreach ($bcc_list_array as $bcc_address)
315
        $emailer->email_address($config['board_email']);
317
        {
316
        $emailer->from($config['board_email']);
318
            if (!empty($bcc_address))
317
        $emailer->replyto($config['board_email']);
319
            {
318
        $emailer->extra_headers($email_headers);
320
                $emailer->bcc($bcc_address);
 
 
321
            }
 
 
322
        }
319
        $emailer->set_subject($subject);
323
        $emailer->set_subject($subject);
320
 
324
 
321
        // Do we want to force line breaks? It is HTML, so we should not replace line breaks...
325
        // Do we want to force line breaks? It is HTML, so we should not replace line breaks...
198199
295
            $group_id = intval($_POST[POST_GROUPS_URL]);
295
            $group_id = intval($_POST[POST_GROUPS_URL]);
296
 
296
 
297
            include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
297
            include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
298
            $emailer = new emailer($config['smtp_delivery']);
298
            $emailer = new emailer();
299
 
299
 
300
            $i = 0;
300
            $i = 0;
301
            while($i < sizeof($user_ids))
301
            while($i < sizeof($user_ids))
...
 
...
 
354
 
354
 
355
                    $server_url = $server_protocol . $server_name . $server_port . $script_name;
355
                    $server_url = $server_protocol . $server_name . $server_port . $script_name;
356
 
356
 
357
                    $emailer->from($config['board_email']);
 
 
358
                    $emailer->replyto($config['board_email']);
 
 
359
 
 
 
360
                    $emailer->use_template('group_added', $row['user_lang']);
357
                    $emailer->use_template('group_added', $row['user_lang']);
361
                    $emailer->email_address($row['user_email']);
358
                    $emailer->to($row['user_email']);
362
                    $emailer->set_subject($lang['Group_added']);
359
                    $emailer->set_subject($lang['Group_added']);
363
 
360
 
364
                    $emailer->assign_vars(array(
361
                    $emailer->assign_vars(array(
198199
1233
 
1233
 
1234
            include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
1234
            include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
1235
 
1235
 
1236
            $email_headers = 'From: ' . $config['board_email'] . "\nReturn-Path: " . $config['board_email'] . "\r\n";
 
 
1237
 
 
 
1238
            $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
1236
            $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
1239
            $server_name = trim($config['server_name']);
1237
            $server_name = trim($config['server_name']);
1240
            $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' :
'/';
1238
            $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' :
'/';
...
 
...
 
1253
            {
1251
            {
1254
                if ($to_users['user_notify_pm'] && !empty($to_users['user_email']) && $to_users['user_active'])
1252
                if ($to_users['user_notify_pm'] && !empty($to_users['user_email']) && $to_users['user_active'])
1255
                {
1253
                {
1256
                    $emailer = new emailer($config['smtp_delivery']);
1254
                    $emailer = new emailer();
1257
 
 
 
1258
                    $emailer->use_template('album_notify', $to_users['user_lang']);
1255
                    $emailer->use_template('album_notify', $to_users['user_lang']);
1259
                    $emailer->extra_headers($email_headers);
1256
                    $emailer->to($to_users['user_email']);
1260
                    $emailer->email_address($to_users['user_email']);
 
 
1261
                    $emailer->set_subject(); //$lang['Notification_subject']
1257
                    $emailer->set_subject(); //$lang['Notification_subject']
1262
 
1258
 
1263
                    $emailer->assign_vars(array(
1259
                    $emailer->assign_vars(array(
198199
28
    array('Number of rows', '', 'md_pics_rows_number', '1,2,3,4', '1,2,3,4', '3', 'album',
'2'),
28
    array('Number of rows', '', 'md_pics_rows_number', '1,2,3,4', '1,2,3,4', '3', 'album',
'2'),
29
    array('Number of columns', '', 'md_pics_cols_number', '1,2,3,4,5', '1,2,3,4,5', '3',
'album', '1'),
29
    array('Number of columns', '', 'md_pics_cols_number', '1,2,3,4,5', '1,2,3,4,5', '3',
'album', '1'),
30
    array('Random or newest pics?', '', 'md_pics_sort', 'Newest,Random', '0,1', '3',
'album', '0'),
30
    array('Random or newest pics?', '', 'md_pics_sort', 'Newest,Random', '0,1', '3',
'album', '0'),
31
    array('Display from what galleries?', '', 'md_pics_all', 'Public,Public and Personal', '0,1',
'3', 'album', '0')
31
    array('Display from what galleries?', '', 'md_pics_all', 'Public,Public and Personal', '0,1', '3', 'album', '0'),
 
 
32
    array('Create Slideshow', '', 'md_pics_slider', 'Yes,No', '1,0', '3', 'album', '0')
32
);
33
);
33
 
34
 
34
$block_count_variables = sizeof($block_variables);
35
$block_count_variables = sizeof($block_variables);
198199
40
        }
40
        }
41
 
41
 
42
        $template->_tpldata['recent_pics.'] = array();
42
        $template->_tpldata['recent_pics.'] = array();
43
        //reset($template->_tpldata['recent_pics.']);
 
 
44
        $template->_tpldata['recent_details.'] = array();
43
        $template->_tpldata['recent_details.'] = array();
45
        //reset($template->_tpldata['recent_details.']);
 
 
46
        $template->_tpldata['no_pics'] = array();
44
        $template->_tpldata['no_pics'] = array();
47
        //reset($template->_tpldata['no_pics.']);
 
 
48
 
45
 
49
        /*
46
        /*
50
        echo($cms_config_vars['md_pics_all'][$block_id] . '<br />');
47
        echo($cms_config_vars['md_pics_all'][$block_id] . '<br />');
...
 
...
 
120
            $pics_allowed = '';
117
            $pics_allowed = '';
121
        }
118
        }
122
 
119
 
 
 
120
        $no_pics = false;
123
        if ($allowed_cat != $pics_allowed)
121
        if ($allowed_cat != $pics_allowed)
124
        {
122
        {
125
            $category_id = $cms_config_vars['md_cat_id'][$block_id];
123
            $category_id = $cms_config_vars['md_cat_id'][$block_id];
...
 
...
 
244
                                    'U_PIC_SP' => $pic_sp_link,
242
                                    'U_PIC_SP' => $pic_sp_link,
245
                                    'U_PIC_DL' => $pic_dl_link,
243
                                    'U_PIC_DL' => $pic_dl_link,
246
 
244
 
 
 
245
                                    'IS_FIRST_PIC' => ($image_counter == 0) ? true : false,
 
 
246
 
247
                                    'THUMBNAIL' => $thumbnail_file,
247
                                    'THUMBNAIL' => $thumbnail_file,
248
                                    'DESC' => $recentrow[$image_counter]['pic_desc'],
248
                                    'DESC' => $recentrow[$image_counter]['pic_desc'],
249
                                    'TITLE' => $recentrow[$image_counter]['pic_title'],
249
                                    'TITLE' => $recentrow[$image_counter]['pic_title'],
...
 
...
 
251
                                    'TIME' => create_date_ip($config['default_dateformat'],
$recentrow[$image_counter]['pic_time'], $config['board_timezone']),
251
                                    'TIME' => create_date_ip($config['default_dateformat'],
$recentrow[$image_counter]['pic_time'], $config['board_timezone']),
252
                                    'VIEW' => $recentrow[$image_counter]['pic_view_count'],
252
                                    'VIEW' => $recentrow[$image_counter]['pic_view_count'],
253
                                    'RATING' => ($album_config['rate'] == 1) ? ($lang['Rating'] . ': ' .
$recentrow[$image_counter]['rating'] . '<br />') : '',
253
                                    'RATING' => ($album_config['rate'] == 1) ? ($lang['Rating'] . ': ' .
$recentrow[$image_counter]['rating'] . '<br />') : '',
254
                                    'COMMENTS' => ($album_config['comment'] == 1) ? ($lang['Comments'] . ': ' . $recentrow[$image_counter]['comments'] . '<br />') : '')
254
                                    'COMMENTS' => ($album_config['comment'] == 1) ? ($lang['Comments'] . ': ' .
$recentrow[$image_counter]['comments'] . '<br />') : ''
 
 
255
                                    )
255
                                );
256
                                );
 
 
257
 
 
 
258
                                if ($image_counter == 0)
 
 
259
                                {
 
 
260
                                    $template->assign_vars(array(
 
 
261
                                        'HS_GALLERY_ID' => 'hs_gallery_id_' . $recentrow[$image_counter]['pic_id'],
 
 
262
                                        'HS_PIC_ID' => 'hs_pic_id_' . $recentrow[$image_counter]['pic_id'],
 
 
263
                                        'HS_PIC_TITLE' => $recentrow[$image_counter]['pic_title'],
 
 
264
                                        'HS_PIC_FULL' => $pic_dl_link,
 
 
265
                                        'HS_PIC_THUMB' => $thumbnail_file,
 
 
266
                                        )
 
 
267
                                    );
 
 
268
                                }
256
                            }
269
                            }
257
 
270
 
258
                            $image_counter++;
271
                            $image_counter++;
...
 
...
 
264
            {
277
            {
265
                // No Pics Found
278
                // No Pics Found
266
                $template->assign_block_vars('no_pics', array());
279
                $template->assign_block_vars('no_pics', array());
 
 
280
                $no_pics = true;
267
            }
281
            }
268
        }
282
        }
269
        else
283
        else
...
 
...
 
270
        {
284
        {
271
            // No Cats Found
285
            // No Cats Found
272
            $template->assign_block_vars('no_pics', array());
286
            $template->assign_block_vars('no_pics', array());
 
 
287
            $no_pics = true;
273
        }
288
        }
274
 
289
 
275
        $template->assign_vars(array(
290
        $template->assign_vars(array(
...
 
...
 
276
            //'S_COL_WIDTH' => (100 / $cms_config_vars['md_pics_number'][$block_id]) . '%',
291
            //'S_COL_WIDTH' => (100 / $cms_config_vars['md_pics_number'][$block_id]) . '%',
277
            'S_COL_WIDTH' => (100 / (($cms_config_vars['md_pics_cols_number'][$block_id] == 0) ? 4 :
$cms_config_vars['md_pics_cols_number'][$block_id])) . '%',
292
            'S_COL_WIDTH' => (100 / (($cms_config_vars['md_pics_cols_number'][$block_id] == 0) ? 4 :
$cms_config_vars['md_pics_cols_number'][$block_id])) . '%',
278
            'TARGET_BLANK' => ($album_config['fullpic_popup']) ? 'target="_blank"' : '',
293
            'TARGET_BLANK' => ($album_config['fullpic_popup']) ? 'target="_blank"' : '',
 
 
294
 
 
 
295
            'S_HIGHSLIDER' => (!empty($cms_config_vars['md_pics_slider'][$block_id]) ? true : false),
 
 
296
            'S_NIVO_SLIDER' => (!empty($cms_config_vars['md_pics_slider'][$block_id]) ? true : false),
 
 
297
            'S_SLIDER_ID' => 'cms_slider_' . $block_id,
 
 
298
            'S_NO_PICS' => (!empty($no_pics) ? true : false),
 
 
299
 
279
            'L_NO_PICS' => $lang['No_Pics'],
300
            'L_NO_PICS' => $lang['No_Pics'],
280
            'L_PIC_TITLE' => $lang['Pic_Title'],
301
            'L_PIC_TITLE' => $lang['Pic_Title'],
281
            'L_VIEW' => $lang['View'],
302
            'L_VIEW' => $lang['View'],
198199
34
        $total_donors = 0;
34
        $total_donors = 0;
35
        if (!empty($cms_config_vars['md_paypal_total_donors'][$block_id]))
35
        if (!empty($cms_config_vars['md_paypal_total_donors'][$block_id]))
36
        {
36
        {
37
            $sql = "SELECT COUNT(transaction_id) AS total FROM " . $table_prefix . 'mg_donations_data';
37
            $sql = "SELECT COUNT(transaction_id) AS total FROM " . $table_prefix . 'donations_data';
38
            $result = $db->sql_query($sql, 86400, 'donations_data_');
38
            $result = $db->sql_query($sql, 86400, 'donations_data_');
39
 
39
 
40
            if ($total = $db->sql_fetchrow($result))
40
            if ($total = $db->sql_fetchrow($result))
...
 
...
 
47
        $total_amount = '';
47
        $total_amount = '';
48
        if (!empty($cms_config_vars['md_paypal_total_amount'][$block_id]))
48
        if (!empty($cms_config_vars['md_paypal_total_amount'][$block_id]))
49
        {
49
        {
50
            $sql = "SELECT mc_currency, SUM(payment_gross) AS total_amount FROM " . $table_prefix . 'mg_donations_data' . " GROUP BY mc_currency";
50
            $sql = "SELECT mc_currency, SUM(payment_gross) AS total_amount FROM " . $table_prefix . 'donations_data' . " GROUP BY
mc_currency";
51
            $result = $db->sql_query($sql, 86400, 'donations_data_');
51
            $result = $db->sql_query($sql, 86400, 'donations_data_');
52
            $total_amounts = array();
52
            $total_amounts = array();
53
            $total_amounts = $db->sql_fetchrowset($result);
53
            $total_amounts = $db->sql_fetchrowset($result);
198199
187
        $viewtopic_server_url = $server_url . CMS_PAGE_VIEWTOPIC;
187
        $viewtopic_server_url = $server_url . CMS_PAGE_VIEWTOPIC;
188
        while ($i < $total_recipients)
188
        while ($i < $total_recipients)
189
        {
189
        {
190
            $emailer = new emailer($config['smtp_delivery']);
190
            $emailer = new emailer();
191
 
191
 
192
            $email_headers = 'X-AntiAbuse: Board servername - ' . trim($config['server_name']) . "\n";
192
            $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
193
            $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
193
            $emailer->headers('X-AntiAbuse: User_id - ' . $userdata['user_id']);
194
            $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
194
            $emailer->headers('X-AntiAbuse: Username - ' . $userdata['username']);
195
            $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
195
            $emailer->headers('X-AntiAbuse: User IP - ' . decode_ip($user_ip));
196
 
196
 
197
            $emailer->use_template('repport_post', (file_exists(IP_ROOT_PATH . 'language/lang_' .
$report_recipients[$i]['user_lang'] . '/email/html/repport_post.tpl')) ? $report_recipients[$i]['user_lang'] :
'english');
197
            $emailer->use_template('repport_post', (file_exists(IP_ROOT_PATH . 'language/lang_' .
$report_recipients[$i]['user_lang'] . '/email/html/repport_post.tpl')) ? $report_recipients[$i]['user_lang'] :
'english');
198
            $emailer->email_address($report_recipients[$i]['user_email']);
198
            $emailer->to($report_recipients[$i]['user_email']);
199
            $emailer->from($config['board_email']);
 
 
200
            $emailer->replyto($config['board_email']);
 
 
201
            $emailer->extra_headers($email_headers);
 
 
202
            //$emailer->set_subject($subject);
199
            //$emailer->set_subject($subject);
203
 
200
 
204
            $emailer->assign_vars(array(
201
            $emailer->assign_vars(array(
...
 
...
 
378
        $from_email = ($userdata['user_email'] && $userdata['user_viewemail']) ? $userdata['user_email'] :
$config['board_email'];
375
        $from_email = ($userdata['user_email'] && $userdata['user_viewemail']) ? $userdata['user_email'] :
$config['board_email'];
379
 
376
 
380
        include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
377
        include_once(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
381
        $emailer = new emailer($config['smtp_delivery']);
378
        $emailer = new emailer();
382
 
379
 
383
        $email_headers = 'X-AntiAbuse: Board servername - ' . trim($config['server_name']) . "\n";
380
        $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
384
        $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
381
        $emailer->headers('X-AntiAbuse: User_id - ' . $userdata['user_id']);
385
        $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
382
        $emailer->headers('X-AntiAbuse: Username - ' . $userdata['username']);
386
        $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
383
        $emailer->headers('X-AntiAbuse: User IP - ' . decode_ip($user_ip));
387
 
384
 
388
        $emailer->use_template($e_temp, $warning_data['user_lang']);
385
        $emailer->use_template($e_temp, $warning_data['user_lang']);
389
        $emailer->email_address($warning_data['user_email']);
386
        $emailer->to($warning_data['user_email']);
390
        $emailer->from($from_email);
387
        $emailer->from($from_email);
391
        $emailer->replyto($from_email);
388
        $emailer->replyto($from_email);
392
        $emailer->extra_headers($email_headers);
 
 
393
        //$emailer->set_subject($e_subj);
389
        //$emailer->set_subject($e_subj);
394
 
390
 
395
        $emailer->assign_vars(array(
391
        $emailer->assign_vars(array(
...
 
...
 
400
            'EMAIL_SIG' => str_replace("<br />", "\n", $config['sig_line'] . " \n" .
$config['board_email_sig']),
396
            'EMAIL_SIG' => str_replace("<br />", "\n", $config['sig_line'] . " \n" .
$config['board_email_sig']),
401
            'WARNER' => $userdata['username'],
397
            'WARNER' => $userdata['username'],
402
            'BLOCK_TIME' => $block_time,
398
            'BLOCK_TIME' => $block_time,
403
            'WARNED_POSTER' => $warning_data['username'])
399
            'WARNED_POSTER' => $warning_data['username']
 
 
400
            )
404
        );
401
        );
405
        $emailer->send();
402
        $emailer->send();
406
        $emailer->reset();
403
        $emailer->reset();
198199
162
 
162
 
163
    // TICKETS - BEGIN
163
    // TICKETS - BEGIN
164
    $bcc_list = '';
164
    $bcc_list = '';
 
 
165
    $bcc_emails = array();
165
    if (!$account_delete)
166
    if (!$account_delete)
166
    {
167
    {
167
        $ticket_cat_id = request_var('ticket_cat_id', '');
168
        $ticket_cat_id = request_var('ticket_cat_id', '');
...
 
...
 
189
        update_flood_time_email();
190
        update_flood_time_email();
190
 
191
 
191
        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
192
        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
192
        $emailer = new emailer($config['smtp_delivery']);
193
        $emailer = new emailer();
193
 
194
 
194
        $email_headers = 'X-AntiAbuse: Board servername - ' . trim($config['server_name']) . "\n";
195
        $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
195
        $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
196
        $emailer->headers('X-AntiAbuse: User_id - ' . $userdata['user_id']);
196
        $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
197
        $emailer->headers('X-AntiAbuse: Username - ' . $userdata['username']);
197
        $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
198
        $emailer->headers('X-AntiAbuse: User IP - ' . decode_ip($user_ip));
198
 
199
 
 
 
200
        $email_subject = htmlspecialchars_decode($subject, ENT_COMPAT);
 
 
201
        //$email_subject = utf8_decode($email_subject);
 
 
202
 
 
 
203
        $email_message = $message;
 
 
204
        /*
 
 
205
        $email_message = htmlspecialchars_decode($email_message, ENT_COMPAT);
 
 
206
        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
 
 
207
        if (!empty($config['html_email']))
 
 
208
        {
 
 
209
            $email_message = strtr($email_message, $trans_tbl);
 
 
210
        }
 
 
211
        */
 
 
212
 
199
        $emailer->use_template('empty_email', $user_lang);
213
        $emailer->use_template('empty_email', $user_lang);
200
        $emailer->email_address($config['board_email']);
214
        $emailer->to($config['board_email']);
201
        $emailer->from($sender);
215
        $emailer->from($sender);
202
        $emailer->bcc($bcc_list);
216
        foreach ($bcc_emails as $bcc_address)
 
 
217
        {
 
 
218
            if (!empty($bcc_address))
 
 
219
            {
 
 
220
                $emailer->bcc($bcc_address);
 
 
221
            }
 
 
222
        }
 
 
223
        // Send also to sender in BCC if needed...
 
 
224
        if (!empty($_POST['cc_email']))
 
 
225
        {
 
 
226
            $emailer->bcc($sender);
 
 
227
        }
203
        $emailer->replyto($sender);
228
        $emailer->replyto($sender);
204
        $emailer->extra_headers($email_headers);
 
 
205
        $emailer->set_subject($subject);
 
 
206
 
229
 
 
 
230
        $emailer->set_subject($email_subject);
 
 
231
 
207
        $emailer->assign_vars(array(
232
        $emailer->assign_vars(array(
208
            'MESSAGE' => $message
233
            'MESSAGE' => $email_message
209
            )
234
            )
210
        );
235
        );
211
        $emailer->send();
236
        $emailer->send();
212
        $emailer->reset();
237
        $emailer->reset();
213
 
238
 
214
        if (!empty($_POST['cc_email']))
 
 
215
        {
 
 
216
            $emailer->from($sender);
 
 
217
            $emailer->replyto($sender);
 
 
218
            $emailer->use_template('empty_email');
 
 
219
            $emailer->email_address($sender);
 
 
220
            $emailer->set_subject($subject);
 
 
221
 
 
 
222
            $emailer->assign_vars(array(
 
 
223
                'MESSAGE' => $message
 
 
224
                )
 
 
225
            );
 
 
226
            $emailer->send();
 
 
227
            $emailer->reset();
 
 
228
        }
 
 
229
 
 
 
230
        $redirect_url = append_sid(CMS_PAGE_HOME);
239
        $redirect_url = append_sid(CMS_PAGE_HOME);
231
        meta_refresh(3, $redirect_url);
240
        meta_refresh(3, $redirect_url);
232
 
241
 
198199
1
Name = "Auto group"
1
Name = "Auto group"
2
Description = "This mod will make it posible to add member to a user group, depending on there post count  "
2
Description = "This mod will make it posible to add member to a user group, depending on there post count  "
3
Author = "Niels (Niels Chr. Rř)"
3
Author = "Niels (Niels Chr. Rø)"
4
 
4
 
5
Version = "1.2.2"
5
Version = "1.2.2"
6
Download_URL = "http://mods.db9.dk/viewtopic.php?t=115"
6
Download_URL = "http://mods.db9.dk/viewtopic.php?t=115"
198199
1
Name = "Birthday"
1
Name = "Birthday"
2
Description = "This mod will add a birthday field into your user's profile and make users age viewable to others when viewing posts."
2
Description = "This mod will add a birthday field into your user's profile and make users age viewable to others when viewing posts."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.5.7"
5
Version = "1.5.7"
6
Download_URL = "http://www.phpbbhacks.com/download/187"
6
Download_URL = "http://www.phpbbhacks.com/download/187"
198199
1
Name = "Fully integrated shoutbox "
1
Name = "Fully integrated shoutbox "
2
Description = "A fully phpBB2 enabled shoutbox witch support: database abstration layer, timezones, languages templates, smilies, BBcode and censored
words"
2
Description = "A fully phpBB2 enabled shoutbox witch support: database abstration layer, timezones, languages templates, smilies, BBcode and censored
words"
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.1.7"
5
Version = "1.1.7"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Gender"
1
Name = "Gender"
2
Description = "This mod will add a Gender field into users' profile, and display a Gender image"
2
Description = "This mod will add a Gender field into users' profile, and display a Gender image"
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.2.6"
5
Version = "1.2.6"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Global announcement"
1
Name = "Global announcement"
2
Description = "This mod, makes it posible to post global announcements viewable in all forums."
2
Description = "This mod, makes it posible to post global announcements viewable in all forums."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
Version = "1.2.8"
4
Version = "1.2.8"
5
Download_URL = "http://mods.db9.dk"
5
Download_URL = "http://mods.db9.dk"
6
Author_EMAIL = "ncr@db9.dk"
6
Author_EMAIL = "ncr@db9.dk"
198199
1
Name = "HighSlide JS"
1
Name = "HighSlide JS"
2
Description = "Highslide JS is an open source JavaScript software, offering a Web 2.0 approach to popup windows. It streamlines the use of thumbnail images
and HTML popups on web pages."
2
Description = "Highslide JS is an open source JavaScript software, offering a Web 2.0 approach to popup windows. It streamlines the use of thumbnail images
and HTML popups on web pages."
3
Author = "Torstein Hřnsi"
3
Author = "Torstein Hønsi"
4
Version = "4.0.12"
4
Version = "4.0.12"
5
Download_URL = "http://highslide.com/"
5
Download_URL = "http://highslide.com/"
6
Author_EMAIL = "http://highslide.com/contact.php?filter=true"
6
Author_EMAIL = "http://highslide.com/contact.php?filter=true"
198199
1
Name = "Last visit"
1
Name = "Last visit"
2
Description = "This mod will register when the user last logged in, allong with the info about how many users have visited the board."
2
Description = "This mod will register when the user last logged in, allong with the info about how many users have visited the board."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.2.8"
5
Version = "1.2.8"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Prune users"
1
Name = "Prune users"
2
Description = "Admin plug-in that makes it posible to delete users who are inactive/haven't posted or like."
2
Description = "Admin plug-in that makes it posible to delete users who are inactive/haven't posted or like."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.4.3"
5
Version = "1.4.3"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Site History Mod"
1
Name = "Site History Mod"
2
Description = "Stores the number of your sites vistitors into the db, so this info can be viewed in a statisics page"
2
Description = "Stores the number of your sites vistitors into the db, so this info can be viewed in a statisics page"
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.1.3"
5
Version = "1.1.3"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Sticky/Announce Moderator Buttons"
1
Name = "Sticky/Announce Moderator Buttons"
2
Description = "This mod will add sticky and announce buttons at the bottom of a topic, next to the lock, move, and split buttons."
2
Description = "This mod will add sticky and announce buttons at the bottom of a topic, next to the lock, move, and split buttons."
3
Author = "ShockWire (Ian J. Gienger)"
3
Author = "ShockWire (Ian J. Gienger)"
4
 
4
 
5
Version = "0.9.9"
5
Version = "0.9.9"
198199
1
Name = "Who viewed a topic"
1
Name = "Who viewed a topic"
2
Description = "This MOD will add the ability to logged users to see who has already viewed the topic they're watching. A small image is added to the
viewtopic page for this."
2
Description = "This MOD will add the ability to logged users to see who has already viewed the topic they're watching. A small image is added to the
viewtopic page for this."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.0.3"
5
Version = "1.0.3"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
1
Name = "Yellow card"
1
Name = "Yellow card"
2
Description = "Also known as "card system" This mod will make 4 colored buttons beside users post (red,yellow,green and blue) ADMIN can in ACP
configure inside witch forum the buttons are visible Red = ban, Yelow = warn, Green = unban, Blue = report to moderators."
2
Description = "Also known as "card system" This mod will make 4 colored buttons beside users post (red,yellow,green and blue) ADMIN can in ACP
configure inside witch forum the buttons are visible Red = ban, Yelow = warn, Green = unban, Blue = report to moderators."
3
Author = "Niels (Niels Chr. Rřd)"
3
Author = "Niels (Niels Chr. Rød)"
4
 
4
 
5
Version = "1.4.12"
5
Version = "1.4.12"
6
Download_URL = "http://mods.db9.dk"
6
Download_URL = "http://mods.db9.dk"
198199
170
                            <li><b>cache/sql/</b></li>
170
                            <li><b>cache/sql/</b></li>
171
                            <li><b>cache/topics/</b></li>
171
                            <li><b>cache/topics/</b></li>
172
                            <li><b>cache/users/</b></li>
172
                            <li><b>cache/users/</b></li>
173
                            <li><b>ctracker/logfiles/logfile_attempt_counter.txt</b></li>
 
 
174
                            <li><b>ctracker/logfiles/logfile_blocklist.txt</b></li>
 
 
175
                            <li><b>ctracker/logfiles/logfile_debug_mode.txt</b></li>
 
 
176
                            <li><b>ctracker/logfiles/logfile_malformed_logins.txt</b></li>
 
 
177
                            <li><b>ctracker/logfiles/logfile_spammer.txt</b></li>
 
 
178
                            <li><b>ctracker/logfiles/logfile_worms.txt</b></li>
 
 
179
                            <li><b>downloads/</b></li>
173
                            <li><b>downloads/</b></li>
180
                            <li><b>files/</b></li>
174
                            <li><b>files/</b></li>
181
                            <li><b>files/album/</b></li>
175
                            <li><b>files/album/</b></li>
...
 
...
 
187
                            <li><b>files/thumbs/</b></li>
181
                            <li><b>files/thumbs/</b></li>
188
                            <li><b>images/avatars/</b></li>
182
                            <li><b>images/avatars/</b></li>
189
                            <li><b>logs/</b></li>
183
                            <li><b>logs/</b></li>
 
 
184
                            <li><b>logs/logfile_attempt_counter.txt</b></li>
 
 
185
                            <li><b>logs/logfile_blocklist.txt</b></li>
 
 
186
                            <li><b>logs/logfile_debug_mode.txt</b></li>
 
 
187
                            <li><b>logs/logfile_malformed_logins.txt</b></li>
 
 
188
                            <li><b>logs/logfile_spammer.txt</b></li>
 
 
189
                            <li><b>logs/logfile_worms.txt</b></li>
190
                            <li><b>pafiledb/uploads/</b></li>
190
                            <li><b>pafiledb/uploads/</b></li>
191
                            </ul>
191
                            </ul>
192
                            <br />
192
                            <br />
...
 
...
 
203
                        <li>Launch the setup from the install folder: <b>install/install.php</b> (i.e. <a class="post-url"
href="http://www.mysite.com/icyphoenix/install/install.php">http://www.mysite.com/forum/install/install.php</a>)</li>
203
                        <li>Launch the setup from the install folder: <b>install/install.php</b> (i.e. <a class="post-url"
href="http://www.mysite.com/icyphoenix/install/install.php">http://www.mysite.com/forum/install/install.php</a>)</li>
204
                        <li>Follow all the instructions on the screen, fill all requested data and complete the setup.</li>
204
                        <li>Follow all the instructions on the screen, fill all requested data and complete the setup.</li>
205
                        <li>Delete or rename <b>install</b> folder.</li>
205
                        <li>Delete or rename <b>install</b> folder.</li>
206
                        <li>Customize what needs to be customized in files and db (some files needs to be edited manually, while most of the options may be set in ACP and CMS).</li>
206
                        <li>Customize files that may needs to be tweaked a bit for your site:
 
 
207
                            <ul>
 
 
208
                            <li><b>.htaccess</b>: settings about your domain and basic apache settings.</li>
 
 
209
                            <li><b>robots.txt</b>: change the path of your sitemap and customize basics bots rules.</li>
 
 
210
                            <li><b>favicon.ico</b> and <b>images/favicon.ico</b>: customize your site icon.</li>
 
 
211
                            <li><b>includes/constants.php</b>: customize some constants values and set your main admins id.</li>
 
 
212
                            <li><b>language/lang_XXX/lang_main_settings.php</b>: some important data about you, your site and basic settings.</li>
 
 
213
                            <li><b>templates/default/overall_header*.tpl</b>: you can customize here some parts of the appearance of your template (some of these settings may be changed in ACP and CMS, so you don't need to edit these files).</li>
 
 
214
                            </ul>
 
 
215
                        </li>
 
 
216
                        <li>Customize options in ACP and CMS.</li>
207
                        <li>Enjoy your New Site <img src="../images/smiles/icon_mrgreen.gif" alt="Enjoy!" title="Enjoy!"
/>.</li>
217
                        <li>Enjoy your New Site <img src="../images/smiles/icon_mrgreen.gif" alt="Enjoy!" title="Enjoy!"
/>.</li>
208
                    </ol>
218
                    </ol>
209
                    <br />
219
                    <br />
198199
189
    if (!$is_autogroup_enable)
189
    if (!$is_autogroup_enable)
190
    {
190
    {
191
        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
191
        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
192
        $emailer = new emailer($config['smtp_delivery']);
192
        $emailer = new emailer();
193
 
 
 
194
        $emailer->from($config['board_email']);
 
 
195
        $emailer->replyto($config['board_email']);
 
 
196
 
 
 
197
        $emailer->use_template('group_request', $moderator['user_lang']);
193
        $emailer->use_template('group_request', $moderator['user_lang']);
198
        $emailer->email_address($moderator['user_email']);
194
        $emailer->to($moderator['user_email']);
199
        $emailer->set_subject($lang['Group_request']);
195
        $emailer->set_subject($lang['Group_request']);
200
 
196
 
201
        $emailer->assign_vars(array(
197
        $emailer->assign_vars(array(
...
 
...
 
437
                    $group_name = $group_name_row['group_name'];
433
                    $group_name = $group_name_row['group_name'];
438
 
434
 
439
                    include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
435
                    include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
440
                    $emailer = new emailer($config['smtp_delivery']);
436
                    $emailer = new emailer();
441
 
 
 
442
                    $emailer->from($config['board_email']);
 
 
443
                    $emailer->replyto($config['board_email']);
 
 
444
 
 
 
445
                    $emailer->use_template('group_added', $row['user_lang']);
437
                    $emailer->use_template('group_added', $row['user_lang']);
446
                    $emailer->email_address($row['user_email']);
438
                    $emailer->to($row['user_email']);
447
                    $emailer->set_subject($lang['Group_added']);
439
                    $emailer->set_subject($lang['Group_added']);
448
 
440
 
449
                    $emailer->assign_vars(array(
441
                    $emailer->assign_vars(array(
...
 
...
 
618
                        $group_name = $group_name_row['group_name'];
610
                        $group_name = $group_name_row['group_name'];
619
 
611
 
620
                        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
612
                        include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
621
                        $emailer = new emailer($config['smtp_delivery']);
613
                        $emailer = new emailer();
622
 
614
                        foreach ($bcc_list as $bcc_address)
623
                        $emailer->from($config['board_email']);
 
 
624
                        $emailer->replyto($config['board_email']);
 
 
625
 
 
 
626
                        for ($i = 0; $i < sizeof($bcc_list); $i++)
 
 
627
                        {
615
                        {
628
                            $emailer->bcc($bcc_list[$i]);
616
                            if (!empty($bcc_address))
 
 
617
                            {
 
 
618
                                $emailer->bcc($bcc_address);
 
 
619
                            }
629
                        }
620
                        }
630
 
 
 
631
                        $emailer->use_template('group_approved');
621
                        $emailer->use_template('group_approved');
632
                        $emailer->set_subject($lang['Group_approved']);
622
                        $emailer->set_subject($lang['Group_approved']);
633
 
623
 
...
 
...
 
636
                            'GROUP_NAME' => $group_name,
626
                            'GROUP_NAME' => $group_name,
637
                            'EMAIL_SIG' => (!empty($config['board_email_sig'])) ? str_replace('<br />', "\n",
$config['sig_line'] . " \n" . $config['board_email_sig']) : '',
627
                            'EMAIL_SIG' => (!empty($config['board_email_sig'])) ? str_replace('<br />', "\n",
$config['sig_line'] . " \n" . $config['board_email_sig']) : '',
638
 
628
 
639
                            'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . '=' . $group_id)
629
                            'U_GROUPCP' => $server_url . '?' . POST_GROUPS_URL . '=' . $group_id
 
 
630
                            )
640
                        );
631
                        );
641
                        $emailer->send();
632
                        $emailer->send();
642
                        $emailer->reset();
633
                        $emailer->reset();
198199
33
}
33
}
34
 
34
 
35
// Include Language
35
// Include Language
36
$language = $config['default_lang'];
36
setup_extra_lang(array('lang_album_main'));
37
 
37
 
38
if (!file_exists(IP_ROOT_PATH . 'language/lang_' . $language . '/lang_album_main.' . PHP_EXT))
 
 
39
{
 
 
40
    $language = 'english';
 
 
41
}
 
 
42
 
 
 
43
include(IP_ROOT_PATH . 'language/lang_' . $language . '/lang_album_main.' . PHP_EXT);
 
 
44
 
 
 
45
// Get Album Config
38
// Get Album Config
46
$album_config = array();
39
$album_config = array();
47
$sql = "SELECT * FROM " . ALBUM_CONFIG_TABLE;
40
$sql = "SELECT * FROM " . ALBUM_CONFIG_TABLE;
198199
798
        if (sizeof($bcc_list_ary))
798
        if (sizeof($bcc_list_ary))
799
        {
799
        {
800
            include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
800
            include(IP_ROOT_PATH . 'includes/emailer.' . PHP_EXT);
801
            $emailer = new emailer($config['smtp_delivery']);
801
            $emailer = new emailer();
802
 
802
 
803
            $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['script_path']));
803
            $script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($config['script_path']));
804
            $script_name = ($script_name != '') ? $script_name . '/album_showpage.' . PHP_EXT : 'album_showpage.' . PHP_EXT;
804
            $script_name = ($script_name != '') ? $script_name . '/album_showpage.' . PHP_EXT : 'album_showpage.' . PHP_EXT;
...
 
...
 
806
            $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
806
            $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
807
            $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' :
'/';
807
            $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' :
'/';
808
 
808
 
809
            $emailer->from($config['board_email']);
 
 
810
            $emailer->replyto($config['board_email']);
 
 
811
 
 
 
812
            @reset($bcc_list_ary);
809
            @reset($bcc_list_ary);
813
            while (list($user_lang, $bcc_list) = each($bcc_list_ary))
810
            while (list($user_lang, $bcc_list) = each($bcc_list_ary))
814
            {
811
            {
198199
229
// $cat_id     : is the currently selected category
229
// $cat_id     : is the currently selected category
230
// $allowed_cat: is a list of all the allowed categories that the current user
230
// $allowed_cat: is a list of all the allowed categories that the current user
231
//               is allowed to view
231
//               is allowed to view
232
// Łcat_ids    : is synomous with $allowed_cat OR $cat_id, depending on the view mode
232
// £cat_ids    : is synomous with $allowed_cat OR $cat_id, depending on the view mode
233
//
233
//
234
// 0: Begin of 'work flow'
234
// 0: Begin of 'work flow'
235
//
235
//
198199
1075
                    $this->attach_filename = delete_extension($this->attach_filename);
1075
                    $this->attach_filename = delete_extension($this->attach_filename);
1076
                    $this->attach_filename = str_replace(array(' ','-'), array('_','_'), $this->attach_filename);
1076
                    $this->attach_filename = str_replace(array(' ','-'), array('_','_'), $this->attach_filename);
1077
                    $this->attach_filename = str_replace('__', '_', $this->attach_filename);
1077
                    $this->attach_filename = str_replace('__', '_', $this->attach_filename);
1078
                    $this->attach_filename = str_replace(array(',', '.', '!', '?', 'ü', 'Ü',
'ö', 'Ö', 'ä', 'Ä', ';', ':', '@', "'", '"',
'&'), array('', '', '', '', 'ue', 'ue', 'oe', 'oe',
'ae', 'ae', '', '', '', '', '', 'and'), $this->attach_filename);
1078
                    $this->attach_filename = str_replace(array(',', '.', '!', '?', 'ü', 'Ü',
'ö', 'Ö', 'ä', 'Ä', ';', ':', '@', "'", '"',
'&'), array('', '', '', '', 'ue', 'ue', 'oe', 'oe',
'ae', 'ae', '', '', '', '', '', 'and'), $this->attach_filename);
1079
                    $this->attach_filename = str_replace(array('$', 'ß',
'>','<','§','%','=','/','(',')','#','*','+',
"\\",'{','}','[',']'), array('dollar',
'ss','greater','lower','paragraph','percent','equal','','','','&#
x27;,'','','','','','',''), $this->attach_filename);
1079
                    $this->attach_filename = str_replace(array('$', 'ß',
'>','<','§','%','=','/','(',')','#','*','+',
"\\",'{','}','[',']'), array('dollar',
'ss','greater','lower','paragraph','percent','equal','','','','&#
x27;,'','','','','','',''), $this->attach_filename);
1080
                    // Remove non-latin characters
1080
                    // Remove non-latin characters
1081
                    $this->attach_filename = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e",
"chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $this->attach_filename);
1081
                    $this->attach_filename = preg_replace("/([\xC2\xC3])([\x80-\xBF])/e",
"chr(ord('\\1')<<6&0xC0|ord('\\2')&0x3F)", $this->attach_filename);
1082
                    $this->attach_filename = rawurlencode($this->attach_filename);
1082
                    $this->attach_filename = rawurlencode($this->attach_filename);
198199
700
                continue;
700
                continue;
701
            }
701
            }
702
 
702
 
703
            $translate = 
array('Ç'=>pack("C",128),'ü'=>pack("C",129),'é'=>pack("C",130),'â'=>pack("
;C",131),'ä'=>pack("C",132),
703
            $translate = 
array('Ç'=>pack("C",128),'ü'=>pack("C",129),'é'=>pack("C",130),'â'=>pack("
;C",131),'ä'=>pack("C",132),
704
                                'ą'=>pack("C",133),'å'=>pack("C",134),'ē'=>pack("C",135),'ź'=>pack("C",136),'ė'=>pack("C",137),
704
                                'à'=>pack("C",133),'å'=>pack("C",134),'ç'=>pack("C",135),'ê'=>pack("C",136),'ë'=>pack("C",137),
705
                                'č'=>pack("C",138),'ļ'=>pack("C",139),'ī'=>pack("C",140),'ģ'=>pack("C",141),'Ä'=>pack("C",142),
705
                                'è'=>pack("C",138),'ï'=>pack("C",139),'î'=>pack("C",140),'ì'=>pack("C",141),'Ä'=>pack("C",142),
706
                                'Ĺ'=>pack("C",143),'É'=>pack("C",144),'ć'=>pack("C",145),'Ć'=>pack("C",146),'ô'=>pack("C",147),
706
                                'Å'=>pack("C",143),'É'=>pack("C",144),'æ'=>pack("C",145),'Æ'=>pack("C",146),'ô'=>pack("C",147),
707
                                'ö'=>pack("C",148),'ň'=>pack("C",149),'ű'=>pack("C",150),'ů'=>pack("C",151),'Ö'=>pack("C",153),
707
                                'ö'=>pack("C",148),'ò'=>pack("C",149),'û'=>pack("C",150),'ù'=>pack("C",151),'Ö'=>pack("C",153),
708
                                'Ü'=>pack("C",154),'Ł'=>pack("C",156),'Ľ'=>pack("C",157),'ƒ'=>pack("C",159),'á'=>pack("C",160),
708
                                'Ü'=>pack("C",154),'£'=>pack("C",156),'¥'=>pack("C",157),'ƒ'=>pack("C",159),'á'=>pack("C",160),
709
                                'í'=>pack("C",161),'ó'=>pack("C",162),'ú'=>pack("C",163),'ń'=>pack("C",164),'Ń'=>pack("C",165));
709
                                'í'=>pack("C",161),'ó'=>pack("C",162),'ú'=>pack("C",163),'ñ'=>pack("C",164),'Ñ'=>pack("C",165));
710
            $current['name2'] = strtr($current['name2'],$translate);
710
            $current['name2'] = strtr($current['name2'],$translate);
711
 
711
 
712
            $timedate = explode(" ", gmdate("Y n j G i s", $current['stat'][9]));
712
            $timedate = explode(" ", gmdate("Y n j G i s", $current['stat'][9]));
198199
96
            $config['smtp_host'] = @ini_get('SMTP');
96
            $config['smtp_host'] = @ini_get('SMTP');
97
        }
97
        }
98
 
98
 
99
        $emailer = new emailer($config['smtp_delivery']);
99
        $emailer = new emailer();
100
 
100
 
101
        $email_headers = 'X-AntiAbuse: Board servername - ' . trim($config['server_name']) . "\n";
101
        $emailer->headers('X-AntiAbuse: Board servername - ' . trim($config['server_name']));
102
        $email_headers .= 'X-AntiAbuse: User_id - ' . $userdata['user_id'] . "\n";
102
        $emailer->headers('X-AntiAbuse: User_id - ' . $userdata['user_id']);
103
        $email_headers .= 'X-AntiAbuse: Username - ' . $userdata['username'] . "\n";
103
        $emailer->headers('X-AntiAbuse: Username - ' . $userdata['username']);
104
        $email_headers .= 'X-AntiAbuse: User IP - ' . decode_ip($user_ip) . "\n";
104
        $emailer->headers('X-AntiAbuse: User IP - ' . decode_ip($user_ip));
105
 
105
 
106
        $emailer->extra_headers($email_headers);
 
 
107
        $emailer->from($config['board_email']);
 
 
108
        $emailer->replyto($config['board_email']);
 
 
109
 
 
 
110
        if ($use_bcc)
106
        if ($use_bcc)
111
        {
107
        {
112
            $emailer->email_address($config['board_email']);
108
            $emailer->to($config['board_email']);
113
            $emailer->bcc($recipient_email);
109
            $emailer->bcc($recipient_email);
114
        }
110
        }
115
        else
111
        else
116
        {
112
        {
117
            $emailer->email_address($recipient_email);
113
            $emailer->to($recipient_email);
118
        }
114
        }
119
 
115
 
120
        $emailer->set_subject($email_subject);
116
        $emailer->set_subject($email_subject);
198199
20
    die('Hacking attempt');
20
    die('Hacking attempt');
21
}
21
}
22
 
22
 
23
define('ICYPHOENIX_VERSION', '1.3.7.60');
23
define('ICYPHOENIX_VERSION', '1.3.9.62');
24
 
24
 
25
// FOUNDER ID, this is the ID used to send Welcome and Birthday PM
25
// FOUNDER ID, this is the ID used to send Welcome and Birthday PM
26
define('FOUNDER_ID', '2');
26
define('FOUNDER_ID', '2');
...
 
...
 
313
define('SESSION_METHOD_COOKIE', 100);
313
define('SESSION_METHOD_COOKIE', 100);
314
define('SESSION_METHOD_GET', 101);
314
define('SESSION_METHOD_GET', 101);
315
 
315
 
 
 
316
// Notify methods
 
 
317
define('NOTIFY_EMAIL', 0);
 
 
318
define('NOTIFY_IM', 1);
 
 
319
define('NOTIFY_BOTH', 2);
 
 
320
 
 
 
321
// Email Priority Settings
 
 
322
define('MAIL_LOW_PRIORITY', 4);
 
 
323
define('MAIL_NORMAL_PRIORITY', 3);
 
 
324
define('MAIL_HIGH_PRIORITY', 2);
 
 
325
 
316
// Various constants
326
// Various constants
317
define('POST_BIRTHDAY', 9);
327
define('POST_BIRTHDAY', 9);
318
define('POST_CALENDAR', 10);
328
define('POST_CALENDAR', 10);
198199
277
            $eur_count = 0;
277
            $eur_count = 0;
278
            $match1 = array();
278
            $match1 = array();
279
            $match2 = array();
279
            $match2 = array();
280
            $match1 = preg_split('/US|\\$|€/m', $_POST['message']);
280
            $match1 = preg_split('/US|\\$|/m', $_POST['message']);
281
            $match2 = preg_split('/US|\\$|€/m', $_POST['subject']);
281
            $match2 = preg_split('/US|\\$|€/m', $_POST['subject']);
282
            $eur_count = sizeof($match1) + sizeof($match2) - 2;
282
            $eur_count = sizeof($match1) + sizeof($match2) - 2;
283
 
283
 
284
            if ($url_count > 6 || $eur_count > 6)
284
            if ($url_count > 6 || $eur_count > 6)
198199
24
*
24
*
25
* We included some virtual Troopers for you. ;-)
25
* We included some virtual Troopers for you. ;-)
26
*
26
*
27
* @author Christian Knerr (cback) and Tekin Birdüzen (cYbercOsmOnauT)
27
* @author Christian Knerr (cback) and Tekin Birdüzen (cYbercOsmOnauT)
28
* @package ctracker
28
* @package ctracker
29
* @version 5.0.6
29
* @version 5.0.6
30
* @since 15.07.2006 - 21:36:24
30
* @since 15.07.2006 - 21:36:24
198199
15
*
15
*
16
*/
16
*/
17
 
17
 
18
//
18
/*
19
// The emailer class has support for attaching files, that isn't implemented
19
* Mighty Gorgon To Fix:
20
// in the 2.0 release but we can probable find some way of using it in a future
20
* - Removed SMTP from emailer class
21
// release
21
* - Changed addresses to to
22
//
22
* - Now addresses are array
 
 
23
* - Headers changed
 
 
24
* - Global search for $email_headers: remove all!
 
 
25
*/
 
 
26
 
 
 
27
/*
 
 
28
* Emailer class
 
 
29
*/
23
class emailer
30
class emailer
24
{
31
{
25
    var $msg, $subject, $extra_headers;
32
    var $vars;
26
    var $addresses, $reply_to, $from;
33
    var $from;
27
    var $use_smtp;
34
    var $replyto;
 
 
35
    var $subject;
 
 
36
    var $msg;
28
 
37
 
 
 
38
    var $addresses = array();
 
 
39
    var $extra_headers = array();
 
 
40
 
 
 
41
    var $mail_priority = MAIL_NORMAL_PRIORITY;
 
 
42
    var $use_queue = true;
 
 
43
    var $use_smtp = false;
 
 
44
 
 
 
45
    var $tpl_obj = NULL;
29
    var $tpl_msg = array();
46
    var $tpl_msg = array();
 
 
47
    var $eol = "\n";
30
 
48
 
31
    function emailer($use_smtp)
49
    /**
 
 
50
    * Initialize the class
 
 
51
    */
 
 
52
    function emailer($use_queue = true)
32
    {
53
    {
 
 
54
        $this->use_queue = (empty($config['email_package_size'])) ? false : $use_queue;
33
        $this->reset();
55
        $this->reset();
34
        $this->use_smtp = $use_smtp;
56
 
35
        $this->reply_to = $this->from = '';
57
        // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac)
 
 
58
        $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol == 'mac') ? "\r" : "\n") : PHP_EOL;
 
 
59
        $this->eol = (!$this->eol) ? "\n" : $this->eol;
36
    }
60
    }
37
 
61
 
38
    // Resets all the data (address, template file, etc etc to default
62
    /**
 
 
63
    * Resets all the data (address, template file, etc etc) to default
 
 
64
    */
39
    function reset()
65
    function reset()
40
    {
66
    {
 
 
67
        global $config;
 
 
68
        $this->use_smtp = $config['smtp_delivery'];
41
        $this->addresses = array();
69
        $this->addresses = array();
42
        $this->vars = $this->msg = $this->extra_headers = '';
70
        $this->extra_headers = array();
 
 
71
        $this->vars = '';
 
 
72
        $this->from = '';
 
 
73
        $this->replyto = '';
 
 
74
        $this->mail_priority = MAIL_NORMAL_PRIORITY;
 
 
75
        $this->msg = '';
43
    }
76
    }
44
 
77
 
45
    // Sets an email address to send to
78
    /**
 
 
79
    * Sets an email address to send to
 
 
80
    */
 
 
81
    function to($address, $realname = '')
 
 
82
    {
 
 
83
        $address = trim($address);
 
 
84
        $realname = trim($realname);
 
 
85
        if (empty($address))
 
 
86
        {
 
 
87
            return;
 
 
88
        }
 
 
89
 
 
 
90
        $pos = isset($this->addresses['to']) ? sizeof($this->addresses['to']) : 0;
 
 
91
 
 
 
92
        $this->addresses['to'][$pos]['email'] = $address;
 
 
93
 
 
 
94
        // If empty sendmail_path on windows, PHP changes the to line
 
 
95
        if (!$this->use_smtp && (DIRECTORY_SEPARATOR == '\\'))
 
 
96
        {
 
 
97
            $this->addresses['to'][$pos]['name'] = '';
 
 
98
        }
 
 
99
        else
 
 
100
        {
 
 
101
            $this->addresses['to'][$pos]['name'] = $realname;
 
 
102
        }
 
 
103
    }
 
 
104
 
 
 
105
    /**
 
 
106
    * Sets an email address to send to
 
 
107
    */
46
    function email_address($address)
108
    function email_address($address)
47
    {
109
    {
48
        $this->addresses['to'] = trim($address);
110
        $this->to($address);
49
    }
111
    }
50
 
112
 
51
    function cc($address)
113
    /**
 
 
114
    * Sets a cc address to send to
 
 
115
    */
 
 
116
    function cc($address, $realname = '')
52
    {
117
    {
53
        $this->addresses['cc'][] = trim($address);
118
        $address = trim($address);
 
 
119
        $realname = trim($realname);
 
 
120
        if (empty($address))
 
 
121
        {
 
 
122
            return;
 
 
123
        }
 
 
124
 
 
 
125
        $pos = isset($this->addresses['cc']) ? sizeof($this->addresses['cc']) : 0;
 
 
126
        $this->addresses['cc'][$pos]['email'] = $address;
 
 
127
        $this->addresses['cc'][$pos]['name'] = $realname;
54
    }
128
    }
55
 
129
 
56
    function bcc($address)
130
    /**
 
 
131
    * Sets a bcc address to send to
 
 
132
    */
 
 
133
    function bcc($address, $realname = '')
57
    {
134
    {
58
        $this->addresses['bcc'][] = trim($address);
135
        $address = trim($address);
 
 
136
        $realname = trim($realname);
 
 
137
        if (empty($address))
 
 
138
        {
 
 
139
            return;
 
 
140
        }
 
 
141
 
 
 
142
        $pos = isset($this->addresses['bcc']) ? sizeof($this->addresses['bcc']) : 0;
 
 
143
        $this->addresses['bcc'][$pos]['email'] = $address;
 
 
144
        $this->addresses['bcc'][$pos]['name'] = $realname;
59
    }
145
    }
60
 
146
 
 
 
147
    /**
 
 
148
    * Sets a im contact to send to
 
 
149
    */
 
 
150
    function im($address, $realname = '')
 
 
151
    {
 
 
152
        // IM-Addresses could be empty
 
 
153
        $address = trim($address);
 
 
154
        $realname = trim($realname);
 
 
155
        if (empty($address))
 
 
156
        {
 
 
157
            return;
 
 
158
        }
 
 
159
 
 
 
160
        $pos = isset($this->addresses['im']) ? sizeof($this->addresses['im']) : 0;
 
 
161
        $this->addresses['im'][$pos]['uid'] = $address;
 
 
162
        $this->addresses['im'][$pos]['name'] = $realname;
 
 
163
    }
 
 
164
 
 
 
165
    /**
 
 
166
    * Set the reply to address
 
 
167
    */
61
    function replyto($address)
168
    function replyto($address)
62
    {
169
    {
63
        $this->reply_to = trim($address);
170
        $this->replyto = trim($address);
64
    }
171
    }
65
 
172
 
 
 
173
    /**
 
 
174
    * Set the from address
 
 
175
    */
66
    function from($address)
176
    function from($address)
67
    {
177
    {
68
        $this->from = trim($address);
178
        $this->from = trim($address);
69
    }
179
    }
70
 
180
 
71
    // set up subject for mail
181
    /**
 
 
182
    * set up subject for mail
 
 
183
    */
72
    function set_subject($subject = '')
184
    function set_subject($subject = '')
73
    {
185
    {
74
        $this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
186
        $this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
75
    }
187
    }
76
 
188
 
77
    // set up extra mail headers
189
    /**
78
    function extra_headers($headers)
190
    * Set the email priority
 
 
191
    */
 
 
192
    function set_mail_priority($priority = MAIL_NORMAL_PRIORITY)
79
    {
193
    {
80
        $this->extra_headers .= trim($headers) . "\n";
194
        $this->mail_priority = $priority;
81
    }
195
    }
82
 
196
 
 
 
197
    /**
 
 
198
    * set up extra mail headers
 
 
199
    */
 
 
200
    function headers($headers)
 
 
201
    {
 
 
202
        $this->extra_headers[] = trim($headers);
 
 
203
    }
 
 
204
 
 
 
205
    /**
 
 
206
    * Return email header
 
 
207
    */
 
 
208
    function build_header($to = '', $cc = '', $bcc = '')
 
 
209
    {
 
 
210
        global $config, $lang;
 
 
211
 
 
 
212
        // Force to UTF-8
 
 
213
        //$encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
 
 
214
        $encoding_charset = 'UTF-8';
 
 
215
 
 
 
216
        // We could use keys here, but we won't do this for 3.0.x to retain backwards compatibility
 
 
217
        $headers = array();
 
 
218
 
 
 
219
        $this->from = !empty($this->from) ? $this->from : '<' . trim($config['board_email']) . '>';
 
 
220
        $this->replyto = !empty($this->replyto) ? $this->replyto : '<' . trim($config['board_email']) . '>';
 
 
221
        $this->mail_priority = !empty($this->mail_priority) ? $this->mail_priority : MAIL_LOW_PRIORITY;
 
 
222
 
 
 
223
        $headers[] = 'From: ' . $this->from;
 
 
224
 
 
 
225
        if (!empty($cc))
 
 
226
        {
 
 
227
            $headers[] = 'Cc: ' . $cc;
 
 
228
        }
 
 
229
 
 
 
230
        if (!empty($bcc))
 
 
231
        {
 
 
232
            $headers[] = 'Bcc: ' . $bcc;
 
 
233
        }
 
 
234
 
 
 
235
        $headers[] = 'Reply-To: ' . $this->replyto;
 
 
236
        $headers[] = 'Return-Path: <' . $config['board_email'] . '>';
 
 
237
        $headers[] = 'Sender: <' . $config['board_email'] . '>';
 
 
238
        $headers[] = 'MIME-Version: 1.0';
 
 
239
        $headers[] = 'Message-ID: <' . md5(unique_id(time())) . '@' . $config['server_name'] . '>';
 
 
240
        $headers[] = 'Date: ' . date('r', time());
 
 
241
        $headers[] = 'Content-Type: text/' . (!empty($config['html_email']) ? 'html' : 'plain') . '; charset='
. $encoding_charset; // format=flowed
 
 
242
        $headers[] = 'Content-Transfer-Encoding: 8bit'; // 7bit
 
 
243
 
 
 
244
        $headers[] = 'X-Priority: ' . $this->mail_priority;
 
 
245
        $headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority ==
MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High'));
 
 
246
        $headers[] = 'X-Mailer: Icy Phoenix';
 
 
247
        $headers[] = 'X-MimeOLE: Icy Phoenix';
 
 
248
        $headers[] = 'X-Icy-Phoenix-Origin: icyphoenix://' . str_replace(array('http://', 'https://'), array('',
''), create_server_url());
 
 
249
 
 
 
250
        if (sizeof($this->extra_headers))
 
 
251
        {
 
 
252
            $headers = array_merge($headers, $this->extra_headers);
 
 
253
        }
 
 
254
 
 
 
255
        return $headers;
 
 
256
    }
 
 
257
 
 
 
258
    /**
 
 
259
    * Assigns vars
 
 
260
    */
 
 
261
    function assign_vars($vars)
 
 
262
    {
 
 
263
        if (empty($vars) || !is_array($vars))
 
 
264
        {
 
 
265
            return;
 
 
266
        }
 
 
267
 
 
 
268
        $this->vars = (empty($this->vars)) ? $vars : array_merge($this->vars, $vars);
 
 
269
    }
 
 
270
 
 
 
271
    /**
 
 
272
    * Send the email
 
 
273
    */
 
 
274
    function send($method = NOTIFY_EMAIL, $break = false)
 
 
275
    {
 
 
276
        global $db, $config, $lang;
 
 
277
 
 
 
278
        /*
 
 
279
        if (empty($config['email_enable']))
 
 
280
        {
 
 
281
            return false;
 
 
282
        }
 
 
283
        */
 
 
284
 
 
 
285
        // Addresses to send to?
 
 
286
        if (empty($this->addresses) || (empty($this->addresses['to']) && empty($this->addresses['cc']) &&
empty($this->addresses['bcc'])))
 
 
287
        {
 
 
288
            // Send was successful. ;)
 
 
289
            return true;
 
 
290
        }
 
 
291
 
 
 
292
        // Mighty Gorgon: force queue to false until we are sure that everything is working fine
 
 
293
        $use_queue = false;
 
 
294
        /*
 
 
295
        if ($config['email_package_size'] && $this->use_queue)
 
 
296
        {
 
 
297
            if (empty($this->queue))
 
 
298
            {
 
 
299
                $this->queue = new queue();
 
 
300
                $this->queue->init('email', $config['email_package_size']);
 
 
301
            }
 
 
302
            $use_queue = true;
 
 
303
        }
 
 
304
        */
 
 
305
 
 
 
306
        $encode_eol = ($config['smtp_delivery']) ? "\r\n" : $this->eol;
 
 
307
 
 
 
308
        // Old Icy Phoenix Code - BEGIN
 
 
309
        // Escape all quotes, else the eval will fail.
 
 
310
        $this->msg = str_replace("'", "\'", $this->msg);
 
 
311
        $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->msg);
 
 
312
 
 
 
313
        // Set vars
 
 
314
        reset($this->vars);
 
 
315
        while(list($key, $val) = each($this->vars))
 
 
316
        {
 
 
317
            $$key = $val;
 
 
318
        }
 
 
319
 
 
 
320
        eval("\$this->msg = '$this->msg';");
 
 
321
 
 
 
322
        // Clear vars
 
 
323
        reset($this->vars);
 
 
324
        while(list($key, $val) = each($this->vars))
 
 
325
        {
 
 
326
            unset($$key);
 
 
327
        }
 
 
328
 
 
 
329
        // We now try and pull a subject from the email body ... if it exists do this here because the subject may contain a variable
 
 
330
        $drop_header = '';
 
 
331
        $this->subject = (($this->subject != '') ? $this->subject : 'No Subject');
 
 
332
        $match = array();
 
 
333
        if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
 
 
334
        {
 
 
335
            $this->subject = (trim($match[2]) != '') ? trim($match[2]) : $this->subject;
 
 
336
            $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
 
 
337
        }
 
 
338
 
 
 
339
        // Force to UTF-8
 
 
340
        //$encoding_charset = !empty($lang['ENCODING']) ? trim($lang['ENCODING']) : 'UTF-8';
 
 
341
        $encoding_charset = 'UTF-8';
 
 
342
        $this->encoding = $encoding_charset;
 
 
343
        if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
 
 
344
        {
 
 
345
            $this->encoding = (trim($match[2]) != '') ? trim($match[2]) : $encoding_charset;
 
 
346
            $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
 
 
347
        }
 
 
348
 
 
 
349
        if (!empty($drop_header))
 
 
350
        {
 
 
351
            $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
 
 
352
        }
 
 
353
        // Old Icy Phoenix Code - END
 
 
354
 
 
 
355
        // Build to, cc and bcc strings
 
 
356
        $to = '';
 
 
357
        $cc = '';
 
 
358
        $bcc = '';
 
 
359
        foreach ($this->addresses as $type => $address_ary)
 
 
360
        {
 
 
361
            if ($type == 'im')
 
 
362
            {
 
 
363
                continue;
 
 
364
            }
 
 
365
 
 
 
366
            foreach ($address_ary as $which_ary)
 
 
367
            {
 
 
368
                $$type .= (($$type != '') ? ', ' : '') . (!empty($which_ary['name']) ?
(mail_encode($which_ary['name'], $encode_eol) . ' <' . $which_ary['email'] . '>') :
$which_ary['email']);
 
 
369
            }
 
 
370
        }
 
 
371
 
 
 
372
        // Build header
 
 
373
        $headers = $this->build_header($to, $cc, $bcc);
 
 
374
 
 
 
375
        // Send message ...
 
 
376
        if (!$use_queue)
 
 
377
        {
 
 
378
            $empty_to_header = empty($to) ? true : false;
 
 
379
            $mail_to = $empty_to_header ? ($config['sendmail_fix'] ? ' ' : 'Undisclosed-recipients:;') : $to;
 
 
380
            $err_msg = '';
 
 
381
 
 
 
382
            if ($this->use_smtp)
 
 
383
            {
 
 
384
                $result = smtpmail($this->addresses, mail_encode($this->subject), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true),
$err_msg, $headers);
 
 
385
                // Old Version
 
 
386
                //$result = smtpmail($to, $this->subject, $this->msg, $this->extra_headers);
 
 
387
            }
 
 
388
            else
 
 
389
            {
 
 
390
                $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg);
 
 
391
                // Old Version
 
 
392
                /*
 
 
393
                $result = @mail($mail_to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
 
 
394
                if (!$result && !$config['sendmail_fix'] && $empty_to_header)
 
 
395
                {
 
 
396
                    $to = ' ';
 
 
397
                    set_config('sendmail_fix', 1);
 
 
398
                    $result = @mail($mail_to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg),
$this->extra_headers);
 
 
399
                }
 
 
400
                */
 
 
401
            }
 
 
402
 
 
 
403
            // Did it work?
 
 
404
            if (!$result && empty($config['disable_email_error']))
 
 
405
            {
 
 
406
                $this->error('EMAIL', $err_msg);
 
 
407
                return false;
 
 
408
            }
 
 
409
 
 
 
410
        }
 
 
411
        else
 
 
412
        {
 
 
413
            $this->queue->put('email', array(
 
 
414
                'to' => $to,
 
 
415
                'addresses' => $this->addresses,
 
 
416
                'subject' => $this->subject,
 
 
417
                'msg' => $this->msg,
 
 
418
                'headers' => $headers
 
 
419
                )
 
 
420
            );
 
 
421
        }
 
 
422
 
 
 
423
        return true;
 
 
424
    }
 
 
425
 
 
 
426
    /**
 
 
427
    * Selects which template to use
 
 
428
    */
83
    function use_template($template_file, $template_lang = '', $no_template = false)
429
    function use_template($template_file, $template_lang = '', $no_template = false)
84
    {
430
    {
85
        global $config;
431
        global $config;
...
 
...
 
115
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
461
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
116
                }
462
                }
117
 
463
 
118
                $this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
464
                $this->tpl_msg[$template_lang . $template_file] = @fread($fd, @filesize($tpl_file));
119
                fclose($fd);
465
                @fclose($fd);
120
            }
466
            }
121
 
467
 
122
            $mail_header = '';
468
            $mail_header = '';
...
 
...
 
160
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_footer, '', __LINE__, __FILE__);
506
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_footer, '', __LINE__, __FILE__);
161
                }
507
                }
162
 
508
 
163
                $mail_footer = fread($fd, filesize($tpl_footer));
509
                $mail_footer = @fread($fd, @filesize($tpl_footer));
164
                fclose($fd);
510
                @fclose($fd);
165
            }
511
            }
166
 
512
 
167
            $this->msg = $mail_header . $this->tpl_msg[$template_lang . $template_file] . $mail_footer;
513
            $this->msg = $mail_header . $this->tpl_msg[$template_lang . $template_file] . $mail_footer;
...
 
...
 
189
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
535
                    message_die(GENERAL_ERROR, 'Failed opening template file :: ' . $tpl_file, '', __LINE__, __FILE__);
190
                }
536
                }
191
 
537
 
192
                $this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
538
                $this->tpl_msg[$template_lang . $template_file] = @fread($fd, @filesize($tpl_file));
193
                fclose($fd);
539
                @fclose($fd);
194
            }
540
            }
195
 
541
 
196
            $this->msg = $this->tpl_msg[$template_lang . $template_file];
542
            $this->msg = $this->tpl_msg[$template_lang . $template_file];
...
 
...
 
199
        }
545
        }
200
    }
546
    }
201
 
547
 
202
    // assign variables
548
    /*
203
    function assign_vars($vars)
549
    * Encodes the given string for proper display for this encoding... nabbed from php.net and modified. There is an alternative encoding method which
204
    {
550
    * may produce lesd output but it's questionable as to its worth in this scenario IMO
205
        $this->vars = (empty($this->vars)) ? $vars : $this->vars . $vars;
551
    */
206
    }
 
 
207
 
 
 
208
    // Send the mail out to the recipients set previously in var $this->address
 
 
209
    function send()
 
 
210
    {
 
 
211
        global $db, $config, $lang;
 
 
212
 
 
 
213
        // Escape all quotes, else the eval will fail.
 
 
214
        $this->msg = str_replace("'", "\'", $this->msg);
 
 
215
        $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->msg);
 
 
216
 
 
 
217
        // Set vars
 
 
218
        reset($this->vars);
 
 
219
        while(list($key, $val) = each($this->vars))
 
 
220
        {
 
 
221
            $$key = $val;
 
 
222
        }
 
 
223
 
 
 
224
        eval("\$this->msg = '$this->msg';");
 
 
225
 
 
 
226
        // Clear vars
 
 
227
        reset($this->vars);
 
 
228
        while(list($key, $val) = each($this->vars))
 
 
229
        {
 
 
230
            unset($$key);
 
 
231
        }
 
 
232
 
 
 
233
        // We now try and pull a subject from the email body ... if it exists do this here because the subject may contain a variable
 
 
234
        $drop_header = '';
 
 
235
        $match = array();
 
 
236
        if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
 
 
237
        {
 
 
238
            $this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject');
 
 
239
            $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
 
 
240
        }
 
 
241
        else
 
 
242
        {
 
 
243
            $this->subject = (($this->subject != '') ? $this->subject : 'No Subject');
 
 
244
        }
 
 
245
 
 
 
246
        $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
 
 
247
        if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
 
 
248
        {
 
 
249
            $this->encoding = (trim($match[2]) != '') ? trim($match[2]) : trim($encoding_charset);
 
 
250
            $drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
 
 
251
        }
 
 
252
        else
 
 
253
        {
 
 
254
            $this->encoding = trim($encoding_charset);
 
 
255
        }
 
 
256
 
 
 
257
        if ($drop_header != '')
 
 
258
        {
 
 
259
            $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
 
 
260
        }
 
 
261
 
 
 
262
        $to = $this->addresses['to'];
 
 
263
 
 
 
264
        $cc = (sizeof($this->addresses['cc'])) ? implode(', ', $this->addresses['cc']) : '';
 
 
265
        $bcc = (sizeof($this->addresses['bcc'])) ? implode(', ', $this->addresses['bcc']) : '';
 
 
266
 
 
 
267
        // Build header
 
 
268
 
 
 
269
        if (!empty($config['html_email']))
 
 
270
        {
 
 
271
            $this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $config['board_email'] . "\n") . "Return-Path: " . $config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/html; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('r') . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By Icy Phoenix\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
 
 
272
        }
 
 
273
        else
 
 
274
        {
 
 
275
            $this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $config['board_email'] . "\n") . "Return-Path: " . $config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('r') . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By Icy Phoenix\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
 
 
276
        }
 
 
277
 
 
 
278
        // Send message ... removed $this->encode() from subject for time being
 
 
279
        if ($this->use_smtp)
 
 
280
        {
 
 
281
            if ( !defined('SMTP_INCLUDED') )
 
 
282
            {
 
 
283
                include(IP_ROOT_PATH . 'includes/smtp.' . PHP_EXT);
 
 
284
            }
 
 
285
 
 
 
286
            $result = smtpmail($to, $this->subject, $this->msg, $this->extra_headers);
 
 
287
        }
 
 
288
        else
 
 
289
        {
 
 
290
            $empty_to_header = ($to == '') ? true : false;
 
 
291
            $to = ($to == '') ? (($config['sendmail_fix']) ? ' ' : 'Undisclosed-recipients:;') : $to;
 
 
292
 
 
 
293
            $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
 
 
294
 
 
 
295
            if (!$result && !$config['sendmail_fix'] && $empty_to_header)
 
 
296
            {
 
 
297
                $to = ' ';
 
 
298
                set_config('sendmail_fix', 1);
 
 
299
                $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
 
 
300
            }
 
 
301
        }
 
 
302
 
 
 
303
        // Did it work?
 
 
304
        if (!$result)
 
 
305
        {
 
 
306
            if ($config['disable_email_error'] == 0)
 
 
307
            {
 
 
308
                message_die(GENERAL_ERROR, 'Failed sending email :: ' . (($this->use_smtp) ? 'SMTP' : 'PHP') . ' :: ' . $result, '', __LINE__, __FILE__);
 
 
309
            }
 
 
310
        }
 
 
311
 
 
 
312
        return true;
 
 
313
    }
 
 
314
 
 
 
315
    // Encodes the given string for proper display for this encoding ... nabbed
 
 
316
    // from php.net and modified. There is an alternative encoding method which
 
 
317
    // may produce lesd output but it's questionable as to its worth in this
 
 
318
    // scenario IMO
 
 
319
    function encode($str)
552
    function encode($str)
320
    {
553
    {
321
        if ($this->encoding == '')
554
        if ($this->encoding == '')
...
 
...
 
341
        return $start . $str . $end;
574
        return $start . $str . $end;
342
    }
575
    }
343
 
576
 
 
 
577
    /**
 
 
578
    * Save to queue
 
 
579
    */
 
 
580
    function save_queue()
 
 
581
    {
 
 
582
        global $config;
 
 
583
 
 
 
584
        if ($config['email_package_size'] && $this->use_queue && !empty($this->queue))
 
 
585
        {
 
 
586
            $this->queue->save();
 
 
587
            return;
 
 
588
        }
 
 
589
    }
 
 
590
 
 
 
591
    /**
 
 
592
    * Add error message to log
 
 
593
    */
 
 
594
    function error($type, $msg)
 
 
595
    {
 
 
596
        global $config, $userdata, $lang;
 
 
597
 
 
 
598
        /*
 
 
599
        // Session doesn't exist, create it
 
 
600
        if (!isset($user->session_id) || $user->session_id === '')
 
 
601
        {
 
 
602
            $user->session_begin();
 
 
603
        }
 
 
604
        */
 
 
605
 
 
 
606
        $calling_page = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
 
 
607
 
 
 
608
        $message = '';
 
 
609
        switch ($type)
 
 
610
        {
 
 
611
            case 'EMAIL':
 
 
612
                $message = '<strong>EMAIL/' . (($config['smtp_delivery']) ? 'SMTP' : 'PHP/' .
$config['email_function_name'] . '()') . '</strong>';
 
 
613
            break;
 
 
614
 
 
 
615
            default:
 
 
616
                $message = "<strong>$type</strong>";
 
 
617
            break;
 
 
618
        }
 
 
619
 
 
 
620
        $message .= '<br /><em>' . htmlspecialchars($calling_page) . '</em><br /><br />' . $msg . '<br
/>';
 
 
621
        //add_log('critical', 'LOG_ERROR_' . $type, $message);
 
 
622
        message_die(GENERAL_ERROR, '<strong>Failed sending email</strong><br />' . $message, '', __LINE__, __FILE__);
 
 
623
    }
 
 
624
 
344
    // Attach files via MIME.
625
    // Attach files via MIME.
345
    function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay)
626
    function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay)
346
    {
627
    {
347
        global $lang;
628
        global $lang;
348
        $encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
629
        // Force to UTF-8
 
 
630
        //$encoding_charset = !empty($lang['ENCODING']) ? $lang['ENCODING'] : 'UTF-8';
 
 
631
        $encoding_charset = 'UTF-8';
 
 
632
 
349
        $mime_boundary = "--==================_846811060==_";
633
        $mime_boundary = "--==================_846811060==_";
350
 
634
 
351
        $this->msg = '--' . $mime_boundary . "\nContent-Type: text/html;\n\tcharset=\"" . $encoding_charset .
"\"\n\n" . $this->msg;
635
        $this->msg = '--' . $mime_boundary . "\nContent-Type: text/html;\n\tcharset=\"" . $encoding_charset .
"\"\n\n" . $this->msg;
...
 
...
 
442
 
726
 
443
} // class emailer
727
} // class emailer
444
 
728
 
 
 
729
/**
 
 
730
* handling email and jabber queue
 
 
731
* @package phpBB3
 
 
732
*/
 
 
733
class queue
 
 
734
{
 
 
735
    var $data = array();
 
 
736
    var $queue_data = array();
 
 
737
    var $package_size = 0;
 
 
738
    var $cache_file = '';
 
 
739
    var $eol = "\n";
 
 
740
 
 
 
741
    /**
 
 
742
    * constructor
 
 
743
    */
 
 
744
    function queue()
 
 
745
    {
 
 
746
        $this->data = array();
 
 
747
        $this->cache_file = IP_ROOT_PATH . 'cache/queue.' . PHP_EXT;
 
 
748
 
 
 
749
        // Determine EOL character (\n for UNIX, \r\n for Windows and \r for Mac)
 
 
750
        $this->eol = (!defined('PHP_EOL')) ? (($eol = strtolower(substr(PHP_OS, 0, 3))) == 'win') ? "\r\n" : (($eol ==
'mac') ? "\r" : "\n") : PHP_EOL;
 
 
751
        $this->eol = (!$this->eol) ? "\n" : $this->eol;
 
 
752
    }
 
 
753
 
 
 
754
    /**
 
 
755
    * Init a queue object
 
 
756
    */
 
 
757
    function init($object, $package_size)
 
 
758
    {
 
 
759
        $this->data[$object] = array();
 
 
760
        $this->data[$object]['package_size'] = $package_size;
 
 
761
        $this->data[$object]['data'] = array();
 
 
762
    }
 
 
763
 
 
 
764
    /**
 
 
765
    * Put object in queue
 
 
766
    */
 
 
767
    function put($object, $scope)
 
 
768
    {
 
 
769
        $this->data[$object]['data'][] = $scope;
 
 
770
    }
 
 
771
 
 
 
772
    /**
 
 
773
    * Process queue
 
 
774
    * Using lock file
 
 
775
    */
 
 
776
    function process()
 
 
777
    {
 
 
778
        global $db, $config, $lang;
 
 
779
 
 
 
780
        set_config('last_queue_run', time(), true);
 
 
781
 
 
 
782
        // Delete stale lock file
 
 
783
        if (file_exists($this->cache_file . '.lock') && !file_exists($this->cache_file))
 
 
784
        {
 
 
785
            @unlink($this->cache_file . '.lock');
 
 
786
            return;
 
 
787
        }
 
 
788
 
 
 
789
        if (!file_exists($this->cache_file) || (file_exists($this->cache_file . '.lock') && filemtime($this->cache_file) > time()
- $config['queue_interval']))
 
 
790
        {
 
 
791
            return;
 
 
792
        }
 
 
793
 
 
 
794
        $fp = @fopen($this->cache_file . '.lock', 'wb');
 
 
795
        fclose($fp);
 
 
796
        @chmod($this->cache_file . '.lock', 0777);
 
 
797
 
 
 
798
        include($this->cache_file);
 
 
799
 
 
 
800
        foreach ($this->queue_data as $object => $data_ary)
 
 
801
        {
 
 
802
            @set_time_limit(0);
 
 
803
 
 
 
804
            if (!isset($data_ary['package_size']))
 
 
805
            {
 
 
806
                $data_ary['package_size'] = 0;
 
 
807
            }
 
 
808
 
 
 
809
            $package_size = $data_ary['package_size'];
 
 
810
            $num_items = (!$package_size || sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size;
 
 
811
 
 
 
812
            // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs...
 
 
813
            if (sizeof($data_ary['data']) > $package_size * 2.5)
 
 
814
            {
 
 
815
                $num_items = sizeof($data_ary['data']);
 
 
816
            }
 
 
817
 
 
 
818
            switch ($object)
 
 
819
            {
 
 
820
                case 'email':
 
 
821
                    // Delete the email queued objects if mailing is disabled
 
 
822
                    if (!$config['email_enable'])
 
 
823
                    {
 
 
824
                        unset($this->queue_data['email']);
 
 
825
                        continue 2;
 
 
826
                    }
 
 
827
                break;
 
 
828
 
 
 
829
                case 'jabber':
 
 
830
                    if (!$config['jab_enable'])
 
 
831
                    {
 
 
832
                        unset($this->queue_data['jabber']);
 
 
833
                        continue 2;
 
 
834
                    }
 
 
835
 
 
 
836
                    include_once(IP_ROOT_PATH . 'includes/functions_jabber.' . PHP_EXT);
 
 
837
                    $this->jabber = new jabber($config['jab_host'], $config['jab_port'], $config['jab_username'],
$config['jab_password'], $config['jab_use_ssl']);
 
 
838
 
 
 
839
                    if (!$this->jabber->connect())
 
 
840
                    {
 
 
841
                        messenger::error('JABBER', $lang['ERR_JAB_CONNECT']);
 
 
842
                        continue 2;
 
 
843
                    }
 
 
844
 
 
 
845
                    if (!$this->jabber->login())
 
 
846
                    {
 
 
847
                        messenger::error('JABBER', $lang['ERR_JAB_AUTH']);
 
 
848
                        continue 2;
 
 
849
                    }
 
 
850
 
 
 
851
                break;
 
 
852
 
 
 
853
                default:
 
 
854
                    return;
 
 
855
            }
 
 
856
 
 
 
857
            for ($i = 0; $i < $num_items; $i++)
 
 
858
            {
 
 
859
                // Make variables available...
 
 
860
                extract(array_shift($this->queue_data[$object]['data']));
 
 
861
 
 
 
862
                switch ($object)
 
 
863
                {
 
 
864
                    case 'email':
 
 
865
                        $err_msg = '';
 
 
866
                        $to = (!$to) ? 'undisclosed-recipients:;' : $to;
 
 
867
 
 
 
868
                        if ($config['smtp_delivery'])
 
 
869
                        {
 
 
870
                            $result = smtpmail($addresses, mail_encode($subject), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $err_msg, $headers);
 
 
871
                        }
 
 
872
                        else
 
 
873
                        {
 
 
874
                            $result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg);
 
 
875
                        }
 
 
876
 
 
 
877
                        if (!$result)
 
 
878
                        {
 
 
879
                            @unlink($this->cache_file . '.lock');
 
 
880
 
 
 
881
                            emailer::error('EMAIL', $err_msg);
 
 
882
                            continue 2;
 
 
883
                        }
 
 
884
                    break;
 
 
885
 
 
 
886
                    case 'jabber':
 
 
887
                        foreach ($addresses as $address)
 
 
888
                        {
 
 
889
                            if ($this->jabber->send_message($address, $msg, $subject) === false)
 
 
890
                            {
 
 
891
                                emailer::error('JABBER', $this->jabber->get_log());
 
 
892
                                continue 3;
 
 
893
                            }
 
 
894
                        }
 
 
895
                    break;
 
 
896
                }
 
 
897
            }
 
 
898
 
 
 
899
            // No more data for this object? Unset it
 
 
900
            if (!sizeof($this->queue_data[$object]['data']))
 
 
901
            {
 
 
902
                unset($this->queue_data[$object]);
 
 
903
            }
 
 
904
 
 
 
905
            // Post-object processing
 
 
906
            switch ($object)
 
 
907
            {
 
 
908
                case 'jabber':
 
 
909
                    // Hang about a couple of secs to ensure the messages are
 
 
910
                    // handled, then disconnect
 
 
911
                    $this->jabber->disconnect();
 
 
912
                break;
 
 
913
            }
 
 
914
        }
 
 
915
 
 
 
916
        if (!sizeof($this->queue_data))
 
 
917
        {
 
 
918
            @unlink($this->cache_file);
 
 
919
        }
 
 
920
        else
 
 
921
        {
 
 
922
            if ($fp = @fopen($this->cache_file, 'wb'))
 
 
923
            {
 
 
924
                @flock($fp, LOCK_EX);
 
 
925
                fwrite($fp, "<?php\nif (!defined('IN_ICYPHOENIX')) exit;\n\$this->queue_data = unserialize(" .
var_export(serialize($this->queue_data), true) . ");\n\n?>");
 
 
926
                @flock($fp, LOCK_UN);
 
 
927
                fclose($fp);
 
 
928
 
 
 
929
                phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
 
 
930
            }
 
 
931
        }
 
 
932
 
 
 
933
        @unlink($this->cache_file . '.lock');
 
 
934
    }
 
 
935
 
 
 
936
    /**
 
 
937
    * Save queue
 
 
938
    */
 
 
939
    function save()
 
 
940
    {
 
 
941
        if (!sizeof($this->data))
 
 
942
        {
 
 
943
            return;
 
 
944
        }
 
 
945
 
 
 
946
        if (file_exists($this->cache_file))
 
 
947
        {
 
 
948
            include($this->cache_file);
 
 
949
 
 
 
950
            foreach ($this->queue_data as $object => $data_ary)
 
 
951
            {
 
 
952
                if (isset($this->data[$object]) && sizeof($this->data[$object]))
 
 
953
                {
 
 
954
                    $this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']);
 
 
955
                }
 
 
956
                else
 
 
957
                {
 
 
958
                    $this->data[$object]['data'] = $data_ary['data'];
 
 
959
                }
 
 
960
            }
 
 
961
        }
 
 
962
 
 
 
963
        if ($fp = @fopen($this->cache_file, 'w'))
 
 
964
        {
 
 
965
            @flock($fp, LOCK_EX);
 
 
966
            fwrite($fp, "<?php\nif (!defined('IN_ICYPHOENIX')) exit;\n\$this->queue_data = unserialize(" .
var_export(serialize($this->data), true) . ");\n\n?>");
 
 
967
            @flock($fp, LOCK_UN);
 
 
968
            fclose($fp);
 
 
969
 
 
 
970
            phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
 
 
971
        }
 
 
972
    }
 
 
973
}
 
 
974
 
 
 
975
/**
 
 
976
* Replacement or substitute for PHP's mail command
 
 
977
*/
 
 
978
function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
 
 
979
{
 
 
980
    global $config, $lang;
 
 
981
 
 
 
982
    // Fix any bare linefeeds in the message to make it RFC821 Compliant.
 
 
983
    $message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);
 
 
984
 
 
 
985
    if ($headers !== false)
 
 
986
    {
 
 
987
        if (!is_array($headers))
 
 
988
        {
 
 
989
            // Make sure there are no bare linefeeds in the headers
 
 
990
            $headers = preg_replace('#(?<!\r)\n#si', "\n", $headers);
 
 
991
            $headers = explode("\n", $headers);
 
 
992
        }
 
 
993
 
 
 
994
        // Ok this is rather confusing all things considered, but we have to grab bcc and cc headers and treat them differently
 
 
995
        // Something we really didn't take into consideration originally
 
 
996
        $headers_used = array();
 
 
997
 
 
 
998
        foreach ($headers as $header)
 
 
999
        {
 
 
1000
            if (strpos(strtolower($header), 'cc:') === 0 || strpos(strtolower($header), 'bcc:') === 0)
 
 
1001
            {
 
 
1002
                continue;
 
 
1003
            }
 
 
1004
            $headers_used[] = trim($header);
 
 
1005
        }
 
 
1006
 
 
 
1007
        $headers = chop(implode("\r\n", $headers_used));
 
 
1008
    }
 
 
1009
 
 
 
1010
    if (trim($subject) == '')
 
 
1011
    {
 
 
1012
        $err_msg = (isset($lang['NO_EMAIL_SUBJECT'])) ? $lang['NO_EMAIL_SUBJECT'] : 'No email subject specified';
 
 
1013
        return false;
 
 
1014
    }
 
 
1015
 
 
 
1016
    if (trim($message) == '')
 
 
1017
    {
 
 
1018
        $err_msg = (isset($lang['NO_EMAIL_MESSAGE'])) ? $lang['NO_EMAIL_MESSAGE'] : 'Email message was blank';
 
 
1019
        return false;
 
 
1020
    }
 
 
1021
 
 
 
1022
    $mail_rcpt = $mail_to = $mail_cc = array();
 
 
1023
 
 
 
1024
    // Build correct addresses for RCPT TO command and the client side display (TO, CC)
 
 
1025
    if (isset($addresses['to']) && sizeof($addresses['to']))
 
 
1026
    {
 
 
1027
        foreach ($addresses['to'] as $which_ary)
 
 
1028
        {
 
 
1029
            $mail_to[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' .
trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
 
 
1030
            $mail_rcpt['to'][] = '<' . trim($which_ary['email']) . '>';
 
 
1031
        }
 
 
1032
    }
 
 
1033
 
 
 
1034
    if (isset($addresses['bcc']) && sizeof($addresses['bcc']))
 
 
1035
    {
 
 
1036
        foreach ($addresses['bcc'] as $which_ary)
 
 
1037
        {
 
 
1038
            $mail_rcpt['bcc'][] = '<' . trim($which_ary['email']) . '>';
 
 
1039
        }
 
 
1040
    }
 
 
1041
 
 
 
1042
    if (isset($addresses['cc']) && sizeof($addresses['cc']))
 
 
1043
    {
 
 
1044
        foreach ($addresses['cc'] as $which_ary)
 
 
1045
        {
 
 
1046
            $mail_cc[] = ($which_ary['name'] != '') ? mail_encode(trim($which_ary['name'])) . ' <' .
trim($which_ary['email']) . '>' : '<' . trim($which_ary['email']) . '>';
 
 
1047
            $mail_rcpt['cc'][] = '<' . trim($which_ary['email']) . '>';
 
 
1048
        }
 
 
1049
    }
 
 
1050
 
 
 
1051
    $smtp = new smtp_class();
 
 
1052
 
 
 
1053
    $errno = 0;
 
 
1054
    $errstr = '';
 
 
1055
 
 
 
1056
    $config['smtp_port'] = empty($config['smtp_port']) ? 25 : $config['smtp_port'];
 
 
1057
    $smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
 
 
1058
 
 
 
1059
    // Ok we have error checked as much as we can to this point let's get on it already.
 
 
1060
    ob_start();
 
 
1061
    $smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
 
 
1062
    $error_contents = ob_get_clean();
 
 
1063
 
 
 
1064
    if (!$smtp->socket)
 
 
1065
    {
 
 
1066
        if ($errstr)
 
 
1067
        {
 
 
1068
            $errstr = utf8_convert_message($errstr);
 
 
1069
        }
 
 
1070
 
 
 
1071
        $err_msg = (isset($lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) : "Could not
connect to smtp host : $errno : $errstr";
 
 
1072
        $err_msg .= ($error_contents) ? '<br /><br />' . htmlspecialchars($error_contents) : '';
 
 
1073
        return false;
 
 
1074
    }
 
 
1075
 
 
 
1076
    // Wait for reply
 
 
1077
    if ($err_msg = $smtp->server_parse('220', __LINE__))
 
 
1078
    {
 
 
1079
        $smtp->close_session($err_msg);
 
 
1080
        return false;
 
 
1081
    }
 
 
1082
 
 
 
1083
    // Let me in. This function handles the complete authentication process
 
 
1084
    if ($err_msg = $smtp->log_into_server($config['smtp_host'], $config['smtp_username'], $config['smtp_password'],
$config['smtp_auth_method']))
 
 
1085
    {
 
 
1086
        $smtp->close_session($err_msg);
 
 
1087
        return false;
 
 
1088
    }
 
 
1089
 
 
 
1090
    // From this point onward most server response codes should be 250
 
 
1091
    // Specify who the mail is from....
 
 
1092
    $smtp->server_send('MAIL FROM:<' . $config['board_email'] . '>');
 
 
1093
    if ($err_msg = $smtp->server_parse('250', __LINE__))
 
 
1094
    {
 
 
1095
        $smtp->close_session($err_msg);
 
 
1096
        return false;
 
 
1097
    }
 
 
1098
 
 
 
1099
    // Specify each user to send to and build to header.
 
 
1100
    $to_header = implode(', ', $mail_to);
 
 
1101
    $cc_header = implode(', ', $mail_cc);
 
 
1102
 
 
 
1103
    // Now tell the MTA to send the Message to the following people... [TO, BCC, CC]
 
 
1104
    $rcpt = false;
 
 
1105
    foreach ($mail_rcpt as $type => $mail_to_addresses)
 
 
1106
    {
 
 
1107
        foreach ($mail_to_addresses as $mail_to_address)
 
 
1108
        {
 
 
1109
            // Add an additional bit of error checking to the To field.
 
 
1110
            if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
 
 
1111
            {
 
 
1112
                $smtp->server_send("RCPT TO:$mail_to_address");
 
 
1113
                if ($err_msg = $smtp->server_parse('250', __LINE__))
 
 
1114
                {
 
 
1115
                    // We continue... if users are not resolved we do not care
 
 
1116
                    if ($smtp->numeric_response_code != 550)
 
 
1117
                    {
 
 
1118
                        $smtp->close_session($err_msg);
 
 
1119
                        return false;
 
 
1120
                    }
 
 
1121
                }
 
 
1122
                else
 
 
1123
                {
 
 
1124
                    $rcpt = true;
 
 
1125
                }
 
 
1126
            }
 
 
1127
        }
 
 
1128
    }
 
 
1129
 
 
 
1130
    // We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here.
 
 
1131
    if (!$rcpt)
 
 
1132
    {
 
 
1133
        $err_msg .= '<br /><br />';
 
 
1134
        $err_msg .= (isset($lang['INVALID_EMAIL_LOG'])) ? sprintf($lang['INVALID_EMAIL_LOG'], htmlspecialchars($mail_to_address)) :
'<strong>' . htmlspecialchars($mail_to_address) . '</strong> possibly an invalid email address?';
 
 
1135
        $smtp->close_session($err_msg);
 
 
1136
        return false;
 
 
1137
    }
 
 
1138
 
 
 
1139
    // Ok now we tell the server we are ready to start sending data
 
 
1140
    $smtp->server_send('DATA');
 
 
1141
 
 
 
1142
    // This is the last response code we look for until the end of the message.
 
 
1143
    if ($err_msg = $smtp->server_parse('354', __LINE__))
 
 
1144
    {
 
 
1145
        $smtp->close_session($err_msg);
 
 
1146
        return false;
 
 
1147
    }
 
 
1148
 
 
 
1149
    // Send the Subject Line...
 
 
1150
    $smtp->server_send("Subject: $subject");
 
 
1151
 
 
 
1152
    // Now the To Header.
 
 
1153
    $to_header = ($to_header == '') ? 'Undisclosed-recipients:;' : $to_header;
 
 
1154
    $smtp->server_send("To: $to_header");
 
 
1155
 
 
 
1156
    // Now the CC Header.
 
 
1157
    if ($cc_header != '')
 
 
1158
    {
 
 
1159
        $smtp->server_send("CC: $cc_header");
 
 
1160
    }
 
 
1161
 
 
 
1162
    // Now any custom headers....
 
 
1163
    if ($headers !== false)
 
 
1164
    {
 
 
1165
        $smtp->server_send("$headers\r\n");
 
 
1166
    }
 
 
1167
 
 
 
1168
    // Ok now we are ready for the message...
 
 
1169
    $smtp->server_send($message);
 
 
1170
 
 
 
1171
    // Ok the all the ingredients are mixed in let's cook this puppy...
 
 
1172
    $smtp->server_send('.');
 
 
1173
    if ($err_msg = $smtp->server_parse('250', __LINE__))
 
 
1174
    {
 
 
1175
        $smtp->close_session($err_msg);
 
 
1176
        return false;
 
 
1177
    }
 
 
1178
 
 
 
1179
    // Now tell the server we are done and close the socket...
 
 
1180
    $smtp->server_send('QUIT');
 
 
1181
    $smtp->close_session($err_msg);
 
 
1182
 
 
 
1183
    return true;
 
 
1184
}
 
 
1185
 
 
 
1186
/**
 
 
1187
* SMTP Class
 
 
1188
* Auth Mechanisms originally taken from the AUTH Modules found within the PHP Extension and Application Repository (PEAR)
 
 
1189
* See docs/AUTHORS for more details
 
 
1190
* @package phpBB3
 
 
1191
*/
 
 
1192
class smtp_class
 
 
1193
{
 
 
1194
    var $server_response = '';
 
 
1195
    var $socket = 0;
 
 
1196
    var $responses = array();
 
 
1197
    var $commands = array();
 
 
1198
    var $numeric_response_code = 0;
 
 
1199
 
 
 
1200
    var $backtrace = false;
 
 
1201
    var $backtrace_log = array();
 
 
1202
 
 
 
1203
    function smtp_class()
 
 
1204
    {
 
 
1205
        // Always create a backtrace for admins to identify SMTP problems
 
 
1206
        $this->backtrace = true;
 
 
1207
        $this->backtrace_log = array();
 
 
1208
    }
 
 
1209
 
 
 
1210
    /**
 
 
1211
    * Add backtrace message for debugging
 
 
1212
    */
 
 
1213
    function add_backtrace($message)
 
 
1214
    {
 
 
1215
        if ($this->backtrace)
 
 
1216
        {
 
 
1217
            $this->backtrace_log[] = utf8_htmlspecialchars($message);
 
 
1218
        }
 
 
1219
    }
 
 
1220
 
 
 
1221
    /**
 
 
1222
    * Send command to smtp server
 
 
1223
    */
 
 
1224
    function server_send($command, $private_info = false)
 
 
1225
    {
 
 
1226
        fputs($this->socket, $command . "\r\n");
 
 
1227
 
 
 
1228
        (!$private_info) ? $this->add_backtrace("# $command") : $this->add_backtrace('# Omitting sensitive information');
 
 
1229
 
 
 
1230
        // We could put additional code here
 
 
1231
    }
 
 
1232
 
 
 
1233
    /**
 
 
1234
    * We use the line to give the support people an indication at which command the error occurred
 
 
1235
    */
 
 
1236
    function server_parse($response, $line)
 
 
1237
    {
 
 
1238
        global $lang;
 
 
1239
 
 
 
1240
        $this->server_response = '';
 
 
1241
        $this->responses = array();
 
 
1242
        $this->numeric_response_code = 0;
 
 
1243
 
 
 
1244
        while (substr($this->server_response, 3, 1) != ' ')
 
 
1245
        {
 
 
1246
            if (!($this->server_response = fgets($this->socket, 256)))
 
 
1247
            {
 
 
1248
                return (isset($lang['NO_EMAIL_RESPONSE_CODE'])) ? $lang['NO_EMAIL_RESPONSE_CODE'] : 'Could not get mail server response
codes';
 
 
1249
            }
 
 
1250
            $this->responses[] = substr(rtrim($this->server_response), 4);
 
 
1251
            $this->numeric_response_code = (int) substr($this->server_response, 0, 3);
 
 
1252
 
 
 
1253
            $this->add_backtrace("LINE: $line <- {$this->server_response}");
 
 
1254
        }
 
 
1255
 
 
 
1256
        if (!(substr($this->server_response, 0, 3) == $response))
 
 
1257
        {
 
 
1258
            $this->numeric_response_code = (int) substr($this->server_response, 0, 3);
 
 
1259
            return (isset($lang['EMAIL_SMTP_ERROR_RESPONSE'])) ? sprintf($lang['EMAIL_SMTP_ERROR_RESPONSE'], $line,
$this->server_response) : "Ran into problems sending Mail at <strong>Line $line</strong>. Response: $this->server_response";
 
 
1260
        }
 
 
1261
 
 
 
1262
        return 0;
 
 
1263
    }
 
 
1264
 
 
 
1265
    /**
 
 
1266
    * Close session
 
 
1267
    */
 
 
1268
    function close_session(&$err_msg)
 
 
1269
    {
 
 
1270
        fclose($this->socket);
 
 
1271
 
 
 
1272
        if ($this->backtrace)
 
 
1273
        {
 
 
1274
            $message = '<h1>Backtrace</h1><p>' . implode('<br />', $this->backtrace_log) .
'</p>';
 
 
1275
            $err_msg .= $message;
 
 
1276
        }
 
 
1277
    }
 
 
1278
 
 
 
1279
    /**
 
 
1280
    * Log into server and get possible auth codes if neccessary
 
 
1281
    */
 
 
1282
    function log_into_server($hostname, $username, $password, $default_auth_method)
 
 
1283
    {
 
 
1284
        global $lang;
 
 
1285
 
 
 
1286
        $err_msg = '';
 
 
1287
 
 
 
1288
        // Here we try to determine the *real* hostname (reverse DNS entry preferrably)
 
 
1289
        $local_host = extract_current_hostname();
 
 
1290
 
 
 
1291
        if (function_exists('php_uname'))
 
 
1292
        {
 
 
1293
            $local_host = php_uname('n');
 
 
1294
 
 
 
1295
            // Able to resolve name to IP
 
 
1296
            if (($addr = @gethostbyname($local_host)) !== $local_host)
 
 
1297
            {
 
 
1298
                // Able to resolve IP back to name
 
 
1299
                if (($name = @gethostbyaddr($addr)) !== $addr)
 
 
1300
                {
 
 
1301
                    $local_host = $name;
 
 
1302
                }
 
 
1303
            }
 
 
1304
        }
 
 
1305
 
 
 
1306
        // If we are authenticating through pop-before-smtp, we
 
 
1307
        // have to login ones before we get authenticated
 
 
1308
        // NOTE: on some configurations the time between an update of the auth database takes so
 
 
1309
        // long that the first email send does not work. This is not a biggie on a live board (only
 
 
1310
        // the install mail will most likely fail) - but on a dynamic ip connection this might produce
 
 
1311
        // severe problems and is not fixable!
 
 
1312
        if ($default_auth_method == 'POP-BEFORE-SMTP' && $username && $password)
 
 
1313
        {
 
 
1314
            global $config;
 
 
1315
 
 
 
1316
            $errno = 0;
 
 
1317
            $errstr = '';
 
 
1318
 
 
 
1319
            $this->server_send("QUIT");
 
 
1320
            fclose($this->socket);
 
 
1321
 
 
 
1322
            $result = $this->pop_before_smtp($hostname, $username, $password);
 
 
1323
            $username = $password = $default_auth_method = '';
 
 
1324
 
 
 
1325
            // We need to close the previous session, else the server is not able to get our ip for matching...
 
 
1326
            $config['smtp_port'] = empty($config['smtp_port']) ? 25 : $config['smtp_port'];
 
 
1327
            if (!$this->socket = @fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 10))
 
 
1328
            {
 
 
1329
                if ($errstr)
 
 
1330
                {
 
 
1331
                    $errstr = utf8_convert_message($errstr);
 
 
1332
                }
 
 
1333
 
 
 
1334
                $err_msg = (isset($lang['NO_CONNECT_TO_SMTP_HOST'])) ? sprintf($lang['NO_CONNECT_TO_SMTP_HOST'], $errno, $errstr) :
"Could not connect to smtp host : $errno : $errstr";
 
 
1335
                return $err_msg;
 
 
1336
            }
 
 
1337
 
 
 
1338
            // Wait for reply
 
 
1339
            if ($err_msg = $this->server_parse('220', __LINE__))
 
 
1340
            {
 
 
1341
                $this->close_session($err_msg);
 
 
1342
                return $err_msg;
 
 
1343
            }
 
 
1344
        }
 
 
1345
 
 
 
1346
        // Try EHLO first
 
 
1347
        $this->server_send("EHLO {$local_host}");
 
 
1348
        if ($err_msg = $this->server_parse('250', __LINE__))
 
 
1349
        {
 
 
1350
            // a 503 response code means that we're already authenticated
 
 
1351
            if ($this->numeric_response_code == 503)
 
 
1352
            {
 
 
1353
                return false;
 
 
1354
            }
 
 
1355
 
 
 
1356
            // If EHLO fails, we try HELO
 
 
1357
            $this->server_send("HELO {$local_host}");
 
 
1358
            if ($err_msg = $this->server_parse('250', __LINE__))
 
 
1359
            {
 
 
1360
                return ($this->numeric_response_code == 503) ? false : $err_msg;
 
 
1361
            }
 
 
1362
        }
 
 
1363
 
 
 
1364
        foreach ($this->responses as $response)
 
 
1365
        {
 
 
1366
            $response = explode(' ', $response);
 
 
1367
            $response_code = $response[0];
 
 
1368
            unset($response[0]);
 
 
1369
            $this->commands[$response_code] = implode(' ', $response);
 
 
1370
        }
 
 
1371
 
 
 
1372
        // If we are not authenticated yet, something might be wrong if no username and passwd passed
 
 
1373
        if (!$username || !$password)
 
 
1374
        {
 
 
1375
            return false;
 
 
1376
        }
 
 
1377
 
 
 
1378
        if (!isset($this->commands['AUTH']))
 
 
1379
        {
 
 
1380
            return (isset($lang['SMTP_NO_AUTH_SUPPORT'])) ? $lang['SMTP_NO_AUTH_SUPPORT'] : 'SMTP server does not support
authentication';
 
 
1381
        }
 
 
1382