Created
October 27, 2013 04:33
-
-
Save sbstp/7177995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// prende la valeur envoyé par le code javascript | |
$text = $_GET['text']; | |
// simple test pour aller cherche le domaine ou l'ip | |
// en fonction du texte envoyé | |
if (filter_var($text, FILTER_VALIDATE_IP)) { | |
$res = gethostbyaddr($text); | |
} else { | |
$res = gethostbyname($text); | |
} | |
// préparer l'objet json à retourner | |
$json = array('res' => $res); | |
// encoder l'objet en json | |
$data = json_encode($json); | |
// renvoyer les données | |
echo $data; | |
// pas besoin de fermer le script php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment