function html_format($instr) { global $colors; /** * If the incoming string already has some HTML in it then maybe we * should try and preserve that s***e */ $is_html = preg_match('/<(p|br|table)(\\s[^>]+)?>/', $instr); $has_links = preg_match('/<(a)(\\s[^>]+)?>/', $instr); $has_lists = preg_match('/<(ul|li)(\\s[^>]+)?>/', $instr); if (!$has_lists) { // Lines beginning with something bullet-like get made into bullet points $instr = preg_replace("/\n *([o+-]) +/", "<br> \$1 ", $instr); } // Lines beginning like e-mail comment lines $instr = preg_replace("/\n( *[|>][^\n]*)/", "<br><span style=\"background: " . $colors["row1"] . ";\">\$1</span>", $instr); // A word like _word_ displays as bold $instr = preg_replace("/ _([^ ]+)_ /", " <b>\$1</b> ", $instr); if (!$has_links) { // A URL surrounded like [http://my.url] gets converted to a link $instr = preg_replace_callback("#\\[(https?://[^]]+)\\]#", "html_format_url", $instr); // A URL like " http://my.url " also gets converted to a link $instr = preg_replace_callback("#(https?://[^[:space:]]+)#", "html_format_url", $instr); // A URL like " mailto:user@domain.name " also gets converted to a link $instr = preg_replace_callback("/(mailto:[^[:space:]]+@[^[:space:]]+)/", "html_format_url", $instr); // A phrase like " W/R #99999 " (and variants) gets converted to a link $instr = preg_replace("/(W\\/?RM?S? ?#?([[:digit:]]{4,6}))([^[:digit:]]|\$)/i", " <a href=\"" . $GLOBALS['base_dns'] . "/wr.php?request_id=\$2\">\$1</a>\$3", $instr); } if (!$is_html) { // Two consecutive newlines is a new paragraph $instr = str_replace("\n\n", "</p><p>", $instr); // A single newline is a line break $instr = str_replace("\n", "<br>", $instr); // So we can read the HTML when we view source $instr = str_replace("<p>", "\n<p>", $instr); $instr = str_replace("<br>", "<br />\n", $instr); } // Fancy stuff links to nodes in the help $instr = link_writeups($instr, "WU"); return $instr; }
$btn = "<label>%s<input type=radio name=\"vote[{$wu->wu_by}]\" value=\"%s\">%s</label> "; echo "<td align=center>"; if ($can_cool) { printf($btn, "Cool", "C", ""); } if ($can_vote) { printf($btn, "+", "+", ""); printf($btn, "", "-", "-"); } if ($can_can) { printf($btn, "", "K", "Kill"); } echo "</td>\n"; } echo "<td align=right>" . link_writeups("by [{$wu->username}]") . " on {$wu->nice_date}</td></tr></table>\n"; echo link_writeups("{$wu->content}\n"); echo "<hr>\n"; if ($session->user_no == $wu->wu_by) { $my_wu = htmlspecialchars($wu->content); } } if ($can_vote) { echo "<input type=submit value=\"Vote\" name=submit>\n</form>"; } if ($can_edit) { echo "<p><br> <br> <br>"; } } else { $words = split("[^a-zA-Z0-9]+", strtolower($nodename), 4); $query = ""; while (list($k, $v) = each($words)) {
} } else { // Many results so display a table of contents if (isset($show_all)) { echo "<h1>Detailed Help</h1>\n"; } else { echo "<h1>Select Your Help Topic</h1>\n"; } echo "<ol type=\"1\">"; for ($i = 0; $i < $rows; $i++) { $help = pg_Fetch_Object($rid, $i); if (isset($seq) && $help->seq == $seq || isset($show_all)) { echo link_writeups("<li><b><big>{$help->title}</big></b></li>\n"); echo link_writeups("{$help->content}\n"); if (is_member_of('Admin', 'Support')) { echo "<p align=right><a href=\"/help.php?action=edit&h=" . htmlspecialchars($help->topic) . "&seq={$help->seq}\">edit this help text</a></p>\n"; } } else { echo link_writeups("<li><a href=\"/help.php?h=" . htmlspecialchars($help->topic) . "&seq={$help->seq}\">{$help->title}</a></li>\n"); } } echo "</ol>"; if (is_member_of('Admin', 'Support')) { echo "<p align=right><a href=\"/help.php?action=add&h=" . htmlspecialchars($topic) . "\">add new help text</a>\n"; } if (!isset($show_all)) { echo "<p align=right><a href=\"{$REQUEST_URI}&show_all=1\">show all</a>\n"; } } } }