summaryrefslogtreecommitdiffstats
path: root/inc/defaultdata.inc.php
blob: abc857bb9fcda272a23efb9866a1737d316a0b61 (plain) (blame)
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
<?php

/**
 * This class is supposed to fill the database with default entries (where required).
 * The insertion should be non-destructive, so if an entry already exists (and
 * possibly changed), it should be skipped.
 */
class DefaultData
{

	public static function populate()
	{
		self::addSettingCategories();
		self::addSettings();
	}

	/**
	 * Categories for basic system config / config variables
	 */
	private static function addSettingCategories()
	{
		$cats = array(
			0 => 20000, // Unassigned/no category
			1 => 30, // Inactivity/Shutdown
			2 => 20, // Internet access
			3 => 100, // Timesync
			4 => 10, // System config
			5 => 15, // Public Shared folder
		);
		foreach ($cats as $cat => $sort) {
			Database::exec("INSERT IGNORE INTO cat_setting (catid, sortval) VALUES (:catid, :sortval)", array(
				'catid' => $cat,
				'sortval' => $sort
			));
		}
	}

	/**
	 * Settings for basic system config
	 */
	private static function addSettings()
	{
		$data = array(
			array(
				'setting' => 'SLX_ADDONS',
				'catid' => '0',
				'defaultvalue' => 'vmware',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_BIOS_CLOCK',
				'catid' => '3',
				'defaultvalue' => 'off',
				'permissions' => '2',
				'validator' => 'list:off|local|utc'
			),
			array(
				'setting' => 'SLX_LOGOUT_TIMEOUT',
				'catid' => '1',
				'defaultvalue' => '1800',
				'permissions' => '2',
				'validator' => 'regex:/^\d*$/'
			),
			array(
				'setting' => 'SLX_NET_DOMAIN',
				'catid' => '2',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_NTP_SERVER',
				'catid' => '3',
				'defaultvalue' => '0.de.pool.ntp.org 1.de.pool.ntp.org',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_PROXY_BLACKLIST',
				'catid' => '2',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_PROXY_IP',
				'catid' => '2',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_PROXY_MODE',
				'catid' => '2',
				'defaultvalue' => 'off',
				'permissions' => '2',
				'validator' => 'list:off|on|auto'
			),
			array(
				'setting' => 'SLX_PROXY_PORT',
				'catid' => '2',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => 'regex:/^\d*$/'
			),
			array(
				'setting' => 'SLX_PROXY_TYPE',
				'catid' => '2',
				'defaultvalue' => 'socks5',
				'permissions' => '2',
				'validator' => ''
			),
			array(
				'setting' => 'SLX_REMOTE_LOG_SESSIONS',
				'catid' => '0',
				'defaultvalue' => 'anonymous',
				'permissions' => '2',
				'validator' => 'list:yes|anonymous|no'
			),
			array(
				'setting' => 'SLX_ROOT_PASS',
				'catid' => '4',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => 'function:linuxPassword'
			),
			array(
				'setting' => 'SLX_SHUTDOWN_SCHEDULE',
				'catid' => '1',
				'defaultvalue' => '22:10 00:00',
				'permissions' => '2',
				'validator' => 'regex:/^(\s*\d{1,2}:\d{1,2})*\s*$/'
			),
			array(
				'setting' => 'SLX_SHUTDOWN_TIMEOUT',
				'catid' => '1',
				'defaultvalue' => '1200',
				'permissions' => '2',
				'validator' => 'regex:/^\d*$/'
			),
			array(
				'setting' => 'SLX_COMMON_SHARE_PATH',
				'catid' => '5',
				'defaultvalue' => '',
				'permissions' => '2',
				'validator' => 'function:networkShare'
			),
			array(
				'setting' => 'SLX_COMMON_SHARE_AUTH',
				'catid' => '5',
				'defaultvalue' => 'guest',
				'permissions' => '2',
				'validator' => 'list:guest|user'
			),
		);
		foreach ($data as $entry) {
			Database::exec("INSERT IGNORE INTO setting (setting, catid, defaultvalue, permissions, validator)"
				. "VALUES (:setting, :catid, :defaultvalue, :permissions, :validator)", $entry);
		}
	}

}