blob: 674aa66e6042e16cea61953ecc873237a14202de (
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
|
<?php
abstract class Config
{
protected static $host;
protected static $dbname;
protected static $user;
protected static $password;
protected static $arttable;
protected static $domain;
protected static $admin;
protected static $editor;
protected static $invite;
protected static $read;
protected static $color4;
protected static $fontsize = 6;
// _______________________________________ F U N _______________________________________
public static function hydrate(array $donnees)
{
foreach ($donnees as $key => $value) {
$method = 'set' . $key;
if (method_exists(get_called_class(), $method)) {
self::$method($value);
}
}
}
public static function readconfig()
{
if (file_exists(Model::CONFIG_FILE)) {
$current = file_get_contents(Model::CONFIG_FILE);
$datas = json_decode($current, true);
self::hydrate($datas);
}
}
public static function createconfig(array $datas)
{
self::hydrate($datas);
}
public static function savejson()
{
$json = self::tojson();
file_put_contents(self::CONFIG_FILE, $json);
}
public static function tojson()
{
$arr = get_object_vars($this);
$json = json_encode($arr, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
return $json;
}
// ________________________________________ G E T _______________________________________
public static function host()
{
return self::$host;
}
public static function dbname()
{
return self::$dbname;
}
public static function user()
{
return self::$user;
}
public static function password()
{
return self::$password;
}
public static function arttable()
{
return self::$arttable;
}
public static function domain()
{
return self::$domain;
}
public static function admin()
{
return self::$admin;
}
public static function editor()
{
return self::$editor;
}
public static function invite()
{
return self::$invite;
}
public static function read()
{
return self::$read;
}
public static function color4()
{
return self::$color4;
}
public static function fontsize()
{
return self::$fontsize;
}
// __________________________________________ S E T ______________________________________
public static function sethost($host)
{
self::$host = strip_tags($host);
}
public static function setdbname($dbname)
{
self::$dbname = strip_tags($dbname);
}
public static function setuser($user)
{
self::$user = strip_tags($user);
}
public static function setpassword($password)
{
self::$password = strip_tags($password);
}
public static function setarttable($arttable)
{
self::$arttable = strip_tags($arttable);
}
public static function setdomain($domain)
{
self::$domain = strip_tags($domain);
}
public static function setadmin($admin)
{
self::$admin = strip_tags($admin);
}
public static function seteditor($editor)
{
self::$editor = strip_tags($editor);
}
public static function setinvite($invite)
{
self::$invite = strip_tags($invite);
}
public static function setread($read)
{
self::$read = strip_tags($read);
}
public static function setcolor4($color4)
{
if(strlen($color4) <= 8) {
self::$color4 = $color4;
}
}
public static function setfontsize($fontsize)
{
$fontsize = intval($fontsize);
if($fontsize > 1) {
self::$fontsize = $fontsize;
}
}
}
?>
|