<?php
		include_once('../config1.php');
		include_once('EmailConfigure.php');
		include_once('custom-functions.php');
		
        $Data = json_encode($_POST);  
        mysql_query("insert into test (name) values('$Data')");  
          
		 
		//https://www.meerindia.com/my-local-app/ws/general.php?check_city_update=1&update_status=1
		//check_city_update=1&update_status=1  
	 
		if(isset($_POST['check_city_update']))
		{
			$result = mysql_query("SELECT city_update from city_update_android ");
			$row = mysql_fetch_row($result);	  
			if($_POST['update_status'])
			{
				mysql_query("update city_update_android  set  city_update=0 ");
				$data['update_status'] = "Done"; 
				$ary['message'] = "Success";
				$ary['status'] = "200";
				$ary['data'] = $data; 
				echo json_encode($ary);   
				die;
			} 
			
			if($row[0]==0)
				$data['updates'] = 0;
			else
				$data['updates'] = 1;
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data; 
			echo json_encode($ary);   
			die;  
		}
		
		//https://www.meerindia.com/my-local-app/ws/general.php?all_cities=1
		//all_cities=1   
		if(isset($_POST['all_cities']))
		{   
			$result= mysql_query("select * from all_cities order by  state_code desc,name   "); 
			$key=0;
			while($row = mysql_fetch_object($result))
			{  
				$all_cities['name'] = $row->name; 
				$all_cities['id'] = $row->id; 
				$all_cities['is_active'] = $row->is_active; 
				$data[$key]  = (object) $all_cities; //IsRefundable  
				$key++;
			}     
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data;   
			echo  json_encode($ary);  
			die;     
		}
		
		//https://www.meerindia.com/my-local-app/ws/general.php?check_job_update=1&update_status=1
		//check_job_update=1&update_status=1
		if(isset($_POST['check_job_update']))
		{
			$result = mysql_query("SELECT job_update from job_update_android ");
			$row = mysql_fetch_row($result);	      
			if($_POST['update_status'])
			{
				mysql_query("update job_update_android  set  job_update=0 ");
				
				$data['update_status'] = "Done"; 
				$ary['message'] = "Success";
				$ary['status'] = "200";
				$ary['data'] = $data; 
				echo json_encode($ary);   
				die;
			}
			
			
			if($row[0]==0)
				$data['updates'] = 0;
			else
				$data['updates'] = 1;
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data; 
			echo json_encode($ary);   
			die;  
		}
		
		//https://www.meerindia.com/my-local-app/ws/general.php?job_categories=1 
		//job_categories=1  
		
		if(isset($_POST['job_categories']))
		{ 
			$result= mysql_query("select * from job_categories order by name ");
			$key=0;
			while($row = mysql_fetch_object($result))
			{  
				$job_categories['name'] = $row->name; 
				$job_categories['id'] = $row->id; 
				$data[$key]  = (object) $job_categories; //IsRefundable  
				$key++;
			}    
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data;   
			echo json_encode($ary);   
			die;    
		} 
		 
		if(isset($_POST['sub_job_categories']))
		{ 
			$result= mysql_query("select * from sub_job_categories where category_id='$_POST[category_id]' order by name "); 
			if(mysql_num_rows($result)>0)
			{  
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['name'] = $row->name; 
					$job_categories['id'] = $row->id; 
					$data[$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}    
				$ary['count'] = 1;
				 
			}else
			{
				$ary['count'] = 0;
			}		  
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data; 
			echo json_encode($ary);   
			die;     
		}   
		
		if(isset($_POST['city_locations']))
		{     
			$result= mysql_query("select id,location_name from city_lacations where  city_id =$_POST[city_id] order by location_name  ");
			if(mysql_num_rows($result)>0)
			{  
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['location_name'] = $row->location_name; 
					$job_categories['id'] = $row->id; 
					$data['locations'][$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}    
				$ary['count'] = 1;
			}else
			{
				$ary['count'] = 0;
			}		
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data; 
			echo json_encode($ary);   
			die;     
			 
		} 
		
		if(isset($_POST['url_test']))
		{ 
			 
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['url'] =  "https://www.meerindia.com/test.php";
			echo json_encode($ary);   
			die; 
		} 
		
		if(isset($_POST['device_details']))
		{ 
			mysql_query("insert into device_details (device_id,token_id,is_active) values('$_POST[device_id]','$_POST[token_id]',1)"); 
			$ary['message'] = "Success";
			$ary['status'] = "200"; 
			echo json_encode($ary);   
			die; 
		} 
		 
		function rand_Pass($upper = 1, $lower=4, $numeric = 3, $other = 2) 
    { 
        $pass_order = Array(); 
        $passWord = ''; 
    
        //Create contents of the password 
        for ($i = 0; $i < $upper; $i++) { 
            $pass_order[] = chr(rand(65, 90)); 
        } 
        for ($i = 0; $i < $lower; $i++) { 
            $pass_order[] = chr(rand(97, 122)); 
        } 
        for ($i = 0; $i < $numeric; $i++) { 
            $pass_order[] = chr(rand(48, 57)); 
        } 
        for ($i = 0; $i < $other; $i++) { 
            $pass_order[] = chr(rand(35, 47)); 
        } 
    
        
        //using shuffle() to shuffle the order
        shuffle($pass_order); 
    
        //Final password string 
        foreach ($pass_order as $char) { 
            $passWord .= $char; 
        } 
        return $passWord; 
    }
		
		 
		
 	 	
		if(isset($_POST['forget_password']))
		{   
			
			$query = mysql_query("SELECT * FROM users WHERE  ( email='$_POST[login_credentials]' || ph='$_POST[login_credentials]') ");  
			if (mysql_num_rows($query) > 0)   
			{
				$query = mysql_query("SELECT email,ph FROM users WHERE  ( email='$_POST[login_credentials]' || ph='$_POST[login_credentials]') ");
				$record = mysql_fetch_object($query);
				
				$data['password_resset'] = 1;   
				$new_password = mt_rand(100000, 999999);//rand_Pass(); 
				$encrypted_pwd = bin2hex(openssl_encrypt($new_password,'AES-128-CBC', $Pwdkey));     
				mysql_query("update  users set password = '$encrypted_pwd' where ( email='$_POST[login_credentials]' || ph='$_POST[login_credentials]') ");  
				 
				$to= $record->email; 
				$subject = "Password has been reset";   
				ResetPassowd($record->email,$subject,$new_password);    
 
				$mobile = $record->ph;
				$val = $new_password;  
				
				$xml_data ='<?xml version="1.0"?>
				<parent>
				<child>
				<user>KalpanaG</user>
				<key>dacc4ff030XX</key>
				<mobile>'.$mobile.'</mobile>
				<message>Dear User, Your Password Has Been Reset. Your New Password is '.$val.'</message>
				<accusage>1</accusage>
				<senderid>LBHARI</senderid>
				</child>
				</parent>'; 
				
				
				$URL = "http://103.233.79.246/submitsms.jsp?";  
				$ch = curl_init($URL);
				curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
				curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
				curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
				curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				$output = curl_exec($ch);
				curl_close($ch);       
				
			}
			else
				$data['password_resset'] = 0;   			
			
			$ary['status'] = "200";
			$ary['message'] = "Success";
			$ary['data'] = $data;
			echo  json_encode($ary);
			die;  
		} 
		
		 
		if(isset($_POST['premium']))
		{   
			if($_POST['type']==1)
			{
				$result= mysql_query("select * from    premium where  type = 1  ");
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['category'] = $row->category; 
					$job_categories['name'] = $row->name; 
					$job_categories['price'] = $row->price; 
					$job_categories['type'] = 1;
					$data[$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}   
				
				$ary['data'] = $data;
				$ary['message'] = "Success";
				$ary['status'] = "200"; 
				echo json_encode($ary);   
				die; 
			}else if($_POST['type']==2)
			{
				$result= mysql_query("select * from    premium where  type = 2  ");
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['category'] = $row->category; 
					$job_categories['name'] = $row->name; 
					$job_categories['price'] = $row->price; 
					$job_categories['candidate'] = $row->candidate; 
					$job_categories['type'] = 2;
					$data[$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}   
				
				$ary['data'] = $data;
				$ary['message'] = "Success";
				$ary['status'] = "200"; 
				echo json_encode($ary);   
				die; 
				
			}			
			else if($_POST['type']==3)
			{
				$result= mysql_query("select * from    premium where  type = 3 ");
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['category'] = $row->category; 
					$job_categories['name'] = $row->name; 
					$job_categories['price'] = $row->price;   
					$job_categories['type'] = 3;
					$data[$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}   
				
				$ary['data'] = $data;
				$ary['message'] = "Success";
				$ary['status'] = "200"; 
				echo json_encode($ary);   
				die; 
				
			}
			
		} 
		
		if(isset($_POST['job_aaply_adv']))
		{ 
			 
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['adv_img'] = "https://www.meerindia.com/my-local-app/ws/seekers.jpg"; 
			echo json_encode($ary);   
			die; 
		} 
		
		
		if(isset($_POST['home_page_images']))
		{ 
			 
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['adv_img1'] = "https://www.laaibhari.com/uploads/banner-images/alert.jpg";
			$ary['adv_img2'] = "https://www.laaibhari.com/uploads/banner-images/small-icons.jpg"; 
			
			$ary['adv_img3'] = "https://www.laaibhari.com/uploads/banner-images/test-new-img-1.jpg"; 
			$ary['adv_img4'] = "https://www.laaibhari.com/uploads/banner-images/test-new-img-2.jpg"; 
			$ary['adv_img5'] = "https://www.laaibhari.com/uploads/banner-images/test-new-img-3.jpg"; 
			$ary['version'] = 5;  
			$ary['city_version'] = 1;  
			$ary['Defaultcity'] = 5;  
			$ary['DefaultcityName'] = 'Nashik'; 
			echo json_encode($ary);   
			die; 
		} 
		 
		
		/*
		if(isset($_POST['all_services']))
		{   	  
			$ct =0;
			$result = mysql_query("select * from service_name ");
			while($row = mysql_fetch_object($result))
			{
				$HotelRoomDetails["service_name"] = $row->name; 
				$result1 = mysql_query("select * from service_categories where service_name_id=$row->id ");
				$key=0;
				while($row1 = mysql_fetch_object($result1))
				{ 
					$HotelRoomDetails["service_categories"][$key]['name']  =  $row1->name;
					$HotelRoomDetails["service_categories"][$key]['service_categories_id']  =  $row1->id;       
					$result2 = mysql_query("select * from sub_service_categories where category_id=$row1->id ");
					$passenger = null;
					$m=0;
					while($row2 = mysql_fetch_object($result2))
					{
						$passenger[$m]['id'] = $row2->id;
						$passenger[$m]['name'] =  	$row2->name;   
						$m++;
					}   
					$HotelRoomDetails["service_categories"][$key]["sub_service_categories"]   =  $passenger; 
					$key++;
				}      
				$data["service_datails"][$ct]  = (object)$HotelRoomDetails;       
				$ct++;
			}  
			$data['message'] = "Success";
			$data['status'] = "200"; 
			echo json_encode($data);   
			die;
		} 
		*/
		 
		
		if(isset($_POST['getSalary']))
		{
		   	$key=0;
		   	$salary['name'] = '5000 & above'; 
	   		$salary['value'] = '5000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '6000 & above'; 
			$salary['value'] = '6000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '7000 & above'; 
			$salary['value'] = '7000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '8000 & above'; 
			$salary['value'] = '8000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
				
			$salary['name'] = '9000 & above'; 
			$salary['value'] = '9000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '10000 & above'; 
			$salary['value'] = '10000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			
			$salary['name'] = '12000 & above'; 
			$salary['value'] = '12000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '15000 & above'; 
			$salary['value'] = '15000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '18000 & above'; 
			$salary['value'] = '18000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '25000 & above'; 
			$salary['value'] = '25000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
				
		
			$salary['name'] = '30000 & above'; 
			$salary['value'] = '30000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '40000 & above'; 
			$salary['value'] = '40000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '50000 & above'; 
			$salary['value'] = '50000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '70000 & above'; 
			$salary['value'] = '70000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++;
			
			$salary['name'] = '100000 & above'; 
			$salary['value'] = '100000'; 
			$data[$key]  = (object) $salary; //IsRefundable  
			$key++; 
		   	
		   	$ary['message'] = "Success";
			$ary['status'] = "200"; 
			$ary['maxSal'] = $data1;   
			echo json_encode($ary);   
			die;    
		}
		
		if(isset($_POST['all_services']))
		{ 
			$result= mysql_query("select * from service_categories ");
			$key=0;
			while($row = mysql_fetch_object($result))
			{  
				$job_categories['name'] = $row->name; 
				$job_categories['id'] = $row->id; 
				$data[$key]  = (object) $job_categories; //IsRefundable  
				$key++;
			}    
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data;   
			echo json_encode($ary);   
			die;    
		} 
		
		if(isset($_POST['sub_service_categories']))
		{ 
			$result= mysql_query("select * from sub_service_categories where category_id='$_POST[category_id]' "); 
			if(mysql_num_rows($result)>0)
			{  
				$key=0;
				while($row = mysql_fetch_object($result))
				{ 
					$job_categories['name'] = $row->name; 
					$job_categories['id'] = $row->id; 
					$data[$key]  = (object) $job_categories; //IsRefundable  
					$key++;
				}    
				$ary['count'] = 1;
				 
			}else
			{
				$ary['count'] = 0;
			}		  
			
			$ary['message'] = "Success";
			$ary['status'] = "200";
			$ary['data'] = $data; 
			echo json_encode($ary);   
			die;     
		}   
		 
		
		if(isset($_POST['candidate_info']))
		{    
			$result = mysql_query("select *  from paid_members where cust_id = '$_POST[cust_id]'  and post_id = 3 "); 
			if (mysql_num_rows($result) > 0)   
			{ 	
				$row = mysql_fetch_object($result); 
				$current_date =  date("Y-m-d");    
				$seconds = strtotime($current_date) - strtotime($row->membership_date); 
				$days    = floor($seconds / 86400);
				
				if($row->no_of_users < 1) 
					$data['result']	 = 3; // You Have Seen Your All Candidate Contacts Kindly Upgrade Your Plan. 
				else if($days > $row->days) 
					$data['result']	 = 2; // Validity Expired..
				else
				{
					$result = mysql_query("select  t1.name,t1.org,t1.address,t1.email,t1.ph,t1.blood_group,t2.salary,t2.idproof,t2.designation,t2.workedfor,t2.special,t2.yearsofworking,t2.job_comfort,t2.language,t2.education,t2.passport,t2.upload_resume  from users as t1 left join user_profile as t2 on t1.cust_id = t2.cust_id where t1.cust_id = '$_POST[user_cust_id]'   "); 	 
					$key = 0;
					$rw = mysql_fetch_object($result);
					   
					if($rw->upload_resume!='')
						 $data['upload_resume'] =  ROOTPATH.'/uploads/users/'.$cust_id.'/resume/'.$rw->upload_resume;  	   
					else 
						$data['upload_resume'] = 'Not Available'; 	
					 
					$alert_details['name'] = $rw->name; 
					$alert_details['org'] = $rw->org; 
					$alert_details['email'] = $rw->email; 
					$alert_details['ph'] = $rw->ph; 
					$alert_details['blood_group'] = $rw->blood_group; 
					$alert_details['address'] = $rw->address;
					$alert_details['salary'] = $rw->salary;
					$alert_details['idproof'] = $rw->idproof;
					$alert_details['designation'] = $rw->designation;   
					$alert_details['workedfor'] = $rw->workedfor;   
					$alert_details['special'] = $rw->special;   
					$alert_details['yearsofworking'] = $rw->yearsofworking;   
					$alert_details['video_resume'] = 'https://www.laaibhari.com';   
					
					$job_comfort='';
					$job_comfort_ary=explode(",",$rw->job_comfort);
					if($job_comfort_ary[0]==1) 
						$job_comfort ="Full Time";
					else if($job_comfort_ary[0]==2) 
						$job_comfort ="Part Time";
					
					if($job_comfort_ary[1]==1) 
						$job_comfort .=", Full Time";
					else if($job_comfort_ary[1]==2) 
						$job_comfort .=", Part Time"; 
					
					
					$alert_details['job_comfort'] = $job_comfort;   
					$alert_details['language'] = $rw->language;   
					$alert_details['education'] = $rw->education;   
					if($rw->passport==1)
						$passport = 'Yes';
					else
						$passport = 'No'; 
					$alert_details['passport'] = $passport;     
					$data['info']	 = $alert_details;   
					$data['contact']	 =  $rw->ph; 
					$data['email']	 = $rw->email; 
					$data['result']	 = 1;      
					 
					if (!preg_match('/'.$_POST['user_cust_id'].'/',$row->cust_id_view))
					{  
					 
						$cust_id_view = $row->cust_id_view.",".$_POST['user_cust_id']; 
						$cust_id_view = trim($cust_id_view,",");  
						mysql_query("update paid_members  set cust_id_view = '$cust_id_view' , no_of_users = no_of_users - 1  where cust_id = '$_POST[cust_id]'  and post_id = 3 "); 
					}   
				}   
			}   	 
			else
				$data['result']	 = 0; // Validity Expired..	

			$data['message'] = "Success";
			$data['status'] = "200"; 
			echo json_encode($data);   
			die;	
		}    
?>

