From ffb9742efbef6894611fc27cbe8ae928ed641f15 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Fri, 15 Nov 2019 14:55:01 +0100 Subject: [PATCH] Loggin fixed --- app/Http/Controllers/Logging.php | 48 +++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/app/Http/Controllers/Logging.php b/app/Http/Controllers/Logging.php index 2019197..1ad1b36 100644 --- a/app/Http/Controllers/Logging.php +++ b/app/Http/Controllers/Logging.php @@ -19,8 +19,10 @@ class Logging extends Controller function conv_bytes($v) { $units = explode(' ', ' K M G T P E Z Y'); - preg_match('/([0-9]+)([GKMTgkmT])?B/',$v,$vu); - $v1 = $vu[1]; + + preg_match('/([0-9]+)([GKMTgkmT])?B/',$v,$vu); + + $v1 = $vu[1]; if (count($vu) == 3) $v2 = $vu[2]; else @@ -37,38 +39,38 @@ class Logging extends Controller public function parse($vals) { - foreach ($vals as $k => $v) - { - if (is_array($k)) { - foreach ($v as $k2 => $v2) { - $this->_values["$k"."_"."$k2"] = $v2; - } - } else { - $this->_values[$k] = $v; - } - } + foreach ($vals as $k => $v) + { + if (is_array($v)) { + foreach ($v as $k2 => $v2) { + $this->_values["$k"."_"."$k2"] = $v2; + } + } else { + $this->_values[$k] = $v; + } + } - foreach ($this->_items as $k => $v) { - $t = $this->_items[$k]; - if ($t == 's') continue; + foreach ($this->_items as $k => $t) { + $val = $this->_values[$k]; + if ($t == 's') continue; - if ($t == 'B') $v = $this->conv_bytes($v); + if ($t == 'B') $val = intval($this->conv_bytes($val)); - if ($t == 'f') $v = floatval($v); - if ($t == 'i') $v = intval($v); + if ($t == 'f') $val = floatval($val); + if ($t == 'i') $val = intval($val); - $this->_values[$k] = $v; - } + $this->_values[$k] = $val; + } } public function log(Request $request) { $data = json_decode($request->getContent(), true); $v = $data["values"]; $i = $data["items"]; - var_export($v); -// $this->parse($v); + + $this->parse($v); -// var_dump($this->_values); + var_export($this->_values); return "OK"; //DB::insert('insert into values (user,computer,recv,send) values (?, ?, ?, ?)', [$u, $c, $r, $s]);