Пример #1
0
                                                <span class="mif-envelop"></span> <a href="mailto:<?php 
    echo $user->email;
    ?>
"><?php 
    echo $user->email;
    ?>
</a>
                                            </div>
                                        </div>
                                    </div>
                                    <table class="table hovered">
                                        <tbody>
                                            <tr>
                                                <td>Web</td>
                                                <td><span class="mif-home"></span> <a href="<?php 
    echo qa_domain($user->web);
    ?>
" target="_blank"><?php 
    echo $user->web;
    ?>
</a></td>
                                            </tr>
                                            <tr>
                                                <td>Location</td>
                                                <td><span class="mif-earth"></span> <?php 
    echo $user->lokasi;
    ?>
</td>
                                            </tr>
                                            <tr>
                                                <td>Registration</td>
Пример #2
0
 function update($str = NULL, $str2nd = NULL)
 {
     if (!empty($str)) {
         $data = array('record' => $this->_get($str), 'role' => $this->qa_model->all('role', 'id_role ASC'), 'record_join' => $this->qa_model->join_where('user', 'role', 'user.role_id=role.id_role', array('user.id_user' => $str), 'user.id_user'));
         if (!empty($data['record'])) {
             if (empty($str2nd)) {
                 foreach ($data['record'] as $get) {
                     $this->form_validation->set_rules('nama', 'nama', 'trim|required|min_length[5]|max_length[100]|xss_clean');
                     $this->form_validation->set_rules('activated', 'activated', 'trim|required|min_length[1]|max_length[4]|xss_clean');
                     $this->form_validation->set_rules('web', 'web', 'trim|required|min_length[5]|max_length[50]|xss_clean');
                     $this->form_validation->set_rules('lokasi', 'lokasi', 'trim|required|min_length[3]|max_length[50]|xss_clean');
                     $this->form_validation->set_rules('role_id', 'role_id', 'trim|required|min_length[1]|max_length[11]|xss_clean');
                     $this->form_validation->set_rules('bio', 'bio', 'trim|required|min_length[1]|max_length[500]|xss_clean');
                     $this->form_validation->set_error_delimiters('', '<br>');
                     if ($this->form_validation->run() == TRUE) {
                         $update = array('nama' => $this->input->post('nama', TRUE), 'activated' => $this->input->post('activated', TRUE), 'web' => qa_domain($this->input->post('web', TRUE)), 'lokasi' => $this->input->post('lokasi', TRUE), 'role_id' => $this->input->post('role_id', TRUE), 'bio' => $this->input->post('bio', TRUE));
                         if (!empty($_FILES['userfile']['tmp_name'])) {
                             $config_upload = array('upload_path' => $this->config->item('pic_user'), 'allowed_types' => 'jpg|jpeg|png|gif', 'encrypt_name' => TRUE);
                             $this->load->library('upload', $config_upload);
                             if (!$this->upload->do_upload()) {
                                 $data['errors'] = $this->upload->display_errors('', '<br>');
                                 $this->_render('user/update', $data);
                             } else {
                                 if (!empty($get->image)) {
                                     unlink($this->config->item('pic_user') . $get->image);
                                 }
                                 $update['image'] = $this->upload->data('file_name');
                                 $this->qa_model->update('user', $update, array('id_user' => $str));
                             }
                         } else {
                             $this->qa_model->update('user', $update, array('id_user' => $str));
                         }
                         if ($get->activated != $update['activated'] || $get->role_id != $update['role_id']) {
                             $this->qa_libs->log_out();
                             redirect();
                         } else {
                             redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                         }
                     } else {
                         $this->_render('user/update', $data);
                     }
                 }
             } else {
                 if ($str2nd === 'username') {
                     $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[3]|max_length[25]|xss_clean');
                     $this->form_validation->set_error_delimiters('', '<br>');
                     if ($this->form_validation->run() == TRUE) {
                         foreach ($this->_get($str) as $user) {
                             $check_username = $this->qa_model->get('user', array('username' => $this->input->post('username', TRUE)));
                             if (strtolower($user->username) === strtolower($this->input->post('username', TRUE))) {
                                 $update = array('username' => $this->input->post('username', TRUE));
                                 $this->qa_model->update('user', $update, array('id_user' => $str));
                                 redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                             } elseif ($check_username != FALSE) {
                                 $data['errors'] = 'Error! Username <b>' . $this->input->post('username', TRUE) . '</b> sudah ada sebelumnya dalam basis data.';
                                 $this->_render('user/username', $data);
                             } else {
                                 $update = array('username' => $this->input->post('username', TRUE));
                                 $this->qa_model->update('user', $update, array('id_user' => $str));
                                 redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                             }
                         }
                     } else {
                         $this->_render('user/username', $data);
                     }
                 } elseif ($str2nd === 'email') {
                     $this->form_validation->set_rules('email', 'E-Mail', 'trim|required|min_length[6]|max_length[100]|xss_clean|valid_email');
                     $this->form_validation->set_error_delimiters('', '<br>');
                     if ($this->form_validation->run() == TRUE) {
                         foreach ($this->_get($str) as $user) {
                             $check_email = $this->qa_model->get('user', array('email' => $this->input->post('email', TRUE)));
                             if (strtolower($user->email) === strtolower($this->input->post('email', TRUE))) {
                                 $update = array('email' => $this->input->post('email', TRUE));
                                 $this->qa_model->update('user', $update, array('id_user' => $str));
                                 redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                             } elseif ($check_email != FALSE) {
                                 $data['errors'] = 'Error! E-mail <b>' . $this->input->post('email', TRUE) . '</b> sudah ada sebelumnya dalam basis data.';
                                 $this->_render('user/email', $data);
                             } else {
                                 $update = array('email' => $this->input->post('email', TRUE));
                                 $this->qa_model->update('user', $update, array('id_user' => $str));
                                 redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                             }
                         }
                     } else {
                         $this->_render('user/email', $data);
                     }
                 } elseif ($str2nd === 'passwd') {
                     $this->form_validation->set_rules('old_passwd', 'Old Password', 'trim|required|min_length[6]|max_length[200]|xss_clean');
                     $this->form_validation->set_rules('new_passwd', 'New Password', 'trim|required|min_length[6]|max_length[200]|xss_clean');
                     $this->form_validation->set_rules('passwd_conf', 'Password Confirmation', 'trim|required|min_length[6]|max_length[200]|xss_clean|matches[new_passwd]');
                     $this->form_validation->set_error_delimiters('', '<br>');
                     if ($this->form_validation->run() == TRUE) {
                         foreach ($this->_get($str) as $user) {
                             $this->load->library('phpass');
                             $check_password = $this->phpass->check_password($this->input->post('old_passwd', TRUE), $user->password);
                             if ($check_password == TRUE) {
                                 if ($this->input->post('old_passwd', TRUE) === $this->input->post('passwd_conf', TRUE)) {
                                     $data = array('errors' => 'Password yang akan anda ganti tidak boleh sama dengan password sebelumnya.');
                                     $this->_render('user/passwd', $data);
                                 } else {
                                     $update = array('password' => $this->phpass->hash_password($this->input->post('passwd_conf', TRUE)));
                                     $this->qa_model->update('user', $update, array('id_user' => $str));
                                     redirect($this->uri->segment(1) . '/' . $this->uri->segment(2));
                                 }
                             } else {
                                 $data = array('errors' => 'Password lama yang anda masukkan salah.');
                                 $this->_render('user/passwd', $data);
                             }
                         }
                     } else {
                         $this->_render('user/passwd', $data);
                     }
                 } else {
                     show_404();
                     return FALSE;
                 }
             }
         } else {
             show_404();
             return FALSE;
         }
     } else {
         show_404();
         return FALSE;
     }
 }