Bonjour à tous! Pouvez vous m'aidez? Php me dit cette erreur lorsque j'effectue mon script:
"Parse error: syntax error, unexpected 'NoirEtBlanc' (T_STRING), expecting function (T_FUNCTION) in G:\I.S.N\EasyPHP-12.1\www\my portable files\philtre noir-blanc.php on line 125".
Je précise que je suis débutant en php et que j'ai besoin de votre aide car je passe mon oral d'isn (nouvelle spécialité pour les terminales s) dans 2 semaines! Merci d'avance
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
	$dossier = 'philtre/';
	$newfichier = 'noirblanc.bmp';
 
	class Bmp32BitsCarib0uClass {
	private $filename = 'upload/image.bmp';
	private $handle   = null;
	private $infos    = array();
 
	function __construct($name) {
		$this->filename = $name;
		if($this->is_bmp()) {
			$this->infos['taille'] = $this->reading_val(4);
			fseek($this->handle,4,SEEK_CUR);
			$this->infos['offset'] = $this->reading_val(4);
			fseek($this->handle,4,SEEK_CUR);
			$this->infos['largeur'] = $this->reading_val(4);
			$this->infos['longueur'] = $this->reading_val(4);
		} else return false;
	}
 
	private function is_bmp() {
		$this->handle = @fopen($this->filename,"rb+");
		if(!$this->handle) return false;
		$header = fread($this->handle,2);
		return $header == "\x42\x4d" ? true : false;
	}
 
	public function dump() {
		echo "Taille : ".$this->infos['taille']." octets.\n".
		"Offset : ".$this->infos['offset']."\n".
		"Largeur : ".$this->infos['largeur']." octets\n".
		"Longueur : ".$this->infos['longueur']." octets.\n";
	}
 
	private function reading_val($n,$mode = '') {
		$len = fread($this->handle,$n);
		$o   = '';
		for($i = strlen($len) - 1; $i >= 0; $i--) {
			if(ord($len[$i]) <= 0x0f) {
				$o .= '0'.dechex(ord($len[$i]));
			} else {
				$o .= dechex(ord($len[$i]));
			}
		}
		if(!$mode) {
			return hexdec($o);
		} else if($mode = "hex") {
			return $o;
		}
	}
 
	public function RemplissageAleatoire() {
		for($i = 0; $i <= $this->GetLongueur(); $i++) {
			for($j = 0; $j <= $this->GetLargeur(); $j++) {
				$color =  dechex(mt_rand(16,255)) . dechex(mt_rand(16,255)) . dechex(mt_rand(16,255));
				$this->SetPixel($j,$i,$color);
			}
		}
	}
 
 
	public function LirePixel($x,$y) {
		if($x <= $this->infos['largeur'] && $y <= $this->infos['longueur']) {
			rewind($this->handle);
			$offimg = ($this->infos['largeur'] * $y * 3) + ($x * 3) + ($y * ($this->infos['largeur'] % 4));
			fseek($this->handle, $this->infos['offset'] + $offimg);
			return $this->reading_val(3,"hex");
		}
	}
 
	public function SetPixel($x,$y,$color) {
		if($x <= $this->infos['largeur'] && $y <= $this->infos['longueur']) {
			rewind($this->handle);
			$offimg = ($this->infos['largeur'] * $y * 3) + ($x * 3) + ($y * ($this->infos['largeur'] % 4));
			fseek($this->handle, $this->infos['offset'] + $offimg);
			$rouge = chr(hexdec(substr($color,0,2)));
			$vert  = chr(hexdec(substr($color,2,2)));
			$bleu  = chr(hexdec(substr($color,4,2)));
			fwrite($this->handle,$bleu);
			fwrite($this->handle,$vert);
			fwrite($this->handle,$rouge);
 
		}
	}
 
	public function GetLongueur() {
		if(!empty($this->infos['longueur'])) return $this->infos['longueur'];
		else return 0;
	}
 
	public function GetLargeur() {
		if(!empty($this->infos['largeur'])) return $this->infos['largeur'];
		else return 0;
	}
 
	public function RemplissageTotal($color) {
		for($i = 0; $i <= $this->GetLongueur(); $i++) {
			for($j = 0; $j <= $this->GetLargeur(); $j++) {
				$this->SetPixel($j,$i,$color);
			}
		}
	}
 
	public function NoirEtBlanc($output) {
		copy($this->filename,$output);
		$img2 = new Bmp32BitsCarib0uClass($output);
		for($i = 0; $i <= $this->GetLongueur(); $i++) {
			for($j = 0; $j <= $this->GetLargeur(); $j++) {
				$color = $this->LirePixel($j,$i);
				$bleu  = hexdec(substr($color,0,2));
				$vert  = hexdec(substr($color,2,2));
				$rouge = hexdec(substr($color,4,2));
				$somme = $bleu + $vert + $rouge;
				$ncolor = ceil($somme / 3);
				if($ncolor <= 0x0f) {
					$ncolor = '0'.dechex($ncolor).'0'.dechex($ncolor).'0'.dechex($ncolor);
				} else {
					$ncolor = dechex($ncolor).dechex($ncolor).dechex($ncolor);
				}
				$img2->SetPixel($j,$i,$ncolor);
			}
		}
	}
	NoirEtBlanc($output);
	if(move_uploaded_file($img2, $dossier . $filename)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
     {	echo 'Modifications effectu&eacute avec succ&egraves !';
		rename($dossier.$filename,$dossier.$newfichier);
	 }
	 else //Sinon (la fonction renvoie FALSE).
     {
          echo 'Echec de la modification !';
     }
}
?>
PS: j'ai trouvé ce code sur ce site: http://venom630.free.fr/geo/tools/bm...uclass_php.txt