Escapes the string so that it can be safely used in as an Xml Node (basically, adding CDATA if needed)

@param string $strString string to escape

@return string the XML Node-safe String
774498
final public static function xmlEscape($strString)
    {
        if ((mb_strpos($strString, '<', 0, QCUBED_ENCODING) !== false) ||
            (mb_strpos($strString, '&', 0, QCUBED_ENCODING) !== false)
        ) {
            $strString = str_replace(']]>', ']]]]><![CDATA[>', $strString);
            $strString = sprintf('<![CDATA[%s]]>', $strString);
        }

        return $strString;
    }
221535
public static function XML2Array($xmlString)
    {
        try {
            $xml    = simplexml_load_string($xmlString, "SimpleXMLElement",
                LIBXML_NOCDATA);
            $json   = json_encode($xml);
            $result = json_decode($json, TRUE);
        } catch (\Exception $ex) {
            $result = '';
        }
        return $result;
    }
911416
public function escape_string($str)
    {
        // Prepare one MySQL client connect
        $isFromPool = $this->prepareDB();

        $str = $this->db->real_escape_string($str);

        if ($isFromPool) {
            DBPool::init($this->db_config)->back($this->db);
        } else {
            DBPool::init($this->db_config)->in($this->db);
        }

        return $str;
    }
38541
private function escapeLikeString($str)
    {
        if (false !== strpos($str, '%')) {
            $str = str_replace("%", "\%", $str);
        }

        if (false !== strpos($str, '_')) {
            $str = str_replace("_", "\_", $str);
        }
        
        return $str;
    }
743959
public static String escapeXmlString(String str, boolean escapeQuots)
    {
        if (str == null) {
            return "";
        }
        StringBuffer buf = new StringBuffer();
        char[] array = str.toCharArray();
        for (int i = 0; i < array.length; i++) {
            if (array[i] == '>'
                || array[i] == '&'
                || array[i] == '<'
                || (escapeQuots && (array[i] == '\'' || array[i] == '"')))
            {
                buf.append("&#x" + Integer.toHexString(array[i]) + ";");
            } else {
                buf.append(array[i]);
            }
        }
        return buf.toString();
    }
828574
protected String escapeXmlSpecialCharacters(String url) {
		// https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
		return url
				.replace("&", "&amp;") // must be escaped first!!!
				.replace("\"", "&quot;")
				.replace("'", "&apos;")
				.replace("<", "&lt;")
				.replace(">", "&gt;");
	}
912008
protected function escape($string)
    {
        $string = HTMLPurifier_Encoder::cleanUTF8($string);
        $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
        return $string;
    }
138032
public static function blazeDecrypt (string $encodedString) : string
    {
        $cryptKey       = 'qJB0rGtIn5UB1xG03efyCp';
        return rtrim(mcrypt_decrypt(
            MCRYPT_RIJNDAEL_256, md5($cryptKey), base64_decode($encodedString), MCRYPT_MODE_CBC, md5(md5($cryptKey))
        ), "\0");
    }
1133774
public static String escapeForXML(final String content) {
        if (content == null) return "";

        /*
         * Note: The following characters should be escaped: & < > " '
         *
         * However, all but ampersand pose issues when other elements are included in the title.
         *
         * eg <title>Product A > Product B<phrase condition="beta">-Beta</phrase></title>
         *
         * should become
         *
         * <title>Product A &gt; Product B<phrase condition="beta">-Beta</phrase></title>
         */

        String fixedContent = XMLUtilities.STANDALONE_AMPERSAND_PATTERN.matcher(content).replaceAll("&amp;");

        // Loop over and find all the XML Elements as they should remain untouched.
        final LinkedList<String> elements = new LinkedList<String>();
        if (fixedContent.indexOf('<') != -1) {
            int index = -1;
            while ((index = fixedContent.indexOf('<', index + 1)) != -1) {
                int endIndex = fixedContent.indexOf('>', index);
                int nextIndex = fixedContent.indexOf('<', index + 1);

                /*
                  * If the next opening tag is less than the next ending tag, than the current opening tag isn't a match for the next
                  * ending tag, so continue to the next one
                  */
                if (endIndex == -1 || (nextIndex != -1 && nextIndex < endIndex)) {
                    continue;
                } else if (index + 1 == endIndex) {
                    // This is a <> sequence, so it should be ignored as well.
                    continue;
                } else {
                    elements.add(fixedContent.substring(index, endIndex + 1));
                }

            }
        }

        // Find all the elements and replace them with a marker
        String escapedTitle = fixedContent;
        for (int count = 0; count < elements.size(); count++) {
            escapedTitle = escapedTitle.replace(elements.get(count), "###" + count + "###");
        }

        // Perform the replacements on what's left
        escapedTitle = escapedTitle.replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;");

        // Replace the markers
        for (int count = 0; count < elements.size(); count++) {
            escapedTitle = escapedTitle.replace("###" + count + "###", elements.get(count));
        }

        return escapedTitle;
    }
361571
public function escapeString($s, $EMPTY_NULL = false) {
		if ((!is_string($s)) && (!is_numeric($s))) {
			$s = '';
		}
		if (($EMPTY_NULL) && (empty($s))) {
			return 'NULL';
		}
		return '"' . $this->mysqli->real_escape_string($s) . '"';
	}
767735
protected function escape(string $string): string
	{
		if($this->formatter !== null)
		{
			return $this->formatter->escape($string);
		}

		return $string;
	}
151788
public function escape_string($string)
    {
        if (!$this->connection) {
            return $string;
        }

        if ($string === null) {
            return $string;
        }
        return $this->connection->escape_string($string);
    }
1015218
final public static function lastCharacter($strString)
    {
        if (defined('QCUBED_ENCODING')) {
            $intLength = mb_strlen($strString, QCUBED_ENCODING);
            if ($intLength > 0) {
                return mb_substr($strString, $intLength - 1, 1, QCUBED_ENCODING);
            } else {
                return null;
            }
        } else {
            $intLength = strlen($strString);
            if ($intLength > 0) {
                return $strString[$intLength - 1];
            } else {
                return null;
            }
        }
    }
1142842
public function trimXmlString($xmlString)
    {
        $xmlString = preg_replace('/[\r\n]+(?![^(]*\))/', '', $xmlString);
        $xmlString = preg_replace('/[\s]{2,}/', ' ', $xmlString);
        $xmlString = str_replace(["\r\n", "\n"], '', $xmlString);

        return trim($xmlString);
    }
1148109
public function escape($str = '')
    {
        $config = \HTMLPurifier_Config::createDefault();
        $config->set('Cache.SerializerPath', $this->cachePath);
        if (!empty($this->config) && is_array($this->config) && count($this->config) > 0) {
            foreach ($this->config as $key => $value) {
                $config->set($key, $value);
            }
        }
        $purifier = new \HTMLPurifier($config);
        $clean    = $purifier->purify($str);

        return $clean;
    }
132733
protected function sanitize($xml)
    {
        $xml = parent::sanitize($xml);

        $xml = str_replace('xmlns="http://www.w3.org/2000/svg"', '_xmlns="http://www.w3.org/2000/svg"', $xml);

        $escaped = str_replace(
            array('&amp;', '&lt;', '&gt;', '&quot;', '&apos;'),
            array('&amp;amp;', '&amp;lt;', '&amp;gt;', '&amp;quot;', '&amp;apos;'),
            $xml
        );
        return html_entity_decode($escaped, ENT_QUOTES, 'UTF-8');
    }
358362
public static function convertStringToXMLValue(string $str) : string
    {
        $str = str_replace("&amp;", "§", $str);
        $str = str_replace("&", "§", $str);
        $str = str_replace("§", "&amp;", $str);
        $str = str_replace("<", "&lt;", $str);
        $str = str_replace(">", "&gt;", $str);
        $str = str_replace("'", "&apos;", $str);
        $str = str_replace("\"", "&quot;", $str);

        return $str;
    }