https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /var/www/laciasmara.com/public_html/shop/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/laciasmara.com/public_html/shop/application/models/User_m.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class User_m extends MY_Model
{

	protected $_table_name = 'users';
	protected $_order_by = 'name';

	public $_rules = array(
		'email' => array(
			'field' => 'email',
			'label' => 'Email',
			'rules' => 'trim|required|valid_email'
		),
		'password' => array(
			'field' => 'password',
			'label' => 'Password',
			'rules' => 'trim|required'
		)
	);

	public $rules_admin = array(
		'name' => array(
			'field' => 'name',
			'label' => 'Name',
			'rules' => 'trim|required'
		),
		'email' => array(
			'field' => 'email',
			'label' => 'Email',
			'rules' => 'trim|required|valid_email|callback__unique_email'
		),
		'password' => array(
			'field' => 'password',
			'label' => 'Password',
			'rules' => 'trim|matches[password_confirm]'
		),
		'password_confirm' => array(
			'field' => 'password_confirm',
			'label' => 'Confirm Password',
			'rules' => 'trim|matches[password]'
		)
	);

	function __construct()
	{
		parent::__construct();
	}

	//function for login
	public function login()
	{
		$user = $this->get_by(array(
			'email' => $this->input->post('email'),
			'password' => $this->hash($this->input->post('password'))
		), TRUE);

		if (count($user) > 0) {
			//if user data is exist in database, then log them in..	
			$admin = array(
				'name' => $user->name,
				'email' => $user->email,
				'id' => $user->id,
				'role' => $user->role,
				'loggedin' => TRUE
			);
			$this->session->set_userdata(array('admin' => $admin));
		}
	}

	//function for logout
	public function logout()
	{

		$this->session->unset_userdata('admin');
	}

	//function to check if logged in, true if loggedin
	// public function loggedin()
	// {
	// 	if (isset($this->session->userdata('admin')['loggedin'])) {
	// 		return (bool) $this->session->userdata('admin')['loggedin'];
	// 	} else {
	// 		return false;
	// 	}
	// }

	public function loggedin()
	{
		if ($this->session->userdata('admin_logged_in') == TRUE) {
			return (bool) $this->session->userdata('admin_logged_in');
		} else {
			return false;
		}
	}

	//function to return new user
	public function get_new()
	{
		$user = new stdClass();
		$user->name = '';
		$user->email = '';
		$user->password = '';
		$user->role = '';
		$user->warehouse_id = '';
		return $user;
	}

	//function for hashing SHA512
	public function hash($string)
	{
		return hash('sha512', $string . config_item('encryption_key'));
		//password is salted with encryption key, and then use sha512
	}

	//function count if existing record exist
	public function count_exist($id)
	{
		$this->db->select('*');
		$this->db->from('users');
		$this->db->where('id', $id);
		$query = $this->db->get();
		return $query->num_rows();
	}

	public function getLogs()
	{
		$this->db->select('logs.id, logs.time, users.name AS user_name, logs.activity');
		$this->db->from('logs');
		$this->db->join('users', 'logs.id_user = users.id', 'left');
		return $this->db->get()->result();
	}


	public function getLogsByUser($userId)
	{
		$this->db->select('logs.id, logs.time, users.name AS user_name, logs.activity');
		$this->db->from('logs');
		$this->db->join('users', 'logs.id_user = users.id', 'left');
		$this->db->where('logs.id_user', $userId);
		return $this->db->get()->result();
	}

	// Admin New
	public function get_user_by_email($email)
	{
		return $this->db->get_where('admin_users', ['email' => $email])->row();
	}

	public function get_admin_users()
	{
		$this->db->select('*');
		$this->db->from('admin_users');
		return $this->db->get()->result();
	}

	public function get_admin_user_by_id($id)
	{
		$this->db->select('*');
		$this->db->from('admin_users');
		$this->db->where('id', $id);
		return $this->db->get()->row();
	}
}

https://t.me/RX1948 - 2025