Short description of method check

@access public
@author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
@return common_configuration_Report
761857
public function check()
    {
        $returnValue = null;

        
        $validity = null;
        $name = $this->getName();
        if (($value = ini_get($name)) !== false){
            // The ini value exists for this name.
            if ((($value == '') ? '0' : $value) == $this->getExpectedValue()){
                $validity = common_configuration_Report::VALID;
                $message = "PHP Configuration Option '${name}' = '${value}' has an expected value.";
            }
            else {
                $validity = common_configuration_Report::INVALID;
                $message = "PHP Configuration Option '${name}' = '${value}' has an unexpected value.";
            }
        }
        else {
            // Unknown ini value name.
            $validity = common_configuration_Report::UNKNOWN;
            $message = "PHP Configuration Option '${name}' is unknown.";
        }

        $returnValue = new common_configuration_Report($validity, $message, $this);
        

        return $returnValue;
    }
1348632
public function performCheck()
    {
        if ($this->installerOptions->isAutoAttachEnabled() === false) {
            try {
                $existingTables = [];
                foreach ($this->connection->fetchAll('show tables') as $row) {
                    $existingTables[] = array_shift($row);
                }
                $numExistingTables = count($existingTables);
                if ($numExistingTables > 0) {
                    $result = new PreconditionResult(
                        PreconditionResult::STATE_FAILED,
                        t2(
                            'There is already %s table in this database. concrete5 must be installed in an empty database.',
                            'There are already %s tables in this database. concrete5 must be installed in an empty database.',
                            $numExistingTables
                        )
                    );
                } else {
                    $result = new PreconditionResult(PreconditionResult::STATE_PASSED);
                }
            } catch (Exception $x) {
                $result = new PreconditionResult(PreconditionResult::STATE_FAILED, $x->getMessage());
            }
        } else {
            $result = new PreconditionResult(PreconditionResult::STATE_SKIPPED, t('The configuration is auto-attached'));
        }

        return $result;
    }
1077394
public function actionReport()
    {
        $hasErrors = false;
        foreach ($this->getAuditManager()->getReport() as $modelName => $result) {
            if (is_string($result) || !$result['enabled']) {
                $color = Console::FG_GREY;
            } elseif ($result['valid'] === false) {
                $hasErrors = false;
                $color = Console::FG_RED;
            } else {
                $color = Console::FG_GREEN;
            }
            $this->stdout('    '.str_pad(is_string($result) ? $result : $modelName.' ', 40, '.').' ', $color);
            if (is_array($result)) {
                $this->stdout($result['enabled'] ? '+' : '-', $color);
                $this->stdout($result['valid'] === false ? '!' : '', $color);
            }
            $this->stdout("\n");
        }
        return $hasErrors ? self::EXIT_CODE_ERROR : self::EXIT_CODE_NORMAL;
    }
434248
public function check()
    {
        $response = $this->client->get($this->getURL());
        $cookie = $this->getCookie($response);
        $fullURL = $this->getURL();

        if ($cookie) {
            return [
                EnvironmentCheck::ERROR,
                "Sessions are being set for {$fullURL} : Set-Cookie => " . $cookie,
            ];
        }
        return [
            EnvironmentCheck::OK,
            "Sessions are not being created for {$fullURL} 👍",
        ];
    }
707552
public function performCheck()
    {
        $result = new PreconditionResult();
        if (version_compare(PHP_VERSION, static::MINIMUM_PHP_VERSION) < 0) {
            $result
                ->setState(PreconditionResult::STATE_FAILED)
                ->setMessage(t('concrete5 requires at least PHP version %1$s (you are running PHP version %2$s).', static::MINIMUM_PHP_VERSION, PHP_VERSION))
            ;
        } else {
            $result->setMessage(t('you are running PHP version %s', PHP_VERSION));
        }

        return $result;
    }
234485
public function check()
    {
        $result = false;

        $version = $this->dataService->getVersion();

        // Check the version. If this is > 0 then it seems to be a version number like 1.2.3
        // Because the getVersion method can return an error like
        //      Warning: Identity file /Users/agrunwald/.ssh/id_rsa_config not accessible: No such file or directory.
        //      Permission denied (publickey).
        //
        if ($version && version_compare($version, 0, '>')) {
            $this->version = $version;
            $result = true;
        }

        return $result;
    }
1290394
public function checkConfig()
    {
        $slugs = [];
        if ($this->passed === null) {
            $this->passed = true;
        } else {
            return $this->passed;
        }

        foreach ($this->data['contenttypes'] as $key => $ct) {
            // Make sure that there are no hyphens in the contenttype name, advise to change to underscores
            if (strpos($key, '-') !== false) {
                $error = Trans::__(
                    'contenttypes.generic.invalid-hyphen',
                    [
                        '%contenttype%' => $key,
                    ]
                );
                $this->app['logger.flash']->error($error);
                unset($this->data['contenttypes'][$key]);

                $this->passed = false;
            }

            /**
             * Make sure any field that has a 'uses' parameter actually points to a field that exists.
             *
             * For example, this will show a notice:
             * entries:
             *   name: Entries
             *     singular_name: Entry
             *     fields:
             *       title:
             *         type: text
             *         class: large
             *       slug:
             *         type: slug
             *         uses: name
             */
            foreach ($ct['fields'] as $fieldname => $field) {
                // Verify that the contenttype doesn't try to add fields that are reserved.
                if ($fieldname != 'slug' && in_array($fieldname, $this->reservedFieldNames)) {
                    $error = Trans::__(
                        'contenttypes.generic.reserved-name',
                        ['%contenttype%' => $key, '%field%' => $fieldname]
                    );
                    $this->app['logger.flash']->danger($error);

                    $this->passed = false;
                }

                // Check 'uses'. If it's an array, split it up, and check the separate parts. We also need to check
                // for the fields that are always present, like 'id'.
                if (!empty($field['uses']) && is_array($field['uses'])) {
                    foreach ((array) $field['uses'] as $useField) {
                        if (!empty($field['uses']) && empty($ct['fields'][$useField]) && !in_array($useField, $this->reservedFieldNames)) {
                            $error = Trans::__(
                                'contenttypes.generic.wrong-use-field',
                                ['%contenttype%' => $key, '%field%' => $fieldname, '%uses%' => $useField]
                            );
                            $this->app['logger.flash']->warning($error);

                            $this->passed = false;
                        }
                    }
                }

                // Check if all the used fields are existing field types.
                // Note: Check is disabled for now, because of the load order. At this point
                // in the execution, field types added by extensions are not yet initialised,
                // giving "false positives". See https://github.com/bolt/bolt/pull/7260
                /*
                if (!isset($field['type']) || !$this->fields->has($field['type'])) {
                    $error = Trans::__(
                        'contenttypes.generic.no-proper-type',
                        [
                            '%contenttype%' => $key,
                            '%field%'       => $fieldname,
                            '%type%'        => $field['type'],
                        ]
                    );
                    $this->app['logger.flash']->warning($error);

                    unset($ct['fields'][$fieldname]);
                    $this->passed = false;
                }
                */

                // Make sure that there are no consecutive underscores in field names
                if (strpos($fieldname, '__') !== false) {
                    $error = Trans::__(
                        'contenttypes.generic.consecutive-underscores',
                        [
                            '%contenttype%' => $key,
                            '%field%'       => $fieldname,
                            '%type%'        => $field['type'],
                        ]
                    );
                    $this->app['logger.flash']->warning($error);

                    unset($ct['fields'][$fieldname]);
                    $this->passed = false;
                }
            }

            /**
             * Make sure any contenttype that has a 'relation' defined points to a contenttype that exists.
             */
            if (isset($ct['relations'])) {
                foreach ($ct['relations'] as $relKey => $relData) {
                    // For BC we check if relation uses hyphen and re-map to underscores
                    if (strpos($relKey, '-') !== false) {
                        $newRelKey = str_replace('-', '_', strtolower(Str::makeSafe($relKey, true)));
                        unset($this->data['contenttypes'][$key]['relations'][$relKey]);
                        $this->data['contenttypes'][$key]['relations'][$newRelKey] = $relData;
                        $relKey = $newRelKey;
                    }
                    if (!isset($this->data['contenttypes'][$relKey])) {
                        $error = Trans::__(
                            'contenttypes.generic.invalid-relation',
                            ['%contenttype%' => $key, '%relation%' => $relKey]
                        );
                        $this->app['logger.flash']->error($error);

                        unset($this->data['contenttypes'][$key]['relations'][$relKey]);
                        $this->passed = false;
                    }
                    if (array_key_exists($relKey, $ct['fields'])) {
                        $error = Trans::__(
                            'general.phrase.clashing-relation',
                            ['%contenttype%' => $key, '%relation%' => $relKey]
                        );
                        $this->app['logger.flash']->error($error);
                    }
                }
            }

            // Keep a running score of used slugs.
            if (!isset($slugs[$ct['slug']])) {
                $slugs[$ct['slug']] = 0;
            }
            ++$slugs[$ct['slug']];
            if (!isset($slugs[$ct['singular_slug']])) {
                $slugs[$ct['singular_slug']] = 0;
            }
            if ($ct['singular_slug'] != $ct['slug']) {
                ++$slugs[$ct['singular_slug']];
            }
        }

        // Sanity checks for taxonomy.yml
        foreach ($this->data['taxonomy'] as $key => $taxo) {
            // Show some helpful warnings if slugs or keys are not set correctly.
            if ($taxo['slug'] != $key) {
                $error = Trans::__(
                    "The identifier and slug for '%taxonomytype%' are the not the same ('%slug%' vs. '%taxonomytype%'). Please edit taxonomy.yml, and make them match to prevent inconsistencies between database storage and your templates.",
                    ['%taxonomytype%' => $key, '%slug%' => $taxo['slug']]
                );
                $this->app['logger.flash']->warning($error);

                $this->passed = false;
            }
        }

        // if there aren't any other errors, check for duplicates across contenttypes.
        if (!$this->app['logger.flash']->has('error')) {
            foreach ($slugs as $slug => $count) {
                if ($count > 1) {
                    $error = Trans::__(
                        "The slug '%slug%' is used in more than one contenttype. Please edit contenttypes.yml, and make them distinct.",
                        ['%slug%' => $slug]
                    );
                    $this->app['logger.flash']->warning($error);

                    $this->passed = false;
                }
            }
        }

        return $this->checkTaxonomy();
    }
997908
public function checkSysConfigAction()
    {
        $success = 0;
        $errors = [];

        if ($this->getRequest()->isXmlHttpRequest()) {
            $response = $this->systemConfigurationChecker();
            $success = $response['success'];
            $errors = $response['errors'];

            // add status to session
            $container = new Container('melisinstaller');
            $container['steps'][$this->steps[0]] = ['page' => 1, 'success' => $success];
        }

        return new JsonModel([
            'success' => $success,
            'errors' => $errors,
        ]);
    }
583468
public function doChecks()
    {
        foreach ($this->checks as $check) {
            $method = 'check' . ucfirst($check);
            $this->$method();
        }

        // If the config folder is OK, but the config files are missing, attempt to fix it.
        foreach ($this->configChecks as $check) {
            $this->lowlevelConfigFix($check);
        }
    }
228116
public function check()
    {
        $checker = new SensioLabsSecurityChecker();

        $alerts = $checker->check(base_path('composer.lock'));

        if (count($alerts) == 0) {
            return $this->makeHealthyResult();
        }

        $problems = collect($alerts)
            ->keys()
            ->implode(', ');

        return $this->makeResult(
            false,
            sprintf($this->target->getErrorMessage(), $problems)
        );
    }
627213
protected function perform_check()
	{
		// fetch the username and login hash from the session
		$username    = \Session::get('username');
		$login_hash  = \Session::get('login_hash');

		// only worth checking if there's both a username and login-hash
		if ( ! empty($username) and ! empty($login_hash))
		{
			if (is_null($this->user) or ($this->user['username'] != $username and $this->user != static::$guest_login))
			{
				$this->user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))
					->where('username', '=', $username)
					->from(\Config::get('simpleauth.table_name'))
					->execute(\Config::get('simpleauth.db_connection'))->current();
			}

			// return true when login was verified, and either the hash matches or multiple logins are allowed
			if ($this->user and (\Config::get('simpleauth.multiple_logins', false) or $this->user['login_hash'] === $login_hash))
			{
				return true;
			}
		}

		// not logged in, do we have remember-me active and a stored user_id?
		elseif (static::$remember_me and $user_id = static::$remember_me->get('user_id', null))
		{
			return $this->force_login($user_id);
		}

		// no valid login when still here, ensure empty session and optionally set guest_login
		$this->user = \Config::get('simpleauth.guest_login', true) ? static::$guest_login : false;
		\Session::delete('username');
		\Session::delete('login_hash');

		return false;
	}
1030148
public function performCheck()
    {
        $notWritableDirectories = [];
        foreach ([
            DIR_CONFIG_SITE => DIRNAME_APPLICATION . '/' . DIRNAME_CONFIG . '/',
            DIR_FILES_UPLOADED_STANDARD => DIRNAME_APPLICATION . '/files/',
            DIR_PACKAGES => DIRNAME_PACKAGES . '/',
        ] as $path => $name) {
            if (!$this->fs->isDirectory($path) || !$this->fs->isWritable($path)) {
                $notWritableDirectories[] = $name;
            }
        }
        $result = new PreconditionResult();
        $numNotWritableDirectories = count($notWritableDirectories);
        if ($numNotWritableDirectories > 0) {
            $message = t2('This directory must exist and it must be writable by your web server:', 'These directories must exist and they must be writable by your web server:', $numNotWritableDirectories);
            $message .= ' ' . \Punic\Misc::join($notWritableDirectories);
            $result
                ->setState(PreconditionResult::STATE_FAILED)
                ->setMessage($message)
            ;
        }

        return $result;
    }
1259809
public static function check() {
		if (R::count("user") < 1) {
			$pwdbname             = setup::getValidation("password");
			$userdbname           = setup::getValidation("username");
			$guest                = R::dispense("user");
			$guest->{$userdbname} = "guest";
			$guest->{$pwdbname}   = "";
			$guest->role          = role::get("guest");
			R::store($guest);
		}
	}
761792
public function check()
    {
    	$action = $this->request->param('action');
        $controller = $this->request->param('controller');
        $prefix = ($this->request->param('prefix') === false) ? '/' : $this->request->param('prefix');
        $plugin = ($this->request->param('plugin') === false) ? '' : $this->request->param('plugin');

        $plugin_prefix = (empty($plugin)) ? $prefix : $plugin . '.' . $prefix;
        if( isset($this->_authorized[$plugin_prefix][$controller]) &&
            in_array($action, $this->_authorized[$plugin_prefix][$controller]) ) return true;

        $user_id = $this->request->session()->read('Auth.User.id');
        $group_id = -1;
        if( isset($this->controllers['group']) ) {
            $User = TableRegistry::get($this->controllers['user']);
            $group_id = $User->get($user_id)->group_id;
        }

        $UserGroupPermission = TableRegistry::get('UserGroupPermission');
        $Permission = TableRegistry::get('Permission');

        $unique_string = $this->getUniqueString($controller, $action, $prefix, $plugin);
        $permission_id = $Permission->find()
            ->select(['id'])
            ->where(['unique_string' => $unique_string])->first();
        if( is_null($permission_id) ) return false;

        $allow = $UserGroupPermission->find()
            ->select(['allow'])
            ->where(
                [
                    'group_or_user'     => 'user',
                    'group_or_user_id'  => $user_id,

                ])
            ->orWhere(
                [
                    'group_or_user'     => 'group',
                    'group_or_user_id'  => $group_id
                ])->andWhere(['permission_id' => $permission_id->id])
            ->order(['allow'=>'DESC'])->first();
        if( is_null($allow) ) return false;

        return $allow->allow;
    }
459249
public function check()
    {
        $fromTables = $this->getInstalledTables();
        $toTables = $this->getSchemaTables();
        $protectedTableNames = $this->app['schema.content_tables']->keys();

        $response = $this->getSchemaComparator()->compare($fromTables, $toTables, $protectedTableNames);
        if (!$response->hasResponses()) {
            $this->getSchemaTimer()->setCheckExpiry();
        }

        return $response;
    }
585202
public function run()
    {
        $result = new EnvironmentCheckSuiteResult();

        foreach ($this->checkInstances() as $check) {
            list($checkClass, $checkTitle) = $check;
            try {
                list($status, $message) = $checkClass->check();
            // If the check fails, register that as an error
            } catch (Exception $e) {
                $status = EnvironmentCheck::ERROR;
                $message = $e->getMessage();
            }
            $result->addResult($status, $message, $checkTitle);
        }

        return $result;
    }
192206
public function performCheck()
    {
        $result = new PreconditionResult();
        if (!(
            extension_loaded('pdo')
            && extension_loaded('pdo_mysql')
        )) {
            $result
                ->setState(PreconditionResult::STATE_FAILED)
                ->setMessage(t('The PDO extension is not loaded.'))
            ;
        }

        return $result;
    }