Validates a store base path
@return boolean|null
185189
protected function validateBasepathStore()
    {
        $field = 'basepath';

        if ($this->isExcluded($field) || $this->isError('domain')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        if ($this->getSubmitted('default')) {
            $this->unsetSubmitted($field);
            return null; // Cannot update basepath of default store
        }

        $updating = $this->getUpdating();

        if (isset($updating['basepath'])
            && $updating['basepath'] === $value
            && $updating['domain'] === $this->getSubmitted('domain')) {
            return true;
        }

        if (preg_match('/^[a-z0-9-]{0,50}$/', $value) !== 1) {
            $this->setErrorInvalid($field, $this->translation->text('Path'));
            return false;
        }

        return true;
    }
1197601
protected function validateUser()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->user->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('User'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
1353218
public function validate()
	{
		$sourceFiles = $this->getFileList($this->sourcePath);
		// License file is required but missing from en/, so we add it here
		$sourceFiles[] = $this->sourceLanguagePath . 'LICENSE';
		$sourceFiles = array_unique($sourceFiles);

		// Get $lang['direction'] of translation to allow additional rtl-files for rtl-translations
		$filePath = $this->originPath . '/' . $this->originLanguagePath . 'common.php';

		if ($this->safeMode)
		{
			$lang = ValidatorRunner::langParser($filePath);
		}

		else
		{
			include($filePath);
		}

		$direction = $lang['DIRECTION'];
		// Throw error, if invalid direction is used
		if (!in_array($direction, array('rtl', 'ltr')))
		{
			$this->output->addMessage(Output::FATAL, 'DIRECTION needs to be rtl or ltr');
		}

		$originFiles = $this->getFileList($this->originPath);

		$missingSubsilver2Files = $availableSubsilver2Files = array();
		$validFiles = array();
		foreach ($sourceFiles as $sourceFile)
		{
			$testOriginFile = str_replace('/' . $this->sourceIso . '/', '/' . $this->originIso . '/', $sourceFile);
			if (!in_array($testOriginFile, $originFiles))
			{
				$this->output->addMessage(Output::FATAL, 'Missing required file', $testOriginFile);
			}
			else if (substr($sourceFile, -4) != '.gif' && substr($sourceFile, -12) != 'imageset.cfg')
			{
				$validFiles[$sourceFile] = $testOriginFile;
			}
		}

		foreach ($originFiles as $origin_file)
		{
			$testSourceFile = str_replace('/' . $this->originIso . '/', '/' . $this->sourceIso . '/', $origin_file);
			if (!in_array($testSourceFile, $sourceFiles))
			{
				if (in_array($origin_file, array(
					$this->originLanguagePath . 'AUTHORS.md',
					$this->originLanguagePath . 'CHANGELOG.md',
					$this->originLanguagePath . 'README.md',
					$this->originLanguagePath . 'VERSION.md',
				)))
				{
					$this->output->addMessage(Output::NOTICE, 'Found additional file', $origin_file);
				}
				else
				{
					if (substr($origin_file, -10) === '/index.htm' || $origin_file === 'index.htm')
					{
						$level = Output::NOTICE;
					}
					else if ($this->phpbbVersion === '3.2' && strpos($origin_file, 'styles/subsilver2/') === 0)
					{
						$level = Output::FATAL;
					}
					else if (in_array(substr($origin_file, -4), array('.gif', '.png')) && $direction === 'rtl')
					{
						$level = Output::WARNING;
					}
					else if (substr($origin_file, -3) !==	'.md')
					{
						$level = Output::FATAL;
					}
					else
					{
						$level = Output::ERROR;
					}

					$this->output->addMessage($level, 'Found additional file', $origin_file);
				}

				if (substr($origin_file, -14) === '/site_logo.gif')
				{
					$this->output->addMessage(Output::FATAL, 'Found additional file', $origin_file);
				}
			}
		}

		return $validFiles;
	}
1171977
private function validate()
    {
        if (!$this->testServer($this->ssh, sprintf('-d "%s"', $this->directory))) {
            throw new SshValidateException('Directory does not exists');
        }

        if (!$this->testServer($this->ssh, sprintf('-x "%s"', $this->executable), $this->directory)) {
            throw new SshValidateException('Executable does not exists');
        }

        return true;
    }
667785
public function validate()
    {
        $steps = [
            'PrivateKey',
            'IdpMetadata',
            'SpMetadata'
        ];

        foreach ($steps as $step) {
            $method = 'validate' . $step;
            if (!$this->$method()) {
                return false;
            }
        }

        return true;
    }
292278
protected function validateDomainStore()
    {
        $field = 'domain';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        if ($this->getSubmitted('default')) {
            $this->unsetSubmitted('domain'); // Cannot update domain of default store
            return null;
        }

        $label = $this->translation->text('Domain');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
        }

        $updating = $this->getUpdating();
        if (isset($updating['domain']) && $updating['domain'] === $value) {
            return true;
        }

        $existing = $this->store->get($value);

        if (!empty($existing)) {
            $this->setErrorExists($field, $label);
            return false;
        }

        return true;
    }
654400
public function isLocalValid()
    {
        $path = $this->getFullPath();
        if (!file_exists($path)) {
            return false;
        }
        return (getimagesize($path) !== false);
    }
25418
protected function checkBasePath(\SwaggerValidator\Common\Context $context)
    {
        if (!isset($this->basePath) || $this->basePath == '/') {
            $context->setBasePath(null);
            $context->setRequestPath($context->getDataValue());
            return $context;
        }

        if (substr($context->getDataValue(), 0, strlen($this->basePath)) != $this->basePath) {
            return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_BASEPATH_ERROR, 'BasePath requested is not matching', __METHOD__, __LINE__);
        }

        $context->setBasePath($this->basePath);
        $context->setRequestPath(substr($context->getDataValue(), strlen($this->basePath)));

        return $context;
    }
64569
public function getBasePath() {
    	
    	return ((isset($this->config['General']['base_path']) 
            && $this->config['General']['base_path'] 
            && isset($this->config['General']['use_base_path']) 
            && $this->config['General']['use_base_path']) 
                ? $this->config['General']['base_path'] : null);
    }
324193
public function isValid()
    {
        return $this->getID() != null && $this->getURL() != null && $this->getLocalPath() != null;
    }
206071
protected function validateDestinationRename()
    {
        if ($this->isError()) {
            return null;
        }

        $files = $this->getSubmitted('files');

        /* @var $file \SplFileInfo */
        $file = reset($files);
        $name = $this->getSubmitted('name');

        $directory = dirname($file->getRealPath());
        $destination = gplcart_path_normalize("$directory/$name");

        if (file_exists($destination)) {
            $this->setError('name', $this->translation->text('Destination already exists'));
            return false;
        }

        $this->setSubmitted('destination', $destination);
        return true;
    }
740993
protected function validateEditInstall()
    {
        $this->setSubmitted('settings');
        $this->setSubmitted('store.host', $this->server->httpHost());
        $this->setSubmitted('store.language', $this->install_language);
        $this->setSubmitted('store.basepath', trim($this->request->base(true), '/'));

        $this->validateComponent('install');

        return !$this->hasErrors(false);
    }
1003921
public function validate($deprecated=null)
    {
        //Resetting violations
        $this->violations = array();

        if ($this->_adapter) {
            $violations = $this->_adapter->validate($this);
            if (is_array($violations) && count($violations) > 0) {
                $this->isValidated = true;

                return false;
            }
        }

        /*
         * All child stores should be validated
         */
        $jsonSchema = $this->_jsonSchema;
        foreach ($jsonSchema['definition'] as $propertyName=>$prodSchema) {
            if ($prodSchema['type']=="object" || $prodSchema['type']=="id") {
                if ($prodSchema['type']=="id" && is_scalar($this->$propertyName)) continue;

                /**
                 * we enter here if we are not able to unserialize the object
                 * because it does not have a valid _className property, or/and there
                 * is two StoreClasses possible
                 */
                if ($this->$propertyName instanceof \stdClass && count($prodSchema['storeClasses'])) {

                    if (isset($this->$propertyName->_className)) {
                        $className = $this->$propertyName->_className;
                        /**
                         * the _className class does not exists
                         */
                        if (!class_exists($className)) {
                            $this->addViolation($propertyName, "$propertyName ->_className '$className' store class does not exists ");
                        }

                        if (!in_array($className, $prodSchema['storeClasses'])) {
                            $this->addViolation($propertyName, "$propertyName ->_className is not allowed here");
                        }
                    }

                    $this->addViolation($propertyName, "$propertyName should define _className property. see store definition");
                }

                if ((!$this->$propertyName instanceof BaseStore)) continue;

                $validationChild = $this->$propertyName->validate();
                if (!$validationChild) {
                    $violationsChild = $this->$propertyName->getViolations();
                    foreach ($violationsChild as $violation) {
                        /*
                         * Adding violations with propertyName as prefix on the
                         * violations of the parent
                         */
                        $this->violations[] = new ConstraintViolation(
                            $violation->getMessage(),
                            $violation->getMessageTemplate(),
                            $violation->getMessageParameters(),
                            $violation->getRoot(),
                            $propertyName . "." . $violation->getPropertyPath(),
                            $violation->getInvalidValue(),
                            $violation->getMessagePluralization(),
                            $violation->getCode()
                        );
                    }
                }
            } elseif ($prodSchema['type']=="array" && count($prodSchema['storeClasses']) >0
                && is_array($this->$propertyName)) {

                foreach ($this->$propertyName as $store) {
                    if (!StoreHelper::checkStoreClass($store, $prodSchema['storeClasses'], $prodSchema['allowedId'])) {
                        $this->addViolation($propertyName, "'$propertyName' array element has a wrong "
                            ."store type.");
                    }
                }
            }
        }

        $violationsFromValidation = StoreManager::getValidator()->validate($this);
        foreach($violationsFromValidation as $violation) $this->violations[] = $violation;

        $this->isValidated = true;

        if (count($this->violations)>0) return false;
        return true;
    }
985888
protected function validateLimitCart()
    {
        if ($this->isError()) {
            return null;
        }

        $admin = $this->getSubmitted('admin');
        $product = $this->getSubmitted('product');

        if (!empty($admin) || empty($product)) {
            return null;
        }

        $sku = $this->getSubmitted('sku');
        $user_id = $this->getSubmitted('user_id');
        $store_id = $this->getSubmitted('store_id');
        $quantity = $this->getSubmitted('quantity');
        $increment = $this->getSubmitted('increment', true);
        $stock = $this->getSubmitted('stock', $product['stock']);

        $expected_quantity_sku = $quantity;
        $existing_quantity = $this->cart->getQuantity(array('user_id' => $user_id, 'store_id' => $store_id));

        if (!empty($increment) && isset($existing_quantity['sku'][$sku])) {
            $expected_quantity_sku += $existing_quantity['sku'][$sku];
        }

        if ($product['subtract'] && $expected_quantity_sku > $stock) {
            $error = $this->translation->text('Too low stock level');
            $this->setError('quantity', $error);
            return false;
        }

        $limit_sku = $this->cart->getLimits('sku');
        $limit_item = $this->cart->getLimits('item');

        if (!empty($limit_item) && !isset($existing_quantity['sku'][$sku]) && count($existing_quantity['sku']) >= $limit_item) {
            $error = $this->translation->text('Please no more than @num items', array('@num' => $limit_item));
            $this->setError('quantity', $error);
            return false;
        }

        if (!empty($limit_sku) && $expected_quantity_sku > $limit_sku) {
            $error = $this->translation->text('Please no more than @num items per SKU', array('@num' => $limit_sku));
            $this->setError('quantity', $error);
            return false;
        }

        return true;
    }
227876
function validate() {

		// Is this an ODT?
		if ( ! $this->isOdt( $this->outputPath ) ) {

			$this->logError( \Pressbooks\Utility\get_contents( $this->logfile ) );

			return false;
		}

		return true;
	}
825158
protected function validateOrder()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->order->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Order'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }
722258
public function isValid()
	{
		// loop through all files
		foreach ($this->container as $file)
		{
			// return false at the first non-valid file
			if ( ! $file->isValid())
			{
				return false;
			}
		}

		// only return true if there are uploaded files, and they are all valid
		return empty($this->container) ? false : true;
	}