Пример #1
0
{
    $parts = explode('.', $input);
    $output = '';
    foreach ($parts as $part) {
        $output .= '0x' . dechex($part) . '.';
    }
    $output .= '<br>anything before real, dots optional';
    return $output;
}
function getDWORDIP($input)
{
    $parts = explode('.', $input);
    $output = $parts[0] * 256;
    $output = ($output + $parts[1]) * 256;
    $output = ($output + $parts[2]) * 256;
    $output = $output + $parts[3];
    return $output;
}
$output = '';
if (true) {
    if (isset($_GET['submit'])) {
        $ip = $_GET['ip'];
        $output .= $ip . "<br>";
        $output .= getOctalIP($ip) . "<br>";
        $output .= getHexIP($ip) . "<br>";
        $output .= getDWORDIP($ip) . "<br>";
    } else {
        $output .= getFormHTML();
    }
}
echo $output;
Пример #2
0
    //Performs query
    if ($res->num_rows < 1) {
        $content = <<<END
\t\t<div id="container">
\t\t\t<p>The {$type} you chose cannot be found. Please try again.</p>
\t\t\t<p><a href="gb.php">Guestbook</a></p>
\t\t</div><!-- container -->
END;
    } else {
        $row = $res->fetch_object();
        //Gets result from DB
        $name = $type == "post" ? $row->postName : $row->commName;
        $msg = $type == "post" ? $row->postMessage : $row->commMessage;
        $name = utf8_decode($name);
        $msg = utf8_decode($msg);
        $content = getFormHTML($type, $postId, $commId, $name, $msg, $feedback);
    }
}
echo $header;
echo $content;
echo $footer;
function getFormHTML($type, $postId, $commId, $name, $msg, $feedback)
{
    $name = htmlspecialchars($name);
    $msg = htmlspecialchars($msg);
    return <<<END
\t\t <div id = "breadcrumbs">
\t\t\t<p><a href="gb.php">Guestbook</a>&gt; Edit</p>
\t\t </div><!-- breadcrumbs -->
\t\t 
\t\t <div id="container">