summaryrefslogtreecommitdiff
path: root/includes/function.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-03-24 17:06:19 +0000
committerDries Buytaert <dries@buytaert.net>2001-03-24 17:06:19 +0000
commit73f26a53fe6059af74180b1dc7a882ed104c74d1 (patch)
tree51a74e1d64cb2026f21de9f1b4c39b9d57d5ee60 /includes/function.inc
parent68f2112b4d291edef3b8065ee1bf7a5379e72c6f (diff)
downloadbrdo-73f26a53fe6059af74180b1dc7a882ed104c74d1.tar.gz
brdo-73f26a53fe6059af74180b1dc7a882ed104c74d1.tar.bz2
- added check_select to format selection boxes
- improved check_input so that it won\\\'t escape charachters more than once - added [linking] mechanism - more about this later
Diffstat (limited to 'includes/function.inc')
-rw-r--r--includes/function.inc29
1 files changed, 24 insertions, 5 deletions
diff --git a/includes/function.inc b/includes/function.inc
index 076bb6c7c..eefbda602 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -2,14 +2,19 @@
$na = "<I>na</I>";
-function check_export($message) {
- return strip_tags(str_replace("\"", "&quot;", stripslashes($message)));
-}
function check_textfield($message) {
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)));
}
+function check_select($message) {
+ return check_textfield($message);
+}
+
+function check_export($message) {
+ return check_textfield($message);
+}
+
function check_textarea($message) {
global $allowed_html;
return htmlspecialchars(strip_tags(stripslashes($message), $allowed_html));
@@ -17,7 +22,7 @@ function check_textarea($message) {
function check_input($message) {
global $allowed_html, $submission_size;
- return strip_tags(addslashes(substr($message, 0, $submission_size)), $allowed_html);
+ return strip_tags(addslashes(stripslashes(substr($message, 0, $submission_size))), $allowed_html);
}
function check_code($message) {
@@ -26,7 +31,7 @@ function check_code($message) {
function check_output($message, $nl2br = 0) {
global $allowed_html, $na;
- $var = strip_tags(stripslashes($message), $allowed_html);
+ $var = strip_tags(stripslashes(format_text($message)), $allowed_html);
return ($var) ? (($nl2br) ? nl2br($var) : $var) : $na;
}
@@ -91,4 +96,18 @@ function format_url($address, $description = "") {
return ($address) ? "<A HREF=\"$address\">". check_output($description) ."</A>" : $na;
}
+function format_tag($link, $text) {
+ return "'<a href=\"node.php?title='. urlencode('$link') .'\">'. ('$text' ? '$text' : '$link') .'</a>'";
+}
+
+function format_text($text) {
+
+ $src = array("/(<\/?)(\w+)([^>]*>)/e", // convert HTML to lower case
+ "/\[(([^\|]*?)(\|([^\|]*?))?)\]/e"); // [link|description]
+ $dst = array("'\\1'. strtolower('\\2') .'\\3'", // convert HTML to lower case
+ format_tag('\\2', '\\4')); // [link|description]
+
+ return preg_replace($src, $dst, $text);
+}
+
?>