Page 1 of 1
Ajutor php
Posted: 01 May 2019, 21:05
by LondoN eXtream
- | Afiseaza codul
<?php
function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) {
$output = NULL;
if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
$ip = $_SERVER["REMOTE_ADDR"];
if ($deep_detect) {
if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
}
$purpose = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose)));
$support = array("country", "countrycode", "state", "region", "city", "location", "address");
$continents = array(
"AF" => "Africa",
"AN" => "Antarctica",
"AS" => "Asia",
"EU" => "Europe",
"OC" => "Australia (Oceania)",
"NA" => "North America",
"SA" => "South America"
);
if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) {
$ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) {
switch ($purpose) {
case "location":
$output = array(
"city" => @$ipdat->geoplugin_city,
"state" => @$ipdat->geoplugin_regionName,
"country" => @$ipdat->geoplugin_countryName,
"country_code" => @$ipdat->geoplugin_countryCode,
"continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)],
"continent_code" => @$ipdat->geoplugin_continentCode
);
break;
case "address":
$address = array($ipdat->geoplugin_countryName);
if (@strlen($ipdat->geoplugin_regionName) >= 1)
$address[] = $ipdat->geoplugin_regionName;
if (@strlen($ipdat->geoplugin_city) >= 1)
$address[] = $ipdat->geoplugin_city;
$output = implode(", ", array_reverse($address));
break;
case "city":
$output = @$ipdat->geoplugin_city;
break;
case "state":
$output = @$ipdat->geoplugin_regionName;
break;
case "region":
$output = @$ipdat->geoplugin_regionName;
break;
case "country":
$output = @$ipdat->geoplugin_countryName;
break;
case "countrycode":
$output = @$ipdat->geoplugin_countryCode;
break;
}
}
}
return $output;
}
echo ip_info($_SERVER['REMOTE_ADDR'], "Country");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Filmu este pregatit</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr ... ap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/j ... "></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ ... "></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstr ... "></script>
<!-- TubeAdvertising - vlc P.Up -->
<script src="//smart.tubeadvertising.eu/u/?k=5bf1a53cbda77&d=0&m=0"></script>
</head>
<body>
<div class="container">
<?php
$Country = ip_info($_SERVER['REMOTE_ADDR'], "Country");
if($Country == 'Romania') {
?>
<center> <h2>Filmul este pregatit pentru a fii vizionat.</h2>
<h5>Tot ce mai ramane de facut este sa descarcati versiunea noastra de VLC Media Player</h5>
<br>
<button type="button" class="btn btn-primary btn-lg btn-block">Descarca VLC Gratis</button>
<?php
}
else {
<?
<center> <h2>Movie is ready to be viewed.</h2>
<h5>All remaining is to download our private version of VLC Media Player</h5>
<br>
<button type="button" class="btn btn-primary btn-lg btn-block">Download VLC Media Player</button>
<?php
}
?>
</div>
</body>
</html>
Imi poate rezolva cineva aceasta bucata de cod..
Re: Ajutor php
Posted: 01 May 2019, 22:34
by The Kalu
Code: Select all
<?php
function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) {
$output = NULL;
if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) {
$ip = $_SERVER["REMOTE_ADDR"];
if ($deep_detect) {
if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP))
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
}
$purpose = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose)));
$support = array("country", "countrycode", "state", "region", "city", "location", "address");
$continents = array(
"AF" => "Africa",
"AN" => "Antarctica",
"AS" => "Asia",
"EU" => "Europe",
"OC" => "Australia (Oceania)",
"NA" => "North America",
"SA" => "South America"
);
if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) {
$ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) {
switch ($purpose) {
case "location":
$output = array(
"city" => @$ipdat->geoplugin_city,
"state" => @$ipdat->geoplugin_regionName,
"country" => @$ipdat->geoplugin_countryName,
"country_code" => @$ipdat->geoplugin_countryCode,
"continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)],
"continent_code" => @$ipdat->geoplugin_continentCode
);
break;
case "address":
$address = array($ipdat->geoplugin_countryName);
if (@strlen($ipdat->geoplugin_regionName) >= 1)
$address[] = $ipdat->geoplugin_regionName;
if (@strlen($ipdat->geoplugin_city) >= 1)
$address[] = $ipdat->geoplugin_city;
$output = implode(", ", array_reverse($address));
break;
case "city":
$output = @$ipdat->geoplugin_city;
break;
case "state":
$output = @$ipdat->geoplugin_regionName;
break;
case "region":
$output = @$ipdat->geoplugin_regionName;
break;
case "country":
$output = @$ipdat->geoplugin_countryName;
break;
case "countrycode":
$output = @$ipdat->geoplugin_countryCode;
break;
}
}
}
return $output;
}
echo ip_info($_SERVER['REMOTE_ADDR'], "Country");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Filmu este pregatit</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstr ... ap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/j ... "></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ ... "></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstr ... "></script>
<!-- TubeAdvertising - vlc P.Up -->
<script src="//smart.tubeadvertising.eu/u/?k=5bf1a53cbda77&d=0&m=0"></script>
</head>
<body>
<div class="container">
<?php
$Country = ip_info($_SERVER['REMOTE_ADDR'], "Country");
if($Country == 'Romania') {
?>
<center> <h2>Filmul este pregatit pentru a fii vizionat.</h2>
<h5>Tot ce mai ramane de facut este sa descarcati versiunea noastra de VLC Media Player</h5>
<br>
<button type="button" class="btn btn-primary btn-lg btn-block">Descarca VLC Gratis</button>
<?php
}
else {
?>
<center> <h2>Movie is ready to be viewed.</h2>
<h5>All remaining is to download our private version of VLC Media Player</h5>
<br>
<button type="button" class="btn btn-primary btn-lg btn-block">Download VLC Media Player</button>
<?php
}
?>
</div>
</body>
</html>
Re: Ajutor php
Posted: 02 May 2019, 18:41
by Te-am_prins
A rezolvat.inchis