Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //here we could theoretically validate the DNS name.
- $last="bm.ayra.ch";
- if(isset($_GET["DNS"]))
- {
- $last=$_GET["DNS"];
- }
- ?>
- <html>
- <head>
- <title>Bitmessage resolver</title>
- <style type="text/css">
- body
- {
- font-family:Sans-Serif;
- }
- a
- {
- color:#0000FF;
- font-weight:bold;
- }
- a:hover
- {
- background-color:#FFFF00;
- }
- i
- {
- font-size:8pt;
- margin-top:50px;
- display:block;
- }
- td
- {
- padding-right:10px;
- }
- </style>
- </head>
- <body>
- <h1>Simple PHP Bitmessage address resolver</h1>
- This tool converts DNS records from
- <a href="https://bitmessage.org/forum/index.php/topic,2767.0.html">this proposal</a>
- into links from
- <a href="https://bitmessage.org/forum/index.php/topic,2704.0.html">this proposal</a>.<br />
- <br />
- <form method="get" action="dns.php">
- <input type="text" name="DNS" value="<?php echo $last; ?>" />
- <input type="submit" value="Get Addresses" />
- </form>
- <h2>Result:</h2>
- <table>
- <?php
- //We check, if a TXT Record is present.
- if($txt=dns_get_record($last,DNS_TXT))
- {
- //Multiple records can exist
- foreach($txt as $txtentry)
- {
- //We split an entry up into pieces.
- //This actually does not tests,
- //if the domain name starts with "bm."
- //since it does not matters for parsing anyway.
- $entries=explode(";",$txtentry["txt"]);
- foreach($entries as $value)
- {
- //Very nasty check, if a Bitmessage address is present
- if(strpos($value,'BM-') !== false)
- {
- //Check, if a label is present.
- if(count(explode("=",$value))==1)
- {
- //no label, just print address.
- echo "<tr><td><a href=\"bitmsg:".urlencode($value)."\">".htmlspecialchars($value)."</a></td>";
- echo "<td><a href=\"bitmsg:".urlencode($value)."?action=subscribe\">subscribe</a>";
- echo " <a href=\"bitmsg:".urlencode($value)."?action=unsubscribe\">unsubscribe</a>";
- echo " <a href=\"bitmsg:".urlencode($value)."?action=add\">save</a>";
- echo " <a href=\"bitmsg:".urlencode($value)."?action=remove\">remove</a></td></tr>";
- }
- else
- {
- //label present, print address and label.
- $parts=explode("=",$value);
- echo "<tr><td><a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."\">".htmlspecialchars("$parts[0] ($parts[1])")."</a></td>";
- echo "<td><a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=subscribe\">subscribe</a>";
- echo " <a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=unsubscribe\">unsubscribe</a>";
- echo " <a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=add\">save</a>";
- echo " <a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=remove\">remove</a>";
- //Since a label is present, it could be a DML address.
- echo " <a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=join\">join DML</a>";
- echo " <a href=\"bitmsg:".urlencode($parts[1])."?label=".urlencode($parts[0])."&action=leave\">leave DML</a></td></tr>";
- }
- }
- else
- {
- //Non BM Record. We print it for diagnostic reasons.
- echo "<tr><td colspan=\"2\">non BM TXT Record: ".htmlspecialchars($value)."</td></tr>";
- }
- }
- }
- }
- else
- {
- //No TXT record at all.
- echo "<tr><td><i>no value found.</i></td></tr>";
- }
- ?>
- </table>
- <i>
- Copyright by <a href="https://ayra.ch">AyrA</a>.
- This page is provied as is and serves only as proof of concept.
- If you use it in a productive environment
- you are helplessly lost anyways.
- </i>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement