Subversion Repositories ALCASAR

Rev

Rev 2994 | Rev 3000 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2994 Rev 2997
Line 31... Line 31...
31
		$tmp = explode('=', $buffer, 2);
31
		$tmp = explode('=', $buffer, 2);
32
		$mail_conf[trim($tmp[0])] = trim($tmp[1]);
32
		$mail_conf[trim($tmp[0])] = trim($tmp[1]);
33
	}
33
	}
34
}
34
}
35
fclose($file_conf);
35
fclose($file_conf);
36
 
-
 
37
$file_conf = fopen(CONF_FILE, 'r');
-
 
38
if (!$file_conf) {
-
 
39
	exit('Error opening the file '.CONF_FILE);
-
 
40
}
-
 
41
while (!feof($file_conf)) {
-
 
42
	$buffer = fgets($file_conf, 4096);
-
 
43
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
-
 
44
		$tmp = explode('=', $buffer, 2);
-
 
45
		$conf[trim($tmp[0])] = trim($tmp[1]);
-
 
46
	}
-
 
47
}
-
 
48
fclose($file_conf);
-
 
49
 
-
 
50
/****************************************
36
/****************************************
51
*			Choice of language			*
37
*			Choice of language			*
52
*****************************************/
38
*****************************************/
53
$Language = 'en';
39
$Language = 'en';
54
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
40
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
Line 64... Line 50...
64
	$l_use_email_address	= "Utiliser une adresse mail";
50
	$l_use_email_address	= "Utiliser une adresse mail";
65
	$l_email_address		= "Adresse mail utilisée pour l'envoi de mail";
51
	$l_email_address		= "Adresse mail utilisée pour l'envoi de mail";
66
	$l_email_password		= "Mot de passe";
52
	$l_email_password		= "Mot de passe";
67
	$l_email_password_confirm	= "Confirmez le mot de passe";
53
	$l_email_password_confirm	= "Confirmez le mot de passe";
68
	$l_mail_service			= "Choisissez le service de messagerie";
54
	$l_mail_service			= "Choisissez le service de messagerie";
-
 
55
	$l_mail_server_ip		= "Adresse IP du serveur SMTP";
-
 
56
	$l_admin_log			= "Avertissement de l'administratateur";
-
 
57
	$l_admin_mail			= "Adresse Email de l'administrateur";
-
 
58
	$l_whitelist_domain		= "Noms de domaine autorisés (whitelist)";
69
	$l_mail_YES				= "OUI";
59
	$l_mail_YES				= "OUI";
70
	$l_mail_NO				= "NON";
60
	$l_mail_NO				= "NON";
71
	$l_mail_submit			= "Enregistrer";
61
	$l_mail_submit			= "Enregistrer";
72
} else {
62
} else {
73
	$l_mail_title			= "Registration by Email";
63
	$l_mail_title			= "Registration by Email";
Line 78... Line 68...
78
	$l_email_address		= "Use an email address";
68
	$l_email_address		= "Use an email address";
79
	$l_email_address		= "Email address used for sending mail";
69
	$l_email_address		= "Email address used for sending mail";
80
	$l_email_password		= "Password";
70
	$l_email_password		= "Password";
81
	$l_email_password_confirm	= "Confirm password";
71
	$l_email_password_confirm	= "Confirm password";
82
	$l_mail_service			= "Choose the mail service";
72
	$l_mail_service			= "Choose the mail service";
-
 
73
	$l_mail_server_ip		= "IP address of mail server";
-
 
74
	$l_admin_log			= "Administrator's warning";
-
 
75
	$l_admin_mail			= "Administrator Email address";
-
 
76
	$l_whitelist_domain		= "Authorized domain names (whitelist)";
83
	$l_mail_YES				= "YES";
77
	$l_mail_YES				= "YES";
84
	$l_mail_NO				= "NO";
78
	$l_mail_NO				= "NO";
85
	$l_mail_submit			= "Save";
79
	$l_mail_submit			= "Save";
86
}
80
}
87
 
81
 
Line 99... Line 93...
99
$mail_whitelist			= $mail_conf['MAIL_WHITEDOMAIN'];
93
$mail_whitelist			= $mail_conf['MAIL_WHITEDOMAIN'];
100
 
94
 
101
if(isset($_POST['submit'])){
95
if(isset($_POST['submit'])){
102
	if($_POST['auth_enable'] === 'on')
96
	if($_POST['auth_enable'] === 'on')
103
	{
97
	{
104
//		exec("systemctl start postfix");
-
 
105
		$mail_type 		= $_POST['mail_type'];
98
		$mail_type 		= $_POST['mail_type'];
106
		$mail_address 	= $_POST['mail_address'];
99
		$mail_address 	= $_POST['mail_address'];
107
		$mail_ip 		= $_POST['mail_ip'];
-
 
108
		$mail_server 	= $_POST['mail_server'];
100
		$mail_server 	= $_POST['mail_server'];
-
 
101
		$mail_ip 		= $_POST['mail_ip'];
109
		$mail_mdp 		= $_POST['mail_mdp'];
102
		$mail_mdp 		= $_POST['mail_mdp'];
110
		$mail_mdp2 		= $_POST['mail_mdp2'];
103
		$mail_mdp2 		= $_POST['mail_mdp2'];
111
		$admin_enable	= $_POST['admin_enable'];
104
		$admin_enable	= $_POST['admin_enable'];
112
		$admin_address	= $_POST['admin_address'];
105
		$admin_address	= $_POST['admin_address'];
113
		$mail_whitelist	= $_POST['mail_whitelist'];
106
		$mail_whitelist	= $_POST['mail_whitelist'];
114
 
-
 
115
		if ($mail_mdp == $mail_mdp2) {
-
 
116
			switch ($mail_server) {
107
		switch ($mail_type) {
117
			case '1':
108
			case '1':
118
				$mail_smtp		= "smtp.orange.fr";
109
				$mail_port = 25;
119
				$mail_port		= 465;
110
				if(isset($mail_admin)){
-
 
111
					exec("sudo /usr/local/bin/alcasar-mail-install.sh -1 -a $admin_address -w $mail_whitelist");
-
 
112
				}
-
 
113
				else {
-
 
114
					exec("sudo /usr/local/bin/alcasar-mail-install.sh -1 -w $mail_whitelist");
-
 
115
				}
120
				break;
116
				break;
121
			case '2':
117
			case '2':
122
				$mail_smtp		= "smtp.live.com";
118
				if(isset($mail_admin)){
-
 
119
					exec("sudo /usr/local/bin/alcasar-mail-install.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -a $admin_address -w $mail_whitelist");
-
 
120
				}
123
				$mail_port		= 587;
121
				else {
-
 
122
					exec("sudo /usr/local/bin/alcasar-mail-install.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -w $mail_whitelist");
-
 
123
				}
124
				break;
124
				break;
125
			case '3':
125
			case '3':
126
				$mail_smtp		= "smtp.office365.com";
126
				if ($mail_mdp == $mail_mdp2) {
127
				$mail_port		= 587;
127
					switch ($mail_server) {
128
				break;
-
 
129
			case '4':
128
						case '1':
130
				$mail_smtp		= "smtp.sfr.fr";
129
							$mail_smtp		= "smtp.orange.fr";
131
				$mail_port		= 465;
130
							$mail_port		= 465;
132
				break;
131
						break;
133
			case '5':
132
						case '2':
134
				$mail_smtp		= "smtp.free.fr";
133
							$mail_smtp		= "smtp.live.com";
135
				$mail_port		= 465;	
134
							$mail_port		= 587;
136
				break;
135
						break;
137
			case '6':
136
						case '3':
138
				$mail_smtp		= "smtp.gmail.com";
137
							$mail_smtp		= "smtp.office365.com";
139
				$mail_port		= 587;
138
							$mail_port		= 587;
140
				break;
139
						break;
141
			case '7':
140
						case '4':
142
				$mail_smtp		= "smtp.laposte.net";
141
							$mail_smtp		= "smtp.sfr.fr";
143
				$mail_port		= 465;
142
							$mail_port		= 465;
144
				break;
143
						break;
145
			case '8':
144
						case '5':
146
				$mail_smtp		= "smtp.bbox.fr";
145
							$mail_smtp		= "smtp.free.fr";
147
				$mail_port		= 587;
146
							$mail_port		= 465;	
148
				break;
147
						break;
149
			default:
148
						case '6':
150
				echo "Erreur dans la saisie !";
149
							$mail_smtp		= "smtp.gmail.com";
-
 
150
							$mail_port		= 587;
151
				break;
151
						break;
152
			}
152
						case '7':
153
			file_put_contents(CONF_FILE, str_replace('MAIL='.$mail_conf['MAIL'],'MAIL=on',file_get_contents(CONF_FILE)));
153
							$mail_smtp		= "smtp.laposte.net";
154
			file_put_contents(CONF_FILE, str_replace('MAIL_TYPE='.$mail_conf['MAIL_TYPE'],'MAIL_TYPE='.$mail_type,file_get_contents(CONF_FILE)));
-
 
155
			file_put_contents(CONF_FILE, str_replace('MAIL_ADDR='.$mail_conf['MAIL_ADDR'],'MAIL_ADDR='.$mail_address,file_get_contents(CONF_FILE)));
-
 
156
			file_put_contents(CONF_FILE, str_replace('MAIL_SMTP_IP='.$mail_conf['MAIL_SMTP_IP'],'MAIL_SMTP_IP='.$mail_ip,file_get_contents(CONF_FILE)));
-
 
157
			file_put_contents(CONF_FILE, str_replace('MAIL_SMTP='.$mail_conf['MAIL_SMTP'],'MAIL_SMTP='.$mail_smtp,file_get_contents(CONF_FILE)));
-
 
158
			file_put_contents(CONF_FILE, str_replace('MAIL_PORT='.$mail_conf['MAIL_PORT'],'MAIL_PORT='.$mail_port,file_get_contents(CONF_FILE)));
-
 
159
			file_put_contents(CONF_FILE, str_replace('MAIL_WHITEDOMAIN='.$mail_conf['MAIL_WHITEDOMAIN'],'MAIL_WHITEDOMAIN='.$mail_whitelist,file_get_contents(CONF_FILE)));
-
 
160
			if (isset($admin_address)) {
154
							$mail_port		= 465;
161
				file_put_contents(CONF_FILE, str_replace('MAIL_ADMIN='.$mail_conf['MAIL_ADMIN'],'MAIL_ADMIN='.$admin_address,file_get_contents(CONF_FILE)));
-
 
162
			}
155
						break;
163
			switch ($mail_type) {
-
 
164
				case '1':
156
						case '8':
165
					$mail_port = 25;
157
							$mail_smtp		= "smtp.bbox.fr";
166
					file_put_contents(CONF_FILE, str_replace('port='.$mail_conf['port'],'port='.$mail_port,file_get_contents(CONF_FILE)));
-
 
167
					if(isset($mail_admin)){
158
							$mail_port		= 587;
168
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -1 -a $admin_address -w $mail_whitelist");
-
 
169
					}
159
						break;
170
					else {
160
						default:
171
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -1 -w $mail_whitelist");
161
							echo "Erreur dans la saisie !";
172
					}
-
 
173
					break;
162
						break;
174
				case '2':
-
 
175
					if(isset($mail_admin)){
-
 
176
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -a $admin_address -w $mail_whitelist");
-
 
177
					}
163
					}
178
					else {
-
 
179
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -2 -s $mail_smtp -p $mail_port -r $mail_ip -w $mail_whitelist");
-
 
180
					}
-
 
181
					break;
-
 
182
				case '3':
-
 
183
					if(isset($mail_admin)){
164
					if(isset($mail_admin)){
184
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -a $admin_address -w $mail_whitelist");
165
						exec("sudo /usr/local/bin/alcasar-mail-install.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -a $admin_address -w $mail_whitelist");
185
					}
166
					}
186
					else {
167
					else {
187
						exec("sudo /usr/bin/bash /usr/local/bin/alcasar-mail-install.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -w $mail_whitelist");
168
						exec("sudo /usr/local/bin/alcasar-mail-install.sh -3 -s $mail_smtp -p $mail_port -m $mail_address -o $mail_mdp -w $mail_whitelist");
188
					}
169
					}
189
					break;
170
				}
190
				default:
-
 
191
					echo "Erreur dans la saisie !";
171
				else { // password are not the same
192
					break;
172
					echo "Erreur";
193
			}
173
				}
194
		}
174
				break;
-
 
175
			default:
195
		else { // password are not the same
176
				echo "Erreur dans la saisie !";
196
			echo "Erreur";
177
				break;
197
		}
178
		}
198
	}
179
	}
199
	else { // switch email registation off
180
	else { // switch email registation off
200
		exec("sudo /usr/local/bin/alcasar-mail-install.sh -0");
181
		exec("sudo /usr/local/bin/alcasar-mail-install.sh -0");
201
	}
182
	}
Line 300... Line 281...
300
						<dt>
281
						<dt>
301
							<label for="auth_enable"><?= $l_mail_registration ?></label>
282
							<label for="auth_enable"><?= $l_mail_registration ?></label>
302
						</dt>
283
						</dt>
303
						<dd>
284
						<dd>
304
							<select id="auth_enable" name="auth_enable" onchange="onMailStatusChange();">
285
							<select id="auth_enable" name="auth_enable" onchange="onMailStatusChange();">
305
								<option value="on"<?= ($mail_status == 'on')  ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option>
286
								<option value="on"<?= ($mail_status == 'on') ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option>
306
								<option value="off"<?= ($mail_status == 'off') ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option>
287
								<option value="off"<?= ($mail_status == 'off') ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option>
307
							</select>
288
							</select>
308
						</dd>
289
						</dd>
309
					</dl>
290
					</dl>
310
					<dl>
291
					<dl>
311
						<dt>
292
						<dt>
312
							<label for="mail_type"><?= $l_mail_choice ?></label><br>
293
							<label for="mail_type"><?= $l_mail_choice ?></label><br>
313
						</dt>
294
						</dt>
314
						<dd>
295
						<dd>
315
							<select id="mail_type" name="mail_type" onchange="onMailStatusChange();">
296
							<select id="mail_type" name="mail_type" onchange="onMailStatusChange();">
316
								<option value=1><?= $l_use_internal_server ?></option>
297
								<option value="1"<?= ($mail_type == '1') ? ' selected="selected"' : '' ?>><?= $l_use_internal_server ?></option>
317
								<option value=2><?= $l_use_external_server ?></option>
298
								<option value="2"<?= ($mail_type == '2') ? ' selected="selected"' : '' ?>><?= $l_use_external_server ?></option>
318
								<option value=3><?= $l_use_email_address ?></option>
299
								<option value="3"<?= ($mail_type == '3') ? ' selected="selected"' : '' ?>><?= $l_use_email_address ?></option>
319
							</select>
300
							</select>
320
						</dd>
301
						</dd>
321
					</dl>
302
					</dl>
322
					<dl>
303
					<dl>
323
						<dt>
304
						<dt>
Line 361... Line 342...
361
							</select>
342
							</select>
362
						</dd>
343
						</dd>
363
					</dl>
344
					</dl>
364
					<dl>
345
					<dl>
365
						<dt>
346
						<dt>
366
							<label for="mail_ip"><?= "IP du serveur SMTP"?></label><br>
347
							<label for="mail_ip"><?= $l_mail_server_ip ?></label><br>
367
							<?= "Adresse IP du serveur SMTP utilisé" ?>
-
 
368
						</dt>
348
						</dt>
369
						<dd>
349
						<dd>
370
							<input type="text" id="mail_ip" size="40" name="mail_ip" value="<?= $mail_address_ip ?>" oninput="onMailStatusChange();"> 
350
							<input type="text" id="mail_ip" size="40" name="mail_ip" value="<?= $mail_address_ip ?>" oninput="onMailStatusChange();"> 
371
						</dd>
351
						</dd>
372
					</dl>
352
					</dl>
373
					<dl>
353
					<dl>
374
						<dt>
354
						<dt>
375
							<label for="admin_enable"><?= "Activer l'adresse admin :" ?></label>
355
							<label for="admin_enable"><?= $l_admin_log ?></label>
376
						</dt>
356
						</dt>
377
						<dd>
357
						<dd>
378
							<select id="admin_enable" name="admin_enable" onchange="onMailStatusChange();">
358
							<select id="admin_enable" name="admin_enable" onchange="onMailStatusChange();">
379
								<option value="1"<?= ($mail_status)  ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option>
359
								<option value="1"<?= ($mail_address != '')  ? ' selected="selected"' : '' ?>><?= $l_mail_YES ?></option>
380
								<option value="0"<?= (!$mail_status) ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option>
360
								<option value="0"<?= ($mail_address == '') ? ' selected="selected"' : '' ?>><?= $l_mail_NO ?></option>
381
							</select>
361
							</select>
382
						</dd>
362
						</dd>
383
					</dl>
363
					</dl>
384
					<dl>
364
					<dl>
385
						<dt>
365
						<dt>
386
							<label for="admin_address"><?= "Adresse Messagerie admin"?></label><br>
366
							<label for="admin_address"><?= $l_admin_mail ?></label><br>
387
							<?= "Adresse de messagerie utilisé pour l'envoi" ?>
-
 
388
						</dt>
367
						</dt>
389
						<dd>
368
						<dd>
390
							<input type="text" id="admin_address" size="40" name="admin_address" value="<?= $admin_address ?>" oninput="onMailStatusChange();"> 
369
							<input type="text" id="admin_address" size="40" name="admin_address" value="<?= $admin_address ?>" oninput="onMailStatusChange();"> 
391
						</dd>
370
						</dd>
392
					</dl>
371
					</dl>
393
					<dl>
372
					<dl>
394
						<dt>
373
						<dt>
395
							<label for="mail_whitelist"><?= "whitelist domaine"?></label><br>
374
							<label for="mail_whitelist"><?= $l_whitelist_domain ?></label><br>
396
							<?= "Adresse de messagerie utilisé pour l'envoi" ?>
-
 
397
						</dt>
375
						</dt>
398
						<dd>
376
						<dd>
399
							<input type="text" id="mail_whitelist" size="40" name="mail_whitelist" value="<?= $mail_whitelist ?>" oninput="onMailStatusChange();"> 
377
							<input type="text" id="mail_whitelist" size="40" name="mail_whitelist" value="<?= $mail_whitelist ?>" oninput="onMailStatusChange();"> 
400
						</dd>
378
						</dd>
401
					</dl>
379
					</dl>