ajgkqsldxvkqsldkqs azelfkqsmkqsmlkdqsmld azmlekdqmskdmlqskd nkldsfkqsmldkqsmdmlskd decrypt($_GET['id']); $service_token = $mcrypt->decrypt($_GET['sid']); $lat = $mcrypt->decrypt($_GET['lat']); $long = $mcrypt->decrypt($_GET['long']); /* Fetch the information */ $con = db_connect(); $sql = session($con,$session); $total = 0; $message = ""; if(db_rows($con,$sql)>0){ /* fetch userid and create session token */ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $userid = $row['userid']; } /* Get service details */ $sql = "select * from business_subcategories where token='".escape($con,$service_token)."'"; if(db_rows($con,$sql)>0){ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $category = $row['category']; $code = $row['code']; } /* Get all businesses who does this service */ /* $sql = "select * from companies where id in(select company from company_services where category='".escape($con,$category)."' and service='".escape($con,$code)."')"; */ $sql = "SELECT name,about,picture,region,town,phone,direction,ghana_post,website,alt_phone,landmark,latitude,longitude,token,ac_type,id,SQRT( POW(69.1 * (latitude - ".$lat."), 2) + POW(69.1 * (".$long." - longitude) * COS(latitude / 57.3), 2)) AS distance FROM users HAVING distance < ".nearby_boundary()." and ac_type=1 and id in(select company from company_services where category='".escape($con,$category)."' and service='".escape($con,$code)."') ORDER BY distance;"; $total = db_rows($con,$sql); if($total>0){ /* Fetch the list of companies */ $query = mysqli_query($con,$sql); while($row=mysqli_fetch_array($query)){ $id = $row['id']; $name = $row['name']; $about = $row['about']; $logo = $row['picture']; /* if logo is empty, use default logo */ if(empty($logo)){ $logo = "no_image.png"; } $logo = logo_url($logo); $region = region_name($con,$row['region']); $town = town_name($con,$row['town']); $phone = $row['phone']; $direction = $row['direction']; $ghana_post = $row['ghana_post']; $website = $row['website']; if(empty($website)){ $website = " "; } $alt_phone = $row['alt_phone']; if(empty($alt_phone)){ $alt_phone = " "; } $landmark = $row['landmark']; $latitude = $row['latitude']; $longitude = $row['longitude']; $token = $row['token']; $opening_hrs = company_opening_hours($con,$id); if(empty($opening_hrs)){ $opening_hrs = " "; } array_push($companies,array('name'=>$mcrypt->encrypt($name), 'about'=>$mcrypt->encrypt($about), 'logo'=>$mcrypt->encrypt($logo), 'region'=>$mcrypt->encrypt($region), 'town'=>$mcrypt->encrypt($town), 'phone'=>$mcrypt->encrypt($phone), 'website'=>$mcrypt->encrypt($website), 'alt_phone'=>$mcrypt->encrypt($alt_phone), 'landmark'=>$mcrypt->encrypt($landmark), 'direction'=>$mcrypt->encrypt($direction), 'ghana_post'=>$mcrypt->encrypt($ghana_post), 'opening_hrs'=>$mcrypt->encrypt($opening_hrs), 'latitude'=>$mcrypt->encrypt($latitude), 'longitude'=>$mcrypt->encrypt($longitude), 'cid'=>$mcrypt->encrypt($id), 'id'=>$mcrypt->encrypt($token) ) ); } }else{ $message = "No company around at the moment"; } }else{ $message = "Service doesn't exist"; } }else{ $message = "You don't have right to access this page"; } echo json_encode(array("total"=>$total,"companies"=>$companies,"message"=>$mcrypt->encrypt($message))); db_close($con); }