403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.216.196
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/kanboard/app/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/kanboard/app/Model/LastLoginModel.php
<?php

namespace Kanboard\Model;

use Kanboard\Core\Base;

/**
 * LastLogin model
 *
 * @package  Kanboard\Model
 * @author   Frederic Guillot
 */
class LastLoginModel extends Base
{
    /**
     * SQL table name
     *
     * @var string
     */
    const TABLE = 'last_logins';

    /**
     * Number of connections to keep for history
     *
     * @var integer
     */
    const NB_LOGINS = 10;

    /**
     * Create a new record
     *
     * @access public
     * @param  string   $auth_type   Authentication method
     * @param  integer  $user_id     User id
     * @param  string   $ip          IP Address
     * @param  string   $user_agent  User Agent
     * @return boolean
     */
    public function create($auth_type, $user_id, $ip, $user_agent)
    {
        $this->cleanup($user_id);

        return $this->db
            ->table(self::TABLE)
            ->insert(array(
                'auth_type' => $auth_type,
                'user_id' => $user_id,
                'ip' => $ip,
                'user_agent' => substr($user_agent, 0, 255),
                'date_creation' => time(),
            ));
    }

    /**
     * Cleanup login history
     *
     * @access public
     * @param  integer $user_id
     */
    public function cleanup($user_id)
    {
        $connections = $this->db
                            ->table(self::TABLE)
                            ->eq('user_id', $user_id)
                            ->desc('id')
                            ->findAllByColumn('id');

        if (count($connections) >= self::NB_LOGINS) {
            $this->db->table(self::TABLE)
                ->eq('user_id', $user_id)
                ->notIn('id', array_slice($connections, 0, self::NB_LOGINS - 1))
                ->remove();
        }
    }

    /**
     * Get the last connections for a given user
     *
     * @access public
     * @param  integer  $user_id  User id
     * @return array
     */
    public function getAll($user_id)
    {
        return $this->db
                    ->table(self::TABLE)
                    ->eq('user_id', $user_id)
                    ->desc('id')
                    ->columns('id', 'auth_type', 'ip', 'user_agent', 'date_creation')
                    ->findAll();
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit