diff options
Diffstat (limited to 'app')
35 files changed, 311 insertions, 125 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 9decba431..1398e4e49 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -113,6 +113,10 @@ class FreshRSS_auth_Controller extends Minz_ActionController { $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'); Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . $file_mtime)); + $conf = Minz_Configuration::get('system'); + $limits = $conf->limits; + $this->view->cookie_days = round($limits['cookie_duration'] / 86400, 1); + if (Minz_Request::isPost()) { $nonce = Minz_Session::param('nonce'); $username = Minz_Request::param('username', ''); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c4115584a..f71f26a4e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -27,6 +27,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } public static function addFeed($url, $title = '', $cat_id = 0, $new_cat_name = '', $http_auth = '') { + FreshRSS_UserDAO::touch(); @set_time_limit(300); $catDAO = new FreshRSS_CategoryDAO(); @@ -484,6 +485,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($feed_id <= 0 || $feed_name == '') { return false; } + FreshRSS_UserDAO::touch(); $feedDAO = FreshRSS_Factory::createFeedDao(); return $feedDAO->updateFeed($feed_id, array('name' => $feed_name)); } @@ -492,6 +494,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($feed_id <= 0 || ($cat_id <= 0 && $new_cat_name == '')) { return false; } + FreshRSS_UserDAO::touch(); $catDAO = new FreshRSS_CategoryDAO(); if ($cat_id > 0) { @@ -540,6 +543,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } public static function deleteFeed($feed_id) { + FreshRSS_UserDAO::touch(); $feedDAO = FreshRSS_Factory::createFeedDao(); if ($feedDAO->deleteFeed($feed_id)) { // TODO: Delete old favicon diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 3ba91a243..6ae89defb 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -531,6 +531,8 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->entryDAO = FreshRSS_Factory::createEntryDao($username); $this->feedDAO = FreshRSS_Factory::createFeedDao($username); + $this->entryDAO->disableBuffering(); + if ($export_feeds === true) { //All feeds $export_feeds = $this->feedDAO->listFeedsIds(); @@ -641,13 +643,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->view->list_title = _t('sub.import_export.starred_list'); $this->view->type = 'starred'; $unread_fav = $this->entryDAO->countUnreadReadFavorites(); - $this->view->entries = $this->entryDAO->listWhere( + $this->view->entriesRaw = $this->entryDAO->listWhereRaw( 's', '', FreshRSS_Entry::STATE_ALL, 'ASC', $unread_fav['all'] ); } elseif ($type === 'feed' && $feed != null) { $this->view->list_title = _t('sub.import_export.feed_list', $feed->name()); $this->view->type = 'feed/' . $feed->id(); - $this->view->entries = $this->entryDAO->listWhere( + $this->view->entriesRaw = $this->entryDAO->listWhereRaw( 'f', $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC', $maxFeedEntries ); diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 64c984b04..8f939dbdb 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -2,6 +2,45 @@ class FreshRSS_update_Controller extends Minz_ActionController { + public static function isGit() { + return is_dir(FRESHRSS_PATH . '/.git/'); + } + + public static function hasGitUpdate() { + $cwd = getcwd(); + chdir(FRESHRSS_PATH); + $output = array(); + try { + exec('git fetch', $output, $return); + if ($return == 0) { + exec('git status -sb --porcelain remote', $output, $return); + } else { + $line = is_array($output) ? implode('; ', $output) : '' . $output; + Minz_Log::warning('git fetch warning:' . $line); + } + } catch (Exception $e) { + Minz_Log::warning('git fetch error:' . $e->getMessage()); + } + chdir($cwd); + $line = is_array($output) ? implode('; ', $output) : '' . $output; + return strpos($line, '[behind') !== false; + } + + public static function gitPull() { + $cwd = getcwd(); + chdir(FRESHRSS_PATH); + $output = array(); + $return = 1; + try { + exec('git pull --ff-only', $output, $return); + } catch (Exception $e) { + Minz_Log::warning('git pull error:' . $e->getMessage()); + } + chdir($cwd); + $line = is_array($output) ? implode('; ', $output) : '' . $output; + return $return == 0 ? true : 'Git error: ' . $line; + } + public function firstAction() { if (!FreshRSS_Auth::hasAccess('admin')) { Minz_Error::error(403); @@ -20,7 +59,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { public function indexAction() { Minz_View::prependTitle(_t('admin.update.title') . ' · '); - if (file_exists(UPDATE_FILENAME) && !is_writable(FRESHRSS_PATH)) { + if (!is_writable(FRESHRSS_PATH)) { $this->view->message = array( 'status' => 'bad', 'title' => _t('gen.short.damn'), @@ -53,49 +92,65 @@ class FreshRSS_update_Controller extends Minz_ActionController { return; } - $auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '?v=' . FRESHRSS_VERSION; - $c = curl_init($auto_update_url); - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); - curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2); - $result = curl_exec($c); - $c_status = curl_getinfo($c, CURLINFO_HTTP_CODE); - $c_error = curl_error($c); - curl_close($c); - - if ($c_status !== 200) { - Minz_Log::warning( - 'Error during update (HTTP code ' . $c_status . '): ' . $c_error - ); + $script = ''; + $version = ''; - $this->view->message = array( - 'status' => 'bad', - 'title' => _t('gen.short.damn'), - 'body' => _t('feedback.update.server_not_found', $auto_update_url) - ); - return; - } - - $res_array = explode("\n", $result, 2); - $status = $res_array[0]; - if (strpos($status, 'UPDATE') !== 0) { - $this->view->message = array( - 'status' => 'bad', - 'title' => _t('gen.short.damn'), - 'body' => _t('feedback.update.none') - ); + if (self::isGit()) { + if (self::hasGitUpdate()) { + $version = 'git'; + } else { + $this->view->message = array( + 'status' => 'bad', + 'title' => _t('gen.short.damn'), + 'body' => _t('feedback.update.none') + ); + @touch(join_path(DATA_PATH, 'last_update.txt')); + return; + } + } else { + $auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '?v=' . FRESHRSS_VERSION; + Minz_Log::debug('HTTP GET ' . $auto_update_url); + $c = curl_init($auto_update_url); + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); + curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2); + $result = curl_exec($c); + $c_status = curl_getinfo($c, CURLINFO_HTTP_CODE); + $c_error = curl_error($c); + curl_close($c); + + if ($c_status !== 200) { + Minz_Log::warning( + 'Error during update (HTTP code ' . $c_status . '): ' . $c_error + ); + + $this->view->message = array( + 'status' => 'bad', + 'title' => _t('gen.short.damn'), + 'body' => _t('feedback.update.server_not_found', $auto_update_url) + ); + return; + } - @touch(join_path(DATA_PATH, 'last_update.txt')); + $res_array = explode("\n", $result, 2); + $status = $res_array[0]; + if (strpos($status, 'UPDATE') !== 0) { + $this->view->message = array( + 'status' => 'bad', + 'title' => _t('gen.short.damn'), + 'body' => _t('feedback.update.none') + ); + @touch(join_path(DATA_PATH, 'last_update.txt')); + return; + } - return; + $script = $res_array[1]; + $version = explode(' ', $status, 2); + $version = $version[1]; } - $script = $res_array[1]; if (file_put_contents(UPDATE_FILENAME, $script) !== false) { - $version = explode(' ', $status, 2); - $version = $version[1]; @file_put_contents(join_path(DATA_PATH, 'last_update.txt'), $version); - Minz_Request::forward(array('c' => 'update'), true); } else { $this->view->message = array( @@ -111,10 +166,13 @@ class FreshRSS_update_Controller extends Minz_ActionController { Minz_Request::forward(array('c' => 'update'), true); } - require(UPDATE_FILENAME); - if (Minz_Request::param('post_conf', false)) { - $res = do_post_update(); + if (self::isGit()) { + $res = !self::hasGitUpdate(); + } else { + require(UPDATE_FILENAME); + $res = do_post_update(); + } Minz_ExtensionManager::callHook('post_update'); @@ -126,14 +184,21 @@ class FreshRSS_update_Controller extends Minz_ActionController { Minz_Request::bad(_t('feedback.update.error', $res), array('c' => 'update', 'a' => 'index')); } - } - - if (Minz_Request::isPost()) { - save_info_update(); - } + } else { + $res = false; - if (!need_info_update()) { - $res = apply_update(); + if (self::isGit()) { + $res = self::gitPull(); + } else { + if (Minz_Request::isPost()) { + save_info_update(); + } + if (!need_info_update()) { + $res = apply_update(); + } else { + return; + } + } if ($res === true) { Minz_Request::forward(array( diff --git a/app/Models/Auth.php b/app/Models/Auth.php index b93942e19..b3255cfbd 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -25,7 +25,7 @@ class FreshRSS_Auth { self::giveAccess(); } elseif (self::accessControl()) { self::giveAccess(); - FreshRSS_UserDAO::touch($current_user); + FreshRSS_UserDAO::touch(); } else { // Be sure all accesses are removed! self::removeAccess(); @@ -219,8 +219,8 @@ class FreshRSS_FormAuth { } public static function makeCookie($username, $password_hash) { + $conf = Minz_Configuration::get('system'); do { - $conf = Minz_Configuration::get('system'); $token = sha1($conf->salt . $username . uniqid(mt_rand(), true)); $token_file = DATA_PATH . '/tokens/' . $token . '.txt'; } while (file_exists($token_file)); @@ -229,15 +229,17 @@ class FreshRSS_FormAuth { return false; } - $expire = time() + 2629744; //1 month //TODO: Use a configuration instead + $limits = $conf->limits; + $cookie_duration = empty($limits['cookie_duration']) ? 2629744 : $limits['cookie_duration']; + $expire = time() + $cookie_duration; Minz_Session::setLongTermCookie('FreshRSS_login', $token, $expire); return $token; } public static function deleteCookie() { $token = Minz_Session::getLongTermCookie('FreshRSS_login'); - Minz_Session::deleteLongTermCookie('FreshRSS_login'); if (ctype_alnum($token)) { + Minz_Session::deleteLongTermCookie('FreshRSS_login'); @unlink(DATA_PATH . '/tokens/' . $token . '.txt'); } @@ -247,7 +249,10 @@ class FreshRSS_FormAuth { } public static function purgeTokens() { - $oldest = time() - 2629744; // 1 month // TODO: Use a configuration instead + $conf = Minz_Configuration::get('system'); + $limits = $conf->limits; + $cookie_duration = empty($limits['cookie_duration']) ? 2629744 : $limits['cookie_duration']; + $oldest = time() - $cookie_duration; foreach (new DirectoryIterator(DATA_PATH . '/tokens/') as $file_info) { // $extension = $file_info->getExtension(); doesn't work in PHP < 5.3.7 $extension = pathinfo($file_info->getFilename(), PATHINFO_EXTENSION); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 58f2c1a79..397471baa 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -241,6 +241,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { if (count($ids) < 1) { return 0; } + FreshRSS_UserDAO::touch(); $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET is_favorite=? ' . 'WHERE id IN (' . str_repeat('?,', count($ids) - 1). '?)'; @@ -315,6 +316,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * @return integer affected rows */ public function markRead($ids, $is_read = true) { + FreshRSS_UserDAO::touch(); if (is_array($ids)) { //Many IDs at once (used by API) if (count($ids) < 6) { //Speed heuristics $affected = 0; @@ -379,6 +381,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * @return integer affected rows */ public function markReadEntries($idMax = 0, $onlyFavorites = false, $priorityMin = 0, $filter = null, $state = 0) { + FreshRSS_UserDAO::touch(); if ($idMax == 0) { $idMax = time() . '000000'; Minz_Log::debug('Calling markReadEntries(0) is deprecated!'); @@ -421,6 +424,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * @return integer affected rows */ public function markReadCat($id, $idMax = 0, $filter = null, $state = 0) { + FreshRSS_UserDAO::touch(); if ($idMax == 0) { $idMax = time() . '000000'; Minz_Log::debug('Calling markReadCat(0) is deprecated!'); @@ -458,6 +462,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { * @return integer affected rows */ public function markReadFeed($id_feed, $idMax = 0, $filter = null, $state = 0) { + FreshRSS_UserDAO::touch(); if ($idMax == 0) { $idMax = time() . '000000'; Minz_Log::debug('Calling markReadFeed(0) is deprecated!'); @@ -513,7 +518,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm->execute($values); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $entries = self::daoToEntry($res); + $entries = self::daoToEntries($res); return isset($entries[0]) ? $entries[0] : null; } @@ -528,7 +533,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm->execute($values); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $entries = self::daoToEntry($res); + $entries = self::daoToEntries($res); return isset($entries[0]) ? $entries[0] : null; } @@ -661,7 +666,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { . ($limit > 0 ? ' LIMIT ' . $limit : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ } - public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { + public function listWhereRaw($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); $sql = 'SELECT e0.id, e0.guid, e0.title, e0.author, ' @@ -675,8 +680,12 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $stm = $this->bd->prepare($sql); $stm->execute($values); + return $stm; + } - return self::daoToEntry($stm->fetchAll(PDO::FETCH_ASSOC)); + public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { + $stm = $this->listWhereRaw($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); + return self::daoToEntries($stm->fetchAll(PDO::FETCH_ASSOC)); } public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { //For API @@ -805,15 +814,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $res[0]; } - public static function daoToEntry($listDAO) { - $list = array(); - - if (!is_array($listDAO)) { - $listDAO = array($listDAO); - } - - foreach ($listDAO as $key => $dao) { - $entry = new FreshRSS_Entry( + public static function daoToEntry($dao) { + $entry = new FreshRSS_Entry( $dao['id_feed'], $dao['guid'], $dao['title'], @@ -825,10 +827,21 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $dao['is_favorite'], $dao['tags'] ); - if (isset($dao['id'])) { - $entry->_id($dao['id']); - } - $list[] = $entry; + if (isset($dao['id'])) { + $entry->_id($dao['id']); + } + return $entry; + } + + private static function daoToEntries($listDAO) { + $list = array(); + + if (!is_array($listDAO)) { + $listDAO = array($listDAO); + } + + foreach ($listDAO as $key => $dao) { + $list[] = self::daoToEntry($dao); } unset($listDAO); diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 764987c46..6502c38b7 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -6,6 +6,7 @@ class FreshRSS_Factory { $conf = Minz_Configuration::get('system'); switch ($conf->db['type']) { case 'sqlite': + case 'pgsql': return new FreshRSS_FeedDAOSQLite($username); default: return new FreshRSS_FeedDAO($username); diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index a95ee6bc4..32bc6de2f 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -84,7 +84,10 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { return is_dir(join_path(DATA_PATH , 'users', $username)); } - public static function touch($username) { + public static function touch($username = '') { + if (($username == '') || (!ctype_alnum($username))) { + $username = Minz_Session::param('currentUser', '_'); + } return touch(join_path(DATA_PATH , 'users', $username, 'config.php')); } diff --git a/app/i18n/cz/admin.php b/app/i18n/cz/admin.php index 84bc58a17..63cee3cca 100644 --- a/app/i18n/cz/admin.php +++ b/app/i18n/cz/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Tabulka kanálů je nastavena špatně.', 'ok' => 'Tabulka kanálů je v pořádku.', ), + 'fileinfo' => array( + 'nok' => 'Nemáte PHP fileinfo (balíček fileinfo).', + 'ok' => 'Máte rozšíření fileinfo.', + ), 'files' => 'Instalace souborů', 'json' => array( 'nok' => 'Nemáte JSON (balíček php5-json).', diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php index e73325c55..3db3a31da 100644 --- a/app/i18n/cz/gen.php +++ b/app/i18n/cz/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Email', - 'keep_logged_in' => 'Zapamatovat přihlášení <small>(1 měsíc)</small>', + 'keep_logged_in' => 'Zapamatovat přihlášení <small>(%s dny)</small>', 'login' => 'Login', 'logout' => 'Odhlášení', 'password' => array( diff --git a/app/i18n/cz/install.php b/app/i18n/cz/install.php index c40ae46e2..ea4812ea5 100644 --- a/app/i18n/cz/install.php +++ b/app/i18n/cz/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Zkontrolujte oprávnění adresáře <em>./data/favicons</em>. HTTP server musí mít do tohoto adresáře práva zápisu', 'ok' => 'Oprávnění adresáře favicons jsou v pořádku.', ), + 'fileinfo' => array( + 'nok' => 'Nemáte PHP fileinfo (balíček fileinfo).', + 'ok' => 'Máte rozšíření fileinfo.', + ), 'http_referer' => array( 'nok' => 'Zkontrolujte prosím že neměníte HTTP REFERER.', 'ok' => 'Váš HTTP REFERER je znám a odpovídá Vašemu serveru.', diff --git a/app/i18n/de/admin.php b/app/i18n/de/admin.php index c12f32bc8..8fc43a7bb 100644 --- a/app/i18n/de/admin.php +++ b/app/i18n/de/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Die Tabelle <em>feed</em> ist schlecht konfiguriert.', 'ok' => 'Die Tabelle <em>feed</em> ist korrekt konfiguriert.', ), + 'fileinfo' => array( + 'nok' => 'Ihnen fehlt PHP fileinfo (Paket fileinfo).', + 'ok' => 'Sie haben die fileinfo-Erweiterung.', + ), 'files' => 'Datei-Installation', 'json' => array( 'nok' => 'Ihnen fehlt die JSON-Erweiterung (Paket php5-json).', diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index c6e7f1ef3..c73aedbfe 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'E-Mail-Adresse', - 'keep_logged_in' => 'Eingeloggt bleiben <small>(1 Monat)</small>', + 'keep_logged_in' => 'Eingeloggt bleiben <small>(%s Tage)</small>', 'login' => 'Anmelden', 'logout' => 'Abmelden', 'password' => array( diff --git a/app/i18n/de/install.php b/app/i18n/de/install.php index 178e8ea4c..b747d1551 100644 --- a/app/i18n/de/install.php +++ b/app/i18n/de/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Überprüfen Sie die Berechtigungen des Verzeichnisses <em>./data/favicons</em>. Der HTTP-Server muss Schreibrechte besitzen.', 'ok' => 'Die Berechtigungen des Verzeichnisses <em>./data/favicons</em> sind in Ordnung.', ), + 'fileinfo' => array( + 'nok' => 'Ihnen fehlt PHP fileinfo (Paket fileinfo).', + 'ok' => 'Sie haben die fileinfo-Erweiterung.', + ), 'http_referer' => array( 'nok' => 'Bitte stellen Sie sicher, dass Sie Ihren HTTP REFERER nicht abändern.', 'ok' => 'Ihr HTTP REFERER ist bekannt und entspricht Ihrem Server.', diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php index e5286d948..e94d9fa80 100644 --- a/app/i18n/en/admin.php +++ b/app/i18n/en/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Feed table is bad configured.', 'ok' => 'Feed table is ok.', ), + 'fileinfo' => array( + 'nok' => 'Cannot find the PHP fileinfo library (fileinfo package).', + 'ok' => 'You have the fileinfo library.', + ), 'files' => 'File installation', 'json' => array( 'nok' => 'Cannot find JSON (php5-json package).', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 17b47ba2f..3f86cfd19 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Email address', - 'keep_logged_in' => 'Keep me logged in <small>(1 month)</small>', + 'keep_logged_in' => 'Keep me logged in <small>(%s days)</small>', 'login' => 'Login', 'logout' => 'Logout', 'password' => array( diff --git a/app/i18n/en/install.php b/app/i18n/en/install.php index 63d31fe53..40fff37dd 100644 --- a/app/i18n/en/install.php +++ b/app/i18n/en/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Check permissions on <em>./data/favicons</em> directory. HTTP server must have rights to write into', 'ok' => 'Permissions on favicons directory are good.', ), + 'fileinfo' => array( + 'nok' => 'Cannot find the PHP fileinfo library (fileinfo package).', + 'ok' => 'You have the fileinfo library.', + ), 'http_referer' => array( 'nok' => 'Please check that you are not altering your HTTP REFERER.', 'ok' => 'Your HTTP REFERER is known and corresponds to your server.', diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.php index e9263a5e2..9a13ecc21 100644 --- a/app/i18n/fr/admin.php +++ b/app/i18n/fr/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'La table feed est mal configurée.', 'ok' => 'La table feed est bien configurée.', ), + 'fileinfo' => array( + 'nok' => 'Impossible de trouver la librairie PHP fileinfo (paquet fileinfo).', + 'ok' => 'Vous disposez de la librairie fileinfo.', + ), 'files' => 'Installation des fichiers', 'json' => array( 'nok' => 'Vous ne disposez pas de JSON (paquet php5-json).', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index d61a716a7..b5dc098ae 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Adresse courriel', - 'keep_logged_in' => 'Rester connecté <small>(1 mois)</small>', + 'keep_logged_in' => 'Rester connecté <small>(%s jours)</small>', 'login' => 'Connexion', 'logout' => 'Déconnexion', 'password' => array( diff --git a/app/i18n/fr/install.php b/app/i18n/fr/install.php index c50807107..09625de78 100644 --- a/app/i18n/fr/install.php +++ b/app/i18n/fr/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Veuillez vérifier les droits sur le répertoire <em>./data/favicons</em>. Le serveur HTTP doit être capable d’écrire dedans', 'ok' => 'Les droits sur le répertoire des favicons sont bons.', ), + 'fileinfo' => array( + 'nok' => 'Vous ne disposez pas de PHP fileinfo (paquet fileinfo).', + 'ok' => 'Vous disposez de fileinfo.', + ), 'http_referer' => array( 'nok' => 'Veuillez vérifier que vous ne modifiez pas votre HTTP REFERER.', 'ok' => 'Le HTTP REFERER est connu et semble correspondre à votre serveur.', diff --git a/app/i18n/it/admin.php b/app/i18n/it/admin.php index c399bc8c8..ae46818ae 100644 --- a/app/i18n/it/admin.php +++ b/app/i18n/it/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'La tabella Feed ha una configurazione errata.', 'ok' => 'Tabella Feed OK.', ), + 'fileinfo' => array( + 'nok' => 'Manca il supporto per PHP fileinfo (pacchetto fileinfo).', + 'ok' => 'Estensione fileinfo presente.', + ), 'files' => 'Installazione files', 'json' => array( 'nok' => 'Manca il supoorto a JSON (pacchetto php5-json).', diff --git a/app/i18n/it/gen.php b/app/i18n/it/gen.php index c02ddd13a..a9a8709d3 100644 --- a/app/i18n/it/gen.php +++ b/app/i18n/it/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Indirizzo email', - 'keep_logged_in' => 'Ricorda i dati <small>(1 mese)</small>', + 'keep_logged_in' => 'Ricorda i dati <small>(%s giorni)</small>', 'login' => 'Accedi', 'logout' => 'Esci', 'password' => array( diff --git a/app/i18n/it/install.php b/app/i18n/it/install.php index 2fa298508..18f8cc337 100644 --- a/app/i18n/it/install.php +++ b/app/i18n/it/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Verifica i permessi sulla cartella <em>./data/favicons</em>. Il server HTTP deve avere i permessi per scriverci dentro', 'ok' => 'I permessi sulla cartella favicons sono corretti.', ), + 'fileinfo' => array( + 'nok' => 'Manca il supporto per PHP fileinfo (pacchetto fileinfo).', + 'ok' => 'Estensione fileinfo presente.', + ), 'http_referer' => array( 'nok' => 'Per favore verifica che non stai alterando il tuo HTTP REFERER.', 'ok' => 'Il tuo HTTP REFERER riconosciuto corrisponde al tuo server.', diff --git a/app/i18n/nl/admin.php b/app/i18n/nl/admin.php index 59637bfef..607fb1892 100644 --- a/app/i18n/nl/admin.php +++ b/app/i18n/nl/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Feed tabel is slecht geconfigureerd.', 'ok' => 'Feed tabel is ok.', ), + 'fileinfo' => array( + 'nok' => 'U mist de PHP fileinfo (fileinfo package).', + 'ok' => 'U hebt de fileinfo uitbreiding.', + ), 'files' => 'Bestanden installatie', 'json' => array( 'nok' => 'U mist JSON (php5-json package).', diff --git a/app/i18n/nl/gen.php b/app/i18n/nl/gen.php index 7e03229c9..83811ce68 100644 --- a/app/i18n/nl/gen.php +++ b/app/i18n/nl/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Email adres', - 'keep_logged_in' => 'Ingelogd blijven voor <small>(1 maand)</small>', + 'keep_logged_in' => 'Ingelogd blijven voor <small>(%s dagen)</small>', 'login' => 'Log in', 'logout' => 'Log uit', 'password' => array( diff --git a/app/i18n/nl/install.php b/app/i18n/nl/install.php index bd2ba0cce..79db9c794 100644 --- a/app/i18n/nl/install.php +++ b/app/i18n/nl/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Controleer permissies van de <em>./data/favicons</em> map. HTTP server moet rechten hebben om er in te kunnen schrijven', 'ok' => 'Permissies van de favicons map zijn goed.', ), + 'fileinfo' => array( + 'nok' => 'U mist PHP fileinfo (fileinfo package).', + 'ok' => 'U hebt de fileinfo uitbreiding.', + ), 'http_referer' => array( 'nok' => 'Controleer a.u.b. dat u niet uw HTTP REFERER wijzigd.', 'ok' => 'Uw HTTP REFERER is bekend en komt overeen met uw server.', diff --git a/app/i18n/ru/admin.php b/app/i18n/ru/admin.php index 355100689..f5da97371 100644 --- a/app/i18n/ru/admin.php +++ b/app/i18n/ru/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Таблица подписок (feed) неправильно настроена.', 'ok' => 'Таблица подписок (feed) настроена правильно.', ), + 'fileinfo' => array( + 'nok' => 'У вас не установлено расширение PHP fileinfo (пакет fileinfo).', + 'ok' => 'У вас установлено расширение fileinfo.', + ), 'files' => 'Установка файлов', 'json' => array( 'nok' => 'У вас не установлена библиотека для работы с JSON (пакет php5-json).', diff --git a/app/i18n/ru/gen.php b/app/i18n/ru/gen.php index eecd72749..bc42afaa8 100644 --- a/app/i18n/ru/gen.php +++ b/app/i18n/ru/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Email address', - 'keep_logged_in' => 'Keep me logged in <small>(1 month)</small>', + 'keep_logged_in' => 'Keep me logged in <small>(%s дней)</small>', 'login' => 'Login', 'logout' => 'Logout', 'password' => array( diff --git a/app/i18n/ru/install.php b/app/i18n/ru/install.php index bad59bbb3..1dea2cd66 100644 --- a/app/i18n/ru/install.php +++ b/app/i18n/ru/install.php @@ -56,6 +56,10 @@ return array( 'nok' => 'Проверьте права доступа к папке <em>./data/favicons</em> . Сервер HTTP должен иметь права на запись в эту папку.', 'ok' => 'Права на папку значков в порядке.', ), + 'fileinfo' => array( + 'nok' => 'У вас нет расширения PHP fileinfo (пакет fileinfo).', + 'ok' => 'У вас установлено расширение fileinfo.', + ), 'http_referer' => array( 'nok' => 'Убедитесь, что вы не изменяете ваш HTTP REFERER.', 'ok' => 'Ваш HTTP REFERER известен и соотвествует вашему серверу.', diff --git a/app/i18n/tr/admin.php b/app/i18n/tr/admin.php index e0dbd288d..9d10ef9dd 100644 --- a/app/i18n/tr/admin.php +++ b/app/i18n/tr/admin.php @@ -57,6 +57,10 @@ return array( 'nok' => 'Akış tablosu kötü yapılandırılmış.', 'ok' => 'Akış tablosu sorunsuz.', ), + 'fileinfo' => array( + 'nok' => 'PHP fileinfo eksik (fileinfo package).', + 'ok' => 'fileinfo eklentisi sorunsuz.', + ), 'files' => 'Dosya kurulumu', 'json' => array( 'nok' => 'JSON eklentisi eksik (php5-json package).', diff --git a/app/i18n/tr/gen.php b/app/i18n/tr/gen.php index 865dbd4e2..bcc839daf 100644 --- a/app/i18n/tr/gen.php +++ b/app/i18n/tr/gen.php @@ -22,7 +22,7 @@ return array( ), 'auth' => array( 'email' => 'Email adresleri', - 'keep_logged_in' => '<small>(1 ay)</small> oturumu açık tut', + 'keep_logged_in' => '<small>(%s günler)</small> oturumu açık tut', 'login' => 'Giriş', 'logout' => 'Çıkış', 'password' => array( diff --git a/app/i18n/tr/install.php b/app/i18n/tr/install.php index 4daa45099..d5564297b 100644 --- a/app/i18n/tr/install.php +++ b/app/i18n/tr/install.php @@ -56,6 +56,10 @@ return array( 'nok' => '<em>./data/favicons</em> klasör yetkisini kontrol edin. HTTP yazma yetkisi olmalı', 'ok' => 'Site ikonu klasörü yetkileri sorunsuz.', ), + 'fileinfo' => array( + 'nok' => 'PHP fileinfo eksik (fileinfo package).', + 'ok' => 'fileinfo eklentisi sorunsuz.', + ), 'http_referer' => array( 'nok' => 'Lütfen HTTP REFERER değiştirmediğinize emin olun.', 'ok' => 'HTTP REFERER ve sunucunuz arası iletişim sorunsuz.', diff --git a/app/install.php b/app/install.php index fcc901713..986a7dc60 100644 --- a/app/install.php +++ b/app/install.php @@ -230,7 +230,7 @@ function saveStep3() { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } else { - $_SESSION['bd_error'] = empty($config_array['db']['bd_error']) ? 'Unknown error!' : $config_array['db']['bd_error']; + $_SESSION['bd_error'] = empty($config_array['db']['error']) ? 'Unknown error!' : $config_array['db']['error']; } } invalidateHttpCache(); @@ -375,7 +375,7 @@ function checkDbUser(&$dbOptions) { } } catch (PDOException $e) { $ok = false; - $dbOptions['bd_error'] = $e->getMessage(); + $dbOptions['error'] = $e->getMessage(); } return $ok; } @@ -478,6 +478,12 @@ function printStep1() { <p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.xml.nok'); ?></p> <?php } ?> + <?php if ($res['fileinfo'] == 'ok') { ?> + <p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.fileinfo.ok'); ?></p> + <?php } else { ?> + <p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.fileinfo.nok'); ?></p> + <?php } ?> + <?php if ($res['data'] == 'ok') { ?> <p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.data.ok'); ?></p> <?php } else { ?> @@ -634,7 +640,7 @@ function printStep3() { <div class="form-group"> <label class="group-name" for="host"><?php echo _t('install.bdd.host'); ?></label> <div class="group-controls"> - <input type="text" id="host" name="host" pattern="[0-9A-Za-z_.-]{1,64}(:[0-9]{2,5})?" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" /> + <input type="text" id="host" name="host" pattern="[0-9A-Z/a-z_.-]{1,64}(:[0-9]{2,5})?" value="<?php echo isset($_SESSION['bd_host']) ? $_SESSION['bd_host'] : $system_default_config->db['host']; ?>" tabindex="2" /> </div> </div> diff --git a/app/views/auth/formLogin.phtml b/app/views/auth/formLogin.phtml index 4bbc8ed55..a8213b7ae 100644 --- a/app/views/auth/formLogin.phtml +++ b/app/views/auth/formLogin.phtml @@ -20,7 +20,7 @@ <div> <label class="checkbox" for="keep_logged_in"> <input type="checkbox" name="keep_logged_in" id="keep_logged_in" value="1" /> - <?php echo _t('gen.auth.keep_logged_in'); ?> + <?php echo _t('gen.auth.keep_logged_in', $this->cookie_days); ?> </label> <br /> </div> diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml index ffdca1daa..49c370023 100644 --- a/app/views/helpers/export/articles.phtml +++ b/app/views/helpers/export/articles.phtml @@ -1,47 +1,66 @@ <?php - $username = Minz_Session::param('currentUser', '_'); +$username = Minz_Session::param('currentUser', '_'); - $articles = array( - 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type, - 'title' => $this->list_title, - 'author' => $username, - 'items' => array() - ); +$options = 0; +if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; +} - foreach ($this->entries as $entry) { - if (!isset($this->feed)) { - $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed ()); - } else { - $feed = $this->feed; - } +$articles = array( + 'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type, + 'title' => $this->list_title, + 'author' => $username, + 'items' => array(), +); - $articles['items'][] = array( - 'id' => $entry->guid(), - 'categories' => array_values($entry->tags()), - 'title' => $entry->title(), - 'author' => $entry->author(), - 'published' => $entry->date(true), - 'updated' => $entry->date(true), - 'alternate' => array(array( - 'href' => $entry->link(), - 'type' => 'text/html' - )), - 'content' => array( - 'content' => $entry->content() - ), - 'origin' => array( - 'streamId' => $feed->id(), - 'title' => $feed->name(), - 'htmlUrl' => $feed->website(), - 'feedUrl' => $feed->url() - ) - ); - } +echo rtrim(json_encode($articles, $options), " ]}\n\r\t"), "\n"; +$first = true; - $options = 0; - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { - $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; - } +foreach ($this->entriesRaw as $entryRaw) { + if (empty($entryRaw)) { + continue; + } + $entry = FreshRSS_EntryDAO::daoToEntry($entryRaw); + if (!isset($this->feed)) { + $feed = FreshRSS_CategoryDAO::findFeed($this->categories, $entry->feed()); + if ($feed == null) { + $feed = $entry->feed(true); + } + } else { + $feed = $this->feed; + } - echo json_encode($articles, $options); -?> + $article = array( + 'id' => $entry->guid(), + 'categories' => array_values($entry->tags()), + 'title' => $entry->title(), + 'author' => $entry->author(), + 'published' => $entry->date(true), + 'updated' => $entry->date(true), + 'alternate' => array(array( + 'href' => $entry->link(), + 'type' => 'text/html', + )), + 'content' => array( + 'content' => $entry->content(), + ), + 'origin' => array( + 'streamId' => $feed == null ? '' : $feed->id(), + 'title' => $feed == null ? '' : $feed->name(), + 'htmlUrl' => $feed == null ? '' : $feed->website(), + 'feedUrl' => $feed == null ? '' : $feed->url(), + ) + ); + + $line = json_encode($article, $options); + if ($line != '') { + if ($first) { + $first = false; + } else { + echo ",\n"; + } + echo $line; + } +} + +echo "\n]}\n"; |
