/**
* @param \Silex\Application $app
*/
public function __construct(Silex\Application $app)
{
$this->app = $app;
$this->db = $app['db'];
$prefix = $this->app['config']->get('general/database/prefix', 'bolt_');
// Hashstrength has a default of '10', don't allow less than '8'.
$this->hashStrength = max($this->app['config']->get('general/hash_strength'), 8);
$this->usertable = $prefix . 'users';
$this->authtokentable = $prefix . 'authtoken';
$this->users = array();
$this->session = $app['session'];
/*
* Get the IP stored earlier in the request cycle. If it's missing we're on CLI so use localhost
*
* @see discussion in https://github.com/bolt/bolt/pull/3031
*/
$request = Request::createFromGlobals();
$this->hostName = $request->getHost();
$this->remoteIP = $request->getClientIp() ?: '127.0.0.1';
$this->userAgent = $request->server->get('HTTP_USER_AGENT');
$this->authToken = $request->cookies->get('bolt_authtoken');
// Set 'validsession', to see if the current session is valid.
$this->validsession = $this->checkValidSession();
$this->allowed = array('dashboard' => self::EDITOR, 'settings' => self::ADMIN, 'login' => self::ANONYMOUS, 'logout' => self::EDITOR, 'dbcheck' => self::ADMIN, 'dbupdate' => self::ADMIN, 'clearcache' => self::ADMIN, 'prefill' => self::DEVELOPER, 'users' => self::ADMIN, 'useredit' => self::ADMIN, 'useraction' => self::ADMIN, 'overview' => self::EDITOR, 'editcontent' => self::EDITOR, 'editcontent:own' => self::EDITOR, 'editcontent:all' => self::ADMIN, 'contentaction' => self::EDITOR, 'about' => self::EDITOR, 'extensions' => self::DEVELOPER, 'files' => self::EDITOR, 'files:config' => self::DEVELOPER, 'files:theme' => self::DEVELOPER, 'files:uploads' => self::ADMIN, 'translation' => self::DEVELOPER, 'activitylog' => self::ADMIN, 'fileedit' => self::ADMIN);
}