예제 #1
0
function print_checker_results()
{
    global $config, $lang;
    $aspell_err = "";
    if ($config['pspell'] == 'pspell') {
        include 'classes/spellchecker/pspell.class.php';
    } elseif ($config['pspell'] == 'mysql') {
        include 'classes/spellchecker/mysql.class.php';
        global $db;
        $path = $db;
    } else {
        include 'classes/spellchecker/php.class.php';
        $path = 'classes/spellchecker/dict/';
    }
    $sc = new spellchecker($lang->phrase('spellcheck_dict'), $config['spellcheck_ignore'], $config['spellcheck_mode'], TRUE);
    if (isset($path)) {
        $sc->set_path($path);
    }
    $sc->init();
    $x = $sc->error();
    if (!empty($x)) {
        $aspell_err .= $sc->error();
    } else {
        $count = count($_POST['textinputs']);
        for ($i = 0; $i < $count; $i++) {
            $text = @utf8_decode(urldecode($_POST['textinputs'][$i]));
            $lines = explode("\n", $text);
            print_textindex_decl($i);
            $index = 0;
            foreach ($lines as $value) {
                $b1 = t1();
                $mistakes = $sc->check_text($value);
                $suggestions = $sc->suggest_text($mistakes);
                foreach ($mistakes as $word) {
                    print_words_elem($word, $index, $i);
                    print_suggs_elem($suggestions[$word], $index, $i);
                    $index++;
                }
            }
        }
    }
    if (!empty($aspell_err)) {
        $aspell_err = "Error executing {$config['pspell']}:\\n{$aspell_err}";
        error_handler($aspell_err);
    }
    @file_put_contents('temp/spellchecker_benchmark.dat', $sc->benchmark());
}
예제 #2
0
	<?php 
    echo foot();
} elseif ($job == "spellcheck_add") {
    echo head();
    $dict = $gpc->get('dict', str);
    if ($config['pspell'] == 'pspell') {
        include 'classes/spellchecker/pspell.class.php';
    } elseif ($config['pspell'] == 'mysql') {
        include 'classes/spellchecker/mysql.class.php';
        global $db;
        $path = $db;
    } else {
        include 'classes/spellchecker/php.class.php';
        $path = 'classes/spellchecker/dict/';
    }
    $sc = new spellchecker($dict, $config['spellcheck_ignore'], $config['spellcheck_mode'], true);
    if (isset($path)) {
        $sc->set_path($path);
    }
    $sc->init();
    $x = $sc->error();
    if (!empty($x)) {
        error('admin.php?action=misc&job=spellcheck', $x);
    }
    $words = $gpc->get('words', none);
    $word_seperator = "0-9\\.,;:!\\?\\-\\|\n\r\\s\"'\\[\\]\\{\\}\\(\\)\\/\\\\";
    $words = preg_split('~[' . $word_seperator . ']+?~', $words, -1, PREG_SPLIT_NO_EMPTY);
    foreach ($words as $k => $w) {
        if (empty($w)) {
            unset($words[$k]);
        }