- Timestamp:
- Nov 6, 2014 11:06:26 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/admin/controllers/admin_acc.php
r423 r424 65 65 { 66 66 $this->load->helper('email'); 67 $result ['success'] = 0;68 $result = array();67 $result = array(); 68 $result['success'] = 0; 69 69 $input = $this->input->post(); 70 70 $this->load->model('admin_model'); … … 115 115 { 116 116 unset($input['pwd2']); 117 $input['passwd'] = md5($input['passwd']); 117 118 $input['created_time']=date("Y-m-d H:i:s"); 118 119 $input['updated_time']=date("Y-m-d H:i:s"); … … 131 132 if ($admin_info) 132 133 { 133 /*134 $input = $this->input->post();135 $result = array();136 $result['success'] = 0;137 $admin_id = (int)$this->uri->segment(4, 0);138 if ($admin_id==0){139 $result['success'] = 0;140 }else141 {142 $this->load->model('admin_model');143 $input['updated_time']=date("Y-m-d H:i:s");144 $this->admin_model->update($admin_id, $input);145 $result['success'] = 1;146 }147 echo json_encode($result);*148 */149 134 $admin_id = $this->uri->segment(4); 150 135 $this->load->model('admin_model'); … … 165 150 $result = array(); 166 151 $result['success'] = 0; 167 //$admin_id = $this->uri->segment(4);168 152 $this->load->model('admin_model'); 169 153 $input['updated_time']=date("Y-m-d H:i:s"); … … 214 198 } 215 199 } 200 201 public function admin_profile() 202 { 203 $admin_info = $this->session->userdata('adminInfo'); 204 if($admin_info) 205 { 206 $admin_id = $admin_info['admin_id']; 207 $this->load->model(array('admin_model')); 208 $data = $this->admin_model->search_by_id($admin_id); 209 $this->load->view('admin_acc/admin_profile', $data); 210 }else 211 { 212 $this->load->view('login'); 213 } 214 } 215 216 public function update_info() 217 { 218 $admin_info = $this->session->userdata('adminInfo'); 219 if ($admin_info) 220 { 221 $this->load->helper('email'); 222 $input = $this->input->post(); 223 $result = array(); 224 $result['success'] = 0; 225 if(strlen($input['email'])>0){ 226 if(!valid_email($input['email'])) 227 { 228 $result['errors']['email_err']="Email khÃŽng Äúng Äá»nh dạng"; 229 } 230 } 231 if(strlen($input['phone'])>0){ 232 if (!preg_match('/[0-9]/', $input['phone'])) 233 { 234 $result['errors']['phone_err']="Phone khÃŽng Äúng Äá»nh dạng"; 235 } 236 } 237 if (!isset($result['errors'])) 238 { 239 $input['admin_id'] = $admin_info['admin_id']; 240 $input['updated_time']=date("Y-m-d H:i:s"); 241 $this->load->model('admin_model'); 242 $this->admin_model->update($input['admin_id'], $input); 243 $result['success'] = 1; 244 } 245 echo json_encode($result); 246 }else 247 { 248 $this->load->view('login'); 249 } 250 } 251 252 public function change_password() 253 { 254 $admin_info = $this->session->userdata('adminInfo'); 255 if ($admin_info){ 256 $result = array(); 257 $result['success'] = 0; 258 $this->load->model('admin_model'); 259 $input = $this->input->post(); 260 $input['admin_id'] = $admin_info['admin_id']; 261 if (strlen($input['passwd']) == 0) 262 { 263 $result['errors']['passwd_old_err'] = "Máºt khẩu khÃŽng ÄÆ°á»£c Äá» trá»ng !"; 264 }else 265 { 266 $check_pass = $this->admin_model->check_password($input['admin_id'], $input['passwd']); 267 if (!$check_pass) 268 { 269 $result['errors']['passwd_old_err'] = "Máºt khẩu cung cấp khÃŽng Äúng !"; 270 } 271 } 272 if (strlen($input['passwd_new']) == 0) 273 { 274 $result['errors']['passwd_new_err'] = "Máºt khẩu khÃŽng ÄÆ°á»£c Äá» trá»ng !"; 275 }else if($input['passwd'] == $input['passwd_new']) 276 { 277 $result['errors']['passwd_new_err'] = "Máºt khẩu trùng vá»i máºt khẩu hiá»n tại !"; 278 } 279 if ($input['passwd_new'] != $input['confirm_passwd_new']) 280 { 281 $result['errors']['confirm_passwd_new_err'] = "Máºt khẩu khÃŽng trùng nhau !"; 282 } 283 if (!isset($result['errors'])) 284 { 285 $updated_time=date("Y-m-d H:i:s"); 286 $data = array('passwd'=>md5($input['passwd_new']), 'updated_time'=>$updated_time); 287 $this->admin_model->update($input['admin_id'], $data); 288 $result['success'] = 1; 289 } 290 291 echo json_encode($result); 292 }else 293 { 294 $this->load->view('login'); 295 } 296 297 } 298 216 299 }
Note: See TracChangeset
for help on using the changeset viewer.