function chars($text)
{
    $trans_tbl = array("&" => "&amp;", "<" => "&lt;", ">" => "&gt;", "&rsquo;" => "&apos;");
    return trim(strtr(entities_to_chars($text), $trans_tbl));
}
示例#2
0
/**
 * send an email when receiving a fresh comment
 *
 * @param unknown_type $posting
 * @param unknown_type $name
 * @param unknown_type $mail
 * @param unknown_type $web
 * @param unknown_type $message
 */
function notify($posting, $name, $mail, $web, $message)
{
    global $settings;
    if (empty($mail)) {
        $mail = "no mail address";
    }
    if (empty($web)) {
        $web = "no web address";
    }
    $authorid = $posting['author_id'];
    $to = getfullname($authorid) . " <" . getmail($authorid) . ">";
    $subject = "New comment on '" . $settings['sitename'] . "'";
    $name = entities_to_chars($name);
    $mail = entities_to_chars($mail);
    $web = entities_to_chars($web);
    $body = $name . " has left a comment for '" . $posting['title'] . "'\n";
    $body .= $settings['url'] . "/index.php?id=" . $posting['id'] . "\n\n";
    $body .= entities_to_chars(strip_tags($message)) . "\n\n";
    $body .= "Name: " . $name;
    if (!empty($mail)) {
        $body .= " / eMail: " . $mail;
        $showmail = $mail;
    } else {
        $showmail = getmail($authorid);
    }
    if ($web != "http://") {
        $body .= " / Web: " . $web;
    }
    //killing komma and semikolon
    $name = str_replace(",", " ", $name);
    $name = str_replace(";", " ", $name);
    $headers = "From: " . $name . " <" . $showmail . ">\r\n";
    mail($to, $subject, $body, $headers);
}