Просмотр исходного кода

Message d'erreur si fichier conf innaccessible

Voir #282
Marien Fressinaud 12 лет назад
Родитель
Сommit
f427014804
2 измененных файлов с 17 добавлено и 2 удалено
  1. 9 1
      app/App_FrontController.php
  2. 8 1
      lib/minz/dao/Model_txt.php

+ 9 - 1
app/App_FrontController.php

@@ -40,7 +40,15 @@ class App_FrontController extends FrontController {
 	}
 
 	private function loadParamsView () {
-		$this->conf = Session::param ('conf', new RSSConfiguration ());
+		try {
+			$this->conf = Session::param ('conf', new RSSConfiguration ());
+		} catch(MinzException $e) {
+			// Permission denied or conf file does not exist
+			// it's critical!
+			print $e->getMessage();
+			exit();
+		}
+
 		View::_param ('conf', $this->conf);
 
 		$entryDAO = new EntryDAO ();

+ 8 - 1
lib/minz/dao/Model_txt.php

@@ -27,10 +27,17 @@ class Model_txt {
 	 */
 	public function __construct ($nameFile, $mode = 'a+') {
 		$this->filename = $nameFile;
+		if (!file_exists($this->filename)) {
+			throw new FileNotExistException (
+				$this->filename,
+				MinzException::WARNING
+			);
+		}
+
 		$this->file = @fopen ($this->filename, $mode);
 		
 		if (!$this->file) {
-			throw new FileNotExistException (
+			throw new PermissionDeniedException (
 				$this->filename,
 				MinzException::WARNING
 			);