GRAYBYTE WORDPRESS FILE MANAGER4051

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/public_html/Barga/application/modules/users/controllers/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/public_html/Barga/application/modules/users/controllers//Users.php
<?php
class Users extends Basecontroller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('Users_model', 'Users');
		$this->controller_name = "users";
		$this->folder = "users";
		if(!$this->session->userdata('is_login')) { redirect('sessions','refresh'); } //Checked is logined in or not
    }

	public function index(){
		if(checkModuleAccessByUser(userInfo('user_role_id'), 4, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['title'] = "Users";
		$data['user_list'] = $this->Users->getUserList();
		$data['modal_user_reset_password'] = $this->load->view('modal_user_reset_password', array(), true);
		$this->template->admin('user_lists', $data);	
    }
	public function userForm($user_id = 0)
	{
		if($user_id == "" || !is_numeric($user_id)){redirect('errors/invalidRequest');} // Check passing argument
		if(checkModuleAccessByUser(userInfo('user_role_id'), 4, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['title'] = "User Form";
		$data['user_id'] = $user_id;
		$data['user_roles'] = $this->Users->getUserRoleList(1);
		if($user_id > 0) { $data['user_data'] = $this->Users->getUserData($user_id); }
		if($this->input->post()) {
			$this->form_validation->set_rules('user_role_id', 'User Role Name', 'required');
			if($user_id == 0) {
				$this->form_validation->set_rules('user_name', 'User Name', 'trim|required|alpha_numeric|is_unique[fly_users.user_name]');
				$this->form_validation->set_rules('user_email', 'User Email', 'trim|required|valid_email|is_unique[fly_users.user_email]');
				$this->form_validation->set_rules('user_profile_name', 'User Profile Name', 'trim|required');
			} else {
				$this->form_validation->set_rules('user_name', 'User Name', 'trim|required|alpha_numeric');
				$this->form_validation->set_rules('user_email', 'User Email', 'trim|required|valid_email');
				$this->form_validation->set_rules('user_profile_name', 'User Profile Name', 'trim|required');
			}
			if($user_id == 0) {
				$this->form_validation->set_rules('user_password', 'User Password', 'trim|required');
			}
			
			$this->form_validation->set_rules('user_phone', 'User Phone', 'trim|numeric');
			if ($this->form_validation->run() === TRUE) {
				$user_role_id = $this->input->post('user_role_id');
				$user_name = $this->input->post('user_name');
				$user_email = $this->input->post('user_email');
				if($user_id == 0) {
					$user_password = $this->input->post('user_password');
				}
				$user_profile_name = $this->input->post('user_profile_name');
				$user_phone = $this->input->post('user_phone');
				$user_status = $this->input->post('user_status');
				
				$data_array['user_role_id'] = $user_role_id;
				if($user_id == 0) {
					$data_array['user_name'] = $user_name;
				}
				$data_array['user_profile_name'] = $user_profile_name;
				if($user_id == 0) {
					$data_array['user_password'] = md5($user_password);
				}
				if($user_id == 0) {
					$data_array['user_email'] = $user_email;
				}
				$data_array['user_phone'] = $user_phone;
				$data_array['user_status'] = $user_status;
				$data_array['user_ip'] = getUserIP();

				$data_array['last_login_date'] = date('Y-m-d H:i:s');
				$data_array['dom'] = date('Y-m-d H:i:s');
				
				if($user_id == 0) { $data_array['doc'] = date('Y-m-d H:i:s');}
				if($user_id > 0) { $data_array['dom'] = date('Y-m-d H:i:s');}
				$id = $this->Users->userSave($data_array, $user_id);
				if($user_id == 0) {
					if(EMAIL_ON == 1){
						$company_name = getSettingValue('company_name');
						$admin_email = getSettingValue('company_email');
			
						$user_login_tpl = getEmailTemplate('send_user_login_tpl');
						$mail_subject = $user_login_tpl->email_template_subject;
						$mail_subject = str_replace("{{user_profile_name}}", $user_profile_name, $mail_subject);
						
						$mail_body = str_replace("{{user_profile_name}}", $user_profile_name, $user_login_tpl->email_template_body);
						$mail_body = str_replace("{{user_name}}", $user_name, $mail_body);
						$mail_body = str_replace("{{password}}", $user_password, $mail_body);
						$this->load->library('supertronmailer', array(
							'to' => convertToLowerCase($user_email), 
							'subject' => $mail_subject, 
							'body' => $mail_body, 
							'name' => convertToUpperCase($user_profile_name),
							'from_name' => $user_profile_name,
							'from_email' => $user_email
						));
						$this->supertronmailer->send();
					}
				}
				$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
				redirect($this->controller_name);
		 	}
		 }
		$this->template->admin('user_form', $data);
	}
	
	public function roleForm($user_role_id = 0)
	{
		if($user_role_id == "" || !is_numeric($user_role_id)){redirect('errors/invalidRequest');} // Check passing argument
		if(checkModuleAccessByUser(userInfo('user_role_id'), 2, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['title'] = "Role Form";
		$data['user_role_id'] = $user_role_id;
		if($user_role_id > 0) { $data['user_role_data'] = $this->Users->getUserRoleData($user_role_id); }
		if($this->input->post()) {
			$this->form_validation->set_rules('user_role_name', 'User Role Name', 'trim|required');
			if ($this->form_validation->run() === TRUE) {
				$user_role_name = $this->input->post('user_role_name');
				$is_visible = $this->input->post('is_visible');
				$data_array['user_role_code'] = chrReplace($user_role_name);
				$data_array['user_role_name'] = $user_role_name;
				$data_array['is_visible'] = $is_visible;
				if($user_role_id == 0) { $data_array['doc'] = date('Y-m-d H:i:s');}
				if($user_role_id > 0) { $data_array['dom'] = date('Y-m-d H:i:s');}
				$id = $this->Users->userRoleSave($data_array, $user_role_id);
				$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
				redirect($this->controller_name.'/userRoleList');
		 	}
		 }
		$this->template->admin('role_form', $data);
	}
	
	public function userRoleList()
	{
		$data['title'] = "User Roles";
		if(checkModuleAccessByUser(userInfo('user_role_id'), 2, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['user_role_list'] = $this->Users->getUserRoleList();
		$this->template->admin('role_lists', $data);	
	}
	
	public function assignModuleAccess($user_role_id)
	{
		if($user_role_id == "" || !is_numeric($user_role_id)){redirect('errors/invalidRequest');} // Check passing argument
		if(checkModuleAccessByUser(userInfo('user_role_id'), 2, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['title'] = "Assign Module Access";
		$data['user_role_name'] = $this->Users->getUserRoleNameById($user_role_id);
		$data['user_role_id'] = $user_role_id;
		$data['role_rights'] = $this->Users->getUserRoleRight($user_role_id);
		if($this->input->post()) {
			//echo $this->input->post('module_view_11');exit;
			$this->Users->checkUserRoleRight($user_role_id);
			$parent_menu = getLeftMenu(0);
			foreach($parent_menu as $key => $pmenu){
				$child_menu = getLeftMenu($pmenu->module_id);
				
				$module_view = $this->input->post('module_view_'.$pmenu->module_id) == "" ? 0 : $this->input->post('module_view_'.$pmenu->module_id);
				$module_add = $this->input->post('module_add_'.$pmenu->module_id) == "" ? 0 : $this->input->post('module_add_'.$pmenu->module_id);
				$module_edit = $this->input->post('module_edit_'.$pmenu->module_id) == "" ? 0 : $this->input->post('module_edit_'.$pmenu->module_id);
				$module_delete = $this->input->post('module_delete_'.$pmenu->module_id) == "" ? 0 : $this->input->post('module_delete_'.$pmenu->module_id);
				$sql = "INSERT INTO ".TABLE_ROLE_RIGHTS." (user_role_id,module_id,module_add,module_edit,module_delete,module_view,module_menu) VALUES (".$user_role_id.", ".$pmenu->module_id.", ".$module_add.", ".$module_edit.", ".$module_delete.", ".$module_view.", 1)";
				$this->db->query($sql);
				
				foreach($child_menu as $key => $cmenu){
					$module_view = $this->input->post('module_view_'.$cmenu->module_id) == "" ? 0 : $this->input->post('module_view_'.$cmenu->module_id);
					$module_add = $this->input->post('module_add_'.$cmenu->module_id) == "" ? 0 : $this->input->post('module_add_'.$cmenu->module_id);
					$module_edit = $this->input->post('module_edit_'.$cmenu->module_id) == "" ? 0 : $this->input->post('module_edit_'.$cmenu->module_id);
					$module_delete = $this->input->post('module_delete_'.$cmenu->module_id) == "" ? 0 : $this->input->post('module_delete_'.$cmenu->module_id);
					$sql = "INSERT INTO ".TABLE_ROLE_RIGHTS." (user_role_id,module_id,module_add,module_edit,module_delete,module_view,module_menu) VALUES (".$user_role_id.", ".$cmenu->module_id.", ".$module_add.", ".$module_edit.", ".$module_delete.", ".$module_view.", 1)";
					$this->db->query($sql);
				}
			}

			$this->session->set_flashdata('msg_success', getMessage("record_updated", 3));
			redirect($this->controller_name.'/assignModuleAccess/'.$user_role_id);
		}
		$this->template->admin('module_access_lists', $data);	
	}
	
	public function resetUserPassword()
	{
		if ($this->input->is_ajax_request()) {
			$this->form_validation->set_rules('new_user_password', 'New password', 'trim|required');
			$this->form_validation->set_rules('new_user_retype_password', 'Retype new password', 'trim|required|matches[new_user_password]');
			if ($this->form_validation->run() === FALSE) {
				$response_data = array('status' => 0, 'msg' => validation_errors());
			} else {
				$user_id = $this->input->post('user_id');
				$fields['user_password'] = md5($this->input->post('new_user_password'));
				$fields['dom'] = date('Y-m-d H:i:s');
				$this->Users->userSave($fields, $user_id);
				$user_data = $this->Users->getUserData($user_id);
				if(EMAIL_ON == 1) {
					 $company_name = getSettingValue('company_name');
					 $company_email = getSettingValue('company_email');
					 $new_user_password = $this->input->post('new_user_password');
					 $user_profile_name = $user_data->user_profile_name;
					 $email_tpl_data = getEmailTemplate("admin_forgot_password_tpl");
					 $subject = $email_tpl_data->email_template_subject;
					 $subject = str_replace("{{company_name}}", $company_name, $subject);
					 $subject = str_replace("{{profile_name}}", $user_profile_name, $subject);
					 $message = str_replace("{{profile_name}}",$user_profile_name,$email_tpl_data->email_template_body);
					 $message = str_replace("{{new_password}}",$new_user_password,$message);
					 $this->load->library('supertronmailer', array(
					 													'to' => $user_data->user_email,
																		'subject' => $subject,
																		'body' => $message,
																		'name' => $user_profile_name,
																		'from_name' => $company_name,
																		'from_email' => $company_email
																));
					 $this->supertronmailer->send();
				}
				/*** Send reset password via sms start ***/
				if (SMS_ON == 1 && $user_data->user_phone != "") {
					// $admin_user_password_reset_data = getSmsTemplate('admin_user_password_reset');
					// $sms_message = str_replace("{{profile_name}}",$user_profile_name,$admin_user_password_reset_data->sms_template_body);
					// $sms_message = str_replace("{{new_password}}",$new_user_password,$sms_message);
					// sendSMS($user_data->user_phone,$sms_message);
					$smsParams = [
						'template_id' => sendSMSTemplate('admin_user_password_reset'),
						'recipients' => [
							[
							'mobiles' => countryCode().$user_data->user_phone,
							'USER_NAME' => $user_profile_name,
							'USER_PASSWORD' => $new_user_password
							]
						]
					];
					sendSMSFunc($smsParams);
				}
				/*** Send reset password via sms end ***/
				$response_data = array('status' => 1, 'msg' => getMessage("change_password_msg", 3));
			}
		} else {
			$response_data = array('status' => 0, 'msg' => getMessage("no_direct_script_access", 3));
		}
		
		echo json_encode($response_data);exit;
	}
	
	public function userProfileForm($user_id)
	{
		if($user_id == "" || $user_id != userInfo('user_id')){redirect('errors/invalidRequest');} // Check passing argument and logined user
		$data['title'] = "User Profile Form"; 
		$data['user_id'] = $user_id;
		$data['user_roles'] = $this->Users->getUserRoleList(1); // 1 for all active user role
		if($user_id > 0) { 
			$data['user_data'] = $this->Users->getUserData($user_id); 
			$data['company_data'] = $this->Users->getCompanyData(); 
		}
		if($this->input->post()) {
			$this->form_validation->set_rules('user_role_id', 'User Role Name', 'required');
			if($user_id == 0) {
				$this->form_validation->set_rules('user_name', 'User Name', 'trim|required|is_unique[fly_users.user_name]');
				$this->form_validation->set_rules('user_email', 'User Email', 'trim|required|valid_email|is_unique[fly_users.user_email]');
			} else {
				$this->form_validation->set_rules('user_name', 'User Name', 'trim|required');
				$this->form_validation->set_rules('user_email', 'User Email', 'trim|required|valid_email');
			}
			if($user_id == 0) {
				$this->form_validation->set_rules('user_password', 'User Password', 'trim|required');
			}
			$this->form_validation->set_rules('user_profile_name', 'User Profile Name', 'trim');
			$this->form_validation->set_rules('user_phone', 'User Phone', 'trim|numeric');
			if ($this->form_validation->run() === TRUE) {
				$user_role_id = $this->input->post('user_role_id');
				$user_name = $this->input->post('user_name');
				$user_email = $this->input->post('user_email');
				$user_profile_name = $this->input->post('user_profile_name');
				$user_phone = $this->input->post('user_phone');
				$user_status = $this->input->post('user_status');
				
				$data_array['user_role_id'] = $user_role_id;
				$data_array['user_name'] = $user_name;
				$data_array['user_profile_name'] = $user_profile_name;
				$data_array['user_email'] = $user_email;
				$data_array['user_phone'] = $user_phone;
				$data_array['user_status'] = $user_status;
				$data_array['dom'] = date('Y-m-d H:i:s');
				$id = $this->Users->userSave($data_array, $user_id);


			
				$company_data_array = array();
				// company info save start
				if(isset($_FILES['company_logo']) && ($_FILES['company_logo']['name']) != '') {
					$file_data = uploadFileCustom(COMPANY_IMAGE_PATH,"company_logo",array("jpeg", "jpg", "png"), "company_img");
					
					if($file_data['upload_status'] == 1 && $file_data['res_msg'] == 'Success') {
						$company_data_array['logo'] = $file_data['new_file_name'];
						$img = $this->input->post('old_company_logo');
						@unlink( COMPANY_IMAGE_PATH . $img);
					}
				}
				if(isset($_FILES['login_page_logo']) && ($_FILES['login_page_logo']['name']) != '') {
					$file_data = uploadFileCustom(COMPANY_IMAGE_PATH,"login_page_logo",array("jpeg", "jpg", "png"), "company_login_img");
					if($file_data['upload_status'] == 1 && $file_data['res_msg'] == 'Success') {
						$company_data_array['login_page_logo'] = $file_data['new_file_name'];
						$img = $this->input->post('old_login_page_logo');
						@unlink( COMPANY_IMAGE_PATH . $img);
					}
				}
				if(isset($_FILES['login_page_bg_logo']) && ($_FILES['login_page_bg_logo']['name']) != '') {
					$file_data = uploadFileCustom(COMPANY_IMAGE_PATH,"login_page_bg_logo",array("jpeg", "jpg", "png"), "login_page_bg_logo");
					if($file_data['upload_status'] == 1 && $file_data['res_msg'] == 'Success') {
						$company_data_array['login_page_bg_logo'] = $file_data['new_file_name'];
						$img = $this->input->post('old_login_page_bg_logo');
						@unlink( COMPANY_IMAGE_PATH . $img);
					}
				}
				//$this->Users->companyInfoSave($company_data_array,2);
				// company info save end




				$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
				redirect($this->controller_name.'/userProfileForm/'.$user_id);
		 	}
		 }
		$this->template->admin('user_profile_form', $data);
		
	}
	
	public function changeStatus($user_id, $status_value)
	{
		if($user_id == "" || $user_id == 0 || $status_value == ""){redirect('errors/invalidRequest');} // Check passing argument and logined user
		if(checkModuleAccessByUser(userInfo('user_role_id'), 2, "module_view") == 0){ redirect('errors/noPermission');} // Check user access permission
		$data['title'] = "User Change Status"; 
		$this->db->where('user_id', $user_id);
		$this->db->update(TABLE_USERS, array('user_status' => $status_value, 'dom' => date('Y-m-d H:i:s')));
		redirect($this->controller_name);
	}
	
	public function userResetPasswordForm($user_id)
	{
		if($user_id == "" || $user_id != userInfo('user_id')){redirect('errors/invalidRequest');} // Check passing argument and logined user
		$data['title'] = "User Reset Password Form"; 
		$data['user_id'] = $user_id;
		if($this->input->post()) {
			$this->form_validation->set_rules('new_user_password', 'User New Password', 'trim|required');
			$this->form_validation->set_rules('confirm_new_user_password', 'Confirm User New Password', 'trim|required|matches[new_user_password]');
			if ($this->form_validation->run() === TRUE) {
				$new_user_password = $this->input->post('new_user_password');
				$data_array['user_password'] = md5($new_user_password);
				$data_array['dom'] = date('Y-m-d H:i:s');
				$id = $this->Users->userSave($data_array, $user_id);
				$this->session->set_flashdata('msg_success', getMessage("record_saved", 3));
				redirect($this->controller_name.'/userResetPasswordForm/'.$user_id);
		 	}
		 }
		$this->template->admin('user_reset_password_form', $data);	
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 27 2024 00:19:25
giriqfky / giriqfky
0755
Users.php
17.209 KB
July 27 2024 00:19:25
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF