View difference between Paste ID: EbwRAgNa and pkyJJW62
SHOW: | | - or go back to the newest paste.
1
<?php
2
	// Désactiver le rapport d'erreurs
3
	// error_reporting(0);
4-
    
4+
5
	$fichier = 'information.txt';    
6-
	$files = scandir('./'.$dossier);
6+
7-
?>            
7+
8
	// je préfère Glob() a scandir() car il n'inclut pas les fichiers cachés (voir http://stackoverflow.com/questions/758594/load-list-of-image-from-folder)
9-
---
9+
	// $files = scandir('./'.$dossier);
10
	
11
	$images = glob($dossier . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
12
13-
	$fichier = 'information.txt';
13+
	// Est-ce qu'il y a des images? 
14
	if(is_array($images)){
15
		
16
	echo "il y a " . count($images) . " images dans le $dossier .";	
17
18
	} else{
19
	die("pas pu parser le dossier. Il y a un prob, mec.");
20
}
21
22
23
	// On va chercher le fichier texte de l'utilisateur
24
25
	$contenu_string = file_get_contents($fichier);
26
27
	// Markdown perso
28
	$string = $contenu_string;
29
	patterns = array();
30
	$patterns[0] = "/t-/";
31
	$patterns[1] = "/-t/";
32
	$patterns[2] = "/d-/";
33
	$patterns[3] = "/-d/";
34
	$patterns[4] = "/#-/";
35
	$patterns[5] = "/-#/";
36
37
	$replacements = array();
38
	$replacements[0] = '<h1 class="titreProjet">';
39
	$replacements[1] = '</h1>';
40
	$replacements[2] = '<p class="descriptionProjet">';
41
	$replacements[3] = '</p class="descriptionProjet">';
42
	$replacements[4] = '<!--';
43
	$replacements[5] = '-->';
44
45
	echo preg_replace($patterns, $replacements, $string);
46
47
48
	// Si ce n'est pas le bon nom de fichier > information.txt
49
	if($fichier != 'information.txt')
50
	{
51
		echo '<h1 class="alertNoInfo">Projet sans titre.</h1>';
52
	}
53
?>