Файл: htdocs/functions.php
Строк: 99
<?php
// the language viewer
function lang($key) {
global $lang, $deblang;
if (array_key_exists($key, $lang)) return $lang[$key];// . " [$key]";
else {
$deblang[] = $key;
return "__" . $key . "__";
}
}
function deblang() {
//mail notfound language keys to debug mailaddr
global $use_lang, $conf_admin_mail, $deblang;
if (!$deblang) return false;
mail($conf_admin_mail, 'SmartMail Language-Error',$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."nnLanguage: $use_langnKeys:nt" . implode("nt",$deblang) . "n");
}
function display_error($message) {
return "<div class='error'><img src='images/icons/error.png' alt='' valign='top'> $message</div>n";
}
function display_success($message) {
return "<div class='success'><img src='images/icons/success.png' alt='' valign='top'> $message</div>n";
}
function cutstr($str,$len) {
if (!$str) return false;
else {
if (strlen($str) > ($len+3)) return substr($str,0,$len) . "...";
else return $str;
}
}
//for the message headers
function strDecode($str) {
if (!$str) return false;
$arr = imap_mime_header_decode($str);
for ($i=0;$i<count($arr);$i++) {
$text .= $arr[$i]->text . " ";
}
return trim($text);
}
function make_clickable($text) {
$ret = ' ' . $text;
$ret = preg_replace("#(^|[n ])([w]+?://[^ "nrt<]*)#is", "\1<a href="\2" target="_blank">\2</a>", $ret);
$ret = preg_replace("#(^|[n ])((www|ftp).[^ "tnr<]*)#is", "\1<a href="http://\2" target="_blank">\2</a>", $ret);
$ret = preg_replace("#(^|[n ])([a-z0-9&-_.]+?)@([w-]+.([w-.]+.)*[w]+)#i", "\1<a href="newmess.php?to=\2@\3">\2@\3</a>", $ret);
$ret = preg_replace("#(^|[n ])(([a-z0-9_-]+).([a-z0-9_-]+).([a-z0-9_-]+)[^ "tnr)<]*)#is", "\1<a href="http://\2" target="_blank">\2</a>", $ret);
$ret = substr($ret, 1);
return($ret);
}
function he($str) {
//short htmlentities checker - converts all quotes
$str = htmlentities($str, ENT_QUOTES);
return $str;
}
if (!function_exists("checkdnsrr")) {
function checkdnsrr() {
return true;
}
}
function is_email($email) {
$email = trim($email);
if (!$email) return false;
if (!preg_match("!^[w|.|-|_]+@w[w|.|-]+.[a-zA-Z]{2,6}$!",$email)) return false;
else {
list($user, $host) = explode("@", $email);
if (checkdnsrr($host, "MX") or checkdnsrr($host, "A")) return true;
else return false;
}
}
?>