javascriptController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class FreshRSS_javascript_Controller extends Minz_ActionController {
  3. public function firstAction() {
  4. $this->view->_useLayout(false);
  5. }
  6. public function actualizeAction() {
  7. header('Content-Type: text/javascript; charset=UTF-8');
  8. $feedDAO = FreshRSS_Factory::createFeedDao();
  9. $this->view->feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$conf->ttl_default);
  10. }
  11. public function nbUnreadsPerFeedAction() {
  12. header('Content-Type: application/json; charset=UTF-8');
  13. $catDAO = new FreshRSS_CategoryDAO();
  14. $this->view->categories = $catDAO->listCategories(true, false);
  15. }
  16. //For Web-form login
  17. public function nonceAction() {
  18. header('Content-Type: application/json; charset=UTF-8');
  19. header('Last-Modified: ' . gmdate('D, d M Y H:i:s \G\M\T'));
  20. header('Expires: 0');
  21. header('Cache-Control: private, no-cache, no-store, must-revalidate');
  22. header('Pragma: no-cache');
  23. $user = isset($_GET['user']) ? $_GET['user'] : '';
  24. if (ctype_alnum($user)) {
  25. try {
  26. $conf = new FreshRSS_Configuration($user);
  27. $s = $conf->passwordHash;
  28. if (strlen($s) >= 60) {
  29. $this->view->salt1 = substr($s, 0, 29); //CRYPT_BLOWFISH Salt: "$2a$", a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z".
  30. $this->view->nonce = sha1(Minz_Configuration::salt() . uniqid(mt_rand(), true));
  31. Minz_Session::_param('nonce', $this->view->nonce);
  32. return; //Success
  33. }
  34. } catch (Minz_Exception $me) {
  35. Minz_Log::warning('Nonce failure: ' . $me->getMessage());
  36. }
  37. } else {
  38. Minz_Log::notice('Nonce failure due to invalid username!');
  39. }
  40. $this->view->nonce = ''; //Failure
  41. $this->view->salt1 = '';
  42. }
  43. }