-
-
Save ellipsisno/8855143 to your computer and use it in GitHub Desktop.
DNS Lookup Poem Generator
This file contains hidden or 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
| <? | |
| $u=uuid(); | |
| //print_r(uuidDecode($u)); | |
| function uuid($serverID=1) | |
| { | |
| $t=explode(" ",microtime()); | |
| return sprintf( '%04x-%08s-%08s-%04s-%04x%04x', | |
| $serverID, | |
| clientIPToHex(), | |
| substr("00000000".dechex($t[1]),-8), // get 8HEX of unixtime | |
| substr("0000".dechex(round($t[0]*65536)),-4), // get 4HEX of microtime | |
| mt_rand(0,0xffff), mt_rand(0,0xffff)); | |
| } | |
| function uuidDecode($uuid) { | |
| $rez=Array(); | |
| $u=explode("-",$uuid); | |
| if(is_array($u)&&count($u)==5) { | |
| $rez=Array( | |
| 'serverID'=>$u[0], | |
| 'ip'=>clientIPFromHex($u[1]), | |
| 'unixtime'=>hexdec($u[2]), | |
| 'micro'=>(hexdec($u[3])/65536) | |
| ); | |
| } | |
| return $rez; | |
| } | |
| function clientIPToHex($ip="") { | |
| $hex=""; | |
| if($ip=="") $ip=getEnv("REMOTE_ADDR"); | |
| $part=explode('.', $ip); | |
| for ($i=0; $i<=count($part)-1; $i++) { | |
| $hex.=substr("0".dechex($part[$i]),-2); | |
| } | |
| return $hex; | |
| } | |
| function clientIPFromHex($hex) { | |
| $ip=""; | |
| if(strlen($hex)==8) { | |
| $ip.=hexdec(substr($hex,0,2))."."; | |
| $ip.=hexdec(substr($hex,2,2))."."; | |
| $ip.=hexdec(substr($hex,4,2))."."; | |
| $ip.=hexdec(substr($hex,6,2)); | |
| } | |
| return $ip; | |
| } | |
| $text = array(); | |
| $enjambment = "<br />"; | |
| $composition = ""; | |
| $hyperauthor = $u; | |
| if (isset($_POST['domain']) && !empty($_POST['domain'])) { | |
| $orthography = '/[a-z\d][a-z\-\d\.]+[a-z\d]/i'; | |
| if (preg_match($orthography, $_POST['domain'])) { | |
| if ($title = parse_url($_POST['domain'])) { | |
| if (isset($title['host'])) { | |
| $text = dns_get_record($title['host'], DNS_ANY); | |
| } else if (isset($title['path'])) { | |
| $text = dns_get_record($title['path'], DNS_ANY); | |
| } | |
| } | |
| } | |
| if (empty($text)) { | |
| $composition = "<br />Nothing!"; | |
| } else { | |
| $newstanza = "<table border='0' width='150' cellpadding='10'><tr><td align='center'>"; | |
| $endstanza = "</td></tr></table>"; | |
| $writingstatus = "0"; | |
| foreach($text as $line) { | |
| $parataxis = count($line); | |
| for ($x = 0; $x <= $parataxis; $x++) { | |
| $musicality[$x] = "0"; | |
| $ambivalence[$x] = rand(0, 1); | |
| $syncopation[$x] = rand(1, 21); | |
| $space[$x] = ""; | |
| do { | |
| $space[$x] .= " "; | |
| $musicality[$x]++; | |
| } while ($musicality[$x] != $syncopation[$x]); | |
| if ($x == "0") { | |
| if ($ambivalence[$x] == "0") { | |
| $composition .= $newstanza . current($line) . $space[$x] . $enjambment; | |
| } | |
| if ($ambivalence[$x] == "1") { | |
| $composition .= $newstanza . $space[$x] . current($line) . $enjambment; | |
| } | |
| } | |
| if ($x != "0") { | |
| if ($x < ($parataxis - 1)) { | |
| if ($ambivalence[$x] == "0") { | |
| $composition .= next($line) . $space[$x] . $enjambment; | |
| } | |
| if ($ambivalence[$x] == "1") { | |
| $composition .= $space[$x] . next($line) . $enjambment; | |
| } | |
| } | |
| if ($x == $parataxis) { | |
| if ($ambivalence[$x] == "0") { | |
| $composition .= end($line) . $space[$x] . $endstanza . $enjambment; | |
| } | |
| if ($ambivalence[$x] == "1") { | |
| $composition .= $space[$x] . end($line) . $endstanza . $enjambment; | |
| } | |
| } | |
| } | |
| } | |
| $writingstatus++; | |
| } | |
| $composition = "<br />\n<table>\n<i>by $hyperauthor</i><br /><br />$composition</table>\n"; | |
| } | |
| } | |
| ?> | |
| <!DOCTYPE HTML> | |
| <html xmlns="http://www.w3.org/1999/html"> | |
| <head> | |
| <meta charset="UTF-8"/> | |
| <title>Free Verse DNS Lookup</title> | |
| <style>/* somethin from bootstrap */ | |
| button,input {margin: 0;font-size: 100%;vertical-align: middle;} | |
| .form-inline {vertical-align: middle;} | |
| table {text-align: center;margin: auto;} | |
| </style> | |
| </head> | |
| <body> | |
| <div style="text-align: center;width: 800px;margin: 1em auto"> | |
| <form method="post"> | |
| <div class="form-inline"> | |
| <input id="domain" type="text" name="domain" value="<?=empty($_POST['domain'])?'':$_POST['domain']?>"> | |
| <button type="submit">Dig</button> | |
| </div> | |
| </form> | |
| <?=$composition?$composition:''?> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment