Oprava chyb v Logging.php, uprava tabuliek
- oprava tabuliek created_at, CURRENT_TIMESTAMP - pridanie memory_total, load - apcu fix
This commit is contained in:
@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\DB;
|
||||
class Logging extends Controller
|
||||
{
|
||||
|
||||
private $_items = [ 'netstat_sent' => 'i', 'netstat_recv' => 'i', 'memory_free' => 'f', 'memory_total' => 'f', 'memory_used' => 'f', 'disk_free' => 'B', 'disk_percent' => 'f', 'disk_used' => 'B', 'disk_total' => 'B', 'processes' => 'i', 'temp' => 'i', 'username' =>'s', 'computer' => 's'];
|
||||
private $_items = [ 'netstat_sent' => 'i', 'netstat_recv' => 'i', 'memory_free' => 'f', 'memory_total' => 'f', 'memory_used' => 'f', 'disk_free' => 'B', 'disk_percent' => 'f', 'disk_used' => 'B', 'disk_total' => 'B', 'processes' => 'i', 'temp' => 'i', 'load' => 'f', 'username' =>'s', 'computer' => 's'];
|
||||
|
||||
private $_values = [];
|
||||
private $_ucache = [];
|
||||
@@ -26,7 +26,7 @@ class Logging extends Controller
|
||||
foreach ($q as $v) {
|
||||
$this->_ucache[$v->name] = $v->id;
|
||||
}
|
||||
\apcu_add('users',$this->_ucache);
|
||||
\apcu_store('users',$this->_ucache);
|
||||
}
|
||||
$this->_ccache = \apcu_fetch('computers',$ret);
|
||||
if ($ret == false ) {
|
||||
@@ -34,31 +34,32 @@ class Logging extends Controller
|
||||
foreach ($q as $v) {
|
||||
$this->_ucache[$v->computer] = $v->id;
|
||||
}
|
||||
\apcu_add('computers',$this->_ccache);
|
||||
\apcu_store('computers',$this->_ccache);
|
||||
}
|
||||
}
|
||||
|
||||
private function get_computer_id($comp){
|
||||
if ($this->_ccache[$comp]) {
|
||||
if (isset($this->_ccache[$comp])) {
|
||||
return $this->_ccache[$comp];
|
||||
}
|
||||
|
||||
$id = DB::table('computers')->insertGetId(['computer' => $comp]);
|
||||
$this->_ccache[$comp] = $id;
|
||||
|
||||
\apcu_add('computers',$this->_ccache);
|
||||
\apc_store('computers',$this->_ccache);
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
private function get_user_id($user) {
|
||||
if ($this->_ucache[$user]) {
|
||||
if (isset($this->_ucache[$user])) {
|
||||
return $this->_ucache[$user];
|
||||
}
|
||||
|
||||
$id = DB::table('users')->insertGetId(['name' => $user]);
|
||||
$id = DB::table('users')->insertGetId(['name' => $user, 'email' => $user]);
|
||||
$this->_ucache[$user] = $id;
|
||||
|
||||
\apcu_add('users',$this->_ucache);
|
||||
\apcu_store('users',$this->_ucache);
|
||||
return $id;
|
||||
}
|
||||
|
||||
@@ -116,9 +117,9 @@ class Logging extends Controller
|
||||
|
||||
$this->parse($v);
|
||||
|
||||
$ia = array_filter($this->_values, function($v) {
|
||||
return $v != 's';
|
||||
});
|
||||
$ia = array_merge($this->_values);
|
||||
unset($ia["computer"]);
|
||||
unset($ia["username"]);
|
||||
|
||||
$cid = $this->get_computer_id($this->_values["computer"]);
|
||||
$uid = $this->get_user_id($this->_values["username"]);
|
||||
|
||||
Reference in New Issue
Block a user