aboutsummaryrefslogtreecommitdiff
path: root/app/class/config.php
blob: 7f18166fd67447a9572691a7320efaab7be106b6 (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
<?php



abstract class Config
{
	protected static $arttable = 'artstore';
	protected static $domain;
	protected static $admin;
	protected static $editor;
	protected static $invite;
	protected static $read;
	protected static $color4;
	protected static $fontsize = 6;
	protected static $cmspath = '';


// _______________________________________ F U N _______________________________________



	public static function hydrate(array $datas)
	{
		foreach ($datas 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);
			return true;
		} else {
			return false;
		}
	}

	public static function createconfig(array $datas)
	{
		self::hydrate($datas);
	}


	public static function savejson()
	{
		$json = self::tojson();
		return file_put_contents(Model::CONFIG_FILE, $json);
	}


	public static function tojson()
	{
		$arr = get_class_vars(__class__);
		$json = json_encode($arr, JSON_FORCE_OBJECT | JSON_PRETTY_PRINT);
		return $json;
	}

	public static function checkcmspath()
	{
		$path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . self::cmspath() . 'w' . DIRECTORY_SEPARATOR . 'w.config.json';
		return (file_exists($path));
	}

// ________________________________________ G E T _______________________________________

	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;
	}

	public static function cmspath()
	{
		return self::$cmspath;
	}



// __________________________________________ S E T ______________________________________

	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)
	{
		if(is_string($admin) && strlen($admin) >= 4 && strlen($admin) <= 64) {
			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;
		}
	}

	public static function setcmspath($cmspath)
	{
		self::$cmspath = strip_tags($cmspath);
	}




}









?>