Selaa lähdekoodia

Cookie : sous-répertoire pour index (changements de répertoires !)

Implémente https://github.com/marienfressinaud/FreshRSS/issues/333
/public/ est renommé /p/
/public/index.php est déplacé dans /p/i/index.php
Le cookie de session est limité à /p/i/
Alexandre Alapetite 12 vuotta sitten
vanhempi
commit
58300c36ad
66 muutettua tiedostoa jossa 48 lisäystä ja 33 poistoa
  1. 2 2
      README.md
  2. 10 7
      constants.php
  3. 2 3
      index.html
  4. 3 0
      index.php
  5. 1 0
      lib/Minz/Session.php
  6. 9 6
      lib/Minz/Url.php
  7. 0 0
      p/.htaccess
  8. 0 0
      p/f.php
  9. 0 0
      p/favicon.ico
  10. 0 0
      p/favicon.png
  11. 1 1
      p/i/index.php
  12. 5 14
      p/i/install.php
  13. 12 0
      p/index.html
  14. 3 0
      p/index.php
  15. 0 0
      p/robots.txt
  16. 0 0
      p/scripts/global_view.js
  17. 0 0
      p/scripts/jquery-2.0.3.min.map
  18. 0 0
      p/scripts/jquery.lazyload.min.js
  19. 0 0
      p/scripts/jquery.min.js
  20. 0 0
      p/scripts/main.js
  21. 0 0
      p/scripts/shortcut.js
  22. 0 0
      p/themes/default/freshrss.css
  23. 0 0
      p/themes/default/global.css
  24. 0 0
      p/themes/default/loader.gif
  25. 0 0
      p/themes/default/metadata.json
  26. 0 0
      p/themes/flat-design/freshrss.css
  27. 0 0
      p/themes/flat-design/global.css
  28. 0 0
      p/themes/flat-design/icons/add.svg
  29. 0 0
      p/themes/flat-design/icons/all.svg
  30. 0 0
      p/themes/flat-design/icons/close.svg
  31. 0 0
      p/themes/flat-design/icons/configure.svg
  32. 0 0
      p/themes/flat-design/icons/down.svg
  33. 0 0
      p/themes/flat-design/icons/next.svg
  34. 0 0
      p/themes/flat-design/icons/prev.svg
  35. 0 0
      p/themes/flat-design/icons/refresh.svg
  36. 0 0
      p/themes/flat-design/icons/search.svg
  37. 0 0
      p/themes/flat-design/icons/up.svg
  38. 0 0
      p/themes/flat-design/loader.gif
  39. 0 0
      p/themes/flat-design/metadata.json
  40. 0 0
      p/themes/fonts/openSans.woff
  41. 0 0
      p/themes/icons/add.svg
  42. 0 0
      p/themes/icons/all.svg
  43. 0 0
      p/themes/icons/bookmark.svg
  44. 0 0
      p/themes/icons/category-white.svg
  45. 0 0
      p/themes/icons/category.svg
  46. 0 0
      p/themes/icons/close.svg
  47. 0 0
      p/themes/icons/configure.svg
  48. 0 0
      p/themes/icons/down.svg
  49. 0 0
      p/themes/icons/grey.gif
  50. 0 0
      p/themes/icons/help.svg
  51. 0 0
      p/themes/icons/icon.svg
  52. 0 0
      p/themes/icons/link.svg
  53. 0 0
      p/themes/icons/login.svg
  54. 0 0
      p/themes/icons/logout.svg
  55. 0 0
      p/themes/icons/next.svg
  56. 0 0
      p/themes/icons/non-starred.svg
  57. 0 0
      p/themes/icons/prev.svg
  58. 0 0
      p/themes/icons/read.svg
  59. 0 0
      p/themes/icons/refresh.svg
  60. 0 0
      p/themes/icons/rss.svg
  61. 0 0
      p/themes/icons/search.svg
  62. 0 0
      p/themes/icons/share.svg
  63. 0 0
      p/themes/icons/starred.svg
  64. 0 0
      p/themes/icons/tag.svg
  65. 0 0
      p/themes/icons/unread.svg
  66. 0 0
      p/themes/icons/up.svg

+ 2 - 2
README.md

@@ -31,7 +31,7 @@ Privilégiez pour cela des demandes sur GitHub
 
 # Installation
 1. Récupérez l’application FreshRSS via la commande git ou [en téléchargeant l’archive](https://github.com/marienfressinaud/FreshRSS/archive/master.zip)
-2. Placez l’application sur votre serveur (la partie à exposer au Web est le répertoire `./public/`)
+2. Placez l’application sur votre serveur (la partie à exposer au Web est le répertoire `./p/`)
 3. Le serveur Web doit avoir les droits d’écriture dans le répertoire `./data/`
 4. Accédez à FreshRSS à travers votre navigateur Web et suivez les instructions d’installation
 5. Tout devrait fonctionner :) En cas de problème, n’hésitez pas à me contacter.
@@ -49,7 +49,7 @@ Il est recommandé de limiter l’accès à votre FreshRSS, soit :
 ```
 
 # Conseils
-* Pour une meilleure sécurité, faites en sorte que seul le répertoire `./public` soit accessible depuis le Web, par exemple en faisant pointer un sous-domaine sur le répertoire `./public`.
+* Pour une meilleure sécurité, faites en sorte que seul le répertoire `./p/` soit accessible depuis le Web, par exemple en faisant pointer un sous-domaine sur le répertoire `./public`.
 * Les données personnelles se trouvent dans le répertoire `./data/` (déjà protégé par un .htaccess pour Apache - vérifiez que cela fonctionne -, à protéger vous-même dans le cas d’autres serveurs Web).
 * Le fichier `./constants.php` définit les chemins d’accès aux répertoires clés de l’application. Si vous les bougez, tout se passe ici.
 * En cas de problème, les logs peuvent être utile à lire, soit depuis l’interface de FreshRSS, soit manuellement depuis `./data/log/*.log`.

+ 10 - 7
constants.php

@@ -3,12 +3,15 @@ define('FRESHRSS_VERSION', '0.7-beta3');
 define('FRESHRSS_WEBSITE', 'http://freshrss.org');
 
 // Constantes de chemins
-define ('FRESHRSS_PATH', dirname(__FILE__));
+define('FRESHRSS_PATH', dirname(__FILE__));
 
-define ('PUBLIC_PATH', FRESHRSS_PATH . '/public');
-define ('DATA_PATH', FRESHRSS_PATH . '/data');
-define ('LIB_PATH', FRESHRSS_PATH . '/lib');
-define ('APP_PATH', FRESHRSS_PATH . '/app');
+	define('PUBLIC_PATH', FRESHRSS_PATH . '/p');
+		define('INDEX_PATH', PUBLIC_PATH . '/i');
+		define('PUBLIC_RELATIVE', '..');
 
-define ('LOG_PATH', DATA_PATH . '/log');
-define ('CACHE_PATH', DATA_PATH . '/cache');
+	define('DATA_PATH', FRESHRSS_PATH . '/data');
+		define('LOG_PATH', DATA_PATH . '/log');
+		define('CACHE_PATH', DATA_PATH . '/cache');
+
+	define('LIB_PATH', FRESHRSS_PATH . '/lib');
+		define('APP_PATH', FRESHRSS_PATH . '/app');

+ 2 - 3
index.html

@@ -2,12 +2,11 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
 <head>
 <meta charset="UTF-8" />
-<meta http-equiv="Refresh" content="0; url=public/" />
+<meta http-equiv="Refresh" content="0; url=p/i/" />
 <title>Redirection</title>
-<meta name="robots" content="noindex,follow" />
 </head>
 
 <body>
-<p><a href="./public/">FreshRSS</a></p>
+<p><a href="p/i/">FreshRSS</a></p>
 </body>
 </html>

+ 3 - 0
index.php

@@ -0,0 +1,3 @@
+<?php
+header('Location: p/i/', true, 301);
+include('index.html');

+ 1 - 0
lib/Minz/Session.php

@@ -18,6 +18,7 @@ class Minz_Session {
 	public static function init ($name) {
 		// démarre la session
 		session_name ($name);
+		session_set_cookie_params (0, './', null, false, true);
 		session_start ();
 
 		if (isset ($_SESSION)) {

+ 9 - 6
lib/Minz/Url.php

@@ -17,12 +17,16 @@ class Minz_Url {
 	 * @return l'url formatée
 	 */
 	public static function display ($url = array (), $encodage = 'html', $absolute = false) {
-		$url = self::checkUrl ($url);
+		$isArray = is_array($url);
+
+		if ($isArray) {
+			$url = self::checkUrl ($url);
+		}
 
 		$url_string = '';
 
 		if ($absolute) {
-			if (is_array ($url) && isset ($url['protocol'])) {
+			if ($isArray && isset ($url['protocol'])) {
 				$protocol = $url['protocol'];
 			} elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
 				$protocol = 'https:';
@@ -30,12 +34,11 @@ class Minz_Url {
 				$protocol = 'http:';
 			}
 			$url_string = $protocol . '//' . Minz_Request::getDomainName () . Minz_Request::getBaseUrl ();
-		}
-		else {
-			$url_string = '.';
+		} else {
+			$url_string = $isArray ? '.' : PUBLIC_RELATIVE;
 		}
 
-		if (is_array ($url)) {
+		if ($isArray) {
 			$router = new Minz_Router ();
 
 			if (Minz_Configuration::useUrlRewriting ()) {

+ 0 - 0
public/.htaccess → p/.htaccess


+ 0 - 0
public/f.php → p/f.php


+ 0 - 0
public/favicon.ico → p/favicon.ico


+ 0 - 0
public/favicon.png → p/favicon.png


+ 1 - 1
public/index.php → p/i/index.php

@@ -21,7 +21,7 @@
 if (file_exists ('install.php')) {
 	require('install.php');
 } else {
-	require('../constants.php');
+	require('../../constants.php');
 
 	session_cache_limiter('');
 	if (!file_exists(DATA_PATH . '/no-cache.txt')) {

+ 5 - 14
public/install.php → p/i/install.php

@@ -1,8 +1,9 @@
 <?php
-require('../constants.php');
+require('../../constants.php');
 include(LIB_PATH . '/lib_rss.php');
 
 session_name('FreshRSS');
+session_set_cookie_params(0, './', null, false, true);
 session_start();
 
 if (isset ($_GET['step'])) {
@@ -381,7 +382,7 @@ function updateDatabase($perform = false) {
 }
 
 function deleteInstall () {
-	$res = unlink (PUBLIC_PATH . '/install.php');
+	$res = unlink (INDEX_PATH . '/install.php');
 	if ($res) {
 		header ('Location: index.php');
 	}
@@ -455,16 +456,6 @@ function delTree($dir) {	//http://php.net/rmdir#110489
 	return rmdir($dir);
 }
 
-function removeOldFiles() {
-	$oldDirs = array('/app/configuration/', '/cache/', '/log/', '/public/data/', '/public/themes/printer/');	//v0.6
-
-	$ok = true;
-	foreach ($oldDirs as $oldDir) {
-		$ok &= delTree(FRESHRSS_PATH . $oldDir);
-	}
-	return $ok;
-}
-
 /*** VÉRIFICATIONS ***/
 function checkStep () {
 	$s0 = checkStep0 ();
@@ -483,7 +474,7 @@ function checkStep () {
 	$_SESSION['actualize_feeds'] = true;
 }
 function checkStep0 () {
-	moveOldFiles() && removeOldFiles();
+	moveOldFiles();
 
 	if (file_exists(DATA_PATH . '/config.php')) {
 		$ini_array = include(DATA_PATH . '/config.php');
@@ -934,7 +925,7 @@ function printStep5 () {
 
 function printStep6 () {
 ?>
-	<p class="alert alert-error"><span class="alert-head"><?php echo _t ('oops'); ?></span> <?php echo _t ('install_not_deleted', PUBLIC_PATH . '/install.php'); ?></p>
+	<p class="alert alert-error"><span class="alert-head"><?php echo _t ('oops'); ?></span> <?php echo _t ('install_not_deleted', INDEX_PATH . '/install.php'); ?></p>
 <?php
 }
 

+ 12 - 0
p/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
+<head>
+<meta charset="UTF-8" />
+<meta http-equiv="Refresh" content="0; url=i/" />
+<title>Redirection</title>
+</head>
+
+<body>
+<p><a href="i/">FreshRSS</a></p>
+</body>
+</html>

+ 3 - 0
p/index.php

@@ -0,0 +1,3 @@
+<?php
+header('Location: i/', true, 301);
+include('index.html');

+ 0 - 0
public/robots.txt → p/robots.txt


+ 0 - 0
public/scripts/global_view.js → p/scripts/global_view.js


+ 0 - 0
public/scripts/jquery-2.0.3.min.map → p/scripts/jquery-2.0.3.min.map


+ 0 - 0
public/scripts/jquery.lazyload.min.js → p/scripts/jquery.lazyload.min.js


+ 0 - 0
public/scripts/jquery.min.js → p/scripts/jquery.min.js


+ 0 - 0
public/scripts/main.js → p/scripts/main.js


+ 0 - 0
public/scripts/shortcut.js → p/scripts/shortcut.js


+ 0 - 0
public/themes/default/freshrss.css → p/themes/default/freshrss.css


+ 0 - 0
public/themes/default/global.css → p/themes/default/global.css


+ 0 - 0
public/themes/default/loader.gif → p/themes/default/loader.gif


+ 0 - 0
public/themes/default/metadata.json → p/themes/default/metadata.json


+ 0 - 0
public/themes/flat-design/freshrss.css → p/themes/flat-design/freshrss.css


+ 0 - 0
public/themes/flat-design/global.css → p/themes/flat-design/global.css


+ 0 - 0
public/themes/flat-design/icons/add.svg → p/themes/flat-design/icons/add.svg


+ 0 - 0
public/themes/flat-design/icons/all.svg → p/themes/flat-design/icons/all.svg


+ 0 - 0
public/themes/flat-design/icons/close.svg → p/themes/flat-design/icons/close.svg


+ 0 - 0
public/themes/flat-design/icons/configure.svg → p/themes/flat-design/icons/configure.svg


+ 0 - 0
public/themes/flat-design/icons/down.svg → p/themes/flat-design/icons/down.svg


+ 0 - 0
public/themes/flat-design/icons/next.svg → p/themes/flat-design/icons/next.svg


+ 0 - 0
public/themes/flat-design/icons/prev.svg → p/themes/flat-design/icons/prev.svg


+ 0 - 0
public/themes/flat-design/icons/refresh.svg → p/themes/flat-design/icons/refresh.svg


+ 0 - 0
public/themes/flat-design/icons/search.svg → p/themes/flat-design/icons/search.svg


+ 0 - 0
public/themes/flat-design/icons/up.svg → p/themes/flat-design/icons/up.svg


+ 0 - 0
public/themes/flat-design/loader.gif → p/themes/flat-design/loader.gif


+ 0 - 0
public/themes/flat-design/metadata.json → p/themes/flat-design/metadata.json


+ 0 - 0
public/themes/fonts/openSans.woff → p/themes/fonts/openSans.woff


+ 0 - 0
public/themes/icons/add.svg → p/themes/icons/add.svg


+ 0 - 0
public/themes/icons/all.svg → p/themes/icons/all.svg


+ 0 - 0
public/themes/icons/bookmark.svg → p/themes/icons/bookmark.svg


+ 0 - 0
public/themes/icons/category-white.svg → p/themes/icons/category-white.svg


+ 0 - 0
public/themes/icons/category.svg → p/themes/icons/category.svg


+ 0 - 0
public/themes/icons/close.svg → p/themes/icons/close.svg


+ 0 - 0
public/themes/icons/configure.svg → p/themes/icons/configure.svg


+ 0 - 0
public/themes/icons/down.svg → p/themes/icons/down.svg


+ 0 - 0
public/themes/icons/grey.gif → p/themes/icons/grey.gif


+ 0 - 0
public/themes/icons/help.svg → p/themes/icons/help.svg


+ 0 - 0
public/themes/icons/icon.svg → p/themes/icons/icon.svg


+ 0 - 0
public/themes/icons/link.svg → p/themes/icons/link.svg


+ 0 - 0
public/themes/icons/login.svg → p/themes/icons/login.svg


+ 0 - 0
public/themes/icons/logout.svg → p/themes/icons/logout.svg


+ 0 - 0
public/themes/icons/next.svg → p/themes/icons/next.svg


+ 0 - 0
public/themes/icons/non-starred.svg → p/themes/icons/non-starred.svg


+ 0 - 0
public/themes/icons/prev.svg → p/themes/icons/prev.svg


+ 0 - 0
public/themes/icons/read.svg → p/themes/icons/read.svg


+ 0 - 0
public/themes/icons/refresh.svg → p/themes/icons/refresh.svg


+ 0 - 0
public/themes/icons/rss.svg → p/themes/icons/rss.svg


+ 0 - 0
public/themes/icons/search.svg → p/themes/icons/search.svg


+ 0 - 0
public/themes/icons/share.svg → p/themes/icons/share.svg


+ 0 - 0
public/themes/icons/starred.svg → p/themes/icons/starred.svg


+ 0 - 0
public/themes/icons/tag.svg → p/themes/icons/tag.svg


+ 0 - 0
public/themes/icons/unread.svg → p/themes/icons/unread.svg


+ 0 - 0
public/themes/icons/up.svg → p/themes/icons/up.svg