Exemplo n.º 1
0
 public function authAction()
 {
     if (Minz_Request::isPost()) {
         $ok = true;
         $passwordPlain = Minz_Request::param('passwordPlain', false);
         if ($passwordPlain != '') {
             Minz_Request::_param('passwordPlain');
             //Discard plain-text password ASAP
             $_POST['passwordPlain'] = '';
             if (!function_exists('password_hash')) {
                 include_once LIB_PATH . '/password_compat.php';
             }
             $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST));
             $passwordPlain = '';
             $passwordHash = preg_replace('/^\\$2[xy]\\$/', '\\$2a\\$', $passwordHash);
             //Compatibility with bcrypt.js
             $ok &= $passwordHash != '';
             $this->view->conf->_passwordHash($passwordHash);
         }
         Minz_Session::_param('passwordHash', $this->view->conf->passwordHash);
         if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
             $this->view->conf->_mail_login(Minz_Request::param('mail_login', false));
         }
         $email = $this->view->conf->mail_login;
         Minz_Session::_param('mail', $email);
         $ok &= $this->view->conf->save();
         if ($email != '') {
             $personaFile = DATA_PATH . '/persona/' . $email . '.txt';
             @unlink($personaFile);
             $ok &= file_put_contents($personaFile, Minz_Session::param('currentUser', '_')) !== false;
         }
         if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
             $current_token = $this->view->conf->token;
             $token = Minz_Request::param('token', $current_token);
             $this->view->conf->_token($token);
             $ok &= $this->view->conf->save();
             $anon = Minz_Request::param('anon_access', false);
             $anon = (bool) $anon && $anon !== 'no';
             $anon_refresh = Minz_Request::param('anon_refresh', false);
             $anon_refresh = (bool) $anon_refresh && $anon_refresh !== 'no';
             $auth_type = Minz_Request::param('auth_type', 'none');
             if ($anon != Minz_Configuration::allowAnonymous() || $auth_type != Minz_Configuration::authType() || $anon_refresh != Minz_Configuration::allowAnonymousRefresh()) {
                 Minz_Configuration::_authType($auth_type);
                 Minz_Configuration::_allowAnonymous($anon);
                 Minz_Configuration::_allowAnonymousRefresh($anon_refresh);
                 $ok &= Minz_Configuration::writeFile();
             }
         }
         invalidateHttpCache();
         $notif = array('type' => $ok ? 'good' : 'bad', 'content' => Minz_Translate::t($ok ? 'configuration_updated' : 'error_occurred'));
         Minz_Session::_param('notification', $notif);
     }
     Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true);
 }
Exemplo n.º 2
0
foreach ($users as $myUser) {
    syslog(LOG_INFO, 'FreshRSS actualize ' . $myUser);
    if (defined('STDOUT')) {
        fwrite(STDOUT, 'Actualize ' . $myUser . "...\n");
        //Unbuffered
    }
    echo $myUser, ' ';
    //Buffered
    $_GET['c'] = 'feed';
    $_GET['a'] = 'actualize';
    $_GET['ajax'] = 1;
    $_GET['force'] = true;
    $_SERVER['HTTP_HOST'] = '';
    $freshRSS = new FreshRSS();
    $freshRSS->_useOb(false);
    Minz_Configuration::_authType('none');
    Minz_Session::init('FreshRSS');
    Minz_Session::_param('currentUser', $myUser);
    $freshRSS->init();
    $freshRSS->run();
    if (!invalidateHttpCache()) {
        syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . LOG_PATH . '/*.log!');
        if (defined('STDERR')) {
            fwrite(STDERR, 'Write access problem in ' . LOG_PATH . '/*.log!' . "\n");
        }
    }
    Minz_Session::unset_session(true);
    Minz_ModelPdo::clean();
}
syslog(LOG_INFO, 'FreshRSS actualize done.');
if (defined('STDOUT')) {