示例#1
0
if ($_REQUEST['ignore'] || $_REQUEST['change'] && $_REQUEST['wordreplace']) {
    // Ignore the word
    $spellChecker->ignoreWord($_REQUEST['wordreplace']);
}
// spell check the email
$_REQUEST['emailmessage'] = str_replace(array('<br>', '<BR>', '<br/>', '<BR/>', '</p>', '</P>'), "\n", $_REQUEST['emailmessage']);
// Remove any html entities and tags
$_REQUEST['emailmessage'] = preg_replace('/&\\w+;/', '', $_REQUEST['emailmessage']);
$_REQUEST['emailmessage'] = strip_tags($_REQUEST['emailmessage']);
// Remove punctuation such as , ; :
//$_REQUEST['emailmessage'] = preg_replace('/[^a-zA-Z\-]+/', ' ', $_REQUEST['emailmessage']);
foreach (explode("\n", $_REQUEST['emailmessage']) as $line) {
    $words = array_unique(preg_split('/\\s+/', $line));
    foreach ($words as $word) {
        if (preg_match('/[a-zA-Z]+/', $word)) {
            $spellChecker->check($word);
        }
    }
}
if ($spellChecker->haveErrors()) {
    $result = $spellChecker->getSuggestions();
    if (is_array($result)) {
        $var['atmailstyle'] = $atmail->parse("html/{$atmail->Language}/simple/atmailstyle.css");
        echo $atmail->parse("html/{$atmail->Language}/{$atmail->LoginType}/spellcheck.html", $result, $var);
    } else {
        header("Content-type: text/xml; charset: utf-8");
        echo $result;
    }
}
$spellChecker->close();
$atmail->end();