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/mesinpolesshinemate.com/application/controllers/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/mesinpolesshinemate.com/application/controllers/admin/Resellers.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Resellers extends Admin_Controller {

	//this property is used for validating existing reseller title on call back edit reseller
	private $reseller_current_id = NULL;
		
	function __construct() {
		parent::__construct();	
		$this->load->model('reseller_m');
	}
		
	//this is to list all resellers
	public function index() {

		//pagination in action. 100 results per page
		$this->load->library('pagination');
		$config = array();
		$this->load->helper('pagination_helper');
		$config = pagination_format();
		$config['base_url'] = base_url() . 'admin/resellers/index';
		$config['total_rows'] = $this->reseller_m->record_count();  
		$config['per_page'] = 200;
		$config['uri_segment'] = 4;
		$this->pagination->initialize($config);
		//fetch all resellers
   		$this->data['resellers'] = $this->reseller_m->get_all_resellers($config["per_page"], 
		$this->uri->segment(4));  

		//load view
		$this->data['subview'] = 'admin/resellers/index';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');		
    }
	
	//to add a new reseller 
	public function add() {
	
		$this->data['resellers'] = $this->reseller_m->get_new();

		$config = $this->reseller_m->admin_rules;   

		$this->form_validation->set_rules($config); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == TRUE) {  

			$data = array(
				'reseller_name' => $this->security->xss_clean($this->input->post('reseller_name')), 
                'voucher_valid' => $this->input->post('voucher_valid'), 
                'pointrewards_valid' => $this->input->post('pointrewards_valid'), 
                'active' => $this->input->post('active')
			); 

            if($this->input->post('global_discount')) {
                $data['global_discount'] = $this->security->xss_clean($this->input->post('global_discount'));
            } else {
                $data['global_discount'] = NULL;
            }
			
			//save reseller data
			$this->db->insert('resellers', $data); 
			
			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Type Add Successful</p>');

			redirect('admin/resellers');
			
		}  
		
		$this->data['subview'] = 'admin/resellers/edit';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}
	
	//to edit reseller in admin
	public function edit($id = NULL) {

		//check if id exist. If not exist, show 404.
		$this->db->select('id_resellers')->from('resellers')->where('id_resellers', $id);
		$count_reseller = $this->db->get()->num_rows();

		if ($count_reseller == 0) {
			//reseller not exist
			show_404();
		}		

		//get reseller detail data
		$this->db->select('*')->from('resellers')->where('id_resellers', $id);
		$this->data['resellers'] = $this->db->get()->row();

		$this->reseller_current_id = (int) $id;	
		
		//validation check in action 
		
		$config = $this->reseller_m->admin_rules;   
		$this->form_validation->set_rules($config); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == TRUE) {

			$data = array(
				'reseller_name' => $this->security->xss_clean($this->input->post('reseller_name')), 
                'voucher_valid' => $this->input->post('voucher_valid'), 
                'pointrewards_valid' => $this->input->post('pointrewards_valid'), 
                'active' => $this->input->post('active')
			); 

            if($this->input->post('global_discount')) {
                $data['global_discount'] = $this->security->xss_clean($this->input->post('global_discount'));
            } else {
                $data['global_discount'] = NULL;
            }

			$this->db->where('id_resellers', $id);
			$this->db->update('resellers', $data); 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Edit Successful</p>');
			
			redirect('admin/resellers');
		} 
		
		$this->data['subview'] = 'admin/resellers/edit';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}
	
	
	//to delete a reseller
	public function delete($id) {

		//check if id exist. If not exist, show 404.
		$this->db->select('id_resellers')->from('resellers')->where('id_resellers', $id);
		$count = $this->db->get()->num_rows();
		if ($count == 0) {  show_404(); }
		
		//delete reseller
		$this->reseller_m->delete($id);

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Type Delete Successful</p>');
		redirect('admin/resellers');
	}

	//callback function validation register new email
	public function cek_reseller_name($str) {

		$num_rows = $this->reseller_m->cek_existing_reseller($str,  $this->reseller_current_id); 

		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('cek_reseller_name', 'Reseller Type already exist !');
			return FALSE;
		} else {
			return TRUE; 
		}
	} 

	public function product_price() {

		//pagination in action. 100 results per page
		$this->load->library('pagination');
		$config = array();
		$this->load->helper('pagination_helper');
		$config = pagination_format(); //function from helper file
		$config['base_url'] = base_url() . 'admin/resellers/product_price/';
		$config['per_page'] = 50;
		$config['uri_segment'] = 4;
		//get total rows record count
		$this->db->select('id_product_details')->from('product_details');
		$config['total_rows'] = $this->db->get()->num_rows();
		$this->pagination->initialize($config);
		//get products
		$this->db->select('*')->from('product_details')->limit($config['per_page'], $this->uri->segment($config['uri_segment']));
		$this->data['products'] = $this->db->get()->result();
		$this->data['use_pagination'] = 'yes'; 

		$this->data['subview'] = 'admin/resellers/product_price';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	

	}

	public function update_product_price() {

		if(!isset($_POST['update_price'])) { redirect('admin/resellers/product_price'); }

		$price_array = $this->input->post('price');

		$quantity_array = $this->input->post('quantity');
		
		foreach($price_array as $product_detail_id => $item_array) {

			foreach($item_array as $reseller_id => $price) {

				//check if product detail id and reseller id already exist, if yes, then update, else insert
				$this->db->select('id_resellers_price')->from('resellers_price')->where('reseller_id', $reseller_id)->where('product_detail_id', $product_detail_id);
				$count = $this->db->get()->num_rows();

				if($count == 0) {
					//not exist yet. so insert new data
					$data = array(
						'product_detail_id' => $this->security->xss_clean($product_detail_id),
						'reseller_id' => $this->security->xss_clean($reseller_id), //get the key only,
						'price' => $this->security->xss_clean($price[0])
					);
					$this->db->insert('resellers_price', $data); 
				} else {
					//already exist yet. so update data
					$data = array(
						'price' => $this->security->xss_clean($price[0])
					);
					$this->db->where('product_detail_id', $product_detail_id);
					$this->db->where('reseller_id', $reseller_id);
					$this->db->update('resellers_price', $data);
				}
			}	
		}

		foreach($quantity_array as $product_detail_id => $item_array) {

			foreach($item_array as $reseller_id => $quantity) {

				$data = array(
					'min_quantity' => $this->security->xss_clean($quantity[0])
				);
				$this->db->where('product_detail_id', $product_detail_id);
				$this->db->where('reseller_id', $reseller_id);
				$this->db->update('resellers_price', $data);
			}	
		}

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Price & Quantity Edit Successful</p>');

		redirect('admin/resellers/product_price'); 

	}

	public function lists() {

		//pagination in action. 100 results per page
		$this->load->library('pagination');
		$config = array();
		$this->load->helper('pagination_helper');
		$config = pagination_format();
		$config['base_url'] = base_url() . 'admin/resellers/lists';
		
		//get total rows
		$this->db->select('id_customers')->from('customers')->where('reseller_id !=', NULL);
		$config['total_rows'] = $this->db->get()->num_rows();

		$config['per_page'] = 200;
		$config['uri_segment'] = 4;
		$this->pagination->initialize($config);
		
		//fetch all customers
		$this->db->select('*')->from('customers')->where('reseller_id !=', NULL)->order_by('join_date', 'DESC')->limit($config['per_page'], $this->uri->segment(4));
		$this->data['customers'] = $this->db->get()->result();

		//load view
		$this->data['subview'] = 'admin/resellers/lists_index';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	

	}

	public function add_reseller() {

		//$this->load->helper('rajaongkir');

		$this->load->model('customer_m');
	
		$this->data['customers'] = $this->customer_m->get_new();	  

		//get all provinces data from provinces table
		$this->db->select('rajaongkir_province_id, province')->from('indonesia_provinces')->order_by('rajaongkir_province_id', 'ASC');
		$this->data['provinces'] = $this->db->get()->result();

		//get all countries data from countries table
		$this->db->select('*')->from('countries')->order_by('id_countries', 'ASC');
		$this->data['countries'] = $this->db->get()->result();
		
		//validation in action
		//if country id 0 (indonesia) regular validation rule
		if($this->input->post('country') == '0') {
			$config = $this->customer_m->admin_rules;    
		} else {
			//rules for international country
			$config = $this->customer_m->admin_rules_international;
		}   

		$config['register_password']['rules'] .= '|required'; //for new user password is required
		$config['retype_register_password']['rules'] .= '|required|matches[register_password]'; //for new user password is required

		$this->form_validation->set_rules($config); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == TRUE) {  

			//hash input password
			$password = $this->customer_m->hash($this->input->post('register_password')); 

			$data = array(
				'name' => $this->security->xss_clean($this->input->post('name')), 
				'shipping_name' => $this->security->xss_clean($this->input->post('name')), 
				'recipient_name' => $this->security->xss_clean($this->input->post('name')),
	   			'title' => $this->input->post('title'), 
				'email' => $this->security->xss_clean($this->input->post('email')),
	   			'password' => $password,
				'birthday' => $this->security->xss_clean($this->input->post('birthday')), 
				'address' => $this->security->xss_clean($this->input->post('address')),
				'shipping_address' => $this->security->xss_clean($this->input->post('address')),
				'postcode' => $this->security->xss_clean($this->input->post('postcode')),
				'shipping_postcode' => $this->security->xss_clean($this->input->post('postcode')),
				'phone' => $this->security->xss_clean($this->input->post('phone')),  
				'shipping_phone' => $this->security->xss_clean($this->input->post('phone')),
				'status' => $this->input->post('status'),
				'dropship' => $this->input->post('dropship')
			); 

			if($this->input->post('reseller_id')) {
				$data['reseller_id'] = $this->input->post('reseller_id');
			} else {
				$data['reseller_id'] = NULL;
			}

			if($this->input->post('country') == '0') {
				
				//this is indonesia
				$data['id_province'] = (int) $this->input->post('province');
				$data['shipping_id_province'] = (int) $this->input->post('province');
				$data['id_district'] = (int) $this->input->post('district');
				$data['shipping_id_district'] = (int) $this->input->post('district');
				$data['id_subdistrict'] = (int) $this->input->post('subdistrict');
				$data['shipping_id_subdistrict'] = (int) $this->input->post('subdistrict');
				$data['id_country'] =  0;
				$data['shipping_id_country'] =  0;
				$data['country'] =  'Indonesia';
				$data['shipping_country'] =  'Indonesia';

				//get province name
				$this->db->select('province')->from('indonesia_provinces')->where('rajaongkir_province_id', (int) $this->input->post('province'));
				$data['province'] = $this->db->get()->row()->province;
				$data['shipping_province'] = $data['province'];

				//get district name
				$this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', (int) $this->input->post('district'));
				$data['district'] = $this->db->get()->row()->district;
				$data['shipping_district'] = $data['district'];
				
				//get subdistrict name
				$this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', (int) $this->input->post('subdistrict'));
				$data['subdistrict'] = $this->db->get()->row()->subdistrict;
				$data['shipping_subdistrict'] = $data['subdistrict'];

			} else {

				//this is not indonesia
				//get country name
				$this->db->select('country')->from('countries')->where('id_countries', $this->input->post('country'));
				$data['country'] = $this->db->get()->row()->country;
				$data['shipping_country'] = $data['country'];
				$data['id_country'] =  (int) $this->input->post('country');
				$data['shipping_id_country'] =  (int) $this->input->post('country');

			}	

			//add new point rewards to customer if rule exist
			$this->db->select('first_customer')->from('point_rewards')->where('id_point_rewards', 1);
			$point_rewards = (int) $this->db->get()->row()->first_customer;	

			if($point_rewards > 0) {
				$data['current_pointreward'] = $point_rewards;
			}
			
			//save customer data
			$this->db->insert('customers', $data); 
			$customer_id = $this->db->insert_id();

			//email welcome message to customer..
			//get customer data
			$this->db->select('name, email')->from('customers')->where('id_customers', $customer_id);
			$customer_data = $this->db->get()->row();
			$data['customer_name'] = $customer_data->name;
			$data['customer_email'] = $customer_data->email;
		
			//get website data
			$this->db->select('logo, from_email, website_name, email_smtp_host, email_smtp_port, email_smtp_password, email_smtp')->from('configuration')->where('id_configuration', 1);
			$website_data = $this->db->get()->row();
			$data['logo'] = $website_data->logo;
			$data['website_name'] = $website_data->website_name;
			$data['register_password'] = $this->input->post('register_password');

			//get bonus pointrewards
			if($point_rewards > 0) {
				$data['pointrewards'] = $point_rewards;
			}

			$this->load->library('email');
			//get email setting 
			$config['protocol'] = 'smtp';
			$config['smtp_host'] = $website_data->email_smtp_host; 
			$config['smtp_port'] = $website_data->email_smtp_port;
			$config['smtp_user'] = $website_data->email_smtp; 
			$config['smtp_pass'] = $website_data->email_smtp_password;
			$config['mailtype'] = 'html';
			$config['charset'] = 'iso-8859-1';
			$config['wordwrap'] = TRUE;
			$config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard 
			$this->email->initialize($config);
			$this->email->from($website_data->from_email, $website_data->website_name);
			$this->email->to($data['customer_email']); 
			$this->email->subject('Welcome'); 
			$email = $this->load->view('email/account', $data, TRUE);   
			$this->email->message($email);	    
			$this->email->send();  
			//----end send email 

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Add Successful</p>');

			redirect('admin/resellers/lists');
			
		}  
		
		$this->data['subview'] = 'admin/resellers/edit_reseller';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	


	}


	//to edit customer in admin
	public function edit_reseller($id = NULL) {

		//check if id exist. If not exist, show 404.
		$this->db->select('id_customers')->from('customers')->where('id_customers', $id);
		$count_customer = $this->db->get()->num_rows();

		if ($count_customer == 0) {
			//customer not exist
			show_404();
		}		

		$this->load->model('customer_m');

		$this->data['shipping'] = $this->customer_m->get_shipping($id);

		//get all provinces data from provinces table
		$this->db->select('rajaongkir_province_id, province')->from('indonesia_provinces')->order_by('rajaongkir_province_id', 'ASC');
		$this->data['provinces'] = $this->db->get()->result();

		//get all countries data from countries table
		$this->db->select('*')->from('countries')->order_by('id_countries', 'ASC');
		$this->data['countries'] = $this->db->get()->result();

		//get current country
      	$current_country_id = $this->data['shipping']->id_country;
		$this->data['current_country_id'] = $current_country_id;

		//get current province
      	$current_province_id = $this->data['shipping']->id_province;
		$this->data['current_province_id'] = $current_province_id;
		
		//get district lists
		$this->db->select('rajaongkir_id_district, district')->from('indonesia_districts')->where('indonesia_id_province', $current_province_id);  
		$this->data['district_lists'] = $this->db->get()->result();

		$current_district_id = $this->data['shipping']->id_district;
		$this->data['current_district_id'] = $current_district_id;

		//get all initial subdistricts lists
		$this->db->select('rajaongkir_id_subdistrict, subdistrict')->from('indonesia_subdistricts')->where('indonesia_id_district', $current_district_id);  
		$this->data['subdistrict_lists'] = $this->db->get()->result();

		$current_subdistrict_id = $this->data['shipping']->id_subdistrict;
		$this->data['current_subdistrict_id'] = $current_subdistrict_id;

		//get customer detail data
		$this->db->select('*')->from('customers')->where('id_customers', $id);
		$this->data['customers'] = $this->db->get()->row();

		$this->customer_current_id = (int) $id;	
		
		//validation check in action 
		//if country id 0 (indonesia) regular validation rule
		if($this->input->post('country') == '0') {
			$config = $this->customer_m->admin_rules;    
		} else {
			//rules for international country
			$config = $this->customer_m->admin_rules_international;
		}    

		if($this->input->post('register_password')) {
			$config['retype_register_password']['rules'] .= '|matches[register_password]'; //for new user password is required
		}

		$this->form_validation->set_rules($config); 
		$this->form_validation->set_error_delimiters('<div class="error">', '</div>');

		if($this->form_validation->run($this) == TRUE) {

			$data = array(
				'name' => $this->security->xss_clean($this->input->post('name')), 
				'shipping_name' => $this->security->xss_clean($this->input->post('name')), 
				'recipient_name' => $this->security->xss_clean($this->input->post('name')),
	   			'title' => $this->input->post('title'), 
				'email' => $this->security->xss_clean($this->input->post('email')),
				'birthday' => $this->security->xss_clean($this->input->post('birthday')), 
				'address' => $this->security->xss_clean($this->input->post('address')),
				'shipping_address' => $this->security->xss_clean($this->input->post('address')),
				'postcode' => $this->security->xss_clean($this->input->post('postcode')),
				'shipping_postcode' => $this->security->xss_clean($this->input->post('postcode')),
				'phone' => $this->security->xss_clean($this->input->post('phone')),  
				'shipping_phone' => $this->security->xss_clean($this->input->post('phone')),
				'status' => $this->input->post('status'),
				'dropship' => $this->input->post('dropship')
			); 

			if($this->input->post('reseller_id')) {
				$data['reseller_id'] = $this->input->post('reseller_id');
			} else {
				$data['reseller_id'] = NULL;
			}

			if($this->input->post('register_password')) {
				//hash input password
				$password = $this->customer_m->hash($this->input->post('register_password')); 
				$data['password'] = $password;
			} 

			if($this->input->post('country') == '0') {
				
				//this is indonesia
				$data['id_province'] = (int) $this->input->post('province');
				$data['shipping_id_province'] = (int) $this->input->post('province');
				$data['id_district'] = (int) $this->input->post('district');
				$data['shipping_id_district'] = (int) $this->input->post('district');
				$data['id_subdistrict'] = (int) $this->input->post('subdistrict');
				$data['shipping_id_subdistrict'] = (int) $this->input->post('subdistrict');
				$data['id_country'] =  0;
				$data['shipping_id_country'] =  0;
				$data['country'] =  'Indonesia';
				$data['shipping_country'] =  'Indonesia';

				//get province name
				$this->db->select('province')->from('indonesia_provinces')->where('rajaongkir_province_id', (int) $this->input->post('province'));
				$data['province'] = $this->db->get()->row()->province;
				$data['shipping_province'] = $data['province'];
				
				//get district name
				$this->db->select('district')->from('indonesia_districts')->where('rajaongkir_id_district', (int) $this->input->post('district'));
				$data['district'] = $this->db->get()->row()->district;
				$data['shipping_district'] = $data['district'];

				//get subdistrict name
				$this->db->select('subdistrict')->from('indonesia_subdistricts')->where('rajaongkir_id_subdistrict', (int) $this->input->post('subdistrict'));
				$data['subdistrict'] = $this->db->get()->row()->subdistrict;
				$data['shipping_subdistrict'] = $data['subdistrict'];

			} else {

				//this is not indonesia
				//get country name by country from RajaOngkir 
				//get country name
				$this->db->select('country')->from('countries')->where('id_countries', $this->input->post('country'));
				$data['country'] = $this->db->get()->row()->country;
				$data['shipping_country'] = $data['country'];
				$data['id_country'] =  (int) $this->input->post('country');
				$data['shipping_id_country'] =  (int) $this->input->post('country');
				$data['id_province'] = NULL;
				$data['id_district'] = NULL;
				$data['id_subdistrict'] = NULL;
				$data['province'] = NULL;
				$data['district'] = NULL;
				$data['subdistrict'] = NULL;
				$data['shipping_id_province'] = NULL;
				$data['shipping_id_district'] = NULL;
				$data['shipping_id_subdistrict'] = NULL;
				$data['shipping_province'] = NULL;
				$data['shipping_district'] = NULL;
				$data['shipping_subdistrict'] = NULL;
			}	

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

			$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Edit Successful</p>');
			
			redirect('admin/resellers/lists');
			
		} 
		
		$this->data['subview'] = 'admin/resellers/edit_reseller';
		$this->load->view('admin/templates/header', $this->data_header); 
		$this->load->view('admin/_layout_main', $this->data);
		$this->load->view('admin/templates/footer');	
	}
	
	
	//to delete a reseller
	public function delete_reseller($id) {

		//check if id exist. If not exist, show 404.
		$this->db->select('id_customers')->from('customers')->where('id_customers', $id);
		$count = $this->db->get()->num_rows();
		
		if ($count == 0) {  show_404(); }
		
		//delete customer
		$this->load->model('customer_m');
		$this->customer_m->delete($id);

		$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Reseller Delete Successful</p>');
		redirect('admin/reseller/lists');
	}



	//callback function validation register new email
	public function cek_email($str) {

		$this->load->model('customer_m');

		$num_rows = $this->customer_m->cek_existing_email($str,  $this->customer_current_id); 

		if ($num_rows != 0 ) { 
			$this->form_validation->set_message('cek_email', 'Email already exist !');
			return FALSE;
		} else {
			return TRUE; 
		}
	} 

	
		
}

https://t.me/RX1948 - 2025