aboutsummaryrefslogtreecommitdiffstats
path: root/functions/init
diff options
context:
space:
mode:
authorJason Oster <parasytic@users.sourceforge.net>2009-05-20 17:10:09 +0000
committerJason Oster <parasytic@users.sourceforge.net>2009-05-20 17:10:09 +0000
commit78b585135fc16c268a9de69a1156231873995a49 (patch)
tree44083f219143e7c452db9096a15b785959148443 /functions/init
parentf5cfc55764e413a120f414e31ed608249303c27b (diff)
downloadphpicalendar-78b585135fc16c268a9de69a1156231873995a49.tar.gz
phpicalendar-78b585135fc16c268a9de69a1156231873995a49.tar.bz2
phpicalendar-78b585135fc16c268a9de69a1156231873995a49.zip
Force makeTitle() to limit the amount of text put into a title
Diffstat (limited to 'functions/init')
-rw-r--r--functions/init/sanitize.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/functions/init/sanitize.php b/functions/init/sanitize.php
index 5e9d57e..0370f9f 100644
--- a/functions/init/sanitize.php
+++ b/functions/init/sanitize.php
@@ -33,6 +33,23 @@ function recursiveSanitize($value) {
}
+/**
+ * Truncate a string to a specific number of words
+ */
+function chopToWordCount($string, $count) {
+ $wc = str_word_count($string);
+ if ($wc > $count) {
+ $words = str_word_count($string, 2);
+ $last_word = array_slice($words, $count, 1, true);
+ $pos = key($last_word);
+ $string = substr($string, 0, $pos);
+ }
+ return $string;
+}
+
+/**
+ * Strip "dangerous" HTML to make it safe to print to web browsers
+ */
function sanitizeForWeb($string) {
$string = preg_replace('/<br\s*\/?>/', "\n", $string);

© 2014-2024 Faster IT GmbH | imprint | privacy policy