-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
44 lines (34 loc) · 1.22 KB
/
test.php
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
<?php
require 'Utilis.php';
require 'WebServiceClient.php';
//$token = 'MU98HLYT6DVBLC0Z';
$token = '8NC3LSONB6GX8YGL';
$humidity = isset($_GET['hum']) ? $_GET['hum'] : 60;
$temperature = isset($_GET['temp']) ? $_GET['temp'] : 25;
$pressure = isset($_GET['press']) ? $_GET['press'] : 980;
$luminosity = isset($_GET['lux']) ? $_GET['lux'] : 150;
$humidity += mt_rand(0,4) - 2;
$temperature += round(mt_rand(0, mt_getrandmax() - 1) / mt_getrandmax() * 3 - 1.5, 1);
$pressure += round(mt_rand(0, mt_getrandmax() - 1) / mt_getrandmax() * 2 - 1.0, 2);
$luminosity += mt_rand(0,4) - 2;
if($humidity > 100 || $humidity < 0)
$humidity = 50;
if($temperature > 50 || $temperature < (-15))
$temperature = 20.0;
if($pressure > 1000 || $pressure < 970)
$pressure = 985.0;
if($luminosity > 1000 || $luminosity < 0 )
$luminosity = 200;
//ws
WebServiceClient::save_values($token, $temperature, $pressure, $humidity, $luminosity);
//WebServiceClient::save_values($token, 0.0, 0.00, 0, 0);
$url = 'test.php?hum=' . $humidity . '&temp=' . $temperature . '&press=' . $pressure . '&lux=' . $luminosity;
?>
<html>
<head>
<meta http-equiv="refresh" content="5;URL='<?php echo $url?>'">
</head>
<body>
we we
</body>
</html>