Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server="localhost";
- $user="root";
- $pass="";
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
- $ip = $_SERVER['HTTP_CLIENT_IP'];
- } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- } else {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- $device_id = $_SERVER ['HTTP_USER_AGENT'];
- $dbh = new PDO("mysql:host=$server;dbname=weather_station",$user,$pass);
- $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
- $stmt = $dbh->prepare("INSERT INTO weather_station_bot (id, ip, device_id, temperature, humidity, rain, wind_speed, wind_speed_raw, wind_direction, pressure, uv, tilt, vin, count, elapsed_time, ethernet_error_count, chip_temp, box_temp, smog, version, error_num, error_msg, deleted_at, created_at, updated_at)
- VALUES (:id, :ip, :device_id, :temperature, :humidity, :rain, :wind_speed, :wind_speed_raw,: wind_direction, :pressure, :uv, :tilt, :vin, :count, :elapsed_time, :ethernet_error_count, :chip_temp, :box_temp, :smog, :version, :error_num, :error_msg, :deleted_at, :created_at, :updated_at)");
- $stmt->bindParam(':id', $id);
- $stmt->bindParam(':ip', $ip);
- $stmt->bindParam(':device_id', $device_id);
- $stmt->bindParam(':temperature', $temperature);
- $stmt->bindParam(':humidity', $humidity);
- $stmt->bindParam(':rain', $rain);
- $stmt->bindParam(':wind_speed', $wind_speed);
- $stmt->bindParam(':wind_speed_raw', $wind_speed_raw);
- $stmt->bindParam(':wind_direction', $wind_direction);
- $stmt->bindParam(':pressure', $pressure);
- $stmt->bindParam(':uv', $uv);
- $stmt->bindParam(':tilt', $tilt);
- $stmt->bindParam(':vin', $vin);
- $stmt->bindParam(':count', $count);
- $stmt->bindParam(':elapsed_time', $elapsed_time);
- $stmt->bindParam(':ethernet_error_count', $ethernet_error_count);
- $stmt->bindParam(':chip_temp', $chip_temp);
- $stmt->bindParam(':box_temp', $box_temp);
- $stmt->bindParam(':smog', $smog);
- $stmt->bindParam(':version', $version);
- $stmt->bindParam(':error_num', $error_num);
- $stmt->bindParam(':error_msg', $error_msg);
- $stmt->bindParam(':deleted_at', $deleted_at);
- $stmt->bindParam(':created_at', $created_at);
- $stmt->bindParam(':updated_at', $updated_at);
- $id=$_POST["id"];
- $temperature=$_POST["temperature"];
- $humidity=$_POST["humidity"];
- $rain=$_POST["rain"];
- $wind_speed=$_POST["wind_speed"];
- $wind_speed_raw=$_POST["wind_speed_raw"];
- $wind_direction=$_POST["wind_direction"];
- $pressure=$_POST["pressure"];
- $uv=$_POST["uv"];
- $vin=$_POST["vin"];
- $tilt=$_POST["tilt"];
- $count=$_POST["count"];
- $elapsed_time=$_POST["elapsed_time"];
- $ethernet_error_count=$_POST["ethernet_error_count"];
- $chip_temp=$_POST["chip_temp"];
- $box_temp=$_POST["box_temp"];
- $smog=$_POST["smog"];
- $version=$_POST["version"];
- $error_num=$_POST["error_num"];
- $error_msg=$_POST["error_msg"];
- $deleted_at=$_POST["deleted_at"];
- $created_at=$_POST["created_at"];
- $updated_at=$_POST["updated_at"];
- $stmt->execute();
- echo "New record";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement