diff --git a/web/application/controllers/base.php b/web/application/controllers/base.php index b100240..53b29cb 100644 --- a/web/application/controllers/base.php +++ b/web/application/controllers/base.php @@ -34,6 +34,7 @@ abstract class base extends \system\engine\HF_Controller { $this->session->sessionid = $sessionId; $this->session->random = 0; $this->session->save(); + $this->saveSession(); setcookie("session", $sessionId, 2147483647, "/"); } } else { @@ -44,11 +45,21 @@ abstract class base extends \system\engine\HF_Controller { $this->session->userAgent = $_SERVER["HTTP_USER_AGENT"]; $this->session->sessionid = $sessionId; $this->session->random = 0; - $this->session->id = $this->session->save(); + $this->session->save(); + $this->saveSession(); setcookie("session", $sessionId, 2147483647, "/"); } } + protected function saveSession() { + $sessionlog = new \application\models\Sessionlogs(); + $sessionlog->ip = $this->session->ip; + $sessionlog->original_id = $this->session->id; + $sessionlog->userAgent = $this->session->userAgent; + $sessionlog->sessionid = $this->session->sessionid; + $sessionlog->save(); + } + public function __construct($config, $core, $tpl) { parent::__construct($config, $core, $tpl); diff --git a/web/application/migrations/1.php b/web/application/migrations/1.php index 2d7ff98..b821af7 100644 --- a/web/application/migrations/1.php +++ b/web/application/migrations/1.php @@ -15,4 +15,12 @@ DB::query("CREATE TABLE sessions ( to_user INTEGER, lastPing INTEGER, random TINYINT(1) +)"); + +DB::query("CREATE TABLE sessionlogs ( + id INTEGER PRIMARY KEY $autoIncrement, + original_id INTEGER, + sessionid VARCHAR(255), + ip VARCHAR(255), + userAgent VARCHAR(255) )"); \ No newline at end of file diff --git a/web/application/models/sessionlogs.php b/web/application/models/sessionlogs.php new file mode 100644 index 0000000..62cdbbd --- /dev/null +++ b/web/application/models/sessionlogs.php @@ -0,0 +1,10 @@ +