protected function initialize() { if (!$this->loaded) { FacebookSession::setDefaultApplication(Config::get('accounts.facebook.id'), Config::get('accounts.facebook.secret')); $this->loaded = true; } }
public function main() { $template = new Template('example.phpt'); $template->set('title', Config::get('app.name')); $template->set('first', Config::get('app.example.first')); $template->set('second', Config::get('app.example.second')); $template->set('third', Config::get('app.example.third')); $template->set('counts', Config::get('app.example')); return Response::template($template); }
private function __construct($settings = array()) { $dsn = 'mysql:dbname=' . Config::get('database.mysql.database') . ';host=' . Config::get('database.mysql.host'); $username = Config::get('database.mysql.username'); $password = Config::get('database.mysql.password'); $pdoconfig = array('client_table' => 'oauth2_clients', 'access_token_table' => 'oauth2_access_tokens', 'refresh_token_table' => 'oauth2_refresh_tokens', 'code_table' => 'oauth2_authorization_codes', 'user_table' => 'oauth2_users', 'jwt_table' => 'oauth2_jwt', 'scope_table' => 'oauth2_scopes', 'public_key_table' => 'oauth2_public_keys'); $storage = new Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password), $pdoconfig); $this->storage = $storage; //$storage = DB::connection()->getPdo(); $settings['allow_implicit'] = true; $settings['access_lifetime'] = 60 * 60 * 24 * 365 * 2; $this->server = new Server($storage, $settings); $this->server->addGrantType(new AuthorizationCode($storage)); $this->server->addGrantType(new RefreshToken($storage, array('always_issue_new_refresh_token' => true, 'refresh_token_lifetime' => 60 * 60 * 24 * 31 * 2))); }
public function logout() { $config = Config::get('openid.client'); $flow = new Basic(array('client_info' => $config)); session_destroy(); /* $template = new Template ('CatLab/Accounts/logout.phpt'); $template->set ('layout', $this->module->getLayout ()); $template->set ('action', URLBuilder::getURL ($this->module->getRoutePath () . '/login')); return Response::template ($template); */ return $this->module->logout($this->request); }
/** * Return mailer (with services) from config. * @return Mailer */ public static function fromConfig() { $mailer = self::getInstance(); $services = Config::get('mailer.services'); if (!$services) { return $mailer; } foreach ($services as $k => $v) { $service = MapperFactory::getServiceMapper()->getFromToken($k); if ($service) { $service->setFromConfig($v); $mailer->addService($service); } } return $mailer; }
public function connect() { if (!isset($this->connection)) { Logger::getInstance()->log('Connecting database.'); try { $this->connection = new MySQLi(Config::get('database.mysql.host'), Config::get('database.mysql.username'), Config::get('database.mysql.password'), Config::get('database.mysql.database')); $this->connection->query('SET names "' . Config::get('database.mysql.charset') . '"'); //$this->connection->query ("SET time_zone = '+00:00'"); } catch (Exception $e) { echo $e; } if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit; } } }
protected function setAdditionalParameters(DeligatedUser $user) { $steamKey = Config::get('accounts.steam.key'); if ($steamKey) { $openid = $user->getUniqueId(); $params = explode('/', $openid); $id = array_pop($params); // Now fetch the user data $request = new Request(); $request->setUrl('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/'); $request->setParameters(array('key' => $steamKey, 'steamids' => $id)); $response = Client::getInstance()->get($request); // No headers? No gain. $data = json_decode($response->getBody(), true); if ($data) { $userdata = $data['response']['players'][0]; $user->setName($userdata['personaname']); $user->setAvatar($userdata['avatarfull']); $user->setFirstname($userdata['realname']); $user->setUrl($userdata['profileurl']); } } }
/** * @param $name * @return string */ protected function getTableName($name) { return Config::get('database.mysql.prefix') . $name; }
<?php error_reporting(E_ALL); $loader = (require_once '../../vendor/autoload.php'); // Start the app $app = \Neuron\Application::getInstance(); // Set config folder \Neuron\Config::folder(__DIR__ . '/../config/'); // Optionally, set an environment $hostname = trim(file_get_contents('/etc/hostname')); switch ($hostname) { case 'my-computer': case 'thijs-home-i7': case 'thijs-i7': \Neuron\Config::environment('development'); break; } // Set the template folder \Neuron\Core\Template::addPath(__DIR__ . '/../templates/'); // Always set a locale $app->setLocale('nl_BE.utf8'); // Load the router $app->setRouter(include 'router.php'); // Return app return $app;
public static function addFilter(\Neuron\Router $router) { $checker = new self(\Neuron\Config::get('auth.users')); $router->addFilter('basicauth', array($checker, 'check')); }
public function sendConfirmationEmail(Module $module) { return; $template = new Template('CatLab/Accounts/mails/confirmation.phpt'); $template->set('user', $this); $mail = new Mail(); $mail->setSubject('Email verification'); $mail->setTemplate($template); $mail->getTo()->add($this->getEmail()); $mail->setFrom(Config::get('mailer.from.email')); Mailer::getInstance()->send($mail); }
define('RELATIVE_URL', \Neuron\Config::get('app.url')); define('TIME_ZONE', 'Europe/Brussels'); define('BASE_URL', ''); define('DATETIME', 'd.m.Y H:i'); define('DEFAULT_TEMPLATE_DIR', BASE_PATH . '/templates/default'); define('STATIC_URL', ''); define('IMAGE_URL', ABSOLUTE_URL . 'images/'); define('LANGUAGE_DIR', BASE_PATH . '/language/'); define('TEMPLATES_DIR', 'templates/'); // Google stuff define('GOOGLE_ANALYTICS', \Neuron\Config::get('google.analytics.id')); define('DB_SERVER', \Neuron\Config::get('database.mysql.host')); define('DB_USERNAME', \Neuron\Config::get('database.mysql.username')); define('DB_PASSWORD', \Neuron\Config::get('database.mysql.password')); define('DB_DATABASE', \Neuron\Config::get('database.mysql.database')); define('MAILER_FROM', \Neuron\Config::get('mailer.from')); if (isset($_GET['language'])) { if (file_exists(LANGUAGE_DIR . $_GET['language']) && is_dir(LANGUAGE_DIR . $_GET['language'])) { setCookie('language', $_GET['language'], time() + 60 * 60 * 24 * 365, '/'); $_COOKIE['language'] = $_GET['language']; } } if (isset($_GET['layout'])) { if (file_exists(TEMPLATES_DIR . $_GET['layout']) && is_dir(TEMPLATES_DIR . $_GET['layout'])) { setCookie('layout', $_GET['layout'], time() + 60 * 60 * 24 * 365, '/'); $_COOKIE['layout'] = $_GET['layout']; } } // Get right language tag if (isset($_COOKIE['language'])) { define('LANGUAGE_TAG', $_COOKIE['language']);
<?php $loader = (require_once 'vendor/autoload.php'); // Start the app $app = \Neuron\Application::getInstance(); // Set config folder \Neuron\Config::folder(__DIR__ . '/../example/config/');
private static function calculateBaseString(array $data) { unset($data['signature']); $txt = '\\(^-^)/ !Stupid Rainbow Tables! \\(^-^)/ '; foreach ($data as $k => $v) { $txt .= $k . ":" . json_encode($v) . "|"; } $txt .= Config::get('app.secret'); return $txt; }