Test for engine validity

This is mainly just a wrapper to set things up for Crypt_Base::isValidEngine()

@see Crypt_Base::isValidEngine()
@param int $engine
@access public
@return bool
551981
function isValidEngine($engine)
    {
        if ($this->key_length_max == 8) {
            if ($engine == CRYPT_ENGINE_OPENSSL) {
                $this->cipher_name_openssl_ecb = 'des-ecb';
                $this->cipher_name_openssl = 'des-' . $this->_openssl_translate_mode();
            }
        }

        return parent::isValidEngine($engine);
    }
306588
protected function validateModel()
    {
        parent::validateModel();

        $table = $this->getTable();

        // Check to see if any of the column constants are PHP reserved words.
        $colConstants = array();

        foreach ($table->getColumns() as $col) {
            $colConstants[] = $this->getColumnName($col);
        }

        $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords());

        $intersect = array_intersect($reservedConstants, $colConstants);
        if (!empty($intersect)) {
            throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")");
        }
    }
913993
public function supports($template)
    {
        foreach ($this->engines as $engine) {
            if ($engine->supports($template)) {
                return true;
            }
        }

        return false;
    }
1329052
public function isValidIsbn(string $isbn) : bool
    {
        return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn);
    }
529776
public function isValid($email)
    {
        if (false === $email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
            return false;
        }

        try {
            list($local, $domain) = Utilities::parseEmailAddress($email);
        } catch (InvalidEmailException $e) {
            return false;
        }

        return !$this->adapter->isThrowawayDomain($domain);
    }
449064
public function setEngine($table, $engine)
	{
		$supported = ['innodb', 'myisam', 'archive', 'merge', 'memory', 'csv', 'federated'];

		if (!in_array(strtolower($engine), $supported))
		{
			throw new UnsupportedEngineException(sprintf(
				'Unsupported engine type of "%s" specified. Engine type must be one of %s',
				$engine,
				implode(', ', $supported)
			));
		}

		$this->setQuery('ALTER TABLE ' . str_replace('#__', $this->tablePrefix, $this->quote($table, false)) . " ENGINE = " . $this->quote($engine));

		return $this->db->query();
	}
677947
public static function create($engine, $args = null)
    {
        $engine = strtolower($engine);
        if (self::validEngine($engine)) {
            return (isset($args)) ? self::createWithArgs($engine, $args) : self::createWithArgs($engine, array());
        }
        throw new \Franzip\SerpFetcher\Exceptions\UnsupportedEngineException('Invalid SerpFetcher $engine: unknown/unsupported Search Engine. Supported engines are: \'google\', \'ask\', \'bing\', \'yahoo\'');
    }
491759
public function isValidProperty(string $property)
    {
        if (!empty($this->validProperties) && !array_key_exists($property, $this->validProperties)) {
            return false;
        }

        return true;
    }
540138
public function isValid($key = null)
    {
        if (parent::isValid() && $this->getKey()) {
            return $key && $this->getKey() && $this->chiper->decrypt($this->getKey()) == $this->chiper->decrypt($key);
        }

        return false;
    }
1079769
public function invalidate()
    {
        list($key, $groupKey) = $this->getKeys(func_get_args());

        $this->engine->setGroupKey($groupKey);

        if (!$this->engine->isValid($key)) {
            return true;
        }

        return $this->engine->invalidate($key);
    }
1014594
public function performCheck()
    {
        try {
            $supported = false;
            foreach ($this->connection->fetchAll('show engines') as $engine) {
                $engine = array_change_key_case($engine, CASE_LOWER);
                if (isset($engine['engine']) && strtolower($engine['engine']) == 'innodb') {
                    $supported = true;
                    break;
                }
            }
            if ($supported) {
                $result = new PreconditionResult(PreconditionResult::STATE_PASSED);
            } else {
                $result = new PreconditionResult(PreconditionResult::STATE_FAILED, t('Your MySQL database does not support InnoDB database tables. These are required.'));
            }
        } catch (Exception $x) {
            $result = new PreconditionResult(PreconditionResult::STATE_FAILED, $x->getMessage());
        }

        return $result;
    }
1316897
function isValidEngine($engine)
    {
        if ($engine == Base::ENGINE_OPENSSL) {
            if (version_compare(PHP_VERSION, '5.3.7') >= 0) {
                $this->cipher_name_openssl = 'rc4-40';
            } else {
                switch (strlen($this->key)) {
                    case 5:
                        $this->cipher_name_openssl = 'rc4-40';
                        break;
                    case 8:
                        $this->cipher_name_openssl = 'rc4-64';
                        break;
                    case 16:
                        $this->cipher_name_openssl = 'rc4';
                        break;
                    default:
                        return false;
                }
            }
        }

        return parent::isValidEngine($engine);
    }
1132765
function isValidEngine($engine)
    {
        switch ($engine) {
            case CRYPT_ENGINE_OPENSSL:
                if ($this->mode == CRYPT_MODE_STREAM && $this->continuousBuffer) {
                    return false;
                }
                $this->openssl_emulate_ctr = false;
                $result = $this->cipher_name_openssl &&
                          extension_loaded('openssl') &&
                          // PHP 5.3.0 - 5.3.2 did not let you set IV's
                          version_compare(PHP_VERSION, '5.3.3', '>=');
                if (!$result) {
                    return false;
                }

                // prior to PHP 5.4.0 OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING were not defined. instead of expecting an integer
                // $options openssl_encrypt expected a boolean $raw_data.
                if (!defined('OPENSSL_RAW_DATA')) {
                    $this->openssl_options = true;
                } else {
                    $this->openssl_options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
                }

                $methods = openssl_get_cipher_methods();
                if (in_array($this->cipher_name_openssl, $methods)) {
                    return true;
                }
                // not all of openssl's symmetric cipher's support ctr. for those
                // that don't we'll emulate it
                switch ($this->mode) {
                    case CRYPT_MODE_CTR:
                        if (in_array($this->cipher_name_openssl_ecb, $methods)) {
                            $this->openssl_emulate_ctr = true;
                            return true;
                        }
                }
                return false;
            case CRYPT_ENGINE_MCRYPT:
                return $this->cipher_name_mcrypt &&
                       extension_loaded('mcrypt') &&
                       in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms());
            case CRYPT_ENGINE_INTERNAL:
                return true;
        }

        return false;
    }
1071513
function isValidEngine($engine)
    {
        if ($engine == self::ENGINE_OPENSSL) {
            if (version_compare(PHP_VERSION, '5.3.7') < 0 && $this->key_length != 16) {
                return false;
            }
            if ($this->key_length < 16) {
                return false;
            }
            $this->cipher_name_openssl_ecb = 'bf-ecb';
            $this->cipher_name_openssl = 'bf-' . $this->_openssl_translate_mode();
        }

        return parent::isValidEngine($engine);
    }
1228436
public function engine($engineIdent = null)
    {
        if ($engineIdent === null) {
            $engineIdent = $this->defaultEngine();
        }
        if (!is_string($engineIdent)) {
            throw new InvalidArgumentException(
                'Invalid engine identifier (must be a string)'
            );
        }

        if (!isset($this->engines[$engineIdent])) {
            throw new InvalidArgumentException(
                sprintf('No configured engines matching "%s"', $engineIdent)
            );
        }
        return $this->engines[$engineIdent];
    }
1129025
function _setEngine()
    {
        $this->engine = null;

        $candidateEngines = array(
            $this->preferredEngine,
            CRYPT_ENGINE_OPENSSL,
            CRYPT_ENGINE_MCRYPT
        );
        foreach ($candidateEngines as $engine) {
            if ($this->isValidEngine($engine)) {
                $this->engine = $engine;
                break;
            }
        }
        if (!$this->engine) {
            $this->engine = CRYPT_ENGINE_INTERNAL;
        }

        if ($this->engine != CRYPT_ENGINE_MCRYPT && $this->enmcrypt) {
            // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed,
            // (re)open them with the module named in $this->cipher_name_mcrypt
            @mcrypt_module_close($this->enmcrypt);
            @mcrypt_module_close($this->demcrypt);
            $this->enmcrypt = null;
            $this->demcrypt = null;

            if ($this->ecb) {
                @mcrypt_module_close($this->ecb);
                $this->ecb = null;
            }
        }

        $this->changed = true;
    }
1362806
public function valid($language)
    {
        if (empty($language)) {
            return false;
        }
        if ($language == 'en' || $language == 'de' || $language == 'pl' || $language == 'ru') {
            return true;
        }
        return false;
    }