summaryrefslogtreecommitdiff
blob: ff64f200ab3ce2a1d14e674f60f8b24ee040056a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php
/**
 * filename: $Source: /syscp/syscp/admin_configfiles.php,v $
 * begin: Wednesday, Sep 08, 2004
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. This program is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * @author Florian Lippert <flo@redenswert.de>
 * @copyright (C) 2003-2004 Florian Lippert
 * @package Panel
 * @version $Id: admin_configfiles.php,v 1.9 2005/06/15 13:53:58 flo Exp $
 * Modified to reflect the Gentoo environment by Luca Longinotti <chtekk@gentoo.org>
 */

	define('AREA', 'admin');

	/**
	 * Include our init.php, which manages Sessions, Language etc.
	 */
	require("./lib/init.php");


	$configfiles = Array
	(
		'gentoo' => Array
		(
			'label' => 'Gentoo',
			'daemons' => Array
			(
				'apache' => Array
				(
					'label' => 'Apache2 Webserver (HTTP)',
					'commands' => Array
					(
						'touch '.$settings['system']['apacheconf_directory'].'vhosts.d/99_syscp-vhosts.conf',
						'chown root:0 '.$settings['system']['apacheconf_directory'].'vhosts.d/99_syscp-vhosts.conf',
						'chmod 0600 '.$settings['system']['apacheconf_directory'].'vhosts.d/99_syscp-vhosts.conf',
						'echo "Include '.$settings['system']['apacheconf_directory'].'vhosts.d/99_syscp-vhosts.conf" >> /etc/apache2/httpd.conf',
						'mkdir -p '.$settings['system']['documentroot_prefix'],
						'mkdir -p '.$settings['system']['logfiles_directory']
					),
					'restart' => Array
					(
						'rc-update add apache2 default',
						'/etc/init.d/apache2 restart'
					)
				),
				'bind' => Array
				(
					'label' => 'Bind9 Nameserver (DNS)',
					'files' => Array
					(
						'etc_bind_default.zone' => '/etc/bind/default.zone'
					),
					'commands' => Array
					(
						'echo "include \"'.$settings['system']['bindconf_directory'].'syscp_bind.conf\";" >> /etc/bind/named.conf',
						'touch '.$settings['system']['bindconf_directory'].'syscp_bind.conf',
						'chown root:0 '.$settings['system']['bindconf_directory'].'syscp_bind.conf',
						'chmod 0600 '.$settings['system']['bindconf_directory'].'syscp_bind.conf'
					),
					'restart' => Array
					(
						'rc-update add named default',
						'/etc/init.d/named restart'
					)
				),
				'courier' => Array
				(
					'label' => 'Courier-IMAP (POP3/IMAP)',
					'files' => Array
					(
						'etc_courier_authlib_authdaemonrc' => '/etc/courier/authlib/authdaemonrc',
						'etc_courier_authlib_authmysqlrc' => '/etc/courier/authlib/authmysqlrc',
						'etc_courier-imap_pop3d' => '/etc/courier-imap/pop3d',
						'etc_courier-imap_imapd' => '/etc/courier-imap/imapd',
						'etc_courier-imap_pop3d-ssl' => '/etc/courier-imap/pop3d-ssl',
						'etc_courier-imap_imapd-ssl' => '/etc/courier-imap/imapd-ssl'
					),
					'commands' => Array
					(
						'rm /etc/courier/authlib/authdaemonrc',
						'rm /etc/courier/authlib/authmysqlrc',
						'rm /etc/courier-imap/pop3d',
						'rm /etc/courier-imap/imapd',
						'rm /etc/courier-imap/pop3d-ssl',
						'rm /etc/courier-imap/imapd-ssl',
						'touch /etc/courier/authlib/authdaemonrc',
						'touch /etc/courier/authlib/authmysqlrc',
						'touch /etc/courier-imap/pop3d',
						'touch /etc/courier-imap/imapd',
						'touch /etc/courier-imap/pop3d-ssl',
						'touch /etc/courier-imap/imapd-ssl',
						'chown root:0 /etc/courier/authlib/authdaemonrc',
						'chown root:0 /etc/courier/authlib/authmysqlrc',
						'chown root:0 /etc/courier-imap/pop3d',
						'chown root:0 /etc/courier-imap/imapd',
						'chown root:0 /etc/courier-imap/pop3d-ssl',
						'chown root:0 /etc/courier-imap/imapd-ssl',
						'chmod 0600 /etc/courier/authlib/authdaemonrc',
						'chmod 0600 /etc/courier/authlib/authmysqlrc',
						'chmod 0600 /etc/courier-imap/pop3d',
						'chmod 0600 /etc/courier-imap/imapd',
						'chmod 0600 /etc/courier-imap/pop3d-ssl',
						'chmod 0600 /etc/courier-imap/imapd-ssl'
					),
					'restart' => Array
					(
						'rc-update add courier-authlib default',
						'rc-update add courier-pop3d default',
						'rc-update add courier-imapd default',
						'/etc/init.d/courier-authlib restart',
						'/etc/init.d/courier-pop3d restart',
						'/etc/init.d/courier-imapd restart'
					)
				),
				'postfix' => Array
				(
					'label' => 'Postfix (MTA)',
					'files' => Array
					(
						'etc_postfix_main.cf' => '/etc/postfix/main.cf',
						'etc_postfix_mysql-virtual_alias_maps.cf' => '/etc/postfix/mysql-virtual_alias_maps.cf',
						'etc_postfix_mysql-virtual_mailbox_domains.cf' => '/etc/postfix/mysql-virtual_mailbox_domains.cf',
						'etc_postfix_mysql-virtual_mailbox_maps.cf' => '/etc/postfix/mysql-virtual_mailbox_maps.cf',
						'etc_sasl2_smtpd.conf' => '/etc/sasl2/smtpd.conf'
					),
					'commands' => Array
					(
						'mkdir -p '.$settings['system']['vmail_homedir'],
						'chown -R vmail:vmail '.$settings['system']['vmail_homedir'],
						'chmod 0750 '.$settings['system']['vmail_homedir'],
						'rm /etc/postfix/main.cf',
						'touch /etc/postfix/main.cf',
						'touch /etc/postfix/master.cf',
						'touch /etc/postfix/mysql-virtual_alias_maps.cf',
						'touch /etc/postfix/mysql-virtual_mailbox_domains.cf',
						'touch /etc/postfix/mysql-virtual_mailbox_maps.cf',
						'touch /etc/sasl2/smtpd.conf',
						'chown root:0 /etc/postfix/main.cf',
						'chown root:0 /etc/postfix/master.cf',
						'chown root:postfix /etc/postfix/mysql-virtual_alias_maps.cf',
						'chown root:postfix /etc/postfix/mysql-virtual_mailbox_domains.cf',
						'chown root:postfix /etc/postfix/mysql-virtual_mailbox_maps.cf',
						'chown root:0 /etc/sasl2/smtpd.conf',
						'chmod 0600 /etc/postfix/main.cf',
						'chmod 0600 /etc/postfix/master.cf',
						'chmod 0640 /etc/postfix/mysql-virtual_alias_maps.cf',
						'chmod 0640 /etc/postfix/mysql-virtual_mailbox_domains.cf',
						'chmod 0640 /etc/postfix/mysql-virtual_mailbox_maps.cf',
						'chmod 0600 /etc/sasl2/smtpd.conf'
					),
					'restart' => Array
					(
						'rc-update add postfix default',
						'/etc/init.d/postfix restart'
					)
				),
				'proftpd' => Array
				(
					'label' => 'ProFTPd (FTP)',
					'files' => Array
					(
						'etc_proftpd_proftpd.conf' => '/etc/proftpd/proftpd.conf'
					),
					'commands' => Array
					(
					'touch /etc/proftpd/proftpd.conf',
					'chown root:0 /etc/proftpd/proftpd.conf',
					'chmod 0600 /etc/proftpd/proftpd.conf'
					),
					'restart' => Array
					(
						'rc-update add proftpd default',
						'/etc/init.d/proftpd restart'
					)
				),
				'cron' => Array
				(
					'label' => 'Crond (cronscript)',
					'files' => Array
					(
						'etc_php_syscp-cronjob_php.ini' => '/etc/php/syscp-cronjob/php.ini',
						'etc_cron.d_syscp' => '/etc/cron.d/syscp'
					),
					'commands' => Array
					(
						'touch /etc/cron.d/syscp',
						'chown root:0 /etc/cron.d/syscp',
						'chmod 0640 /etc/cron.d/syscp',
						'mkdir -p /etc/php/syscp-cronjob',
						'touch /etc/php/syscp-cronjob/php.ini',
						'chown -R root:0 /etc/php/syscp-cronjob',
						'chmod 0750 /etc/php/syscp-cronjob',
						'chmod 0640 /etc/php/syscp-cronjob/php.ini'
					),
					'restart' => Array
					(
						'rc-update add vixie-cron default',
						'/etc/init.d/vixie-cron restart'
					)
				)
			)
		)
	);

	/*echo '<pre>';
	print_r($configfiles);
	echo '</pre>';*/

	if( ($page == 'configfiles' || $page == 'overview') && $userinfo['change_serversettings'] == '1')
	{
		if(isset($_GET['distribution']) && $_GET['distribution']!='' && isset($configfiles[$_GET['distribution']]) && is_array($configfiles[$_GET['distribution']]) &&
		   isset($_GET['daemon']) && $_GET['daemon']!='' && isset($configfiles[$_GET['distribution']]['daemons'][$_GET['daemon']]) && is_array($configfiles[$_GET['distribution']]['daemons'][$_GET['daemon']]))
		{
			$distribution = addslashes($_GET['distribution']);
			$daemon = addslashes($_GET['daemon']);

			if(isset($configfiles[$distribution]['daemons'][$daemon]['commands']) && is_array($configfiles[$distribution]['daemons'][$daemon]['commands']))
			{
				$commands = implode("\n", $configfiles[$distribution]['daemons'][$daemon]['commands']);
			}
			else
			{
				$commands = '';
			}

			$replace_arr = Array
			(
				'<SQL_UNPRIVILEGED_USER>' => $sql['user'],
				'<SQL_UNPRIVILEGED_PASSWORD>' => 'MYSQL_PASSWORD',
				'<SQL_DB>' => $sql['db'], 
				'<SQL_HOST>' => $sql['host'],
				'<SERVERNAME>' => $settings['system']['hostname'],
				'<SERVERIP>' => $settings['system']['ipaddress'],
				'<VIRTUAL_MAILBOX_BASE>' => $settings['system']['vmail_homedir'],
				'<VIRTUAL_UID_MAPS>' => $settings['system']['vmail_uid'],
				'<VIRTUAL_GID_MAPS>' => $settings['system']['vmail_gid']
			);
			$files = '';
			if(isset($configfiles[$distribution]['daemons'][$daemon]['files']) && is_array($configfiles[$distribution]['daemons'][$daemon]['files']))
			{
				while(list($filename, $realname) = each($configfiles[$distribution]['daemons'][$daemon]['files']))
				{
					$file_content = implode('', file('./templates/misc/configfiles/'.$distribution.'/'.$daemon.'/'.$filename));
					$file_content = strtr($file_content, $replace_arr);
					$file_content = htmlspecialchars($file_content);
					$numbrows = count(explode("\n", $file_content));
					eval("\$files.=\"".getTemplate("configfiles/configfiles_file")."\";");
				}
			}

			if(isset($configfiles[$distribution]['daemons'][$daemon]['restart']) && is_array($configfiles[$distribution]['daemons'][$daemon]['restart']))
			{
				$restart = implode("\n", $configfiles[$distribution]['daemons'][$daemon]['restart']);
			}
			else
			{
				$restart = '';
			}

			eval("echo \"".getTemplate("configfiles/configfiles")."\";");
		}
		else
		{
			$distributions = '';
			while (list($distribution_name, $distribution_details) = each($configfiles))
			{
				$daemons = '';
				while(list($daemon_name, $daemon_details) = each($distribution_details['daemons']))
				{
					eval("\$daemons.=\"".getTemplate("configfiles/choose_daemon")."\";");
				}
				eval("\$distributions.=\"".getTemplate("configfiles/choose_distribution")."\";");
			}
			eval("echo \"".getTemplate("configfiles/choose")."\";");
		}
	}

?>