/**
  * checks whether a user needs a login and is loggedin
  * otherwise redirect to login page
  *
  * @return void
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // allways allow silent update (for easy cronjob)
     if ($request->getControllerName() == 'update' && $request->getActionName() == 'silent') {
         return;
     }
     // show login
     if ($request->getParam('login', false) !== false) {
         $request->setControllerName('index');
         $request->setActionName('login');
         return;
     }
     // logout?
     if ($request->getParam('logout', false) !== false) {
         Zend_Registry::get('session')->__unset('authenticated');
         $request->setControllerName('index');
         $request->setActionName('login');
         return;
     }
     // disallow readonly mode if user has option public not set
     if (Zend_Registry::get('session')->authenticated === 'readonly' && Zend_Registry::get('session')->public != 1) {
         Zend_Registry::get('session')->authenticated = false;
     }
     // check whether user loggedin or public access allowed
     if (Zend_Registry::get('session')->authenticated !== true && Zend_Registry::get('session')->authenticated !== 'readonly') {
         // no login required?
         $users = new application_models_users();
         if (!$users->getUsername()) {
             Zend_Registry::get('session')->authenticated = true;
             // public access allowed? start public mode
         } elseif (Zend_Registry::get('session')->public == 1) {
             Zend_Registry::get('session')->authenticated = 'readonly';
             // unallowed access -> show login window
         } else {
             $request->setControllerName('index');
             $request->setActionName('login');
             return;
         }
     }
     // load default values 4 readonly mode
     if (Zend_Registry::get('session')->authenticated === 'readonly') {
         $priorityStart = Zend_Registry::get('session')->priorityStart;
         $priorityEnd = Zend_Registry::get('session')->priorityEnd;
         // reset session with default config from config.ini
         Zend_Registry::get('bootstrap')->resetSession(false);
         // set priority slider
         Zend_Registry::get('session')->currentPriorityStart = $priorityStart;
         Zend_Registry::get('session')->currentPriorityEnd = $priorityEnd;
         Zend_Registry::get('session')->priorityStart = $priorityStart;
         Zend_Registry::get('session')->priorityEnd = $priorityEnd;
     }
     // don't allow any changings in readonly mode
     if (Zend_Registry::get('session')->authenticated !== true) {
         if ($request->getControllerName() != 'error' && $request->getControllerName() != 'index' && $request->getControllerName() != 'patch' && !($request->getControllerName() == 'item' && $request->getActionName() == 'list') && !($request->getControllerName() == 'item' && $request->getActionName() == 'listmore') && !($request->getControllerName() == 'update' && $request->getActionName() == 'silent')) {
             die('access denied');
         }
     }
 }
 /**
  * Save new settings
  *
  * @return void
  */
 public function saveAction()
 {
     // suppress view rendering
     Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
     // save username password
     $activateLogin = $this->getRequest()->getParam('activate_login');
     $username = $this->getRequest()->getParam('username', false);
     $password = $this->getRequest()->getParam('password', false);
     $passwordAgain = $this->getRequest()->getParam('password_again', false);
     $result = array();
     // deactivate login
     if ($activateLogin == '0') {
         $this->removeLogin();
         // activate login
     } else {
         // any data changed?
         $user = new application_models_users();
         if ($username != $user->getUsername() || strlen($password) != 0) {
             if ($password != $passwordAgain) {
                 $result = array('password_again' => Zend_Registry::get('language')->translate('given passwords not equal'));
             } else {
                 if (strlen(trim($password)) != 0 && strlen(trim($username)) == 0) {
                     $result = array('username' => Zend_Registry::get('language')->translate('if you set a password you must set an username'));
                 } else {
                     $this->saveLogin($username, $password);
                 }
             }
         }
     }
     $newSettings = $this->getRequest()->getPost();
     // save new settings
     if (count($result) == 0) {
         $settingsModel = new application_models_settings();
         $result = $settingsModel->save($newSettings);
     }
     // delete cached js files (for language settings)
     $target = Zend_Registry::get('config')->pub->path . 'javascript/' . Zend_Registry::get('config')->cache->minifiedjsfile;
     if (file_exists($target)) {
     }
     unlink($target);
     // return result (errors or success)
     $this->_helper->json($result);
 }
Exemplo n.º 3
0
 /**
  * show main window
  *
  * @return void
  */
 public function indexAction()
 {
     // include DetectMobile lib
     require_once Zend_Registry::get('config')->includePaths->library . '/rsslounge/DetectMobile.php';
     // prepare icon cache
     Zend_Controller_Action_HelperBroker::getStaticHelper('icon')->generateIconImage();
     // stop if ie is current browser
     $browser = @get_browser();
     if (isset($browser->browser) && get_browser()->browser == 'IE' && get_browser()->majorver == 6) {
         $this->_redirect('index/ie');
     }
     // update
     $this->checkDatabase();
     // load feedlist
     $this->feedlistData();
     // set unread if setting firstUnread is set and unread available
     if (Zend_Registry::get('session')->firstUnread == 1 && $this->view->unread > 0) {
         Zend_Registry::get('session')->unread = 1;
     }
     // convert session into array (for loading items)
     $settings = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter')->getSessionAsArray();
     // get list template vars
     $listHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('list');
     try {
         $listHelper->readItems($settings);
         $listHelper->setTemplateVars($this->view);
     } catch (Exception $e) {
         $this->view->messages = $e->getMessage();
     }
     // set new timeout for rss refresh in session settings
     Zend_Controller_Action_HelperBroker::getStaticHelper('updater')->timeout();
     // logout/login available?
     $users = new application_models_users();
     if ($users->getUsername() !== false && Zend_Registry::get('session')->authenticated === true) {
         $this->view->logout = true;
     } elseif (Zend_Registry::get('session')->authenticated === 'readonly') {
         $this->view->login = true;
     }
     // add new feed? Then show the dialog (for add feed bookmark)
     $this->view->newfeed = $this->getRequest()->getParam('url', '');
     // ipad detection
     $this->view->isIpad = (bool) strpos($_SERVER['HTTP_USER_AGENT'], 'iPad');
 }