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']);
|
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)
|
14
|
{
|
15
|
$value = htmlspecialchars($value);
|
16
|
}
|
17
|
|
18
|
|
19
|
|
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
|
|
24
|
}
|
25
|
else
|
26
|
{
|
27
|
echo 'Le ' . $_POST['param_latitude'] . ' n\'est pas valide, recommencez !';
|
28
|
|
29
|
}
|
30
|
|
31
|
|
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
|
|
36
|
}
|
37
|
else
|
38
|
{
|
39
|
echo 'Le ' . $_POST['param_longitude'] . ' n\'est pas valide, recommencez !';
|
40
|
|
41
|
}
|
42
|
|
43
|
|
44
|
if (preg_match("#^([1-9]+[0-9]{0,4}|0)$#", $_POST['param_altitude']))
|
45
|
{
|
46
|
$alt = $_POST['param_altitude'];
|
47
|
|
48
|
}
|
49
|
else
|
50
|
{
|
51
|
echo 'Le ' . $_POST['param_altitude'] . ' n\'est pas valide, recommencez !';
|
52
|
|
53
|
}
|
54
|
|
55
|
|
56
|
if (preg_match("#^(\-?[1-9]+[0-9]?|0)$#", $_POST['param_elevation']))
|
57
|
{
|
58
|
$ele = $_POST['param_elevation'];
|
59
|
|
60
|
}
|
61
|
else
|
62
|
{
|
63
|
echo 'Le ' . $_POST['param_elevation'] . ' n\'est pas valide, recommencez !';
|
64
|
|
65
|
}
|
66
|
|
67
|
$loop = $_POST['param_loop'];
|
68
|
if(isset($lat) && isset($lon) && isset($alt) && isset($ele) && isset($loop)) {
|
69
|
|
70
|
|
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
|
|
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;
|
79
|
}
|
80
|
}
|
81
|
closedir($dir_open);
|
82
|
|
83
|
$retour = "\n";
|
84
|
|
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>
|