public function resetClientPassword($fields = array()) { $client = new Client($fields['email']); // 4Nov15 :: Sankalp : Change $data to an array so that it can hold user information $data['info'] = $client->data(); if ($data) { //29Nov15 :: Sankalp : Enter proper email of client $verify = Hash::get($data['info']['email'], 'reset_password'); $crud = CRUD::getInstance(); //29Nov15 :: Sankalp : Enter proper id of client $crud->insert("client_reset_tokens", array('client_id' => $data['info']['client_id'], 'hash' => $verify)); // 4Nov15 :: Sankalp : adding $rlink to data array $data['rlink'] = RESOURCE_PATH_DIY . "confirm-password?reset=" . $verify; if ($verify) { return $data; } else { return "error"; } } else { return "error"; } }
<?php require_once '../core/config.php'; if (isset($_POST['reset-email'])) { $response = array(); $client = new Client($_POST['reset-email']); $data = $client->data(); if ($data) { $verify = Hash::get($data['email'], 'reset_password'); $crud = CRUD::getInstance(); $crud->insert("client_reset_tokens", array('client_id' => $data['client_id'], 'hash' => $verify)); $mail = new Mail(); $rlink = RESOURCE_PATH_DIY . "confirm-password?reset=" . $verify; $send = $mail->passwordResetMail(array(array('name' => $data['name'], 'email' => $data['email'])), $rlink); if ($send) { $response['status'] = 1; $response['message'] = "An email has been sent to {$data['email']} to reset your password."; } else { $response['status'] = 0; $response['message'] = "Unable to send email right now."; } } else { $response['status'] = 0; $response['message'] = "No record found for this email."; } print_r(json_encode($response)); } // VISHWAS : 4 Dec 2015 :: Commenting following line as this file is already included at top. //require_once '../core/config.php'; if (isset($_POST['reset']) && $_POST['reset'] != "") { $crud = CRUD::getInstance();
<?php require_once '../core/config.php'; if (isset($_GET['verify']) && $_GET['verify'] != "") { $crud = CRUD::getInstance(); $find = $crud->select("client_reset_tokens", "client_id,expired_date", "where hash='{$_GET['verify']}'"); /* * 25-03-15 :: check if hash is correct, check expiration, update is_verified and update expiration for hash */ if ($find) { $client_id = $crud->getFirst()['client_id']; $expired_date = $crud->getFirst()['expired_date']; if ($expired_date == "0000-00-00 00:00:00") { $client = new Client(); $data = $client->get($client_id); if ($client->data()['is_verified'] == 0) { $client->edit(array('is_verified' => 1), $client_id); /* * 27-03-15 :: expired_date updated istead of delete */ $crud->update("client_reset_tokens", array('expired_date' => date("Y-m-d H:i:s")), "where type='email' and hash='{$_GET['verify']}'"); $mail = new Mail(); $mail->welcomeMail(array(array('name' => $data['name'], 'email' => $data['email']))); } /* redirect path corrected */ echo '<body style="background-color:#f4f5f9; margin:0"><div class="page" style="width:100%; float:left; background-color:#f4f5f9;font-family:Arial, Helvetica, sans-serif;" > <div class="header" style="width:100%; float:left; height:75px; background-color:#fff;"><div class="left_header" style="float:left; width:50%; "><img style="margin:15px 0px 0px 50px;" src="http://plobalapps.com/diy/images/emailer/plobal-logo.png" height="40" /> </div> <div class="right_header" style="float:right; width:50%; "><div class="social_icons" style="float:right; margin:24px 0px 15px 0px;width:90px;"><a href="#"> <img style="margin-right:10px;" src="http://plobalapps.com/diy/images/emailer/fb-icon.png" /></a><a href="#"> <img style="margin-right:10px;" src="http://plobalapps.com/diy/images/emailer/twitter-icon.png" /></a></div><h3 style="line-height:70px; float:right; font-size:14px; color:#8b8b8b; padding:0px; font-weight:normal;margin:0 15px 0 0;"><img src="http://plobalapps.com/diy/images/emailer/call.png" style="float:left; margin:24px 0px 3px 0px;" /> +91 9819405002 </h3></div></div><div class="container" style="width:600px; margin:120px auto 0 auto; background-color:#fff; text-align:center; padding:100px;"><div class="inner_container" style="background-color:#fff;"><p style="font-size:20px;color:#222;">Thank You For Verifying Your Email Address</p><br /><br /><a style="background-color:#1fafec; color:#fff; padding:15px 25px; text-decoration:none;" href="' . RESOURCE_PATH_DIY . 'dashboard">Visit Homepage</a></div> </div> <div class="contant"> </div></div></body>'; } else { echo '<body style="background-color:#f4f5f9; margin:0"><div class="page" style="width:100%; float:left; background-color:#f4f5f9;font-family:Arial, Helvetica, sans-serif;" > <div class="header" style="width:100%; float:left; height:75px; background-color:#fff;"> <div class="left_header" style="float:left; width:50%; "> <img style="margin:15px 0px 0px 50px;" src="http://plobalapps.com/diy/images/emailer/plobal-logo.png" height="40" /> </div> <div class="right_header" style="float:right; width:50%; "><div class="social_icons" style="float:right; margin:24px 0px 15px 0px;width:90px;"><a href="#"> <img style="margin-right:10px;" src="http://plobalapps.com/diy/images/emailer/fb-icon.png" /></a><a href="#"> <img style="margin-right:10px;" src="http://plobalapps.com/diy/images/emailer/twitter-icon.png" /></a></div><h3 style="line-height:70px; float:right; font-size:14px; color:#8b8b8b; padding:0px; font-weight:normal;margin:0 15px 0 0;"><img src="http://plobalapps.com/diy/images/emailer/call.png" style="float:left; margin:24px 0px 3px 0px;" /> +91 9819405002 </h3></div></div><div class="container" style="width:600px; margin:120px auto 0 auto; background-color:#fff; text-align:center; padding:100px;"><div class="inner_container" style="background-color:#fff;"><p style="font-size:20px;color:#222;">Expired verification link</p><br /><br /><a style="background-color:#1fafec; color:#fff; padding:15px 25px; text-decoration:none;" href="' . RESOURCE_PATH_DIY . 'dashboard">Visit Homepage</a></div> </div> <div class="contant"> </div></div></body>'; }