Examples: PHP/File

Example #1

<?php
include("file/cwhois.php");
$cwObj = new CFileCWhois();
if (!
$cwObj->connect($data = "cwhois.cwb", $xml = "cwhois.xml")) {
    die(
$cwObj->getLastError());
}
echo
"Hello, you are visiting us from <B>".$cwObj->getNameByAddr($_SERVER["REMOTE_ADDR"])."</B>";
?>

view

Example #2

<form action="" method="POST">
<textarea name="address"></textarea><input type="submit" value="Request">
</form>
<table>
<tr>
<th>Address</th>
<th>Code</th>
<th>Country</th>
</tr>
<?php
if ("POST" == $_SERVER["REQUEST_METHOD"]) {
    
$addr = preg_split("/\s+/s", trim($_POST["address"]));
    if (
count($addr) > 0) {
        include(
"file/cwhois.php");
        
$cwObj = new CFileCWhois();
        if (!
$cwObj->connect($data = "cwhois.cwb", $xml = "cwhois.xml")) {
            die(
$cwObj->getLastError());
        }
        foreach (
$addr as $key=>$val) {
            
$country = $cwObj->getCountryByAddr($val);
            
?>
            <tr>
            <td><?php echo $val?></td>
            <td><?php echo $country[0]?></td>
            <td><?php echo $country[1]?></td>
            </tr>
            <?php
        
}
    }
}
?>
</table>

view