| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/adeetie_hellogtx/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Fauth extends CI_Controller {
function __construct() {
parent:: __construct();
}
function index() {
$this->load->library('form_validation');
$this->form_validation->set_rules('email_id','Email','required|valid_email');
$this->form_validation->set_rules('password','Password','required');
$user_detail = $this->session->has_userdata('email_id');
if($this->form_validation->run() == FALSE) {
$this->load->view('facilation/login');
} else {
$captcha = $this->input->post('g-recaptcha-response');
$remoteaddr = verify_captcha($captcha, $_SERVER['REMOTE_ADDR']);
// if(empty(json_decode($remoteaddr)) || json_decode($remoteaddr)->success !=1) {
// redirect('fauth', 'refresh');
// return;
// }
$emailid = trim($this->input->post('email_id'));
$password = trim($this->input->post('password'));
$userdata = $this->is_email_exit($emailid);
if(!empty($userdata)) {
if(password_verify($password, $userdata['password'])) {
$array = array(
'name' => $userdata['name'],
'email_id' => $userdata['email_id'],
'user_id' => $userdata['user_id'],
'module' => 'fc'
);
$this->session->set_userdata($array);
redirect('fc', 'refresh');
}
}
$this->session->set_flashdata('error','Invalid email or password');
redirect('fauth', 'refresh');
}
}
function is_email_exit($emailid) {
$this->db->where('email_id', $emailid);
$sql = $this->db->get('facilation_users');
if($sql->num_rows() > 0) {
return $sql->row_array();
}
}
function forgetpassword(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email','Email id','required');
if($this->form_validation->run() == FALSE) {
$this->load->view('facilation/forgot_password');
} else {
$captcha = $this->input->post('g-recaptcha-response');
$remoteaddr = verify_captcha($captcha, $_SERVER['REMOTE_ADDR']);
// if(empty(json_decode($remoteaddr)) || json_decode($remoteaddr)->success !=1) {
// redirect('auth/login', 'refresh');
// return;
// }
$this->resetEmail($this->input->post('email'));
}
}
public function _reset_mail($email, $resetcode) {
$this->load->library('email');
$config = array();
$config['charset'] = 'utf-8';
$config['newline'] = "\r\n";
$config['wordwrap'] = true;
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail";
$mail_config['mailtype'] = 'html'; //FIXED
$mail_config['send_multipart'] = false;
$this->email->initialize($mail_config);
$this->email->from('mail@bee.umon.in', 'Reset password link');
$this->email->to($email);
$msg = "";
$msg .= "<table>";
$msg .= "<tr><td>Hello,</td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td>We'hve have recived a request to reset password for the ADEETIE </td></tr>";
$msg .= "<tr><td>account associated with ".$email. " No changes <br> have been made to your account yet</td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td>You can reset your password by clicking the link below:</td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td><a style='padding:7px 20px; width: 100%; display:block; background:#38ae00; color: #fff; text-align: center' href=".base_url('fauth/resetlink/'.$resetcode)."> Reset your password </a></td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td>If you did not request a new password, please ignore link. </td></tr>";
$msg .= "<tr><td>Ip address :" . $this->input->ip_address() . "</td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td> </td></tr>";
$msg .= "<tr><td>-- ADEETIE Team </td></tr>";
$msg .= "<table>";
$this->email->subject('Reset Password');
$this->email->message($msg);
$this->email->send(false);
}
function resetEmail($email) {
if(!empty($email)) {
$sql = $this->db->where('email_id', $email)
->get('facilation_users');
if($sql->num_rows() == 1) {
$resetcode = md5(uniqid('bee'));
$arr = [
'reset_link' => $resetcode,
'reset_date' => date('Y-m-d H:i:s')
];
$this->db->where('email_id', $email)->update('facilation_users', $arr);
$this->_reset_mail($email, $resetcode);
redirect('fauth/thanks', 'refresh');
}
}
redirect('fauth/thanks', 'refresh');
}
function resetlink($code) {
$this->form_validation->set_rules('password','Password','required');
if(!empty($code)) {
$sql = $this->db->where('reset_link', $code)->get('facilation_users');
if($sql->num_rows() == 1) {
$detail = $sql->row_array();
$date1 = date('Y-m-d H:i:s');
$date2 = $detail['reset_date'];
$seconds = strtotime($date1) - strtotime($date2);
$minutes = ($seconds /60);
if($minutes < 361) {
if($this->form_validation->run() == FALSE) {
$this->load->view('bee/change_password');
} else {
$captcha = $this->input->post('g-recaptcha-response');
$remoteaddr = verify_captcha($captcha, $_SERVER['REMOTE_ADDR']);
// if(empty(json_decode($remoteaddr)) || json_decode($remoteaddr)->success !=1) {
// redirect('auth/login', 'refresh');
// return;
// }
$this->db->where('email_id', $detail['email_id']);
$data = [
'reset_link' => '',
'reset_date' => NULL,
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT)
];
$this->db->update('facilation_users', $data);
redirect('fauth', 'refresh');
}
}
} else {
redirect('fauth/linkexpire', 'refresh');
}
} else {
redirect('fauth/linkexpire', 'refresh');
}
}
function thanks() {
$data['menu']= $data['menu']= $this->menudetail();
$this->load->vars($data);
$this->load->view('bee/layout/template', ['page'=> 'bee/thanks']);
}
function linkexpire() {
$data['menu']= $this->menudetail();
$this->load->vars($data);
$this->load->view('bee/layout/template', ['page'=> 'bee/linkexpire']);
}
function menudetail() {
return $this->db->query('SELECT A.menu_name,A.id,A.menu_type,A.menu_external_link,A.menu_order,group_concat(B.page_slug ) as
page_slug, group_concat(B.page_name ORDER BY FIND_IN_SET(B.id,A.menu_related_pages)) as page_name FROM
'.TBL_MENU.' A left join '.TBL_PAGES.' B on FIND_IN_SET(B.id,A.menu_related_pages) WHERE A.status=1 AND
(( A.menu_type=3 ) OR ( A.menu_type!=3 AND B.status=1 ) ) group by A.menu_name ORDER BY A.menu_order ASC ' )->result();
}
}