/** * Constructor * Loads user configuration and strategies. * * @param array $config User configuration * @param boolean $run Whether Opauth should auto run after initialization. */ public function __construct($config = array(), $run = true) { /** * Configurable settings */ $this->config = array_merge(array('host' => (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'], 'path' => '/', 'callback_url' => '{path}callback', 'callback_transport' => 'session', 'debug' => false, 'security_salt' => 'LDFmiilYf8Fyw5W10rx4W1KsVrieQCnpBzzpTBWA5vJidQKDx8pMJbmw28R1C4m', 'security_iteration' => 300, 'security_timeout' => '2 minutes'), $config); /** * Environment variables, including config * Used mainly as accessors */ $this->env = array_merge(array('request_uri' => $_SERVER['REQUEST_URI'], 'complete_path' => $this->config['host'] . $this->config['path'], 'lib_dir' => dirname(__FILE__) . '/', 'strategy_dir' => dirname(__FILE__) . '/Strategy/'), $this->config); if (!class_exists('OpauthStrategy')) { require $this->env['lib_dir'] . 'OpauthStrategy.php'; } foreach ($this->env as $key => $value) { $this->env[$key] = OpauthStrategy::envReplace($value, $this->env); } if ($this->env['security_salt'] == 'LDFmiilYf8Fyw5W10rx4W1KsVrieQCnpBzzpTBWA5vJidQKDx8pMJbmw28R1C4m') { trigger_error('Please change the value of \'security_salt\' to a salt value specific to your application', E_USER_NOTICE); } $this->loadStrategies(); if ($run) { $this->run(); } }