function email_encode($code) { wproUtilities::emailEncode($code); }
function cutHTML($html, $len, $cut = '') { $fullLen = strlen($html); $tag = 0; $ent = 0; // do not cut in the middle of an entity $c = 0; // full character count $c2 = 0; // non html character count $lastWhite = 0; // last occurance of white space for ($i = 0; $i < $fullLen; $i++) { $chr = $html[$i]; if ($chr == '&' && preg_match("/^&[a-z0-9#]{2,10};/", substr($html, $i, 10))) { // look ahead to check for a valid entity $ent = 1; if (!$tag) { $c2++; } } else { if ($chr == ';') { $ent = 0; } else { if ($chr == '<') { $tag++; } elseif ($chr == '>') { $tag--; } elseif (!$tag && preg_match("#\\s#", $chr)) { $lastWhite = $c; // record position of last white space $c2++; } elseif (!$tag && !$ent) { $c2++; } } } $c++; if ($c2 >= $len && !$tag && !$ent) { if ($lastWhite > 0) { // return to last white space position $c = $lastWhite; } break; } } // cut the string if (strlen($html) > $c) { $snippet = substr($html, 0, $c) . $cut; $snippet = wproUtilities::closeTags($snippet); } else { $snippet = $html; } return $snippet; }