Public feed
#891235
<?// code: Takes a string and does a IBM-437-to-HTML-Unicode-Entities-conversion.// swedishmagic specifies special behavior for Swedish characters.// Some Swedish Latin-1 letters collide with popular DOS glyphs. If these// characters are between ASCII-characters (a-zA-Z and more) they are// treated like the Swedish letters, otherwise like the DOS glyphs.function code($ibm_437, $swedishmagic = false) {$table437 = array("\200", "\201", "\202", "\203", "\204", "\205", "\206", "\207","\210", "\211", "\212", "\213", "\214", "\215", "\216", "\217", "\220","\221", "\222", "\223", "\224", "\225", "\226", "\227", "\230", "\231","\232", "\233", "\234", "\235", "\236", "\237", "\240", "\241", "\242","\243", "\244", "\245", "\246", "\247", "\250", "\251", "\252", "\253","\254", "\255", "\256", "\257", "\260", "\261", "\262", "\263", "\264","\265", "\266", "\267", "\270", "\271", "\272", "\273", "\274", "\275","\276", "\277", "\300", "\301", "\302", "\303", "\304", "\305", "\306","\307", "\310", "\311", "\312", "\313", "\314", "\315", "\316", "\317","\320", "\321", "\322", "\323", "\324", "\325", "\326", "\327", "\330","\331", "\332", "\333", "\334", "\335", "\336", "\337", "\340", "\341","\342", "\343", "\344", "\345", "\346", "\347", "\350", "\351", "\352","\353", "\354", "\355", "\356", "\357", "\360", "\361", "\362", "\363","\364", "\365", "\366", "\367", "\370", "\371", "\372", "\373", "\374","\375", "\376", "\377");$tablehtml = array("Ç", "ü", "é", "â", "ä","à", "å", "ç", "ê", "ë", "è","ï", "î", "ì", "Ä", "Å", "É","æ", "Æ", "ô", "ö", "ò", "û","ù", "ÿ", "Ö", "Ü", "¢", "£","¥", "₧", "ƒ", "á", "í", "ó","ú", "ñ", "Ñ", "ª", "º", "¿","⌐", "¬", "½", "¼", "¡", "«","»", "░", "▒", "▓", "│", "┤","╡", "╢", "╖", "╕", "╣", "║","╗", "╝", "╜", "╛", "┐", "└","┴", "┬", "├", "─", "┼", "╞","╟", "╚", "╔", "╩", "╦", "╠","═", "╬", "╧", "╨", "╤", "╥","╙", "╘", "╒", "╓", "╫", "╪","┘", "┌", "█", "▄", "▌", "▐","▀", "α", "ß", "Γ", "π", "Σ","σ", "μ", "τ", "Φ", "Θ", "Ω","δ", "∞", "φ", "ε", "∩", "≡","±", "≥", "≤", "⌠", "⌡", "÷","≈", "°", "∙", "·", "√", "ⁿ","²", "■", " ");$s = htmlspecialchars($ibm_437);// 0-9, 11-12, 14-31, 127 (decimalt)$control =array("\000", "\001", "\002", "\003", "\004", "\005", "\006", "\007","\010", "\011", /*"\012",*/ "\013", "\014", /*"\015",*/ "\016", "\017","\020", "\021", "\022", "\023", "\024", "\025", "\026", "\027","\030", "\031", "\032", "\033", "\034", "\035", "\036", "\037","\177");/* Code control characters to control pictures.http://www.unicode.org/charts/PDF/U2400.pdf(This is somewhat the Right Thing, but looks crappy with Courier New.)$controlpict = array("␣","␄");$s = str_replace($control,$controlpict,$s); */// replace control chars with space - feel free to fix the regexp smile.gif/*echo "[a\\x00-\\x1F]";//$s = ereg_replace("[ \\x00-\\x1F]", " ", $s);$s = ereg_replace("[ \000-\037]", " ", $s); */$s = str_replace($control," ",$s);if ($swedishmagic){$s = str_replace("\345","\206",$s); // Code windows "?" to dos.$s = str_replace("\344","\204",$s); // Code windows "ä" to dos.$s = str_replace("\366","\224",$s); // Code windows "ö" to dos.// $s = str_replace("\304","\216",$s); // Code windows "Ä" to dos.//$s = "[ -~]\\xC4[a-za-z]";// couldn't get ^ and $ to work, even through I read the man-pages,// i'm probably too tired and too unfamiliar with posix regexps right now.$s = ereg_replace("([ -~])\305([ -~])", "\\1\217\\2", $s); // ?$s = ereg_replace("([ -~])\304([ -~])", "\\1\216\\2", $s); // Ä$s = ereg_replace("([ -~])\326([ -~])", "\\1\231\\2", $s); // Ö$s = str_replace("\311", "\220", $s); // É$s = str_replace("\351", "\202", $s); // é}$s = str_replace($table437, $tablehtml, $s);return $s;}require "include/bittorrent.php";dbconn(false);loggedinorreturn();$id = $_GET["id"];//if (get_user_class() < UC_POWER_USER || !is_valid_id($id))//die;$r = mysql_query("SELECT name,nfo FROM torrents WHERE id=$id") or sqlerr();$a = mysql_fetch_assoc($r) or die("Puke");//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);// view might be one of: "magic", "latin-1", "strict" or "fonthack"$view = "";if (isset($_GET["view"])) {$view = unesc($_GET["view"]);}else {$view = "magic"; // default behavior}$nfo = "";if ($view == "latin-1" || $view == "fonthack") {// Do not convert from ibm-437, read bytes as is.// NOTICE: TBSource specifies Latin-1 encoding in include/bittorrent.php:// stdhead()$nfo = htmlentities(($a["nfo"]));}else {// Convert from ibm-437 to html unicode entities.// take special care of Swedish letters if in magic view.$nfo = code($a["nfo"], $view == "magic");}stdhead();print("<h1>NFO for <a href=details.php?id=$id>".htmlentities($a["name"])."</a></h1>\n");?><table border="1" cellspacing="0" cellpadding="10" align="center"><tr><?/*<td align="center" width="25%"><a href="viewnfo.php?id=<?=$id?>&view=fonthack"title="Teckensnittshack: Använder n?gon av teckensnitten MS LineDraw eller Terminal"><b>Teckensnittshack</b></a></td>*/?><td align="center" width="50%"><a href="viewnfo.php?id=<?=$id?>&view=magic"title="Magisk IBM-437: Gör speciella ?tgärder för svenska bokstäver"><b>DOS-vy</b></a></td><td align="center" width="50%"><a href="viewnfo.php?id=<?=$id?>&view=latin-1"title="Latin-1: Inget socker tack!"><b>Windows-vy</b></a></td><?/*<td align="center" width="25%"><a href="viewnfo.php?id=<?=$id?>&view=strict"title="Strikt: Visar nfo-filen som den ser ut i teckentabellen IBM-437"><b>Strikt DOS-vy</b></a></td>*/?></tr><tr><td colspan="3"><table border=1 cellspacing=0 cellpadding=5><tr><td class=text><?php// -- About to output NFO dataif ($view == "fonthack") {// Please notice: MS LineDraw's glyphs are included in the Courier New font// as of Courier New version 2.0, but uses the correct mappings instead.// http://support.microsoft.com/kb/q179422/print("<pre style=\"font-size:10pt; font-family: 'MS LineDraw', 'Terminal', monospace;\">");}else {// IE6.0 need to know which font to use, Mozilla can figure it out in its own// (windows firefox at least)// Anything else than 'Courier New' looks pretty broken.// 'Lucida Console', 'FixedSys'print("<pre style=\"font-size:10pt; font-family: 'Courier New', monospace;\">");}// Writes the (eventually modified) nfo data to output, first formating urls.print(format_urls($nfo));print("</pre>\n");?></td></tr></table></td></tr></table><?//error_reporting(0);stdfoot();?>