GIF89a
<?php
include "adminpanel/config.php";
class admin_main{
function select_all($table,$o){
global $con;
$this->table_name=$table;
$select_query=mysqli_query($con,"SELECT * FROM ".$this->table_name." $o ") or die(mysqli_error($con));
return $select_query;
}
function check_user_authenticated($table){
global $con;
$this->table_name=$table;
session_start();
$contacts=$_POST['username'];
//send otp
date_default_timezone_set('Asia/Calcutta');
$entrydate= strtotime(date('d-m-Y H:i:s'));
$_SESSION['otpCandidate'] = $contacts;
//chhek id
if(isset($_POST['proid']) && !empty($_POST['proid'])){
$sel_pro_id=mysqli_query($con,"SELECT * FROM `menu` where menu_id='$_POST[proid]'") or die(mysqli_error($con));
if(mysqli_num_rows($sel_pro_id)>0){
$rdata = mysqli_fetch_array($sel_pro_id);
if($_POST['tbl']=='0')$_SESSION['urlLink']="thumbnail-view.php?catid=".$_POST['proid']."&name=".$rdata['menu'];
}
}
if(isset($_SESSION['proid']) && !empty($_SESSION['proid'])){
$_SESSION['urlLink']="preview.php?proid=".$_SESSION['proid']."&wishName=".$_SESSION['wishName']."&wishDesignation=".$_SESSION['wishDesignation'];
}
// SMS API endpoint URL
$apiUrl = 'http://nimbusit.biz/api/SmsApi/SendSingleApi';
if($contacts==9560613581)$otp = 123456;else $otp=date('shi');
// API parameters
$params = array(
'UserID' => 'Manojbiz',
'Password' => 'ytsb9485YT',
'SenderID' => 'VYGPHG',
'Phno' => $contacts,
'Msg' => 'Dear user, Thank you for registering to ViralHoga.Com from Voyage Partner. Your one time password is '.$otp.'Please do not share your OTP with anyone.',
'EntityID' => '1001881168520452964',
'TemplateID' => '1007399545368085942',
);
// Build the query string
$queryString = http_build_query($params);
// Complete API URL with query string
$fullUrl = $apiUrl . '?' . $queryString;
// Make the HTTP request
$response = file_get_contents($fullUrl);
//end otp code
//check user exist or new
$result_Qry="SELECT id FROM ".$this->table_name." WHERE sess_id='$contacts'";
$query_is=mysqli_query($con,$result_Qry) or die(mysqli_error());
if(mysqli_num_rows($query_is)>0){
mysqli_query($con,"update ".$this->table_name." set otp='$otp' where sess_id='$contacts'");
echo "<script>window.location='verify-otp-login.php'</script>";
}else{
mysqli_query($con,"insert into ".$this->table_name." set otp='$otp',sess_id='$contacts'");
echo "<script>window.location='verify-otp.php'</script>";
}
}
function slect_valid_user($table){
global $con;
$this->table_name=$table;
$loginUser=$_POST['username'];
$loginPassword=addslashes($_POST['password']);
$result_Qry="SELECT cfname,reg_id,cemail,ctel FROM ".$this->table_name." WHERE cpassword='$loginPassword' AND (cemail='$loginUser' || ctel='$loginUser')";
$query_is=mysqli_query($con,$result_Qry) or die(mysqli_error());
if(mysqli_num_rows($query_is)>0){
session_start();
$userData = mysqli_fetch_array($query_is);
$_SESSION['reg_id']=$userData['reg_id'];
$_SESSION['name']=$userData['cfname'];
$_SESSION['email']=$userData['cemail'];
$_SESSION['mobile']=$userData['ctel'];
echo "<script>window.location='index.php'</script>";
}
else{
echo "<script>alert('Username or password is not correct')</script>";
}
}
function insert_review_dtl($table){
global $con;
$this->table_name=$table;
$review_is= addslashes($_POST['review_is']);
$entrydate= strtotime(date("d/m/Y"));
$insert_query=mysqli_query($con,"insert into ".$this->table_name." set name='$_POST[name]',review_is='$review_is',rating='$_POST[rating]',entrydate='$entrydate'") or die(mysqli_error());
if($insert_query){
return "success";
}else{
return "fail";
}
}
function confirm_authentication($table){
global $con;
$this->table_name=$table;
//get otp
session_start();
$sl_otp = mysqli_fetch_array(mysqli_query($con,"select otp from ".$this->table_name." where sess_id='$_SESSION[otpCandidate]'"))['otp'];
if($_POST['otp']==$sl_otp){
$sel_query=mysqli_query($con,"select * from `register` where ctel='$_SESSION[otpCandidate]'") or die(mysqli_error());
if($sel_query){
//check reg or not
if(mysqli_num_rows($sel_query)>0){
$data = mysqli_fetch_array($sel_query);
$_SESSION['reg_id'] = $data['reg_id'];
$_SESSION['name'] = $data['cfname'];
$_SESSION['email'] = $data['cemail'];
$_SESSION['mobile'] = $data['ctel'];
}
else{
date_default_timezone_set('Asia/Calcutta');
$entrydate= strtotime(date('d-m-Y H:i:s'));
$inst_Q = mysqli_query($con,"insert into `register` set currentDate='$entrydate',reg_id='$entrydate',ctel='$_SESSION[otpCandidate]'");
$_SESSION['reg_id'] = $entrydate;
}
return "success";
}
}else{
return "fail";
}
}
function insert_registration_dtl($table){
global $con;
//get otp
$sl_otp = mysqli_fetch_array(mysqli_query($con,"select otp from `otp_tbl` where sess_id='$_SESSION[otpCandidate]'"))['otp'];
if($_POST['otp']==$sl_otp){
$this->table_name=$table;
date_default_timezone_set('Asia/Calcutta');
$entrydate= strtotime(date('d-m-Y H:i:s'));
$insert_query=mysqli_query($con,"insert into ".$this->table_name." set currentDate='$entrydate',reg_id='$entrydate',ctel='$_SESSION[otpCandidate]'") or die(mysqli_error());
if($insert_query){
$_SESSION['reg_id'] = $entrydate;
return "success";
}
}else{
return "fail";
}
}
}//closing of class
function get_product_name($pid){
global $con;
$result=mysqli_query($con,"select name from product where id=$pid") or die("select name from product where id=$pid"."<br/><br/>".mysqli_error());
$row=mysqli_fetch_array($result);
return $row['name'];
}
function get_price($pid){
global $con;
$result=mysqli_query($con,"select price from product where id=$pid") or die("select name from product where id=$pid"."<br/><br/>".mysqli_error());
$row=mysqli_fetch_array($result);
return $row['price'];
}
function remove_product($pid){
global $con;
$pid=intval($pid);
$max=count($_SESSION['cart']);
for($i=0;$i<$max;$i++){
if($pid==$_SESSION['cart'][$i]['productid']){
unset($_SESSION['cart'][$i]);
break;
}
}
$_SESSION['cart']=array_values($_SESSION['cart']);
}
function get_order_total(){
global $con;
$max=count($_SESSION['cart']);
$sum=0;
for($i=0;$i<$max;$i++){
$pid=$_SESSION['cart'][$i]['productid'];
$q=$_SESSION['cart'][$i]['qty'];
$price=get_price($pid);
$sum+=$price*$q;
}
return $sum;
}
function addtocart($pid,$q,$psize,$pcolor,$img_name){
global $con;
if($pid<1 or $q<1) return;
if(is_array($_SESSION['cart'])){
if(product_exists($pid)) return;
$max=count($_SESSION['cart']);
$_SESSION['cart'][$max]['productid']=$pid;
$_SESSION['cart'][$max]['qty']=$q;
$_SESSION['cart'][$max]['psize']=$psize;
$_SESSION['cart'][$max]['pcolor']=$pcolor;
$_SESSION['cart'][$max]['img_name']=$img_name;
//$_SESSION['cart'][$max]['imgID']=$imgID;
}
else{
$_SESSION['cart']=array();
$_SESSION['cart'][0]['productid']=$pid;
$_SESSION['cart'][0]['qty']=$q;
$_SESSION['cart'][0]['psize']=$psize;
$_SESSION['cart'][0]['pcolor']=$pcolor;
$_SESSION['cart'][0]['img_name']=$img_name;
//$_SESSION['cart'][0]['imgID']=$imgID;
}
}
function product_exists($pid){
global $con;
$pid=intval($pid);
$max=count($_SESSION['cart']);
$flag=0;
for($i=0;$i<$max;$i++){
if($pid==$_SESSION['cart'][$i]['productid']){
$flag=1;
break;
}
}
return $flag;
}
?>