-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfunctionsCreated.php
114 lines (106 loc) · 3.43 KB
/
functionsCreated.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// Load Configuration File
include 'config.php';
//Function to find muni details
function getmuni($id)
{
global $db;
$m = $db->prepare("SELECT * FROM munishri, upadhis WHERE id = ? AND approved=1 AND uid=upadhi");
$m->execute(array($id));
if($m->rowCount() == 1)
{
$n = $m->fetch(PDO::FETCH_ASSOC);
if($n['alias'] == "") {$t = $n['uname'].' '.$n['prefix'].' '.$n['name'].' '.$n['suffix'];}
else {$t = $n['uname'].' '.$n['prefix'].' '.$n['name'].' '.$n['suffix'].' '.$n['alias'];}
return $t;
}
else
{
return "N/A";
}
}
//Function to get url of muni image
function getImg($id)
{
global $db;
$m = $db->prepare("SELECT img FROM munishri WHERE id = ?");
$m->execute(array($id));
if($m->rowCount() == 1) {
$n = $m->fetch(PDO::FETCH_ASSOC);
$t = $n['img'];
return $t;
} else {
return "na.png";
}
}
//Function to find location address from coordinates
function getaddress($lat,$lng){
$url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false';
$json = @file_get_contents($url);
$data=json_decode($json);
$status = $data->status;
if($status=="OK") {
return $data->results[0]->formatted_address;
} else {
return "N/A";
//alert('Geocoder failed due to: ' + status);
}
}
//Function to find latitude from location address
function getlatitude($address) {
$address= preg_replace('/\s+/', '+', $address);
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=India";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
return $response_a->results[0]->geometry->location->lat;
}
//Function to find longitude from location address
function getlongitude($address) {
$address= preg_replace('/\s+/', '+', $address);
$url = "http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=India";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
curl_close($ch);
$response_a = json_decode($response);
return $response_a->results[0]->geometry->location->lng;
}
//Function to get the guru details
function getguru($id)
{
global $db;
$m = $db->prepare("SELECT * FROM munishri, aryika, kshullak, ailak, muni, upadhyay, ailacharya, acharya WHERE id = ? AND approved=1 AND id=aryikaid AND id=kid AND id=ailakid AND id=muniid AND id=upadhyayid AND id=ailacharyaid AND id=acharyaid");
$m->execute(array($id));
if($m->rowCount() == 1)
{
$n = $m->fetch(PDO::FETCH_ASSOC);
if($n['upadhi'] == 1) $t = $n['aguru'];
if($n['upadhi'] == 2) $t = $n['ailacharyaguru'];
if($n['upadhi'] == 3) $t = $n['upadhyayguru'];
if($n['upadhi'] == 4) $t = $n['muniguru'];
if($n['upadhi'] == 5) $t = $n['ailakguru'];
if($n['upadhi'] == 6) $t = $n['kguru'];
if($n['upadhi'] == 7) $t = $n['aryikaguru'];
return $t;
}
else
{
return "N/A";
}
}
//Mobile detection
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
?>