CSV support for telemetry
This commit is contained in:
parent
cd1168f78b
commit
b197e2fc78
|
@ -49,4 +49,25 @@ if($db_type=="mysql"){
|
|||
$stmt->execute(array($ip,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||
$conn = null;
|
||||
}
|
||||
elseif($db_type=="csv"){
|
||||
// Prepare the csv formatted string
|
||||
date_default_timezone_set($timezone);
|
||||
$date = date('Y-m-d H:M:S');
|
||||
$str = '"' . $ip . '",';
|
||||
$str .= '"' . $ua . '",';
|
||||
$str .= '"' . $dl . '",';
|
||||
$str .= '"' . $ul . '",';
|
||||
$str .= '"' . $ping . '",';
|
||||
$str .= '"' . $jitter . '",';
|
||||
$str .= '"' . $$log . '"' . "\n";
|
||||
|
||||
// Set header if this is a new file
|
||||
if (!file_exists($Csv_File)) {
|
||||
$header = '"ip","ua","download","upload","ping","jitter","log"' . "\n";
|
||||
file_put_contents($Csv_File, $header, FILE_APPEND);
|
||||
}
|
||||
|
||||
// Writting line to file
|
||||
file_put_contents($Csv_File, $str, FILE_APPEND);
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
$db_type="mysql"; //Type of db: "mysql", "sqlite" or "postgresql"
|
||||
$db_type="mysql"; //Type of db: "mysql", "sqlite" or "postgresql" or "csv"
|
||||
|
||||
// Sqlite3 settings
|
||||
$Sqlite_db_file = "../telemetry.sql";
|
||||
|
@ -17,4 +17,8 @@ $PostgreSql_password="PASSWORD";
|
|||
$PostgreSql_hostname="DB_HOSTNAME";
|
||||
$PostgreSql_databasename="DB_NAME";
|
||||
|
||||
// CSV settings
|
||||
$Csv_File="reports.csv";
|
||||
$timezone='UTC';
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue