envoiFichiers.php
3.71 KB
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
136
137
138
139
140
<?php
session_start();
$error = false;
/*$error2 = false;
if ( isset($_POST['sensor']) && count($_POST['sensor']<>0) ) {
$xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\r\n"
.'<all>';
foreach($_POST['sensor'] as $sensor => $value)
{
$val = explode(":", $value);
if(count($types)<>0 && !in_array($val[2], $types)) {$error2 = true;}
else {$types[] = $val[2];}
$xml = $xml. '<sensor>' . '<raspberry>' . htmlspecialchars($val[0]) . '</raspberry>' . '<numero>' . htmlspecialchars($val[1]) . '</numero>' . '</sensor>';
$xml = $xml."\r\n";
}
$xml = $xml.'</all>';
if(!$error2) {file_put_contents('upload/sensor.xml', $xml) ;}
}*/
if(isset($_POST['sensor']) && count($_POST['sensor']<>0))
{
$ini = "";
$arduino_simple = "[Arduino]\r\n";
$arduino_spi = "[Arduino_spi]\r\n";
$nucleo = "[Nucleo]\r\n";
$a_simple = false;
$a_spi = false;
$n = false;
foreach($_POST['sensor'] as $sensor => $value)
{
$val = explode(":", $value);
if(count($types)<>0 && !in_array($val[2], $types)) {$error = true;}
else {$types[] = $val[2];}
$version = 1;//getSensorVersion($val[0], $val[1]);
if($version == 0)
{
$a_simple = true;
$arduino_simple = $arduino_simple.$val[0]." capteur=".$val[1]."\n";
}
elseif($version == 1)
{
$a_spi = true;
$arduino_spi = $arduino_spi.$val[0]." capteur=".$val[1]."\n";
}
elseif($version == 2)
{
$n = true;
$nucleo = $nucleo.$val[0]." capteur=".$val[1]."\n";
}
}
echo $arduino_simple;
echo $arduino_spi;
echo $nucleo;
if($a_simple) {$ini = $ini.$arduino_simple."\n";}
if($a_spi) {$ini = $ini.$arduino_spi."\n";}
if($n) {$ini = $ini.$nucleo."\n";}
if(!$error) {file_put_contents('upload/inventaire.ini', $ini);}
}
?>
<!DOCTYPE html>
<html>
<head>
<?php include("head.php"); ?>
</head>
<!-- Contenu du site -->
<body>
<?php
include("header.php");
if(!$error)
{
$upload1 = upload('fichier',FALSE, array('c', 'txt') );
?>
<div class="row">
<div class="col-4 col-md-4 offset-md-4 offset-4">
<br/>
<h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-cloud"></i> Envoi du fichier en ligne</h1>
<?php if($upload1){
?>
<div class="alert alert-success" role="alert">
Upload du fichier réussi !
</div>
<?php
}
else {?>
<div class="alert alert-danger" role="alert">
Erreur lors du transfert du fichier !
</div><?php
}
?>
<h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-info-circle"></i> Informations complémentaires</h1>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td>Nom du fichier</td>
<td><?php echo $_FILES['fichier']['name'];?></td>
</tr>
<tr>
<td>Type</td>
<td><?php echo $_FILES['fichier']['type'];?></td>
</tr>
<tr>
<td>Localisation</td>
<td><?php echo $_FILES['fichier']['tmp_name'];?></td>
</tr>
<tr>
<td>Erreur</td>
<td><?php echo $_FILES['fichier']['error'];?></td>
</tr>
<tr>
<td>Taille</td>
<td><?php echo $_FILES['fichier']['size'];?></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php }
else
{
?>
<div class="row">
<div class="col-4 col-md-4 offset-md-4 offset-4">
<br/>
<h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;"><i class="fa fa-cloud"></i> Envoi du fichier en ligne</h1>
<div class="alert alert-danger" role="alert">
Vous devez choisir des capteurs de même type !
</div>
<meta http-equiv="Refresh" content="3;url=send.php" />
</div>
</div>
<?php
}
?>
</body>
</html>