<?php
class ControllerCommonLogout extends Controller {
	public function index() {
        $user_id = $this->user->getId();
        $username = $this->user->getUserName();
    
        $this->user->logout();
    
        $this->db->query("INSERT INTO " . DB_PREFIX . "admin_login_log SET
            user_id = '" . (int)$user_id . "',
            username = '" . $this->db->escape($username) . "',
            action = 'logout',
            ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "',
            date_added = NOW()
        ");
    
        unset($this->session->data['user_token']);
    
        $this->response->redirect($this->url->link('common/login', '', true));
    }

}