conv_table[$i] != 0) { $str = str_replace(chr($i), "&#".$this->conv_table[$i].";", $str); } } return $str; } function add_css() { echo '\n"; } function part_one($content) { return preg_replace('#(\|\(.*?)\<\/nfo\>)#ise', '$this->do_nfo(\'\\1\', \'\\3\', \'\\4\', \'\\5\');', $content); } function part_two($content) { if (count($this->blocks)) { $content = str_replace(array_keys($this->blocks), array_values($this->blocks), $content); $this->blocks = array(); } return $content; } function get_content($url) { $url_parsed = parse_url($url); $host = $url_parsed["host"]; if (!isset($url_parsed["port"])) { $port = 80; } else { $port = $url_parsed["port"]; } $path = $url_parsed["path"]; if ($url_parsed["query"] != "") $path .= "?" . $url_parsed["query"]; $out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n"; $fp = fsockopen($host, $port, $errno, $errstr, 30); fwrite($fp, $out); $body = false; $in = ""; while (!feof($fp)) { $s = fgets($fp, 1024); if ($body) $in .= $s; if ($s == "\r\n") $body = true; } fclose($fp); return $in; } function do_nfo($content, $url1, $url2, $txt) { $blockID = $this->getBlockID($content); if ($url1) { $this->blocks[$blockID] = $this->get_content($url1); } else if ($url2) { $this->blocks[$blockID] = $this->get_content($url2); } else { $this->blocks[$blockID] = $txt; } $this->blocks[$blockID] = "
"
            . preg_replace("/(^|\s)(www\.\S+)|(^|\s)((http|ftp|https):\/\/\S+)/is",
                " $2$4",
                $this->nfo2html($this->blocks[$blockID]))
            . "
"; return $blockID; } function getBlockID($content) { static $num = 0; // Just do a check to make sure the user // hasn't (however unlikely) input block replacements // as legit text do { ++$num; $blockID = "

++NFO_BLOCK_$num++

"; } while(strpos($content, $blockID) !== false); return $blockID; } } $nfo = new NFO(); // Showing add_filter('the_content', array(&$nfo, 'part_one'), -100); add_filter('the_content', array(&$nfo, 'part_two'), 500); add_filter('the_excerpt', array(&$nfo, 'part_one'), -100); add_filter('the_excerpt', array(&$nfo, 'part_two'), 500); add_filter('comment_text', array(&$nfo, 'part_one'), -100); add_filter('comment_text', array(&$nfo, 'part_two'), 500); add_action('wp_head', array(&$nfo, 'add_css')); unset($nfo); ?>