|
|
@@ -1,50 +1,50 @@
|
|
|
<?php
|
|
|
+
|
|
|
class FreshRSS extends Minz_FrontController {
|
|
|
public function init() {
|
|
|
if (!isset($_SESSION)) {
|
|
|
Minz_Session::init('FreshRSS');
|
|
|
}
|
|
|
|
|
|
+ // Need to be called just after session init because it initializes
|
|
|
+ // current user.
|
|
|
FreshRSS_Auth::init();
|
|
|
- $this->loadConfiguration();
|
|
|
- $this->loadParamsView();
|
|
|
+
|
|
|
if (Minz_Request::isPost() && !is_referer_from_same_domain()) {
|
|
|
- //Basic protection against XSRF attacks
|
|
|
+ // Basic protection against XSRF attacks
|
|
|
FreshRSS_Auth::removeAccess();
|
|
|
+ $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
|
|
Minz_Error::error(
|
|
|
403,
|
|
|
- array('error' => array(_t('access_denied') . ' [HTTP_REFERER=' .
|
|
|
- htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']'))
|
|
|
+ array('error' => array(
|
|
|
+ _t('access_denied'),
|
|
|
+ ' [HTTP_REFERER=' . htmlspecialchars($http_referer) . ']'
|
|
|
+ ))
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ // Load context and configuration.
|
|
|
+ // TODO: remove $this->view->conf variable which is contained in context
|
|
|
+ FreshRSS_Context::init();
|
|
|
+ Minz_View::_param('conf', FreshRSS_Context::$conf);
|
|
|
+
|
|
|
+ $this->loadParamsView();
|
|
|
$this->loadStylesAndScripts();
|
|
|
$this->loadNotifications();
|
|
|
$this->loadExtensions();
|
|
|
}
|
|
|
|
|
|
- private function loadConfiguration() {
|
|
|
- $current_user = Minz_Session::param('currentUser');
|
|
|
- try {
|
|
|
- $this->conf = new FreshRSS_Configuration($current_user);
|
|
|
- Minz_View::_param('conf', $this->conf);
|
|
|
- } catch(Minz_Exception $e) {
|
|
|
- Minz_Log::error('Cannot load configuration file of user `' . $current_user . '`');
|
|
|
- die($e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private function loadParamsView() {
|
|
|
- Minz_Session::_param('language', $this->conf->language);
|
|
|
- Minz_Translate::init();
|
|
|
+ // TODO: outputs should be different actions.
|
|
|
$output = Minz_Request::param('output', '');
|
|
|
if (($output === '') || ($output !== 'normal' && $output !== 'rss' && $output !== 'reader' && $output !== 'global')) {
|
|
|
- $output = $this->conf->view_mode;
|
|
|
+ $output = FreshRSS_Context::$conf->view_mode;
|
|
|
Minz_Request::_param('output', $output);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function loadStylesAndScripts() {
|
|
|
- $theme = FreshRSS_Themes::load($this->conf->theme);
|
|
|
+ $theme = FreshRSS_Themes::load(FreshRSS_Context::$conf->theme);
|
|
|
if ($theme) {
|
|
|
foreach($theme['files'] as $file) {
|
|
|
if ($file[0] === '_') {
|