From 9804bcb9e8b1b7418f0e38e56a8800888d68f64d Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 2 Jan 2024 13:35:06 +0700 Subject: [PATCH] log class --- system/autoload/Log.php | 32 ++++++++++++++++++++++++++++++++ system/boot.php | 8 +------- 2 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 system/autoload/Log.php diff --git a/system/autoload/Log.php b/system/autoload/Log.php new file mode 100644 index 00000000..fc61d1c5 --- /dev/null +++ b/system/autoload/Log.php @@ -0,0 +1,32 @@ +create(); + $d->date = date('Y-m-d H:i:s'); + $d->type = $type; + $d->description = $description; + $d->userid = $userid; + $d->ip = (empty($username)) ? $_SERVER["REMOTE_ADDR"] : $username; + $d->save(); + } + + public static function arrayToText($array, $start = '', $result = '') + { + foreach ($array as $k => $v) { + if (is_array($v)) { + $result = Log::arrayToText($v, "$start$k.", $result); + } else { + $result .= $start.$k ." : ". strval($v) ."\n"; + } + } + return $result; + } +} \ No newline at end of file diff --git a/system/boot.php b/system/boot.php index 4294c485..56ed2d60 100644 --- a/system/boot.php +++ b/system/boot.php @@ -223,13 +223,7 @@ function _admin($login = true) function _log($description, $type = '', $userid = '0') { - $d = ORM::for_table('tbl_logs')->create(); - $d->date = date('Y-m-d H:i:s'); - $d->type = $type; - $d->description = $description; - $d->userid = $userid; - $d->ip = $_SERVER["REMOTE_ADDR"]; - $d->save(); + Log::put($type, $description, $userid); } function Lang($key)