@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | /** |
373 | 373 | * @param $fields |
374 | - * @param $table |
|
374 | + * @param string $table |
|
375 | 375 | * @param string $where |
376 | 376 | * @return bool|mixed|mysqli_result |
377 | 377 | */ |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | /** |
519 | - * @param $name |
|
519 | + * @param string $name |
|
520 | 520 | * @param mysqli_result|string $dsq |
521 | 521 | * @return array |
522 | 522 | */ |
@@ -650,6 +650,9 @@ discard block |
||
650 | 650 | return $this->conn->server_info; |
651 | 651 | } |
652 | 652 | |
653 | + /** |
|
654 | + * @param string $tbl |
|
655 | + */ |
|
653 | 656 | public function getFullTableName($tbl) |
654 | 657 | { |
655 | 658 | return $this->config['dbase'] . ".`" . $this->config['table_prefix'] . $tbl . "`"; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $pre = null, |
34 | 34 | $charset = '', |
35 | 35 | $connection_method = 'SET CHARACTER SET' |
36 | - ) { |
|
36 | + ){ |
|
37 | 37 | $this->config['host'] = $host ? $host : $GLOBALS['database_server']; |
38 | 38 | $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; |
39 | 39 | $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $ua = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT']); |
74 | 74 | $referer = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER']); |
75 | 75 | $modx->sendmail(array( |
76 | - 'subject' => 'Missing to create the database connection! from ' . $modx->getPhpCompat()->entities($modx->config['site_name']), |
|
76 | + 'subject' => 'Missing to create the database connection! from '.$modx->getPhpCompat()->entities($modx->config['site_name']), |
|
77 | 77 | 'body' => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}", |
78 | 78 | 'type' => 'text' |
79 | 79 | )); |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | $tend = $modx->getMicroTime(); |
89 | 89 | $totaltime = $tend - $tstart; |
90 | 90 | if ($modx->dumpSQL) { |
91 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s", |
|
92 | - $totaltime) . "</fieldset><br />"; |
|
91 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s", |
|
92 | + $totaltime)."</fieldset><br />"; |
|
93 | 93 | } |
94 | 94 | $this->conn->set_charset($this->config['charset']); |
95 | 95 | $this->isConnected = true; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | if (1000 < $safeCount) { |
123 | 123 | exit("Too many loops '{$safeCount}'"); |
124 | 124 | } |
125 | - if ( ! ($this->conn instanceof mysqli)) { |
|
125 | + if (!($this->conn instanceof mysqli)) { |
|
126 | 126 | $this->connect(); |
127 | 127 | } |
128 | 128 | if (is_array($s)) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public function query($sql, $watchError = true) |
149 | 149 | { |
150 | 150 | $modx = evolutionCMS(); |
151 | - if ( ! ($this->conn instanceof mysqli)) { |
|
151 | + if (!($this->conn instanceof mysqli)) { |
|
152 | 152 | $this->connect(); |
153 | 153 | } |
154 | 154 | $tStart = $modx->getMicroTime(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | case 1091: |
169 | 169 | break; |
170 | 170 | default: |
171 | - $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql); |
|
171 | + $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql); |
|
172 | 172 | } |
173 | 173 | } else { |
174 | 174 | $tend = $modx->getMicroTime(); |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | $debug_path[] = $line['function']; |
183 | 183 | } |
184 | 184 | $debug_path = implode(' > ', array_reverse($debug_path)); |
185 | - $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms", |
|
186 | - $totalTime * 1000) . "</legend>"; |
|
187 | - $modx->queryCode .= $sql . '<br><br>'; |
|
185 | + $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms", |
|
186 | + $totalTime * 1000)."</legend>"; |
|
187 | + $modx->queryCode .= $sql.'<br><br>'; |
|
188 | 188 | if ($modx->event->name) { |
189 | - $modx->queryCode .= 'Current Event => ' . $modx->event->name . '<br>'; |
|
189 | + $modx->queryCode .= 'Current Event => '.$modx->event->name.'<br>'; |
|
190 | 190 | } |
191 | 191 | if ($modx->event->activePlugin) { |
192 | - $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>'; |
|
192 | + $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>'; |
|
193 | 193 | } |
194 | 194 | if ($modx->currentSnippet) { |
195 | - $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>'; |
|
195 | + $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>'; |
|
196 | 196 | } |
197 | 197 | if (stripos($sql, 'select') === 0) { |
198 | - $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>'; |
|
198 | + $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>'; |
|
199 | 199 | } else { |
200 | - $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>'; |
|
200 | + $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>'; |
|
201 | 201 | } |
202 | - $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>'; |
|
202 | + $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>'; |
|
203 | 203 | $modx->queryCode .= "</fieldset><br />"; |
204 | 204 | } |
205 | 205 | $modx->executedQueries++; |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | if ($value === null || strtolower($value) === 'null') { |
307 | 307 | $f = 'NULL'; |
308 | 308 | } else { |
309 | - $f = "'" . $value . "'"; |
|
309 | + $f = "'".$value."'"; |
|
310 | 310 | } |
311 | - $fields[$key] = "`{$key}` = " . $f; |
|
311 | + $fields[$key] = "`{$key}` = ".$f; |
|
312 | 312 | } |
313 | 313 | $fields = implode(',', $fields); |
314 | 314 | } |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | $this->query("INSERT INTO {$intotable} {$fields}"); |
344 | 344 | } else { |
345 | 345 | if (empty($fromtable)) { |
346 | - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", |
|
347 | - array_values($fields)) . "')"; |
|
346 | + $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '", |
|
347 | + array_values($fields))."')"; |
|
348 | 348 | $this->query("INSERT INTO {$intotable} {$fields}"); |
349 | 349 | } else { |
350 | 350 | $fromtable = $this->replaceFullTableName($fromtable); |
351 | - $fields = "(" . implode(",", array_keys($fields)) . ")"; |
|
351 | + $fields = "(".implode(",", array_keys($fields)).")"; |
|
352 | 352 | $where = trim($where); |
353 | 353 | $limit = trim($limit); |
354 | 354 | if ($where !== '' && stripos($where, 'WHERE') !== 0) { |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | */ |
443 | 443 | public function getInsertId($conn = null) |
444 | 444 | { |
445 | - if (! ($conn instanceof mysqli)) { |
|
446 | - $conn =& $this->conn; |
|
445 | + if (!($conn instanceof mysqli)) { |
|
446 | + $conn = & $this->conn; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | return $conn->insert_id; |
@@ -455,8 +455,8 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function getAffectedRows($conn = null) |
457 | 457 | { |
458 | - if (! ($conn instanceof mysqli)) { |
|
459 | - $conn =& $this->conn; |
|
458 | + if (!($conn instanceof mysqli)) { |
|
459 | + $conn = & $this->conn; |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | return $conn->affected_rows; |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | */ |
469 | 469 | public function getLastError($conn = null) |
470 | 470 | { |
471 | - if (! ($conn instanceof mysqli)) { |
|
472 | - $conn =& $this->conn; |
|
471 | + if (!($conn instanceof mysqli)) { |
|
472 | + $conn = & $this->conn; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | return $conn->error; |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | { |
494 | 494 | $out = false; |
495 | 495 | if ($ds instanceof mysqli_result) { |
496 | - switch($mode){ |
|
496 | + switch ($mode) { |
|
497 | 497 | case 'assoc': |
498 | 498 | $out = $ds->fetch_assoc(); |
499 | 499 | break; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | public function getColumn($name, $dsq) |
524 | 524 | { |
525 | 525 | $col = array(); |
526 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
526 | + if (!($dsq instanceof mysqli_result)) { |
|
527 | 527 | $dsq = $this->query($dsq); |
528 | 528 | } |
529 | 529 | if ($dsq) { |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | public function getColumnNames($dsq) |
543 | 543 | { |
544 | 544 | $names = array(); |
545 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
545 | + if (!($dsq instanceof mysqli_result)) { |
|
546 | 546 | $dsq = $this->query($dsq); |
547 | 547 | } |
548 | 548 | if ($dsq) { |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | public function getValue($dsq) |
563 | 563 | { |
564 | 564 | $out = false; |
565 | - if ( ! ($dsq instanceof mysqli_result)) { |
|
565 | + if (!($dsq instanceof mysqli_result)) { |
|
566 | 566 | $dsq = $this->query($dsq); |
567 | 567 | } |
568 | 568 | if ($dsq) { |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | public function getFullTableName($tbl) |
654 | 654 | { |
655 | - return $this->config['dbase'] . ".`" . $this->config['table_prefix'] . $tbl . "`"; |
|
655 | + return $this->config['dbase'].".`".$this->config['table_prefix'].$tbl."`"; |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | $tableName = trim($tableName); |
666 | 666 | $dbase = trim($this->config['dbase'], '`'); |
667 | 667 | $prefix = $this->config['table_prefix']; |
668 | - if ((bool)$force === true) { |
|
668 | + if ((bool) $force === true) { |
|
669 | 669 | $result = "`{$dbase}`.`{$prefix}{$tableName}`"; |
670 | 670 | } elseif (strpos($tableName, '[+prefix+]') !== false) { |
671 | 671 | $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName); |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('delete_eventlog')) { |
|
5 | +if (!$modx->hasPermission('delete_eventlog')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -if (isset($_GET['cls']) && $_GET['cls']==1) { |
|
9 | +if (isset($_GET['cls']) && $_GET['cls'] == 1) { |
|
10 | 10 | $where = ''; |
11 | 11 | } else { |
12 | - $id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
13 | - if($id==0) { |
|
12 | + $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
13 | + if ($id == 0) { |
|
14 | 14 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
15 | 15 | } |
16 | 16 | $where = "id='{$id}'"; |
@@ -19,5 +19,5 @@ discard block |
||
19 | 19 | // delete event log |
20 | 20 | $modx->getDatabase()->delete($modx->getDatabase()->getFullTableName('event_log'), $where); |
21 | 21 | |
22 | -$header="Location: index.php?a=114"; |
|
22 | +$header = "Location: index.php?a=114"; |
|
23 | 23 | header($header); |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('new_chunk')) { |
|
5 | +if (!$modx->hasPermission('new_chunk')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // count duplicates |
15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_htmlsnippets'), "id='{$id}'")); |
16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_htmlsnippets'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
17 | -if($count>=1) $count = ' '.($count+1); |
|
17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
18 | 18 | else $count = ''; |
19 | 19 | |
20 | 20 | // duplicate htmlsnippet |
@@ -32,5 +32,5 @@ discard block |
||
32 | 32 | $_SESSION['itemname'] = $name; |
33 | 33 | |
34 | 34 | // finish duplicating - redirect to new chunk |
35 | -$header="Location: index.php?r=2&a=78&id=$newid"; |
|
35 | +$header = "Location: index.php?r=2&a=78&id=$newid"; |
|
36 | 36 | header($header); |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('new_module')) { |
|
5 | +if (!$modx->hasPermission('new_module')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | // count duplicates |
14 | 14 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_modules'), "id='{$id}'")); |
15 | 15 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('name', $modx->getDatabase()->getFullTableName('site_modules'), "name LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
16 | -if($count>=1) $count = ' '.($count+1); |
|
16 | +if ($count >= 1) $count = ' '.($count + 1); |
|
17 | 17 | else $count = ''; |
18 | 18 | |
19 | 19 | // duplicate module |
@@ -58,5 +58,5 @@ discard block |
||
58 | 58 | $_SESSION['itemname'] = $name; |
59 | 59 | |
60 | 60 | // finish duplicating - redirect to new module |
61 | -$header="Location: index.php?r=2&a=108&id=$newid"; |
|
61 | +$header = "Location: index.php?r=2&a=108&id=$newid"; |
|
62 | 62 | header($header); |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('new_template')) { |
|
5 | +if (!$modx->hasPermission('new_template')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id'])? (int)$_GET['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // count duplicates |
15 | 15 | $name = $modx->getDatabase()->getValue($modx->getDatabase()->select('templatename', $modx->getDatabase()->getFullTableName('site_templates'), "id='{$id}'")); |
16 | 16 | $count = $modx->getDatabase()->getRecordCount($modx->getDatabase()->select('templatename', $modx->getDatabase()->getFullTableName('site_templates'), "templatename LIKE '{$name} {$_lang['duplicated_el_suffix']}%'")); |
17 | -if($count>=1) $count = ' '.($count+1); |
|
17 | +if ($count >= 1) $count = ' '.($count + 1); |
|
18 | 18 | else $count = ''; |
19 | 19 | |
20 | 20 | // duplicate template |
@@ -41,5 +41,5 @@ discard block |
||
41 | 41 | $_SESSION['itemname'] = $name; |
42 | 42 | |
43 | 43 | // finish duplicating - redirect to new template |
44 | -$header="Location: index.php?r=2&a=16&id=$newid"; |
|
44 | +$header = "Location: index.php?r=2&a=16&id=$newid"; |
|
45 | 45 | header($header); |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('delete_template')) { |
|
5 | +if (!$modx->hasPermission('delete_template')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
10 | -if($id == 0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | $forced = isset($_GET['force']) ? $_GET['force'] : 0; |
15 | 15 | |
16 | 16 | // check for relations |
17 | -if(!$forced) { |
|
18 | - $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getDatabase()->getFullTableName('site_content') . " AS sc |
|
19 | - INNER JOIN " . $modx->getDatabase()->getFullTableName('site_tmplvar_contentvalues') . " AS stcv ON stcv.contentid=sc.id", "stcv.tmplvarid='{$id}'"); |
|
17 | +if (!$forced) { |
|
18 | + $drs = $modx->getDatabase()->select('sc.id, sc.pagetitle,sc.description', $modx->getDatabase()->getFullTableName('site_content')." AS sc |
|
19 | + INNER JOIN " . $modx->getDatabase()->getFullTableName('site_tmplvar_contentvalues')." AS stcv ON stcv.contentid=sc.id", "stcv.tmplvarid='{$id}'"); |
|
20 | 20 | $count = $modx->getDatabase()->getRecordCount($drs); |
21 | - if($count > 0) { |
|
21 | + if ($count > 0) { |
|
22 | 22 | include_once "header.inc.php"; |
23 | 23 | ?> |
24 | 24 | <script> |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | <p><?= $_lang['tmplvar_inuse'] ?></p> |
43 | 43 | <ul> |
44 | 44 | <?php |
45 | - while($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['description'] != '' ? ' - ' . $row['description'] : '') . '</li>'; |
|
45 | + while ($row = $modx->getDatabase()->getRow($drs)) { |
|
46 | + echo '<li><span style="width: 200px"><a href="index.php?id='.$row['id'].'&a=27">'.$row['pagetitle'].'</a></span>'.($row['description'] != '' ? ' - '.$row['description'] : '').'</li>'; |
|
47 | 47 | } |
48 | 48 | ?> |
49 | 49 | </ul> |
@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | -if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
2 | +if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
3 | 3 | header('HTTP/1.0 404 Not Found'); |
4 | 4 | exit('error'); |
5 | 5 | } |
6 | -define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through |
|
6 | +define('IN_MANAGER_MODE', true); // we use this to make sure files are accessed through |
|
7 | 7 | define('MODX_API_MODE', true); |
8 | -include_once(__DIR__ . '/../../index.php'); |
|
8 | +include_once(__DIR__.'/../../index.php'); |
|
9 | 9 | $modx->getDatabase()->connect(); |
10 | 10 | $modx->getSettings(); |
11 | 11 | $modx->invokeEvent('OnManagerPageInit'); |
12 | 12 | |
13 | -$core_path = MODX_MANAGER_PATH . 'includes/'; |
|
13 | +$core_path = MODX_MANAGER_PATH.'includes/'; |
|
14 | 14 | // include_once the language file |
15 | 15 | $_lang = array(); |
16 | 16 | include_once("{$core_path}lang/english.inc.php"); |
17 | 17 | |
18 | -if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { |
|
18 | +if ($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { |
|
19 | 19 | include_once("{$core_path}lang/{$manager_language}.inc.php"); |
20 | 20 | } |
21 | 21 | |
22 | 22 | // Initialize System Alert Message Queque |
23 | -if(!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
23 | +if (!isset($_SESSION['SystemAlertMsgQueque'])) { |
|
24 | 24 | $_SESSION['SystemAlertMsgQueque'] = array(); |
25 | 25 | } |
26 | 26 | $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | 'rememberme' => $rememberme |
42 | 42 | )); |
43 | 43 | $fields = 'mu.*, ua.*'; |
44 | -$from = $modx->getDatabase()->getFullTableName('manager_users') . ' AS mu, ' . |
|
45 | - $modx->getDatabase()->getFullTableName('user_attributes') . ' AS ua'; |
|
44 | +$from = $modx->getDatabase()->getFullTableName('manager_users').' AS mu, '. |
|
45 | + $modx->getDatabase()->getFullTableName('user_attributes').' AS ua'; |
|
46 | 46 | $where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id"; |
47 | 47 | $rs = $modx->getDatabase()->select($fields, $from, $where); |
48 | 48 | $limit = $modx->getDatabase()->getRecordCount($rs); |
49 | 49 | |
50 | -if($limit == 0 || $limit > 1) { |
|
50 | +if ($limit == 0 || $limit > 1) { |
|
51 | 51 | jsAlert($_lang['login_processor_unknown_user']); |
52 | 52 | return; |
53 | 53 | } |
@@ -73,32 +73,32 @@ discard block |
||
73 | 73 | $modx->getDatabase()->getFullTableName('user_settings'), |
74 | 74 | "user='{$internalKey}' AND setting_value!=''" |
75 | 75 | ); |
76 | -while($row = $modx->getDatabase()->getRow($rs)) { |
|
76 | +while ($row = $modx->getDatabase()->getRow($rs)) { |
|
77 | 77 | extract($row); |
78 | 78 | ${$setting_name} = $setting_value; |
79 | 79 | } |
80 | 80 | |
81 | 81 | // blocked due to number of login errors. |
82 | -if($failedlogins >= $failed_allowed && $blockeduntildate > time()) { |
|
82 | +if ($failedlogins >= $failed_allowed && $blockeduntildate > time()) { |
|
83 | 83 | @session_destroy(); |
84 | 84 | session_unset(); |
85 | - if($cip = getenv("HTTP_CLIENT_IP")) { |
|
85 | + if ($cip = getenv("HTTP_CLIENT_IP")) { |
|
86 | 86 | $ip = $cip; |
87 | - } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) { |
|
87 | + } elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) { |
|
88 | 88 | $ip = $cip; |
89 | - } elseif($cip = getenv("REMOTE_ADDR")) { |
|
89 | + } elseif ($cip = getenv("REMOTE_ADDR")) { |
|
90 | 90 | $ip = $cip; |
91 | 91 | } else { |
92 | 92 | $ip = "UNKNOWN"; |
93 | 93 | } |
94 | 94 | $log = new EvolutionCMS\Legacy\LogHandler(); |
95 | - $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip); |
|
95 | + $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: ".$ip); |
|
96 | 96 | jsAlert($_lang['login_processor_many_failed_logins']); |
97 | 97 | return; |
98 | 98 | } |
99 | 99 | |
100 | 100 | // blocked due to number of login errors, but get to try again |
101 | -if($failedlogins >= $failed_allowed && $blockeduntildate < time()) { |
|
101 | +if ($failedlogins >= $failed_allowed && $blockeduntildate < time()) { |
|
102 | 102 | $fields = array(); |
103 | 103 | $fields['failedlogincount'] = '0'; |
104 | 104 | $fields['blockeduntil'] = time() - 1; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | // this user has been blocked by an admin, so no way he's loggin in! |
113 | -if($blocked == '1') { |
|
113 | +if ($blocked == '1') { |
|
114 | 114 | @session_destroy(); |
115 | 115 | session_unset(); |
116 | 116 | jsAlert($_lang['login_processor_blocked1']); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | // blockuntil: this user has a block until date |
121 | -if($blockeduntildate > time()) { |
|
121 | +if ($blockeduntildate > time()) { |
|
122 | 122 | @session_destroy(); |
123 | 123 | session_unset(); |
124 | 124 | jsAlert($_lang['login_processor_blocked2']); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | // blockafter: this user has a block after date |
129 | -if($blockedafterdate > 0 && $blockedafterdate < time()) { |
|
129 | +if ($blockedafterdate > 0 && $blockedafterdate < time()) { |
|
130 | 130 | @session_destroy(); |
131 | 131 | session_unset(); |
132 | 132 | jsAlert($_lang['login_processor_blocked3']); |
@@ -134,24 +134,24 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | // allowed ip |
137 | -if($allowed_ip) { |
|
138 | - if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { |
|
139 | - if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { |
|
137 | +if ($allowed_ip) { |
|
138 | + if (($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { |
|
139 | + if (gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { |
|
140 | 140 | jsAlert($_lang['login_processor_remotehost_ip']); |
141 | 141 | return; |
142 | 142 | } |
143 | 143 | } |
144 | - if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { |
|
144 | + if (!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { |
|
145 | 145 | jsAlert($_lang['login_processor_remote_ip']); |
146 | 146 | return; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // allowed days |
151 | -if($allowed_days) { |
|
151 | +if ($allowed_days) { |
|
152 | 152 | $date = getdate(); |
153 | 153 | $day = $date['wday'] + 1; |
154 | - if(!in_array($day,explode(',',$allowed_days))) { |
|
154 | + if (!in_array($day, explode(',', $allowed_days))) { |
|
155 | 155 | jsAlert($_lang['login_processor_date']); |
156 | 156 | return; |
157 | 157 | } |
@@ -168,33 +168,33 @@ discard block |
||
168 | 168 | |
169 | 169 | // check if plugin authenticated the user |
170 | 170 | $matchPassword = false; |
171 | -if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { |
|
171 | +if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { |
|
172 | 172 | // check user password - local authentication |
173 | 173 | $hashType = $modx->getManagerApi()->getHashType($dbasePassword); |
174 | - if($hashType == 'phpass') { |
|
174 | + if ($hashType == 'phpass') { |
|
175 | 175 | $matchPassword = login($username, $_REQUEST['password'], $dbasePassword); |
176 | - } elseif($hashType == 'md5') { |
|
176 | + } elseif ($hashType == 'md5') { |
|
177 | 177 | $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username); |
178 | - } elseif($hashType == 'v1') { |
|
178 | + } elseif ($hashType == 'v1') { |
|
179 | 179 | $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username); |
180 | 180 | } else { |
181 | 181 | $matchPassword = false; |
182 | 182 | } |
183 | -} else if($rt === true || (is_array($rt) && in_array(true, $rt))) { |
|
183 | +} else if ($rt === true || (is_array($rt) && in_array(true, $rt))) { |
|
184 | 184 | $matchPassword = true; |
185 | 185 | } |
186 | 186 | |
187 | -if(!$matchPassword) { |
|
187 | +if (!$matchPassword) { |
|
188 | 188 | jsAlert($_lang['login_processor_wrong_password']); |
189 | 189 | incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); |
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | -if($modx->config['use_captcha'] == 1) { |
|
194 | - if(!isset ($_SESSION['veriword'])) { |
|
193 | +if ($modx->config['use_captcha'] == 1) { |
|
194 | + if (!isset ($_SESSION['veriword'])) { |
|
195 | 195 | jsAlert($_lang['login_processor_captcha_config']); |
196 | 196 | return; |
197 | - } elseif($_SESSION['veriword'] != $captcha_code) { |
|
197 | + } elseif ($_SESSION['veriword'] != $captcha_code) { |
|
198 | 198 | jsAlert($_lang['login_processor_bad_code']); |
199 | 199 | incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); |
200 | 200 | return; |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | |
224 | 224 | // successful login so reset fail count and update key values |
225 | 225 | $modx->getDatabase()->update( |
226 | - 'failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", |
|
226 | + 'failedlogincount=0, '.'logincount=logincount+1, '.'lastlogin=thislogin, '.'thislogin='.time().', '."sessionid='{$currentsessionid}'", |
|
227 | 227 | $modx->getDatabase()->getFullTableName('user_attributes'), |
228 | 228 | "internalKey='{$internalKey}'" |
229 | 229 | ); |
230 | 230 | |
231 | 231 | // get user's document groups |
232 | 232 | $i = 0; |
233 | -$rs = $modx->getDatabase()->select('uga.documentgroup', $modx->getDatabase()->getFullTableName('member_groups') . ' ug |
|
234 | - INNER JOIN ' . $modx->getDatabase()->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); |
|
233 | +$rs = $modx->getDatabase()->select('uga.documentgroup', $modx->getDatabase()->getFullTableName('member_groups').' ug |
|
234 | + INNER JOIN ' . $modx->getDatabase()->getFullTableName('membergroup_access').' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); |
|
235 | 235 | $_SESSION['mgrDocgroups'] = $modx->getDatabase()->getColumn('documentgroup', $rs); |
236 | 236 | |
237 | 237 | $_SESSION['mgrToken'] = md5($currentsessionid); |
238 | 238 | |
239 | -if($rememberme == '1') { |
|
240 | - $_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$modx->config['session.cookie.lifetime']; |
|
239 | +if ($rememberme == '1') { |
|
240 | + $_SESSION['modx.mgr.session.cookie.lifetime'] = (int) $modx->config['session.cookie.lifetime']; |
|
241 | 241 | |
242 | 242 | // Set a cookie separate from the session cookie with the username in it. |
243 | 243 | // Are we using secure connection? If so, make sure the cookie is secure |
244 | 244 | global $https_port; |
245 | 245 | |
246 | 246 | $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); |
247 | - if(version_compare(PHP_VERSION, '5.2', '<')) { |
|
247 | + if (version_compare(PHP_VERSION, '5.2', '<')) { |
|
248 | 248 | setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure); |
249 | 249 | } else { |
250 | 250 | setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true); |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | // Check if user already has an active session, if not check if user pressed logout end of last session |
260 | 260 | $rs = $modx->getDatabase()->select('lasthit', $modx->getDatabase()->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'"); |
261 | 261 | $activeSession = $modx->getDatabase()->getValue($rs); |
262 | -if(!$activeSession) { |
|
262 | +if (!$activeSession) { |
|
263 | 263 | $rs = $modx->getDatabase()->select('lasthit', $modx->getDatabase()->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8"); |
264 | - if($lastHit = $modx->getDatabase()->getValue($rs)) { |
|
264 | + if ($lastHit = $modx->getDatabase()->getValue($rs)) { |
|
265 | 265 | $_SESSION['show_logout_reminder'] = array( |
266 | 266 | 'type' => 'logout_reminder', |
267 | 267 | 'lastHit' => $lastHit |
@@ -286,17 +286,17 @@ discard block |
||
286 | 286 | $modx->getDatabase()->getFullTableName('user_settings'), |
287 | 287 | "user='{$internalKey}' AND setting_name='manager_login_startup'" |
288 | 288 | ); |
289 | -$id = (int)$modx->getDatabase()->getValue($rs); |
|
290 | -if($id > 0) { |
|
291 | - $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); |
|
292 | - if($_POST['ajax'] == 1) { |
|
289 | +$id = (int) $modx->getDatabase()->getValue($rs); |
|
290 | +if ($id > 0) { |
|
291 | + $header = 'Location: '.$modx->makeUrl($id, '', '', 'full'); |
|
292 | + if ($_POST['ajax'] == 1) { |
|
293 | 293 | echo $header; |
294 | 294 | } else { |
295 | 295 | header($header); |
296 | 296 | } |
297 | 297 | } else { |
298 | - $header = 'Location: ' . MODX_MANAGER_URL; |
|
299 | - if($_POST['ajax'] == 1) { |
|
298 | + $header = 'Location: '.MODX_MANAGER_URL; |
|
299 | + if ($_POST['ajax'] == 1) { |
|
300 | 300 | echo $header; |
301 | 301 | } else { |
302 | 302 | header($header); |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('save_document')||!$modx->hasPermission('publish_document')) { |
|
5 | +if (!$modx->hasPermission('save_document') || !$modx->hasPermission('publish_document')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_REQUEST['id'])? (int)$_REQUEST['id'] : 0; |
|
10 | -if($id==0) { |
|
9 | +$id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | /************webber ********/ |
15 | -$content=$modx->getDatabase()->getRow($modx->getDatabase()->select('parent, pagetitle', $modx->getDatabase()->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | -$pid=($content['parent']==0?$id:$content['parent']); |
|
15 | +$content = $modx->getDatabase()->getRow($modx->getDatabase()->select('parent, pagetitle', $modx->getDatabase()->getFullTableName('site_content'), "id='{$id}'")); |
|
16 | +$pid = ($content['parent'] == 0 ? $id : $content['parent']); |
|
17 | 17 | |
18 | 18 | /************** webber *************/ |
19 | -$sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; |
|
20 | -$sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; |
|
21 | -$pg=isset($_REQUEST['page'])?'&page='.(int)$_REQUEST['page']:''; |
|
22 | -$add_path=$sd.$sb.$pg; |
|
19 | +$sd = isset($_REQUEST['dir']) ? '&dir='.$_REQUEST['dir'] : '&dir=DESC'; |
|
20 | +$sb = isset($_REQUEST['sort']) ? '&sort='.$_REQUEST['sort'] : '&sort=createdon'; |
|
21 | +$pg = isset($_REQUEST['page']) ? '&page='.(int) $_REQUEST['page'] : ''; |
|
22 | +$add_path = $sd.$sb.$pg; |
|
23 | 23 | |
24 | 24 | /***********************************/ |
25 | 25 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $udperms->document = $id; |
32 | 32 | $udperms->role = $_SESSION['mgrRole']; |
33 | 33 | |
34 | -if(!$udperms->checkPermissions()) { |
|
34 | +if (!$udperms->checkPermissions()) { |
|
35 | 35 | $modx->webAlertAndQuit($_lang["access_permission_denied"]); |
36 | 36 | } |
37 | 37 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ), $modx->getDatabase()->getFullTableName('site_content'), "id='{$id}'"); |
49 | 49 | |
50 | 50 | // invoke OnDocPublished event |
51 | -$modx->invokeEvent("OnDocPublished",array("docid"=>$id)); |
|
51 | +$modx->invokeEvent("OnDocPublished", array("docid"=>$id)); |
|
52 | 52 | |
53 | 53 | // Set the item name for logger |
54 | 54 | $_SESSION['itemname'] = $content['pagetitle']; |
@@ -56,6 +56,6 @@ discard block |
||
56 | 56 | // empty cache |
57 | 57 | $modx->clearCache('full'); |
58 | 58 | |
59 | -$header="Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
59 | +$header = "Location: index.php?a=3&id=$pid&r=1".$add_path; |
|
60 | 60 | |
61 | 61 | header($header); |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | -if(!$modx->hasPermission('delete_template')) { |
|
5 | +if (!$modx->hasPermission('delete_template')) { |
|
6 | 6 | $modx->webAlertAndQuit($_lang["error_no_privileges"]); |
7 | 7 | } |
8 | 8 | |
9 | -$id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
|
10 | -if($id == 0) { |
|
9 | +$id = isset($_GET['id']) ? (int) $_GET['id'] : 0; |
|
10 | +if ($id == 0) { |
|
11 | 11 | $modx->webAlertAndQuit($_lang["error_no_id"]); |
12 | 12 | } |
13 | 13 | |
14 | 14 | // delete the template, but first check it doesn't have any documents using it |
15 | 15 | $rs = $modx->getDatabase()->select('id, pagetitle,introtext', $modx->getDatabase()->getFullTableName('site_content'), "template='{$id}' AND deleted=0"); |
16 | 16 | $limit = $modx->getDatabase()->getRecordCount($rs); |
17 | -if($limit > 0) { |
|
17 | +if ($limit > 0) { |
|
18 | 18 | include "header.inc.php"; |
19 | 19 | ?> |
20 | 20 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | <p>Documents using this template:</p> |
29 | 29 | <ul> |
30 | 30 | <?php |
31 | - while($row = $modx->getDatabase()->getRow($rs)) { |
|
32 | - echo '<li><span style="width: 200px"><a href="index.php?id=' . $row['id'] . '&a=27">' . $row['pagetitle'] . '</a></span>' . ($row['introtext'] != '' ? ' - ' . $row['introtext'] : '') . '</li>'; |
|
31 | + while ($row = $modx->getDatabase()->getRow($rs)) { |
|
32 | + echo '<li><span style="width: 200px"><a href="index.php?id='.$row['id'].'&a=27">'.$row['pagetitle'].'</a></span>'.($row['introtext'] != '' ? ' - '.$row['introtext'] : '').'</li>'; |
|
33 | 33 | } |
34 | 34 | ?> |
35 | 35 | </ul> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | exit; |
41 | 41 | } |
42 | 42 | |
43 | -if($id == $default_template) { |
|
43 | +if ($id == $default_template) { |
|
44 | 44 | $modx->webAlertAndQuit("This template is set as the default template. Please choose a different default template in the MODX configuration before deleting this template."); |
45 | 45 | } |
46 | 46 |