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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //var/www/kanvakanva.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 $_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 $registration_rules = array(

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

			'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'),

			'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'),

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

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

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

	public $guestcheckout_rules = array(

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

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

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

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

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

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

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

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


	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(

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

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

			'address' => array(
				'field'=>'address',
				'label'=>'Address',
				'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'),

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

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

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

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

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

		if($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,
				'birthday' => $customer->birthday,
				'customer_loggedin' => TRUE
			);
			$this->session->set_userdata(array('customer' => $customer_data));
		}
	}

	//function for 1st login after registration
	public function first_login() {
		$customer = $this->get_by(array(
			'email' => $this->input->post('register_email'),
			'password' => $this->hash($this->input->post('register_password'))
			), TRUE);

		if($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
			);
			$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->input->post('register_email2'),
			/* 'password' => NULL */
			), TRUE);

		if($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
			);
			$this->session->set_userdata(array('customer' => $customer_data));

		}
	}

	//function for logout
	public function logout() {
   		$this->session->unset_userdata('customer');
    }

	//function to check if logged in, true if loggedin
	public function loggedin() {

		if($this->session->userdata('customer')) {
			return (bool) $this->session->userdata('customer')['customer_loggedin'];
		} else {
			return false;
		}
	}

	//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 cek_existing_email($email) {
		$this->db->select('*');
		$this->db->from('customers');
		$this->db->where('email', $email);
		$query = $this->db->get();
		return $query->num_rows();
	}

	function get_customer($id_customer) {
		$this->db->select('name, email, birthday');
		$this->db->from('customers');
		$this->db->where('id_customers', $id_customer);
		$query = $this->db->get();
		return $query->row();
	}

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

	function get_shipping_address($id_customer) {
		$this->db->select('*');
		$this->db->from('address');
		$this->db->where('id_customers', $id_customer);
		$query = $this->db->get();
		return $query->result();
	}

	function get_address($id_address) {
		$this->db->select('*');
		$this->db->from('address');
		$this->db->where('id_address', $id_address);
		$query = $this->db->get();
		return $query->row();
	}

	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();
	}

	function add_address($id_customer, $data) {
		$data['id_customers'] = $id_customer;
		$this->db->insert('address', $data);
	}

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

	function update_address($id_address, $id_customer, $data) {
		$data['id_customers'] = $id_customer;
		$this->db->where('id_address', $id_address);
		$this->db->update('address', $data);
	}

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

	//function count all record for customers
	public function record_count() {
        return $this->db->get('customers')->num_rows();
    }

    //pagination included
	// function get_all_customers() {
	// 	$this->db->select('*');
	// 	$this->db->from('customers');
	// 	$this->db->order_by('id_customers', 'desc');
	// 	$query = $this->db->get();
	// 	return $query->result();
	// }

	function get_all_customers_bydate($start_date, $end_date) {
		$this->db->select('*');
		$this->db->from('customers');
		$this->db->where('join_date >= "'.$start_date.'" ');
		$this->db->where('join_date <= "'.$end_date.'" ');
		$this->db->order_by('id_customers', 'desc');
		$query = $this->db->get();
		return $query->result();
	}

	public $lostpassword_rules = array(

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

	function get_point($id_customer=""){
		if($id_customer == ''){
			$id_customer = (int) $this->session->userdata('customer')['customer_id'];
		}

		$this->db->select('point');
		$this->db->from('customers');
		$this->db->where('id_customers', $id_customer);

		return $this->db->get()->row('point');
	}

	function get_point_history() {
		$id_customer = (int) $this->session->userdata('customer')['customer_id'];

		$query = $this->db->query("SELECT * FROM (
			SELECT date(created_at) as tgl,
				if(orders_id is not null, concat(title_reward,' For Order #',orders_id), title_reward) as title, 
				0 as point_in, point as point_out,created_at
			FROM redeem_point
			WHERE id_customers='$id_customer'

			UNION ALL

			SELECT date(created_at) as tgl,title, point as point_in, 0 as point_out,created_at
			FROM get_point
			WHERE id_customers='$id_customer'
		
		)z ORDER BY created_at DESC");
			
		return $query->result();
	}

	function get_reward() {

		$query = $this->db->query("SELECT a.id_reward_customer,a.discount,a.point,a.min_buy,
				if(a.id_products is null, 'Discount', b.title) as title, b.image1, b.alias
			FROM reward_customer a
			LEFT JOIN products b on a.id_products=b.id_products
        	LEFT JOIN stocks c on b.id_products=c.product_id and a.size_id=c.size_id
			WHERE (b.product_status='1' and c.stock > 0) or a.id_products is null");
			
		return $query->result();
	}


}

https://t.me/RX1948 - 2025