/
Settings.cs
executable file
·239 lines (207 loc) · 6.89 KB
/
Settings.cs
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
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using KioServ;
namespace Settings
{
class Apache
{
private static bool started;
public static bool Started
{
set
{
started = value;
Ini.Set("apache", "started", started ? "1" : "0");
Ini.SaveToFile();
}
get { return Ini.Get("apache", "started") == "1" ? true : false; }
}
private static string documentRoot;
public static string DocumentRoot
{
set { documentRoot = value; }
get { return Ini.Get("apache", "documentRoot"); }
}
private static string port;
public static string Port
{
set { port = value; }
get { return Ini.Get("apache", "port"); }
}
public static void UpdateConfigFile()
{
string s = File.ReadAllText(@"settings\httpd.conf");
string lol = Settings.Apache.DocumentRoot[1] == ':'
? DocumentRoot
: Kio.Path + "/" + DocumentRoot;
s = s.Replace("{documentRoot}", lol);
s = s.Replace("{port}", Port);
s = s.Replace("{path}", Kio.Path);
s = s.Replace("{phpVersion}", Php.Version);
File.WriteAllText(@"apache\conf\httpd.conf", s);
}
}
class MySql
{
private static bool started;
public static bool Started
{
set
{
started = value;
Ini.Set("mysql", "started", started ? "1" : "0");
Ini.SaveToFile();
}
get { return Ini.Get("mysql", "started") == "1" ? true : false; }
}
private static string port;
public static string Port
{
set { port = value; }
get { return Ini.Get("mysql", "port"); }
}
public static void UpdateConfigFile()
{
string s = File.ReadAllText(@"settings\my.ini");
s = s.Replace("{port}", Port);
File.WriteAllText(@"mysql\my.ini", s);
}
}
class PostgreSql
{
private static bool started;
public static bool Started
{
set
{
started = value;
Ini.Set("postgresql", "started", started ? "1" : "0");
Ini.SaveToFile();
}
get { return Ini.Get("postgresql", "started") == "1" ? true : false; }
}
private static string port;
public static string Port
{
set { port = value; }
get { return Ini.Get("postgresql", "port"); }
}
public static void UpdateConfigFile()
{
string s = File.ReadAllText("pgsql/data/postgresql.conf");
s = s.Replace("{port}", Port);
File.WriteAllText("pgsql/data/postgresql.conf", s);
}
}
class Php
{
//public static string SafeMode = Ini.Get("php", "safeMode");
//public static string RegisterGlobals = Ini.Get("php", "registerGlobals");
private static string version;
public static string Version
{
set { version = value; }
get { return Ini.Get("php", "version"); }
}
public static void UpdateConfigFile()
{
string s = File.ReadAllText(@"settings\php.ini");
s = s.Replace("{phpVersion}", Version);
s = s.Replace("{path}", Kio.Path);
s = s.Replace("{mySqlPort}", MySql.Port);
File.WriteAllText(@"php\" + Settings.Php.Version + @"\php.ini", s);
}
}
class App
{
private static bool hideAtStartup;
public static bool HideAtStartup
{
set { hideAtStartup = value; }
get { return Ini.Get("app", "hideAtStartup") != "1" ? false : true; }
}
private static string lang;
public static string Lang
{
set { lang = value; }
get { return Ini.Get("app", "lang"); }
}
private static int lMouseButton;
public static int LMouseButton
{
set { lMouseButton = value; }
get { return Convert.ToInt16(Ini.Get("app", "lMouseButton")); }
}
private static string lMouseButtonPath;
public static string LMouseButtonPath
{
set { lMouseButtonPath = value; }
get { return Ini.Get("app", "lMouseButtonPath"); }
}
private static int rMouseButton;
public static int RMouseButton
{
set { rMouseButton = value; }
get { return Convert.ToInt16(Ini.Get("app", "rMouseButton")); }
}
private static string rMouseButtonPath;
public static string RMouseButtonPath
{
set { rMouseButtonPath = value; }
get { return Ini.Get("app", "rMouseButtonPath"); }
}
private static int mMouseButton;
public static int MMouseButton
{
set { mMouseButton = value; }
get { return Convert.ToInt16(Ini.Get("app", "mMouseButton")); }
}
private static string mMouseButtonPath;
public static string MMouseButtonPath
{
set { mMouseButtonPath = value; }
get { return Ini.Get("app", "mMouseButtonPath"); }
}
private static int locationX;
public static int LocationX
{
set { locationX = value; }
get { return Convert.ToInt16(Ini.Get("app", "locationX")); }
}
private static int locationY;
public static int LocationY
{
set { locationY = value; }
get { return Convert.ToInt16(Ini.Get("app", "locationY")); }
}
}
class Ini
{
public static IniParser File = new IniParser(@"settings\kioserv.ini");
public static string Get(string sectionName, string settingName)
{
return File.GetSetting(sectionName, settingName);
}
public static void Set(string sectionName, string settingName, string settingValue)
{
File.AddSetting(sectionName, settingName, settingValue);
}
public static void SaveToFile()
{
File.SaveSettings();
File = null;
File = new IniParser(@"settings\kioserv.ini");
}
public static void SaveToFile(string newFilePath)
{
File.SaveSettings(newFilePath);
File = null;
File = new IniParser(@"settings\kioserv.ini");
}
public static void ReadAll()
{
}
}
}