@param $text
@param $cfg

@return bool
14615
public function valid($text, $cfg, $name = "")
    {
        $this->text = $text;
        $cfg = explode("|", $cfg);
        foreach ($cfg as $val) {
            $this->checkValid($val);
        }
        if ($this->text == $text) {
            return true;
        } else {
            $this->error['char'][$name] = "Недопустимые символы";

            return false;
        }
    }
312903
public function get_delete(array $cfg): string
  {
    $res = '';
    if ( count($cfg['tables']) === 1 ){
      $res = 'DELETE '.( $cfg['ignore'] ? 'IGNORE ' : '' ).
        'FROM '.$this->table_full_name(current($cfg['tables']), true).PHP_EOL;
    }
    return $res;
  }
542611
protected function frame($text)
    {
        $line   = '+'.str_repeat('-', strlen($text) + 4).'+';
        $this->info($line);
        $this->info("|  $text  |");
        $this->info($line);
    }
243859
private function _checkAliases($text) {
		if ($this->_isActive('checkAliases')) {
			$key = strtolower($text);
			if (array_key_exists($key, $this->_aliasedFunctions)) {
				$msg = $this->_getMessage('ALIASED_FUNCTION', $this->_aliasedFunctions[$key]['old'], $this->_aliasedFunctions[$key]['new']);
				$this->_writeError('checkAliases', $msg);
			}
		}
	}
725094
protected function parseUnicode($text)
	{
		if (strpos($text, "\xE2") === false && strpos($text, "\xEF") === false && strpos($text, "\xF0") === false)
		{
			return;
		}
		preg_match_all($this->unicodeRegexp, $text, $matches, PREG_OFFSET_CAPTURE);
		foreach ($matches[0] as list($emoji, $tagPos))
		{
			$this->addTag($tagPos, strlen($emoji), $this->getHexSequence($emoji));
		}
	}
687268
public function filter($text, $config = array())
    {
        $context = $this->_chain->getContext();
        $context->data = $text;
        $context->config = $config;
        if ($context->config->filter) {
            $filter = (array) AnConfig::unbox($context->config->filter);
            $filter[] = 'ptag';
            $context->config->filter = $filter;
        }
        $this->_chain->run('filter', $context);

        return $context->data;
    }
420459
public function parse($text, $context = null)
    {
        $parser = $this->getParser($context);

        $this->events->dispatch(new Parsing($parser, $context, $text));

        return $parser->parse($text);
    }
1030028
public static function preg($text, $preg)
	{
	    if (!$preg) {
	        throw new \InvalidArgumentException('Please set the $preg pattern');
	    }

	    if (is_array($preg)) {
	        if (empty($preg['preg'])) {
	            throw new \InvalidArgumentException('The $preg argument must have "preg" key');
	        }
	        $preg = $preg['preg'];
	    }

	    return (bool)preg_match($preg, $text);
	}
957508
private function _convertTagsToEscapeSequences ( $text ) {
        list($patterns, $replacements) = $this->_getConvertingDictionary();
        $convertedText = preg_replace($patterns, $replacements, $text);
        return $convertedText;
    }
909135
function (cfg) {
            var i;

            if (!JS.isObject(cfg)) {
                return false;
            }

            if (cfg.prev) {
                if (!JS.isArray(cfg.prev)) {
                    return false;
                }
                for (i in cfg.prev) {
                    if (cfg.prev.hasOwnProperty(i)) {
                        if (!JS.isString(cfg.prev[i].nodeName)) {
                            return false;
                        }
                    }
                }
            }

            if (cfg.next) {
                if (!JS.isArray(cfg.next)) {
                    return false;
                }
                for (i in cfg.next) {
                    if (cfg.next.hasOwnProperty(i)) {
                        if (!JS.isString(cfg.next[i].nodeName)) {
                            return false;
                        }
                    }
                }
            }

            return true;
        }
414392
private function _connect_ssh(array $cfg): bool
  {
    if ( isset($cfg['host']) ){
      $param = [];
      if ( isset($cfg['public'], $cfg['private']) ){
        $param['hostkey'] = 'ssh-rsa';
      }
      $this->cn = @ssh2_connect($cfg['host'], $cfg['port'] ?? 22, $param, [
        'debug' => function($message, $language, $always_display){
          bbn\x::log([$message, $language, $always_display]);
        },
        'disconnect' => function($reason, $message, $language){
          bbn\x::log([$reason, $message, $language]);
        }
      ]);
      if ( !$this->cn ){
        $this->error = _("Could not connect through SSH.");
      }
      else if ( isset($cfg['user'], $cfg['public'], $cfg['private']) ){
        /*
        $fingerprint = ssh2_fingerprint($this->cn, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX);
        if ( strcmp($this->ssh_server_fp, $fingerprint) !== 0 ){
          $this->error = _('Unable to verify server identity!');
        }
        */
        if ( !ssh2_auth_pubkey_file($this->cn, $cfg['user'], $cfg['public'], $cfg['private'], $cfg['pass'] ?? null) ){
          $this->error = _('Authentication rejected by server');
        }
        else if ( $this->stream = @ssh2_sftp($this->cn) ){
          $this->current = ssh2_sftp_realpath($this->stream, '.');
          return true;
        }
        else{
          $this->error = _("Could not connect through SFTP.");
        }
      }
      else if ( isset($cfg['user'], $cfg['pass']) && @ssh2_auth_password($this->cn, $cfg['user'], $cfg['pass']) ){
        //die(_("Could not authenticate with username and password."));
        $this->stream = @ssh2_sftp($this->cn);
        if ( $this->stream ){
          $this->current = ssh2_sftp_realpath($this->stream, '.');
          return true;
        }
        $this->error = _("Could not initialize SFTP subsystem.");
      }
      else{
        $this->error = _("Could not authenticate with username and password.");
      }
    }
    return false;
  }
863490
private function tag_text($text)
	{
		if($this->current_tag instanceof Node_Container_Tag)
		{
			$accepted_children = $this->bbcodes[$this->current_tag->tag()]->accepted_children();

			if(!empty($accepted_children) && !in_array('text_node', $accepted_children))
				return;
		}

		$this->current_tag->add_child(new Node_Text($text));
	}
1179793
private function _connect_ftp(array $cfg): bool
  {
    if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) ){
      $args = [$cfg['host'], $cfg['port'] ?? 21, $cfg['timeout'] ?? 3];
      try {
        $this->stream = ftp_ssl_connect(...$args);
      }
      catch ( \Exception $e ){
        $this->error = _('Impossible to connect to the FTP host');
        $this->error .= PHP_EOL.$e->getMessage();
      }
      if ( $this->stream ){
        if ( !@ftp_login($this->stream, $cfg['user'], $cfg['pass']) ){
          try {
            $this->stream = ftp_connect(...$args);
          }
          catch ( \Exception $e ){
            $this->error = _('Impossible to connect to the FTP host');
            $this->error .= PHP_EOL.$e->getMessage();
          }
          if ( !@ftp_login($this->stream, $cfg['user'], $cfg['pass']) ){
            $this->error = _('Impossible to login to the FTP host');
            $this->error .= PHP_EOL.error_get_last()['message'];
          }
        }
        if ( !$this->error ){
          $this->current = ftp_pwd($this->stream);
          if (
            !empty($cfg['passive']) ||
            (defined('BBN_SERVER_NAME') && !@fsockopen(BBN_SERVER_NAME, $args[1]))
          ){
            ftp_pasv($this->stream, true);
          }
          return true;
        }
      }
    }
    return false;
  }
1039205
public function waitForVisibleText($text)
    {
        $this->waitFor(function ($context) use ($text) {
            try {
                /** @var Web $context */
                $context->assertPageContainsText($text);
                return true;
            } catch (ResponseTextException $e) {

            }
        });
    }
625535
protected static function checkColons($text)
    {
        if (strpos($text, ':') !== false
        || strpos($text, '[') !== false
        || strpos($text, '{') !== false
        || strpos($text, '-') !== false
        || strpos($text, '<') !== false
        || strpos($text, '&') !== false
        ) {
            return '"'.str_replace('"', '\"', $text).'"';
        }

        return $text;
    }
119201
public function set_cfg(string $id = null, array $cfg = null): int
  {
    if ( null !== $cfg ){
      $cfg = $this->get_cfg(null, $cfg);
      $config = json_encode($cfg);
    }
    else{
      $config = null;
    }
    return $this->db->update($this->class_cfg['table'], [
      $this->fields['cfg'] => $config
    ], [
      $this->fields['id'] => $id
    ]);
  }
783927
public static function isWellFormed( $text ) {
		$parser = xml_parser_create( "UTF-8" );

		# case folding violates XML standard, turn it off
		xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );

		if( !xml_parse( $parser, $text, true ) ) {
			//$err = xml_error_string( xml_get_error_code( $parser ) );
			//$position = xml_get_current_byte_index( $parser );
			//$fragment = $this->extractFragment( $html, $position );
			//$this->mXmlError = "$err at byte $position:\n$fragment";
			xml_parser_free( $parser );
			return false;
		}

		xml_parser_free( $parser );

		return true;
	}