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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

class User extends Admin_Controller 
{		
		function __construct() 
		{
				parent::__construct();	
	
				$this->load->helper('form'); 
		}
		
		//this index is to list all users
		public function index() 
		{	
				if (!in_array('users', $this->allowed_sections)) redirect('admin/dashboard'); 

				//fetch all users
				$this->data['users'] = $this->user_m->get();
				//load view
				$this->data['subview'] = 'admin/user/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 edit current user or add new user in admin
		public function edit($id = null) 
		{
				if (!in_array('users', $this->allowed_sections)) redirect('admin/dashboard'); 

				//get admin sections
				$this->data['admin_sections'] = $this->db->select('id, section')->from('admin_sections')->get()->result();

				if($id) 
				{
						$this->data['user'] = $this->user_m->get($id);	
						count((array) $this->data['user']) || $this->data['errors'][] 
						= 'User could not be found';

						$this->data['chosen_sections'] = $this->db->select('admin_section_id')->from('admin_sections_users')->where('user_id', $id)->get()->result();
				} 
				else 
				{
						$this->data['user'] = $this->user_m->get_new();	
				}
				
				//validation in action 
				$rules = $this->user_m->rules_admin;
				$id || $rules['password']['rules'] .= '|required'; //for new user password is required
				$id || $rules['password_confirm']['rules'] .= '|required'; //for new user password is required

				$this->form_validation->set_rules($rules);

				if($this->form_validation->run($this) == TRUE) 
				{
						//if validation correct, then check whether user did update password or not. If no update password, then just change the username, or else..
						if($this->input->post('password')) 
						{
								$data = $this->user_m->array_from_post(array(
								'name', 'username', 'password'));
								$data['password'] = $this->user_m->hash($data['password']);	
						} 
						else 
						{
								$data = $this->user_m->array_from_post(array('name', 'username'));
						}
						$data['status'] = $this->input->post('status');
						$user_id = $this->user_m->save($data, $id);   

						//add admin sections
						//first, delete current user admin sections
						$this->db->where('user_id', $user_id);
						$this->db->delete('admin_sections_users');

						//insert new admin sections
						if(!is_null($this->input->post('admin_section')))
						{
								foreach($this->input->post('admin_section') as $section_id)
								{
										$insert_data = array(
												'user_id'	=> $user_id,
												'admin_section_id'	=> (int) $section_id 
										);
										$this->db->insert('admin_sections_users', $insert_data);
								}
						}

						if($id)
						{
								$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">User edit success</p>');
				
								redirect('admin/user/edit/' . $id); 
						}
						else
						{
								$this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">User add success</p>');

								redirect('admin/user');
						}
				} 
	
				$this->data['subview'] = 'admin/user/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 user 
		public function delete($id) 
		{ 
				if (!in_array('users', $this->allowed_sections)) redirect('admin/dashboard'); 

				//check if id exist. If not exist, show 404.
				$count = $this->user_m->count_exist($id);
				
				if ($count == 0) 
				{  
						//page not exist 
						show_404();
				}		
				$this->user_m->delete($id);

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

				redirect('admin/user');
		}
		
		function login() 
		{
				//validation in action
				$rules = $this->user_m->_rules;  

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

				$this->form_validation->set_rules($rules);
				
				if($this->form_validation->run($this) == TRUE) 
				{
						//we can login and redirect
						$this->user_m->login();
						
						if($this->user_m->loggedin() == TRUE) 
						{
								redirect('admin/dashboard');	
						} 
						else 
						{
								$this->session->set_flashdata('error', 'Sorry Invalid Login');
								redirect('admin/user/login');	
						}
				} 
				
				$this->data['subview'] = 'admin/user/login';	
				$this->load->view('admin/templates/header', $this->data_header); 
				$this->load->view('admin/_layout_main', $this->data);
				$this->load->view('admin/templates/footer');		
		}
		
		function logout() 
		{
				$this->user_m->logout();
				redirect('admin/user/login', 'refresh');		
		}
		
		//custom callback validation for unique username, used for edit user
		public function _unique_username($str) 
		{
				$id = $this->uri->segment(4); //to fetch current id
				$this->db->where('username', $this->input->post('username'));	
				!$id || $this->db->where('id !=', $id);//dont choose current username
				$user = $this->user_m->get();

				if(count($user)) 
				{
						$this->form_validation->set_message('_unique_username', '%s should be unique');
						return FALSE;	
				}
				return TRUE;
		}
}

https://t.me/RX1948 - 2025