XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
example.php
Go to the documentation of this file.
1 <?php
2 $encoded = $decoded = $add = '';
3 header('Content-Type: text/html; charset=utf-8');
4 require_once('idna_convert.class.php');
5 
6 $idn_version = isset($_REQUEST['idn_version']) && $_REQUEST['idn_version'] == 2003 ? 2003 : 2008;
7 $IDN = new idna_convert(array('idn_version' => $idn_version));
8 
9 $version_select = '<select size="1" name="idn_version"><option value="2003">IDNA 2003</option><option value="2008"';
10 if ($idn_version == 2008) {
11  $version_select .= ' selected="selected"';
12 }
13 $version_select .= '>IDNA 2008</option></select>';
14 
15 if (isset($_REQUEST['encode'])) {
16  $decoded = isset($_REQUEST['decoded']) ? stripslashes($_REQUEST['decoded']) : '';
17  $encoded = $IDN->encode($decoded);
18 }
19 if (isset($_REQUEST['decode'])) {
20  $encoded = isset($_REQUEST['encoded']) ? stripslashes($_REQUEST['encoded']) : '';
21  $decoded = $IDN->decode($encoded);
22 }
23 $lang = 'en';
24 if (isset($_REQUEST['lang'])) {
25  if ('de' == $_REQUEST['lang'] || 'en' == $_REQUEST['lang']) {
26  $lang = $_REQUEST['lang'];
27  $add .= '<input type="hidden" name="lang" value="'.$lang.'" />'."\n";
28  }
29 }
30 ?>
31 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32 <html xmlns="http://www.w3.org/1999/xhtml">
33 <head>
34 <title>phlyLabs Punycode Converter</title>
35 <meta name="author" content="phlyLabs" />
36 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
37 <style type="text/css">
38 /*<![CDATA[*/
39 body { color:black;background:white;font-size:10pt;font-family:Verdana,Helvetica,Sans-Serif; }
40 body, form { margin:0; }
41 form { display:inline; }
42 input { font-size:8pt;font-family:Verdana,Helvetica,Sans-Serif; }
43 #round { width:730px;padding:10px;background-color:rgb(230,230,240);border:1px solid black;text-align:center;vertical-align:middle;margin:auto;margin-top:50px; }
44 th { font-size:9pt;font-weight:bold; }
45 #copy { font-size:8pt;color:rgb(60,60,80); }
46 #subhead { font-size:8pt; }
47 #bla { font-size:8pt;text-align:left; }
48 h5 {margin:0;font-size:11pt;font-weight:bold;}
49 /*]]>*/
50 </style>
51 </head>
52 <body>
53 <div id="round">
54  <h5>phlyLabs' pure PHP IDNA Converter</h5><br />
55  <span id="subhead">
56  See the RFCs <a href="http://faqs.org/rfcs/rfc3490.html" title="IDNA" target="_blank">3490</a>,
57  <a href="http://faqs.org/rfcs/rfc3491.html" title="Nameprep, a Stringprep profile" target="_blank">3491</a>,
58  <a href="http://faqs.org/rfcs/rfc3492.html" title="Punycode" target="_blank">3492</a> and
59  <a href="http://faqs.org/rfcs/rfc3454.html" title="Stringprep" target="_blank">3454</a> as well as
60  <a href="http://faqs.org/rfcs/rfc5890.html" target="_blank">5890</a>,
61  <a href="http://faqs.org/rfcs/rfc5891.html" target="_blank">5891</a>,
62  <a href="http://faqs.org/rfcs/rfc5892.html" target="_blank">5892</a>,
63  <a href="http://faqs.org/rfcs/rfc5893.html" target="_blank">5893</a> and
64  <a href="http://faqs.org/rfcs/rfc5894.html" target="_blank">RFC5894</a>.<br />
65  </span>
66  <br />
67  <div id="bla"><?php if ($lang == 'de') { ?>
68  Dieser Konverter erlaubt die Übersetzung von Domainnamen zwischen der Punycode- und der
69  Unicode-Schreibweise.<br />
70  Geben Sie einfach den Domainnamen im entsprechend bezeichneten Feld ein und klicken Sie dann auf den darunter
71  liegenden Button. Sie können einfache Domainnamen, komplette URLs (wie http://jürgen-müller.de)
72  oder Emailadressen eingeben.<br />
73  <br />
74  Stellen Sie aber sicher, dass Ihr Browser den Zeichensatz <strong>UTF-8</strong> unterstützt.<br />
75  <br />
76  Wenn Sie Interesse an der zugrundeliegenden PHP-Klasse haben, können Sie diese
77  <a href="http://phlymail.com/de/downloads/idna-convert.html">hier herunterladen</a>.<br />
78  <br />
79  Diese Klasse wird ohne Garantie ihrer Funktionstüchtigkeit bereit gestellt. Nutzung auf eigene Gefahr.<br />
80  Um sicher zu stellen, dass eine Zeichenkette korrekt umgewandelt wurde, sollten Sie diese immer zurückwandeln
81  und das Ergebnis mit Ihrer ursprünglichen Eingabe vergleichen.<br />
82  <br />
83  Fehler und Probleme können Sie gern an <a href="mailto:team@phlymail.de">team@phlymail.de</a> senden.<br />
84  <?php } else { ?>
85  This converter allows you to transfer domain names between the encoded (Punycode) notation
86  and the decoded (UTF-8) notation.<br />
87  Just enter the domain name in the respective field and click on the button right below it to have
88  it converted. Please note, that you might even enter complete domain names (like j&#xFC;rgen-m&#xFC;ller.de)
89  or a email addresses.<br />
90  <br />
91  Make sure, that your browser is capable of the <strong>UTF-8</strong> character encoding.<br />
92  <br />
93  For those of you interested in the PHP source of the underlying class, you might
94  <a href="http://phlymail.com/en/downloads/idna-convert.html">download it here</a>.<br />
95  <br />
96  Please be aware, that this class is provided as is and without any liability. Use at your own risk.<br />
97  To ensure, that a certain string has been converted correctly, you should convert it both ways and compare the
98  results.<br />
99  <br />
100  Please feel free to report bugs and problems to: <a href="mailto:team@phlymail.com">team@phlymail.com</a>.<br />
101  <?php } ?>
102  <br />
103  </div>
104  <table border="0" cellpadding="2" cellspacing="2" align="center">
105  <thead>
106  <tr>
107  <th align="left">Original (Unicode)</th>
108  <th align="right">Punycode (ACE)</th>
109  </tr>
110  </thead>
111  <tbody>
112  <tr>
113  <td align="right">
114  <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'); ?>" method="get">
115  <input type="text" name="decoded" value="<?php echo htmlspecialchars($decoded, ENT_QUOTES, 'UTF-8'); ?>" size="48" maxlength="255" /><br />
116  <?php echo $version_select; ?>
117  <input type="submit" name="encode" value="Encode &gt;&gt;" /><?php echo $add; ?>
118  </form>
119  </td>
120  <td align="left">
121  <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'); ?>" method="get">
122  <input type="text" name="encoded" value="<?php echo htmlspecialchars($encoded, ENT_QUOTES, 'UTF-8'); ?>" size="48" maxlength="255" /><br />
123  <input type="submit" name="decode" value="&lt;&lt; Decode" /><?php echo $add; ?>
124  </form>
125  </td>
126  </tr>
127  </tbody>
128  </table>
129  <br />
130  <span id="copy">Version used: 0.9.0; &copy; 2004-2014 phlyLabs Berlin; part of <a href="http://phlymail.com/">phlyMail</a></span>
131 </div>
132 </body>
133 </html>
$IDN
Definition: example.php:7
$args title
Definition: ko.install.php:189
$encoded
Definition: example.php:2
$version_select
Definition: example.php:9
widget to display content
$idn_version
Definition: example.php:6
if(isset($_REQUEST['encode'])) if(isset($_REQUEST['decode'])) $lang
Definition: example.php:23