-
Notifications
You must be signed in to change notification settings - Fork 0
/
func.php
33 lines (27 loc) · 966 Bytes
/
func.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
<?php
class Func {
public function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
public function getBrowserName() {
$arr = explode(";", $_SERVER['HTTP_USER_AGENT'], 2);
return $arr[0] . ')';
}
public function curlPost($url, $param) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
curl_close($ch);
return $server_output;
}
}