<?php
/*
Displays a form which lets you enter a list of whitespace-separated keywords
on each line. When the form is submitted, it converts the list into .com domain names
by stripping the whitespace and adding .com to each line.
If a line already ends in .com, another is not added.
.com is not added to the end of blank lines.
*/
if (isset($_POST['keywords'])) // convert
{
// break the text area into lines
$lines = explode("\n", $_POST['keywords']);
for ($i=0; $i<count($lines); $i++)
{
// strip whitespace
$lines[$i] = preg_replace('/\s+/', '', $lines[$i]);
// append .com if not present
if ($lines[$i] && substr_compare($lines[$i],'.com',-4,4,true) !== 0)
$lines[$i] .= '.com';
}
// make the list display safe
$keywords = htmlentities(implode("\n",$lines));
}
else // initialize
{
$keywords = '';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Domain Maker</title>
</head>
<body>
<p>
Enter or paste a list of whitespace-separated keywords below. When you press the
"convert" button, the list will be converted into a list of .com domain names.
</p>
<form action="" method="post">
<textarea cols="64" rows="10" name="keywords"><?php echo $keywords; ?></textarea><br />
<input type="submit" value="convert" />
</form>
</body>
</html>