Tries to parse $content as a KeePass XML key file.
@param $content A key file content.
@return true in case of success, false otherwise.
354357
private function tryParseXML($content)
	{
		$xml = new ProtectedXMLReader(null);
		if(!$xml->XML($content) || !$xml->read(-1))
			return false;
		if($xml->isElement(self::XML_ROOT))
		{
			$d = $xml->depth();
			while($xml->read($d))
			{
				if($xml->isElement(self::XML_KEY))
				{
					$keyD = $xml->depth();
					while($xml->read($keyD))
					{
						if($xml->isElement(self::XML_DATA))
						{
							$value = $xml->readTextInside();
							$this->hash = base64_decode($value);
							$xml->close();
							return true;
						}
					}
				}
			}
		}
		$xml->close();
		return false;
	}
203370
protected function writeConfigFile($content)
    {
        if (!is_writable('config/autoload')) {
            return false;
        }

        $file = 'config/autoload/yawik.config.global.php';
        // need to chmod 777 to be usable by docker and local environment
        @touch($file);
        @chmod($file, 0777);
        return (bool) @file_put_contents($file, $content, LOCK_EX);
    }
148459
public function setContent($content)
    {
        if (!is_null($content)) {
            $content = (string) $content;
        }

        $this->content = $content;
        return $this;
    }
1262175
public function parse(&$content)
	{
	    $str = $this->getEngineInstance()->parse($content);
	    return $this->getBeginContent() . $str;
	}
1084928
public function getSig($content) {
        if(!$this->privateKey || !$content) {
            return false;
        }
        $privateKey = openssl_pkey_get_private($this->privateKey, '');
        $encryptedData = '';
        // 私钥加密
        openssl_sign($content, $encryptedData, $privateKey, OPENSSL_ALGO_SHA1);
        return base64_encode($encryptedData);
    }
1161445
public static function parse($content, Document $document = null, &$offset = 0)
    {
        if (preg_match('/^\s*\<(?P<name>[A-F0-9]+)\>/is', $content, $match)) {
            $name    = $match['name'];
            $offset += strpos($content, '<' . $name) + strlen($name) + 2; // 1 for '>'
            // repackage string as standard
            $name    = '(' . self::decode($name, $document) . ')';
            $element = false;

            if (!($element = ElementDate::parse($name, $document))) {
                $element = ElementString::parse($name, $document);
            }

            return $element;
        }

        return false;
    }
622119
private function parse($content)
    {
        $buffer = '';
        $idx = &$this->idx;
        $idx = 0;

        $balise = $textarea = $select = $option = false;

        for (; $this->offset<strlen($content); $this->offset++) {
            $char = $content[$this->offset];

            if ($char == "\n") {
                $this->currentLine++;
            }

            if (!isset($this->data[$idx])) {
                $this->data[] = '';
            }

            if (!$balise) {
                if ($char == '<') {
                    $balise = true;
                    $buffer = '';
                } else {
                    if ($textarea || $option) {
                        $this->data[$idx-1]->addValue($char);
                    } else if (!$select) {
                        $this->data[$idx] .= $char;
                    }
                }
            } else {
                if ($char == '>') {
                    $balise = false;
                    $newNode = $this->parseTag($buffer);
                    if (!is_object($newNode)) {
                        switch ($newNode) {
                        case '</textarea>':
                            $textarea = false;
                            break;
                        case '</select>':
                            $select = false;
                            break;
                        case '</option>':
                            $option = false;
                            break;
                        case '</multiple>':
                            return;
                            break;
                        case '</form>':
                            if (!isset($this->fields[PostIndicator::$fieldName])) {
                                $name = '';
                                if ($this->head && $this->head->has('name')) {
                                    $name .= $this->head->get('name');
                                }

                                $this->push(new PostIndicator($name));
                            } 

                            $this->push('</form>');
                            break;
                        default:
                            $this->data[$idx] .= $newNode;
                        }

                        if ($textarea) {
                            $this->data[$idx-1]->addValue($newNode);
                        }
                    } else {
                        $this->needJs = $this->needJs || $newNode->needJs();
                        if ($newNode instanceof Fields\Options) {
                            if (!$this->data[$idx-1] instanceof Fields\Select) {
                                throw new ParserException('<option> should always be in a <select>');
                            }
                            $this->sources[$newNode->getSource()] = $newNode;
                            $newNode->setParent($this->data[$idx-1]);
                        } else {
                            if ($newNode instanceof Fields\Option) {
                                $option = true;

                                if (!$this->data[$idx-1] instanceof Fields\Select) {
                                    throw new ParserException('<option> should always be in a <select>');
                                } else {
                                    $this->data[$idx-1]->addOption($newNode);
                                }
                            } else if ($newNode instanceof Fields\RadioField) {
                                $this->push($newNode);

                                if (!isset($this->fields[$newNode->getName()])) {
                                    $this->fields[$newNode->getName()] = $this->factory->getObject('radios');
                                    $this->fields[$newNode->getName()]->setName($newNode->getName());
                                }
                                $this->fields[$newNode->getName()]->addRadio($newNode);
                            } else {
                                $this->push($newNode);

                                if ($newNode instanceof Fields\Multiple) {
                                    $parser = $this->factory->getParser($content, $this->offset+1);
                                    $newNode->setParserData($parser);
                                    $this->offset = $parser->getOffset();
                                }

                                if ($newNode instanceof Head) {
                                    $this->head = $newNode;
                                } else {
                                    if ($newNode->getIndex() === array()) {
                                        $name = $newNode->getBaseName();

                                        if (!isset($this->fields[$name])) {
                                            $this->fields[$name] = new Fields\Group;
                                            $this->fields[$name]->setName($name);
                                        }

                                        $this->fields[$name]->addChild($newNode);
                                    } else {
                                        $this->fields[$newNode->getName()] = $newNode;
                                    }
                                }

                                if ($newNode instanceof Fields\FileField && $this->head) {
                                    $this->head->set('enctype', 'multipart/form-data');
                                }

                                if ($newNode instanceof Fields\Textarea) {
                                    $textarea = true;
                                }

                                if ($newNode instanceof Fields\Select) {
                                    $select = true;
                                }

                                if ($newNode->getSource()) {
                                    $this->sources[$newNode->getSource()] = $newNode;
                                }
                            }
                        }
                    }
                } else {
                    $buffer .= $char;
                }
            }
        }

        if (null === $this->getHead()) {
            throw new ParserException('The Formidable form should have a <form> tag');
        }

        $this->findPlaceholders();
    }
1170729
public function save($file, $content)
    {
        $dir = dirname($file);

        if (!is_dir($dir)) {
            mkdir($dir, 0777);
        }

        if (file_put_contents($file, $content)) {
            chmod($file, 0777);

            return true;
        } else {
            $message = "Cannot open cache file for writing: ";
            //			if (!Nip_Staging::instance()->isPublic()) {
            //				$message .= " [ ".$this->cache_file." ] ";
            //			}
            die($message);
        }
    }
873580
public function prepareContent($content)
    {
        if (is_array($content)) {
            $ctt = '';
            foreach ($content as $key=>$ctt_entry) {
                $ctt .= $ctt_entry;
            }
            $content = $ctt;
        }
        return (string) $content;
    }
462259
public function parse(&$content)
    {
        // 内容为空不解析
        if (empty($content)) {
            return;
        }

        // 替换literal标签内容
        $this->parseLiteral($content);

        // 解析继承
        $this->parseExtend($content);

        // 解析布局
        $this->parseLayout($content);

        // 检查include语法
        $this->parseInclude($content);

        // 替换包含文件中literal标签内容
        $this->parseLiteral($content);

        // 检查PHP语法
        $this->parsePhp($content);

        // 获取需要引入的标签库列表
        // 标签库只需要定义一次，允许引入多个一次
        // 一般放在文件的最前面
        // 格式：<taglib name="html,mytag..." />
        // 当TAGLIB_LOAD配置为true时才会进行检测
        if ($this->config['taglib_load']) {
            $tagLibs = $this->getIncludeTagLib($content);

            if (!empty($tagLibs)) {
                // 对导入的TagLib进行解析
                foreach ($tagLibs as $tagLibName) {
                    $this->parseTagLib($tagLibName, $content);
                }
            }
        }

        // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀
        if ($this->config['taglib_pre_load']) {
            $tagLibs = explode(',', $this->config['taglib_pre_load']);

            foreach ($tagLibs as $tag) {
                $this->parseTagLib($tag, $content);
            }
        }

        // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀
        $tagLibs = explode(',', $this->config['taglib_build_in']);

        foreach ($tagLibs as $tag) {
            $this->parseTagLib($tag, $content, true);
        }

        // 解析普通模板标签 {$tagName}
        $this->parseTag($content);

        // 还原被替换的Literal标签
        $this->parseLiteral($content, true);

        return;
    }
148396
private function isSelectable(Content $content): bool
    {
        if (!$this->config->hasParameter('allowed_content_types')) {
            return true;
        }

        if ($this->allowedContentTypeIds === null) {
            $this->allowedContentTypeIds = [];

            $allowedContentTypes = $this->config->getParameter('allowed_content_types');
            if (is_string($allowedContentTypes) && $allowedContentTypes !== '') {
                $allowedContentTypes = array_map('trim', explode(',', $allowedContentTypes));
                $this->allowedContentTypeIds = $this->getContentTypeIds($allowedContentTypes);
            }
        }

        if (count($this->allowedContentTypeIds) === 0) {
            return true;
        }

        return in_array($content->contentInfo->contentTypeId, $this->allowedContentTypeIds, true);
    }
286584
protected function createDOM($content)
    {
        if (!$content) {
            return false;
        }
        $dom = new DOMDocument();
        $dom->loadHTML($content);
        $dom->preserveWhiteSpace = false;

        return $dom;
    }
1190024
private function fixContentEncoding($content)
    {
        if (!empty($content)) {
            // Little hack to force UTF-8
            if (false === strpos($content, '<?xml encoding')) {
                $hack = false === strpos(
                    $content,
                    '<body'
                ) ? '<?xml encoding="UTF-8"><body>' : '<?xml encoding="UTF-8">';
                $content = $hack.$content;
            }

            $encoding = mb_detect_encoding($content);
            $headPos = mb_strpos($content, '<head>');

            // Add a meta to the <head> section
            if (false !== $headPos) {
                $headPos += 6;
                $content = mb_substr($content, 0, $headPos).
                    '<meta http-equiv="Content-Type" content="text/html; charset='.$encoding.'">'.
                    mb_substr($content, $headPos);
            }

            $content = mb_convert_encoding($content, 'HTML-ENTITIES', $encoding);
        }

        return $content;
    }
278295
public function parseContent($content) {
        $dc = json_decode($content, true);

        $ret = [];

        foreach ($dc as $key => $content) {
            preg_match("/^(?P<type>[a-z0-9A-Z]*):(?P<path>(?P<id>[a-z0-9A-Z]*):(?P<field>[a-z0-9A-Z]*))$/", $key, $matches);

            $ret[] = [
                'type' => $matches['type'],
                'path' => $matches['path'],
                'id' => $matches['id'],
                'field' => $matches['field'],
                'content' => $content
            ];
        }

        return $ret;
    }
145395
private function isContentTypeExcluded(Content $content)
    {
        $contentType = $this->repository->sudo(function () use ($content) {
            $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);

            return $contentType;
        });

        return !in_array($contentType->identifier, $this->options['included-content-types']);
    }
1362777
private static function successContent($content)
    {
        header('HTTP/1.1 200 OK');
        header('Content-Type: ' . self::$CONTENT_TYPE);
        header('Content-Length: ' . strlen($content));
        echo $content;
        exit();
    }
1185812
public function parse($content)
    {
        $map = [];

        if (preg_match(self::CONFIGURATION_PATTERN, $content, $matches)) {
            if (preg_match(self::DATABASE_PATTERN, $matches[1], $database)) {
                $map[self::DATABASE_INDEX] = $database[1];
            }
            if (preg_match(self::COLLECTION_PATTERN, $matches[1], $collection)) {
                $map[self::COLLECTION_INDEX] = $collection[1];
            }
        }

        return $map;
    }