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 : /proc/self/root/var/www/blue-sky.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?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() { //admin role module check $this->check_admin_role('admin member'); //method from Admin_controller //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'); } function verify_passwordreset($this_str,$this_email) { if (empty($this_str) || empty($this_email)) { redirect(base_url('admin/user/login')); } $this_email = str_replace("%40","@",$this_email); $query_users = $this->db->get_where('users',array( "email"=>$this_email )); if ($query_users->num_rows()>0) { $query_users = $query_users->row(); $this_password = md5($query_users->password); if ($this_password != $this_str) { $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:red; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Kode pemulihan password tidak sesuai.</strong></div>"); redirect(base_url('admin/user/login')); }else{ $this->session->set_flashdata('open_form_lostpas', "open"); $this->session->set_flashdata('old_email_val', $this_email); $this->session->set_flashdata('old_pass_val', $this_str); redirect(base_url('admin/user/login')); } }else{ $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:red; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Email anda tidak ditemukan.</strong></div>"); redirect(base_url('admin/user/login')); } } function lost_password() { if (empty($this->input->post('lost_password'))) { redirect(base_url('admin/user/login')); } $email = $this->security->xss_clean($this->input->post('emaillost')); $old_pas = $this->input->post('old_pass'); if (isset($old_pas) && $old_pas != '' && $old_pas != null) { $new_pas = $this->input->post('inp_password'); $query_users = $this->db->get_where('users',array( "email"=>$email )); if ($query_users->num_rows()>0) { $query_users = $query_users->row(); $this_oldpassword = md5($query_users->password); if ($old_pas != $this_oldpassword) { $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:red; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Wrong Account.</strong></div>"); }else{ $new_pas = hash('sha512', $new_pas . config_item('encryption_key')); $this->db->update('users',array( "password"=>$new_pas, ),array( "email"=>$email, )); $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:green; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Password berhasil di ubah.</strong></div>"); } }else{ $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:red; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Wrong Account.</strong></div>"); } redirect('admin/user/login'); exit(); } // $rules = array( // 'field'=>'emaillost', // 'label'=>'Email', // 'rules'=>'' // ); // $this->form_validation->set_rules($rules); $this->form_validation->set_rules('emaillost', 'Email', 'trim|required|valid_email'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run($this) == FALSE) { redirect('admin/user/login'); } else { //upload random string to customer table $this->load->helper('string'); $query_users = $this->db->get_where('users',array( "email"=>$email )); if ($query_users->num_rows()>0) { $query_users = $query_users->row(); $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['this_user'] = 'admin'; $data['this_email'] = str_replace("@","%40",$email); $data['random_string'] = md5($query_users->password); $data['email'] = $email; $data['subject'] = 'Password Reset Confirmation'; $data['title'] = 'Password Reset Confirmation'; $view_file = $this->load->view('email/indonesian/password_reset_confirmation', $data, TRUE); $this->send_email($view_file, $data, true); //----end send email $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:green; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Konfirmasi Password Reset telah dikirimkan Ke email Anda.</strong></div>"); redirect('admin/user/login'); }else{ $this->session->set_flashdata('confirmation', "<div style='font-size:1.2em; color:white; background:red; padding:5px;'><img width='25px' src='https://www.tokodaku.com/store-shared/assets/frontend/img/warning_icon.jpg'/><strong> Email yang anda masukan salah.</strong></div>"); redirect('admin/user/login'); } } } //to edit current user or add new user in admin public function edit($id=NULL) { //admin role module check $this->check_admin_role('admin member'); //method from Admin_controller if($id) { $this->data['user'] = $this->user_m->get($id); count($this->data['user']) || $this->data['errors'][] = 'User could not be found'; } else { $pars_submit = $this->input->post('submit'); $this->data['user'] = $this->user_m->get_new(); } // if (($this->data['membership_type']=="starter" || $this->data['membership_type']=="business") && $this->data['jml_user']>=2) { // redirect('admin/user'); // } //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 email, and else.. if($this->input->post('password')) { $data = $this->user_m->array_from_post(array( 'name', 'email', 'role_id', 'password')); $data['password'] = $this->user_m->hash($data['password']); } else { $data = $this->user_m->array_from_post(array( 'name', 'email', 'role_id')); } $this->user_m->save($data, $id); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">User Berhasil di Edit</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) { //admin role module check $this->check_admin_role('admin member'); //method from Admin_controller //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 Berhasil di Hapus</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>'); //above is to add class to form validation error, to be styled $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', 'Maaf, Login Tidak Valid'); redirect('admin/user/login'); } } //get membership active status.. $this->data['membership_active'] = $this->db->select('membership_active')->from('configuration')->where('id_configuration', 1)->get()->row()->membership_active; $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 email, used for edit user public function _unique_email($str) { $id = $this->uri->segment(4); //to fetch current id $this->db->where('email', $this->input->post('email')); !$id || $this->db->where('id !=', $id);//dont choose current email $user = $this->user_m->get(); if(count($user)) { $this->form_validation->set_message('_unique_email', '%s harus unik'); return FALSE; } return TRUE; } }