1
|
|
|
<?php namespace EvolutionCMS\Legacy; |
2
|
|
|
|
3
|
|
|
use EvolutionCMS\Interfaces\DeprecatedCoreInterface; |
4
|
|
|
|
5
|
|
|
class DeprecatedCore implements DeprecatedCoreInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @deprecated |
9
|
|
|
* |
10
|
|
|
* return @void |
11
|
|
|
*/ |
12
|
|
|
public function dbConnect() |
13
|
|
|
{ |
14
|
|
|
$modx = evolutionCMS(); |
15
|
|
|
$modx->getDatabase()->connect(); |
16
|
|
|
$modx->rs = $modx->getDatabase()->conn; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @deprecated |
21
|
|
|
* |
22
|
|
|
* @param $sql |
23
|
|
|
* @return bool|mysqli_result|resource |
|
|
|
|
24
|
|
|
*/ |
25
|
|
|
public function dbQuery($sql) |
26
|
|
|
{ |
27
|
|
|
$modx = evolutionCMS(); |
28
|
|
|
|
29
|
|
|
return $modx->getDatabase()->query($sql); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @deprecated |
34
|
|
|
* |
35
|
|
|
* @param $rs |
36
|
|
|
* @return int |
37
|
|
|
*/ |
38
|
|
|
public function recordCount($rs) |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$modx = evolutionCMS(); |
41
|
|
|
|
42
|
|
|
return $modx->getDatabase()->getRecordCount($rs); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @deprecated |
47
|
|
|
* |
48
|
|
|
* @param $rs |
49
|
|
|
* @param string $mode |
50
|
|
|
* @return array|bool|mixed|object|stdClass |
51
|
|
|
*/ |
52
|
|
|
public function fetchRow($rs, $mode = 'assoc') |
|
|
|
|
53
|
|
|
{ |
54
|
|
|
$modx = evolutionCMS(); |
55
|
|
|
|
56
|
|
|
return $modx->getDatabase()->getRow($rs, $mode); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @deprecated |
61
|
|
|
* |
62
|
|
|
* @param $rs |
63
|
|
|
* @return int |
64
|
|
|
*/ |
65
|
|
|
public function affectedRows($rs) |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
$modx = evolutionCMS(); |
68
|
|
|
|
69
|
|
|
return $modx->getDatabase()->getAffectedRows($rs); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @deprecated |
74
|
|
|
* |
75
|
|
|
* @param $rs |
76
|
|
|
* @return int|mixed |
77
|
|
|
*/ |
78
|
|
|
public function insertId($rs) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
$modx = evolutionCMS(); |
81
|
|
|
|
82
|
|
|
return $modx->getDatabase()->getInsertId($rs); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @deprecated |
87
|
|
|
* |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
public function dbClose() |
91
|
|
|
{ |
92
|
|
|
$modx = evolutionCMS(); |
93
|
|
|
$modx->getDatabase()->disconnect(); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @deprecated |
98
|
|
|
* |
99
|
|
|
* @param array $array |
100
|
|
|
* @param string $ulroot |
101
|
|
|
* @param string $ulprefix |
102
|
|
|
* @param string $type |
103
|
|
|
* @param bool $ordered |
104
|
|
|
* @param int $tablevel |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function makeList($array, $ulroot = 'root', $ulprefix = 'sub_', $type = '', $ordered = false, $tablevel = 0) |
108
|
|
|
{ |
109
|
|
|
// first find out whether the value passed is an array |
110
|
|
|
if (!is_array($array)) { |
111
|
|
|
return "<ul><li>Bad list</li></ul>"; |
112
|
|
|
} |
113
|
|
|
if (!empty ($type)) { |
114
|
|
|
$typestr = " style='list-style-type: $type'"; |
115
|
|
|
} else { |
116
|
|
|
$typestr = ""; |
117
|
|
|
} |
118
|
|
|
$tabs = ""; |
119
|
|
|
for ($i = 0; $i < $tablevel; $i++) { |
120
|
|
|
$tabs .= "\t"; |
121
|
|
|
} |
122
|
|
|
$listhtml = $ordered == true ? $tabs . "<ol class='$ulroot'$typestr>\n" : $tabs . "<ul class='$ulroot'$typestr>\n"; |
|
|
|
|
123
|
|
|
foreach ($array as $key => $value) { |
124
|
|
|
if (is_array($value)) { |
125
|
|
|
$listhtml .= $tabs . "\t<li>" . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, |
|
|
|
|
126
|
|
|
$type, $ordered, $tablevel + 2) . $tabs . "\t</li>\n"; |
127
|
|
|
} else { |
128
|
|
|
$listhtml .= $tabs . "\t<li>" . $value . "</li>\n"; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
$listhtml .= $ordered == true ? $tabs . "</ol>\n" : $tabs . "</ul>\n"; |
|
|
|
|
132
|
|
|
|
133
|
|
|
return $listhtml; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @deprecated |
138
|
|
|
* |
139
|
|
|
* @return array |
140
|
|
|
*/ |
141
|
|
|
public function getUserData() |
|
|
|
|
142
|
|
|
{ |
143
|
|
|
$client = array(); |
144
|
|
|
$client['ip'] = $_SERVER['REMOTE_ADDR']; |
145
|
|
|
$client['ua'] = $_SERVER['HTTP_USER_AGENT']; |
146
|
|
|
|
147
|
|
|
return $client; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Returns true, install or interact when inside manager |
152
|
|
|
* |
153
|
|
|
* @deprecated |
154
|
|
|
* |
155
|
|
|
* @return bool|string |
156
|
|
|
*/ |
157
|
|
|
public function insideManager() |
158
|
|
|
{ |
159
|
|
|
$m = false; |
|
|
|
|
160
|
|
|
if (defined('IN_MANAGER_MODE') && IN_MANAGER_MODE === true) { |
161
|
|
|
$m = true; |
162
|
|
|
if (defined('SNIPPET_INTERACTIVE_MODE') && SNIPPET_INTERACTIVE_MODE == 'true') { |
163
|
|
|
$m = "interact"; |
164
|
|
|
} else { |
165
|
|
|
if (defined('SNIPPET_INSTALL_MODE') && SNIPPET_INSTALL_MODE == 'true') { |
166
|
|
|
$m = "install"; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
return $m; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @deprecated |
176
|
|
|
* |
177
|
|
|
* @param $chunkName |
178
|
|
|
* @return bool|string |
179
|
|
|
*/ |
180
|
|
|
public function putChunk($chunkName) |
181
|
|
|
{ // alias name >.< |
182
|
|
|
$modx = evolutionCMS(); |
183
|
|
|
|
184
|
|
|
return $modx->getChunk($chunkName); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @deprecated |
189
|
|
|
* |
190
|
|
|
* @return array|string |
191
|
|
|
*/ |
192
|
|
|
public function getDocGroups() |
193
|
|
|
{ |
194
|
|
|
$modx = evolutionCMS(); |
195
|
|
|
|
196
|
|
|
return $modx->getUserDocGroups(); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @deprecated |
201
|
|
|
* |
202
|
|
|
* @param string $o |
203
|
|
|
* @param string $n |
204
|
|
|
* @return bool|string |
205
|
|
|
*/ |
206
|
|
|
public function changePassword($o, $n) |
|
|
|
|
207
|
|
|
{ |
208
|
|
|
$modx = evolutionCMS(); |
209
|
|
|
|
210
|
|
|
return $modx->changeWebUserPassword($o, $n); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @deprecated |
215
|
|
|
* |
216
|
|
|
* @return array|bool |
|
|
|
|
217
|
|
|
*/ |
218
|
|
|
public function userLoggedIn() |
|
|
|
|
219
|
|
|
{ |
220
|
|
|
$modx = evolutionCMS(); |
221
|
|
|
$userdetails = array(); |
222
|
|
|
if ($modx->isFrontend() && isset ($_SESSION['webValidated'])) { |
223
|
|
|
// web user |
224
|
|
|
$userdetails['loggedIn'] = true; |
225
|
|
|
$userdetails['id'] = $_SESSION['webInternalKey']; |
226
|
|
|
$userdetails['username'] = $_SESSION['webShortname']; |
227
|
|
|
$userdetails['usertype'] = 'web'; // added by Raymond |
228
|
|
|
|
229
|
|
|
return $userdetails; |
230
|
|
|
} else { |
231
|
|
|
if ($modx->isBackend() && isset ($_SESSION['mgrValidated'])) { |
232
|
|
|
// manager user |
233
|
|
|
$userdetails['loggedIn'] = true; |
234
|
|
|
$userdetails['id'] = $_SESSION['mgrInternalKey']; |
235
|
|
|
$userdetails['username'] = $_SESSION['mgrShortname']; |
236
|
|
|
$userdetails['usertype'] = 'manager'; // added by Raymond |
237
|
|
|
|
238
|
|
|
return $userdetails; |
239
|
|
|
} else { |
240
|
|
|
return false; |
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @deprecated |
247
|
|
|
* |
248
|
|
|
* @param string $method |
249
|
|
|
* @param string $prefix |
250
|
|
|
* @param string $trim |
251
|
|
|
* @param $REQUEST_METHOD |
252
|
|
|
* @return array|bool |
|
|
|
|
253
|
|
|
*/ |
254
|
|
|
public function getFormVars($method = "", $prefix = "", $trim = "", $REQUEST_METHOD) |
|
|
|
|
255
|
|
|
{ |
256
|
|
|
// function to retrieve form results into an associative array |
257
|
|
|
$modx = evolutionCMS(); |
|
|
|
|
258
|
|
|
$results = array(); |
259
|
|
|
$method = strtoupper($method); |
260
|
|
|
if ($method == "") { |
261
|
|
|
$method = $REQUEST_METHOD; |
262
|
|
|
} |
263
|
|
|
if ($method == "POST") { |
264
|
|
|
$method = &$_POST; |
265
|
|
|
} elseif ($method == "GET") { |
266
|
|
|
$method = &$_GET; |
267
|
|
|
} else { |
268
|
|
|
return false; |
269
|
|
|
} |
270
|
|
|
reset($method); |
271
|
|
|
foreach ($method as $key => $value) { |
272
|
|
|
if (($prefix != "") && (substr($key, 0, strlen($prefix)) == $prefix)) { |
273
|
|
|
if ($trim) { |
274
|
|
|
$pieces = explode($prefix, $key, 2); |
275
|
|
|
$key = $pieces[1]; |
276
|
|
|
$results[$key] = $value; |
277
|
|
|
} else { |
278
|
|
|
$results[$key] = $value; |
279
|
|
|
} |
280
|
|
|
} elseif ($prefix == "") { |
281
|
|
|
$results[$key] = $value; |
282
|
|
|
} |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
return $results; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Displays a javascript alert message in the web browser |
290
|
|
|
* |
291
|
|
|
* @deprecated |
292
|
|
|
* |
293
|
|
|
* @param string $msg Message to show |
294
|
|
|
* @param string $url URL to redirect to |
295
|
|
|
*/ |
296
|
|
|
public function webAlert($msg, $url = "") |
297
|
|
|
{ |
298
|
|
|
$modx = evolutionCMS(); |
299
|
|
|
$msg = addslashes($modx->getDatabase()->escape($msg)); |
300
|
|
View Code Duplication |
if (substr(strtolower($url), 0, 11) == "javascript:") { |
301
|
|
|
$act = "__WebAlert();"; |
302
|
|
|
$fnc = "function __WebAlert(){" . substr($url, 11) . "};"; |
303
|
|
|
} else { |
304
|
|
|
$act = ($url ? "window.location.href='" . addslashes($url) . "';" : ""); |
305
|
|
|
} |
306
|
|
|
$html = "<script>$fnc window.setTimeout(\"alert('$msg');$act\",100);</script>"; |
|
|
|
|
307
|
|
|
if ($modx->isFrontend()) { |
308
|
|
|
$modx->regClientScript($html); |
309
|
|
|
} else { |
310
|
|
|
echo $html; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
######################################## |
|
|
|
|
315
|
|
|
// END New database functions - rad14701 |
316
|
|
|
######################################## |
|
|
|
|
317
|
|
|
} |
318
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.