From 105531e3cc529a7161242ffbb82891078f135890 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:29:31 +0900 Subject: [PATCH 001/168] refactor $modx->sendUnauthorizedPage() --- manager/includes/document.parser.class.inc.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 5435b75224..bc3c5b9447 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -424,17 +424,22 @@ public function sendUnauthorizedPage($noEvent = false) // invoke OnPageUnauthorized event $_REQUEST['refurl'] = $this->documentIdentifier; $this->systemCacheKey = 'unauth'; + if (!$noEvent) { $this->invokeEvent('OnPageUnauthorized'); } + if ($this->config['unauthorized_page']) { - $unauthorizedPage = $this->config['unauthorized_page']; - } elseif ($this->config['error_page']) { - $unauthorizedPage = $this->config['error_page']; - } else { - $unauthorizedPage = $this->config['site_start']; + $this->sendForward($this->config['unauthorized_page'], 'HTTP/1.1 401 Unauthorized'); + exit(); } - $this->sendForward($unauthorizedPage, 'HTTP/1.1 401 Unauthorized'); + + if ($this->config['error_page']) { + $this->sendForward($this->config['error_page'], 'HTTP/1.1 401 Unauthorized'); + exit(); + } + + $this->sendForward($this->config['site_start'], 'HTTP/1.1 401 Unauthorized'); exit(); } From e8f5fa54b0517a059b4613b9abd6935f34d0cb9f Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:31:01 +0900 Subject: [PATCH 002/168] refactor $mmdx->outputContent() --- manager/includes/document.parser.class.inc.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index bc3c5b9447..8e5edad36f 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -984,8 +984,8 @@ public function outputContent($noEvent = false) { $this->documentOutput = $this->documentContent; - if ($this->documentGenerated == 1 && $this->documentObject['cacheable'] == 1) { - if($this->documentObject['type'] === 'document' && $this->documentObject['published'] == 1) { + if ($this->documentGenerated && $this->documentObject['cacheable']) { + if($this->documentObject['type'] === 'document' && $this->documentObject['published']) { if (!empty($this->sjscripts)) { $this->documentObject['__MODxSJScripts__'] = $this->sjscripts; } @@ -1040,13 +1040,12 @@ public function outputContent($noEvent = false) $name = $this->cleanUpMODXTags($name); $name = strtolower($name); $name = preg_replace('/&.+?;/', '', $name); // kill entities - $name = preg_replace('/[^\.%a-z0-9 _-]/', '', $name); + $name = preg_replace('/[^.%a-z0-9 _-]/', '', $name); $name = preg_replace('/\s+/', '-', $name); - $name = preg_replace('|-+|', '-', $name); + $name = preg_replace('/-+/', '-', $name); $name = trim($name, '-'); } - $header = 'Content-Disposition: attachment; filename=' . $name; - header($header); + header('Content-Disposition: attachment; filename=' . $name); } } $this->setConditional(); From a4fa81827319983aa3ad8527ceb94f2231ebb818 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:31:46 +0900 Subject: [PATCH 003/168] refactor $modx->setConditional() --- manager/includes/document.parser.class.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 8e5edad36f..3ce28735ff 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -1166,7 +1166,13 @@ public function getTimerStats($tstart) public function setConditional() { - if (!empty($_POST) || (defined('MODX_API_MODE') && MODX_API_MODE) || $this->getLoginUserID('mgr') || !$this->useConditional || empty($this->recentUpdate)) { + if (!empty($_POST)) { + return; + } + if (defined('MODX_API_MODE') && MODX_API_MODE) { + return; + } + if ($this->getLoginUserID('mgr') || !$this->useConditional || empty($this->recentUpdate)) { return; } $last_modified = gmdate('D, d M Y H:i:s T', $this->recentUpdate); From bcd7de3591c01c5932285585fe5787e398a3b7d6 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:33:35 +0900 Subject: [PATCH 004/168] improved $modx->getConfig() --- manager/includes/document.parser.class.inc.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 3ce28735ff..6915870b8e 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4511,13 +4511,12 @@ public function getAliasListing($id) * @param string $name * @return bool|string */ - public function getConfig($name = '') + public function getConfig($name = '', $default = null) { - if (!empty ($this->config[$name])) { - return $this->config[$name]; - } else { - return false; + if (!isset($this->config[$name])) { + return $default; } + return $this->config[$name]; } /** From 09aecc61afc85cadd6bc1a0f6a990c452620b3c5 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:38:05 +0900 Subject: [PATCH 005/168] refactor $modx->getVersionData() --- .../includes/document.parser.class.inc.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 6915870b8e..c6711f071b 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4522,24 +4522,28 @@ public function getConfig($name = '', $default = null) /** * Returns the EVO version information as version, branch, release date and full application name. * - * @param null $data + * @param null $key * @return array */ - public function getVersionData($data = null) + public function getVersionData($key = null) { $out = []; if (empty($this->version) || !is_array($this->version)) { //include for compatibility modx version < 1.0.10 include MODX_MANAGER_PATH . "includes/version.inc.php"; - $this->version = []; - $this->version['version'] = isset($modx_version) ? $modx_version : ''; - $this->version['branch'] = isset($modx_branch) ? $modx_branch : ''; - $this->version['release_date'] = isset($modx_release_date) ? $modx_release_date : ''; - $this->version['full_appname'] = isset($modx_full_appname) ? $modx_full_appname : ''; - $this->version['new_version'] = isset($this->config['newversiontext']) ? $this->config['newversiontext'] : ''; - } - return (!is_null($data) && is_array($this->version) && isset($this->version[$data])) ? $this->version[$data] : $this->version; + $this->version = [ + 'version' => $modx_version ?? '', + 'branch' => $modx_branch ?? '', + 'release_date' => $modx_release_date ?? '', + 'full_appname' => $modx_full_appname ?? '', + 'new_version' => $this->config['newversiontext'] ?? '' + ]; + } + if (!$key) { + return $this->version; + } + return $this->version[$key]; } /** From c3eb18aba1cd1e5900333486c5b35ccbb4454308 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:40:12 +0900 Subject: [PATCH 006/168] refactor $modx->runSnippet() --- .../includes/document.parser.class.inc.php | 53 +++++++++++++------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index c6711f071b..430c113973 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4556,26 +4556,45 @@ public function getVersionData($key = null) public function runSnippet($snippetName, $params = []) { if (isset ($this->snippetCache[$snippetName])) { - $snippet = $this->snippetCache[$snippetName]; - $properties = !empty($this->snippetCache[$snippetName . "Props"]) ? $this->snippetCache[$snippetName . "Props"] : ''; - } else { // not in cache so let's check the db - $sql = "SELECT ss.`name`, ss.`snippet`, ss.`properties`, sm.properties as `sharedproperties` FROM " . $this->getFullTableName("site_snippets") . " as ss LEFT JOIN " . $this->getFullTableName('site_modules') . " as sm on sm.guid=ss.moduleguid WHERE ss.`name`='" . $this->db->escape($snippetName) . "' AND ss.disabled=0;"; - $result = $this->db->query($sql); - if ($this->db->getRecordCount($result) == 1) { - $row = $this->db->getRow($result); - $snippet = $this->snippetCache[$snippetName] = $row['snippet']; - $mergedProperties = array_merge($this->parseProperties($row['properties']), $this->parseProperties($row['sharedproperties'])); - $properties = $this->snippetCache[$snippetName . "Props"] = json_encode($mergedProperties); - } else { - $snippet = $this->snippetCache[$snippetName] = "return false;"; - $properties = $this->snippetCache[$snippetName . "Props"] = ''; - } + $parameters = $this->parseProperties( + $this->snippetCache[$snippetName . 'Props'] ?? '', + $snippetName, + 'snippet' + ); + return $this->evalSnippet( + $this->snippetCache[$snippetName], + array_merge($parameters, $params) + ); + } + + $result = $this->db->select( + "snippet.`name`, snippet.`snippet`, snippet.`properties`, module.properties as `sharedproperties`", + [ + sprintf('%s as snippet', $this->getFullTableName("site_snippets")), + sprintf( + 'LEFT JOIN %s as module on module.guid=snippet.moduleguid', + $this->getFullTableName('site_modules') + ) + ], + "snippet.`name`='" . $this->db->escape($snippetName) . "' AND snippet.disabled=0" + ); + if ($this->db->getRecordCount($result) != 1) { + $this->snippetCache[$snippetName] = 'return false;'; + $this->snippetCache[$snippetName . 'Props'] = ''; + return $this->evalSnippet('return false;', []); } - // load default params/properties + + $row = $this->db->getRow($result); + $snippet = $this->snippetCache[$snippetName] = $row['snippet']; + $mergedProperties = array_merge( + $this->parseProperties($row['properties']), + $this->parseProperties($row['sharedproperties']) + ); + $properties = json_encode($mergedProperties); + $this->snippetCache[$snippetName . 'Props'] = $properties; + $parameters = $this->parseProperties($properties, $snippetName, 'snippet'); $parameters = array_merge($parameters, $params); - - // run snippet return $this->evalSnippet($snippet, $parameters); } From 1a933c2c2a98459c548c29003bd2e32c8f949761 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:40:54 +0900 Subject: [PATCH 007/168] refactor $modx->getChunk() --- .../includes/document.parser.class.inc.php | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 430c113973..03d983a3dc 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4606,26 +4606,36 @@ public function runSnippet($snippetName, $params = []) */ public function getChunk($chunkName) { - $out = null; - if (empty($chunkName)) { - // nop - } elseif ($this->isChunkProcessor('DLTemplate')) { - $out = DLTemplate::getInstance($this)->getChunk($chunkName); - } elseif (isset ($this->chunkCache[$chunkName])) { - $out = $this->chunkCache[$chunkName]; - } elseif (stripos($chunkName, '@FILE') === 0) { - $out = $this->chunkCache[$chunkName] = $this->atBindFileContent($chunkName); - } else { - $where = sprintf("`name`='%s' AND disabled=0", $this->db->escape($chunkName)); - $rs = $this->db->select('snippet', '[+prefix+]site_htmlsnippets', $where); - if ($this->db->getRecordCount($rs) == 1) { - $row = $this->db->getRow($rs); - $out = $this->chunkCache[$chunkName] = $row['snippet']; - } else { - $out = $this->chunkCache[$chunkName] = null; - } + if (!$chunkName) { + return null; } - return $out; + + if ($this->isChunkProcessor('DLTemplate')) { + return DLTemplate::getInstance($this)->getChunk($chunkName); + } + + if (isset ($this->chunkCache[$chunkName])) { + return $this->chunkCache[$chunkName]; + } + + if (stripos($chunkName, '@FILE') === 0) { + $this->chunkCache[$chunkName] = $this->atBindFileContent($chunkName); + return $this->chunkCache[$chunkName]; + } + + $rs = $this->db->select( + 'snippet', + '[+prefix+]site_htmlsnippets', + sprintf("`name`='%s' AND disabled=0", $this->db->escape($chunkName)) + ); + if ($this->db->getRecordCount($rs) != 1) { + $this->chunkCache[$chunkName] = null; + return null; + } + + $row = $this->db->getRow($rs); + $this->chunkCache[$chunkName] = $row['snippet']; + return $this->chunkCache[$chunkName]; } /** From 9c05a4c5c4c59037160e7d02c8aad666ab80cfbe Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:41:50 +0900 Subject: [PATCH 008/168] refactor $modx->isChunkProcessor() --- manager/includes/document.parser.class.inc.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 03d983a3dc..45bc6e5113 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4712,13 +4712,22 @@ public function parseText($tpl = '', $ph = [], $left = '[+', $right = '+]', $exe */ public function isChunkProcessor($processor) { - $value = (string)$this->getConfig('chunk_processor'); - if(is_object($processor)) { $processor = get_class($processor); } - return is_scalar($processor) && mb_strtolower($value) === mb_strtolower($processor) && class_exists($processor, false); + if (!is_scalar($processor)) { + return false; + } + + if (mb_strtolower($this->getConfig('chunk_processor', '')) !== mb_strtolower($processor)) { + return false; + } + if (!class_exists($processor, false)) { + return false; + } + + return true; } /** From 7e386c1be45a766b0e8d562b56da69a90abf9567 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:42:23 +0900 Subject: [PATCH 009/168] refactor $modx->parseChunk() --- manager/includes/document.parser.class.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 45bc6e5113..bf8add7a47 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4752,9 +4752,14 @@ public function parseChunk($chunkName, $chunkArr, $prefix = '{', $suffix = '}') return false; } - return $prefix === '[+' && $suffix === '+]' && $this->isChunkProcessor('DLTemplate') ? - DLTemplate::getInstance($this)->parseChunk($chunkName, $chunkArr) : - $this->parseText($this->getChunk($chunkName), $chunkArr, $prefix, $suffix); + if ($prefix !== '[+' || $suffix !== '+]') { + return $this->parseText($this->getChunk($chunkName), $chunkArr, $prefix, $suffix); + } + if (!$this->isChunkProcessor('DLTemplate')) { + return $this->parseText($this->getChunk($chunkName), $chunkArr); + } + + return DLTemplate::getInstance($this)->parseChunk($chunkName, $chunkArr); } /** From c1d999f9797c60344c5d73116d7e65aff96448f4 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:43:16 +0900 Subject: [PATCH 010/168] refactor $modx->messageQuit() --- manager/includes/document.parser.class.inc.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index bf8add7a47..7bc77c6280 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -6603,7 +6603,7 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error = $referer = $this->htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES, $this->config['modx_charset']); if ($is_error) { $str = '

« Evo Parse Error »

'; - if ($msg != 'PHP Parse Error') { + if ($msg !== 'PHP Parse Error') { $str .= '

' . $msg . '

'; } } else { @@ -6711,14 +6711,14 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error = $totalTime = sprintf("%2.4f s", $totalTime); $phpTime = sprintf("%2.4f s", $phpTime); - $str = str_replace('[^q^]', $queries, $str); - $str = str_replace('[^qt^]', $queryTime, $str); - $str = str_replace('[^p^]', $phpTime, $str); - $str = str_replace('[^t^]', $totalTime, $str); - $str = str_replace('[^m^]', $total_mem, $str); + $str = str_replace( + ['[^q^]', '[^qt^]', '[^p^]', '[^t^]', '[^m^]'], + [$queries, $queryTime, $phpTime, $totalTime, $total_mem], + $str + ); if (isset($php_errormsg) && !empty($php_errormsg)) { - $str = "{$php_errormsg}
\n{$str}"; + $str = "" . $php_errormsg . "
\n" . $str; } $str .= $this->get_backtrace(debug_backtrace()); // Log error From e53e5b2aa60bf1a629f2e244ee1ad84922e00272 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:44:18 +0900 Subject: [PATCH 011/168] refactor $modx->get_backtrace() --- .../includes/document.parser.class.inc.php | 90 ++++++++----------- 1 file changed, 39 insertions(+), 51 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 7bc77c6280..acf32729f6 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -6796,67 +6796,55 @@ public function get_backtrace($backtrace) $MakeTable->setRowAlternateClass('gridAltItem'); $table = []; $backtrace = array_reverse($backtrace); - foreach ($backtrace as $key => $val) { - $key++; - if (substr($val['function'], 0, 11) === 'messageQuit') { + foreach ($backtrace as $val) { + if (strpos($val['function'], 'messageQuit') === 0) { break; - } elseif (substr($val['function'], 0, 8) === 'phpError') { - break; - } - $path = str_replace('\\', '/', $val['file']); - if (strpos($path, MODX_BASE_PATH) === 0) { - $path = substr($path, strlen(MODX_BASE_PATH)); } - switch ($val['type']) { - case '->': - case '::': - $functionName = $val['function'] = $val['class'] . $val['type'] . $val['function']; - break; - default: - $functionName = $val['function']; + if (strpos($val['function'], 'phpError') === 0) { + break; } - $tmp = 1; - $_ = (!empty($val['args'])) ? count($val['args']) : 0; + $num = 1; + $_ = empty($val['args']) ? 0 : count($val['args']); $args = array_pad([], $_, '$var'); $args = implode(", ", $args); - $modx = &$this; - $args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) { - $arg = $val['args'][$tmp - 1]; - switch (true) { - case is_null($arg): { + $args = preg_replace_callback( + '/\$var/', + function () use (&$num, $val) { + $arg = $val['args'][$num - 1]; + if (is_null($arg)) { $out = 'NULL'; - break; - } - case is_numeric($arg): { + } elseif (is_numeric($arg)) { $out = $arg; - break; - } - case is_scalar($arg): { - $out = strlen($arg) > 20 ? 'string $var' . $tmp : ("'" . $this->htmlspecialchars(str_replace("'", "\\'", $arg)) . "'"); - break; - } - case is_bool($arg): { + } elseif (is_scalar($arg)) { + if (strlen($arg) <= 20) { + $out = sprintf("'%s'", $this->htmlspecialchars(str_replace("'", "\\'", $arg))); + } else { + $out = 'string $var' . $num; + } + } elseif (is_bool($arg)) { $out = $arg ? 'TRUE' : 'FALSE'; - break; - } - case is_array($arg): { - $out = 'array $var' . $tmp; - break; - } - case is_object($arg): { - $out = get_class($arg) . ' $var' . $tmp; - break; - } - default: { - $out = '$var' . $tmp; + } elseif (is_array($arg)) { + $out = 'array $var' . $num; + } elseif (is_object($arg)) { + $out = get_class($arg) . ' $var' . $num; + } else { + $out = '$var' . $num; } - } - $tmp++; - return $out; - }, $args); + $num++; + return $out; + }, + $args + ); + if (in_array($val['type'], ['->', '::'])) { + $val['function'] = $val['class'] . $val['type'] . $val['function']; + } + $path = str_replace('\\', '/', $val['file']); + if (strpos($path, MODX_BASE_PATH) === 0) { + $path = substr($path, strlen(MODX_BASE_PATH)); + } $line = array( - "" . $functionName . "(" . $args . ")", - $path . " on line " . $val['line'] + sprintf('%s(%s)', $val['function'], $args), + sprintf('%s on line %s', $path, $val['line']) ); $table[] = array(implode("
", $line)); } From 8ed64d4b225a7eb213ada2aa610c1c9f32b10411 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:45:14 +0900 Subject: [PATCH 012/168] refactor $modx->getHiddenIdFromAlias() --- .../includes/document.parser.class.inc.php | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index acf32729f6..2cccf8ac33 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -6915,31 +6915,42 @@ public function nicesize($size) */ public function getHiddenIdFromAlias($parentid, $alias) { - $out = false; - if ($alias !== '') { - $table = $this->getFullTableName('site_content'); - $query = $this->db->query("SELECT - `sc`.`id` AS `hidden_id`, - `children`.`id` AS `child_id`, - children.alias AS `child_alias`, - COUNT(`grandsons`.`id`) AS `grandsons_count` - FROM " . $table ." AS `sc` - JOIN " . $table . " AS `children` ON `children`.`parent` = `sc`.`id` - LEFT JOIN " . $table . " AS `grandsons` ON `grandsons`.`parent` = `children`.`id` - WHERE `sc`.`parent` = '" . (int)$parentid . "' AND `sc`.`alias_visible` = '0' - GROUP BY `children`.`id`"); - - while ($child = $this->db->getRow($query)) { - if ($child['child_alias'] == $alias || $child['child_id'] == $alias) { - $out = $child['child_id']; - break; - } elseif ($child['grandsons_count'] > 0 && ($id = $this->getHiddenIdFromAlias($child['hidden_id'], $alias))) { - $out = $id; - break; - } + if ($alias === '') { + return false; + } + + $query = $this->db->select( + 'sc.id AS hidden_id, + children.id AS child_id, + children.alias AS child_alias, + COUNT(grandsons.id) AS grandsons_count', + [ + sprintf('%s AS sc', $this->getFullTableName('site_content')), + sprintf( + 'JOIN %s AS children ON children.parent=sc.id', + $this->getFullTableName('site_content') + ), + sprintf( + 'LEFT JOIN %s AS grandsons ON grandsons.parent=children.id', + $this->getFullTableName('site_content') + ) + ], + sprintf( + "sc.parent='%s' AND sc.alias_visible=0 GROUP BY children.id", + (int)$parentid + ) + ); + + while ($child = $this->db->getRow($query)) { + if ($child['child_alias'] == $alias || $child['child_id'] == $alias) { + return $child['child_id']; + } + $id = $this->getHiddenIdFromAlias($child['hidden_id'], $alias); + if ($child['grandsons_count'] > 0 && $id) { + return $id; } } - return $out; + return false; } /** From be342e39854f1be6bcf1374766328e24b59c5741 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:46:12 +0900 Subject: [PATCH 013/168] refactor $modx->getIdFromAlias() --- .../includes/document.parser.class.inc.php | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 2cccf8ac33..cd4907fad4 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -6954,60 +6954,64 @@ public function getHiddenIdFromAlias($parentid, $alias) } /** - * @param string $alias + * @param string $aliasPath * @return bool|int */ - public function getIdFromAlias($alias) + public function getIdFromAlias($aliasPath) { - if (isset($this->documentListing[$alias])) { - return $this->documentListing[$alias]; + if (isset($this->documentListing[$aliasPath])) { + return $this->documentListing[$aliasPath]; } - $tbl_site_content = $this->getFullTableName('site_content'); if (!$this->config['use_alias_path']) { $rs = $this->db->select( 'id', - $tbl_site_content, - "deleted=0 and alias='" . $alias . "'", + $this->getFullTableName('site_content'), + "deleted=0 and alias='" . $aliasPath . "'", 'parent, menuindex' ); $id = $this->db->getValue($rs); if (!$id) { - $id = false; + return false; } return $id; } - if ($alias === '.') { + if ($aliasPath === '.') { return 0; } - if (strpos($alias, '/') !== false) { - $_a = explode('/', $alias); - } else { - $_a[] = $alias; - } - $id = 0; + $_a = strpos($aliasPath, '/') !== false + ? explode('/', $aliasPath) + : [$aliasPath] + ; + $id = 0; foreach ($_a as $alias) { if ($id === false) { - break; + return false; } - $alias = $this->db->escape($alias); $rs = $this->db->select( 'id', - $tbl_site_content, - "deleted=0 and parent='" . $id . "' and alias='" . $alias . "'" + $this->getFullTableName('site_content'), + sprintf( + "deleted=0 and parent='%s' and alias='%s'", + $id, + $this->db->escape($alias) + ) ); - if ($this->db->getRecordCount($rs) == 0) { + if (!$this->db->getRecordCount($rs)) { $rs = $this->db->select( 'id', - $tbl_site_content, - "deleted=0 and parent='" . $id . "' and id='" . $alias . "'" + $this->getFullTableName('site_content'), + sprintf( + "deleted=0 and parent='%s' and id='%s'", + $id, + $this->db->escape($alias) + ) ); } - $next = $this->db->getValue($rs); - $id = $next ?: $this->getHiddenIdFromAlias($id, $alias); + $id = $this->db->getValue($rs) ?: $this->getHiddenIdFromAlias($id, $alias); } return $id; } From 32d3e2d3a60f9759b42adfa16071826c55b1d411 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:47:01 +0900 Subject: [PATCH 014/168] minor fix $modx->atBindInclude() --- manager/includes/document.parser.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index cd4907fad4..516635c6ad 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -7052,7 +7052,7 @@ public function atBindInclude($str = '') return false; } - if (!$file_path || !is_file($file_path)) { + if (!is_file($file_path)) { return false; } From e82451874cec655e68f2341c35caaf93a3a540c4 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 10:50:56 +0900 Subject: [PATCH 015/168] refactor header.inc.php --- manager/includes/header.inc.php | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/manager/includes/header.inc.php b/manager/includes/header.inc.php index 166cd22e0f..97f774b652 100755 --- a/manager/includes/header.inc.php +++ b/manager/includes/header.inc.php @@ -3,13 +3,11 @@ die("INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly."); } -$mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; // invoke OnManagerRegClientStartupHTMLBlock event $evtOut = $modx->invokeEvent('OnManagerMainFrameHeaderHTMLBlock'); -$modx_textdir = isset($modx_textdir) ? $modx_textdir : null; +$modx_textdir = $modx_textdir ?? null; $onManagerMainFrameHeaderHTMLBlock = is_array($evtOut) ? implode("\n", $evtOut) : ''; -$textdir = $modx_textdir === 'rtl' ? 'rtl' : 'ltr'; if (!isset($modx->config['mgr_jquery_path'])) { $modx->config['mgr_jquery_path'] = 'media/script/jquery/jquery.min.js'; } @@ -19,30 +17,31 @@ $body_class = ''; $theme_modes = array('', 'lightness', 'light', 'dark', 'darkness'); -$theme_mode = isset($_COOKIE['MODX_themeMode']) ? $_COOKIE['MODX_themeMode'] : ''; -if (!empty($theme_modes[$theme_mode])) { +$theme_mode = $_COOKIE['MODX_themeMode'] ?? ''; +if ($theme_mode && !empty($theme_modes[$theme_mode])) { $body_class .= ' ' . $theme_modes[$theme_mode]; } elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { $body_class .= ' ' . $theme_modes[$modx->config['manager_theme_mode']]; } -$css = 'media/style/' . $modx->config['manager_theme'] . '/style.css?v=' . $lastInstallTime; +$css = 'media/style/' . $modx->config['manager_theme'] . '/style.css?v=' . $modx->recentUpdate; -if ($modx->config['manager_theme'] == 'default') { - if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') - && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { +$style_path = MODX_MANAGER_PATH . 'media/style/'; +if ($modx->config['manager_theme'] === 'default') { + if (!file_exists($style_path . $modx->config['manager_theme'] . '/css/styles.min.css') + && is_writable($style_path . $modx->config['manager_theme'] . '/css')) { $files = array( - 'bootstrap' => MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css', - 'font-awesome' => MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css', - 'fonts' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css', - 'forms' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css', - 'mainmenu' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css', - 'tree' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css', - 'custom' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css', - 'tabpane' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css', - 'contextmenu' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css', - 'index' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css', - 'main' => MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css' + 'bootstrap' => $style_path . 'common/bootstrap/css/bootstrap.min.css', + 'font-awesome' => $style_path . 'common/font-awesome/css/font-awesome.min.css', + 'fonts' => $style_path . $modx->config['manager_theme'] . '/css/fonts.css', + 'forms' => $style_path . $modx->config['manager_theme'] . '/css/forms.css', + 'mainmenu' => $style_path . $modx->config['manager_theme'] . '/css/mainmenu.css', + 'tree' => $style_path . $modx->config['manager_theme'] . '/css/tree.css', + 'custom' => $style_path . $modx->config['manager_theme'] . '/css/custom.css', + 'tabpane' => $style_path . $modx->config['manager_theme'] . '/css/tabpane.css', + 'contextmenu' => $style_path . $modx->config['manager_theme'] . '/css/contextmenu.css', + 'index' => $style_path . $modx->config['manager_theme'] . '/css/index.css', + 'main' => $style_path . $modx->config['manager_theme'] . '/css/main.css' ); $evtOut = $modx->invokeEvent('OnBeforeMinifyCss', array( 'files' => $files, @@ -63,18 +62,18 @@ $minifier = new Formatter\CSSMinify($files); $css = $minifier->minify(); file_put_contents( - MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', + $style_path . $modx->config['manager_theme'] . '/css/styles.min.css', $css ); } - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { - $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; + if (file_exists($style_path . $modx->config['manager_theme'] . '/css/styles.min.css')) { + $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $modx->recentUpdate; } } ?> - + Evolution CMS @@ -88,7 +87,7 @@ - config['enable_mootools'] != "0") { ?> + config['enable_mootools'] != "0") { ?> From 65ec0274732c05bf630dd1c15c5749b3ffcc023a Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 11:42:15 +0900 Subject: [PATCH 016/168] refactor db:__construct() --- manager/includes/extenders/dbapi.mysqli.class.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index cc7a2f785d..ff3d73c807 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -31,11 +31,11 @@ public function __construct( $charset = '', $connection_method = 'SET CHARACTER SET' ) { - $this->config['host'] = $host ? $host : $GLOBALS['database_server']; - $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase']; - $this->config['user'] = $uid ? $uid : $GLOBALS['database_user']; - $this->config['pass'] = $pwd ? $pwd : $GLOBALS['database_password']; - $this->config['charset'] = $charset ? $charset : $GLOBALS['database_connection_charset']; + $this->config['host'] = $host ?: $GLOBALS['database_server']; + $this->config['dbase'] = $dbase ?: $GLOBALS['dbase']; + $this->config['user'] = $uid ?: $GLOBALS['database_user']; + $this->config['pass'] = $pwd ?: $GLOBALS['database_password']; + $this->config['charset'] = $charset ?: $GLOBALS['database_connection_charset']; $this->config['connection_method'] = $this->_dbconnectionmethod = (isset($GLOBALS['database_connection_method']) ? $GLOBALS['database_connection_method'] : $connection_method); $this->config['table_prefix'] = ($pre !== null) ? $pre : $GLOBALS['table_prefix']; } From 020813122bcc03e472ff8b7913fcb0973cd14358 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 11:43:09 +0900 Subject: [PATCH 017/168] refactor db::connect() --- manager/includes/extenders/dbapi.mysqli.class.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index ff3d73c807..67872e5cab 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -50,11 +50,11 @@ public function __construct( public function connect($host = '', $dbase = '', $uid = '', $pwd = '') { $modx = evolutionCMS(); - $uid = $uid ? $uid : $this->config['user']; - $pwd = $pwd ? $pwd : $this->config['pass']; - $host = $host ? $host : $this->config['host']; + $uid = $uid ?: $this->config['user']; + $pwd = $pwd ?: $this->config['pass']; + $host = $host ?: $this->config['host']; $host = explode(':', $host, 2); - $dbase = $dbase ? $dbase : $this->config['dbase']; + $dbase = $dbase ?: $this->config['dbase']; $dbase = trim($dbase, '`'); // remove the `` chars $charset = $this->config['charset']; $connection_method = $this->config['connection_method']; From fa40aa62e76d6607d0c1529f20541242ce74f9a6 Mon Sep 17 00:00:00 2001 From: Yamamoto Date: Sun, 15 Jan 2023 11:45:00 +0900 Subject: [PATCH 018/168] refactor db::escape() --- .../extenders/dbapi.mysqli.class.inc.php | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index 67872e5cab..5d3942d6cb 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -114,25 +114,22 @@ public function disconnect() * @param int $safeCount * @return array|string */ - public function escape($s, $safeCount = 0) + public function escape($s) { - $safeCount++; - if (1000 < $safeCount) { - exit("Too many loops '{$safeCount}'"); - } - if ( ! ($this->conn instanceof mysqli)) { + if (!$this->conn instanceof mysqli) { $this->connect(); } - if (is_array($s)) { - if (count($s) === 0) { - $s = ''; - } else { - foreach ($s as $i => $v) { - $s[$i] = $this->escape($v, $safeCount); - } - } - } else { - $s = $this->conn->escape_string($s); + + if (!is_array($s)) { + return $this->conn->escape_string($s); + } + + if (!count($s)) { + return ''; + } + + foreach ($s as $i => $v) { + $s[$i] = $this->escape($v); } return $s; From f9721eccda850deadf1920f52fbb9616aa51ccb8 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Fri, 11 Mar 2022 03:31:32 +0300 Subject: [PATCH 019/168] fix path bug --- manager/actions/files.dynamic.php | 2 +- manager/actions/welcome.static.php | 814 ++++++++++++++--------------- 2 files changed, 402 insertions(+), 414 deletions(-) diff --git a/manager/actions/files.dynamic.php b/manager/actions/files.dynamic.php index fb61c2b499..96d54d9d90 100755 --- a/manager/actions/files.dynamic.php +++ b/manager/actions/files.dynamic.php @@ -97,7 +97,7 @@ function add_dot($array) } else { $startpath = $filemanager_path; } -$startpath = rtrim($startpath, '/'); +$startpath = $startpath == '/' ? '/' : rtrim($startpath, '/'); if (!is_readable($startpath)) { $modx->webAlertAndQuit($_lang["not_readable_dir"]); diff --git a/manager/actions/welcome.static.php b/manager/actions/welcome.static.php index add71b8581..b7953f1c8e 100755 --- a/manager/actions/welcome.static.php +++ b/manager/actions/welcome.static.php @@ -1,13 +1,13 @@ INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly.'); + die('INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly.'); } unset($_SESSION['itemname']); // clear this, because it's only set for logging purposes if($modx->hasPermission('settings') && (!isset($settings_version) || $settings_version != $modx->getVersionData('version'))) { - // seems to be a new install - send the user to the configuration page - exit(''); + // seems to be a new install - send the user to the configuration page + exit(''); } // set placeholders @@ -17,92 +17,92 @@ // setup message info if($modx->hasPermission('messages')) { - include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); - $_SESSION['nrtotalmessages'] = $nrtotalmessages; - $_SESSION['nrnewmessages'] = $nrnewmessages; + include_once(MODX_MANAGER_PATH . 'includes/messageCount.inc.php'); + $_SESSION['nrtotalmessages'] = $nrtotalmessages; + $_SESSION['nrnewmessages'] = $nrnewmessages; - $msg = array(); - $msg[] = sprintf('', $_style['icons_mail_large']); - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (' . $_SESSION['nrnewmessages'] . ')' : ''; - $msg[] = sprintf(' [%%inbox%%]%s
', $nrnewmessages); - $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '' . $_SESSION['nrnewmessages'] . '' : '0'; - $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); - $msg[] = sprintf('%s', $welcome_messages); - $ph['MessageInfo'] = implode("\n", $msg); + $msg = array(); + $msg[] = sprintf('', $_style['icons_mail_large']); + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? ' (' . $_SESSION['nrnewmessages'] . ')' : ''; + $msg[] = sprintf(' [%%inbox%%]%s
', $nrnewmessages); + $nrnewmessages = $_SESSION['nrnewmessages'] > 0 ? '' . $_SESSION['nrnewmessages'] . '' : '0'; + $welcome_messages = sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages); + $msg[] = sprintf('%s', $welcome_messages); + $ph['MessageInfo'] = implode("\n", $msg); } // setup icons if($modx->hasPermission('new_user') || $modx->hasPermission('edit_user')) { - $icon = ' [%user_management_title%]'; - $ph['SecurityIcon'] = wrapIcon($icon, 75); + $icon = ' [%user_management_title%]'; + $ph['SecurityIcon'] = wrapIcon($icon, 75); } if($modx->hasPermission('new_web_user') || $modx->hasPermission('edit_web_user')) { - $icon = ' [%web_user_management_title%]'; - $ph['WebUserIcon'] = wrapIcon($icon, 99); + $icon = ' [%web_user_management_title%]'; + $ph['WebUserIcon'] = wrapIcon($icon, 99); } if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) { - $icon = ' [%modules%]'; - $ph['ModulesIcon'] = wrapIcon($icon, 106); + $icon = ' [%modules%]'; + $ph['ModulesIcon'] = wrapIcon($icon, 106); } if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin') || $modx->hasPermission('manage_metatags')) { - $icon = ' [%elements%]'; - $ph['ResourcesIcon'] = wrapIcon($icon, 76); + $icon = ' [%elements%]'; + $ph['ResourcesIcon'] = wrapIcon($icon, 76); } if($modx->hasPermission('bk_manager')) { - $icon = ' [%backup%]'; - $ph['BackupIcon'] = wrapIcon($icon, 93); + $icon = ' [%backup%]'; + $ph['BackupIcon'] = wrapIcon($icon, 93); } if($modx->hasPermission('help')) { - $icon = ' [%help%]'; - $ph['HelpIcon'] = wrapIcon($icon, 9); + $icon = ' [%help%]'; + $ph['HelpIcon'] = wrapIcon($icon, 9); } if($modx->hasPermission('new_document')) { - $icon = '[%add_resource%]'; - $ph['ResourceIcon'] = wrapIcon($icon, 4); - $icon = '[%add_weblink%]'; - $ph['WeblinkIcon'] = wrapIcon($icon, 72); + $icon = '[%add_resource%]'; + $ph['ResourceIcon'] = wrapIcon($icon, 4); + $icon = '[%add_weblink%]'; + $ph['WeblinkIcon'] = wrapIcon($icon, 72); } if($modx->hasPermission('assets_images')) { - $icon = '[%images_management%]'; - $ph['ImagesIcon'] = wrapIcon($icon, 72); + $icon = '[%images_management%]'; + $ph['ImagesIcon'] = wrapIcon($icon, 72); } if($modx->hasPermission('assets_files')) { - $icon = '[%files_management%]'; - $ph['FilesIcon'] = wrapIcon($icon, 72); + $icon = '[%files_management%]'; + $ph['FilesIcon'] = wrapIcon($icon, 72); } if($modx->hasPermission('change_password')) { - $icon = '[%change_password%]'; - $ph['PasswordIcon'] = wrapIcon($icon, 28); + $icon = '[%change_password%]'; + $ph['PasswordIcon'] = wrapIcon($icon, 28); } $icon = '[%logout%]'; $ph['LogoutIcon'] = wrapIcon($icon, 8); // do some config checks if(($modx->config['warning_visibility'] == 0 && $_SESSION['mgrRole'] == 1) || $modx->config['warning_visibility'] == 1) { - include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); - if($config_check_results != $_lang['configcheck_ok']) { - $ph['config_check_results'] = $config_check_results; - $ph['config_display'] = 'block'; - } else { - $ph['config_display'] = 'none'; - } + include_once(MODX_MANAGER_PATH . 'includes/config_check.inc.php'); + if($config_check_results != $_lang['configcheck_ok']) { + $ph['config_check_results'] = $config_check_results; + $ph['config_display'] = 'block'; + } else { + $ph['config_display'] = 'none'; + } } else { - $ph['config_display'] = 'none'; + $ph['config_display'] = 'none'; } // Check logout-reminder if(isset($_SESSION['show_logout_reminder'])) { - switch($_SESSION['show_logout_reminder']['type']) { - case 'logout_reminder': - $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); - $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']); - break; - } - $ph['show_logout_reminder'] = 'block'; - unset($_SESSION['show_logout_reminder']); + switch($_SESSION['show_logout_reminder']['type']) { + case 'logout_reminder': + $date = $modx->toDateFormat($_SESSION['show_logout_reminder']['lastHit'], 'dateOnly'); + $ph['logout_reminder_msg'] = str_replace('[+date+]', $date, $_lang['logout_reminder_msg']); + break; + } + $ph['show_logout_reminder'] = 'block'; + unset($_SESSION['show_logout_reminder']); } else { - $ph['show_logout_reminder'] = 'none'; + $ph['show_logout_reminder'] = 'none'; } // Check multiple sessions @@ -111,13 +111,13 @@ //$count = $modx->db->getValue($rs); /* if($count > 1) { - $ph['multiple_sessions_msg'] = $modx->parseText($_lang['multiple_sessions_msg'], array( - 'username' => $_SESSION['mgrShortname'], - 'total' => $count - )); - $ph['show_multiple_sessions'] = 'block'; + $ph['multiple_sessions_msg'] = $modx->parseText($_lang['multiple_sessions_msg'], array( + 'username' => $_SESSION['mgrShortname'], + 'total' => $count + )); + $ph['show_multiple_sessions'] = 'block'; } else { - $ph['show_multiple_sessions'] = 'none'; + $ph['show_multiple_sessions'] = 'none'; }*/ $ph['show_multiple_sessions'] = 'none'; @@ -125,36 +125,36 @@ $tpl = ' - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
[%yourinfo_username%][+username+]
[%yourinfo_role%][+role+]
[%yourinfo_previous_login%][+lastlogin+]
[%yourinfo_total_logins%][+logincount+]
[%inbox%][+msginfo+]
[%yourinfo_username%][+username+]
[%yourinfo_role%][+role+]
[%yourinfo_previous_login%][+lastlogin+]
[%yourinfo_total_logins%][+logincount+]
[%inbox%][+msginfo+]
'; $nrnewmessages = '' . $_SESSION['nrnewmessages'] . ''; $ph['UserInfo'] = $modx->parseText($tpl, array( - 'username' => $modx->getLoginUserName(), - 'role' => $_SESSION['mgrPermissions']['name'], - 'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time), - 'logincount' => $_SESSION['mgrLogincount'] + 1, - 'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages) + 'username' => $modx->getLoginUserName(), + 'role' => $_SESSION['mgrPermissions']['name'], + 'lastlogin' => $modx->toDateFormat($_SESSION['mgrLastlogin'] + $server_offset_time), + 'logincount' => $_SESSION['mgrLogincount'] + 1, + 'msginfo' => sprintf($_lang['welcome_messages'], $_SESSION['nrtotalmessages'], $nrnewmessages) )); $from = array(); @@ -163,59 +163,59 @@ $rs = $modx->db->select('*', $from, '', 'username ASC, au.sid ASC'); if($modx->db->getRecordCount($rs) < 1) { - $html = '

[%no_active_users_found%]

'; + $html = '

[%no_active_users_found%]

'; } else { - include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); - $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; - $ph['now'] = strftime('%H:%M:%S', $now); - $timetocheck = ($now - (60 * 20)); //+$server_offset_time; - $html = ' -
- [%onlineusers_message%] - [+now+]): -
-
- - - - - - - - - - - '; - - $userList = array(); - $userCount = array(); - // Create userlist with session-count first before output - while($activeusers = $modx->db->getRow($rs)) { - $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; - - $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; - $webicon = $activeusers['internalKey'] < 0 ? 'Web user ' : ''; - $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip']; - $currentaction = getAction($activeusers['action'], $activeusers['id']); - $userList[] = array( - $idle, - '', - $activeusers['username'], - $webicon, - abs($activeusers['internalKey']), - $ip, - strftime($modx->toDateFormat(0,'formatOnly').' %H:%M:%S', $activeusers['lasthit'] + $server_offset_time), - $currentaction - ); - } - foreach($userList as $params) { - $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; - $html .= "\n\t\t" . vsprintf('', $params); - } - - $html .= ' - -
[%onlineusers_user%]ID[%onlineusers_ipaddress%][%onlineusers_lasthit%][%onlineusers_action%]                   
%s%s%s%s%s%s
+ include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); + $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; + $ph['now'] = strftime('%H:%M:%S', $now); + $timetocheck = ($now - (60 * 20)); //+$server_offset_time; + $html = ' +
+ [%onlineusers_message%] + [+now+]): +
+
+ + + + + + + + + + + '; + + $userList = array(); + $userCount = array(); + // Create userlist with session-count first before output + while($activeusers = $modx->db->getRow($rs)) { + $userCount[$activeusers['internalKey']] = isset($userCount[$activeusers['internalKey']]) ? $userCount[$activeusers['internalKey']] + 1 : 1; + + $idle = $activeusers['lasthit'] < $timetocheck ? ' class="userIdle"' : ''; + $webicon = $activeusers['internalKey'] < 0 ? 'Web user ' : ''; + $ip = $activeusers['ip'] === '::1' ? '127.0.0.1' : $activeusers['ip']; + $currentaction = getAction($activeusers['action'], $activeusers['id']); + $userList[] = array( + $idle, + '', + $activeusers['username'], + $webicon, + abs($activeusers['internalKey']), + $ip, + strftime($modx->toDateFormat(0,'formatOnly').' %H:%M:%S', $activeusers['lasthit'] + $server_offset_time), + $currentaction + ); + } + foreach($userList as $params) { + $params[1] = $userCount[$params[4]] > 1 ? ' class="userMultipleSessions"' : ''; + $html .= "\n\t\t" . vsprintf('', $params); + } + + $html .= ' + +
[%onlineusers_user%]ID[%onlineusers_ipaddress%][%onlineusers_lasthit%][%onlineusers_action%]                   
%s%s%s%s%s%s
'; } @@ -254,135 +254,135 @@ // invoke event OnManagerWelcomePrerender $evtOut = $modx->invokeEvent('OnManagerWelcomePrerender'); if(is_array($evtOut)) { - $output = implode('', $evtOut); - $ph['OnManagerWelcomePrerender'] = $output; + $output = implode('', $evtOut); + $ph['OnManagerWelcomePrerender'] = $output; } $buttons = ''; if($modx->hasPermission('new_document')) { - $buttons .=' - - - [%add_resource%] - - - - - - [%add_weblink%] - - '; + $buttons .=' + + + [%add_resource%] + + + + + + [%add_weblink%] + + '; } if($modx->hasPermission('assets_images')) { - $buttons .=' - - - [%images_management%] - - '; + $buttons .=' + + + [%images_management%] + + '; } if($modx->hasPermission('assets_files')) { - $buttons .=' - - - [%files_management%] - - '; + $buttons .=' + + + [%files_management%] + + '; } if($modx->hasPermission('edit_template') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_plugin')) { - $buttons .=' - - - [%elements%] - - '; + $buttons .=' + + + [%elements%] + + '; } if($modx->hasPermission('bk_manager')) { - $buttons .=' - - - [%backup%] - - '; + $buttons .=' + + + [%backup%] + + '; } if($modx->hasPermission('change_password')) { - $buttons .=' - - - [%change_password%] - - '; + $buttons .=' + + + [%change_password%] + + '; } $buttons .=' - - - [%logout%] - - '; + + + [%logout%] + + '; $messages = ''; if($modx->hasPermission('messages')) { - $messages = ' - [%inbox%] - [[#getMessageCount]] - '; + $messages = ' + [%inbox%] + [[#getMessageCount]] + '; } $widgets['welcome'] = array( - 'menuindex' => '10', - 'id' => 'welcome', - 'cols' => 'col-lg-6', - 'icon' => 'fa-home', - 'title' => '[%welcome_title%]', - 'body' => ' -
- '.$buttons.' -
-
- - - - - - - - - - - - - - - - - - '.$messages.' -
[%yourinfo_username%][[#getLoginUserName]]
[%yourinfo_role%][[$_SESSION[\'mgrPermissions\'][\'name\'] ]]
[%yourinfo_previous_login%][[$_SESSION[\'mgrLastlogin\']:math(\'%s+[(server_offset_time)]\'):dateFormat]]
[%yourinfo_total_logins%][[$_SESSION[\'mgrLogincount\']:math(\'%s+1\')]]
-
- ', - 'hide'=>'0' + 'menuindex' => '10', + 'id' => 'welcome', + 'cols' => 'col-lg-6', + 'icon' => 'fa-home', + 'title' => '[%welcome_title%]', + 'body' => ' +
+ '.$buttons.' +
+
+ + + + + + + + + + + + + + + + + + '.$messages.' +
[%yourinfo_username%][[#getLoginUserName]]
[%yourinfo_role%][[$_SESSION[\'mgrPermissions\'][\'name\'] ]]
[%yourinfo_previous_login%][[$_SESSION[\'mgrLastlogin\']:math(\'%s+[(server_offset_time)]\'):dateFormat]]
[%yourinfo_total_logins%][[$_SESSION[\'mgrLogincount\']:math(\'%s+1\')]]
+
+ ', + 'hide'=>'0' ); $widgets['onlineinfo'] = array( - 'menuindex' => '20', - 'id' => 'onlineinfo', - 'cols' => 'col-lg-6', - 'icon' => 'fa-user', - 'title' => '[%onlineusers_title%]', - 'body' => '
[+OnlineInfo+]
', - 'hide'=>'0' + 'menuindex' => '20', + 'id' => 'onlineinfo', + 'cols' => 'col-lg-6', + 'icon' => 'fa-user', + 'title' => '[%onlineusers_title%]', + 'body' => '
[+OnlineInfo+]
', + 'hide'=>'0' ); $widgets['recentinfo'] = array( - 'menuindex' => '30', - 'id' => 'modxrecent_widget', - 'cols' => 'col-sm-12', - 'icon' => 'fa-pencil-square-o', - 'title' => '[%activity_title%]', - 'body' => '
[+RecentInfo+]
', - 'hide'=>'0' + 'menuindex' => '30', + 'id' => 'modxrecent_widget', + 'cols' => 'col-sm-12', + 'icon' => 'fa-pencil-square-o', + 'title' => '[%activity_title%]', + 'body' => '
[+RecentInfo+]
', + 'hide'=>'0' ); if ($modx->config['rss_url_news']) { $widgets['news'] = array( @@ -410,7 +410,7 @@ // invoke OnManagerWelcomeHome event $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets)); if(is_array($sitewidgets)) { - $newwidgets = array(); + $newwidgets = array(); foreach($sitewidgets as $widget){ $newwidgets = array_merge($newwidgets, unserialize($widget)); } @@ -418,49 +418,37 @@ } usort($widgets, function ($a, $b) { - return $a['menuindex'] - $b['menuindex']; + return $a['menuindex'] - $b['menuindex']; }); $tpl = getTplWidget(); $output = ''; foreach($widgets as $widget) { - if ($widget['hide'] != '1'){ - $output .= $modx->parseText($tpl, $widget); - } + if ($widget['hide'] != '1'){ + $output .= $modx->parseText($tpl, $widget); + } } $ph['widgets'] = $output; // load template -if(!isset($modx->config['manager_welcome_tpl']) || empty($modx->config['manager_welcome_tpl'])) { - $modx->config['manager_welcome_tpl'] = MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'; -} - -$target = $modx->config['manager_welcome_tpl']; +$target = $modx->getConfig('manager_welcome_tpl'); $target = str_replace('[+base_path+]', MODX_BASE_PATH, $target); $target = $modx->mergeSettingsContent($target); if(substr($target, 0, 1) === '@') { - if(substr($target, 0, 6) === '@CHUNK') { - $content = $modx->getChunk(trim(substr($target, 7))); - } elseif(substr($target, 0, 5) === '@FILE') { - $content = file_get_contents(trim(substr($target, 6))); - } else { - $content = ''; - } + if(substr($target, 0, 6) === '@CHUNK') { + $content = $modx->getChunk(trim(substr($target, 7))); + } elseif(substr($target, 0, 5) === '@FILE') { + $content = file_get_contents(trim(substr($target, 6))); + } else { + $content = ''; + } } else { - $chunk = $modx->getChunk($target); - if($chunk !== false && !empty($chunk)) { - $content = $chunk; - } elseif(is_file(MODX_BASE_PATH . $target)) { - $content = file_get_contents(MODX_BASE_PATH . $target); - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); - } elseif(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html')) // ClipperCMS compatible - { - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/html/welcome.html'); - } else { - $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); - } + if(is_file(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl')) { + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/welcome.tpl'); + } else { + $content = file_get_contents(MODX_MANAGER_PATH . 'media/style/common/welcome.tpl'); + } } // merge placeholders @@ -468,8 +456,8 @@ $content = $modx->mergeSettingsContent($content); $content = $modx->parseText($content, $ph); if(strpos($content, '[+') !== false) { - $modx->toPlaceholders($ph); - $content = $modx->mergePlaceholderContent($content); + $modx->toPlaceholders($ph); + $content = $modx->mergePlaceholderContent($content); } $content = $modx->parseDocumentSource($content); $content = $modx->parseText($content, $_lang, '[%', '%]'); @@ -477,187 +465,187 @@ $content = $modx->cleanUpMODXTags($content); //cleanup if($js = $modx->getRegisteredClientScripts()) { - $content .= $js; + $content .= $js; } echo $content; // -// +// // // function getTplWidget() { // recent document info - return ' -
-
-
[+title+]
-
[+body+]
-
-
+ return ' +
+
+
[+title+]
+
[+body+]
+
+
'; } function getRecentInfo() { // recent document info - $modx = evolutionCMS(); - - $modx->addSnippet('recentInfoList', 'getRecentInfoList'); - - $html = ' -
- - - - - - - - - - - - [[#recentInfoList]] - -
[%id%][%resource_title%][%page_data_edited%][%user%][%mgrlog_action%]
-
+ $modx = evolutionCMS(); + + $modx->addSnippet('recentInfoList', 'getRecentInfoList'); + + $html = ' +
+ + + + + + + + + + + + [[#recentInfoList]] + +
[%id%][%resource_title%][%page_data_edited%][%user%][%mgrlog_action%]
+
'; - return $html; + return $html; } function getRecentInfoList() { - $modx = evolutionCMS(); - - $rs = $modx->db->select('id, pagetitle, editedon, editedby, deleted, published', '[+prefix+]site_content', '', 'editedon DESC', 10); - - if($modx->db->getRecordCount($rs) < 1) { - return '[%no_activity_message%]'; - } - - $tpl = getRecentInfoRowTpl(); - - $btntpl['edit'] = ' '; - $btntpl['preview_btn'] = ' '; - - $output = array(); - while($ph = $modx->db->getRow($rs)) { - $docid = $ph['id']; - $_ = $modx->getUserInfo($ph['editedby']); - $ph['username'] = $_['username']; - - if($ph['deleted'] == 1) { - $ph['status'] = 'deleted text-danger'; - } elseif($ph['published'] == 0) { - $ph['status'] = 'unpublished font-italic text-muted'; - } else { - $ph['status'] = 'published'; - } - - if($modx->hasPermission('edit_document')) { - $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']); - } else { - $ph['edit_btn'] = ''; - } - - $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : ''; - $ph['preview_btn'] = str_replace(array( - '[+id+]', - '[+preview_disabled+]' - ), array( - $docid, - $preview_disabled - ), $btntpl['preview_btn']); - - if($modx->hasPermission('delete_document')) { - if($ph['deleted'] == 0) { - $delete_btn = ' '; - } else { - $delete_btn = ' '; - } - $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn); - } else { - $ph['delete_btn'] = ''; - } - - if($ph['deleted'] == 1 && $ph['published'] == 0) { - $publish_btn = ' '; - } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { - $publish_btn = ' '; - } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { - $publish_btn = ' '; - } else { - $publish_btn = ' '; - } - $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn); - - $ph['info_btn'] = str_replace('[+id+]', $docid, ''); + $modx = evolutionCMS(); + + $rs = $modx->db->select('id, pagetitle, editedon, editedby, deleted, published', '[+prefix+]site_content', '', 'editedon DESC', 10); + + if($modx->db->getRecordCount($rs) < 1) { + return '[%no_activity_message%]'; + } + + $tpl = getRecentInfoRowTpl(); + + $btntpl['edit'] = ' '; + $btntpl['preview_btn'] = ' '; + + $output = array(); + while($ph = $modx->db->getRow($rs)) { + $docid = $ph['id']; + $_ = $modx->getUserInfo($ph['editedby']); + $ph['username'] = $_['username']; + + if($ph['deleted'] == 1) { + $ph['status'] = 'deleted text-danger'; + } elseif($ph['published'] == 0) { + $ph['status'] = 'unpublished font-italic text-muted'; + } else { + $ph['status'] = 'published'; + } + + if($modx->hasPermission('edit_document')) { + $ph['edit_btn'] = str_replace('[+id+]', $docid, $btntpl['edit']); + } else { + $ph['edit_btn'] = ''; + } + + $preview_disabled = ($ph['deleted'] == 1) ? 'disabled' : ''; + $ph['preview_btn'] = str_replace(array( + '[+id+]', + '[+preview_disabled+]' + ), array( + $docid, + $preview_disabled + ), $btntpl['preview_btn']); + + if($modx->hasPermission('delete_document')) { + if($ph['deleted'] == 0) { + $delete_btn = ' '; + } else { + $delete_btn = ' '; + } + $ph['delete_btn'] = str_replace('[+id+]', $docid, $delete_btn); + } else { + $ph['delete_btn'] = ''; + } + + if($ph['deleted'] == 1 && $ph['published'] == 0) { + $publish_btn = ' '; + } elseif($ph['deleted'] == 1 && $ph['published'] == 1) { + $publish_btn = ' '; + } elseif($ph['deleted'] == 0 && $ph['published'] == 0) { + $publish_btn = ' '; + } else { + $publish_btn = ' '; + } + $ph['publish_btn'] = str_replace('[+id+]', $docid, $publish_btn); + + $ph['info_btn'] = str_replace('[+id+]', $docid, ''); $ph['longtitle'] = !isset($ph['longtitle']) || $ph['longtitle'] == '' ? '([%not_set%])' : html_escape($ph['longtitle']); $ph['description'] = !isset($ph['description']) || $ph['description'] == '' ? '([%not_set%])' : html_escape($ph['description']); $ph['introtext'] = !isset($ph['introtext']) || $ph['introtext'] == '' ? '([%not_set%])' : html_escape($ph['introtext']); $ph['alias'] = !isset($ph['alias']) || $ph['alias'] == '' ? '([%not_set%])' : html_escape($ph['alias']); - $output[] = $modx->parseText($tpl, $ph); - } - return implode("\n", $output); + $output[] = $modx->parseText($tpl, $ph); + } + return implode("\n", $output); } function getRecentInfoRowTpl() { - $modx = EvolutionCMS(); - $tpl = ' - - [+id+] - [+pagetitle:htmlentities+] - [+editedon:math("%s+[(server_offset_time)]"):dateFormat=`'.$modx->toDateFormat(0,'formatOnly').' %H:%M:%S`+] - [+username:htmlentities+] - [+edit_btn+][+preview_btn+][+delete_btn+][+publish_btn+][+info_btn+] - - - -
-
    -
  • [%long_title%]: [+longtitle+]
  • -
  • [%description%]: [+description+]
  • -
  • [%resource_summary%]: [+introtext+]
  • -
  • [%type%]: [+type:is(reference):then([%weblink%]):else([%resource%])+]
  • -
  • [%resource_alias%]: [+alias+]
  • -
  • [%page_data_cacheable%]: [+cacheable:is(1):then([%yes%]):else([%no%])+]
  • -
  • [%resource_opt_show_menu%]: [+hidemenu:is(0):then([%yes%]):else([%no%])+]
  • -
  • [%page_data_template%]: [+template:templatename:htmlentities+]
  • -
-
- - '; - return $tpl; + $modx = EvolutionCMS(); + $tpl = ' + + [+id+] + [+pagetitle:htmlentities+] + [+editedon:math("%s+[(server_offset_time)]"):dateFormat=`'.$modx->toDateFormat(0,'formatOnly').' %H:%M:%S`+] + [+username:htmlentities+] + [+edit_btn+][+preview_btn+][+delete_btn+][+publish_btn+][+info_btn+] + + + +
+
    +
  • [%long_title%]: [+longtitle+]
  • +
  • [%description%]: [+description+]
  • +
  • [%resource_summary%]: [+introtext+]
  • +
  • [%type%]: [+type:is(reference):then([%weblink%]):else([%resource%])+]
  • +
  • [%resource_alias%]: [+alias+]
  • +
  • [%page_data_cacheable%]: [+cacheable:is(1):then([%yes%]):else([%no%])+]
  • +
  • [%resource_opt_show_menu%]: [+hidemenu:is(0):then([%yes%]):else([%no%])+]
  • +
  • [%page_data_template%]: [+template:templatename:htmlentities+]
  • +
+
+ + '; + return $tpl; } // setup icons function wrapIcon($i, $action) { - return sprintf('%s', $action, $i); + return sprintf('%s', $action, $i); } function getStartUpScript() { - $script = ' + $script = ' '; - return $script; + return $script; } From d7878411f90e1ade2b02c27c1f7ca715f5ae59f6 Mon Sep 17 00:00:00 2001 From: Serg <64j@mail.ru> Date: Tue, 15 Mar 2022 21:08:51 +0300 Subject: [PATCH 020/168] [1.4x] Fix installer for PHP8.1 --- install/actions/action_summary.php | 4 +- install/connection.databasetest.php | 5 +- install/functions.php | 16 +++++ install/instprocessor.php | 72 ++++++++++--------- install/setup.data.sql | 2 +- install/setup.info.php | 22 +++--- install/sqlParser.class.php | 16 +++-- .../includes/document.parser.class.inc.php | 2 +- .../processors/cache_sync.class.processor.php | 8 +-- 9 files changed, 87 insertions(+), 60 deletions(-) diff --git a/install/actions/action_summary.php b/install/actions/action_summary.php index f72b874f4e..9d942ff592 100755 --- a/install/actions/action_summary.php +++ b/install/actions/action_summary.php @@ -238,7 +238,7 @@ function f_owc($path, $data, $mode = null){ // check table prefix if ($conn && $installMode == 0) { echo '

' . $_lang['checking_table_prefix'] . $table_prefix . '`: '; - if ($rs= mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { + if ($rs= checkIssetTable($conn, "$dbase.`" . $table_prefix . "site_content`")) { echo '' . $_lang['failed'] . '' . $_lang['table_prefix_already_inuse'] . '

'; $errors++; echo "

" . $_lang['table_prefix_already_inuse_note'] . '

'; @@ -247,7 +247,7 @@ function f_owc($path, $data, $mode = null){ } } elseif ($conn && $installMode == 2) { echo '

' . $_lang['checking_table_prefix'] . $table_prefix . '`: '; - if (!$rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { + if (!$rs = checkIssetTable($conn, "$dbase.`" . $table_prefix . "site_content`")) { echo '' . $_lang['failed'] . '' . $_lang['table_prefix_not_exist'] . '

'; $errors++; echo '

' . $_lang['table_prefix_not_exist_note'] . '

'; diff --git a/install/connection.databasetest.php b/install/connection.databasetest.php index dcc83a4387..52b127407f 100755 --- a/install/connection.databasetest.php +++ b/install/connection.databasetest.php @@ -14,10 +14,11 @@ define('MGR_DIR','manager'); } require_once("lang.php"); +require_once 'functions.php'; $output = $_lang["status_checking_database"]; $h = explode(':', $host, 2); -if (!$conn = mysqli_connect($h[0], $uid, $pwd,'', isset($h[1]) ? $h[1] : null)) { +if (!$conn = mysqli_connect($h[0], $uid, $pwd,'', $h[1] ?? null)) { $output .= ''.$_lang['status_failed'].''; } else { @@ -39,7 +40,7 @@ $output .= ''.$_lang['status_passed_database_created'].''; } } - elseif (($installMode == 0) && (mysqli_query($conn, "SELECT COUNT(*) FROM {$database_name}.`{$tableprefix}site_content`"))) { + elseif (($installMode == 0) && checkIssetTable($conn, "`$database_name`.`{$tableprefix}site_content`")) { $output .= ''.$_lang['status_failed_table_prefix_already_in_use'].''; } elseif (($database_connection_method != 'SET NAMES') && ($rs = mysqli_query($conn, "show variables like 'collation_database'")) && ($row = mysqli_fetch_row($rs)) && ($row[1] != $database_collation)) { diff --git a/install/functions.php b/install/functions.php index 07c3da9b03..250cbf7187 100755 --- a/install/functions.php +++ b/install/functions.php @@ -177,3 +177,19 @@ function getLangs($install_language) return implode("\n", $_); } } + +if (!function_exists('checkIssetTable')) { + function checkIssetTable($conn, $tableName) + { + try { + $r = mysqli_query($conn, "SELECT COUNT(*) FROM $tableName"); + + if ($r && $r->fetch_assoc()) { + return true; + } + } catch (Exception $exception) { + } + + return false; + } +} diff --git a/install/instprocessor.php b/install/instprocessor.php index 996e68bc8c..0ccc5f30c9 100755 --- a/install/instprocessor.php +++ b/install/instprocessor.php @@ -1,4 +1,8 @@ ".$_lang['setup_database_selection_failed']."".$_lang['setup_database_selection_failed_note']."

"; $create = true; } else { - if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); + if (function_exists('mysqli_set_charset') && $database_charset) mysqli_set_charset($conn, $database_charset); mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); echo ''.$_lang['ok']."

"; } @@ -116,7 +120,7 @@ // check table prefix if ($installMode == 0) { echo "

" . $_lang['checking_table_prefix'] . $table_prefix . "`: "; - if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { + if (@ $rs = checkIssetTable($conn, "$dbase.`" . $table_prefix . "site_content`")) { echo '' . $_lang['failed'] . "" . $_lang['table_prefix_already_inuse'] . "

"; $errors += 1; echo "

" . $_lang['table_prefix_already_inuse_note'] . "

"; @@ -282,7 +286,7 @@ // Install Templates if (isset ($_POST['template']) || $installData) { echo "

" . $_lang['templates'] . ":

"; - $selTemplates = $_POST['template']; + $selTemplates = $_POST['template'] ?? []; foreach ($moduleTemplates as $k=>$moduleTemplate) { $installSample = in_array('sample', $moduleTemplate[6]) && $installData == 1; if($installSample || in_array($k, $selTemplates)) { @@ -337,22 +341,22 @@ // Install Template Variables if (isset ($_POST['tv']) || $installData) { echo "

" . $_lang['tvs'] . ":

"; - $selTVs = $_POST['tv']; + $selTVs = $_POST['tv'] ?? []; foreach ($moduleTVs as $k=>$moduleTV) { $installSample = in_array('sample', $moduleTV[12]) && $installData == 1; if($installSample || in_array($k, $selTVs)) { - $name = mysqli_real_escape_string($conn, $moduleTV[0]); - $caption = mysqli_real_escape_string($conn, $moduleTV[1]); - $desc = mysqli_real_escape_string($conn, $moduleTV[2]); - $input_type = mysqli_real_escape_string($conn, $moduleTV[3]); - $input_options = mysqli_real_escape_string($conn, $moduleTV[4]); - $input_default = mysqli_real_escape_string($conn, $moduleTV[5]); - $output_widget = mysqli_real_escape_string($conn, $moduleTV[6]); - $output_widget_params = mysqli_real_escape_string($conn, $moduleTV[7]); - $filecontent = $moduleTV[8]; - $assignments = $moduleTV[9]; - $category = mysqli_real_escape_string($conn, $moduleTV[10]); - $locked = mysqli_real_escape_string($conn, $moduleTV[11]); + $name = mysqli_real_escape_string($conn, $moduleTV[0] ?? ''); + $caption = mysqli_real_escape_string($conn, $moduleTV[1] ?? ''); + $desc = mysqli_real_escape_string($conn, $moduleTV[2] ?? ''); + $input_type = mysqli_real_escape_string($conn, $moduleTV[3] ?? ''); + $input_options = mysqli_real_escape_string($conn, $moduleTV[4] ?? ''); + $input_default = mysqli_real_escape_string($conn, $moduleTV[5] ?? ''); + $output_widget = mysqli_real_escape_string($conn, $moduleTV[6] ?? ''); + $output_widget_params = mysqli_real_escape_string($conn, $moduleTV[7] ?? ''); + $filecontent = $moduleTV[8] ?? ''; + $assignments = $moduleTV[9] ?? ''; + $category = mysqli_real_escape_string($conn, $moduleTV[10] ?? ''); + $locked = mysqli_real_escape_string($conn, $moduleTV[11] ?? ''); // Create the category if it does not already exist @@ -394,7 +398,7 @@ foreach ($assignments as $assignment) { $template = mysqli_real_escape_string($conn, $assignment); $ts = mysqli_query($sqlParser->conn, "SELECT id FROM $dbase.`".$table_prefix."site_templates` WHERE templatename='$template';"); - if ($ds && $ts) { + if ($ds && $ts && $ts->lengths) { $tRow = mysqli_fetch_assoc($ts); $templateId = $tRow['id']; mysqli_query($sqlParser->conn, "INSERT INTO $dbase.`" . $table_prefix . "site_tmplvar_templates` (tmplvarid, templateid) VALUES($id, $templateId)"); @@ -408,7 +412,7 @@ // Install Chunks if (isset ($_POST['chunk']) || $installData) { echo "

" . $_lang['chunks'] . ":

"; - $selChunks = $_POST['chunk']; + $selChunks = $_POST['chunk'] ?? []; foreach ($moduleChunks as $k=>$moduleChunk) { $installSample = in_array('sample', $moduleChunk[5]) && $installData == 1; $count_new_name = 0; @@ -463,7 +467,7 @@ // Install Modules if (isset ($_POST['module']) || $installData) { echo "

" . $_lang['modules'] . ":

"; - $selModules = $_POST['module']; + $selModules = $_POST['module'] ?? []; foreach ($moduleModules as $k=>$moduleModule) { $installSample = in_array('sample', $moduleModule[7]) && $installData == 1; if($installSample || in_array($k, $selModules)) { @@ -510,22 +514,22 @@ // Install Plugins if (isset ($_POST['plugin']) || $installData) { echo "

" . $_lang['plugins'] . ":

"; - $selPlugs = $_POST['plugin']; + $selPlugs = $_POST['plugin'] ?? []; foreach ($modulePlugins as $k=>$modulePlugin) { - $installSample = in_array('sample', (array) $modulePlugin[8]) && $installData == 1; + $installSample = in_array('sample', (array) $modulePlugin[8] ?? []) && $installData == 1; if($installSample || in_array($k, $selPlugs)) { - $name = mysqli_real_escape_string($conn, $modulePlugin[0]); - $desc = mysqli_real_escape_string($conn, $modulePlugin[1]); - $filecontent = $modulePlugin[2]; - $properties = $modulePlugin[3]; - $events = explode(",", $modulePlugin[4]); - $guid = mysqli_real_escape_string($conn, $modulePlugin[5]); - $category = mysqli_real_escape_string($conn, $modulePlugin[6]); + $name = mysqli_real_escape_string($conn, $modulePlugin[0] ?? ''); + $desc = mysqli_real_escape_string($conn, $modulePlugin[1] ?? ''); + $filecontent = $modulePlugin[2] ?? ''; + $properties = $modulePlugin[3] ?? ''; + $events = explode(",", $modulePlugin[4] ?? ''); + $guid = mysqli_real_escape_string($conn, $modulePlugin[5] ?? ''); + $category = mysqli_real_escape_string($conn, $modulePlugin[6] ?? ''); $leg_names = ''; - $disabled = $modulePlugin[9]; + $disabled = $modulePlugin[9] ?? ''; if(array_key_exists(7, $modulePlugin)) { // parse comma-separated legacy names and prepare them for sql IN clause - $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7]))) . "'"; + $leg_names = "'" . implode("','", preg_split('/\s*,\s*/', mysqli_real_escape_string($conn, $modulePlugin[7] ?? ''))) . "'"; } if (!file_exists($filecontent)) echo "

  $name: " . $_lang['unable_install_plugin'] . " '$filecontent' " . $_lang['not_found'] . ".

"; @@ -619,7 +623,7 @@ // Install Snippets if (isset ($_POST['snippet']) || $installData) { echo "

" . $_lang['snippets'] . ":

"; - $selSnips = $_POST['snippet']; + $selSnips = $_POST['snippet'] ?? []; foreach ($moduleSnippets as $k=>$moduleSnippet) { $installSample = in_array('sample', $moduleSnippet[5]) && $installData == 1; if($installSample || in_array($k, $selSnips)) { @@ -809,9 +813,9 @@ function propUpdate($new,$old){ * @param bool|mixed $json * @return string */ -function parseProperties($propertyString, $json=false) { - $propertyString = str_replace('{}', '', $propertyString ); - $propertyString = str_replace('} {', ',', $propertyString ); +function parseProperties($propertyString = '', $json=false) { + $propertyString = str_replace('{}', '', $propertyString ?? ''); + $propertyString = str_replace('} {', ',', $propertyString ?? ''); if(empty($propertyString)) return $json ? json_encode(array(), JSON_UNESCAPED_UNICODE) : array(); if($propertyString=='{}' || $propertyString=='[]') return $json ? json_encode(array(), JSON_UNESCAPED_UNICODE) : array(); diff --git a/install/setup.data.sql b/install/setup.data.sql index a8642cf95b..17beedb3b5 100755 --- a/install/setup.data.sql +++ b/install/setup.data.sql @@ -95,7 +95,7 @@ REPLACE INTO `{PREFIX}site_tmplvar_contentvalues` VALUES ('3','8','9','assets/im REPLACE INTO `{PREFIX}site_snippets` VALUES ('24','ifsnippet','','0','1','0','\nif (!isset($modx->snippetCache[$name])) {\n return \'

For work \'.$name.\' in demo site you need install \'.$name.\' from Extras module

\';\n}','0','{}',' ','1509819147','1509826185','0'); -REPLACE INTO `{PREFIX}site_snippets` VALUES ('23','prepareBlog','','0','1','0','\nif ($data[\'image\'] != \'\'){\n $data[\'blog-image\'] = \'runSnippet(\'phpthumb\', array(\'input\'=>$data[\'image\'], \'options\'=>\'w=600,h=280,zc=1\')).\'\" alt=\"\'.$data[\'pagetitle\'].\'\">\';\n}else{\n $data[\'blog-image\'] = \'\';\n}\nreturn $data;','0','{}',' ','1507723822','1509819933','0'); +REPLACE INTO `{PREFIX}site_snippets` VALUES ('23','prepareBlog','','0','1','0','\nif (!empty($data[\'image\'])){\n $data[\'blog-image\'] = \'runSnippet(\'phpthumb\', array(\'input\'=>$data[\'image\'], \'options\'=>\'w=600,h=280,zc=1\')).\'\" alt=\"\'.$data[\'pagetitle\'].\'\">\';\n}else{\n $data[\'blog-image\'] = \'\';\n}\nreturn $data;','0','{}',' ','1507723822','1509819933','0'); # # Dumping data for table `site_templates` diff --git a/install/setup.info.php b/install/setup.info.php index 89b06f11af..6242c26937 100755 --- a/install/setup.info.php +++ b/install/setup.info.php @@ -57,10 +57,10 @@ $params['caption'], $description, $params['input_type'], - $params['input_options'], - $params['input_default'], - $params['output_widget'], - $params['output_widget_params'], + $params['input_options'] ?? null, + $params['input_default'] ?? null, + $params['output_widget'] ?? null, + $params['output_widget_params'] ?? null, "$templatePath/{$params['filename']}", /* not currently used */ $params['template_assignments']!="*"?$params['template_assignments']:implode(",",array_map(function($value){return isset($value[0]) && is_scalar($value[0]);},$mt)), /* comma-separated list of template names */ $params['modx_category'], @@ -110,7 +110,7 @@ $params['name'], $description, "$snippetPath/{$params['filename']}", - $params['properties'], + $params['properties'] ?? null, $params['modx_category'], array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false ); @@ -134,13 +134,13 @@ $params['name'], $description, "$pluginPath/{$params['filename']}", - $params['properties'], + $params['properties'] ?? null, $params['events'], - $params['guid'], + $params['guid'] ?? null, $params['modx_category'], - $params['legacy_names'], + $params['legacy_names'] ?? null, array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false, - (int)$params['disabled'] + (int)($params['disabled'] ?? 0) ); } } @@ -163,8 +163,8 @@ $params['name'], $description, "$modulePath/{$params['filename']}", - $params['properties'], - $params['guid'], + $params['properties'] ?? null, + $params['guid'] ?? null, (int)$params['shareparams'], $params['modx_category'], array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false diff --git a/install/sqlParser.class.php b/install/sqlParser.class.php index f5e7785e64..138490edc6 100755 --- a/install/sqlParser.class.php +++ b/install/sqlParser.class.php @@ -18,9 +18,9 @@ class SqlParser { public $adminpass; public $managerlanguage; public $mode; - public $fileManagerPath; - public $imgPath; - public $imgUrl; + public $fileManagerPath = ''; + public $imgPath = ''; + public $imgUrl = ''; public $dbMODx; public $dbVersion; public $connection_charset; @@ -29,7 +29,7 @@ class SqlParser { public $autoTemplateLogic; public $database_collation; - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { + public function __construct($host = null, $user = null, $password = null, $db = null, $prefix='modx_', $adminname = null, $adminemail = null, $adminpass = null, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { $this->host = $host; $this->dbname = $db; $this->prefix = $prefix; @@ -128,7 +128,13 @@ public function process($filename) { $num = $num + 1; - if ($sql_do) mysqli_query($this->conn, $sql_do); + if ($sql_do) { + try { + mysqli_query($this->conn, $sql_do); + } catch (Exception $exception) { + + } + } if(mysqli_error($this->conn)) { // Ignore duplicate and drop errors - Raymond if ($this->ignoreDuplicateErrors){ diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 516635c6ad..d442afdaf1 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -5929,7 +5929,7 @@ public function getPluginCode($pluginName) */ public function parseProperties($propertyString, $elementName = null, $elementType = null) { - $propertyString = trim($propertyString); + $propertyString = trim($propertyString ?? ''); $propertyString = str_replace('{}', '', $propertyString); $propertyString = str_replace('} {', ',', $propertyString); $property = []; diff --git a/manager/processors/cache_sync.class.processor.php b/manager/processors/cache_sync.class.processor.php index 80822ac7b7..2063929743 100755 --- a/manager/processors/cache_sync.class.processor.php +++ b/manager/processors/cache_sync.class.processor.php @@ -27,7 +27,7 @@ public function __construct() { $modx = evolutionCMS(); - $this->request_time = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; + $this->request_time = $_SERVER['REQUEST_TIME'] + ($modx->config['server_offset_time'] ?? 0); } /** @@ -265,7 +265,7 @@ public function buildCache($modx) } if (!isset($config['full_aliaslisting']) || $config['full_aliaslisting'] != 1) { - if ($config['aliaslistingfolder'] == 1) { + if (!empty($config['aliaslistingfolder'])) { $f['id'] = 'c.id'; $f['alias'] = "IF( c.alias='', c.id, c.alias)"; $f['parent'] = 'c.parent'; @@ -332,7 +332,7 @@ public function buildCache($modx) $content .= '$s[\'' . $key . '\']=\'return false;\';'; } else { $value = trim($row['snippet']); - if ($modx->config['minifyphp_incache']) { + if (!empty($modx->config['minifyphp_incache'])) { $value = $this->php_strip_whitespace($value); } $content .= '$s[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; @@ -357,7 +357,7 @@ public function buildCache($modx) while ($row = $modx->db->getRow($rs)) { $key = $modx->db->escape($row['name']); $value = trim($row['plugincode']); - if ($modx->config['minifyphp_incache']) { + if (!empty($modx->config['minifyphp_incache'])) { $value = $this->php_strip_whitespace($value); } $content .= '$p[\'' . $key . '\']=\'' . $this->escapeSingleQuotes($value) . '\';'; From 8308671e0fa3c23b7127ed05a6c774e10c8a68d1 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 05:28:31 +0300 Subject: [PATCH 021/168] fix manager password recovery # Conflicts: # manager/processors/login.processor.php --- manager/processors/login.processor.php | 508 +++++++++++++------------ 1 file changed, 265 insertions(+), 243 deletions(-) diff --git a/manager/processors/login.processor.php b/manager/processors/login.processor.php index 5132051dfa..ca878259f6 100755 --- a/manager/processors/login.processor.php +++ b/manager/processors/login.processor.php @@ -1,11 +1,11 @@ db->connect(); $modx->getSettings(); $modx->invokeEvent('OnManagerPageInit'); @@ -17,49 +17,56 @@ extract($modx->config, EXTR_OVERWRITE); // include_once the language file -$_lang = array(); +$_lang = []; include_once("{$core_path}lang/english.inc.php"); -if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { - include_once("{$core_path}lang/{$manager_language}.inc.php"); +if ($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { + include_once("{$core_path}lang/{$manager_language}.inc.php"); } // allow custom language overrides not altered by future EVO-updates -if(is_file("{$core_path}lang/override/{$manager_language}.inc.php")) { - include_once("{$core_path}lang/override/{$manager_language}.inc.php"); +if (is_file("{$core_path}lang/override/{$manager_language}.inc.php")) { + include_once("{$core_path}lang/override/{$manager_language}.inc.php"); } // include the logger include_once("{$core_path}log.class.inc.php"); // Initialize System Alert Message Queque -if(!isset($_SESSION['SystemAlertMsgQueque'])) { - $_SESSION['SystemAlertMsgQueque'] = array(); +if (!isset($_SESSION['SystemAlertMsgQueque'])) { + $_SESSION['SystemAlertMsgQueque'] = []; } $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; // initiate the content manager class // for backward compatibility -$username = isset($_REQUEST['username']) ? $modx->db->escape($modx->htmlspecialchars($_REQUEST['username'], ENT_NOQUOTES)) : ''; -$givenPassword = isset($_POST['password']) ? $modx->htmlspecialchars($_POST['password'], ENT_NOQUOTES) : ''; -$captcha_code = isset($_POST['captcha_code']) ? $_POST['captcha_code'] : ''; -$rememberme = isset($_POST['rememberme']) ? $_POST['rememberme'] : ''; +if (isset($_GET['username']) && is_scalar($_GET['username'])) { + $username = $_GET['username']; +} elseif (isset($_POST['username']) && is_scalar($_POST['username'])) { + $username = $_POST['username']; +} else { + $username = ''; +} +$username = $modx->db->escape($modx->htmlspecialchars($username, ENT_NOQUOTES)); +$givenPassword = $modx->htmlspecialchars($_POST['password'] ?? '', ENT_NOQUOTES); +$captcha_code = $_POST['captcha_code'] ?? ''; +$rememberme = $_POST['rememberme'] ?? ''; $failed_allowed = $modx->config['failed_login_attempts']; // invoke OnBeforeManagerLogin event -$modx->invokeEvent('OnBeforeManagerLogin', array( - 'username' => $username, - 'userpassword' => $givenPassword, - 'rememberme' => $rememberme - )); +$modx->invokeEvent('OnBeforeManagerLogin', [ + 'username' => $username, + 'userpassword' => $givenPassword, + 'rememberme' => $rememberme +]); $fields = 'mu.*, ua.*'; $from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua'; $where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id"; $rs = $modx->db->select($fields, $from, $where); $limit = $modx->db->getRecordCount($rs); -if($limit == 0 || $limit > 1) { - jsAlert($_lang['login_processor_unknown_user']); - return; +if ($limit == 0 || $limit > 1) { + jsAlert($_lang['login_processor_unknown_user']); + return; } $row = $modx->db->getRow($rs); @@ -78,131 +85,134 @@ $email = $row['email']; // get the user settings from the database -$rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''"); -while($row = $modx->db->getRow($rs)) { - extract($row); - ${$setting_name} = $setting_value; +$rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', + "user='{$internalKey}' AND setting_value!=''"); +while ($row = $modx->db->getRow($rs)) { + extract($row); + ${$setting_name} = $setting_value; } // blocked due to number of login errors. -if($failedlogins >= $failed_allowed && $blockeduntildate > time()) { - @session_destroy(); - session_unset(); - if($cip = getenv("HTTP_CLIENT_IP")) { - $ip = $cip; - } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) { - $ip = $cip; - } elseif($cip = getenv("REMOTE_ADDR")) { - $ip = $cip; - } else { - $ip = "UNKNOWN"; - } - $log = new logHandler; - $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip); - jsAlert($_lang['login_processor_many_failed_logins']); - return; +if ($failedlogins >= $failed_allowed && $blockeduntildate > time()) { + @session_destroy(); + session_unset(); + if ($cip = getenv("HTTP_CLIENT_IP")) { + $ip = $cip; + } elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) { + $ip = $cip; + } elseif ($cip = getenv("REMOTE_ADDR")) { + $ip = $cip; + } else { + $ip = "UNKNOWN"; + } + $log = new logHandler; + $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip); + jsAlert($_lang['login_processor_many_failed_logins']); + return; } // blocked due to number of login errors, but get to try again -if($failedlogins >= $failed_allowed && $blockeduntildate < time()) { - $fields = array(); - $fields['failedlogincount'] = '0'; - $fields['blockeduntil'] = time() - 1; - $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); +if ($failedlogins >= $failed_allowed && $blockeduntildate < time()) { + $fields = []; + $fields['failedlogincount'] = '0'; + $fields['blockeduntil'] = time() - 1; + $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); } // this user has been blocked by an admin, so no way he's loggin in! -if($blocked == '1') { - @session_destroy(); - session_unset(); - jsAlert($_lang['login_processor_blocked1']); - return; +if ($blocked == '1') { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked1']); + return; } // blockuntil: this user has a block until date -if($blockeduntildate > time()) { - @session_destroy(); - session_unset(); - jsAlert($_lang['login_processor_blocked2']); - return; +if ($blockeduntildate > time()) { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked2']); + return; } // blockafter: this user has a block after date -if($blockedafterdate > 0 && $blockedafterdate < time()) { - @session_destroy(); - session_unset(); - jsAlert($_lang['login_processor_blocked3']); - return; +if ($blockedafterdate > 0 && $blockedafterdate < time()) { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked3']); + return; } // allowed ip -if($allowed_ip) { - if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { - if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { - jsAlert($_lang['login_processor_remotehost_ip']); - return; - } - } - if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { - jsAlert($_lang['login_processor_remote_ip']); - return; - } +if ($allowed_ip) { + if (($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { + if (gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { + jsAlert($_lang['login_processor_remotehost_ip']); + return; + } + } + if (!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { + jsAlert($_lang['login_processor_remote_ip']); + return; + } } // allowed days -if($allowed_days) { - $date = getdate(); - $day = $date['wday'] + 1; - if(!in_array($day,explode(',',$allowed_days))) { - jsAlert($_lang['login_processor_date']); - return; - } +if ($allowed_days) { + $date = getdate(); + $day = $date['wday'] + 1; + if (!in_array($day, explode(',', $allowed_days))) { + jsAlert($_lang['login_processor_date']); + return; + } } // invoke OnManagerAuthentication event -$rt = $modx->invokeEvent('OnManagerAuthentication', array( - 'userid' => $internalKey, - 'username' => $username, - 'userpassword' => $givenPassword, - 'savedpassword' => $dbasePassword, - 'rememberme' => $rememberme - )); +$rt = $modx->invokeEvent('OnManagerAuthentication', [ + 'userid' => $internalKey, + 'username' => $username, + 'userpassword' => $givenPassword, + 'savedpassword' => $dbasePassword, + 'rememberme' => $rememberme +]); // check if plugin authenticated the user $matchPassword = false; -if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { - // check user password - local authentication - $hashType = $modx->manager->getHashType($dbasePassword); - if($hashType == 'phpass') { - $matchPassword = login($username, $_REQUEST['password'], $dbasePassword); - } elseif($hashType == 'md5') { - $matchPassword = loginMD5($internalKey, $_REQUEST['password'], $dbasePassword, $username); - } elseif($hashType == 'v1') { - $matchPassword = loginV1($internalKey, $_REQUEST['password'], $dbasePassword, $username); - } else { - $matchPassword = false; - } -} else if($rt === true || (is_array($rt) && in_array(true, $rt))) { - $matchPassword = true; +if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { + // check user password - local authentication + $hashType = $modx->manager->getHashType($dbasePassword); + if ($hashType == 'phpass') { + $matchPassword = login($username, $_POST['password'], $dbasePassword); + } elseif ($hashType == 'md5') { + $matchPassword = loginMD5($internalKey, $_POST['password'], $dbasePassword, $username); + } elseif ($hashType == 'v1') { + $matchPassword = loginV1($internalKey, $_POST['password'], $dbasePassword, $username); + } else { + $matchPassword = false; + } +} else { + if ($rt === true || (is_array($rt) && in_array(true, $rt))) { + $matchPassword = true; + } } -$blocked_minutes = (int)$modx->config['blocked_minutes']; +$blocked_minutes = (int) $modx->config['blocked_minutes']; -if(!$matchPassword) { - jsAlert($_lang['login_processor_wrong_password']); - incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); - return; +if (!$matchPassword) { + jsAlert($_lang['login_processor_wrong_password']); + incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); + return; } -if($modx->config['use_captcha'] == 1) { - if(!isset ($_SESSION['veriword'])) { - jsAlert($_lang['login_processor_captcha_config']); - return; - } elseif($_SESSION['veriword'] != $captcha_code) { - jsAlert($_lang['login_processor_bad_code']); - incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); - return; - } +if ($modx->config['use_captcha'] == 1) { + if (!isset ($_SESSION['veriword'])) { + jsAlert($_lang['login_processor_captcha_config']); + return; + } elseif ($_SESSION['veriword'] != $captcha_code) { + jsAlert($_lang['login_processor_bad_code']); + incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); + return; + } } $modx->cleanupExpiredLocks(); @@ -226,191 +236,203 @@ $_SESSION['mgrPermissions'] = $modx->db->getRow($rs); // successful login so reset fail count and update key values -$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); +$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", + '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); // get user's document groups $i = 0; $rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups') . ' ug - INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); + INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', + "ug.member='{$internalKey}'"); $_SESSION['mgrDocgroups'] = $modx->db->getColumn('documentgroup', $rs); $_SESSION['mgrToken'] = md5($currentsessionid); -if($rememberme == '1') { - $_SESSION['modx.mgr.session.cookie.lifetime'] = (int)$modx->config['session.cookie.lifetime']; - - // Set a cookie separate from the session cookie with the username in it. - // Are we using secure connection? If so, make sure the cookie is secure - global $https_port; - - $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); - if(version_compare(PHP_VERSION, '5.2', '<')) { - setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure); - } else { - setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true); - } +if ($rememberme == '1') { + $_SESSION['modx.mgr.session.cookie.lifetime'] = (int) $modx->config['session.cookie.lifetime']; + + // Set a cookie separate from the session cookie with the username in it. + // Are we using secure connection? If so, make sure the cookie is secure + global $https_port; + + $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); + if (version_compare(PHP_VERSION, '5.2', '<')) { + setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, + '; HttpOnly', $secure); + } else { + setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, null, + $secure, true); + } } else { - $_SESSION['modx.mgr.session.cookie.lifetime'] = 0; + $_SESSION['modx.mgr.session.cookie.lifetime'] = 0; - // Remove the Remember Me cookie - setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL); + // Remove the Remember Me cookie + setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL); } // Check if user already has an active session, if not check if user pressed logout end of last session $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'"); $activeSession = $modx->db->getValue($rs); -if(!$activeSession) { - $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8"); - if($lastHit = $modx->db->getValue($rs)) { - $_SESSION['show_logout_reminder'] = array( - 'type' => 'logout_reminder', - 'lastHit' => $lastHit - ); - } +if (!$activeSession) { + $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), + "internalKey='{$internalKey}' AND action != 8"); + if ($lastHit = $modx->db->getValue($rs)) { + $_SESSION['show_logout_reminder'] = [ + 'type' => 'logout_reminder', + 'lastHit' => $lastHit + ]; + } } $log = new logHandler; $log->initAndWriteLog('Logged in', $modx->getLoginUserID(), $_SESSION['mgrShortname'], '58', '-', 'MODX'); // invoke OnManagerLogin event -$modx->invokeEvent('OnManagerLogin', array( - 'userid' => $internalKey, - 'username' => $username, - 'userpassword' => $givenPassword, - 'rememberme' => $rememberme - )); +$modx->invokeEvent('OnManagerLogin', [ + 'userid' => $internalKey, + 'username' => $username, + 'userpassword' => $givenPassword, + 'rememberme' => $rememberme +]); // check if we should redirect user to a web page -$rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'"); -$id = (int)$modx->db->getValue($rs); -if($id > 0) { - $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); - if($_POST['ajax'] == 1) { - echo $header; - } else { - header($header); - } +$rs = $modx->db->select('setting_value', '[+prefix+]user_settings', + "user='{$internalKey}' AND setting_name='manager_login_startup'"); +$id = (int) $modx->db->getValue($rs); +if ($id > 0) { + $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); + if ($_POST['ajax'] == 1) { + echo $header; + } else { + header($header); + } } else { - $header = 'Location: ' . MODX_MANAGER_URL; - if($_POST['ajax'] == 1) { - echo $header; - } else { - header($header); - } + $header = 'Location: ' . MODX_MANAGER_URL; + if ($_POST['ajax'] == 1) { + echo $header; + } else { + header($header); + } } /** * show javascript alert * - * @param string $msg + * @param string $msg */ -function jsAlert($msg) { - $modx = evolutionCMS(); - if(isset($_POST['ajax']) && $_POST['ajax'] != 1) { - echo ""; - } else { - echo $msg . "\n"; - } +function jsAlert($msg) +{ + $modx = evolutionCMS(); + if ($_POST['ajax'] != 1) { + echo ""; + } else { + echo $msg . "\n"; + } } /** - * @param string $username - * @param string $givenPassword - * @param string $dbasePassword + * @param string $username + * @param string $givenPassword + * @param string $dbasePassword * @return bool */ -function login($username, $givenPassword, $dbasePassword) { - $modx = evolutionCMS(); - return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); +function login($username, $givenPassword, $dbasePassword) +{ + $modx = evolutionCMS(); + return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); } /** - * @param int $internalKey - * @param string $givenPassword - * @param string $dbasePassword - * @param string $username + * @param int $internalKey + * @param string $givenPassword + * @param string $dbasePassword + * @param string $username * @return bool */ -function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { - $modx = evolutionCMS(); +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) +{ + $modx = evolutionCMS(); - $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); + $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); - if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { - $modx->config['pwd_hash_algo'] = 'UNCRYPT'; - } + if (!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { + $modx->config['pwd_hash_algo'] = 'UNCRYPT'; + } - if($user_algo !== $modx->config['pwd_hash_algo']) { - $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; - $modx->config['pwd_hash_algo'] = $user_algo; - } + if ($user_algo !== $modx->config['pwd_hash_algo']) { + $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; + $modx->config['pwd_hash_algo'] = $user_algo; + } - if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { - return false; - } + if ($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { + return false; + } - updateNewHash($username, $givenPassword); + updateNewHash($username, $givenPassword); - return true; + return true; } /** - * @param int $internalKey - * @param string $givenPassword - * @param string $dbasePassword - * @param string $username + * @param int $internalKey + * @param string $givenPassword + * @param string $dbasePassword + * @param string $username * @return bool */ -function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { - $modx = evolutionCMS(); - - if($dbasePassword != md5($givenPassword)) { - return false; - } - updateNewHash($username, $givenPassword); - return true; +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) +{ + $modx = evolutionCMS(); + + if ($dbasePassword != md5($givenPassword)) { + return false; + } + updateNewHash($username, $givenPassword); + return true; } /** - * @param string $username - * @param string $password + * @param string $username + * @param string $password */ -function updateNewHash($username, $password) { - $modx = evolutionCMS(); +function updateNewHash($username, $password) +{ + $modx = evolutionCMS(); - $field = array(); - $field['password'] = $modx->phpass->HashPassword($password); - $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); + $field = []; + $field['password'] = $modx->phpass->HashPassword($password); + $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); } /** - * @param int $internalKey - * @param int $failedlogins - * @param int $failed_allowed - * @param int $blocked_minutes + * @param int $internalKey + * @param int $failedlogins + * @param int $failed_allowed + * @param int $blocked_minutes */ -function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { - $modx = evolutionCMS(); - - $failedlogins += 1; - - $fields = array('failedlogincount' => $failedlogins); - if($failedlogins >= $failed_allowed) //block user for too many fail attempts - { - $fields['blockeduntil'] = time() + ($blocked_minutes * 60); - } - - $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); - - if($failedlogins < $failed_allowed) { - //sleep to help prevent brute force attacks - $sleep = (int) $failedlogins / 2; - if($sleep > 5) { - $sleep = 5; - } - sleep($sleep); - } - @session_destroy(); - session_unset(); - return; +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) +{ + $modx = evolutionCMS(); + + $failedlogins += 1; + + $fields = ['failedlogincount' => $failedlogins]; + if ($failedlogins >= $failed_allowed) //block user for too many fail attempts + { + $fields['blockeduntil'] = time() + ($blocked_minutes * 60); + } + + $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); + + if ($failedlogins < $failed_allowed) { + //sleep to help prevent brute force attacks + $sleep = (int) $failedlogins / 2; + if ($sleep > 5) { + $sleep = 5; + } + sleep($sleep); + } + @session_destroy(); + session_unset(); + return; } From 38f5995157b29d6d897dd9aec12eb0d1d52a1416 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 05:51:38 +0300 Subject: [PATCH 022/168] fix xss --- manager/actions/category_mgr/skin/sort.tpl.phtml | 2 +- manager/actions/mutate_templates.dynamic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manager/actions/category_mgr/skin/sort.tpl.phtml b/manager/actions/category_mgr/skin/sort.tpl.phtml index 7b2b9c36f0..d6d148d8dc 100755 --- a/manager/actions/category_mgr/skin/sort.tpl.phtml +++ b/manager/actions/category_mgr/skin/sort.tpl.phtml @@ -22,7 +22,7 @@ foreach ($data as $category): ?> - + diff --git a/manager/actions/mutate_templates.dynamic.php b/manager/actions/mutate_templates.dynamic.php index 4d4071a44f..788301f599 100755 --- a/manager/actions/mutate_templates.dynamic.php +++ b/manager/actions/mutate_templates.dynamic.php @@ -109,7 +109,7 @@

- (' . $content['id'] . ')' : $_lang['new_template']) ?> + htmlspecialchars($content['templatename']) . '(' . $content['id'] . ')' : $_lang['new_template']) ?>

From 53efd74e9823ffcd67bdcd0394c7005349ea83e3 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 05:57:01 +0300 Subject: [PATCH 023/168] fix xss --- manager/actions/resources/functions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/actions/resources/functions.inc.php b/manager/actions/resources/functions.inc.php index 8255a85aa4..499df31eef 100755 --- a/manager/actions/resources/functions.inc.php +++ b/manager/actions/resources/functions.inc.php @@ -254,7 +254,7 @@ function prepareElementRowPh($row, $resourceTable, $resources) { return array( 'class' => $class ? ' class="' . $class . '"' : '', 'lockedByUser' => $lockedByUser, - 'name' => $row['name'], + 'name' => $modx->htmlspecialchars($row['name']), 'caption' => $caption, 'buttons' => $buttons, 'marks' => $marks, From f6c00dea660eaf57f5791b21bbba79f93a5eaf65 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 06:25:44 +0300 Subject: [PATCH 024/168] fix xss --- manager/actions/category_mgr/skin/edit.tpl.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/actions/category_mgr/skin/edit.tpl.phtml b/manager/actions/category_mgr/skin/edit.tpl.phtml index 7be26e7d9b..cbdbc3fd71 100755 --- a/manager/actions/category_mgr/skin/edit.tpl.phtml +++ b/manager/actions/category_mgr/skin/edit.tpl.phtml @@ -37,7 +37,7 @@ - txt('delete'); ?> + txt('delete'); ?> From d07f93e346035aa0351379bf78ef6ae3e4239e3d Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 06:39:25 +0300 Subject: [PATCH 025/168] fix xss --- .../actions/category_mgr/inc/request_trigger.inc.php | 10 +++++----- .../skin/chunks/categorize/category.tpl.phtml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manager/actions/category_mgr/inc/request_trigger.inc.php b/manager/actions/category_mgr/inc/request_trigger.inc.php index d95f86fd55..acc1b0915c 100755 --- a/manager/actions/category_mgr/inc/request_trigger.inc.php +++ b/manager/actions/category_mgr/inc/request_trigger.inc.php @@ -121,7 +121,7 @@ $cm->addMessage( sprintf( $cm->txt( 'cm_category_x_saved_at_position_y' ), - $category, + htmlspecialchars($category), $rank ), 'add' @@ -153,7 +153,7 @@ $cm->addMessage( sprintf( $cm->txt('cm_category_x_moved_to_position_y'), - $data['category'], + htmlspecialchars($data['category']), $data['rank'] ), 'sort' @@ -195,7 +195,7 @@ $cm->addMessage( sprintf( $cm->txt('cm_category_x_deleted'), - urldecode( $_data['origin'] ) + htmlspecialchars(urldecode( $_data['origin'] )) ), 'edit' ); @@ -215,7 +215,7 @@ sprintf( $cm->txt('cm_category_x_renamed_to_y'), urldecode( $_data['origin'] ), - $data['category'] + htmlspecialchars($data['category']) ), 'edit' ); @@ -242,7 +242,7 @@ $cm->addMessage( sprintf( $cm->txt('cm_category_x_deleted'), - urldecode( $_GET[$cm->get('request_key')]['category'] ) + htmlspecialchars(urldecode( $_GET[$cm->get('request_key')]['category'] )) ), 'edit' ); diff --git a/manager/actions/category_mgr/skin/chunks/categorize/category.tpl.phtml b/manager/actions/category_mgr/skin/chunks/categorize/category.tpl.phtml index 236f8882d5..22ce5882dc 100755 --- a/manager/actions/category_mgr/skin/chunks/categorize/category.tpl.phtml +++ b/manager/actions/category_mgr/skin/chunks/categorize/category.tpl.phtml @@ -1,6 +1,6 @@
-

+

renderView('chunks/categorize/drag_element',$element); ?> From 7e5c8b3dc009de8027c0b2f0966386fb68bb92aa Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 15:52:21 +0300 Subject: [PATCH 026/168] add editorconfig --- .editorconfig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..8f7e8058a2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,26 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +tab_width = 4 + +[**.js] +tab_width = 4 + +[**.coffee] +tab_width = 4 + +[**.cson] +tab_width = 4 + +[**.json] +tab_width = 4 + +[**rc] +tab_width = 4 + +[**php] +tab_width = 4 From 0183b665811599c15772914a3f176c52d4345811 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 20 Mar 2022 16:57:51 +0300 Subject: [PATCH 027/168] fix warning --- install/setup.info.php | 1 + 1 file changed, 1 insertion(+) diff --git a/install/setup.info.php b/install/setup.info.php index 6242c26937..f79ec6f13c 100755 --- a/install/setup.info.php +++ b/install/setup.info.php @@ -275,6 +275,7 @@ function clean_up($sqlParser) { echo "An error occurred while executing a query: ".mysqli_error($sqlParser->conn); } else { + $ids = []; while($r = mysqli_fetch_assoc($ds)) $ids[]=$r["id"]; if(count($ids)>0) { mysqli_query($sqlParser->conn,"UPDATE `".$sqlParser->prefix."site_content` SET privatemgr = 1 WHERE id IN (".implode(", ",$ids).")"); From 5e9748744467b4193a7cd835a4a66b2597b12cc3 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Thu, 24 Mar 2022 17:57:26 +0300 Subject: [PATCH 028/168] fix event log style --- manager/actions/eventlog.dynamic.php | 215 ++++++++++++++------------- 1 file changed, 108 insertions(+), 107 deletions(-) diff --git a/manager/actions/eventlog.dynamic.php b/manager/actions/eventlog.dynamic.php index 2ff16bc4aa..05160851ad 100755 --- a/manager/actions/eventlog.dynamic.php +++ b/manager/actions/eventlog.dynamic.php @@ -1,9 +1,9 @@ INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly."); + die("INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly."); } if(!$modx->hasPermission('view_eventlog')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } // Get table Names (alphabetical) @@ -16,14 +16,14 @@ // get and save search string if(isset($_REQUEST['op']) && $_REQUEST['op'] == 'reset') { - $sqlQuery = $query = ''; - $_PAGE['vs']['search'] = ''; + $sqlQuery = $query = ''; + $_PAGE['vs']['search'] = ''; } else { - $sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : (isset($_PAGE['vs']['search']) ? $_PAGE['vs']['search'] : ''); - if(!is_numeric($sqlQuery)) { - $sqlQuery = $modx->db->escape($query); - } - $_PAGE['vs']['search'] = $query; + $sqlQuery = $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : (isset($_PAGE['vs']['search']) ? $_PAGE['vs']['search'] : ''); + if(!is_numeric($sqlQuery)) { + $sqlQuery = $modx->db->escape($query); + } + $_PAGE['vs']['search'] = $query; } // get & save listmode @@ -40,74 +40,74 @@ ?>
- - + + -

- -

+

+ +

-
-
-
+
+
+
-
- -
+
+ +
-
-
- db->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el - LEFT JOIN {$tbl_manager_users} AS mu ON mu.id=el.user AND el.usertype=0 - LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "" . (is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '') . "(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC"); - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; - $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items - $grd->pagerClass = ''; - $grd->pagerStyle = 'white-space: normal;'; - $grd->pageClass = 'page-item'; - $grd->selPageClass = 'page-item active'; - $grd->noRecordMsg = $_lang['no_records_found']; - $grd->cssClass = "table data eventlog"; // nowrap - $grd->columnHeaderClass = "tableHeader"; - $grd->itemClass = "tableItem"; - $grd->altItemClass = "tableAltItem"; - $grd->fields = "type,source,createdon,eventid,username"; - $grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid']; - $grd->colWidths = "1%,,1%,1%,1%"; - $grd->colAligns = "center,,,center,center"; - $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p'; - if($listmode == '1') { - $grd->pageSize = 0; - } - if(isset($_REQUEST['op']) && $_REQUEST['op'] == 'reset') { - $grd->pageNumber = 1; - } - // render grid - echo $grd->render(); - ?> -
-
-
-
+
+
+ db->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el + LEFT JOIN {$tbl_manager_users} AS mu ON mu.id=el.user AND el.usertype=0 + LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "" . (is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '') . "(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC"); + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; + $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items + $grd->pagerClass = ''; + $grd->pagerStyle = 'white-space: normal;'; + $grd->pageClass = 'page-item'; + $grd->selPageClass = 'page-item active'; + $grd->noRecordMsg = $_lang['no_records_found']; + $grd->cssClass = "table data eventlog"; // nowrap + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->fields = "type,source,createdon,eventid,username"; + $grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid']; + $grd->colWidths = "1%,,1%,1%,1%"; + $grd->colAligns = "center,,,center,center"; + $grd->colWraps = ",,1"; + $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p'; + if($listmode == '1') { + $grd->pageSize = 0; + } + if(isset($_REQUEST['op']) && $_REQUEST['op'] == 'reset') { + $grd->pageNumber = 1; + } + // render grid + echo $grd->render(); + ?> +
+
+
+
From 8c1688229540851b3ebffb973b838043ceff032d Mon Sep 17 00:00:00 2001 From: Pathologic Date: Thu, 24 Mar 2022 18:01:13 +0300 Subject: [PATCH 029/168] fix event log date format --- manager/actions/eventlog.dynamic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/actions/eventlog.dynamic.php b/manager/actions/eventlog.dynamic.php index 05160851ad..6cba04b2bc 100755 --- a/manager/actions/eventlog.dynamic.php +++ b/manager/actions/eventlog.dynamic.php @@ -147,7 +147,7 @@ function menuAction(a) { $grd->colWidths = "1%,,1%,1%,1%"; $grd->colAligns = "center,,,center,center"; $grd->colWraps = ",,1"; - $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p'; + $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %R'; if($listmode == '1') { $grd->pageSize = 0; } From 948ed3a786c4a88fd3c73281ff400cf2733e868d Mon Sep 17 00:00:00 2001 From: Pathologic Date: Fri, 25 Mar 2022 11:46:14 +0300 Subject: [PATCH 030/168] fix php 8.1 error --- manager/includes/document.parser.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index d442afdaf1..702655a802 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -2660,7 +2660,7 @@ public function sendStrictURI() $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; $len_base_url = strlen($this->config['base_url']); - $url_path = $q;//LANG + $url_path = $q ?? '';//LANG if (substr($url_path, 0, $len_base_url) === $this->config['base_url']) { $url_path = substr($url_path, $len_base_url); From ae404e726b96d7bf06ca508cca936ea4d7375bba Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sat, 26 Mar 2022 13:45:09 +0300 Subject: [PATCH 031/168] php 8.1 --- manager/includes/document.parser.class.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 702655a802..149f174119 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4833,9 +4833,9 @@ public function toDateFormat($timestamp = 0, $mode = '') } if (empty($mode)) { - $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); + $strTime = date_format(date_create('@' . $timestamp), $dateFormat . " %H:%M:%S"); } elseif ($mode == 'dateOnly') { - $strTime = strftime($dateFormat, $timestamp); + $strTime = date_format(date_create('@' . $timestamp), $dateFormat); } elseif ($mode == 'formatOnly') { $strTime = $dateFormat; } From 21f8b5147ac1ddb6faf4d0e085804179e1ada6c6 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 27 Mar 2022 05:21:04 +0300 Subject: [PATCH 032/168] revert php 8.1 fix # Conflicts: # manager/includes/document.parser.class.inc.php --- manager/includes/document.parser.class.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 149f174119..702655a802 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4833,9 +4833,9 @@ public function toDateFormat($timestamp = 0, $mode = '') } if (empty($mode)) { - $strTime = date_format(date_create('@' . $timestamp), $dateFormat . " %H:%M:%S"); + $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); } elseif ($mode == 'dateOnly') { - $strTime = date_format(date_create('@' . $timestamp), $dateFormat); + $strTime = strftime($dateFormat, $timestamp); } elseif ($mode == 'formatOnly') { $strTime = $dateFormat; } From d275ada5684383bce39367c15556c6373ecb8590 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Tue, 29 Mar 2022 16:55:55 +0300 Subject: [PATCH 033/168] php 8.1 --- assets/modules/store/installer/setup.info.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/modules/store/installer/setup.info.php b/assets/modules/store/installer/setup.info.php index a07d55856c..9acc80bfba 100755 --- a/assets/modules/store/installer/setup.info.php +++ b/assets/modules/store/installer/setup.info.php @@ -119,7 +119,7 @@ $params['name'], $description, "$snippetPath/{$params['filename']}", - $params['properties'], + $params['properties'] ?? '', $params['modx_category'], array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false ); @@ -143,7 +143,7 @@ $params['name'], $description, "$pluginPath/{$params['filename']}", - $params['properties'], + $params['properties'] ?? '', $params['events'], $params['guid'], $params['modx_category'], @@ -171,7 +171,7 @@ $params['name'], $description, "$modulePath/{$params['filename']}", - $params['properties'], + $params['properties'] ?? '', $params['guid'], (int)$params['shareparams'], $params['modx_category'], From 54c8ac1c30fb6543585241fd43fa34eb96e2b6fb Mon Sep 17 00:00:00 2001 From: Pathologic Date: Wed, 30 Mar 2022 14:05:04 +0300 Subject: [PATCH 034/168] php 8.1 --- manager/includes/extenders/dbapi.mysqli.class.inc.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index 5d3942d6cb..b09a7b84c1 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -151,7 +151,12 @@ public function query($sql, $watchError = true) $sql = implode("\n", $sql); } $this->lastQuery = $sql; - if (!($result = $this->conn->query($sql))) { + try { + $result = $this->conn->query($sql); + } catch (Exception $e) { + $result = false; + } + if (!$result) { if (!$watchError) { return false; } From 7a1bfaa585eb9e16e61f54488479d39f0c199eca Mon Sep 17 00:00:00 2001 From: Pathologic Date: Wed, 6 Apr 2022 04:51:45 +0300 Subject: [PATCH 035/168] remove strftime # Conflicts: # manager/includes/document.parser.class.inc.php --- manager/actions/user_management.static.php | 2 +- .../actions/web_user_management.static.php | 2 +- manager/actions/welcome.static.php | 6 +++--- manager/includes/controls/datagrid.class.php | 4 ++-- manager/includes/default_config.php | 2 +- .../includes/document.parser.class.inc.php | 10 +++++----- .../extenders/modifiers.class.inc.php | 9 +++------ manager/includes/tmplvars.format.inc.php | 4 ++-- manager/media/browser/mcpuk/core/uploader.php | 20 ++++++++++++++++--- 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/manager/actions/user_management.static.php b/manager/actions/user_management.static.php index 4538038d8d..fdfa2db2a6 100755 --- a/manager/actions/user_management.static.php +++ b/manager/actions/user_management.static.php @@ -160,7 +160,7 @@ function menuAction(a) { 'template:[+fullname+]', 'template:[+role+]', 'template:[+email+]', - 'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' %H:%M', + 'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' H:i', 'template:[+logincount+]', 'template:[+blocked+]' )); diff --git a/manager/actions/web_user_management.static.php b/manager/actions/web_user_management.static.php index 4565c8a247..18ad118e97 100755 --- a/manager/actions/web_user_management.static.php +++ b/manager/actions/web_user_management.static.php @@ -138,7 +138,7 @@ function menuAction(a) { $grd->colWidths = "1%,,,,1%,1%,1%"; $grd->colAligns = "center,,,,right' nowrap='nowrap,right,center"; $grd->colTypes = "template:||template:[+value+]||template:[+fullname+]||template:[+email+]||date: " . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . - " %H:%M"; + " H:i"; if($listmode == '1') { $grd->pageSize = 0; } diff --git a/manager/actions/welcome.static.php b/manager/actions/welcome.static.php index b7953f1c8e..b3e0ce88a3 100755 --- a/manager/actions/welcome.static.php +++ b/manager/actions/welcome.static.php @@ -167,7 +167,7 @@ } else { include_once(MODX_MANAGER_PATH . 'includes/actionlist.inc.php'); $now = $_SERVER['REQUEST_TIME'] + $server_offset_time; - $ph['now'] = strftime('%H:%M:%S', $now); + $ph['now'] = date('H:i:s', $now); $timetocheck = ($now - (60 * 20)); //+$server_offset_time; $html = '
@@ -204,7 +204,7 @@ $webicon, abs($activeusers['internalKey']), $ip, - strftime($modx->toDateFormat(0,'formatOnly').' %H:%M:%S', $activeusers['lasthit'] + $server_offset_time), + date($modx->toDateFormat(0,'formatOnly').' H:i:s', $activeusers['lasthit'] + $server_offset_time), $currentaction ); } @@ -594,7 +594,7 @@ function getRecentInfoRowTpl() { [+id+] [+pagetitle:htmlentities+] - [+editedon:math("%s+[(server_offset_time)]"):dateFormat=`'.$modx->toDateFormat(0,'formatOnly').' %H:%M:%S`+] + [+editedon:math("%s+[(server_offset_time)]"):dateFormat=`'.$modx->toDateFormat(0,'formatOnly').' H:i:s`+] [+username:htmlentities+] [+edit_btn+][+preview_btn+][+delete_btn+][+publish_btn+][+info_btn+] diff --git a/manager/includes/controls/datagrid.class.php b/manager/includes/controls/datagrid.class.php index e6f6c8e34b..a5c37ca914 100755 --- a/manager/includes/controls/datagrid.class.php +++ b/manager/includes/controls/datagrid.class.php @@ -279,9 +279,9 @@ public function formatColumnValue($row, $value, $type, &$align) { $value = strtotime($value); } if(!$type_format) { - $type_format = "%A %d, %B %Y"; + $type_format = "l d, F Y"; } - $value = strftime($type_format, $value); + $value = date($type_format, $value); break; case "boolean": diff --git a/manager/includes/default_config.php b/manager/includes/default_config.php index 9afd6e9718..dd4f3da0fc 100755 --- a/manager/includes/default_config.php +++ b/manager/includes/default_config.php @@ -83,7 +83,7 @@ $c['session_timeout'] = 15; $c['site_unavailable_message'] = $_lang['siteunavailable_message_default']; $c['allow_eval'] = 'with_scan'; -$c['safe_functions_at_eval'] = 'time,date,strtotime,strftime'; +$c['safe_functions_at_eval'] = 'time,date,strtotime'; $c['use_udperms'] = '1'; $c['email_sender_method'] = 1; $c['email_method'] = 'mail'; diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 702655a802..936980a51a 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4817,13 +4817,13 @@ public function toDateFormat($timestamp = 0, $mode = '') switch ($this->config['datetime_format']) { case 'YYYY/mm/dd': - $dateFormat = '%Y/%m/%d'; + $dateFormat = 'Y/m/d'; break; case 'dd-mm-YYYY': - $dateFormat = '%d-%m-%Y'; + $dateFormat = 'd-m-Y'; break; case 'mm/dd/YYYY': - $dateFormat = '%m/%d/%Y'; + $dateFormat = 'm/d/Y'; break; /* case 'dd-mmm-YYYY': @@ -4833,9 +4833,9 @@ public function toDateFormat($timestamp = 0, $mode = '') } if (empty($mode)) { - $strTime = strftime($dateFormat . " %H:%M:%S", $timestamp); + $strTime = date_format(date_create('@' . $timestamp), $dateFormat . " H:i:s"); } elseif ($mode == 'dateOnly') { - $strTime = strftime($dateFormat, $timestamp); + $strTime = date_format(date_create('@' . $timestamp), $dateFormat); } elseif ($mode == 'formatOnly') { $strTime = $dateFormat; } diff --git a/manager/includes/extenders/modifiers.class.inc.php b/manager/includes/extenders/modifiers.class.inc.php index da6e862edd..7c0b50868a 100755 --- a/manager/includes/extenders/modifiers.class.inc.php +++ b/manager/includes/extenders/modifiers.class.inc.php @@ -678,14 +678,11 @@ public function getValueFromPreset($key, $value, $cmd, $opt) case 'dateformat': if(empty($opt)) $opt = $modx->toDateFormat(null, 'formatOnly'); if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); - if(strpos($opt,'%')!==false) - return strftime($opt,0+$value); - else - return date($opt,0+$value); + return date($opt,0+$value); case 'time': - if(empty($opt)) $opt = '%H:%M'; + if(empty($opt)) $opt = 'H:i'; if(!preg_match('@^[0-9]+$@',$value)) $value = strtotime($value); - return strftime($opt,0+$value); + return date($opt,0+$value); case 'strtotime': return strtotime($value); ##### mathematical function diff --git a/manager/includes/tmplvars.format.inc.php b/manager/includes/tmplvars.format.inc.php index 862e00e76a..5acd012668 100755 --- a/manager/includes/tmplvars.format.inc.php +++ b/manager/includes/tmplvars.format.inc.php @@ -101,8 +101,8 @@ function getTVDisplayFormat($name, $value, $format, $paramstring = "", $tvtype = $value = 'now'; } $timestamp = getUnixtimeFromDateString($value); - $p = $params['format'] ? $params['format'] : "%A %d, %B %Y"; - $o = strftime($p, $timestamp); + $p = $params['format'] ? $params['format'] : "l d, F Y"; + $o = date($p, $timestamp); } else { $value = ''; } diff --git a/manager/media/browser/mcpuk/core/uploader.php b/manager/media/browser/mcpuk/core/uploader.php index aa2492e090..f8950278b2 100755 --- a/manager/media/browser/mcpuk/core/uploader.php +++ b/manager/media/browser/mcpuk/core/uploader.php @@ -658,9 +658,9 @@ protected function localize($langCode) { require "lang/{$langCode}.php"; setlocale(LC_ALL, $lang['_locale']); $this->charset = $lang['_charset']; - $this->dateTimeFull = $lang['_dateTimeFull']; - $this->dateTimeMid = $lang['_dateTimeMid']; - $this->dateTimeSmall = $lang['_dateTimeSmall']; + $this->dateTimeFull = $this->convertDateFormat($lang['_dateTimeFull']); + $this->dateTimeMid = $this->convertDateFormat($lang['_dateTimeMid']); + $this->dateTimeSmall = $this->convertDateFormat($lang['_dateTimeSmall']); unset($lang['_locale']); unset($lang['_charset']); unset($lang['_dateTimeFull']); @@ -669,6 +669,20 @@ protected function localize($langCode) { $this->labels = $lang; } + protected function convertDateFormat($format) + { + $replace = [ + '%d' => 'd', '%a' => 'D', '%e' => 'j', '%A' => 'l', '%u' => 'N', '%w' => 'w', '%j' => 'z', + '%V' => 'W', + '%B' => 'F', '%m' => 'm', '%b' => 'M', + '%G' => 'o', '%Y' => 'Y', '%y' => 'y', + '%P' => 'a', '%p' => 'A', '%l' => 'g', '%I' => 'h', '%H' => 'H', '%M' => 'i', '%S' => 's', + '%z' => 'O', '%Z' => 'T', + '%s' => 'U' + ]; + return strtr((string)$format, $replace); + } + /** * @param $string * @param array|null $data From 5608f2fa93812e3ae310b7df5d5e561303f7fbb8 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Mon, 11 Apr 2022 01:51:38 +0300 Subject: [PATCH 036/168] fix warnings --- .../modules/store/installer/instprocessor-fast.php | 12 ++++++------ assets/modules/store/installer/instprocessor.php | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/assets/modules/store/installer/instprocessor-fast.php b/assets/modules/store/installer/instprocessor-fast.php index d5a6462046..a64f36449a 100755 --- a/assets/modules/store/installer/instprocessor-fast.php +++ b/assets/modules/store/installer/instprocessor-fast.php @@ -295,8 +295,8 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - - $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); + $module = end($tmp); // remove installer docblock $module = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $module, 1); $module = $modx->db->escape($module); @@ -354,8 +354,8 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - - $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); + $plugin = end($tmp); // remove installer docblock $plugin = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $plugin, 1); $plugin = $modx->db->escape($plugin); @@ -449,8 +449,8 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - - $snippet = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent))); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); + $snippet = end($tmp); // remove installer docblock $snippet = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $snippet, 1); $snippet = $modx->db->escape($snippet); diff --git a/assets/modules/store/installer/instprocessor.php b/assets/modules/store/installer/instprocessor.php index 4261f483aa..21301d7804 100755 --- a/assets/modules/store/installer/instprocessor.php +++ b/assets/modules/store/installer/instprocessor.php @@ -258,8 +258,8 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - - $module = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); + $module = end($tmp); // remove installer docblock $module = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $module, 1); $module = $modx->db->escape($module); @@ -317,8 +317,8 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - - $plugin = end(preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2)); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); + $plugin = end($tmp); // remove installer docblock $plugin = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $plugin, 1); $plugin = $modx->db->escape($plugin); @@ -411,7 +411,7 @@ function parseProperties($propertyString) { // Create the category if it does not already exist $category = getCreateDbCategory($category, $sqlParser); - $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent)); + $tmp = preg_split("/(\/\/)?\s*\<\?php/", file_get_contents($filecontent), 2); $snippet = end($tmp); // remove installer docblock $snippet = preg_replace("/^.*?\/\*\*.*?\*\/\s+/s", '', $snippet, 1); From d06112d8999586682d6e6123b443ad2070c05c92 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Mon, 11 Apr 2022 04:19:44 +0300 Subject: [PATCH 037/168] fix save manager error --- manager/includes/document.parser.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php index 936980a51a..e1d42ceba1 100755 --- a/manager/includes/document.parser.class.inc.php +++ b/manager/includes/document.parser.class.inc.php @@ -4811,7 +4811,7 @@ public function toDateFormat($timestamp = 0, $mode = '') { $timestamp = trim($timestamp); if ($mode !== 'formatOnly' && empty($timestamp)) { - return '-'; + return ''; } $timestamp = (int)$timestamp; From 79787191d0e3280bc7308fc3f6cf8e23e995eb01 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Mon, 11 Apr 2022 04:34:09 +0300 Subject: [PATCH 038/168] fix time format --- manager/actions/eventlog.dynamic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/actions/eventlog.dynamic.php b/manager/actions/eventlog.dynamic.php index 6cba04b2bc..c75b546520 100755 --- a/manager/actions/eventlog.dynamic.php +++ b/manager/actions/eventlog.dynamic.php @@ -147,7 +147,7 @@ function menuAction(a) { $grd->colWidths = "1%,,1%,1%,1%"; $grd->colAligns = "center,,,center,center"; $grd->colWraps = ",,1"; - $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %R'; + $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' H:i:s'; if($listmode == '1') { $grd->pageSize = 0; } From 427a0fdfcaf58944ac2d55b262921af90d26bd70 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Mon, 11 Apr 2022 04:41:56 +0300 Subject: [PATCH 039/168] fix xss --- manager/actions/mutate_user.dynamic.php | 2 +- manager/actions/mutate_web_user.dynamic.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manager/actions/mutate_user.dynamic.php b/manager/actions/mutate_user.dynamic.php index f0d739855d..d6c2b69977 100755 --- a/manager/actions/mutate_user.dynamic.php +++ b/manager/actions/mutate_user.dynamic.php @@ -766,7 +766,7 @@ function SetUrl(url, width, height, alt) { - +
diff --git a/manager/actions/mutate_web_user.dynamic.php b/manager/actions/mutate_web_user.dynamic.php index 94ec4560c0..dc9a8f035c 100755 --- a/manager/actions/mutate_web_user.dynamic.php +++ b/manager/actions/mutate_web_user.dynamic.php @@ -515,7 +515,7 @@ function SetUrl(url, width, height, alt) { - " /> + htmlspecialchars($userdata['photo']) : $_style["tx"]; ?>" />
From 2d0ddc144eef19aadbd80be7c0fe0911d8637d83 Mon Sep 17 00:00:00 2001 From: I Ko Date: Tue, 12 Apr 2022 12:57:56 +0300 Subject: [PATCH 040/168] Fix auto_menuindex --- manager/actions/mutate_content.dynamic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/actions/mutate_content.dynamic.php b/manager/actions/mutate_content.dynamic.php index 1d4e73112d..3ad437b7b1 100755 --- a/manager/actions/mutate_content.dynamic.php +++ b/manager/actions/mutate_content.dynamic.php @@ -137,7 +137,7 @@ $modx->config['auto_menuindex'] = 1; } if($modx->config['auto_menuindex']) { - $pid = 0; + $pid = (int)$_REQUEST['pid']; $rs = $modx->db->select('count(*)', $tbl_site_content, "parent='{$pid}'"); $content['menuindex'] = $modx->db->getValue($rs); } else { From 5b888003af25f84d86da0f3bc4c1e3350f6bcf58 Mon Sep 17 00:00:00 2001 From: Andrey <0test@mail.ru> Date: Fri, 15 Apr 2022 12:35:27 +0300 Subject: [PATCH 041/168] remove strange install --- index.php | 3 ++- install/template.tpl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 25edb910c6..eef9c15fad 100644 --- a/index.php +++ b/index.php @@ -100,7 +100,8 @@ $rt = @include_once(dirname(__FILE__).'/'.MGR_DIR.'/includes/config.inc.php'); // Be sure config.inc.php is there and that it contains some important values if(!$rt || !$database_type || !$database_server || !$database_user || !$dbase) { - readfile('install/not_installed.tpl'); + header("HTTP/1.1 302 Moved Temporarily"); + header("Location: /install"); exit; } } diff --git a/install/template.tpl b/install/template.tpl index 60da8a01e4..d0a0bb5b01 100755 --- a/install/template.tpl +++ b/install/template.tpl @@ -20,7 +20,7 @@
- +
From e4a76ec0cc1776eb2643fb67d2df912f3f37fcc5 Mon Sep 17 00:00:00 2001 From: Dreamer0x01 Date: Fri, 29 Apr 2022 00:29:58 +0300 Subject: [PATCH 042/168] Update dbapi.mysqli.class.inc.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Фиксим баг https://github.com/evocms-community/evolution/issues/53 --- manager/includes/extenders/dbapi.mysqli.class.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index b09a7b84c1..8a918fe137 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -341,8 +341,12 @@ public function insert($fields, $intotable, $fromfields = "*", $fromtable = "", $this->query("INSERT INTO {$intotable} {$fields}"); } else { if (empty($fromtable)) { - $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '", - array_values($fields)) . "')"; + $field_values = $fields; //проверим значения на null, их нужно передать в запрос без кавычек + foreach($field_values as &$f_value) + { + $f_value = (null === $f_value) ? "NULL" : "'{$f_value}'"; + } + $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES(" . implode(", ", array_values($field_values)) . ")"; $this->query("INSERT INTO {$intotable} {$fields}"); } else { $fromtable = $this->replaceFullTableName($fromtable); From 377b2fcb04607eeb0aa62643181bfe5b35edda6a Mon Sep 17 00:00:00 2001 From: Pathologic Date: Fri, 29 Apr 2022 02:27:36 +0300 Subject: [PATCH 043/168] fix php 8.1 error --- assets/modules/store/core.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/modules/store/core.php b/assets/modules/store/core.php index 30f6fb69a0..df8316cd97 100644 --- a/assets/modules/store/core.php +++ b/assets/modules/store/core.php @@ -200,8 +200,6 @@ public function downloadFile ($url, $path) { } } - - public function removeFolder($path){ $dir = realpath($path); if ( !is_dir($dir)) return; @@ -220,9 +218,11 @@ public function removeFolder($path){ } rmdir($dir); } + public static function copyFolder($src, $dest) { - $path = realpath($src); + $path = realpath($src); $dest = realpath($dest); + if (!is_dir($path) || !is_dir($dest)) return; $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object) { From 44308b3e80508a399aefef322466b834d2f40c76 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 1 May 2022 05:48:21 +0300 Subject: [PATCH 044/168] update phpthumb --- assets/snippets/phpthumb/composer.lock | 14 +- assets/snippets/phpthumb/phpthumb.class.php | 4 +- assets/snippets/phpthumb/snippet.phpthumb.php | 20 - assets/snippets/phpthumb/vendor/autoload.php | 5 + .../phpthumb/vendor/composer/ClassLoader.php | 151 ++++- .../vendor/composer/InstalledVersions.php | 552 +++++++++++------- .../vendor/composer/autoload_classmap.php | 2 +- .../vendor/composer/autoload_files.php | 2 +- .../vendor/composer/autoload_namespaces.php | 2 +- .../vendor/composer/autoload_psr4.php | 2 +- .../vendor/composer/autoload_real.php | 40 +- .../phpthumb/vendor/composer/installed.json | 17 +- .../phpthumb/vendor/composer/installed.php | 59 +- .../vendor/composer/platform_check.php | 18 +- .../phpthumb/docs/phpthumb.changelog.txt | 6 + .../phpthumb/phpThumb.config.php.default | 2 +- .../james-heinrich/phpthumb/phpThumb.php | 6 +- .../phpthumb/phpthumb.class.php | 25 +- install/assets/snippets/phpthumb.tpl | 2 +- 19 files changed, 589 insertions(+), 340 deletions(-) diff --git a/assets/snippets/phpthumb/composer.lock b/assets/snippets/phpthumb/composer.lock index 22e901fa1e..49702bbbc7 100644 --- a/assets/snippets/phpthumb/composer.lock +++ b/assets/snippets/phpthumb/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "james-heinrich/phpthumb", - "version": "v1.7.16", + "version": "v1.7.17", "source": { "type": "git", "url": "https://github.com/JamesHeinrich/phpThumb.git", - "reference": "79aa5b21ee7277f67b863560bccc2490c4f0b82a" + "reference": "1ef2db62e8d4a4e391159653b200144a37462de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/79aa5b21ee7277f67b863560bccc2490c4f0b82a", - "reference": "79aa5b21ee7277f67b863560bccc2490c4f0b82a", + "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/1ef2db62e8d4a4e391159653b200144a37462de3", + "reference": "1ef2db62e8d4a4e391159653b200144a37462de3", "shasum": "" }, "require": { @@ -59,9 +59,9 @@ ], "support": { "issues": "https://github.com/JamesHeinrich/phpThumb/issues", - "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.16" + "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.17" }, - "time": "2021-02-06T16:34:15+00:00" + "time": "2021-09-22T15:40:00+00:00" } ], "packages-dev": [], @@ -72,5 +72,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.3.0" } diff --git a/assets/snippets/phpthumb/phpthumb.class.php b/assets/snippets/phpthumb/phpthumb.class.php index 3845eef319..e0fbc7574f 100644 --- a/assets/snippets/phpthumb/phpthumb.class.php +++ b/assets/snippets/phpthumb/phpthumb.class.php @@ -1,2 +1,4 @@ > + */ private $prefixLengthsPsr4 = array(); + /** + * @var array[] + * @psalm-var array> + */ private $prefixDirsPsr4 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr4 = array(); // PSR-0 + /** + * @var array[] + * @psalm-var array> + */ private $prefixesPsr0 = array(); + /** + * @var array[] + * @psalm-var array + */ private $fallbackDirsPsr0 = array(); + /** @var bool */ private $useIncludePath = false; + + /** + * @var string[] + * @psalm-var array + */ private $classMap = array(); + + /** @var bool */ private $classMapAuthoritative = false; + + /** + * @var bool[] + * @psalm-var array + */ private $missingClasses = array(); + + /** @var ?string */ private $apcuPrefix; + /** + * @var self[] + */ + private static $registeredLoaders = array(); + + /** + * @param ?string $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + + /** + * @return string[] + */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -66,28 +120,47 @@ public function getPrefixes() return array(); } + /** + * @return array[] + * @psalm-return array> + */ public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirs() { return $this->fallbackDirsPsr0; } + /** + * @return array[] + * @psalm-return array + */ public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } + /** + * @return string[] Array of classname => path + * @psalm-return array + */ public function getClassMap() { return $this->classMap; } /** - * @param array $classMap Class to filename map + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap + * + * @return void */ public function addClassMap(array $classMap) { @@ -102,9 +175,11 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void */ public function add($prefix, $paths, $prepend = false) { @@ -147,11 +222,13 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException + * + * @return void */ public function addPsr4($prefix, $paths, $prepend = false) { @@ -195,8 +272,10 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories + * + * @return void */ public function set($prefix, $paths) { @@ -211,10 +290,12 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException + * + * @return void */ public function setPsr4($prefix, $paths) { @@ -234,6 +315,8 @@ public function setPsr4($prefix, $paths) * Turns on searching the include path for class files. * * @param bool $useIncludePath + * + * @return void */ public function setUseIncludePath($useIncludePath) { @@ -256,6 +339,8 @@ public function getUseIncludePath() * that have not been registered with the class map. * * @param bool $classMapAuthoritative + * + * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -276,6 +361,8 @@ public function isClassMapAuthoritative() * APCu prefix to use to cache found/not-found classes, if the extension is enabled. * * @param string|null $apcuPrefix + * + * @return void */ public function setApcuPrefix($apcuPrefix) { @@ -296,25 +383,44 @@ public function getApcuPrefix() * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** * Unregisters this instance as an autoloader. + * + * @return void */ public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** * Loads the given class or interface. * * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise + * @return true|null True if loaded, null otherwise */ public function loadClass($class) { @@ -323,6 +429,8 @@ public function loadClass($class) return true; } + + return null; } /** @@ -367,6 +475,21 @@ public function findFile($class) return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ private function findFileWithExtension($class, $ext) { // PSR-4 lookup @@ -438,6 +561,10 @@ private function findFileWithExtension($class, $ext) * Scope isolated include. * * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private */ function includeFile($file) { diff --git a/assets/snippets/phpthumb/vendor/composer/InstalledVersions.php b/assets/snippets/phpthumb/vendor/composer/InstalledVersions.php index c7fefa3406..41bc143c11 100644 --- a/assets/snippets/phpthumb/vendor/composer/InstalledVersions.php +++ b/assets/snippets/phpthumb/vendor/composer/InstalledVersions.php @@ -1,218 +1,352 @@ + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Composer; +use Composer\Autoload\ClassLoader; use Composer\Semver\VersionParser; - - - - - +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ class InstalledVersions { -private static $installed = array ( - 'root' => - array ( - 'pretty_version' => 'No version set (parsed as 1.0.0)', - 'version' => '1.0.0.0', - 'aliases' => - array ( - ), - 'reference' => NULL, - 'name' => '__root__', - ), - 'versions' => - array ( - '__root__' => - array ( - 'pretty_version' => 'No version set (parsed as 1.0.0)', - 'version' => '1.0.0.0', - 'aliases' => - array ( - ), - 'reference' => NULL, - ), - 'james-heinrich/phpthumb' => - array ( - 'pretty_version' => 'v1.7.16', - 'version' => '1.7.16.0', - 'aliases' => - array ( - ), - 'reference' => '79aa5b21ee7277f67b863560bccc2490c4f0b82a', - ), - ), -); - - - - - - - -public static function getInstalledPackages() -{ -return array_keys(self::$installed['versions']); -} - - - - - - - - - -public static function isInstalled($packageName) -{ -return isset(self::$installed['versions'][$packageName]); -} - - - - - - - - - - - - - - -public static function satisfies(VersionParser $parser, $packageName, $constraint) -{ -$constraint = $parser->parseConstraints($constraint); -$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); - -return $provided->matches($constraint); -} - - - - - - - - - - -public static function getVersionRanges($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -$ranges = array(); -if (isset(self::$installed['versions'][$packageName]['pretty_version'])) { -$ranges[] = self::$installed['versions'][$packageName]['pretty_version']; -} -if (array_key_exists('aliases', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']); -} -if (array_key_exists('replaced', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']); -} -if (array_key_exists('provided', self::$installed['versions'][$packageName])) { -$ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']); -} - -return implode(' || ', $ranges); -} - - - - - -public static function getVersion($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['version'])) { -return null; -} - -return self::$installed['versions'][$packageName]['version']; -} - - - - - -public static function getPrettyVersion($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { -return null; -} - -return self::$installed['versions'][$packageName]['pretty_version']; -} - - - - - -public static function getReference($packageName) -{ -if (!isset(self::$installed['versions'][$packageName])) { -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); -} - -if (!isset(self::$installed['versions'][$packageName]['reference'])) { -return null; -} - -return self::$installed['versions'][$packageName]['reference']; -} - - - - - -public static function getRootPackage() -{ -return self::$installed['root']; -} - - - - - - - -public static function getRawData() -{ -return self::$installed; -} - - - - - - - - - - - - - - - - - - - -public static function reload($data) -{ -self::$installed = $data; -} + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints($constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + + if (self::$canGetVendors) { + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { + self::$installed = $installed[count($installed) - 1]; + } + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = require __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + $installed[] = self::$installed; + + return $installed; + } } diff --git a/assets/snippets/phpthumb/vendor/composer/autoload_classmap.php b/assets/snippets/phpthumb/vendor/composer/autoload_classmap.php index b26f1b13b1..0fb0a2c194 100644 --- a/assets/snippets/phpthumb/vendor/composer/autoload_classmap.php +++ b/assets/snippets/phpthumb/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/assets/snippets/phpthumb/vendor/composer/autoload_files.php b/assets/snippets/phpthumb/vendor/composer/autoload_files.php index a6abe2551e..0e09b6a74e 100644 --- a/assets/snippets/phpthumb/vendor/composer/autoload_files.php +++ b/assets/snippets/phpthumb/vendor/composer/autoload_files.php @@ -2,7 +2,7 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/assets/snippets/phpthumb/vendor/composer/autoload_namespaces.php b/assets/snippets/phpthumb/vendor/composer/autoload_namespaces.php index b7fc0125db..15a2ff3ad6 100644 --- a/assets/snippets/phpthumb/vendor/composer/autoload_namespaces.php +++ b/assets/snippets/phpthumb/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/assets/snippets/phpthumb/vendor/composer/autoload_psr4.php b/assets/snippets/phpthumb/vendor/composer/autoload_psr4.php index b265c64a22..3890ddc240 100644 --- a/assets/snippets/phpthumb/vendor/composer/autoload_psr4.php +++ b/assets/snippets/phpthumb/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/assets/snippets/phpthumb/vendor/composer/autoload_real.php b/assets/snippets/phpthumb/vendor/composer/autoload_real.php index 86c9f166a7..08db08693c 100644 --- a/assets/snippets/phpthumb/vendor/composer/autoload_real.php +++ b/assets/snippets/phpthumb/vendor/composer/autoload_real.php @@ -25,38 +25,15 @@ public static function getLoader() require __DIR__ . '/platform_check.php'; spl_autoload_register(array('ComposerAutoloaderInit59b4f21b3db48af42f3ca10324cc4c65', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit59b4f21b3db48af42f3ca10324cc4c65', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; - - call_user_func(\Composer\Autoload\ComposerStaticInit59b4f21b3db48af42f3ca10324cc4c65::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - } + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInit59b4f21b3db48af42f3ca10324cc4c65::getInitializer($loader)); $loader->register(true); - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit59b4f21b3db48af42f3ca10324cc4c65::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } + $includeFiles = \Composer\Autoload\ComposerStaticInit59b4f21b3db48af42f3ca10324cc4c65::$files; foreach ($includeFiles as $fileIdentifier => $file) { composerRequire59b4f21b3db48af42f3ca10324cc4c65($fileIdentifier, $file); } @@ -65,11 +42,16 @@ public static function getLoader() } } +/** + * @param string $fileIdentifier + * @param string $file + * @return void + */ function composerRequire59b4f21b3db48af42f3ca10324cc4c65($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - require $file; - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; } } diff --git a/assets/snippets/phpthumb/vendor/composer/installed.json b/assets/snippets/phpthumb/vendor/composer/installed.json index 36e42b4be1..5b8404ff5f 100644 --- a/assets/snippets/phpthumb/vendor/composer/installed.json +++ b/assets/snippets/phpthumb/vendor/composer/installed.json @@ -2,17 +2,17 @@ "packages": [ { "name": "james-heinrich/phpthumb", - "version": "v1.7.16", - "version_normalized": "1.7.16.0", + "version": "v1.7.17", + "version_normalized": "1.7.17.0", "source": { "type": "git", "url": "https://github.com/JamesHeinrich/phpThumb.git", - "reference": "79aa5b21ee7277f67b863560bccc2490c4f0b82a" + "reference": "1ef2db62e8d4a4e391159653b200144a37462de3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/79aa5b21ee7277f67b863560bccc2490c4f0b82a", - "reference": "79aa5b21ee7277f67b863560bccc2490c4f0b82a", + "url": "https://api.github.com/repos/JamesHeinrich/phpThumb/zipball/1ef2db62e8d4a4e391159653b200144a37462de3", + "reference": "1ef2db62e8d4a4e391159653b200144a37462de3", "shasum": "" }, "require": { @@ -22,7 +22,7 @@ "ext-gd": "PHP GD library", "ext-imagick": "PHP ImageMagick" }, - "time": "2021-02-06T16:34:15+00:00", + "time": "2021-09-22T15:40:00+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -56,10 +56,11 @@ ], "support": { "issues": "https://github.com/JamesHeinrich/phpThumb/issues", - "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.16" + "source": "https://github.com/JamesHeinrich/phpThumb/tree/v1.7.17" }, "install-path": "../james-heinrich/phpthumb" } ], - "dev": true + "dev": true, + "dev-package-names": [] } diff --git a/assets/snippets/phpthumb/vendor/composer/installed.php b/assets/snippets/phpthumb/vendor/composer/installed.php index 1e41d37546..808de6565f 100644 --- a/assets/snippets/phpthumb/vendor/composer/installed.php +++ b/assets/snippets/phpthumb/vendor/composer/installed.php @@ -1,33 +1,32 @@ - - array ( - 'pretty_version' => 'No version set (parsed as 1.0.0)', - 'version' => '1.0.0.0', - 'aliases' => - array ( + array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '2df5ab4d64904f33813d269992414ad1cbc3d27f', + 'name' => '__root__', + 'dev' => true, ), - 'reference' => NULL, - 'name' => '__root__', - ), - 'versions' => - array ( - '__root__' => - array ( - 'pretty_version' => 'No version set (parsed as 1.0.0)', - 'version' => '1.0.0.0', - 'aliases' => - array ( - ), - 'reference' => NULL, + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'reference' => '2df5ab4d64904f33813d269992414ad1cbc3d27f', + 'dev_requirement' => false, + ), + 'james-heinrich/phpthumb' => array( + 'pretty_version' => 'v1.7.17', + 'version' => '1.7.17.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../james-heinrich/phpthumb', + 'aliases' => array(), + 'reference' => '1ef2db62e8d4a4e391159653b200144a37462de3', + 'dev_requirement' => false, + ), ), - 'james-heinrich/phpthumb' => - array ( - 'pretty_version' => 'v1.7.16', - 'version' => '1.7.16.0', - 'aliases' => - array ( - ), - 'reference' => '79aa5b21ee7277f67b863560bccc2490c4f0b82a', - ), - ), ); diff --git a/assets/snippets/phpthumb/vendor/composer/platform_check.php b/assets/snippets/phpthumb/vendor/composer/platform_check.php index 9997ec3c0a..7621d4ff97 100644 --- a/assets/snippets/phpthumb/vendor/composer/platform_check.php +++ b/assets/snippets/phpthumb/vendor/composer/platform_check.php @@ -5,10 +5,22 @@ $issues = array(); if (!(PHP_VERSION_ID >= 50300)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.'; + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { - echo 'Composer detected issues in your platform:' . "\n\n" . implode("\n", $issues); - exit(104); + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); } diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt index 4ae862471d..01c6f47931 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/docs/phpthumb.changelog.txt @@ -7,6 +7,12 @@ ¤ = structure change or important new feature * = less important new feature or change +v1.7.17-202109221111 + * [bugfix: G171] problem with class_exists and autoloading + * [bugfix: G173] file_get_contents instead of readfile + * [bugfix: G178] missing quality parameter in webp + * [bugfix: G181] missing webp in ImageCreateFromFilename + v1.7.16-202012161640 ¤ PHP 8.0 compatibility * [bugfix: G168] bad call to $this inside static function diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default index 9f5668a58c..2f26aed3dc 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.config.php.default @@ -13,7 +13,7 @@ define('phpThumbConfigFileVersion', '1.7.16'); ob_start(); -if (!class_exists('phpthumb_functions')) { // normally include_once should take care of this, but see https://github.com/JamesHeinrich/phpThumb/issues/94 +if (!class_exists('phpthumb_functions', false)) { // normally include_once should take care of this, but see https://github.com/JamesHeinrich/phpThumb/issues/94 if (!file_exists( __DIR__ .'/phpthumb.functions.php') || !include_once( __DIR__ .'/phpthumb.functions.php')) { ob_end_flush(); die('failed to include_once(phpthumb.functions.php) - realpath="'.realpath( __DIR__ .'/phpthumb.functions.php').'"'); diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php index 672cf6ded6..8e02199542 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpThumb.php @@ -75,7 +75,7 @@ function RedirectToCachedFile() { if (preg_match('#^'.preg_quote($nice_docroot).'(.*)$#', $nice_cachefile, $matches)) { $phpThumb->DebugMessage('* Would have sent headers (3): Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])), __FILE__, __LINE__); } else { - $phpThumb->DebugMessage('* Would have sent data: readfile('.$phpThumb->cache_filename.')', __FILE__, __LINE__); + $phpThumb->DebugMessage('* Would have sent data: file_get_contents('.$phpThumb->cache_filename.')', __FILE__, __LINE__); } } else { @@ -106,7 +106,7 @@ function RedirectToCachedFile() { if (empty($phpThumb->config_cache_force_passthru) && preg_match('#^'.preg_quote($nice_docroot).'(.*)$#', $nice_cachefile, $matches)) { header('Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1]))); } else { - @readfile($phpThumb->cache_filename); + echo file_get_contents($phpThumb->cache_filename); } exit; @@ -551,7 +551,7 @@ function RedirectToCachedFile() { if ($contentType = phpthumb_functions::ImageTypeToMIMEtype(@$phpThumb->getimagesizeinfo[2])) { header('Content-Type: '.$contentType); } - @readfile($SourceFilename); + echo file_get_contents($SourceFilename); exit; } else { diff --git a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php index 37e93a6f14..119d82d3a2 100644 --- a/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php +++ b/assets/snippets/phpthumb/vendor/james-heinrich/phpthumb/phpthumb.class.php @@ -9,7 +9,7 @@ // /// ////////////////////////////////////////////////////////////// -if (!class_exists('phpthumb_functions')) +if (!class_exists('phpthumb_functions', false)) { ob_start(); if(!include_once __DIR__ . '/phpthumb.functions.php') @@ -220,7 +220,7 @@ class phpthumb { public $issafemode = null; public $php_memory_limit = null; - public $phpthumb_version = '1.7.16-202012161640'; + public $phpthumb_version = '1.7.17-202109221111'; ////////////////////////////////////////////////////////////////////// @@ -553,7 +553,7 @@ public function RenderOutput() { ob_end_clean(); return false; } - imagewebp($this->gdimg_output); + imagewebp($this->gdimg_output, null, $this->thumbnailQuality); $this->outputImageData = ob_get_contents(); break; @@ -669,14 +669,9 @@ public function OutputThumbnail() { $this->DebugMessage('imageinterlace($this->gdimg_output, '. (int) $this->config_output_interlace .')', __FILE__, __LINE__); imageinterlace($this->gdimg_output, (int) $this->config_output_interlace); switch ($this->thumbnailFormat) { + case 'gif': case 'jpeg': - header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat)); - $ImageOutFunction = 'image'.$this->thumbnailFormat; - @$ImageOutFunction($this->gdimg_output, null, $this->thumbnailQuality); - break; - case 'png': - case 'gif': case 'webp': $ImageOutFunction = 'image'.$this->thumbnailFormat; if (!function_exists($ImageOutFunction)) { @@ -684,7 +679,11 @@ public function OutputThumbnail() { return false; } header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($this->thumbnailFormat)); - @$ImageOutFunction($this->gdimg_output); + if ($this->thumbnailFormat == 'gif') { + @$ImageOutFunction($this->gdimg_output); + } else { + @$ImageOutFunction($this->gdimg_output, null, $this->thumbnailQuality); + } break; case 'bmp': @@ -1907,8 +1906,8 @@ public function ImageMagickThumbnailToGD() { } else { - $this->w = (($this->aoe && $this->w) ? $this->w : ($this->w ? phpthumb_functions::nonempty_min($this->w, $getimagesize[0]) : '')); - $this->h = (($this->aoe && $this->h) ? $this->h : ($this->h ? phpthumb_functions::nonempty_min($this->h, $getimagesize[1]) : '')); + $this->w = (($this->aoe && $this->w) ? $this->w : ($this->w ? phpthumb_functions::nonempty_min($this->w, $getimagesize[0]) : null)); + $this->h = (($this->aoe && $this->h) ? $this->h : ($this->h ? phpthumb_functions::nonempty_min($this->h, $getimagesize[1]) : null)); if ($this->w || $this->h) { if ($IMuseExplicitImageOutputDimensions) { if ($this->w && !$this->h) { @@ -3701,6 +3700,7 @@ public function ImageCreateFromFilename($filename) { 2 => 'imagecreatefromjpeg', 3 => 'imagecreatefrompng', 15 => 'imagecreatefromwbmp', + 18 => 'imagecreatefromwebp', ); $this->DebugMessage('ImageCreateFromFilename found ($getimagesizeinfo[2]=='.@$getimagesizeinfo[2].')', __FILE__, __LINE__); switch (@$getimagesizeinfo[2]) { @@ -3708,6 +3708,7 @@ public function ImageCreateFromFilename($filename) { case 2: // JPEG case 3: // PNG case 15: // WBMP + case 18: // WEBP $ImageCreateFromFunctionName = $ImageCreateFromFunction[$getimagesizeinfo[2]]; if (function_exists($ImageCreateFromFunctionName)) { $this->DebugMessage('Calling '.$ImageCreateFromFunctionName.'('.$filename.')', __FILE__, __LINE__); diff --git a/install/assets/snippets/phpthumb.tpl b/install/assets/snippets/phpthumb.tpl index 04247889f5..78eefa762c 100644 --- a/install/assets/snippets/phpthumb.tpl +++ b/install/assets/snippets/phpthumb.tpl @@ -5,7 +5,7 @@ * PHPThumb creates thumbnails and altered images on the fly and caches them * * @category snippet - * @version 1.3.4 + * @version 1.4.1 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @internal @properties * @internal @modx_category Content From f1336f1a4a66edec157b790a2eb571a8155acc05 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Fri, 6 May 2022 00:20:29 +0300 Subject: [PATCH 045/168] fix installer to prevent errors in php 8.1 --- install/actions/action_connection.php | 15 ++++++++++++--- install/connection.collation.php | 6 +++++- install/connection.databasetest.php | 23 ++++++++++++++++++----- install/connection.servertest.php | 7 ++++++- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/install/actions/action_connection.php b/install/actions/action_connection.php index e97479c3bb..2716735402 100755 --- a/install/actions/action_connection.php +++ b/install/actions/action_connection.php @@ -17,9 +17,18 @@ if ($dbase) { $database_name = trim($dbase, '`'); $host = explode(':', $database_server, 2); - if (!$conn = mysqli_connect($host[0], $database_user, $database_password,'', isset($host[1]) ? $host[1] : null)) - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) + try { + $conn = mysqli_connect($host[0], $database_user, $database_password,'', isset($host[1]) ? $host[1] : null); + try { + $result = mysqli_select_db($conn, trim($dbase, '`')); + } catch (Exception $e) { + $result = false; + } + } catch (Exception $e) { + $conn = false; + $result = false; + } + if (!$conn || !$result) $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; else $upgradeable = 1; diff --git a/install/connection.collation.php b/install/connection.collation.php index d76615d3c7..4d9889a112 100755 --- a/install/connection.collation.php +++ b/install/connection.collation.php @@ -16,7 +16,11 @@ if (function_exists('mysqli_connect')) { $h = explode(':', $host, 2); - $conn = mysqli_connect($h[0], $uid, $pwd,'', isset($h[1]) ? $h[1] : null); + try { + $conn = mysqli_connect($h[0], $uid, $pwd,'', isset($h[1]) ? $h[1] : null); + } catch (Exception $e) { + $conn = false; + } if (!$conn) { exit('can not connect'); } diff --git a/install/connection.databasetest.php b/install/connection.databasetest.php index 52b127407f..fda087f95e 100755 --- a/install/connection.databasetest.php +++ b/install/connection.databasetest.php @@ -18,7 +18,12 @@ $output = $_lang["status_checking_database"]; $h = explode(':', $host, 2); -if (!$conn = mysqli_connect($h[0], $uid, $pwd,'', $h[1] ?? null)) { +try { + $conn = mysqli_connect($h[0], $uid, $pwd,'', $h[1] ?? null); +} catch (Exception $e) { + $conn = false; +} +if (!$conn) { $output .= ''.$_lang['status_failed'].''; } else { @@ -27,13 +32,21 @@ $tableprefix = mysqli_real_escape_string($conn, $_POST['tableprefix']); $database_collation = mysqli_real_escape_string($conn, $_POST['database_collation']); $database_connection_method = mysqli_real_escape_string($conn, $_POST['database_connection_method']); - - if (!@ mysqli_select_db($conn, $database_name)) { + try { + $result = mysqli_select_db($conn, $database_name); + } catch (Exception $e) { + $result = false; + } + if (!$result) { // create database $database_charset = substr($database_collation, 0, strpos($database_collation, '_')); $query = "CREATE DATABASE `".$database_name."` CHARACTER SET ".$database_charset." COLLATE ".$database_collation.";"; - - if (! mysqli_query($conn, $query)){ + try { + $result = mysqli_query($conn, $query); + } catch (Exception $e) { + $result = false; + } + if (!$result){ $output .= ''.$_lang['status_failed_could_not_create_database'].''; } else { diff --git a/install/connection.servertest.php b/install/connection.servertest.php index 920c69abbc..abd7430e7a 100755 --- a/install/connection.servertest.php +++ b/install/connection.servertest.php @@ -17,7 +17,12 @@ $output = $_lang["status_connecting"]; if (function_exists('mysqli_connect')) { $h = explode(':', $host, 2); - if (!$conn = @mysqli_connect($h[0], $uid, $pwd,'', isset($h[1]) ? $h[1] : null)) { + try { + $conn = mysqli_connect($h[0], $uid, $pwd,'', isset($h[1]) ? $h[1] : null); + } catch (Exception $e) { + $conn = false; + } + if (!$conn) { $output .= ' '.$_lang['status_failed'].''; } else { $output .= ' '.$_lang['status_passed_server'].''; From e7eceacba6e93c568005d35f1ea69af28981c1fe Mon Sep 17 00:00:00 2001 From: Pathologic Date: Fri, 6 May 2022 00:29:07 +0300 Subject: [PATCH 046/168] fix php 8.1 --- manager/includes/extenders/dbapi.mysqli.class.inc.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php index 8a918fe137..5a9e8e2c90 100644 --- a/manager/includes/extenders/dbapi.mysqli.class.inc.php +++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php @@ -61,8 +61,12 @@ public function connect($host = '', $dbase = '', $uid = '', $pwd = '') $tstart = $modx->getMicroTime(); $safe_count = 0; do { - $this->conn = new mysqli($host[0], $uid, $pwd, $dbase, isset($host[1]) ? $host[1] : null); - if ($this->conn->connect_error) { + try { + $this->conn = new mysqli($host[0], $uid, $pwd, $dbase, isset($host[1]) ? $host[1] : null); + } catch (Exception $e) { + $this->conn = null; + } + if (is_null($this->conn) || $this->conn->connect_error) { $this->conn = null; if (isset($modx->config['send_errormail']) && $modx->config['send_errormail'] !== '0') { if ($modx->config['send_errormail'] <= 2) { From 7be6580526d3e26c646a6919dcf852aaa9e3c891 Mon Sep 17 00:00:00 2001 From: Pathologic Date: Sun, 22 May 2022 02:41:47 +0300 Subject: [PATCH 047/168] fix #26 --- manager/includes/lang/english.inc.php | 1 + manager/includes/lang/russian-UTF8.inc.php | 1 + manager/media/style/default/ajax.php | 5 ++++- manager/processors/move_document.processor.php | 7 ++++++- manager/processors/save_content.processor.php | 16 ++++++++++++++++ .../processors/undelete_content.processor.php | 7 ++++++- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/manager/includes/lang/english.inc.php b/manager/includes/lang/english.inc.php index 66f17728f2..d018ac926a 100755 --- a/manager/includes/lang/english.inc.php +++ b/manager/includes/lang/english.inc.php @@ -1360,6 +1360,7 @@ $_lang["error_no_id"] = "ID not passed in request!"; $_lang["error_id_nan"] = "ID passed in request is NaN!"; $_lang["error_no_parent"] = "Couldn't find parent document's name!"; +$_lang["error_parent_deleted"] = "Failed because resource parent is deleted!"; $_lang["error_many_results"] = "Too many results returned from database!"; $_lang["error_no_results"] = "Not enough/ no results returned from database!"; $_lang["error_no_user_selected"] = "No user selected as recipient of this message!"; diff --git a/manager/includes/lang/russian-UTF8.inc.php b/manager/includes/lang/russian-UTF8.inc.php index d9020f45aa..9d35209005 100755 --- a/manager/includes/lang/russian-UTF8.inc.php +++ b/manager/includes/lang/russian-UTF8.inc.php @@ -1353,6 +1353,7 @@ $_lang["error_no_id"] = "Не верно указан ID в вашем запросе!"; $_lang["error_id_nan"] = "ID переданного запроса пуст!"; $_lang["error_no_parent"] = "Не удалось найти имя родительского документа!"; +$_lang["error_parent_deleted"] = "Не удалось выполнить, потому что родитель отмечен как удаленный!"; $_lang["error_many_results"] = "Слишком много результатов возвращается из базы данных!"; $_lang["error_no_results"] = "Результаты из базы данных не вернулись или вернулись не полностью!"; $_lang["error_no_user_selected"] = "Не указан получатель этого сообщения!"; diff --git a/manager/media/style/default/ajax.php b/manager/media/style/default/ajax.php index 125df4d307..8d158d2a09 100755 --- a/manager/media/style/default/ajax.php +++ b/manager/media/style/default/ajax.php @@ -496,7 +496,10 @@ $menuindex = isset($_REQUEST['menuindex']) && is_scalar($_REQUEST['menuindex']) ? $_REQUEST['menuindex'] : 0; // set parent - if ($id && $parent >= 0) { + $parentNotDeleted = $modx->db->getValue($modx->db->select('id', $modx->getFullTableName('site_content'), "`id`={$parent} AND `deleted`=0")); + if ($parent > 0 && !$parentNotDeleted) { + $json['errors'] = $_lang["error_parent_deleted"]; + } elseif ($id && $parent >= 0) { // find older parent $parentOld = $modx->db->getValue($modx->db->select('parent', $modx->getFullTableName('site_content'), 'id=' . $id)); diff --git a/manager/processors/move_document.processor.php b/manager/processors/move_document.processor.php index c0a8c390fd..846afd4a41 100755 --- a/manager/processors/move_document.processor.php +++ b/manager/processors/move_document.processor.php @@ -15,7 +15,12 @@ if($documentID==$newParentID) $modx->webAlertAndQuit($_lang["error_movedocument1"]); if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); - +if ($newParentID > 0) { + $rs = $modx->db->select('id', $modx->getFullTableName('site_content'), "`id`={$newParentID} AND `deleted`=0"); + if (!$modx->db->getValue($rs)) { + $modx->webAlertAndQuit($_lang["error_parent_deleted"]); + } +} $parents = $modx->getParentIds($newParentID); if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); diff --git a/manager/processors/save_content.processor.php b/manager/processors/save_content.processor.php index 6883cf8eac..35fab2531d 100755 --- a/manager/processors/save_content.processor.php +++ b/manager/processors/save_content.processor.php @@ -301,6 +301,12 @@ "id" => $id )); + $deleted = 0; + $parentNotDeleted = $modx->db->getValue($modx->db->select('id', $modx->getFullTableName('site_content'), "`id`={$parent} AND `deleted`=0")); + if ($parent > 0 && !$parentNotDeleted) { + $deleted = 1; + } + // deny publishing if not permitted if (!$modx->hasPermission('publish_document')) { $pub_date = 0; @@ -327,6 +333,7 @@ "link_attributes" => $link_attributes , "isfolder" => $isfolder , "richtext" => $richtext , + "deleted" => $deleted , "published" => $published , "parent" => $parent , "template" => $template , @@ -465,6 +472,14 @@ $modx->webAlertAndQuit("Document can not be it's own parent!"); } + $deleted = (int)$existingDocument['deleted']; + if ($parent != $oldparent && $parent > 0) { + $parentNotDeleted = $modx->db->getValue($modx->db->select('id', $modx->getFullTableName('site_content'), "`id`={$parent} AND `deleted`=0")); + if (!$parentNotDeleted) { + $deleted = 1; + } + } + $parents = $modx->getParentIds($parent); if (in_array($id, $parents)) { $modx->webAlertAndQuit("Document descendant can not be it's parent!"); @@ -520,6 +535,7 @@ . "link_attributes='{$link_attributes}', " . "isfolder={$isfolder}, " . "richtext={$richtext}, " + . "deleted={$deleted}, " . "published={$published}, " . "pub_date={$pub_date}, " . "unpub_date={$unpub_date}, " diff --git a/manager/processors/undelete_content.processor.php b/manager/processors/undelete_content.processor.php index 84cdc95f72..681755fcc3 100755 --- a/manager/processors/undelete_content.processor.php +++ b/manager/processors/undelete_content.processor.php @@ -14,7 +14,12 @@ /************ webber ********/ $content=$modx->db->getRow($modx->db->select('parent, pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'")); $pid=($content['parent']==0?$id:$content['parent']); - +if ($content['parent'] > 0) { + $parentNotDeleted = $modx->db->getValue($modx->db->select('id', $modx->getFullTableName('site_content'), "`id`={$content['parent']} AND `deleted`=0")); + if (!$parentNotDeleted) { + $modx->webAlertAndQuit($_lang["error_parent_deleted"]); + } +} /************** webber *************/ $sd=isset($_REQUEST['dir'])?'&dir='.$_REQUEST['dir']:'&dir=DESC'; $sb=isset($_REQUEST['sort'])?'&sort='.$_REQUEST['sort']:'&sort=createdon'; From 341216a9cdf4e2df7c14ba64b6cf135b25d7ea85 Mon Sep 17 00:00:00 2001 From: Serg <64j@mail.ru> Date: Sun, 22 May 2022 15:03:29 +0300 Subject: [PATCH 048/168] [1.4x] Fix modx.js # Conflicts: # manager/frames/1.php --- manager/frames/1.php | 1329 ++++++++++---------- manager/media/style/default/js/modx.js | 127 +- manager/media/style/default/js/modx.min.js | 1 - manager/media/style/default/style.php | 1044 +++++++-------- 4 files changed, 1271 insertions(+), 1230 deletions(-) delete mode 100755 manager/media/style/default/js/modx.min.js diff --git a/manager/frames/1.php b/manager/frames/1.php index 8ee2d350b3..93f549d3da 100755 --- a/manager/frames/1.php +++ b/manager/frames/1.php @@ -1,658 +1,671 @@ -INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly."); -} -header("X-XSS-Protection: 0"); - -$_SESSION['browser'] = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 1') !== false) ? 'legacy_IE' : 'modern'; - -// invoke OnManagerPreFrameLoader -$modx->invokeEvent('OnManagerPreFrameLoader', array('action' => $action)); - -$mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; - -if (!isset($modx->config['manager_menu_height'])) { - $modx->config['manager_menu_height'] = 2.2; // rem -} - -if (!isset($modx->config['manager_tree_width'])) { - $modx->config['manager_tree_width'] = 20; // rem -} - -if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) { - $initMainframeAction = $_SESSION['onLoginForwardToAction']; - unset($_SESSION['onLoginForwardToAction']); -} else { - $initMainframeAction = 2; // welcome.static -} - -if (!isset($_SESSION['tree_show_only_folders'])) { - $_SESSION['tree_show_only_folders'] = 0; -} - -$body_class = ''; -$menu_height = $modx->config['manager_menu_height']; -$tree_width = $modx->config['manager_tree_width']; -$tree_min_width = 0; - -if (isset($_COOKIE['MODX_widthSideBar'])) { - $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar']; -} else { - $MODX_widthSideBar = $tree_width; -} - -if (!$MODX_widthSideBar) { - $body_class .= 'sidebar-closed'; -} - -$theme_mode = isset($_COOKIE['MODX_themeMode']) ? $_COOKIE['MODX_themeMode'] : ''; -$theme_modes = array('', 'lightness', 'light', 'dark', 'darkness'); -if (!empty($theme_modes[$theme_mode])) { - $body_class .= ' ' . $theme_modes[$_COOKIE['MODX_themeMode']]; -} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { - $body_class .= ' ' . $theme_modes[$modx->config['manager_theme_mode']]; -} - -$navbar_position = $modx->config['manager_menu_position']; -if ($navbar_position == 'left') { - $body_class .= ' navbar-left navbar-left-icon-and-text'; -} - -if (isset($modx->pluginCache['ElementsInTree'])) { - $body_class .= ' ElementsInTree'; -} - -$unlockTranslations = array( - 'msg' => $_lang["unlock_element_id_warning"], - 'type1' => $_lang["lock_element_type_1"], - 'type2' => $_lang["lock_element_type_2"], - 'type3' => $_lang["lock_element_type_3"], - 'type4' => $_lang["lock_element_type_4"], - 'type5' => $_lang["lock_element_type_5"], - 'type6' => $_lang["lock_element_type_6"], - 'type7' => $_lang["lock_element_type_7"], - 'type8' => $_lang["lock_element_type_8"] -); - -foreach ($unlockTranslations as $key => $value) { - $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); -} - -$user = $modx->getUserInfo($modx->getLoginUserID()); -if (isset($user['which_browser']) && $user['which_browser'] == 'default') { - $user['which_browser'] = $modx->config['which_browser']; -} - -$css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime; - -if ($modx->config['manager_theme'] == 'default') { - if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { - require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php'; - $minifier = new Formatter\CSSMinify(); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css'); - $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css'); - $css = $minifier->minify(); - file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css); - } - if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { - $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; - } -} - -$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin'))); - -?> - -> - - <?= $site_name ?> (EVO CMS Manager) - - - - - - config['show_picker'] != "0") { ?> - - - - - - - - - - config['show_picker'] != "0") { ?> - - - - - invokeEvent('OnManagerTopPrerender', $_REQUEST); - if (is_array($evtOut)) { - echo implode("\n", $evtOut); - } - ?> - - - -
- -
- -
-
- config['global_tabs']): ?> -
-

-
-
- -
- -
- -
- - -
-
-
-
- - - - - - - ', $action, $action); - echo sprintf(' %s
', $img, $text); - } - } - - ?> - - - config['show_fullscreen_btn'] != "0") { ?> - - - invokeEvent('OnManagerFrameLoader', array('action' => $action)); - ?> - -
-config['show_picker'] != "0") { - include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php'); -} ?> - - +INCLUDE_ORDERING_ERROR

Please use the EVO Content Manager instead of accessing this file directly."); +} +header("X-XSS-Protection: 0"); + +$_SESSION['browser'] = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 1') !== false) ? 'legacy_IE' : 'modern'; + +// invoke OnManagerPreFrameLoader +$modx->invokeEvent('OnManagerPreFrameLoader', array('action' => $action)); + +$mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; + +if (!isset($modx->config['manager_menu_height'])) { + $modx->config['manager_menu_height'] = 2.2; // rem +} + +if (!isset($modx->config['manager_tree_width'])) { + $modx->config['manager_tree_width'] = 20; // rem +} + +if (isset($_SESSION['onLoginForwardToAction']) && is_int($_SESSION['onLoginForwardToAction'])) { + $initMainframeAction = $_SESSION['onLoginForwardToAction']; + unset($_SESSION['onLoginForwardToAction']); +} else { + $initMainframeAction = 2; // welcome.static +} + +if (!isset($_SESSION['tree_show_only_folders'])) { + $_SESSION['tree_show_only_folders'] = 0; +} + +$body_class = ''; +$menu_height = $modx->config['manager_menu_height']; +$tree_width = $modx->config['manager_tree_width']; +$tree_min_width = 0; + +if (isset($_COOKIE['MODX_widthSideBar'])) { + $MODX_widthSideBar = $_COOKIE['MODX_widthSideBar']; +} else { + $MODX_widthSideBar = $tree_width; +} + +if (!$MODX_widthSideBar) { + $body_class .= 'sidebar-closed'; +} + +$theme_mode = isset($_COOKIE['MODX_themeMode']) ? $_COOKIE['MODX_themeMode'] : ''; +$theme_modes = array('', 'lightness', 'light', 'dark', 'darkness'); +if (!empty($theme_modes[$theme_mode])) { + $body_class .= ' ' . $theme_modes[$_COOKIE['MODX_themeMode']]; +} elseif (!empty($theme_modes[$modx->config['manager_theme_mode']])) { + $body_class .= ' ' . $theme_modes[$modx->config['manager_theme_mode']]; +} + +$navbar_position = $modx->config['manager_menu_position']; +if ($navbar_position == 'left') { + $body_class .= ' navbar-left navbar-left-icon-and-text'; +} + +if (isset($modx->pluginCache['ElementsInTree'])) { + $body_class .= ' ElementsInTree'; +} + +$unlockTranslations = array( + 'msg' => $_lang["unlock_element_id_warning"], + 'type1' => $_lang["lock_element_type_1"], + 'type2' => $_lang["lock_element_type_2"], + 'type3' => $_lang["lock_element_type_3"], + 'type4' => $_lang["lock_element_type_4"], + 'type5' => $_lang["lock_element_type_5"], + 'type6' => $_lang["lock_element_type_6"], + 'type7' => $_lang["lock_element_type_7"], + 'type8' => $_lang["lock_element_type_8"] +); + +foreach ($unlockTranslations as $key => $value) { + $unlockTranslations[$key] = iconv($modx->config["modx_charset"], "utf-8", $value); +} + +$user = $modx->getUserInfo($modx->getLoginUserID()); +if (isset($user['which_browser']) && $user['which_browser'] == 'default') { + $user['which_browser'] = $modx->config['which_browser']; +} + +$css = 'media/style/' . $modx->config['manager_theme'] . '/css/page.css?v=' . $lastInstallTime; + +if ($modx->config['manager_theme'] == 'default') { + if (!file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css') && is_writable(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css')) { + require_once MODX_BASE_PATH . 'assets/lib/Formatter/CSSMinify.php'; + $minifier = new Formatter\CSSMinify(); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/bootstrap/css/bootstrap.min.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/common/font-awesome/css/font-awesome.min.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/fonts.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/forms.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/mainmenu.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tree.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/custom.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/tabpane.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/contextmenu.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/index.css'); + $minifier->addFile(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/main.css'); + $css = $minifier->minify(); + file_put_contents(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css', $css); + } + if (file_exists(MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css')) { + $css = 'media/style/' . $modx->config['manager_theme'] . '/css/styles.min.css?v=' . $lastInstallTime; + } +} + +$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin'))); + +?> + +> + + <?= $site_name ?> (EVO CMS Manager) + + + + + + config['show_picker'] != "0") { ?> + + + + + + + + + + config['show_picker'] != "0") { ?> + + + + + invokeEvent('OnManagerTopPrerender', $_REQUEST); + if (is_array($evtOut)) { + echo implode("\n", $evtOut); + } + ?> + + + +
+ +
+ +
+
+ config['global_tabs']): ?> +
+

+
+
+ +
+ +
+ +
+ + +
+
+
+
+ + + + + + + ', $action, $action); + echo sprintf(' %s
', $img, $text); + } + } + + ?> + + + config['show_fullscreen_btn'] != "0") { ?> + + + invokeEvent('OnManagerFrameLoader', array('action' => $action)); + ?> + +
+config['show_picker'] != "0") { + include('media/style/' . $modx->config['manager_theme'] . '/color.switcher.php'); +} ?> + + diff --git a/manager/media/style/default/js/modx.js b/manager/media/style/default/js/modx.js index 522a24d174..1a6a1e276f 100755 --- a/manager/media/style/default/js/modx.js +++ b/manager/media/style/default/js/modx.js @@ -1,5 +1,6 @@ (function(w, d, u) { 'use strict'; + modx.tree_parent = modx.tree_parent || 0; modx.extended({ frameset: 'frameset', minWidth: 840, @@ -14,11 +15,12 @@ } //this.tree.init(); this.mainmenu.init(); - if (w.location.hash) { - if (modx.getActionFromUrl(w.location.hash, 2)) { + var href = modx.normalizeUrl(w.location.href); + if (href) { + if (modx.getActionFromUrl(href, 2)) { w.history.replaceState(null, d.title, modx.MODX_MANAGER_URL); - } else if (modx.getActionFromUrl(w.location.hash) || modx.main.getQueryVariable('filemanager', w.location.hash)) { - var url = modx.main.getQueryVariable('filemanager', w.location.hash) ? modx.MODX_MANAGER_URL + modx.main.getQueryVariable('filemanager', w.location.hash) + w.location.hash.replace('#?', '?') : w.location.href.replace('#?', '?'); + } else if (modx.getActionFromUrl(href) || modx.main.getQueryVariable('filemanager', href) || /^modules\//.test(href)) { + var url = modx.main.getQueryVariable('filemanager', href) ? modx.MODX_MANAGER_URL + modx.main.getQueryVariable('filemanager', href) + href : href; if (modx.config.global_tabs) { modx.tabs({url: url, title: 'blank'}); } else if (w.main) { @@ -278,7 +280,7 @@ d.body.appendChild(this.result); } this.loader = d.createElement('i'); - this.loader.className = 'fa fa-refresh fa-spin fa-fw'; + this.loader.className = modx.style.icon_refresh + modx.style.icon_spin; this.input.parentNode.appendChild(this.loader); if (modx.config.global_tabs) { this.input.parentNode.onsubmit = function(e) { @@ -369,7 +371,8 @@ if (modx.config.global_tabs) { w.main.document.addEventListener('click', modx.tabs, false); } - w.history.replaceState(null, d.title, modx.getActionFromUrl(w.main.location.search, 2) ? modx.MODX_MANAGER_URL : '#' + w.main.location.search); + var url = modx.normalizeUrl(w.main.location.href); + w.history.replaceState(null, d.title, modx.getActionFromUrl(url, 2) ? modx.MODX_MANAGER_URL : '#' + url); setTimeout('modx.tree.restoreTree()', 100); }, oncontextmenu: function(e) { @@ -416,7 +419,7 @@ row.parentNode.insertBefore(rowContainer, row); rowContainer.appendChild(row); var p = d.createElement('i'); - p.className = 'fa fa-angle-left prev disable'; + p.className = modx.style.icon_angle_left + ' prev disable'; p.onclick = function(e) { e.stopPropagation(); e.preventDefault(); @@ -428,7 +431,7 @@ }; rowContainer.appendChild(p); var n = d.createElement('i'); - n.className = 'fa fa-angle-right next disable'; + n.className = modx.style.icon_angle_right + ' next disable'; n.onclick = function(e) { e.stopPropagation(); e.preventDefault(); @@ -521,7 +524,7 @@ }, scrollWork: function() { var a = w.main.frameElement.contentWindow, - b = a.location.search.substring(1) || a.location.hash.substring(2), + b = modx.normalizeUrl(a.location.href), c = localStorage.getItem('page_y') || 0, f = localStorage.getItem('page_url') || b; if (((modx.getActionFromUrl(f) === modx.getActionFromUrl(b)) && (modx.main.getQueryVariable('id', f) && modx.main.getQueryVariable('id', f) === modx.main.getQueryVariable('id', b))) || (f === b)) { @@ -913,10 +916,10 @@ parent: parent, menuindex: menuindex }, function(r) { - if (r?.errors) alert(r.errors); + if (r && r.errors) alert(r.errors); modx.tree.restoreTree(); }, 'json'); - var b = w.main.frameElement.contentWindow.location.search.substr(1); + var b = modx.normalizeUrl(w.main.frameElement.contentWindow.location.href); if (modx.getActionFromUrl(b, 27) && parseInt(modx.main.getQueryVariable('id', b)) === parseInt(id)) { var index = menuindex.indexOf(id), elMenuIndex = w.main.document.querySelector('#documentPane input[name=menuindex]'), @@ -1231,7 +1234,7 @@ } var f = d.getElementById('nameHolder'); f.innerHTML = this.selectedObjectName; - el.style.left = a + (modx.config.textdir ? '-190' : '') + 'px'; + el.style.left = a + (modx.config.textdir === 'rtl' ? '-190' : '') + 'px'; el.style.top = b + 'px'; el.classList.add('show'); }, @@ -1323,7 +1326,7 @@ if (el) el.classList.add('selected'); }, setItemToChange: function() { - var a = w.main.document && (w.main.document.URL || w.main.document.location.search), + var a = w.main.document && (w.main.document.URL || modx.normalizeUrl(w.main.document.location.href)), b = modx.getActionFromUrl(a); if (a && modx.typesactions[b]) { this.itemToChange = (modx.typesactions[b] === 7 ? '' : modx.typesactions[b] + '_') + parseInt(modx.main.getQueryVariable('id', a)); @@ -1338,7 +1341,7 @@ d.getElementById('treeloader').classList.add('visible'); this.setItemToChange(); this.rpcNode = d.getElementById('treeRoot'); - modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=0&expandAll=2&id=' + this.itemToChange, function(r) { + modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=' + modx.tree_parent + '&expandAll=2&id=' + this.itemToChange, function(r) { modx.tree.rpcLoadData(r); modx.tree.draggable(); }); @@ -1347,7 +1350,7 @@ expandTree: function() { this.rpcNode = d.getElementById('treeRoot'); d.getElementById('treeloader').classList.add('visible'); - modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=0&expandAll=1&id=' + this.itemToChange, function(r) { + modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=' + modx.tree_parent + '&expandAll=1&id=' + this.itemToChange, function(r) { modx.tree.rpcLoadData(r); modx.tree.saveFolderState(); modx.tree.draggable(); @@ -1356,7 +1359,7 @@ collapseTree: function() { this.rpcNode = d.getElementById('treeRoot'); d.getElementById('treeloader').classList.add('visible'); - modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=0&expandAll=0&id=' + this.itemToChange, function(r) { + modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', 'a=1&f=nodes&indent=1&parent=' + modx.tree_parent + '&expandAll=0&id=' + this.itemToChange, function(r) { modx.openedArray = []; modx.tree.saveFolderState(); modx.tree.rpcLoadData(r); @@ -1367,7 +1370,7 @@ this.rpcNode = d.getElementById('treeRoot'); d.getElementById('treeloader').classList.add('visible'); var a = d.sortFrm; - var b = 'a=1&f=nodes&indent=1&parent=0&expandAll=2&dt=' + a.dt.value + '&tree_sortby=' + a.sortby.value + '&tree_sortdir=' + a.sortdir.value + '&tree_nodename=' + a.nodename.value + '&id=' + this.itemToChange + '&showonlyfolders=' + a.showonlyfolders.value; + var b = 'a=1&f=nodes&indent=1&parent=' + modx.tree_parent + '&expandAll=2&dt=' + a.dt.value + '&tree_sortby=' + a.sortby.value + '&tree_sortdir=' + a.sortdir.value + '&tree_nodename=' + a.nodename.value + '&id=' + this.itemToChange + '&showonlyfolders=' + a.showonlyfolders.value; modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', b, function(r) { modx.tree.rpcLoadData(r); modx.tree.draggable(); @@ -1414,7 +1417,7 @@ if (a) { el.title = modx.lang.empty_recycle_bin; el.classList.remove('disabled'); - el.innerHTML = modx.style.empty_recycle_bin; + el.innerHTML = modx.style.icon_trash; el.onclick = function() { modx.tree.emptyTrash(); }; @@ -1425,7 +1428,7 @@ } else { el.title = modx.lang.empty_recycle_bin_empty; el.classList.add('disabled'); - el.innerHTML = modx.style.empty_recycle_bin_empty; + el.innerHTML = modx.style.icon_trash_alt; el.onclick = null; } } @@ -1524,15 +1527,16 @@ function Tabs(a) { var s = this; - this.url = a.url; + this.url = a.url.replace(new RegExp(modx.MODX_MANAGER_URL, 'g'), ''); this.title = a.title || ''; this.name = a.name || ''; this.timer = null; this.olduid = ''; this.closeactions = [6, 61, 62, 63, 94]; - this.saveAndCloseActions = [75, 86, 99, 106]; + this.saveAndCloseActions = [75, 76, 86, 99, 106]; this.reload = typeof a.reload !== 'undefined' ? a.reload : 1; this.action = modx.getActionFromUrl(a.url); + this.getTab = modx.main.getQueryVariable('tab', a.url); this.uid = modx.getActionFromUrl(a.url, 2) ? 'home' : modx.urlToUid(a.url); this.page = d.getElementById('evo-tab-page-' + this.uid); this.row = d.getElementsByClassName('evo-tab-row')[0].firstElementChild; @@ -1620,26 +1624,26 @@ onload: function(e) { var s = this; w.main = e.target.contentWindow || e.target.defaultView; - this.url = w.main.location.search || w.location.hash.substring(1); + this.url = modx.normalizeUrl(w.main.location.href) || modx.normalizeUrl(w.location.href); this.olduid = this.uid; this.uid = modx.urlToUid(this.url); if (!!w.main.__alertQuit) { w.main.alert = function(a) { }; var message = w.main.document.body.innerHTML; w.main.document.body.style.display = 'none'; - history.pushState(null, d.title, modx.getActionFromUrl(w.location.search, 2) ? modx.MODX_MANAGER_URL : '#' + w.location.search); + history.pushState(null, d.title, modx.getActionFromUrl(this.url, 2) ? modx.MODX_MANAGER_URL : '#' + this.url); w.onpopstate = function() { history.go(1); }; modx.popup({ type: 'warning', - title: 'MODX :: Alert', + title: 'Evolution CMS :: Alert', position: 'top center alertQuit', content: message, wrap: 'body' }); modx.getLockedElements(modx.getActionFromUrl(this.url), modx.main.getQueryVariable('id', this.url), function(data) { - if (!!data) { + if (!!data || ~s.closeactions.indexOf(modx.getActionFromUrl(s.url))) { s.page.close(); modx.tree.restoreTree(); } else { @@ -1647,7 +1651,6 @@ w.history.replaceState(null, d.title, modx.getActionFromUrl(s.url, 2) ? modx.MODX_MANAGER_URL : '#' + s.url); } }); - modx.main.stopWork(); } else { if (modx.getActionFromUrl(this.url, 2) || (~this.saveAndCloseActions.indexOf(modx.getActionFromUrl(this.url)) && parseInt(modx.main.getQueryVariable('r', this.url)))) { this.close(e); @@ -1671,7 +1674,7 @@ } }, false); w.main.document.addEventListener('keyup', function a(e) { - if (typeof e.view.documentDirty !== 'undefined' && e.view.documentDirty && !s.tab.classList.contains('changed')) { + if (e.view && e.view.documentDirty && !s.tab.classList.contains('changed')) { s.tab.classList.add('changed'); this.removeEventListener(e.type, a, false); } @@ -1680,7 +1683,6 @@ } }, show: function() { - var s = this; modx.tabs.selected = this.row.querySelector('.selected'); if (modx.tabs.selected && modx.tabs.selected !== this.tab) { d.getElementById(modx.tabs.selected.id.replace('tab', 'tab-page')).classList.remove('show'); @@ -1690,9 +1692,13 @@ this.tab.classList.add('selected'); modx.tabs.selected = this.tab; w.main = this.page.firstElementChild.contentWindow; - w.history.replaceState(null, w.main.document.title, modx.getActionFromUrl(w.main.location.search, 2) ? modx.MODX_MANAGER_URL : '#' + w.main.location.search); - modx.tree.setItemToChange(); - modx.main.tabRow.scroll(this.row, this.tab, 350); + if (this.getTab && this.action === 76 && !~w.main.frameElement.contentDocument.location.href.indexOf(this.url)) { + w.main.frameElement.src = this.url; + } else { + w.history.replaceState(null, w.main.document.title, modx.getActionFromUrl(this.url, 2) ? modx.MODX_MANAGER_URL : '#' + this.url); + modx.tree.setItemToChange(); + modx.main.tabRow.scroll(this.row, this.tab, 350); + } }, close: function(e) { var documentDirty = this.page.firstElementChild.contentWindow.documentDirty; @@ -1706,6 +1712,7 @@ this.row.removeChild(this.tab); modx.tabs.selected.show(); } + modx.main.stopWork(); }, select: function(e) { if (e.target.className === 'tab-close') { @@ -1731,7 +1738,7 @@ el.checked = this.action === 61; w.main.document.getElementsByName('published')[0].value = +el.checked; } - if (modx.getActionFromUrl(w.main.location.search, 3)) { + if (modx.getActionFromUrl(modx.normalizeUrl(w.main.location.href), 3)) { w.main.location.reload(); } } @@ -1848,6 +1855,7 @@ if (o.draggable) { modx.dragging(o.el, {wrap: o.wrap, resize: o.resize}); } + o.el.classList.add('show'); }, close: function(e) { o.event = e || o.event || w.event; @@ -1978,7 +1986,7 @@ o.el.style.height = !/[^[0-9]/.test(o.height) ? o.height + 'px' : o.height; o.el.style.zIndex = o.zIndex; o.el.style.margin = o.margin; - o.el.className = o.className + ' show alert alert-' + o.type + ' ' + o.addclass + (o.animation ? ' animation ' + o.animation : ''); + o.el.className = o.className + ' alert alert-' + o.type + ' ' + o.addclass + (o.animation ? ' animation ' + o.animation : ''); o.el.dataset.position = o.position.join(':'); if (o.showclose) { o.el.innerHTML += '
×
'; @@ -2021,7 +2029,7 @@ if (!!e.target.contentWindow.__alertQuit) { modx.popup({ type: 'warning', - title: 'MODX :: Alert', + title: 'Evolution CMS :: Alert', position: 'top center alertQuit', content: e.target.contentWindow.document.body.querySelector('p').innerHTML }); @@ -2115,7 +2123,7 @@ modx.tree.ctx = null; } if (!/dropdown\-item/.test(e.target.className) - //&& !(e && ("click" === e.type && /form|label|input|textarea|select/i.test(e.target.tagName))) + //&& !(e && ("click" === e.type && /form|label|input|textarea|select/i.test(e.target.tagName))) ) { var els = d.querySelectorAll('.dropdown.show'), n = null, @@ -2126,17 +2134,17 @@ } else if (t.classList.contains('dropdown-toggle')) { n = t.offsetParent; } - els.forEach(function(el) { - if (n !== el) { - el.classList.remove('show'); + for (i = 0; i < els.length; i++) { + if (n !== els[i]) { + els[i].classList.remove('show'); } - }); + } els = w.main && w.main.document.querySelectorAll('.dropdown.show') || []; - els.forEach(function(el) { - if (n !== el) { - el.classList.remove('show'); + for (i = 0; i < els.length; i++) { + if (n !== els[i]) { + els[i].classList.remove('show'); } - }); + } } }, XHR: function() { @@ -2230,12 +2238,18 @@ return parseInt(modx.main.getQueryVariable('a', a)); } }, + normalizeUrl(url) { + url = url.replace(new RegExp(modx.MODX_MANAGER_URL, 'g'), ''); + url = url.replace(/^index\.php/, ''); + url = url.replace(/^#/, ''); + return url; + }, getLockedElements: function(a, b, c) { if (modx.typesactions[a] && b) { modx.post(modx.MODX_MANAGER_URL + 'media/style/' + modx.config.theme + '/ajax.php', { a: 'getLockedElements', - id: modx.main.getQueryVariable('id', w.main.location.search), - type: modx.typesactions[modx.getActionFromUrl(w.main.location.search)] + id: modx.main.getQueryVariable('id', modx.normalizeUrl(w.main.location.href)), + type: modx.typesactions[modx.getActionFromUrl(modx.normalizeUrl(w.main.location.href))] }, c); } }, @@ -2436,28 +2450,28 @@ var b = ''; switch (this.typesactions[a]) { case 1: - b = 'fa fa-newspaper-o'; + b = modx.style.icon_template; break; case 2: - b = 'fa fa-list-alt'; + b = modx.style.icon_tv; break; case 3: - b = 'fa fa-th-large'; + b = modx.style.icon_chunk; break; case 4: - b = 'fa fa-code'; + b = modx.style.icon_code; break; case 5: - b = 'fa fa-plug'; + b = modx.style.icon_plugin; break; case 6: - b = 'fa fa-cube'; + b = modx.style.icon_element; break; case 7: - b = 'fa fa-pencil-square-o'; + b = modx.style.icon_edit; break; default: - b = 'fa fa-circle'; + b = modx.style.icon_circle; } return b; }, @@ -2571,9 +2585,10 @@ //console.log('tree.resizeTree() off') }; w.onbeforeunload = function() { - var a = w.main.frameElement.contentWindow; - if (modx.getActionFromUrl(a.location.search, 27)) { - modx.get(modx.MODX_MANAGER_URL + '?a=67&type=7&id=' + modx.main.getQueryVariable('id', a.location.search.substring(1))); + var a = w.main.frameElement.contentWindow, + url = modx.normalizeUrl(a.location.href); + if (modx.getActionFromUrl(url, 27)) { + modx.get(modx.MODX_MANAGER_URL + '?a=67&type=7&id=' + modx.main.getQueryVariable('id', url)); } }; d.addEventListener('DOMContentLoaded', function() { diff --git a/manager/media/style/default/js/modx.min.js b/manager/media/style/default/js/modx.min.js deleted file mode 100755 index 5d0934971c..0000000000 --- a/manager/media/style/default/js/modx.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(w,d,u){"use strict";modx.extended({frameset:"frameset",minWidth:840,isMobile:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),typesactions:{16:1,301:2,78:3,22:4,102:5,108:6,3:7,4:7,6:7,27:7,61:7,62:7,63:7,72:7},thememodes:["","lightness","light","dark","darkness"],tabsTimer:0,popupTimer:0,init:function(){var e;localStorage.getItem("MODX_widthSideBar")||localStorage.setItem("MODX_widthSideBar",this.config.tree_width),this.mainmenu.init(),w.location.hash&&(modx.getActionFromUrl(w.location.hash,2)?w.history.replaceState(null,d.title,modx.MODX_MANAGER_URL):(modx.getActionFromUrl(w.location.hash)||modx.main.getQueryVariable("filemanager",w.location.hash))&&(e=modx.main.getQueryVariable("filemanager",w.location.hash)?modx.MODX_MANAGER_URL+modx.main.getQueryVariable("filemanager",w.location.hash)+w.location.hash.replace("#?","?"):w.location.href.replace("#?","?"),modx.config.global_tabs?modx.tabs({url:e,title:"blank"}):w.main?w.main.frameElement.src=e:modx.openWindow(e))),this.resizer.init(),this.search.init(),0 li > a:not(:hover)").forEach(function(e){e.classList.remove("selected")}),this.classList.add("selected"),t.classList.add("show")),e.stopPropagation(),e.target.dataset.toggle="#mainMenu",modx.hideDropDown(e)),this.closest("ul").classList.contains("dropdown-menu")&&!this.closest("li").classList.contains("dropdown-back")&&(t.querySelectorAll(".nav > .active").forEach(function(e){e.classList.remove("active")}),t.querySelectorAll(".nav li.selected").forEach(function(e){e.classList.remove("selected")}),this.closest(".nav > li").classList.add("active"),this.offsetParent.id&&d.getElementById(this.offsetParent.id.substr(7)).classList.add("selected"),(modx.isMobile||w.innerWidth li").forEach(function(e){e.addEventListener("mouseenter",function(){t.querySelectorAll(".nav > li.hover:not(:hover)").forEach(function(e){e.classList.remove("hover")}),this.classList.add("hover")})}),t.querySelectorAll(".nav > li li").forEach(function(e){e.addEventListener("mouseenter",function(s){var n,a=this;t.querySelectorAll(".nav > li li.hover:not(:hover)").forEach(function(e){e.classList.remove("hover")}),this.classList.add("hover"),clearTimeout(r),this.offsetParent.nextElementSibling&&this.offsetParent.nextElementSibling.classList.contains("sub-menu")?n=this.offsetParent.nextElementSibling:this.offsetParent&&this.offsetParent.classList.contains("sub-menu")?n=this.offsetParent:((n=d.createElement("ul")).className="sub-menu dropdown-menu",this.parentNode.parentNode.appendChild(n)),r=setTimeout(function(){d.querySelector(".nav .sub-menu.show")&&d.querySelector(".nav .sub-menu.show").classList.remove("show"),n.style.left=a.offsetWidth+"px",a.classList.contains("dropdown-toggle")?n.id==="parent_"+a.id?(modx.isMobile?a.parentNode.classList.add("selected"):a.onclick=function(e){e.target.classList.contains("toggle")&&a.parentNode.classList.add("selected")},n.classList.add("show")):(n.classList.remove("show"),t.querySelectorAll(".nav ul.selected").forEach(function(e){e.classList.remove("selected")}),r=setTimeout(function(){var i=a.firstElementChild.href&&"main"===a.firstElementChild.target?a.firstElementChild.href.split("?")[1]+"&elements="+a.id:"";modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php",i,function(e){if(e){(modx.isMobile||w.innerWidth'+modx.lang.paging_prev+""+e),n.id="parent_"+a.id,n.innerHTML=e;var e=w.location.hash.substr(2).replace(/=/g,"_").replace(/&/g,"__"),t=d.getElementById(e);t&&(t.parentNode.classList.add("selected"),d.getElementById(t.parentNode.parentNode.id.substr(7)).classList.add("selected"));for(var o=0;oi.length-1&&(n=i.length-1),0<=n&&n .tab-row");e&&this.build(e)},build:function(t){var e=d.createElement("div"),o=t.querySelector(".selected");e.className="tab-row-container",t.parentNode.insertBefore(e,t),e.appendChild(t);var i=d.createElement("i");i.className="fa fa-angle-left prev disable",i.onclick=function(e){e.stopPropagation(),e.preventDefault();e=t.querySelector(".selected");e.previousSibling&&(e.previousSibling.click(),modx.main.tabRow.scroll(t))},e.appendChild(i);var s=d.createElement("i");s.className="fa fa-angle-right next disable",s.onclick=function(e){e.stopPropagation(),e.preventDefault();e=t.querySelector(".selected");e.nextSibling&&(e.nextSibling.click(),modx.main.tabRow.scroll(t))},e.appendChild(s),setTimeout(function(){o=t.querySelector(".selected"),modx.main.tabRow.scroll(t,o),w.main.addEventListener("resize",function(){modx.main.tabRow.scroll(t)},!1),o&&(o.previousSibling&&i.classList.remove("disable"),o.nextSibling&&s.classList.remove("disable"))},100),t.onclick=function(e){e="H2"===e.target.tagName?e.target:"SPAN"===e.target.tagName?e.target.parentNode:null;e&&(e.previousSibling?this.parentNode.querySelector("i.prev").classList.remove("disable"):this.parentNode.querySelector("i.prev").classList.add("disable"),e.nextSibling?this.parentNode.querySelector("i.next").classList.remove("disable"):this.parentNode.querySelector("i.next").classList.add("disable"),modx.main.tabRow.scroll(this,e))}},scroll:function(e,t,o){t=t||e.querySelector(".selected")||e.firstChild,o=o||64;for(var i=0,s=e.childNodes,n=0;nt.offsetLeft&&modx.animate(e,{scrollLeft:t.offsetLeft-(t.previousSibling?30:1)},o),t.offsetLeft+t.offsetWidth>e.offsetWidth+e.scrollLeft&&modx.animate(e,{scrollLeft:t.offsetLeft-e.offsetWidth+t.offsetWidth+(t.nextSibling?30:0)},o),i>e.offsetWidth&&this.drag(e)},drag:function(i){i.onmousedown=function(e){var t,o;0===e.button&&(e.preventDefault(),t=e.clientX,o=i.scrollLeft,i.ownerDocument.body.focus(),i.onmousemove=i.ownerDocument.onmousemove=function(e){5Math.abs(t)&&this.swipe&&(e<0&&this.sidebar?(Math.abs(e)>n&&(e=-n),s.style.transform="translate3d("+e+"px, 0, 0)",s.style.WebkitTransform="translate3d("+e+"px, 0, 0)",modx.resizer.mask.style.opacity=(.5-.5/-n*e).toFixed(2),Math.abs(e)>n/3?this.swipe="left":this.swipe="right"):0n&&(e=n),s.style.transform="translate3d("+-(n-e)+"px, 0, 0)",s.style.WebkitTransform="translate3d("+-(n-e)+"px, 0, 0)",modx.resizer.mask.style.opacity=(.5/n*e).toFixed(2),Math.abs(e)>n/3?this.swipe="right":this.swipe="left"))},!1),w.addEventListener("touchend",function(){"left"===this.swipe&&(d.body.classList.add("sidebar-closed"),modx.resizer.setWidth(0)),"right"===this.swipe&&(d.body.classList.remove("sidebar-closed"),modx.resizer.setWidth(n)),s.style.cssText="",modx.resizer.mask.style.cssText=""},!1)))},onMouseDown:function(e){if(e=e||w.event,modx.resizer.dragElement=null!==e.target?e.target:e.srcElement,(1===e.buttons||0===e.button)&&modx.resizer.dragElement.id===modx.resizer.id)return modx.resizer.oldZIndex=modx.resizer.dragElement.style.zIndex,modx.resizer.dragElement.style.zIndex=modx.resizer.newZIndex,modx.resizer.dragElement.style.background=modx.resizer.background,localStorage.setItem("MODX_widthSideBar",0this.offsetHeight/1.51?(this.parentNode.classList.add("dragafter"),this.parentNode.classList.remove("dragbefore"),this.parentNode.classList.remove("dragenter"),e.dataTransfer.effectAllowed="move",e.dataTransfer.dropEffect="move"):t";if(this.nextSibling)for(this.nextSibling.innerHTML?this.nextSibling.appendChild(t):t.parentNode.removeChild(t),o=this.parentNode.lastChild.children,l=0;l";for(this.parentNode.parentNode.insertBefore(t,this.parentNode.nextSibling),o=this.parentNode.parentNode.children,l=0;l";for(this.parentNode.parentNode.insertBefore(t,this.parentNode),o=this.parentNode.parentNode.children,l=0;l a").dataset.titleEsc+")"))},toggleTheme:function(){var e,t,o=1,i=w.main.myCodeMirrors;for(t in void 0===localStorage.MODX_themeMode&&(localStorage.MODX_themeMode=modx.config.theme_mode),modx.thememodes[parseInt(localStorage.MODX_themeMode)+1]&&(o=parseInt(localStorage.MODX_themeMode)+1),e=modx.thememodes[o],modx.thememodes)modx.thememodes[t]&&(d.body.classList.remove(modx.thememodes[t]),w.main.document.body.classList.remove(modx.thememodes[t]));if(d.body.classList.add(e),w.main.document.body.classList.add(e),d.cookie="MODX_themeMode="+o,localStorage.MODX_themeMode=o,void 0!==i)for(t in i)i.hasOwnProperty(t)&&(~e.indexOf("dark")?(w.main.document.getElementsByName(t)[0].nextElementSibling.classList.add("cm-s-"+i[t].options.darktheme),w.main.document.getElementsByName(t)[0].nextElementSibling.classList.remove("cm-s-"+i[t].options.defaulttheme)):(w.main.document.getElementsByName(t)[0].nextElementSibling.classList.remove("cm-s-"+i[t].options.darktheme),w.main.document.getElementsByName(t)[0].nextElementSibling.classList.add("cm-s-"+i[t].options.defaulttheme)))},toggleNode:function(e,t){var o,i,s,n,a;(e=e||w.event).ctrlKey||(e.stopPropagation(),o=d.getElementById("node"+t).firstChild,this.rpcNode=o.nextSibling,i=o.querySelector(".toggle"),s=o.querySelector(".icon"),""===this.rpcNode.innerHTML?(i&&(i.innerHTML=o.dataset.iconCollapsed),s.innerHTML=o.dataset.iconFolderOpen,n=this.rpcNode.innerHTML,a=modx.lang.loading_doc_tree,modx.openedArray[t]=1,(""===n||0("+t+")"}),modx.isMobile&&w.innerWidthe.view.position.width&&(x=e.view.position.width-this.ctx.offsetWidth),y+this.ctx.offsetHeight/2>e.view.position.height?y=e.view.position.height-this.ctx.offsetHeight-5:y-this.ctx.offsetHeight/2bodyHeight?y=bodyHeight-ctx.offsetHeight-5:y-ctx.offsetHeight/2("+this.itemToChange+")"});break;case 2:this.setActiveFromContextMenu(this.itemToChange),modx.tabs({url:modx.MODX_MANAGER_URL+"?a=27&r=1&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 3:modx.tabs({url:modx.MODX_MANAGER_URL+"?a=4&pid="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 4:this.selectedObjectDeleted?alert('"'+this.selectedObjectName+'" '+modx.lang.already_deleted):!0===confirm('"'+this.selectedObjectName+'"\n\n'+modx.lang.confirm_delete_resource)&&modx.tabs({url:modx.MODX_MANAGER_URL+"?a=6&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 5:this.setActiveFromContextMenu(this.itemToChange),modx.tabs({url:modx.MODX_MANAGER_URL+"?a=51&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 6:modx.tabs({url:modx.MODX_MANAGER_URL+"?a=72&pid="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 7:!0===confirm(modx.lang.confirm_resource_duplicate)&&modx.tabs({url:modx.MODX_MANAGER_URL+"?a=94&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 8:d.getElementById("node"+this.itemToChange).firstChild.dataset.deleted?!0===confirm('"'+this.selectedObjectName+'" '+modx.lang.confirm_undelete)&&modx.tabs({url:modx.MODX_MANAGER_URL+"?a=63&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"}):alert('"'+this.selectedObjectName+'"'+modx.lang.not_deleted);break;case 9:!0===confirm('"'+this.selectedObjectName+'" '+modx.lang.confirm_publish)&&modx.tabs({url:modx.MODX_MANAGER_URL+"?a=61&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 10:this.itemToChange!==modx.config.site_start?!0===confirm('"'+this.selectedObjectName+'" '+modx.lang.confirm_unpublish)&&modx.tabs({url:modx.MODX_MANAGER_URL+"?a=62&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"}):alert("Document is linked to site_start variable and cannot be unpublished!");break;case 11:modx.tabs({url:modx.MODX_MANAGER_URL+"?a=56&id="+this.itemToChange,title:this.selectedObjectName+"("+this.itemToChange+")"});break;case 12:w.open(d.getElementById("node"+this.itemToChange).firstChild.dataset.href,"previeWin");break;default:alert("Unknown operation command.")}},setSelected:function(e){var t=d.querySelector("#tree .current");t&&t.classList.remove("current"),e&&("object"==typeof e?e.classList.add("current"):(t=d.querySelector("#node"+e+">.node")||d.getElementById("node"+e))&&t.classList.add("current"))},setActiveFromContextMenu:function(e){e=d.querySelector("#node"+e+">.node");e&&this.setSelected(e)},setSelectedByContext:function(e){var t=d.querySelector("#treeRoot .selected");t&&t.classList.remove("selected"),(t=d.querySelector("#node"+e+">.node"))&&t.classList.add("selected")},setItemToChange:function(){var e=w.main.document&&(w.main.document.URL||w.main.document.location.search),t=modx.getActionFromUrl(e);e&&modx.typesactions[t]?this.itemToChange=(7===modx.typesactions[t]?"":modx.typesactions[t]+"_")+parseInt(modx.main.getQueryVariable("id",e)):this.itemToChange="",this.setSelected(this.itemToChange)},restoreTree:function(){d.getElementById("treeRoot")&&(d.getElementById("treeloader").classList.add("visible"),this.setItemToChange(),this.rpcNode=d.getElementById("treeRoot"),modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php","a=1&f=nodes&indent=1&parent=0&expandAll=2&id="+this.itemToChange,function(e){modx.tree.rpcLoadData(e),modx.tree.draggable()}))},expandTree:function(){this.rpcNode=d.getElementById("treeRoot"),d.getElementById("treeloader").classList.add("visible"),modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php","a=1&f=nodes&indent=1&parent=0&expandAll=1&id="+this.itemToChange,function(e){modx.tree.rpcLoadData(e),modx.tree.saveFolderState(),modx.tree.draggable()})},collapseTree:function(){this.rpcNode=d.getElementById("treeRoot"),d.getElementById("treeloader").classList.add("visible"),modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php","a=1&f=nodes&indent=1&parent=0&expandAll=0&id="+this.itemToChange,function(e){modx.openedArray=[],modx.tree.saveFolderState(),modx.tree.rpcLoadData(e),modx.tree.draggable()})},updateTree:function(){this.rpcNode=d.getElementById("treeRoot"),d.getElementById("treeloader").classList.add("visible");var e=d.sortFrm,e="a=1&f=nodes&indent=1&parent=0&expandAll=2&dt="+e.dt.value+"&tree_sortby="+e.sortby.value+"&tree_sortdir="+e.sortdir.value+"&tree_nodename="+e.nodename.value+"&id="+this.itemToChange+"&showonlyfolders="+e.showonlyfolders.value;modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php",e,function(e){modx.tree.rpcLoadData(e),modx.tree.draggable()})},getFolderState:function(){var e;if(modx.openedArray!==[0])for(var t in e="&opened=",modx.openedArray)modx.openedArray[t]&&(e+=t+"|");else e="&opened=";return e},saveFolderState:function(){modx.post(modx.MODX_MANAGER_URL+"media/style/"+modx.config.theme+"/ajax.php","a=1&f=nodes&savestateonly=1"+this.getFolderState())},showSorter:function(e){e=e||w.event;var t=d.getElementById("floater");e.target.dataset.toggle="#floater",t.classList.toggle("show"),t.onclick=function(e){e.stopPropagation()}},emptyTrash:function(){!0===confirm(modx.lang.confirm_empty_trash)&&modx.get(modx.MODX_MANAGER_URL+"?a=64",function(){modx.tabsClose(modx.tree.deleted),modx.tree.deleted=[],modx.tree.restoreTree()})},showBin:function(e){var t=d.getElementById("treeMenu_emptytrash");if(t)if(e){t.title=modx.lang.empty_recycle_bin,t.classList.remove("disabled"),t.innerHTML=modx.style.empty_recycle_bin,t.onclick=function(){modx.tree.emptyTrash()};for(var o=d.getElementById("tree").querySelectorAll(".deleted"),i=0;i"+modx.style.email+modx.lang.inbox+" ("+t[0]+" / "+t[1]+")",e.style.display="block"),0':this.page.innerHTML='',d.getElementById("main").appendChild(this.page),this.page.firstElementChild.onload=function(e){t.onload.call(t,e)},this.tab=d.createElement("h2"),this.tab.id="evo-tab-"+this.uid,this.tab.className="tab selected",this.icon="",/'),this.tab.innerHTML=''+this.icon+this.title+'×',this.row.appendChild(this.tab),this.tab.onclick=function(e){t.select.call(t,e,this)},this.tab.close=function(e){t.close.call(t,e)},this.tab.show=function(e){t.show.call(t,e)},this.page.close=function(e){t.close.call(t,e)}},onload:function(e){var t,o=this;w.main=e.target.contentWindow||e.target.defaultView,this.url=w.main.location.search||w.location.hash.substring(1),this.olduid=this.uid,this.uid=modx.urlToUid(this.url),w.main.__alertQuit?(w.main.alert=function(e){},t=w.main.document.body.innerHTML,w.main.document.body.style.display="none",history.pushState(null,d.title,modx.getActionFromUrl(w.location.search,2)?modx.MODX_MANAGER_URL:"#"+w.location.search),w.onpopstate=function(){history.go(1)},modx.popup({type:"warning",title:"MODX :: Alert",position:"top center alertQuit",content:t,wrap:"body"}),modx.getLockedElements(modx.getActionFromUrl(this.url),modx.main.getQueryVariable("id",this.url),function(e){e?(o.page.close(),modx.tree.restoreTree()):(w.main.location.href=modx.MODX_MANAGER_URL+o.url,w.history.replaceState(null,d.title,modx.getActionFromUrl(o.url,2)?modx.MODX_MANAGER_URL:"#"+o.url))}),modx.main.stopWork()):modx.getActionFromUrl(this.url,2)||~this.saveAndCloseActions.indexOf(modx.getActionFromUrl(this.url))&&parseInt(modx.main.getQueryVariable("r",this.url))?this.close(e):this.olduid!==this.uid&&d.getElementById("evo-tab-"+this.uid)?(this.close(e),d.getElementById("evo-tab-"+this.uid).show()):(this.title=w.main.document.body.querySelectorAll("h1")[0]&&w.main.document.body.querySelectorAll("h1")[0].innerHTML||this.title,this.title&&"home"!==this.uid&&(this.tab.innerHTML=''+this.title+'×'),this.page.id="evo-tab-page-"+this.uid,this.tab.id="evo-tab-"+this.uid,this.tab.classList.remove("changed"),this.show(),modx.main.onload(e),w.main.document.addEventListener("click",function e(t){void 0!==t.view.documentDirty&&t.view.documentDirty&&!o.tab.classList.contains("changed")&&(o.tab.classList.add("changed"),this.removeEventListener(t.type,e,!1))},!1),w.main.document.addEventListener("keyup",function e(t){void 0!==t.view.documentDirty&&t.view.documentDirty&&!o.tab.classList.contains("changed")&&(o.tab.classList.add("changed"),this.removeEventListener(t.type,e,!1))},!1))},show:function(){modx.tabs.selected=this.row.querySelector(".selected"),modx.tabs.selected&&modx.tabs.selected!==this.tab&&(d.getElementById(modx.tabs.selected.id.replace("tab","tab-page")).classList.remove("show"),modx.tabs.selected.classList.remove("selected")),this.page.classList.add("show"),this.tab.classList.add("selected"),modx.tabs.selected=this.tab,w.main=this.page.firstElementChild.contentWindow,w.history.replaceState(null,w.main.document.title,modx.getActionFromUrl(w.main.location.search,2)?modx.MODX_MANAGER_URL:"#"+w.main.location.search),modx.tree.setItemToChange(),modx.main.tabRow.scroll(this.row,this.tab,350)},close:function(e){var t=this.page.firstElementChild.contentWindow.documentDirty,o=!!this.page.firstElementChild.contentWindow.checkDirt;(t&&o&&confirm(this.page.firstElementChild.contentWindow.checkDirt(e))||!t)&&(modx.tabs.selected===this.tab&&(tree.ca="open"),modx.tabs.selected=this.tab.classList.contains("selected")?this.tab.previousElementSibling:this.row.querySelector(".selected"),this.page.parentNode.removeChild(this.page),this.row.removeChild(this.tab),modx.tabs.selected.show())},select:function(e){var t;"tab-close"===e.target.className?this.close(e):modx.tabs.selected===this.tab?(t=this).timer?(clearTimeout(this.timer),this.timer=null,w.main.location.reload()):this.timer=setTimeout(function(){t.timer=null},250):this.show()},setDocPublished:function(){var e=w.main.document.getElementsByName("publishedcheck")[0];e&&(e.checked=61===this.action,w.main.document.getElementsByName("published")[0].value=+e.checked),modx.getActionFromUrl(w.main.location.search,3)&&w.main.location.reload()}},modx.config.global_tabs){if(void 0===e.currentTarget)return new t(e);var o=e;0===o.button&&o.target&&("A"===o.target.tagName&&"main"===o.target.target||o.target.parentNode&&"A"===o.target.parentNode.tagName&&"main"===o.target.parentNode.target)&&(e="A"===o.target.tagName&&o.target||"A"===o.target.parentNode.tagName&&o.target.parentNode,o.shiftKey?modx.openWindow({url:e.href}):modx.tabs({url:e.href,title:e.innerHTML}),o.preventDefault())}else e.url&&(w.main?w.main.frameElement.src=e.url:modx.openWindow(e.url))},popup:function(t){if("object"==typeof t&&(t.url||t.content||t.text)){var e,o,i={addclass:"",animation:"fade",content:t.content||t.text||"",clickclose:0,closeall:0,data:"",dataType:"document",delay:5e3,draggable:!1,event:null,height:"auto",hide:1,hover:1,icon:"",iframe:"iframe",margin:".5rem",maxheight:"",method:"GET",overlay:0,overlayclose:0,position:"center",resize:!1,selector:"",showclose:1,target:"main",uid:"",type:"default",title:"",url:"",width:"20rem",wrap:t.wrap||w.main.document.body,zIndex:10500,w:null,show:function(){~i.position.indexOf("center")&&(i.event?(i.el.style.left=i.event.clientX+i.mt+"px",i.el.style.bottom=i.w.innerHeight-i.el.offsetHeight-i.event.clientY+i.mt+"px"):(i.el.style.left=/(%)/.test(i.width)?(100-parseInt(i.width))/2-i.mt/(i.w.innerWidth/100)+"%":(i.w.innerWidth-i.el.offsetWidth)/2-i.mt+"px",i.el.style.bottom=/(%)/.test(i.height)?(100-parseInt(i.height))/2-i.mt/(i.w.innerHeight/100)+"%":(i.w.innerHeight-i.el.offsetHeight-i.wrap.offsetTop)/2-i.mt+"px")),~i.position.indexOf("left")&&(i.el.style.left=0),~i.position.indexOf("right")?i.el.style.right=0:i.el.style.right="auto",~i.position.indexOf("top")?(i.el.style.top=0,i.el.style.bottom=""):i.el.style.top="auto",~i.position.indexOf("bottom")&&(i.el.style.bottom=0),i.calc(),i.el.className+=" in",i.showclose&&(i.el.querySelector(".close").onclick=i.close),i.hide&&(i.el.timer=setTimeout(function(){clearTimeout(i.el.timer),i.close()},i.delay)),i.hover&&(i.el.onmouseenter=function(){clearTimeout(i.el.timer)},i.el.onmouseleave=i.close),i.overlayclose&&i.o&&(i.o.onclick=i.close),i.clickclose&&(i.el.onclick=i.close),i.draggable&&modx.dragging(i.el,{wrap:i.wrap,resize:i.resize})},close:function(e){var t;i.event=e||i.event||w.event,i.url&&"iframe"===i.iframe?!i.wrap.ownerDocument.querySelectorAll("."+i.className+".in")||((t=i.el.lastElementChild.firstElementChild.contentWindow.documentDirty)&&confirm(i.el.lastElementChild.firstElementChild.contentWindow.checkDirt(i.event))||!t)&&(i.el.classList.remove("in"),i.animation||i.el.classList.remove("show"),i.calc(1),i.o&&i.o.parentNode&&(i.o.parentNode.removeChild(i.o),i.wrap.style.overflow=""),i.el.timer=setTimeout(function(){clearTimeout(i.el.timer),i.el.parentNode&&i.el.parentNode.removeChild(i.el)},200)):(i.el.classList.remove("in"),i.animation||i.el.classList.remove("show"),i.calc(1),i.o&&i.o.parentNode&&(i.o.parentNode.removeChild(i.o),i.wrap.style.overflow=""),i.el.timer=setTimeout(function(){clearTimeout(i.el.timer),i.el.parentNode&&i.el.parentNode.removeChild(i.el)},200)),"function"==typeof i.onclose&&i.onclose(e,i.el)},calc:function(e){var t=i.wrap.ownerDocument.querySelectorAll("."+i.className+'.in[data-position="'+i.el.dataset.position+'"]');if(t&&t.length){i.els=[];for(var o=0;o×'),i.title&&(i.header=document.createElement("div"),"none"!==i.icon&&(i.header.innerHTML+=''),i.header.innerHTML+=i.title,i.header.className="evo-popup-header",i.el.appendChild(i.header)),i.el.innerHTML+='
',i.wrap.appendChild(i.el),i.mt=parseFloat(getComputedStyle(i.el).marginTop),i.maxheight&&(i.maxheight=/(%)/.test(i.maxheight)?(i.w.innerHeight-i.el.offsetHeight-i.mt)/100*parseInt(i.maxheight):i.maxheight,i.el.lastChild.style.overflowY="auto",i.el.lastChild.style.maxHeight=i.maxheight+"px"),i.url?(i.draggable=1,"iframe"===i.iframe?(i.resize=1,i.uid=modx.urlToUid(t.url),i.el.className+=" "+i.addclass+" "+i.className+"-iframe",i.el.id="evo-popup-"+i.uid,d.getElementById("mainloader").className="show",i.frame=d.createElement("iframe"),i.frame.width="100%",i.frame.height="100%",i.frame.frameBorder="0",i.frame.src=i.url,i.frame.onload=function(e){e.target.contentWindow.opener=i.w,t.url=e.target.contentWindow.location.href,i.uid=modx.urlToUid(t.url),(i.event=e).target.contentWindow.__alertQuit?(modx.popup({type:"warning",title:"MODX :: Alert",position:"top center alertQuit",content:e.target.contentWindow.document.body.querySelector("p").innerHTML}),e.target.contentWindow.document.body.innerHTML="",e.target.contentWindow.alert=function(){}):modx.getActionFromUrl(t.url,2)||1',this.classDrag&&this.el.classList.add(this.classDrag),this.classResize&&this.el.classList.add(this.classResize),this.el.insertBefore(this.borders,this.el.firstChild),this.handler&&this.el.getElementsByClassName(this.handler)[0]&&(this.handler=this.el.getElementsByClassName(this.handler)[0],this.handlerHeight=this.handler.offsetHeight),this.el.onmousedown=function(e){s.mousedown(e)},this.el.ontouchstart=function(e){s.mousedown(e.changedTouches[0])},this.wrap.addEventListener("mousemove",function(e){s.calc(e)},!1),this.wrap.addEventListener("touchmove",function(e){s.calc(e.changedTouches[0])},!1)},this.dragging.init.prototype={mousedown:function(e){var t,o,i,s;e.target.classList.contains("close")||(e=document.all?window.event:e,t=this,o=(document.all?window.event:e).clientX,i=(document.all?window.event:e).clientY,s=w.getComputedStyle(this.el),this.elmX=o-this.el.offsetLeft+parseInt(s.marginLeft),this.elmY=i-this.el.offsetTop+parseInt(s.marginTop),this.el.position=this.el.getBoundingClientRect(),this.el.style.position="fixed",this.el.style.transitionDuration="0s",this.el.style.webkitTransitionDuration="0s",this.el.style.left=this.el.offsetLeft-parseInt(s.marginLeft)+"px",this.el.style.top=this.el.offsetTop-parseInt(s.marginTop)+"px",this.el.style.right="auto",this.el.style.bottom="auto",this.el.style.width=this.el.position.width+"px",this.el.style.height=this.el.position.height+"px",e.target.parentNode===this.borders?(this.isresize=this.resize,this.el.classList.add("is-resize")):(!this.handler||this.handler&&e.target===this.handler)&&(this.isdrag=!0,this.el.classList.add("is-drag")),"function"==typeof this.start&&this.onstart(e,this.el),e.preventDefault?e.preventDefault():document.onselectstart=function(){return!1},this.wrap.onmousemove=function(e){t.mousemove(e)},this.wrap.ontouchmove=function(e){t.mousemove(e.changedTouches[0]),e.stopPropagation()},this.wrap.onmouseup=function(e){t.mouseup(e)},this.wrap.ontouchend=function(e){t.mouseup(e.changedTouches[0]),e.stopPropagation()})},mousemove:function(e){var t,o=(document.all?window.event:e).clientX,i=(document.all?window.event:e).clientY;this.isresize?(this.onRight&&(this.el.style.width=Math.max(o-this.el.position.left+(this.el.position.width-this.x),this.minWidth)+"px"),this.onBottom&&(this.el.style.height=Math.max(i-this.el.position.top+(this.el.position.height-this.y),this.minHeight)+"px"),this.onLeft&&(this.width=Math.max(this.el.position.left-o+this.el.position.width+this.x,this.minWidth),this.width>this.minWidth&&(this.el.style.width=this.width+"px",this.el.style.left=o-this.elmX+"px")),!this.onTop||(t=Math.max(this.el.position.top-i+this.el.position.height+this.y,this.minHeight))>this.minHeight&&(this.el.style.height=t+"px",this.el.style.top=i-this.elmY+"px"),"function"==typeof this.onresize&&this.onresize(e,this.el)):this.isdrag&&(this.el.style.opacity=this.opacity,this.el.style.left=o-this.elmX+"px",this.el.style.top=i-this.elmY+"px","function"==typeof this.drag&&this.ondrag(e,this.el))},mouseup:function(e){(this.isdrag||this.isresize)&&(this.el.classList.remove("is-resize"),this.el.classList.remove("is-drag"),this.el.style.opacity="",this.el.style.transitionDuration="",this.el.style.webkitTransitionDuration="",this.el.position=this.el.getBoundingClientRect(),this.isdrag=!1,this.isresize=!1,this.wrap.onmousemove=null,this.wrap.onselectstart=null,"function"==typeof this.stop&&this.onstop(e,this.el))},calc:function(e){this.isresize||this.isdrag||(this.x=e.clientX-this.el.offsetLeft,this.y=e.clientY-this.el.offsetTop,this.resize?(this.onTop=this.y=this.el.offsetWidth-this.border,this.onBottom=this.y>=this.el.offsetHeight-this.border,this.onRight&&this.onBottom||this.onLeft&&this.onTop?this.el.style.cursor="nwse-resize":this.onRight&&this.onTop||this.onBottom&&this.onLeft?this.el.style.cursor="nesw-resize":this.onRight||this.onLeft?this.el.style.cursor="ew-resize":this.onBottom||this.onTop?this.el.style.cursor="ns-resize":0=this.border?this.el.style.cursor="move":this.el.style.cursor="default"):0=this.border&&(this.el.style.cursor="move"))}},new this.dragging.init(e,t)},setTypeIcon:function(e){var t="";switch(this.typesactions[e]){case 1:t="fa fa-newspaper-o";break;case 2:t="fa fa-list-alt";break;case 3:t="fa fa-th-large";break;case 4:t="fa fa-code";break;case 5:t="fa fa-plug";break;case 6:t="fa fa-cube";break;case 7:t="fa fa-pencil-square-o";break;default:t="fa fa-circle"}return t},animate:function(n,a,r,l){if(n&&a&&"object"==typeof a){var e="px";"function"==typeof r&&(l=r,r=null),r=r||64,l="function"!=typeof l?function(){}:l;var t,o,i=getComputedStyle(n);for(t in a)a.hasOwnProperty(t)&&("opacity"===t&&(e=""),o=i[t],"scrollLeft"===t?o=n.scrollLeft:"scrollTop"===t&&(o=n.scrollTop),a[t]={start:parseInt(o),end:a[t],unit:e});var d=performance.now();requestAnimationFrame(function e(t){var o,i,s=(tconfig['manager_theme']/style.php - * Function: Manager style variables for images and icons. - * Encoding: UTF-8 - * Credit: icons by Mark James of FamFamFam http://www.famfamfam.com/lab/icons/ - * Date: 18-Mar-2010 - * Version: 1.1 - * MODX version: 1.0.3 - */ -$style_path = 'media/style/' . $modx->config['manager_theme'] . '/images/'; -$modx->config['mgr_date_picker_path'] = 'media/calendar/datepicker.inc.php'; -if(empty($modx->config['lang_code'])) { - global $modx_lang_attribute; - $modx->config['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; -} - -if(isset($_GET['a']) && $_GET['a'] == 2) { - include_once('welcome.php'); -} - -// Favicon -$_style['favicon'] = (file_exists(MODX_BASE_PATH . 'favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/' . $modx->config['manager_theme'] . '/images/favicon.ico'); - -//Main Menu -$_style['menu_search'] = ''; -$_style['menu_preview_site'] = ''; -$_style['menu_new_resource'] = ''; -$_style['menu_system'] = ''; -$_style['menu_user'] = ''; -// full screen -$_style['menu_expand'] = 'fa-expand'; -$_style['menu_compress'] = 'fa-compress'; -//help toggle -$_style['icons_help'] = ''; -//pages -$_style['page_settings'] = ''; -$_style['page_shedule'] = ''; -$_style['page_eventlog'] = ''; -$_style['page_manager_logs'] = ''; -$_style['page_sys_info'] = ''; -$_style['page_help'] = ''; -$_style['page_change_password'] = ''; -$_style['page_logout'] = ''; - -// Tree Menu Toolbar -$_style['add_doc_tree'] = ''; -$_style['add_weblink_tree'] = ''; -$_style['collapse_tree'] = ''; -$_style['empty_recycle_bin'] = ''; -$_style['empty_recycle_bin_empty'] = ''; -$_style['expand_tree'] = ''; -$_style['hide_tree'] = ''; -$_style['refresh_tree'] = ''; -$_style['show_tree'] = $style_path.'tree/expand.png'; -$_style['sort_tree'] = ''; -$_style['sort_menuindex'] = ''; -$_style['element_management'] = ''; -$_style['images_management'] = ''; -$_style['files_management'] = ''; -$_style['email'] = ''; - -//Tree Contextual Menu Popup -$_style['ctx_new_document'] = 'fa fa-file-o'; -$_style['ctx_edit_document'] = 'fa fa-pencil-square-o'; -$_style['ctx_move_document'] = 'fa fa-arrows'; -$_style['ctx_resource_duplicate'] = 'fa fa-clone'; -$_style['ctx_sort_menuindex'] = 'fa fa-sort-numeric-asc'; -$_style['ctx_publish_document'] = 'fa fa-check'; -$_style['ctx_unpublish_resource'] = 'fa fa-close'; -$_style['ctx_delete'] = 'fa fa-trash'; -$_style['ctx_undelete_resource'] = 'fa fa-undo'; -$_style['ctx_weblink'] = 'fa fa-link'; -$_style['ctx_resource_overview'] = 'fa fa-info'; -$_style['ctx_preview_resource'] = 'fa fa-eye'; - -// Tree Icons -$_style['tree_deletedpage'] = ""; -$_style['tree_folder'] = $style_path.'tree/folder-close-alt.png'; /* folder.png */ -$_style['tree_folderopen'] = $style_path.'tree/folder-open-alt.png'; /* folder-open.png */ -$_style['tree_globe'] = $style_path.'tree/globe.png'; -$_style['tree_folder_new'] = ""; /* folder.png */ -$_style['tree_folderopen_new'] = ""; /* folder-open.png */ -$_style['tree_folder_secure'] = ""; -$_style['tree_folderopen_secure'] = ""; -$_style['tree_linkgo'] = ""; -$_style['tree_page'] = ""; -$_style['tree_page_home'] = ""; -$_style['tree_page_404'] = ""; -$_style['tree_page_hourglass'] = ""; -$_style['tree_page_info'] = ""; -$_style['tree_page_blank'] = ""; -$_style['tree_page_css'] = ""; -$_style['tree_page_html'] = ""; -$_style['tree_page_xml'] = ""; -$_style['tree_page_js'] = ""; -$_style['tree_page_rss'] = ""; -$_style['tree_page_pdf'] = ""; -$_style['tree_page_word'] = ""; -$_style['tree_page_excel'] = ""; - -$_style['tree_minusnode'] = "";//$style_path.'tree/angle-down.png'; -$_style['tree_plusnode'] = "";//$style_path.'tree/angle-right.png'; -$_style['tree_weblink'] = $style_path.'tree/link.png'; -$_style['tree_preview_resource'] = "";//$style_path.'icons/eye.png'; - -$_style['tree_showtree'] = ''; -$_style['tree_working'] = ''; -$_style['tree_info'] = ''; - -$_style['tree_page_secure'] = ""; -$_style['tree_page_blank_secure'] = ""; -$_style['tree_page_css_secure'] = ""; -$_style['tree_page_html_secure'] = ""; -$_style['tree_page_xml_secure'] = ""; -$_style['tree_page_js_secure'] = ""; -$_style['tree_page_rss_secure'] = ""; -$_style['tree_page_pdf_secure'] = ""; -$_style['tree_page_word_secure'] = ""; -$_style['tree_page_excel_secure'] = ""; - -//search -$_style['icons_external_link'] = ''; - -//View Resource data -$_style['icons_new_document'] = 'fa fa-file-o'; -$_style['icons_new_weblink'] = 'fa fa-link'; -$_style['icons_move_document'] = 'fa fa-arrows'; -$_style['icons_publish_document'] = 'fa fa-check'; -$_style['icons_unpublish_resource'] = 'fa fa-close'; -$_style['icons_delete_resource'] = 'fa fa-trash'; -$_style['icons_undelete_resource'] = 'fa fa-undo'; -$_style['icons_resource_overview'] = 'fa fa-info'; -$_style['icons_edit_resource'] = 'fa fa-pencil-square-o'; -//context menu -$_style['icons_resource_duplicate'] = $style_path.'icons/clone.png'; -$_style['icons_edit_document'] = $style_path.'icons/save.png'; -$_style['icons_delete_document'] = $style_path.'icons/trash.png'; -//locks -$_style['icons_preview_resource'] = $style_path.'icons/eye.png';//$style_path.'icons/eye.png'; -$_style['icons_secured'] = '';//$style_path.'icons/lock.png'; - -//file manager icons -$_style['files_save'] = 'fa fa-floppy-o'; -$_style['files_folder'] = 'fa fa-folder-o'; -$_style['files_deleted_folder'] = 'fa fa-folder-o'; -$_style['files_folder-open'] = 'fa fa-folder-open-o'; -$_style['files_page_php'] = 'fa fa-file-o'; -$_style['files_page_html'] = 'fa fa-file-o'; -$_style['files_cancel'] = 'fa fa-times-circle'; -$_style['files_top'] = 'fa fa-folder-open-o'; -$_style['files_add'] = 'fa fa-plus-circle'; -$_style['files_upload'] = 'fa fa-upload'; -$_style['files_delete'] = 'fa fa-trash'; -$_style['files_duplicate'] = 'fa fa-clone'; -$_style['files_rename'] = 'fa fa-i-cursor'; -$_style['files_view'] = 'fa fa-eye'; -$_style['files_download'] = 'fa fa-download'; -$_style['files_unzip'] = 'fa fa-file-archive-o'; -$_style['files_edit'] = 'fa fa-pencil-square-o'; - -//Action buttons -$_style['actions_save'] = 'fa fa-floppy-o'; -$_style['actions_duplicate'] = 'fa fa-clone'; -$_style['actions_delete'] = 'fa fa-trash'; -$_style['actions_cancel'] = 'fa fa-times-circle'; -$_style['actions_close'] = 'fa fa-times-circle'; -$_style['actions_add'] = 'fa fa-plus-circle'; -$_style['actions_preview'] = 'fa fa-eye'; -$_style['actions_run'] = 'fa fa-play'; -$_style['actions_stop'] = 'fa fa-stop'; -$_style['actions_new'] = 'fa fa-plus-circle'; -$_style['actions_help'] = 'fa fa-question-circle'; -$_style['actions_sort'] = 'fa fa-sort'; -$_style['actions_options'] = 'fa fa-check-square'; -$_style['actions_categories'] = 'fa fa-folder-open'; -$_style['actions_search'] = 'fa fa-search'; -$_style['actions_file'] = 'fa fa-file-o'; -$_style['actions_folder'] = 'fa fa-folder-o'; -$_style['actions_folder_open'] = 'fa fa-folder-open-o'; -$_style['actions_calendar'] = 'fa fa-calendar'; -$_style['actions_calendar_delete'] = 'fa fa-calendar-times-o'; -$_style['actions_angle_up'] = 'fa fa-angle-up'; -$_style['actions_angle_down'] = 'fa fa-angle-down'; -$_style['actions_angle_left'] = 'fa fa-angle-left'; -$_style['actions_angle_right'] = 'fa fa-angle-right'; -$_style['actions_chain'] = 'fa fa-chain'; -$_style['actions_chain_broken'] = 'fa fa-chain-broken'; -$_style['actions_edit'] = 'fa fa-edit'; -$_style['actions_move'] = 'fa fa-arrows'; -$_style['actions_pencil'] = 'fa fa-pencil'; -$_style['actions_reply'] = 'fa fa-reply'; -$_style['actions_plus'] = 'fa fa-plus'; -$_style['actions_refresh'] = 'fa fa-refresh'; -$_style['actions_error'] = 'fa fa-times-circle'; -$_style['actions_info'] = 'fa fa-info-circle'; -$_style['actions_triangle'] = 'fa fa-exclamation-triangle'; -$_style['actions_table'] = 'fa fa-table'; - -//for back compatibility - -$_style['icons_save'] = $style_path.'icons/save.png'; -$_style['icons_delete'] = $style_path.'icons/trash.png'; -$_style['icons_deleted_folder'] = $style_path.'tree/deletedfolder.png'; -$_style['icons_unzip'] = $style_path.'icons/download-alt.png'; - - -// Indicators -$_style['icons_tooltip'] = 'fa fa-question-circle'; -$_style['icons_tooltip_over'] = $style_path.'icons/question-sign.png'; -$_style['icons_cal'] = $style_path.'icons/calendar.png'; -$_style['icons_cal_nodate'] = $style_path.'icons/calendar.png'; -$_style['icons_set_parent'] = $style_path.'icons/folder-open.png'; - -//modules -$_style['icons_module'] = 'fa fa-cube'; -$_style['icons_modules'] = 'fa fa-cubes'; //$style_path.'icons/modules.png'; -$_style['icons_run'] = $style_path.'icons/play.png'; - -//users and webusers -$_style['icons_user'] = 'fa fa-user-circle-o'; //$style_path.'icons/user.png'; -$_style['icons_web_user'] = 'fa fa-user'; //$style_path.'icons/user.png'; - -//Messages -$_style['icons_message_unread'] = $style_path.'icons/email.png'; -$_style['icons_message_forward'] = $style_path.'icons/forward.png'; -$_style['icons_message_reply'] = $style_path.'icons/reply.png'; - -// Icons -$_style['icons_add'] = $style_path.'icons/add.png'; -$_style['icons_cancel'] = $style_path.'icons/cancel.png'; -$_style['icons_close'] = $style_path.'icons/stop.png'; -$_style['icons_refresh'] = $style_path.'icons/refresh.png'; -$_style['icons_table'] = $style_path.'icons/table.png'; - -// top bar -$_style['icons_loading_doc_tree'] = $style_path.'icons/info-sign.png'; -$_style['icons_mail'] = $style_path.'icons/email.png'; -$_style['icons_working'] = $style_path.'icons/exclamation.png'; - -//event log -$_style['icons_event1'] = $style_path.'icons/event1.png'; -$_style['icons_event2'] = $style_path.'icons/event2.png'; -$_style['icons_event3'] = $style_path.'icons/event3.png'; - - -//nowhere in the manager -$_style['icons_folder'] = $style_path.'icons/folder.png'; -$_style['icons_email'] = $style_path.'icons/email.png'; -$_style['icons_home'] = $style_path.'icons/home.png'; -$_style['icons_sort_menuindex'] = $style_path.'icons/sort_index.png'; -$_style['icons_weblink'] = $style_path.'icons/world_link.png'; -$_style['icons_tab_preview'] = $style_path.'icons/preview.png'; // Tabs -$_style['icons_information'] = $style_path.'icons/info-sign.png'; - - -// Miscellaneous -$_style['ajax_loader'] = '

'.$_lang['loading_page'].'

'; -$_style['tx'] = $style_path.'misc/_tx_.gif'; -$_style['icons_right_arrow'] = $style_path.'icons/arrow-right.png'; -$_style['fade'] = $style_path.'misc/fade.gif'; -$_style['ed_save'] = $style_path.'misc/ed_save.gif'; - -// actions buttons templates -$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; -if (!empty($modx->config['global_tabs']) && !isset($_SESSION['stay'])) { - $_REQUEST['stay'] = 2; -} -if (isset($_REQUEST['stay'])) { - $_SESSION['stay'] = $_REQUEST['stay']; -} else if (isset($_SESSION['stay'])) { - $_REQUEST['stay'] = $_SESSION['stay']; -} -$stay = isset($_REQUEST['stay']) ? $_REQUEST['stay'] : ''; -$addnew = 0; -$run = 0; -switch($action) { - case '3': - case '4': - case '27': - case '72': - if($modx->hasPermission('new_document')) { - $addnew = 1; - } - break; - case '16': - case '19': - if($modx->hasPermission('new_template')) { - $addnew = 1; - } - break; - case '300': - case '301': - if($modx->hasPermission('new_snippet') && $modx->hasPermission('new_chunk') && $modx->hasPermission('new_plugin')) { - $addnew = 1; - } - break; - case '77': - case '78': - if($modx->hasPermission('new_chunk')) { - $addnew = 1; - } - break; - case '22': - case '23': - if($modx->hasPermission('new_snippet')) { - $addnew = 1; - } - break; - case '101': - case '102': - if($modx->hasPermission('new_plugin')) { - $addnew = 1; - } - break; - case '106': - case '107': - case '108': - if($modx->hasPermission('new_module')) { - $addnew = 1; - } - if($modx->hasPermission('exec_module')) { - $run = 1; - } - break; - case '88': - if($modx->hasPermission('new_web_user')) { - $addnew = 1; - } - break; -} - -$disabled = ($action == '19' || $action == '300' || $action == '77' || $action == '23' || $action == '101' || $action == '4' || $action == '72' || $action == '87' || $action == '11' || $action == '107' || $action == '38') ? ' disabled' : ''; - -$_style['actionbuttons'] = array( - 'dynamic' => array( - 'document' => '
-
-
- - ' . $_lang['save'] . ' - - - -
' . - ($addnew ? ' - - ' . $_lang['duplicate'] . ' - - ' : '') . ' - - ' . $_lang['delete'] . ' - - - ' . $_lang['cancel'] . ' - - - ' . $_lang['preview'] . ' - -
-
', - 'user' => '
-
-
- - ' . $_lang['save'] . ' - - - -
- - ' . $_lang['delete'] . ' - - - ' . $_lang['cancel'] . ' - -
-
', - 'element' => '
-
-
- - ' . $_lang['save'] . ' - - - -
- ' . ($addnew ? ' - - ' . $_lang['duplicate'] . ' - - ' : '') . ' - - ' . $_lang['delete'] . ' - - - ' . $_lang['cancel'] . ' - - ' . ($run ? ' - - ' . $_lang['run_module'] . ' - - ' : '') . ' -
-
', - 'newmodule' => ($addnew ? '' : ''), - 'close' => '', - 'save' => '', - 'savedelete' => '', - 'cancel' => '', - 'canceldelete' => '', - ), - 'static' => array( - 'document' => '', - 'cancel' => '', - ) -); +config['manager_theme']/style.php + * Function: Manager style variables for images and icons. + * Encoding: UTF-8 + * Credit: icons by Mark James of FamFamFam http://www.famfamfam.com/lab/icons/ + * Date: 18-Mar-2010 + * Version: 1.1 + * MODX version: 1.0.3 + */ +$style_path = 'media/style/' . $modx->config['manager_theme'] . '/images/'; +$modx->config['mgr_date_picker_path'] = 'media/calendar/datepicker.inc.php'; +if(empty($modx->config['lang_code'])) { + global $modx_lang_attribute; + $modx->config['lang_code'] = !$modx_lang_attribute ? 'en' : $modx_lang_attribute; +} + +if (isset($_GET['a']) && $_GET['a'] == 2) { + include_once('welcome.php'); +} + +// Favicon +$_style['favicon'] = (file_exists(MODX_BASE_PATH . 'favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/' . $modx->config['manager_theme'] . '/images/favicon.ico'); + +// Icons +$_style['icon_size_2x'] = ' fa-2x'; +$_style['icon_size_fix'] = ' fa-fw'; +$_style['icon_spin'] = ' fa-spin'; +$_style['icon_template'] = 'fa fa-newspaper-o'; +$_style['icon_tv'] = 'fa fa-list-alt'; +$_style['icon_chunk'] = 'fa fa-th-large'; +$_style['icon_code'] = 'fa fa-code'; +$_style['icon_plugin'] = 'fa fa-plug'; +$_style['icon_elements'] = 'fa fa-th'; +$_style['icon_edit'] = 'fa fa-edit'; +$_style['icon_circle'] = 'fa fa-circle'; +$_style['icon_refresh'] = 'fa fa-refresh'; + +//Main Menu +$_style['menu_search'] = ''; +$_style['menu_preview_site'] = ''; +$_style['menu_new_resource'] = ''; +$_style['menu_system'] = ''; +$_style['menu_user'] = ''; +// full screen +$_style['menu_expand'] = 'fa-expand'; +$_style['menu_compress'] = 'fa-compress'; +//help toggle +$_style['icons_help'] = ''; +//pages +$_style['page_settings'] = ''; +$_style['page_shedule'] = ''; +$_style['page_eventlog'] = ''; +$_style['page_manager_logs'] = ''; +$_style['page_sys_info'] = ''; +$_style['page_help'] = ''; +$_style['page_change_password'] = ''; +$_style['page_logout'] = ''; + +// Tree Menu Toolbar +$_style['add_doc_tree'] = ''; +$_style['add_weblink_tree'] = ''; +$_style['collapse_tree'] = ''; +$_style['empty_recycle_bin'] = ''; +$_style['empty_recycle_bin_empty'] = ''; +$_style['expand_tree'] = ''; +$_style['hide_tree'] = ''; +$_style['refresh_tree'] = ''; +$_style['show_tree'] = $style_path.'tree/expand.png'; +$_style['sort_tree'] = ''; +$_style['sort_menuindex'] = ''; +$_style['element_management'] = ''; +$_style['images_management'] = ''; +$_style['files_management'] = ''; +$_style['email'] = ''; + +//Tree Contextual Menu Popup +$_style['ctx_new_document'] = 'fa fa-file-o'; +$_style['ctx_edit_document'] = 'fa fa-pencil-square-o'; +$_style['ctx_move_document'] = 'fa fa-arrows'; +$_style['ctx_resource_duplicate'] = 'fa fa-clone'; +$_style['ctx_sort_menuindex'] = 'fa fa-sort-numeric-asc'; +$_style['ctx_publish_document'] = 'fa fa-check'; +$_style['ctx_unpublish_resource'] = 'fa fa-close'; +$_style['ctx_delete'] = 'fa fa-trash'; +$_style['ctx_undelete_resource'] = 'fa fa-undo'; +$_style['ctx_weblink'] = 'fa fa-link'; +$_style['ctx_resource_overview'] = 'fa fa-info'; +$_style['ctx_preview_resource'] = 'fa fa-eye'; + +// Tree Icons +$_style['tree_deletedpage'] = ""; +$_style['tree_folder'] = $style_path.'tree/folder-close-alt.png'; /* folder.png */ +$_style['tree_folderopen'] = $style_path.'tree/folder-open-alt.png'; /* folder-open.png */ +$_style['tree_globe'] = $style_path.'tree/globe.png'; +$_style['tree_folder_new'] = ""; /* folder.png */ +$_style['tree_folderopen_new'] = ""; /* folder-open.png */ +$_style['tree_folder_secure'] = ""; +$_style['tree_folderopen_secure'] = ""; +$_style['tree_linkgo'] = ""; +$_style['tree_page'] = ""; +$_style['tree_page_home'] = ""; +$_style['tree_page_404'] = ""; +$_style['tree_page_hourglass'] = ""; +$_style['tree_page_info'] = ""; +$_style['tree_page_blank'] = ""; +$_style['tree_page_css'] = ""; +$_style['tree_page_html'] = ""; +$_style['tree_page_xml'] = ""; +$_style['tree_page_js'] = ""; +$_style['tree_page_rss'] = ""; +$_style['tree_page_pdf'] = ""; +$_style['tree_page_word'] = ""; +$_style['tree_page_excel'] = ""; + +$_style['tree_minusnode'] = "";//$style_path.'tree/angle-down.png'; +$_style['tree_plusnode'] = "";//$style_path.'tree/angle-right.png'; +$_style['tree_weblink'] = $style_path.'tree/link.png'; +$_style['tree_preview_resource'] = "";//$style_path.'icons/eye.png'; + +$_style['tree_showtree'] = ''; +$_style['tree_working'] = ''; +$_style['tree_info'] = ''; + +$_style['tree_page_secure'] = ""; +$_style['tree_page_blank_secure'] = ""; +$_style['tree_page_css_secure'] = ""; +$_style['tree_page_html_secure'] = ""; +$_style['tree_page_xml_secure'] = ""; +$_style['tree_page_js_secure'] = ""; +$_style['tree_page_rss_secure'] = ""; +$_style['tree_page_pdf_secure'] = ""; +$_style['tree_page_word_secure'] = ""; +$_style['tree_page_excel_secure'] = ""; + +//search +$_style['icons_external_link'] = ''; + +//View Resource data +$_style['icons_new_document'] = 'fa fa-file-o'; +$_style['icons_new_weblink'] = 'fa fa-link'; +$_style['icons_move_document'] = 'fa fa-arrows'; +$_style['icons_publish_document'] = 'fa fa-check'; +$_style['icons_unpublish_resource'] = 'fa fa-close'; +$_style['icons_delete_resource'] = 'fa fa-trash'; +$_style['icons_undelete_resource'] = 'fa fa-undo'; +$_style['icons_resource_overview'] = 'fa fa-info'; +$_style['icons_edit_resource'] = 'fa fa-pencil-square-o'; +//context menu +$_style['icons_resource_duplicate'] = $style_path.'icons/clone.png'; +$_style['icons_edit_document'] = $style_path.'icons/save.png'; +$_style['icons_delete_document'] = $style_path.'icons/trash.png'; +//locks +$_style['icons_preview_resource'] = $style_path.'icons/eye.png';//$style_path.'icons/eye.png'; +$_style['icons_secured'] = '';//$style_path.'icons/lock.png'; + +//file manager icons +$_style['files_save'] = 'fa fa-floppy-o'; +$_style['files_folder'] = 'fa fa-folder-o'; +$_style['files_deleted_folder'] = 'fa fa-folder-o'; +$_style['files_folder-open'] = 'fa fa-folder-open-o'; +$_style['files_page_php'] = 'fa fa-file-o'; +$_style['files_page_html'] = 'fa fa-file-o'; +$_style['files_cancel'] = 'fa fa-times-circle'; +$_style['files_top'] = 'fa fa-folder-open-o'; +$_style['files_add'] = 'fa fa-plus-circle'; +$_style['files_upload'] = 'fa fa-upload'; +$_style['files_delete'] = 'fa fa-trash'; +$_style['files_duplicate'] = 'fa fa-clone'; +$_style['files_rename'] = 'fa fa-i-cursor'; +$_style['files_view'] = 'fa fa-eye'; +$_style['files_download'] = 'fa fa-download'; +$_style['files_unzip'] = 'fa fa-file-archive-o'; +$_style['files_edit'] = 'fa fa-pencil-square-o'; + +//Action buttons +$_style['actions_save'] = 'fa fa-floppy-o'; +$_style['actions_duplicate'] = 'fa fa-clone'; +$_style['actions_delete'] = 'fa fa-trash'; +$_style['actions_cancel'] = 'fa fa-times-circle'; +$_style['actions_close'] = 'fa fa-times-circle'; +$_style['actions_add'] = 'fa fa-plus-circle'; +$_style['actions_preview'] = 'fa fa-eye'; +$_style['actions_run'] = 'fa fa-play'; +$_style['actions_stop'] = 'fa fa-stop'; +$_style['actions_new'] = 'fa fa-plus-circle'; +$_style['actions_help'] = 'fa fa-question-circle'; +$_style['actions_sort'] = 'fa fa-sort'; +$_style['actions_options'] = 'fa fa-check-square'; +$_style['actions_categories'] = 'fa fa-folder-open'; +$_style['actions_search'] = 'fa fa-search'; +$_style['actions_file'] = 'fa fa-file-o'; +$_style['actions_folder'] = 'fa fa-folder-o'; +$_style['actions_folder_open'] = 'fa fa-folder-open-o'; +$_style['actions_calendar'] = 'fa fa-calendar'; +$_style['actions_calendar_delete'] = 'fa fa-calendar-times-o'; +$_style['actions_angle_up'] = 'fa fa-angle-up'; +$_style['actions_angle_down'] = 'fa fa-angle-down'; +$_style['actions_angle_left'] = 'fa fa-angle-left'; +$_style['actions_angle_right'] = 'fa fa-angle-right'; +$_style['actions_chain'] = 'fa fa-chain'; +$_style['actions_chain_broken'] = 'fa fa-chain-broken'; +$_style['actions_edit'] = 'fa fa-edit'; +$_style['actions_move'] = 'fa fa-arrows'; +$_style['actions_pencil'] = 'fa fa-pencil'; +$_style['actions_reply'] = 'fa fa-reply'; +$_style['actions_plus'] = 'fa fa-plus'; +$_style['actions_refresh'] = 'fa fa-refresh'; +$_style['actions_error'] = 'fa fa-times-circle'; +$_style['actions_info'] = 'fa fa-info-circle'; +$_style['actions_triangle'] = 'fa fa-exclamation-triangle'; +$_style['actions_table'] = 'fa fa-table'; + +//for back compatibility + +$_style['icons_save'] = $style_path.'icons/save.png'; +$_style['icons_delete'] = $style_path.'icons/trash.png'; +$_style['icons_deleted_folder'] = $style_path.'tree/deletedfolder.png'; +$_style['icons_unzip'] = $style_path.'icons/download-alt.png'; + + +// Indicators +$_style['icons_tooltip'] = 'fa fa-question-circle'; +$_style['icons_tooltip_over'] = $style_path.'icons/question-sign.png'; +$_style['icons_cal'] = $style_path.'icons/calendar.png'; +$_style['icons_cal_nodate'] = $style_path.'icons/calendar.png'; +$_style['icons_set_parent'] = $style_path.'icons/folder-open.png'; + +//modules +$_style['icons_module'] = 'fa fa-cube'; +$_style['icons_modules'] = 'fa fa-cubes'; //$style_path.'icons/modules.png'; +$_style['icons_run'] = $style_path.'icons/play.png'; + +//users and webusers +$_style['icons_user'] = 'fa fa-user-circle-o'; //$style_path.'icons/user.png'; +$_style['icons_web_user'] = 'fa fa-user'; //$style_path.'icons/user.png'; + +//Messages +$_style['icons_message_unread'] = $style_path.'icons/email.png'; +$_style['icons_message_forward'] = $style_path.'icons/forward.png'; +$_style['icons_message_reply'] = $style_path.'icons/reply.png'; + +// Icons +$_style['icons_add'] = $style_path.'icons/add.png'; +$_style['icons_cancel'] = $style_path.'icons/cancel.png'; +$_style['icons_close'] = $style_path.'icons/stop.png'; +$_style['icons_refresh'] = $style_path.'icons/refresh.png'; +$_style['icons_table'] = $style_path.'icons/table.png'; + +// top bar +$_style['icons_loading_doc_tree'] = $style_path.'icons/info-sign.png'; +$_style['icons_mail'] = $style_path.'icons/email.png'; +$_style['icons_working'] = $style_path.'icons/exclamation.png'; + +//event log +$_style['icons_event1'] = $style_path.'icons/event1.png'; +$_style['icons_event2'] = $style_path.'icons/event2.png'; +$_style['icons_event3'] = $style_path.'icons/event3.png'; + + +//nowhere in the manager +$_style['icons_folder'] = $style_path.'icons/folder.png'; +$_style['icons_email'] = $style_path.'icons/email.png'; +$_style['icons_home'] = $style_path.'icons/home.png'; +$_style['icons_sort_menuindex'] = $style_path.'icons/sort_index.png'; +$_style['icons_weblink'] = $style_path.'icons/world_link.png'; +$_style['icons_tab_preview'] = $style_path.'icons/preview.png'; // Tabs +$_style['icons_information'] = $style_path.'icons/info-sign.png'; + + +// Miscellaneous +$_style['ajax_loader'] = '

'.$_lang['loading_page'].'

'; +$_style['tx'] = $style_path.'misc/_tx_.gif'; +$_style['icons_right_arrow'] = $style_path.'icons/arrow-right.png'; +$_style['fade'] = $style_path.'misc/fade.gif'; +$_style['ed_save'] = $style_path.'misc/ed_save.gif'; + +// actions buttons templates +$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : ''; +if (!empty($modx->config['global_tabs']) && !isset($_SESSION['stay'])) { + $_REQUEST['stay'] = 2; +} +if (isset($_REQUEST['stay'])) { + $_SESSION['stay'] = $_REQUEST['stay']; +} else if (isset($_SESSION['stay'])) { + $_REQUEST['stay'] = $_SESSION['stay']; +} +$stay = isset($_REQUEST['stay']) ? $_REQUEST['stay'] : ''; +$addnew = 0; +$run = 0; +switch ($action) { + case '3': + case '4': + case '27': + case '72': + if ($modx->hasPermission('new_document')) { + $addnew = 1; + } + break; + case '16': + case '19': + if ($modx->hasPermission('new_template')) { + $addnew = 1; + } + break; + case '300': + case '301': + if ($modx->hasPermission('new_snippet') && $modx->hasPermission('new_chunk') && $modx->hasPermission('new_plugin')) { + $addnew = 1; + } + break; + case '77': + case '78': + if ($modx->hasPermission('new_chunk')) { + $addnew = 1; + } + break; + case '22': + case '23': + if ($modx->hasPermission('new_snippet')) { + $addnew = 1; + } + break; + case '101': + case '102': + if ($modx->hasPermission('new_plugin')) { + $addnew = 1; + } + break; + case '106': + case '107': + case '108': + if ($modx->hasPermission('new_module')) { + $addnew = 1; + } + if ($modx->hasPermission('exec_module')) { + $run = 1; + } + break; + case '88': + if ($modx->hasPermission('new_web_user')) { + $addnew = 1; + } + break; +} + +$disabled = ($action == '19' || $action == '300' || $action == '77' || $action == '23' || $action == '101' || $action == '4' || $action == '72' || $action == '87' || $action == '11' || $action == '107' || $action == '38') ? ' disabled' : ''; + +$_style['actionbuttons'] = array( + 'dynamic' => array( + 'document' => '
+
+
+ + ' . $_lang['save'] . ' + + + +
' . + ($addnew ? ' + + ' . $_lang['duplicate'] . ' + + ' : '') . ' + + ' . $_lang['delete'] . ' + + + ' . $_lang['cancel'] . ' + + + ' . $_lang['preview'] . ' + +
+
', + 'user' => '
+
+
+ + ' . $_lang['save'] . ' + + + +
+ + ' . $_lang['delete'] . ' + + + ' . $_lang['cancel'] . ' + +
+
', + 'element' => '
+
+
+ + ' . $_lang['save'] . ' + + + +
+ ' . ($addnew ? ' + + ' . $_lang['duplicate'] . ' + + ' : '') . ' + + ' . $_lang['delete'] . ' + + + ' . $_lang['cancel'] . ' + + ' . ($run ? ' + + ' . $_lang['run_module'] . ' + + ' : '') . ' +
+
', + 'newmodule' => ($addnew ? '' : ''), + 'close' => '', + 'save' => '', + 'savedelete' => '', + 'cancel' => '', + 'canceldelete' => '', + ), + 'static' => array( + 'document' => '', + 'cancel' => '', + ) +); From 130eee27dccd5fe4ae16d2ed96b043ca4e83b934 Mon Sep 17 00:00:00 2001 From: Serg <64j@mail.ru> Date: Wed, 25 May 2022 19:57:45 +0300 Subject: [PATCH 049/168] [1.4x] Fix modx.js --- manager/media/style/default/js/modx.js | 93 +++++++++++--------------- 1 file changed, 40 insertions(+), 53 deletions(-) diff --git a/manager/media/style/default/js/modx.js b/manager/media/style/default/js/modx.js index 1a6a1e276f..ca7d60a55b 100755 --- a/manager/media/style/default/js/modx.js +++ b/manager/media/style/default/js/modx.js @@ -47,44 +47,48 @@ mainmenu: { id: 'mainMenu', init: function() { - //console.log('modx.mainMenu.init()'); var mm = d.getElementById('mainMenu'), timer; - mm.delegateEventListener('click', 'a', function(e) { - if (this.classList.contains('dropdown-toggle')) { - if (mm.classList.contains('show') && (this.classList.contains('selected') || !modx.isMobile && this.parentElement.classList.contains('hover'))) { - this.classList.remove('selected'); + mm.addEventListener('click', function(e) { + var a = e.target.closest('a'); + if (!a) { + return; + } + if (a.classList.contains('dropdown-toggle')) { + if (mm.classList.contains('show') && (a.classList.contains('selected') || !modx.isMobile && a.parentElement.classList.contains('hover'))) { + a.classList.remove('selected'); mm.classList.remove('show'); } else { mm.querySelectorAll('.nav > li > a:not(:hover)').forEach(function(el) { el.classList.remove('selected'); }); - this.classList.add('selected'); + a.classList.add('selected'); mm.classList.add('show'); } e.stopPropagation(); e.target.dataset.toggle = '#mainMenu'; modx.hideDropDown(e); } - if (this.closest('ul').classList.contains('dropdown-menu') && !this.closest('li').classList.contains('dropdown-back')) { + if (a.closest('ul').classList.contains('dropdown-menu') && !a.closest('li').classList.contains('dropdown-back')) { mm.querySelectorAll('.nav > .active').forEach(function(el) { el.classList.remove('active'); }); mm.querySelectorAll('.nav li.selected').forEach(function(el) { el.classList.remove('selected'); }); - this.closest('.nav > li').classList.add('active'); - if (this.offsetParent.id) { - d.getElementById(this.offsetParent.id.substr(7)).classList.add('selected'); + a.closest('.nav > li').classList.add('active'); + if (a.offsetParent.id) { + d.getElementById(a.offsetParent.id.substr(7)).classList.add('selected'); } - if ((modx.isMobile || w.innerWidth < modx.minWidth) && this.classList.contains('toggle')) { - this.parentNode.classList.add('selected'); + if ((modx.isMobile || w.innerWidth < modx.minWidth) && e.target.classList.contains('toggle')) { + a.parentNode.classList.add('selected'); e.stopPropagation(); e.preventDefault(); } } }); - mm.delegateEventListener('click', '.nav li', function() { - if ((modx.isMobile || w.innerWidth < modx.minWidth)) { + mm.addEventListener('click', function(e) { + let li = e.target.closest('.nav li'); + if (li && modx.isMobile) { mm.querySelectorAll('.nav ul.selected').forEach(function(el) { el.classList.remove('selected'); }); @@ -174,7 +178,7 @@ } ul.classList.add('show'); if (modx.isMobile) { - if (e.target.classList.contains('toggle')) { + if (e.target.classList.contains('dropdown-toggle')) { self.parentNode.classList.add('selected'); } } else { @@ -585,6 +589,9 @@ } }, false); w.addEventListener('touchmove', function(e) { + if (d.getElementById('mainMenu').classList.contains('show')) { + return; + } var touch = e.changedTouches[0]; tree.style.transition = 'none'; tree.style.WebkitTransition = 'none'; @@ -916,7 +923,7 @@ parent: parent, menuindex: menuindex }, function(r) { - if (r && r.errors) alert(r.errors); + if (r && r.errors) modx.alert(r.errors); modx.tree.restoreTree(); }, 'json'); var b = modx.normalizeUrl(w.main.frameElement.contentWindow.location.href); @@ -1290,7 +1297,7 @@ modx.tabs({url: modx.MODX_MANAGER_URL + '?a=62&id=' + this.itemToChange, title: this.selectedObjectName + '(' + this.itemToChange + ')'}); } } else { - alert('Document is linked to site_start variable and cannot be unpublished!'); + modx.alert('Document is linked to site_start variable and cannot be unpublished!'); } break; case 11: @@ -1300,7 +1307,7 @@ w.open(d.getElementById('node' + this.itemToChange).firstChild.dataset.href, 'previeWin'); break; default: - alert('Unknown operation command.'); + modx.alert('Unknown operation command.'); } }, setSelected: function(a) { @@ -1562,13 +1569,15 @@ this.show(); if (~this.closeactions.indexOf(this.action)) { this.setDocPublished(); - modx.get(this.url, function() { + modx.get(this.url, function(r) { + /__alertQuit\(\)/.test(r) && modx.alert(r.match(/\(.*?)\<\/body\>/s)[0]); modx.tree.restoreTree(); }); } } } else if (~this.closeactions.indexOf(this.action)) { - modx.get(this.url, function() { + modx.get(this.url, function(r) { + /__alertQuit\(\)/.test(r) && modx.alert(r.match(/\(.*?)\<\/body\>/s)[0]); modx.tree.restoreTree(); }); } else { @@ -1635,13 +1644,7 @@ w.onpopstate = function() { history.go(1); }; - modx.popup({ - type: 'warning', - title: 'Evolution CMS :: Alert', - position: 'top center alertQuit', - content: message, - wrap: 'body' - }); + modx.alert(message); modx.getLockedElements(modx.getActionFromUrl(this.url), modx.main.getQueryVariable('id', this.url), function(data) { if (!!data || ~s.closeactions.indexOf(modx.getActionFromUrl(s.url))) { s.page.close(); @@ -2027,12 +2030,7 @@ o.uid = modx.urlToUid(a.url); o.event = e; if (!!e.target.contentWindow.__alertQuit) { - modx.popup({ - type: 'warning', - title: 'Evolution CMS :: Alert', - position: 'top center alertQuit', - content: e.target.contentWindow.document.body.querySelector('p').innerHTML - }); + modx.alert(e.target.contentWindow.document.body.querySelector('p').innerHTML); e.target.contentWindow.document.body.innerHTML = ''; e.target.contentWindow.alert = function() {}; } else { @@ -2093,6 +2091,15 @@ return o; } }, + alert: function(m, t) { + modx.popup({ + type: t || 'warning', + title: 'Evolution CMS :: Alert', + position: 'top center alertQuit', + content: m, + wrap: 'body' + }); + }, getWindowDimension: function() { var a = 0, b = 0, @@ -2618,23 +2625,3 @@ }; } })(); - -!function(o, e) { - var n = window.Element.prototype, - i = n.matches; - i || ['webkit', 'ms', 'moz'].some(function(e) { - var t = e + 'MatchesSelector'; - if (n.hasOwnProperty(t)) return i = n[t], !0; - }), e.prototype.delegateEventListener = function(e, n, r) { - this.addEventListener(e, function(e) { - var t = function(e, t, n) { - for (var r = e.target; ;) { - if (i.call(r, t)) return r; - if (r === n || r === o.body) return !1; - r = r.parentNode; - } - }(e, n, e.currentTarget); - t && r.call(t, e); - }); - }; -}(window.document, window.EventTarget || window.Element); From 38180dad41a1142625342e5c6b4c56134b3b6d41 Mon Sep 17 00:00:00 2001 From: Serg <64j@mail.ru> Date: Mon, 6 Jun 2022 21:58:45 +0300 Subject: [PATCH 050/168] [1.4x] Fix global tabs --- manager/frames/1.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/manager/frames/1.php b/manager/frames/1.php index 93f549d3da..da3ce46b93 100755 --- a/manager/frames/1.php +++ b/manager/frames/1.php @@ -108,7 +108,14 @@ } } -$modx->config['global_tabs'] = (int)($modx->config['global_tabs'] && ($user['role'] == 1 || $modx->hasPermission('edit_template') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('edit_plugin'))); +$modx->config['global_tabs'] = (int) ($modx->config['global_tabs'] && ($user['role'] == 1 + || $modx->hasPermission('edit_template') + || $modx->hasPermission('edit_chunk') + || $modx->hasPermission('edit_snippet') + || $modx->hasPermission('edit_plugin') + || $modx->hasPermission('edit_document') + ) +); ?> From f2d796569ed69e80803c23dbcca426bc37dec2ed Mon Sep 17 00:00:00 2001 From: BBloke Date: Mon, 6 Jun 2022 21:31:54 +0100 Subject: [PATCH 051/168] Update mutate_tmplvars.dynamic.php Fix php-8.0 warnings when creating and editing template variables --- manager/actions/mutate_tmplvars.dynamic.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manager/actions/mutate_tmplvars.dynamic.php b/manager/actions/mutate_tmplvars.dynamic.php index 459ca8c2d6..c71b445a1e 100755 --- a/manager/actions/mutate_tmplvars.dynamic.php +++ b/manager/actions/mutate_tmplvars.dynamic.php @@ -44,7 +44,7 @@ $content['name'] = $_REQUEST['itemname']; } else { $_SESSION['itemname'] = $_lang["new_tmplvars"]; - $content['category'] = (int)$_REQUEST['catid']; + if (!empty($_REQUEST['catid'])) $content['category'] = (int)$_REQUEST['catid']; } if($modx->manager->hasFormValues()) { @@ -291,7 +291,7 @@ function decode(s) {

- (' . $content['id'] . ')' : $_lang['new_tmplvars']) ?> + (' . $content['id'] . ')' : $_lang['new_tmplvars'] ?>

@@ -313,7 +313,7 @@ function decode(s) {
- + " class="form-control form-control-lg" onchange="documentDirty=true;" /> hasPermission('save_role')): ?>