Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        frontend
5
 * @package         account
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: confirm_mails.php 1924 2013-06-08 13:58:40Z darkviper $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/account/confirm_mails.php $
14
 * @lastmodified    $Date: 2013-06-08 15:58:40 +0200 (Sat, 08 Jun 2013) $
15
 *
16
 */
17

    
18
/* -------------------------------------------------------- */
19
// Must include code to stop this file being accessed directly
20
if(defined('WB_PATH') == false)
21
{
22
	die('<h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2>');
23
}
24
/* -------------------------------------------------------- */
25
if (!function_exists('ObfuscateIp')) {
26
	function ObfuscateIp() {
27
	    $sClientIp = (isset($_SERVER['REMOTE_ADDR']))
28
	                         ? $_SERVER['REMOTE_ADDR'] : '000.000.000.000';
29
//	    $iClientIp = ip2long($sClientIp);
30
//	    $sClientIp = long2ip(($iClientIp & ~65535));
31
	    return $sClientIp;
32
	}
33
}
34

    
35
if (!function_exists('emailAdmin')) {
36
	function emailAdmin() {
37
		global $database,$admin;
38
        $retval = $admin->get_email();
39
        if($admin->get_user_id()!='1') {
40
			$sql  = 'SELECT `email` FROM `'.TABLE_PREFIX.'users` ';
41
			$sql .= 'WHERE `user_id`=\'1\' ';
42
	        $retval = $database->get_one($sql);
43
        }
44
		return $retval;
45
	}
46
}
47

    
48
// load module language file
49
$mLang = Translate::getInstance();
50
$mLang->enableAddon('account');
51
//WB_MAILER settings
52
$sServerEmail = (defined('SERVER_EMAIL') && SERVER_EMAIL != '' ? SERVER_EMAIL : emailAdmin());
53
$sWebMailer   = (defined('WBMAILER_DEFAULT_SENDERNAME') && WBMAILER_DEFAULT_SENDERNAME != '' ? WBMAILER_DEFAULT_SENDERNAME : 'WebsiteBaker Mailer');
54

    
55
/**
56
 * now send user email, if activation don't failed'
57
 *
58
 *
59
 */
60

    
61
if(($email_to != '') && $bSaveRegistration ) {
62

    
63
	$email_body = '';
64
//	$get_ip = ObfuscateIp();
65
	$get_ts = time();
66
	$mail_message = $mLang->MESSAGE_SEND_CONFIRMED_ACTIVATION.$mLang->MESSAGE_SUCCESS_EMAIL_TEXT_GENERATED;
67
	$search = array('{LOGIN_DISPLAY_NAME}', '{LOGIN_WEBSITE_TITLE}',  '{{webmaster_email}}');
68
	$replace = array($sDisplayName, WEBSITE_TITLE, $sServerEmail);
69
	$mail_message = str_replace($search, $replace, $mail_message);
70

    
71
	$email_subject = $mLang->MESSAGE_SIGNUP_ACTIVATION;
72
	$regex = "/[^a-z0-9ßöäüÖÄÜ !?:;,.\/_\-=+@#$&\*\(\)]/im";
73
	$recipient = preg_replace( $regex, "?", $sDisplayName );
74
	$email_fromname = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "?", $recipient );
75
	$email_body = preg_replace( "/(content-type:|bcc:|cc:|from:)/im", "", $mail_message );
76

    
77
    $bSendRegistrationMailtoUser = $wb->mail($sServerEmail,$email_to,$email_subject,$email_body,$sWebMailer);
78
}
79

    
80
	$mail_replyto = $email_to;
81
	$mail_replyName = $sDisplayName;
82
	$mail_message = $MESSAGE['SIGNUP2_ADMIN_INFO'];
83
	$email_subject = $MESSAGE['SIGNUP2_NEW_USER'];
84
	$search = array('{LOGIN_EMAIL}','{LOGIN_ID}', '{SIGNUP_DATE}', '{LOGIN_NAME}', '{LOGIN_IP}');
85
	$replace = array($email_to, $email_fromname.' ('.$iUserId.')', date(DATE_FORMAT.' '.TIME_FORMAT,$get_ts ), $sLoginName, $sLoginIp);
86
	$mail_message = str_replace($search, $replace, $mail_message);
87
	$email_body = preg_replace( "/(content-type:|bcc:|cc:|to:|from:)/im", "", $mail_message );
88
	$success_email_to = emailAdmin();
89

    
90
	$bSendRegistrationMailtoAdmin = $wb->mail($sServerEmail,$success_email_to,$email_subject,$email_body,$mail_replyName,$mail_replyto);
91

    
92
	$output = '';
93
	msgQueue::clear();
94
	// success registration output
95
	$oTpl = new Template(dirname(__FILE__).'/htt','keep');
96
	$oTpl->set_file('page', 'success.htt');
97
	$oTpl->debug = false; // false, true
98
	$oTpl->set_block('page', 'main_block', 'main');
99
	// show messages, default block off
100
	$oTpl->set_block('main_block', 'show_registration_block', 'message');
101
	$oTpl->parse('message', '');
102
	if( ($msg = msgQueue::getSuccess()) != '')
103
	{
104
		$output = $wb->format_message($msg, 'ok');
105
		$oTpl->set_var('MESSAGE_VALUE',$output);
106
		$oTpl->parse('message', 'show_registration_block', true);
107
	}
108
	$oTpl->set_var(array(
109
			'BACK' => $TEXT['BACK'],
110
			'HTTP_REFERER' => isset($_SESSION['HTTP_REFERER']) ? $_SESSION['HTTP_REFERER'] : WB_URL.'/',
111
			)
112
		);
113

    
114
	if(CONFIRMED_REGISTRATION) {
115
		$sMessage  = $mLang->MESSAGE_SIGNUP2_SUBJECT_NEW_USER.'<br /> ';
116
		$sMessage .= $mLang->MESSAGE_ACTIVATED_NEW_USER;
117
		$oTpl->set_var('MESSAGE',$sMessage);
118
	} else {
119
		$sMessage  = $mLang->MESSAGE_SIGNUP2_SUBJECT_NEW_USER.' ';
120
		$sMessage .= $mLang->MESSAGE_SIGNUP_REGISTRATION;
121
		$oTpl->set_var('MESSAGE',$sMessage);
122
	}
123
	//$oTpl->parse('message', 'message_block', true);
124
	$oTpl->parse('main', 'main_block', false);
125
	$output = $oTpl->finish($oTpl->parse('output', 'page'));
126
	unset($oTpl);
127
	print $output;
(5-5/22)