Révision 1f5db711
Ajouté par root il y a plus de 11 ans
addParams.php | ||
---|---|---|
1 |
<!DOCTYPE html> |
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> |
|
3 |
<?php |
|
4 |
if(isset($_GET['dir']) && isset($_GET['panorama'])){ |
|
5 |
|
|
6 |
$_GET['dir'] = htmlspecialchars($_GET['dir']); //Protection des variables GET. |
|
7 |
$_GET['panorama'] = htmlspecialchars($_GET['panorama']); // ... |
|
8 |
|
|
9 |
if (isset($_POST['param_latitude']) && isset($_POST['param_longitude']) |
|
10 |
&& isset($_POST['param_altitude']) && isset($_POST['param_elevation']) |
|
11 |
&& isset($_POST['param_title']) && isset($_POST['param_loop'])) { |
|
12 |
|
|
13 |
foreach ($_POST as $value) //Protection des variables POST. |
|
14 |
{ |
|
15 |
$value = htmlspecialchars($value); |
|
16 |
} |
|
17 |
|
|
18 |
/* --- Vérification des inputs avec des regex. ---*/ |
|
19 |
// Pour la latitude : ( Le javascript bride entre -90 et 90) |
|
20 |
if (preg_match("#^(\-?[1-9]+[0-9]?[.,]{0,1}[0-9]{0,6}|\-?[0-9]{1}[.,]{0,1}[0-9]{0,6})$#", $_POST['param_latitude'])) |
|
21 |
{ |
|
22 |
$lat = $_POST['param_latitude']; |
|
23 |
//echo 'Le ' . $_POST['param_latitude'] . ' est un numéro <strong>valide</strong> !'; |
|
24 |
} |
|
25 |
else |
|
26 |
{ |
|
27 |
echo 'Le ' . $_POST['param_latitude'] . ' n\'est pas valide, recommencez !'; |
|
28 |
|
|
29 |
} |
|
30 |
|
|
31 |
// Pour la longitude : ( Le javascript bride entre -180 et 180) |
|
32 |
if (preg_match("#^(\-?[1-9]+[0-9]?[.,]{0,1}[0-9]{0,6}|\-?[0-9]{0,1}[.,]{1}[0-9]{0,6})$#", $_POST['param_longitude'])) |
|
33 |
{ |
|
34 |
$lon = $_POST['param_longitude']; |
|
35 |
//echo 'Le ' . $_POST['param_longitude'] . ' est un numéro <strong>valide</strong> !'; |
|
36 |
} |
|
37 |
else |
|
38 |
{ |
|
39 |
echo 'Le ' . $_POST['param_longitude'] . ' n\'est pas valide, recommencez !'; |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
// Pour l'altitude ( Le javascript bride entre 0 et 500) |
|
44 |
if (preg_match("#^([1-9]+[0-9]{0,4}|0)$#", $_POST['param_altitude'])) |
|
45 |
{ |
|
46 |
$alt = $_POST['param_altitude']; |
|
47 |
//echo 'Le ' . $_POST['param_altitude'] . ' est un numéro <strong>valide</strong> !'; |
|
48 |
} |
|
49 |
else |
|
50 |
{ |
|
51 |
echo 'Le ' . $_POST['param_altitude'] . ' n\'est pas valide, recommencez !'; |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
// Pour l'élévation ( Le javascript bride entre -10 et 10) |
|
56 |
if (preg_match("#^(\-?[1-9]+[0-9]?|0)$#", $_POST['param_elevation'])) |
|
57 |
{ |
|
58 |
$ele = $_POST['param_elevation']; |
|
59 |
//echo 'Le ' . $_POST['param_elevation'] . ' est un numéro <strong>valide</strong> !'; |
|
60 |
} |
|
61 |
else |
|
62 |
{ |
|
63 |
echo 'Le ' . $_POST['param_elevation'] . ' n\'est pas valide, recommencez !'; |
|
64 |
|
|
65 |
} |
|
66 |
|
|
67 |
$loop = $_POST['param_loop']; // Variable radio automatiquement présente |
|
68 |
if(isset($lat) && isset($lon) && isset($alt) && isset($ele) && isset($loop)) { |
|
69 |
|
|
70 |
// On recherche le dossier correspondant au panorama en question |
|
71 |
$dir_file = "/var/www/data/tsf2/vpongnian/panorama/".$_GET['dir']."/".$_GET['panorama']; |
|
72 |
$dir_open = opendir($dir_file); |
|
73 |
while (false !== ($file = readdir($dir_open))) { |
|
74 |
// Si on trouve bien des tuiles |
|
75 |
if (preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $file, $reg)) { |
|
76 |
$prefix = $reg[1]; |
|
77 |
$new_param_file = $prefix.".params"; |
|
78 |
break; // On sort à la première tuile trouvée |
|
79 |
} |
|
80 |
} |
|
81 |
closedir($dir_open); |
|
82 |
|
|
83 |
$retour = "\n"; |
|
84 |
// On vérifie qu'on a bien crée un nouveau fichier .params et on écrit dedans. |
|
85 |
if(isset($new_param_file)){ |
|
86 |
$param_file = fopen($dir_file."/".$new_param_file,'a+'); |
|
87 |
fputs($param_file,"titre = \"" . $_POST['param_title'] . "\""); |
|
88 |
fputs($param_file,$retour); |
|
89 |
fputs($param_file,"latitude = " . $lat); |
|
90 |
fputs($param_file,$retour); |
|
91 |
fputs($param_file,"longitude = " . $lon); |
|
92 |
fputs($param_file,$retour); |
|
93 |
fputs($param_file,"altitude = " . $alt); |
|
94 |
fputs($param_file,$retour); |
|
95 |
fputs($param_file,"elevation = " . $alt); |
|
96 |
fputs($param_file,$retour); |
|
97 |
fputs($param_file,"image_loop =" . $loop); |
|
98 |
fputs($param_file,$retour); |
|
99 |
fclose($param_file); |
|
100 |
|
|
101 |
echo 'Paramétrage OK. Retour au panorama'; |
|
102 |
header("Refresh: 1; URL=index.php"); |
|
103 |
} else { |
|
104 |
|
|
105 |
echo "<script>alert(\"impossible d'écrire dans le fichier\")</script>"; |
|
106 |
} |
|
107 |
} |
|
108 |
} else { |
|
109 |
echo '<script>alert(\'$_POST manquant\')</script>'; |
|
110 |
header("Refresh: 2; URL=javascript:history.back();"); |
|
111 |
} |
|
112 |
} else { |
|
113 |
echo '<script>alert(\'La destinaton est manquante\')</script>'; |
|
114 |
header("Refresh: 2; URL=javascript:history.back();"); |
|
115 |
} |
|
116 |
|
|
117 |
?> |
|
118 |
</html> |
creerPano.php | ||
---|---|---|
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> |
|
3 |
<head> |
|
4 |
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/> |
|
5 |
<link rel="stylesheet" media="screen" href="css/ttn_style_1.css" /> |
|
6 |
<title>creation d'un panoramique</title> |
|
7 |
<script type="text/javascript"> |
|
8 |
|
|
9 |
function showLoad(outgoingLink){ |
|
10 |
|
|
11 |
var link = document.getElementById(outgoingLink); |
|
12 |
var loader = document.createElement('img'); |
|
13 |
loader.id = 'loader'; |
|
14 |
loader.src ='images/loader2.gif'; |
|
15 |
var li = link.parentNode; |
|
16 |
li.appendChild(loader); |
|
17 |
} |
|
18 |
</script> |
|
19 |
</head> |
|
20 |
<body> |
|
21 |
<img id="top" src="images/top.png" alt=""> |
|
22 |
<div id="page_container"> |
|
23 |
<h1><img src="images/tetaneutral.png"></h1> |
|
24 |
<h2>Listes des photos sur le serveur</h2> |
|
25 |
<p>Cliquez pour générer un panorama</p> |
|
26 |
<div id="containerList"> |
|
27 |
<ul> |
|
28 |
|
|
29 |
<?php |
|
30 |
|
|
31 |
$base_dir = "/var/www/data/tsf2/vpongnian/panorama/upload/"; // modifier selon l'arborescence. |
|
32 |
try |
|
33 |
{ |
|
34 |
// On ouvre le dossier ou se trouve les images |
|
35 |
$dir_fd = opendir($base_dir); |
|
36 |
|
|
37 |
$i=0; // Garantir l'unicité du id des liens. |
|
38 |
while (false !== ($image_name = readdir($dir_fd))) { |
|
39 |
$dir = $base_dir.$image_name; |
|
40 |
|
|
41 |
if ($image_name != "." && $image_name != "..") // N'affiche pas les répertoires parents et courant. |
|
42 |
{ |
|
43 |
printf('<li><a href="genererPano.php?name=%s" id="link_'.$i.'" onclick="showLoad(this.id);return true;">%s</a></li>'."\n",$image_name,$image_name); |
|
44 |
$i++; |
|
45 |
} |
|
46 |
|
|
47 |
|
|
48 |
} |
|
49 |
} |
|
50 |
catch(Exception $e) |
|
51 |
{ |
|
52 |
die('Erreur : '.$e->getMessage()); |
|
53 |
} |
|
54 |
?> |
|
55 |
</ul> |
|
56 |
</div> |
|
57 |
<div id="footer"><a href="./index.php">Retour à l'index</a></div> |
|
58 |
|
|
59 |
</div> |
|
60 |
<img id="bottom" src="images/bottom.png" alt=""> |
|
61 |
</body> |
|
62 |
</html> |
css/index_style.css | ||
---|---|---|
1 |
body |
|
2 |
{ |
|
3 |
|
|
4 |
background:#44F; |
|
5 |
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; |
|
6 |
font-size:small; |
|
7 |
margin:8px 0 16px; |
|
8 |
text-align:center; |
|
9 |
overflow:auto; |
|
10 |
|
|
11 |
} |
|
12 |
|
|
13 |
#top |
|
14 |
{ |
|
15 |
display:block; |
|
16 |
height:10px; |
|
17 |
margin:10px auto 0; |
|
18 |
width:650px; |
|
19 |
} |
|
20 |
|
|
21 |
div#index_container |
|
22 |
{ |
|
23 |
background:#fff; |
|
24 |
|
|
25 |
margin: auto; |
|
26 |
text-align:left; |
|
27 |
width:640px; |
|
28 |
} |
|
29 |
|
|
30 |
div#index_container h2 { |
|
31 |
margin:1.05em; |
|
32 |
text-shadow: 0.1em 0.1em 0.15em #44F; |
|
33 |
} |
|
34 |
#bottom |
|
35 |
{ |
|
36 |
display:block; |
|
37 |
height:10px; |
|
38 |
margin:0 auto; |
|
39 |
width:650px; |
|
40 |
} |
|
41 |
|
|
42 |
h1 |
|
43 |
{ |
|
44 |
background-color:#6699CC; |
|
45 |
margin:0; |
|
46 |
min-height:0; |
|
47 |
padding:0; |
|
48 |
text-decoration:none; |
|
49 |
text-align: center; |
|
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
h1 a |
|
54 |
{ |
|
55 |
|
|
56 |
display:block; |
|
57 |
height:100%; |
|
58 |
min-height:40px; |
|
59 |
|
|
60 |
} |
|
61 |
|
|
62 |
h1 img |
|
63 |
{ |
|
64 |
margin-top: 8px; |
|
65 |
} |
|
66 |
|
|
67 |
img |
|
68 |
{ |
|
69 |
/*behavior:url(css/iepngfix.htc);*/ |
|
70 |
border:none; |
|
71 |
} |
|
72 |
|
|
73 |
div#containerList |
|
74 |
{ |
|
75 |
margin:20px 20px 0; |
|
76 |
padding:0 0 20px; |
|
77 |
} |
|
78 |
|
|
79 |
#containerList |
|
80 |
{ |
|
81 |
font-family:Lucida Grande, Tahoma, Arial, Verdana, sans-serif; |
|
82 |
|
|
83 |
} |
|
84 |
|
|
85 |
#containerList li |
|
86 |
{ |
|
87 |
width:100%; |
|
88 |
margin:1.05em; |
|
89 |
font-size:14px; |
|
90 |
|
|
91 |
} |
|
92 |
|
|
93 |
div#containerList ul |
|
94 |
{ |
|
95 |
font-size:100%; |
|
96 |
list-style-type:circle; |
|
97 |
margin:0; |
|
98 |
padding:0; |
|
99 |
width:100%; |
|
100 |
} |
|
101 |
|
|
102 |
div#interaction { |
|
103 |
background-color:#fff; |
|
104 |
margin: auto; |
|
105 |
width:640px; |
|
106 |
border-top: 2px dotted #44F; |
|
107 |
} |
|
108 |
|
|
109 |
div#interaction li{ |
|
110 |
|
|
111 |
display:inline-block; |
|
112 |
list-style-type:none; |
|
113 |
margin:1.08em; |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
div#interaction li a{ |
|
118 |
|
|
119 |
color:#3F2DFF; |
|
120 |
text-decoration:none; |
|
121 |
font-size:16px; |
|
122 |
} |
|
123 |
|
|
124 |
div#interaction li a:hover { |
|
125 |
color:#FF9900; |
|
126 |
text-decoration:underline; |
|
127 |
} |
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
p a { |
|
132 |
background-color:#fff; |
|
133 |
border-radius: 4px; |
|
134 |
padding:3px; |
|
135 |
text-shadow: 0.1em 0.05em 0.15em #444; |
|
136 |
font-size:11px; |
|
137 |
} |
css/ttn_style_1.css | ||
---|---|---|
1 |
body |
|
2 |
{ |
|
3 |
|
|
4 |
background:#44F; |
|
5 |
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; |
|
6 |
font-size:small; |
|
7 |
margin:8px 0 16px; |
|
8 |
text-align:center; |
|
9 |
overflow:auto; |
|
10 |
|
|
11 |
} |
|
12 |
|
|
13 |
#top |
|
14 |
{ |
|
15 |
display:block; |
|
16 |
height:10px; |
|
17 |
margin:10px auto 0; |
|
18 |
width:650px; |
|
19 |
} |
|
20 |
|
|
21 |
div#page_container |
|
22 |
{ |
|
23 |
background:#fff; |
|
24 |
|
|
25 |
margin: auto; |
|
26 |
text-align:left; |
|
27 |
width:640px; |
|
28 |
} |
|
29 |
|
|
30 |
div#page_container h2 { |
|
31 |
display:inline-block; |
|
32 |
margin:1.05em; |
|
33 |
text-shadow: 0.1em 0.1em 0.15em #44F; |
|
34 |
} |
|
35 |
#bottom |
|
36 |
{ |
|
37 |
display:block; |
|
38 |
height:10px; |
|
39 |
margin:0 auto; |
|
40 |
width:650px; |
|
41 |
} |
|
42 |
|
|
43 |
h1 |
|
44 |
{ |
|
45 |
background-color:#6699CC; |
|
46 |
margin:0; |
|
47 |
min-height:0; |
|
48 |
padding:0; |
|
49 |
text-decoration:none; |
|
50 |
text-align: center; |
|
51 |
|
|
52 |
} |
|
53 |
|
|
54 |
h1 a |
|
55 |
{ |
|
56 |
|
|
57 |
display:block; |
|
58 |
height:100%; |
|
59 |
min-height:40px; |
|
60 |
|
|
61 |
} |
|
62 |
|
|
63 |
h1 img |
|
64 |
{ |
|
65 |
margin-top: 8px; |
|
66 |
} |
|
67 |
|
|
68 |
img |
|
69 |
{ |
|
70 |
/*behavior:url(css/iepngfix.htc);*/ |
|
71 |
border:none; |
|
72 |
} |
|
73 |
|
|
74 |
h2 + p { |
|
75 |
display:inline-block; |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
div#containerList |
|
80 |
{ |
|
81 |
margin:20px 20px 0; |
|
82 |
padding:0 0 20px; |
|
83 |
} |
|
84 |
|
|
85 |
#containerList |
|
86 |
{ |
|
87 |
font-family:Lucida Grande, Tahoma, Arial, Verdana, sans-serif; |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
#containerList li |
|
92 |
{ |
|
93 |
width:100%; |
|
94 |
margin:1.05em; |
|
95 |
font-size:14px; |
|
96 |
list-style-type:none; |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
div#containerList ul |
|
101 |
{ |
|
102 |
font-size:100%; |
|
103 |
list-style-type:circle; |
|
104 |
margin:0; |
|
105 |
padding:0; |
|
106 |
width:100%; |
|
107 |
} |
|
108 |
|
|
109 |
li a{ |
|
110 |
|
|
111 |
color:#3F2DFF; |
|
112 |
text-decoration:none; |
|
113 |
font-size:16px; |
|
114 |
} |
|
115 |
|
|
116 |
li a:hover { |
|
117 |
color:#FF9900; |
|
118 |
text-decoration:underline; |
|
119 |
} |
|
120 |
|
|
121 |
li img { |
|
122 |
margin-left:20px; |
|
123 |
} |
|
124 |
|
|
125 |
#footer |
|
126 |
{ |
|
127 |
width:640px; |
|
128 |
clear:both; |
|
129 |
color:#999999; |
|
130 |
text-align:center; |
|
131 |
width:640px; |
|
132 |
padding-bottom: 15px; |
|
133 |
font-size: 85%; |
|
134 |
} |
|
135 |
|
css/view.css | ||
---|---|---|
1 |
body |
|
2 |
{ |
|
3 |
|
|
4 |
background:#44F; |
|
5 |
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; |
|
6 |
font-size:small; |
|
7 |
margin:8px 0 16px; |
|
8 |
text-align:center; |
|
9 |
} |
|
10 |
|
|
11 |
#form_container |
|
12 |
{ |
|
13 |
background:#fff; |
|
14 |
|
|
15 |
margin:0 auto; |
|
16 |
text-align:left; |
|
17 |
width:640px; |
|
18 |
} |
|
19 |
|
|
20 |
#top |
|
21 |
{ |
|
22 |
display:block; |
|
23 |
height:10px; |
|
24 |
margin:10px auto 0; |
|
25 |
width:650px; |
|
26 |
} |
|
27 |
|
|
28 |
#footer |
|
29 |
{ |
|
30 |
width:640px; |
|
31 |
clear:both; |
|
32 |
color:#999999; |
|
33 |
text-align:center; |
|
34 |
width:640px; |
|
35 |
padding-bottom: 15px; |
|
36 |
font-size: 85%; |
|
37 |
} |
|
38 |
|
|
39 |
#footer a{ |
|
40 |
color:#999999; |
|
41 |
text-decoration: none; |
|
42 |
border-bottom: 1px dotted #999999; |
|
43 |
} |
|
44 |
|
|
45 |
#bottom |
|
46 |
{ |
|
47 |
display:block; |
|
48 |
height:10px; |
|
49 |
margin:0 auto; |
|
50 |
width:650px; |
|
51 |
} |
|
52 |
|
|
53 |
form.appnitro |
|
54 |
{ |
|
55 |
margin:20px 20px 0; |
|
56 |
padding:0 0 20px; |
|
57 |
} |
|
58 |
|
|
59 |
h1 |
|
60 |
{ |
|
61 |
background-color:#6699CC; |
|
62 |
margin:0; |
|
63 |
min-height:0; |
|
64 |
padding:0; |
|
65 |
text-decoration:none; |
|
66 |
text-align: center; |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
h1 a |
|
71 |
{ |
|
72 |
|
|
73 |
display:block; |
|
74 |
height:100%; |
|
75 |
min-height:40px; |
|
76 |
overflow:hidden; |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
h1 img |
|
81 |
{ |
|
82 |
margin-top: 8px; |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
img |
|
87 |
{ |
|
88 |
/*behavior:url(css/iepngfix.htc);*/ |
|
89 |
border:none; |
|
90 |
} |
|
91 |
|
|
92 |
div#form_container h2 |
|
93 |
{ |
|
94 |
margin:1.05em; |
|
95 |
text-shadow: 0.1em 0.1em 0.15em #44F; |
|
96 |
} |
|
97 |
/**** Form Section ****/ |
|
98 |
.appnitro |
|
99 |
{ |
|
100 |
font-family:Lucida Grande, Tahoma, Arial, Verdana, sans-serif; |
|
101 |
font-size:small; |
|
102 |
} |
|
103 |
|
|
104 |
.appnitro li |
|
105 |
{ |
|
106 |
width:61%; |
|
107 |
} |
|
108 |
|
|
109 |
form ul |
|
110 |
{ |
|
111 |
font-size:100%; |
|
112 |
list-style-type:none; |
|
113 |
margin:0; |
|
114 |
padding:0; |
|
115 |
width:100%; |
|
116 |
} |
|
117 |
|
|
118 |
form li |
|
119 |
{ |
|
120 |
display:block; |
|
121 |
margin:0; |
|
122 |
padding:4px 5px 2px 9px; |
|
123 |
position:relative; |
|
124 |
} |
|
125 |
|
|
126 |
form li:after |
|
127 |
{ |
|
128 |
clear:both; |
|
129 |
content:"."; |
|
130 |
display:block; |
|
131 |
height:0; |
|
132 |
visibility:hidden; |
|
133 |
} |
|
134 |
|
|
135 |
.buttons:after |
|
136 |
{ |
|
137 |
clear:both; |
|
138 |
content:"."; |
|
139 |
display:block; |
|
140 |
height:0; |
|
141 |
visibility:hidden; |
|
142 |
} |
|
143 |
|
|
144 |
.buttons |
|
145 |
{ |
|
146 |
clear:both; |
|
147 |
display:block; |
|
148 |
margin-top:10px; |
|
149 |
} |
|
150 |
|
|
151 |
* html form li |
|
152 |
{ |
|
153 |
height:1%; |
|
154 |
} |
|
155 |
|
|
156 |
* html .buttons |
|
157 |
{ |
|
158 |
height:1%; |
|
159 |
} |
|
160 |
|
|
161 |
* html form li div |
|
162 |
{ |
|
163 |
display:inline-block; |
|
164 |
} |
|
165 |
|
|
166 |
form li div |
|
167 |
{ |
|
168 |
color:#444; |
|
169 |
margin:0 4px 0 0; |
|
170 |
padding:0 0 8px; |
|
171 |
} |
|
172 |
|
|
173 |
.clear |
|
174 |
{ |
|
175 |
clear:both; |
|
176 |
} |
|
177 |
|
|
178 |
form li div label |
|
179 |
{ |
|
180 |
clear:both; |
|
181 |
color:#444; |
|
182 |
display:block; |
|
183 |
font-size:9px; |
|
184 |
line-height:9px; |
|
185 |
margin:0; |
|
186 |
padding-top:3px; |
|
187 |
} |
|
188 |
|
|
189 |
|
|
190 |
form li span |
|
191 |
{ |
|
192 |
color:#444; |
|
193 |
float:left; |
|
194 |
margin:0 4px 0 0; |
|
195 |
padding:0 0 8px; |
|
196 |
} |
|
197 |
|
|
198 |
.form_description |
|
199 |
{ |
|
200 |
border-bottom:1px dotted #ccc; |
|
201 |
clear:both; |
|
202 |
display:inline-block; |
|
203 |
margin:0 0 1em; |
|
204 |
} |
|
205 |
|
|
206 |
.form_description[class] |
|
207 |
{ |
|
208 |
display:block; |
|
209 |
} |
|
210 |
|
|
211 |
.form_description h2 |
|
212 |
{ |
|
213 |
clear:left; |
|
214 |
font-size:160%; |
|
215 |
font-weight:400; |
|
216 |
margin:0 0 3px; |
|
217 |
} |
|
218 |
|
|
219 |
.form_description p |
|
220 |
{ |
|
221 |
font-size:95%; |
|
222 |
line-height:130%; |
|
223 |
margin:0 0 12px; |
|
224 |
} |
|
225 |
|
|
226 |
div#infoSize #bulle,#txtInfo |
|
227 |
{ |
|
228 |
display:inline-block; |
|
229 |
} |
|
230 |
|
|
231 |
img#bulle |
|
232 |
{ |
|
233 |
margin-right:1.1em; |
|
234 |
} |
|
235 |
|
|
236 |
#pb_outer { |
|
237 |
height: 20px; |
|
238 |
border: 1px inset #000000; |
|
239 |
width: 80%; |
|
240 |
margin: 20px auto; |
|
241 |
display: none; |
|
242 |
} |
|
243 |
#pb_inner { |
|
244 |
font-weight: bold; |
|
245 |
color: #FFFFFF; |
|
246 |
background-color: #003399; |
|
247 |
height: 20px; |
|
248 |
width: 1px; |
|
249 |
text-align: center; |
|
250 |
} |
|
251 |
|
|
252 |
div#genererPano |
|
253 |
{ |
|
254 |
border:2px inset #FF0; |
|
255 |
border-radius:4px; |
|
256 |
width : 40%; |
|
257 |
margin : auto; |
|
258 |
margin-bottom: 10px; |
|
259 |
|
|
260 |
} |
|
261 |
|
|
262 |
label#l_generer |
|
263 |
{ |
|
264 |
background-color:#6699CC; |
|
265 |
padding:2px; |
|
266 |
border-radius:10px; |
|
267 |
} |
|
268 |
|
envoyer.php | ||
---|---|---|
1 |
<?php $uid = md5(uniqid(rand())); ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> |
|
4 |
<head> |
|
5 |
|
|
6 |
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/> |
|
7 |
<link type="image/x-icon" rel="shortcut icon" href="images/tsf.png"/> |
|
8 |
<link rel="stylesheet" media="screen" href="css/view.css" /> |
|
9 |
<title>Upload d'une image sur le serveur !</title> |
|
10 |
<!-- suivi de l'upload par ajax. Peut être utile pour certains navigateurs qui ne renseigne pas l'avancement. |
|
11 |
<script type="text/javascript"> |
|
12 |
var HttpRequestObject = false; |
|
13 |
if(window.XMLHttpRequest) { |
|
14 |
HttpRequestObject = new XMLHttpRequest(); |
|
15 |
} |
|
16 |
else if(window.ActiveXObject) { |
|
17 |
HttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP"); |
|
18 |
} |
|
19 |
|
|
20 |
function startProgress(uid) { |
|
21 |
|
|
22 |
|
|
23 |
<!--document.getElementById('upload').style.display = 'none';--> |
|
24 |
document.getElementById('pb_outer').style.display = 'block'; |
|
25 |
setTimeout('getProgress("' + uid + '")', 1000); |
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
} |
|
30 |
function getProgress(uid) { |
|
31 |
if(HttpRequestObject) { |
|
32 |
HttpRequestObject.open('GET', 'getprogress.php?uid=' + uid, true); |
|
33 |
HttpRequestObject.onreadystatechange = function() { |
|
34 |
if(HttpRequestObject.readyState == 4 && HttpRequestObject.status == 200) { |
|
35 |
var response = HttpRequestObject.responseText; |
|
36 |
var elem = response.split('#'); |
|
37 |
var progress = elem[0]; |
|
38 |
var url =elem[1]; |
|
39 |
var message=elem[2]; |
|
40 |
|
|
41 |
document.getElementById('pb_inner').style.width = progress + '%'; |
|
42 |
document.getElementById('pb_inner').innerHTML = progress + '%'; |
|
43 |
|
|
44 |
if(progress < 100) { |
|
45 |
|
|
46 |
setTimeout('getProgress("' + uid + '")', 100); |
|
47 |
|
|
48 |
} else { |
|
49 |
if(message !=='') { |
|
50 |
document.getElementById('pb_outer').style.display = 'none'; |
|
51 |
document.getElementById('pb_inner').style.width = 'none'; |
|
52 |
alert(message); |
|
53 |
} else { |
|
54 |
document.getElementById('pb_inner').innerHTML = 'Upload Complete!'; |
|
55 |
document.location.href= url; |
|
56 |
} |
|
57 |
} |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
HttpRequestObject.send(null); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
function showLoader() { |
|
66 |
document.getElementById('loader').innerHTML = "Veuillez patienter ... "; |
|
67 |
|
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
</script> |
|
72 |
</head> |
|
73 |
<body id="main_body"> |
|
74 |
<img id="top" src="images/top.png" alt=""> |
|
75 |
<div id="form_container"> |
|
76 |
<h1><img src="images/tetaneutral.png"></h1> |
|
77 |
|
|
78 |
<form onSubmit="startProgress('<?php echo $uid; ?>');" action="uploadTest.php" method="post" class="appnitro" enctype="multipart/form-data" name="upload" id="upload" target="upload_frame"> |
|
79 |
<h2>Ajouter un nouveau panorama</h2> |
|
80 |
|
|
81 |
<ul> |
|
82 |
<li id="li_1" > |
|
83 |
<label for="file" class="description">Envoyer le fichier :</label> |
|
84 |
<div> |
|
85 |
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $uid; ?>" /> |
|
86 |
<input type="file" name="file" id="file" /> |
|
87 |
</div> |
|
88 |
</li> |
|
89 |
|
|
90 |
<li class="buttons"> |
|
91 |
<input type="submit" name="submit" id="submit" value="Submit" /> |
|
92 |
</li> |
|
93 |
</ul> |
|
94 |
</form> |
|
95 |
<!-- Fin du formulaire --> |
|
96 |
<div id="footer"> |
|
97 |
<a href="./index.php">Retour liste</a> |
|
98 |
</div> |
|
99 |
</div> |
|
100 |
<div id="infoSize"> |
|
101 |
<img src="images/bulle.png" id="bulle"/> |
|
102 |
<label id="txtInfo">Le fichier à envoyer doit etre une image de type .tif ou .jpeg<br /> |
|
103 |
Taille maximale : 300 Mo</label> |
|
104 |
</div> |
|
105 |
<!-- Barre d'upload --> |
|
106 |
<div id="pb_outer"> |
|
107 |
<div id="pb_inner"></div> |
|
108 |
</div> |
|
109 |
<p id="info"></p> |
|
110 |
|
|
111 |
<iframe style="display: none" id="upload_frame" name="upload_frame"></iframe> |
|
112 |
|
|
113 |
<?php |
|
114 |
|
|
115 |
/******************************************************************* |
|
116 |
* Permet d'afficher l'image uploadée sur le serveur |
|
117 |
*******************************************************************/ |
|
118 |
|
|
119 |
if(isset($_GET['img']) && isset($_GET['dir'])){ |
|
120 |
|
|
121 |
apc_delete('link'); // Suppression de la variable cache. |
|
122 |
|
|
123 |
$image_name = htmlspecialchars($_GET['img']); |
|
124 |
$dir_image = htmlspecialchars($_GET['dir']); |
|
125 |
|
|
126 |
$basename = basename($_GET['img']); |
|
127 |
$filePartArr = explode('.', $basename); |
|
128 |
$ext = $filePartArr[count($filePartArr) - 1]; |
|
129 |
if($ext=="tif"){ |
|
130 |
$basename = basename($_GET['img'],".tif"); |
|
131 |
}else if($ext=="jpeg"){ |
|
132 |
$basename = basename($_GET['img'],".jpeg"); |
|
133 |
} else { |
|
134 |
$basename = basename($_GET['img'],".jpg"); |
|
135 |
} |
|
136 |
//Permet d'afficher l'image après uptload ( Conversion des .tiff et .jpg pour affichage dans le navigateur ) |
|
137 |
$input = 'convert /var/www/data/tsf2/vpongnian/panorama/upload/'.$_GET['img'].' -resize 10% /var/www/data/tsf2/vpongnian/panorama/upload/'.$basename.'.jpg'; // Adapter les chemins absolus ou relatifs |
|
138 |
$escaped_command = escapeshellcmd($input); |
|
139 |
$output = shell_exec($escaped_command); |
|
140 |
echo "<pre>$output</pre>\n"; |
|
141 |
|
|
142 |
?><div id="genererPano"> |
|
143 |
<form enctype="multipart/form-data" action="<?php echo "envoyer.php"/*htmlspecialchars($_SERVER['PHP_SELF'])*/; ?>" method="post" onSubmit="showLoader()"> |
|
144 |
<p> |
|
145 |
<label id="l_generer" for="no" title="Génerer le panoramique">Generer le panoramique :</label> |
|
146 |
<input type="hidden" name="image_name" value="<?php echo $image_name; ?>" /> |
|
147 |
<input type="submit" name="no" value="pas maintenant"/> |
|
148 |
<input type="submit" name="yes" value="oui" /> |
|
149 |
<label id="loader"></label> |
|
150 |
</p> |
|
151 |
</form> |
|
152 |
</div> |
|
153 |
<?php |
|
154 |
|
|
155 |
echo "<img src=/data/tsf2/vpongnian/panorama/upload/".$basename.".jpg id='imageUpload'/>"; |
|
156 |
} |
|
157 |
if (isset($_POST['no'])) { |
|
158 |
header("Location: ./index.php"); /* Redirection du navigateur */ |
|
159 |
exit; |
|
160 |
} |
|
161 |
if (isset($_POST['yes'])) { |
|
162 |
header("Location: ./genererPano.php?name=".$_POST['image_name']); |
|
163 |
exit; |
|
164 |
} |
|
165 |
?> |
|
166 |
|
|
167 |
</body> |
|
168 |
</html> |
genererPano.php | ||
---|---|---|
1 |
<?php |
|
2 |
if (isset($_GET['name'])) { |
|
3 |
// Protection de la variable GET |
|
4 |
$pano_name = htmlspecialchars($_GET['name']); |
|
5 |
$filePartArr = explode('.',$pano_name); |
|
6 |
$ext = $filePartArr[count($filePartArr) - 1]; |
|
7 |
if($ext=="tif"){ |
|
8 |
$pano_basename = basename($pano_name,".tif"); |
|
9 |
}else if($ext=="jpeg"){ |
|
10 |
$pano_basename = basename($pano_name,".jpeg"); |
|
11 |
} else { |
|
12 |
$pano_basename = basename($pano_name,".jpg"); |
|
13 |
} |
|
14 |
|
|
15 |
//Partie exécutante du script gen_tiles qui gènere les tuiles à partir d'une image. |
|
16 |
$input = './to_tiles/gen_tiles.sh -p '.$pano_basename.' /var/www/data/tsf2/vpongnian/panorama/upload/'.$pano_name; |
|
17 |
$escaped_command = escapeshellcmd($input); |
|
18 |
$output = shell_exec($escaped_command); |
|
19 |
$log_file = fopen('./log/'.$pano_basename.'.log','a+'); |
|
20 |
fputs($log_file, $output); // verbose intégré dans un .log. |
|
21 |
fclose($log_file); |
|
22 |
|
|
23 |
// Ouverture d'un nouveau dossier qui contiendra toutes les tuiles. |
|
24 |
$dir = '/var/www/data/tsf2/tiles/'.$pano_basename; |
|
25 |
|
|
26 |
mkdir($dir,0777); |
|
27 |
|
|
28 |
$dir_fd = opendir('/var/www/data/tsf2/vpongnian/panorama'); |
|
29 |
|
|
30 |
while (false !== ($image_name = readdir($dir_fd))) { |
|
31 |
// Déplacement des tuiles dans le nouveau dossier à partir de dir_fd. |
|
32 |
if(preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $image_name, $reg)) { |
|
33 |
rename("./".$image_name, $dir."/".$image_name); |
|
34 |
} |
|
35 |
|
|
36 |
} |
|
37 |
closedir($dir_fd); |
|
38 |
header("Location: ./index.php?"); |
|
39 |
} |
|
40 |
?> |
getprogress.php | ||
---|---|---|
1 |
<?php |
|
2 |
header('Expires: Tue, 08 Oct 1991 00:00:00 GMT'); |
|
3 |
header('Cache-Control: no-cache, must-revalidate'); |
|
4 |
|
|
5 |
if(isset($_GET['uid'])){ |
|
6 |
$status = apc_fetch('upload_' . $_GET['uid']); |
|
7 |
$url = apc_fetch('link'); |
|
8 |
$message = apc_fetch('info'); |
|
9 |
echo round($status['current']/$status['total']*100)."#".$url."#".$message; |
|
10 |
} |
|
11 |
?> |
images/locapoint.svg | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|
2 |
<!-- Created with Inkscape (http://www.inkscape.org/) --> |
|
3 |
|
|
4 |
<svg |
|
5 |
xmlns:dc="http://purl.org/dc/elements/1.1/" |
|
6 |
xmlns:cc="http://creativecommons.org/ns#" |
|
7 |
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
|
8 |
xmlns:svg="http://www.w3.org/2000/svg" |
|
9 |
xmlns="http://www.w3.org/2000/svg" |
|
10 |
version="1.1" |
|
11 |
width="34.368469" |
|
12 |
height="63.25069" |
|
13 |
id="svg2"> |
|
14 |
<metadata |
|
15 |
id="metadata8"> |
|
16 |
<rdf:RDF> |
|
17 |
<cc:Work |
|
18 |
rdf:about=""> |
|
19 |
<dc:format>image/svg+xml</dc:format> |
|
20 |
<dc:type |
|
21 |
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> |
|
22 |
<dc:title></dc:title> |
|
23 |
</cc:Work> |
|
24 |
</rdf:RDF> |
|
25 |
</metadata> |
|
26 |
<defs |
|
27 |
id="defs6" /> |
|
28 |
<path |
|
29 |
d="M 17.22788,62.750691 C 16.126185,55.865098 17.254492,46.698747 6.4863542,33.14264 -4.2817838,19.586533 -0.41736984,0.86394177 17.22788,0.50492817 34.873129,0.14591457 38.539189,19.479763 27.969405,33.14264 17.399621,46.805517 17.503304,55.589674 17.22788,62.750691 z" |
|
30 |
id="path2987" |
|
31 |
style="fill:#fa7a6f;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> |
|
32 |
<path |
|
33 |
d="m 27.542374,21.069916 a 8.125,8.675848 0 1 1 -16.25,0 8.125,8.675848 0 1 1 16.25,0 z" |
|
34 |
transform="translate(-2.2331398,-2.2493091)" |
|
35 |
id="path2989" |
|
36 |
style="fill:#000000;fill-opacity:1;stroke:none" /> |
|
37 |
</svg> |
js/hide_n_showForm.js | ||
---|---|---|
1 |
function showForm() { |
|
2 |
|
|
3 |
var displayAddParams = document.getElementById('addParams'); |
|
4 |
var displayAdding = document.getElementById ('adding'); |
|
5 |
displayAddParams.style.visibility = 'hidden'; |
|
6 |
displayAdding.style.visibility = 'visible'; |
|
7 |
} |
|
8 |
|
|
9 |
function hideForm() { |
|
10 |
|
|
11 |
var displayAddParams = document.getElementById('addParams'); |
|
12 |
var displayAdding = document.getElementById ('adding'); |
|
13 |
displayAddParams.style.visibility = 'visible'; |
|
14 |
displayAdding.style.visibility = 'hidden'; |
|
15 |
} |
|
16 |
|
|
17 |
function showLoca() { |
|
18 |
|
|
19 |
var displayloca = document.getElementById('loca'); |
|
20 |
var putDraw = document.getElementById ('locadraw'); |
|
21 |
displayloca.style.visibility = 'hidden'; |
|
22 |
putDraw.style.visibility = 'visible'; |
|
23 |
} |
|
24 |
|
|
25 |
function hideLoca() { |
|
26 |
|
|
27 |
var displayloca = document.getElementById('loca'); |
|
28 |
var putDraw = document.getElementById ('locadraw'); |
|
29 |
displayloca.style.visibility = 'visible'; |
|
30 |
putDraw.style.visibility = 'hidden'; |
|
31 |
} |
js/pano_deroulant.js | ||
---|---|---|
1 |
|
|
2 |
function getInfoBox(element) { |
|
3 |
|
|
4 |
while (element = element.nextSibling) { |
|
5 |
if (element.className === 'infobox') { |
|
6 |
return element; |
|
7 |
} |
|
8 |
} |
|
9 |
|
|
10 |
return false; |
|
11 |
|
|
12 |
} |
|
13 |
|
|
14 |
// Fonctions de vérification du formulaire, elles renvoient « true » si tout est OK |
|
15 |
|
|
16 |
var check = {}; // On met toutes nos fonctions dans un objet littéral |
|
17 |
|
|
18 |
check['param_title'] = function() { |
|
19 |
|
|
20 |
var title = document.getElementById('param_title'); |
|
21 |
|
|
22 |
if (title.value.length >= 4) { |
|
23 |
title.className = 'correct'; |
|
24 |
|
|
25 |
return true; |
|
26 |
} else { |
|
27 |
title.className = 'incorrect'; |
|
28 |
|
|
29 |
return false; |
|
30 |
} |
|
31 |
}; |
|
32 |
|
|
33 |
check['param_latitude'] = function() { |
|
34 |
|
|
35 |
var latitude = document.getElementById('param_latitude'); |
|
36 |
var lat = parseFloat(latitude.value); |
|
37 |
|
|
38 |
if (!isNaN(lat) && lat >= -90 && lat <= 90) { |
|
39 |
latitude.className = 'correct'; |
|
40 |
|
|
41 |
return true; |
|
42 |
|
|
43 |
} else { |
|
44 |
latitude.className = 'incorrect'; |
|
45 |
|
|
46 |
return false; |
|
47 |
} |
|
48 |
|
|
49 |
}; |
|
50 |
|
|
51 |
check['param_longitude'] = function() { |
|
52 |
|
|
53 |
var longitude = document.getElementById('param_longitude'); |
|
54 |
var lon = parseFloat(longitude.value); |
|
55 |
|
|
56 |
if (!isNaN(lon) && lon >= -180 && lon <= 180) { |
|
57 |
longitude.className = 'correct'; |
|
58 |
|
|
59 |
return true; |
|
60 |
|
|
61 |
} else { |
|
62 |
longitude.className = 'incorrect'; |
|
63 |
|
|
64 |
return false; |
|
65 |
} |
|
66 |
|
|
67 |
}; |
|
68 |
|
|
69 |
check['param_altitude'] = function() { |
|
70 |
|
|
71 |
var altitude = document.getElementById('param_altitude'); |
|
72 |
var alt = parseInt(altitude.value); |
|
73 |
|
|
74 |
if (!isNaN(alt) && alt >= 0 && alt <= 10000) { |
|
75 |
altitude.className = 'correct'; |
|
76 |
|
|
77 |
return true; |
|
78 |
|
|
79 |
} else { |
|
80 |
altitude.className = 'incorrect'; |
|
81 |
|
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
}; |
|
86 |
|
|
87 |
check['param_elevation'] = function() { |
|
88 |
|
|
89 |
|
|
90 |
var elevation = document.getElementById('param_elevation'); |
|
91 |
var ele = parseFloat(elevation.value); |
|
92 |
|
|
93 |
if (!isNaN(ele) && ele >= -10 && ele <= 10) { |
|
94 |
elevation.className = 'correct'; |
|
95 |
|
|
96 |
return true; |
|
97 |
|
|
98 |
} else { |
|
99 |
elevation.className = 'incorrect'; |
|
100 |
|
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
}; |
|
105 |
|
|
106 |
(function() { // Utilisation d'une fonction anonyme pour éviter les variables globales. |
|
107 |
|
|
108 |
var form_param = document.getElementById('form_param'), |
|
109 |
inputs = document.getElementsByTagName('input'), |
|
110 |
inputsLength = inputs.length; |
|
111 |
|
|
112 |
for (var i = 0 ; i < inputsLength ; i++) { |
|
113 |
|
|
114 |
if (inputs[i].type == 'text') { |
|
115 |
|
|
116 |
inputs[i].onkeyup = function() { |
|
117 |
check[this.id](this.id); // « this » représente l'input actuellement modifié |
|
118 |
}; |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
form_param.onsubmit = function() { |
|
125 |
|
|
126 |
var result = true; |
|
127 |
|
|
128 |
for (var i in check) { |
|
129 |
|
|
130 |
result = check[i](i) && result; |
|
131 |
} |
|
132 |
|
|
133 |
if (result) { |
|
134 |
alert('Le formulaire est bien rempli.'); |
|
135 |
return true; |
|
136 |
} else { |
|
137 |
|
|
138 |
return false; |
|
139 |
} |
|
140 |
|
|
141 |
}; |
|
142 |
|
|
143 |
form_param.onreset = function() { |
|
144 |
|
|
145 |
for (var i = 0 ; i < inputsLength ; i++) { |
|
146 |
if (inputs[i].type == 'text' || inputs[i].type == 'number') { |
|
147 |
inputs[i].className = ''; |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
}; |
|
152 |
|
|
153 |
})(); |
uploadTest.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// Constantes |
|
4 |
define('TARGET', '/var/www/data/tsf2/vpongnian/panorama/upload/'); // Repertoire cible |
|
5 |
define('MAX_SIZE', 300000000); // Taille max en octets du fichier |
|
6 |
define('WIDTH_MAX', 200000); // Largeur max de l'image en pixels |
|
7 |
define('HEIGHT_MAX', 100000); // Hauteur max de l'image en pixels |
|
8 |
|
|
9 |
|
|
10 |
// Creation du repertoire cible si inexistant |
|
11 |
|
|
12 |
/*if( !is_dir(TARGET) ) { |
|
13 |
if( !mkdir(TARGET, 0755) ) { |
|
14 |
exit('Erreur : le répertoire cible ne peut-être créé ! Vérifiez que vous diposiez des droits suffisants pour le faire ou créez le manuellement !'); |
|
15 |
} |
|
16 |
} |
|
17 |
*/ |
|
18 |
|
|
19 |
// Script d'upload |
|
20 |
|
|
21 |
// Variables |
|
22 |
$extension = ''; |
|
23 |
$message = ''; |
|
24 |
$nomImage = ''; |
|
25 |
$url=''; |
|
26 |
$already=false; |
|
27 |
|
|
28 |
// Tableaux de donnees |
|
29 |
$tabExt = array('jpeg','tif','jpg'); // Extensions autorisees |
|
30 |
$infosImg = array(); |
|
31 |
$stats = array(); |
|
32 |
|
|
33 |
|
|
34 |
if(!empty($_POST)) |
|
35 |
{ |
|
36 |
|
|
37 |
// On verifie si le champ est rempli |
|
38 |
if( !empty($_FILES['file']['name']) ) |
|
39 |
{ |
|
40 |
|
|
41 |
// Recuperation de l'extension du fichier |
|
42 |
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); |
|
43 |
|
|
44 |
// On verifie l'extension du fichier |
|
45 |
if(in_array(strtolower($extension),$tabExt)) |
|
46 |
{ |
|
47 |
// On recupere les dimensions du fichier |
|
48 |
$infosImg = getimagesize($_FILES['file']['tmp_name']); |
|
49 |
|
|
50 |
// On verifie les dimensions et taille de l'image |
|
51 |
if(($infosImg[0] <= WIDTH_MAX) && ($infosImg[1] <= HEIGHT_MAX) && (filesize($_FILES['file']['tmp_name']) <= MAX_SIZE)) |
|
52 |
{ |
|
53 |
// Parcours du tableau d'erreurs |
|
54 |
if(isset($_FILES['file']['error']) |
|
55 |
&& UPLOAD_ERR_OK === $_FILES['file']['error']) |
|
56 |
{ |
|
57 |
// On bouge le fichier uploadé dans un répertoire a son nom |
|
58 |
// on garde en cache la variable $url qui permettra de passer sur une page envoyer.php plus avancée. |
|
59 |
|
|
60 |
$err = $_FILES['file']['error']; |
|
61 |
echo "<script>alert(\"$err\");</script>"; |
|
62 |
$url ="envoyer.php?dir=upload/".$_FILES['file']['name']."&img=".$_FILES['file']['name']; |
|
63 |
move_uploaded_file($_FILES['file']['tmp_name'],TARGET.basename($_FILES['file']['name'])); |
|
64 |
apc_store('link', $url); |
|
65 |
|
|
66 |
} |
|
67 |
else |
|
68 |
{ |
|
69 |
$message = 'Une erreur interne a empêché l\'uplaod de l\'image : '. $_FILES['file']['error']; |
|
70 |
} |
|
71 |
} |
|
72 |
else |
|
73 |
{ |
|
74 |
// Sinon erreur sur les dimensions et taille de l'image |
|
75 |
$message = 'Erreur dans les dimensions de l\'image !'; |
|
76 |
} |
|
77 |
} |
|
78 |
else |
|
79 |
{ |
|
80 |
// Sinon on affiche une erreur pour l'extension |
|
81 |
$message = 'L\'extension du fichier est incorrecte !'; |
|
82 |
} |
|
83 |
} |
|
84 |
else |
|
85 |
{ |
|
86 |
// Sinon on affiche une erreur pour le champ vide |
|
87 |
$message = 'Veuillez remplir le formulaire svp !'; |
|
88 |
} |
|
89 |
// On met en cache un message d'erreur. |
|
90 |
apc_store('info', $message); |
|
91 |
} |
|
92 |
?> |
Formats disponibles : Unified diff
maj suite au stage de Victor Pongnian