Browse Source

Fix issue #65 : création d'un vrai script de mise à jour permettant de mettre tous les flux à jour via CRON

Marien Fressinaud 13 years ago
parent
commit
5963221249
3 changed files with 54 additions and 4 deletions
  1. 6 3
      README
  2. 45 0
      actualize_script.php
  3. 3 1
      app/controllers/feedController.php

+ 6 - 3
README

@@ -49,9 +49,12 @@ SÉCURITÉ ET CONSEILS
 	3. Le fichier `/public/index.php` défini les chemins d'accès aux
 	   répertoires clés de l'application. Si vous les bougez, tout se passe
 	   ici.
-	4. Vous pouvez ajouter une tâche CRON sur l'url de mise à jour des flux
-	   (clic droit sur le bouton d'actualisation puis "Copier l'adresse du
-	   lien") pour que celle-ci se fasse de manière transparente
+	4. Vous pouvez ajouter une tâche CRON sur le script d'actualisation des
+	   flux. Il s'agit d'un script PHP à exécuter avec la commande `php`.
+	   Par exemple, pour exécuter le script toutes les heures :
+	   0 * * * * php /chemin/vers/freshrss/actualize_script.php >/dev/null 2>&1
+	   Veuillez cependant vérifier que le fichier PUBLIC_PATH/data/Configuration.array.php
+	   soit accessible en lecture / écriture par l'exécuteur du script
 
 CHANGELOG
 =========

+ 45 - 0
actualize_script.php

@@ -0,0 +1,45 @@
+<?php
+# ***** BEGIN LICENSE BLOCK *****
+# MINZ - A free PHP framework
+# Copyright (C) 2011 Marien Fressinaud
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# ***** END LICENSE BLOCK *****
+
+// Constantes de chemins
+define ('PUBLIC_PATH', realpath (dirname (__FILE__) . '/public'));
+define ('LIB_PATH', realpath (PUBLIC_PATH . '/../lib'));
+define ('APP_PATH', realpath (PUBLIC_PATH . '/../app'));
+define ('LOG_PATH', realpath (PUBLIC_PATH . '/../log'));
+define ('CACHE_PATH', realpath (PUBLIC_PATH . '/../cache'));
+
+$_GET['c'] = 'feed';
+$_GET['a'] = 'actualize';
+$_GET['force'] = true;
+$_SERVER['HTTP_HOST'] = '';
+
+set_include_path (get_include_path ()
+		 . PATH_SEPARATOR
+		 . LIB_PATH
+		 . PATH_SEPARATOR
+		 . LIB_PATH . '/minz'
+		 . PATH_SEPARATOR
+		 . APP_PATH);
+
+require (APP_PATH . '/App_FrontController.php');
+
+$front_controller = new App_FrontController ();
+$front_controller->init ();
+$front_controller->run ();

+ 3 - 1
app/controllers/feedController.php

@@ -118,6 +118,7 @@ class feedController extends ActionController {
 		$entryDAO = new EntryDAO ();
 
 		$id = Request::param ('id');
+		$force = Request::param ('force', false);
 
 		// on créé la liste des flux à mettre à actualiser
 		// si on veut mettre un flux à jour spécifiquement, on le met
@@ -163,8 +164,9 @@ class feedController extends ActionController {
 			}
 
 			// On arrête à 10 flux pour ne pas surcharger le serveur
+			// sauf si le paramètre $force est à vrai
 			$i++;
-			if ($i >= 10) {
+			if ($i >= 10 && !$force) {
 				break;
 			}
 		}