From 286cb386da80a58ab7e34d165d698f5789a7e922 Mon Sep 17 00:00:00 2001 From: suseendhiran17 <58357088+suseendhiran17@users.noreply.github.com> Date: Thu, 11 May 2023 14:57:02 +0530 Subject: [PATCH] change pass:suseendhiran --- app/Config/Routes.php | 3 +- app/Controllers/Admin_controller.php | 66 +++++++++++++++++++------ app/Views/admin_login.php | 6 ++- app/Views/layout/header.php | 4 +- app/Views/profile.php | 41 ++++++++-------- app/Views/user_form.php | 2 +- app/Views/users_password.php | 73 ++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+), 42 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5a8ec4f..86568ae 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -56,11 +56,12 @@ $routes->match(['post'],'/user_edit','Admin_controller::user_edit'); $routes->match(['get','post'],'/user_add','Admin_controller::user_add'); $routes->match(['get'],'/admin_profile/(:any)','Admin_controller::admin_profile/$1'); $routes->match(['post'],'/admin_profile','Admin_controller::admin_profile'); -$routes->match(['post'],'/profilepic','Admin_controller::profilepic_insert'); +$routes->match(['post'],'/profilepic_insert','Admin_controller::profilepic_insert'); $routes->match(['get'],'/credits_pack_list','Admin_controller::credits_pack_list'); $routes->match(['get'],'/credits_pack_edit/(:any)','Admin_controller::credits_pack_edit/$1'); $routes->match(['post'],'/credits_pack_edit','Admin_controller::credits_pack_edit'); $routes->match(['get','post'],'/credits_pack_add','Admin_controller::credits_pack_add'); +$routes->match(['get','post'],'/user_password_change','Admin_controller::user_password_change'); $routes->match(['get'],'/admin_home','Dashboard::admin_home'); $routes->match(['get'],'/member_home','Dashboard::member_home'); diff --git a/app/Controllers/Admin_controller.php b/app/Controllers/Admin_controller.php index c30bac0..afa5771 100644 --- a/app/Controllers/Admin_controller.php +++ b/app/Controllers/Admin_controller.php @@ -157,25 +157,30 @@ class Admin_controller extends BaseController public function profilepic_insert() { - + if($this->request->getmethod() == 'post') { - if(isset($_FILES["image_file"]["name"])) + $path = ROOTPATH ."/public/assets/images/users"; + if($this->request->getFile('profile')) { - $config['upload_path'] = base_url()."/public/assets/images/users"; - $config['allowed_types'] = 'jpg|jpeg|png|gif'; - print_r($config);die(); - - $this->load->library('upload', $config); - if(!$this->upload->do_upload('image_file')) - { - echo $this->upload->display_errors(); - } - else - { - $data = $this->upload->data(); - echo ''; - } + $img = $this->request->getFile('profile'); + if ($img->isValid() && ! $img->hasMoved()) + { + //$newName = $img->getRandomName(); + $f_type=$_FILES['profile']['name']; + $data['profile'] = $f_type; + $this->UserModel->where('id', $this->request->getVar('id') )->set($data)->update(); + $img->move($path, $f_type); + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); + } + else + { + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); + } + } + else + { + return redirect()->to(base_url()."admin_profile/".md5($this->request->getVar('id'))); } } @@ -238,6 +243,35 @@ class Admin_controller extends BaseController echo view('credits_pack_form'); echo view('layout/footer'); + } + + public function user_password_change() + { + + if($this->request->getmethod() == 'post') + { + //insert member details + $UserData = $this->request->getVar(); + $old_password = $this->request->getVar('old_password'); + $data = $this->UserModel->where('id', $this->request->getVar('id') )->find(); + if (password_verify($old_password ,$data[0]['password'])) + { + $this->UserModel->where('id', $this->request->getVar('id') )->set($UserData)->update(); + $this->session->setTempdata('mail_success',"Password changed successfully",3); + return redirect()->to(base_url()."admin"); + } + else + { + $this->session->setTempdata('error',"Entered wrong old password",3); + return redirect()->to(base_url()."user_password_change"); + } + } + + $userdata['userdata']=$this->dModel->getLoggedInUserData(session()->get('logged_user')); + echo view('layout/header',$userdata); + echo view('users_password'); + echo view('layout/footer'); + } // ----------------------------------------------- } diff --git a/app/Views/admin_login.php b/app/Views/admin_login.php index 1c342f0..2cf9476 100644 --- a/app/Views/admin_login.php +++ b/app/Views/admin_login.php @@ -45,7 +45,11 @@
"> - + getTempdata('mail_success')):?> +
+ getTempdata('mail_success'); ?> +
+ getTempdata('error')):?>
getTempdata('error'); ?> diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php index d18fb22..00eb0c9 100644 --- a/app/Views/layout/header.php +++ b/app/Views/layout/header.php @@ -304,8 +304,8 @@ $(document).ready(function(){ - id); ?>" class="dropdown-item notify-item"> - + " class="dropdown-item notify-item"> + Change Password diff --git a/app/Views/profile.php b/app/Views/profile.php index 1dde8ac..4cbebb5 100644 --- a/app/Views/profile.php +++ b/app/Views/profile.php @@ -73,9 +73,10 @@ body {
- + " enctype="multipart/form-data"> - + +
profile-image @@ -89,7 +90,7 @@ body { else { ?>
- ' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image"> + ' class="rounded-circle avatar-xl img-thumbnail" alt="profile-image">
@@ -137,27 +138,25 @@ $(".profilepic").one('click',function() { }); // change login person profile pic => file name : user/profile.php -$(document).ready(function(){ $("#file_profile").change(function(){ $(".btn-success").click(); }); -}); -$(document).on('change','#file_profile',function(e){ - var data = $("#form").serialize(); - $.ajax({ - type: "post", - url: "profilepic", - data: data, - json: true, - success: function(response) { - alert(response) - if (response == true) { - alert("dakug"); - } +// $(document).on('change','#file_profile',function(e){ +// var data = $("#form").serialize(); +// $.ajax({ +// type: "post", +// url: "profilepic_insert", +// data: data, +// json: true, +// success: function(response) { +// alert(response) +// if (response == true) { +// alert("dakug"); +// } - }, - error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) } - }); -}); +// }, +// error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) } +// }); +// }); \ No newline at end of file diff --git a/app/Views/user_form.php b/app/Views/user_form.php index d385cc8..eff71e5 100644 --- a/app/Views/user_form.php +++ b/app/Views/user_form.php @@ -148,7 +148,7 @@ Update Save
diff --git a/app/Views/users_password.php b/app/Views/users_password.php index e69de29..ce06054 100644 --- a/app/Views/users_password.php +++ b/app/Views/users_password.php @@ -0,0 +1,73 @@ + \ No newline at end of file