1
|
<!DOCTYPE html>
|
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
|
3
|
<head>
|
4
|
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
|
5
|
<link rel="stylesheet" media="screen" href="css/index_style.css" />
|
6
|
<title>Positionnerment dun panoramique</title>
|
7
|
<?php
|
8
|
|
9
|
$params = array('title' => array('name' => 'titre',
|
10
|
'pattern' => '^.{1,50}$',
|
11
|
'required' => true),
|
12
|
'latitude' => array('name' => 'latitude',
|
13
|
'type' => 'numeric',
|
14
|
'min' => -180,
|
15
|
'max' => 180,
|
16
|
'required' => true),
|
17
|
'longitude' => array('name' => 'longitude',
|
18
|
'type' => 'numeric',
|
19
|
'min' => -180,
|
20
|
'max' => 180,
|
21
|
'required' => true),
|
22
|
'altitude' => array('name' => 'altitude',
|
23
|
'type' => 'numeric',
|
24
|
'min' => -180,
|
25
|
'max' => 180,
|
26
|
'required' => true),
|
27
|
'loop' => array('name' => 'image_loop',
|
28
|
'type' => 'boolean',
|
29
|
'required' => false),
|
30
|
'dir' => array('required' => true),
|
31
|
'panorama' => array('required' => true));
|
32
|
$wrong = array();
|
33
|
$values = array();
|
34
|
|
35
|
foreach($params as $param => $check) {
|
36
|
if (isset($_REQUEST['param_'.$param])) {
|
37
|
$tst = $_REQUEST['param_'.$param];
|
38
|
if ((isset($check['min']) || isset($check['max'])) && ! is_numeric($tst)) $wrong[$param] = "<em>$tst</em> ne correspond pas à une valeur numérique";
|
39
|
else if (isset($check['min']) && $tst < $check['min']) $wrong[$param] = "<em>$tst</em> trop bas";
|
40
|
else if (isset($check['max']) && $tst > $check['max']) $wrong[$param] = "<em>$tst</em> trop haut";
|
41
|
else if (isset($check['pattern']) && preg_match('/'.preg_quote($check['pattern']).'/', $tst)) $wrong[$param] = "<em>$tst</em> non conforme";
|
42
|
else $values[$param] = $tst;
|
43
|
} else if (isset($check['required']) && $check['required']) {
|
44
|
$wrong[$param] = '<em>$tst</em> est un paramètre manquant';
|
45
|
}
|
46
|
}
|
47
|
|
48
|
if (isset($values['panorama'])) {
|
49
|
$back_url = sprintf('panorama.php?panorama=%s', $values['panorama']);
|
50
|
if (isset($values['dir'])) $back_url .= '&dir='. $values['dir'];
|
51
|
} else {
|
52
|
$back_url = '.';
|
53
|
}
|
54
|
|
55
|
if (count($wrong) == 0) {
|
56
|
|
57
|
$dir_file = "./".$values['dir']."/".$values['panorama'];
|
58
|
$dir_open = opendir($dir_file);
|
59
|
while (false !== ($file = readdir($dir_open))) {
|
60
|
|
61
|
if (preg_match('/(.*)_[0-9]+_[0-9]+_[0-9]+\.jpg$/', $file, $reg)) {
|
62
|
$prefix = $reg[1];
|
63
|
$new_param_file = $prefix.".params";
|
64
|
break;
|
65
|
}
|
66
|
}
|
67
|
closedir($dir_open);
|
68
|
|
69
|
|
70
|
if(isset($new_param_file)){
|
71
|
$fid = fopen($dir_file."/".$new_param_file,'a+');
|
72
|
echo '<p>Les valeurs suivantes sont utilisées.</p>'."\n";
|
73
|
echo "<dl>\n";
|
74
|
foreach ($values as $k => $v) {
|
75
|
echo "$k -$v<br/>\n";
|
76
|
if (isset($params[$k]['name'])) {
|
77
|
$nm = $params[$k]['name'];
|
78
|
if (isset($params[$k]['type']) && $params[$k]['type'] == 'numeric') {
|
79
|
$vf = $v;
|
80
|
} else if (isset($params[$k]['type']) && $params[$k]['type'] == 'boolean') {
|
81
|
$vf = $v ? "true" : "false";
|
82
|
} else {
|
83
|
$vf = "\"$v\"";
|
84
|
}
|
85
|
fputs($fid, "$nm = $vf\n");
|
86
|
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $nm, $vf);
|
87
|
}
|
88
|
}
|
89
|
echo "</dl>\n";
|
90
|
fclose($fid);
|
91
|
echo '<p class="succes">Paramétrage terminé.</p>'."\n";
|
92
|
} else {
|
93
|
printf("<p class=\"error\">impossible d'écrire dans le fichier '%s'</p>\n", $dir_file);
|
94
|
}
|
95
|
} else {
|
96
|
echo '<p class="error">Les valeurs suivantes sont incorrectes.</p>'."\n";
|
97
|
echo "<dl>\n";
|
98
|
foreach ($wrong as $k => $v) {
|
99
|
printf("<dt>%s</dt>\n<dd>%s</dd>\n", $k, $v);
|
100
|
}
|
101
|
echo "</dl>\n";
|
102
|
}
|
103
|
printf('<a href="%s">Retour au panorama</a></p>'."\n", $back_url);
|
104
|
|
105
|
?>
|
106
|
</html>
|