JezK
Edit File: functions.php
<?php class uflexitMasterAdmin { function __construct() { require_once dirname(__FILE__) . '/uflexitConfig.php'; require_once dirname(__FILE__) . '/class.db.php'; $this->db = new DB(); } /** * function name: generateSecuredPassword * decription: hash password for users registration * developed by: lathif */ function generateSecuredPassword($password) { $passwordHash=''; $options = [ 'cost' => 12, ]; $passwordHash=password_hash($password, PASSWORD_BCRYPT, $options); return $passwordHash; } /** * function name: checkPasswordMatch * decription: check hash password in db match with given password or not * developed by: Gowtham */ function checkPasswordMatch($password,$passwordHash) { if(password_verify($password,$passwordHash)) { return 1; } else{ return 0; } } /** * function name: SuperAdminLogin * decription: Login functionality * developed by: Gowtham */ function superAdminLogin($post,$type=NULL) { $returnVal = 0; $email=strip_tags($this->db->escape(trim($post['email']))); $password=strip_tags($this->db->escape(trim($post['password']))); $query="SELECT * FROM uflexit_super_administrator WHERE email='$email'"; // $hash_password=$this->generateSecuredPassword($password); // print_r($hash_password); // exit; if ($this->db->num_rows($query) > 0) { $loginDetails = $this->db->get_row($query); // print_r($loginDetails); $_SESSION['name']=$loginDetails['name']; $_SESSION['email']=$loginDetails['email']; $_SESSION['password']=$loginDetails['password']; $_SESSION['admin_id']=$loginDetails['admin_id']; $_SESSION['profile_pic']=$loginDetails['profile_pic']; // print_r($_SESSION['admin_id']); // print_r($_SESSION['email']); $db_password=strip_tags($this->db->escape(trim($loginDetails['password']))); //echo $db_password; $password_result=$this->checkPasswordMatch($password,$db_password); // echo $password_result; if($password_result) { return $returnVal=1; } else{ return $returnVal=2; } } else{ return $returnVal; } } /** * function name: getUserlist * decription:get all the data from table uflexit_users role =1 or 2; * developed by: Gowtham */ function getUserlist(){ $query= "SELECT * FROM uflexit_users WHERE role_id= 1 OR 2"; $count=$this->db->num_rows($query); if($count>0) { return $this->db->get_results($query); } } /** * function name: getSubadmins * decription:get all the data from table uflexit_users role =1 or 2; * developed by: Gowtham */ function getSubadminlist(){ $query= "SELECT * FROM uflexit_super_administrator WHERE role_id=2"; $count=$this->db->num_rows($query); if($count>0) { return $this->db->get_results($query); } } /** * function name: getSuperadmindata * decription:get the superadmin data from table uflexit_super_administrator ; * developed by: Gowtham */ function getAdmindata($id){ $row =""; $query= "SELECT * FROM uflexit_super_administrator WHERE admin_id= '$id'"; if($this->db->num_rows($query)>0) { $row=$this->db->get_row($query); } // print_r($count); return $row; } /** * function name: checkEmailExistsOrNot * decription: This is for check email exists or not * developed by: Kiran kumar */ function checkEmailExistsOrNot($email) { $returnVal=0; $trimEmail=strip_tags($this->db->escape(trim($email))); $query="select * from uflexit_super_administrator where email='".$trimEmail."'"; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: checkUpdatedExistsOrNot * decription: This is for check updated email/phone number exists or not * developed by: Kiran kumar */ function checkUpdatedExistsOrNot($emailOrPhone,$id,$type) { $returnVal=0; $whereCon =''; if($type==1) { $whereCon = "email='".$emailOrPhone."' and admin_id !='".$id."'"; } if($type==2) { $whereCon = "phonenumber='".$emailOrPhone."' and admin_id !='".$id."'"; } $trimEmail=strip_tags($this->db->escape(trim($emailOrPhone))); $query="select * from uflexit_super_administrator where $whereCon "; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: checkPhoneExistsOrNot * decription: This is for check phone exists or not * developed by: Kiran kumar */ function checkPhoneExistsOrNot($mobile) { $returnVal=0; $trimPhone=strip_tags($this->db->escape(trim($mobile))); $query="select * from uflexit_super_administrator where phonenumber='".$trimPhone; $count=$this->db->num_rows($query); if(isset($count) && $count>0) { $returnVal=1; } return $returnVal; } /** * function name: superAdminEdit * decription:Editing Super Admin profile ; * developed by: Gowtham */ function superAdminEdit($post,$id) { //image upload $recordFile=''; $t = $_FILES["image"]["tmp_name"]; $n = $_FILES["image"]["name"]; $p=strtotime(date('d-m-Y H:i:s')); $k=substr(str_shuffle($p),0,5); $tfname=$k.$n; // echo $tfname; if(move_uploaded_file($t, "../uploads/superadmin_photos/".$tfname)) { $recordFile=strip_tags($this->db->escape(trim($tfname))); // $recordFile=$tfname; } else if($recordFile) { echo "Uploaded successfully"; } $name=strip_tags($this->db->escape(trim($post['super_admin_name']))); $email=strip_tags($this->db->escape(trim($post['super_admin_email']))); $password=strip_tags($this->db->escape(trim($post['super_admin_password']))); if(empty($password)){ $query="UPDATE uflexit_super_administrator SET name='".$name."', email='".$email."', profile_pic='".$tfname."' WHERE admin_id='".$id."'"; $result=$this->db->query($query); return 1 ; } else{ $hash_password=$this->generateSecuredPassword($password); $query="UPDATE uflexit_super_administrator SET name='".$name."', email='".$email."', password='".$hash_password."' WHERE admin_id='".$id."'"; $result=$this->db->query($query); return 2; } } /** * function name: getCountryList * decription: This is for getting all countries in uflexit_countries table * developed by: Kiran kumar */ function getCountryList($id='') { $whereCon=''; if($id !='') { $whereCon = "where country_id='".$id."'"; } $data=array(); $query="SELECT * FROM uflexit_countries $whereCon "; if ($this->db->num_rows($query) > 0) { $data=$this->db->get_results($query); } return $data; } /** * function name: addSubAdmin * decription: for adding subadmin ; * developed by: Kiran kumar */ function addSubAdmin($post) { $returnVal = 0; $createdDate=gmdate("Y-m-d H:m:i"); $passwordHash=''; $password="123456"; $options = [ 'cost' => 12, ]; $passwordHash=password_hash($password, PASSWORD_BCRYPT, $options); $query = "insert into uflexit_super_administrator(name,email,password,profile_pic,role_id,country,phonenumber,address,created_dt)VALUES('".$post['admin_name']."','".$post['admin_email']."','".$passwordHash."','','2','".$post['admin_country']."','".$post['admin_phone']."','".$post['admin_address']."','".$createdDate."')"; $result = $this->db->query($query); if($result){ $returnVal=1; } return $returnVal; } /** * function name: updateSubAdmin * decription: for updating subadmin ; * developed by: Kiran kumar */ function updateSubAdmin($post) { $returnVal = 0; $updatedDate=gmdate("Y-m-d H:m:i"); $query = "update uflexit_super_administrator set name ='".$post['name']."', email='".$post['email']."', country='".$post['country']."', phonenumber='".$post['phonenumber']."', address='".$post['address']."', updated_at='".$updatedDate."' where admin_id ='".$post['subadmin_id']."'"; $result = $this->db->query($query); if($result){ $returnVal=1; } return $returnVal; } /** * function name: newsletterlist * decription: deleting newsletterlist profiles ; * developed by: Veeranna chowdary */ function newLetterlist(){ $query= "SELECT * FROM uflexit_newsletter"; $count=$this->db->num_rows($query); if($count>0) { return $this->db->get_results($query); } } function deletenewLetterList($id){ // echo $id; $returnval=0; $query="delete from uflexit_newsletter where id='".$id."'"; $row=$this->db->query($query); if($row){ return $returnval=1; } else{ return $returnval=2; } } /** * function name: getWarehouseList * decription:get all the data from table uflexit_master_wareHouse; * developed by: Ramyakrishna */ function getWarehouseList(){ $query= "SELECT * FROM uflexit_master_wareHouse inner join uflexit_countries on uflexit_master_wareHouse.warehouse_countryId=uflexit_countries.country_id"; $count=$this->db->num_rows($query); if($count>0) { return $this->db->get_results($query); } } function forgotPassword($post) { $returnValue = 0; // $emailactiveToken=$this->generateApiKey(); $email=strip_tags($this->db->escape(trim($post['email']))); $query="SELECT * FROM uflexit_super_administrator WHERE email='" .$email. "'"; $result = $this->db->get_row($query); if($result) { $this->sendForgetPasswordMail($post['email']); $returnValue = 1; } return $returnValue; } function sendForgetPasswordMail($email) { $baseUrl=HOSTPATH; //config file $fromName = 'Uflexit'; $from='support@uflexit.com'; $to=$email; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= 'From: ' . $fromName . '<' . $from . '>' . "\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= 'Cc: ' .$from. "\r\n"; $headers .= 'Bcc: ' .$from. "\r\n"; $subject='Forget Password from Uflexit'; $customerContent=' <tr style="padding:10px !important;display:flex;width:100%;color: #000;word-break: break-word;justify-content: space-evenly;"> <td style="width:45%;font-weight:bold;text-align:center">change Your password</td> <td style="width: 5%;">:</td> <td style="width: 50%;"><a href="' . $baseUrl .COMMONPATH.'/resetPassword.php?etoken='.$emailToken.'"" target="_blank">Reset Password</a></td> </tr> '; $htmlContent = ' <html> <head> <title>Uflexit WareHouse Service</title> </head> <body> <div style="text-align:center;width: 550px;margin: 40px auto;border: 2px solid #2157c9;border-radius: 28px;"> <div style="color: #2157c9;font-size: 24px;text-align:center !important;font-weight: 600;padding-top:10px;">Reset your password by clciking below link</div> <div style="margin:15px;padding:20px !important;"> <hr style="border: 1px solid #2157c9;"/> <table style="width: 100%;"> <tbody style="overflow:auto;font-size: 16px;"> '.$customerContent.' </tbody> </table> <hr style="border: 1px solid #2157c9;"/> <footer> <h3 style="color: #2157c9;font-size: 18px;"><br/>Thanks & Regards<br/> Uflexit Team</h3> </footer> </div> </div> </body> </html>'; //exit; //echo "<br/>"; $sent_mail_customer = mail($to, $subject,$htmlContent,$headers,"-f".$from); //mail to forget password user return true; } /** * function name: activateWarehouseUser * decription:Updating warehouse status from table uflexit_master_wareHouse; * developed by: Ramyakrishna */ function activateWarehouseUser($id){ $query= "update uflexit_master_wareHouse set warehouse_status=1 where warehouse_id ='".$id."'"; $row=$this->db->query($query); if($row) { $data = 0; }else{ $data = 1; } return $data; } /** * function name: activateUser * decription:Updating User status from table uflexit_super_administrator; * developed by: Valli */ function activateUser($id){ $query= "update uflexit_super_administrator set status=1 where admin_id ='".$id."'"; $row=$this->db->query($query); if($row) { $data = 0; }else{ $data = 1; } return $data; } /** * function name: InactivateUser * decription:Updating User status from table uflexit_super_administrator; * developed by: Valli */ function InactivateUser($id){ $query= "update uflexit_super_administrator set status=0 where admin_id ='".$id."'"; $row=$this->db->query($query); if($row) { $data = 0; }else{ $data = 1; } return $data; } /** * function name: GetSingleuser * decription:GetSingle user status from table uflexit_super_administrator; * developed by: Valli */ function getSingleadmin($id){ $query="SELECT * FROM uflexit_super_administrator WHERE admin_id='" .$_GET['id']. "'"; $result = $this->db->get_row($query); if($result) { return $result; }else{ $data = 0; } return $result; } /** * function name: inActivateWarehouseUser * decription:Updating warehouse status from table uflexit_master_wareHouse; * developed by: Ramyakrishna */ function inActivateWarehouseUser($id){ $query= "update uflexit_master_wareHouse set warehouse_status=0 where warehouse_id ='".$id."'"; $row=$this->db->query($query); if($row) { $data = 0; }else{ $data = 1; } return $data; } /** * function name: RejectWarehouseUser * decription:Updating warehouse status from table uflexit_master_wareHouse; * developed by: Ramyakrishna */ function rejectWarehouseUser($id){ $query= "update uflexit_master_wareHouse set warehouse_status=2 where warehouse_id ='".$id."'"; $row=$this->db->query($query); if($row) { $data = 0; }else{ $data = 1; } return $data; } }