private function pspell()
 {
     foreach ($_REQUEST as $key => $value) {
         ${$key} = html_entity_decode(urldecode(stripslashes(trim($value))));
     }
     // load the dictionary
     $pspell_link = pspell_new_personal($this->pspell_personal_dictionary, $this->lang);
     // return suggestions
     if (isset($suggest)) {
         exit(json_encode(pspell_suggest($pspell_link, urldecode($suggest))));
     } elseif (isset($text)) {
         $words = array();
         foreach ($text = explode(' ', urldecode($text)) as $word) {
             if (!pspell_check($pspell_link, $word) and !in_array($word, $words)) {
                 $words[] = $word;
             }
         }
         exit(json_encode($words));
     } elseif (isset($addtodictionary)) {
         $pspell_config = pspell_config_create('en');
         @pspell_config_personal($pspell_config, $this->pspell_personal_dictionary) or die('can\'t find pspell dictionary');
         $pspell_link = pspell_new_config($pspell_config);
         @pspell_add_to_personal($pspell_link, strtolower($addtodictionary)) or die('You can\'t add a word to the dictionary that contains any punctuation.');
         pspell_save_wordlist($pspell_link);
         exit(array());
     }
 }
Ejemplo n.º 2
0
/**
 * Initialise our aSpell calling environment.
 *
 * @return array			A tuple of environmental details (dictionary list,aspell call command,temporary file name,language being used)
 */
function aspell_init()
{
    // Find the language
    if (!isset($_REQUEST['dictionary']) || strlen(trim($_REQUEST['dictionary'])) < 1) {
        $lang = function_exists('do_lang') ? do_lang('dictionary') : 'en_GB';
        // Default to UK English (as per ocPortal)
    } else {
        $lang = $_REQUEST['dictionary'];
    }
    $aspellcommand = mixed();
    $force_shell = false;
    if (!function_exists('pspell_check') || $force_shell) {
        if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1') {
            exit('Spell Checker does not work with safe mode systems that do not have direct pspell support into PHP');
        }
        if (strpos(@ini_get('disable_functions'), 'shell_exec') !== false) {
            exit('Spell Checker does not work on systems with shell_exec disabled that do not have direct pspell support into PHP');
        }
        // Our temporary spell check file
        $temptext = tempnam(str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('safe_mode'))) == '1' || @strval(ini_get('open_basedir')) != '' && preg_match('#(^|:|;)/tmp($|:|;|/)#', ini_get('open_basedir')) == 0 ? get_custom_file_base() . '/safe_mode_temp/' : '/tmp/', 'spell_');
        if ($temptext === false) {
            $temptext = tempnam(get_custom_file_base() . '/safe_mode_temp/', 'spell_');
        }
        // Find aspell
        $aspell = 'aspell';
        $aspell_args = '-a --lang=' . _filter_naughty_harsh($lang);
        if (DIRECTORY_SEPARATOR == '\\') {
            // See if there is a local install of aspell here
            if (file_exists(dirname(__FILE__) . '\\aspell\\bin\\aspell.exe')) {
                $aspell = dirname(__FILE__) . '\\aspell\\bin\\aspell.exe';
                if (file_exists(dirname(__FILE__) . '\\aspell\\bin\\aspell_wrap.exe')) {
                    $aspell = dirname(__FILE__) . '\\aspell\\bin\\aspell_wrap.exe ' . dirname(__FILE__) . '\\aspell\\bin\\';
                }
                //$dic_dir=wrap_exec($aspell.' config dict-dir');
                //$dicfil=preg_replace('/^.*\/lib\/(aspell\S*)\n.*/s','$1',$dic_dir);
                //$aspell_args.=' --dict-dir='.$dicfil;
            } else {
                $aspell = 'C:\\Progra~1\\Aspell\\bin\\aspell.exe';
            }
            if (!file_exists($aspell)) {
                exit('ASpell not installed in default locations.');
            }
            $aspell_version = wrap_exec($aspell . ' version');
        } else {
            // See if there is a local install of aspell here
            if (file_exists(dirname(__FILE__) . '/aspell/bin/aspell')) {
                putenv('PATH=' . dirname(__FILE__) . '/aspell/bin:' . getenv('PATH'));
                putenv('LD_LIBRARY_PATH=' . dirname(__FILE__) . '/aspell/lib:' . getenv('LD_LIBRARY_PATH'));
                //$dic_dir=wrap_exec($aspell.' config dict-dir');
                //$dicfil=dirname(__FILE__).'/aspell/lib/'.preg_replace('/^.*\/lib\/(aspell\S*)\n.*/s','$1',$dic_dir);
                //$aspell_args.=' --dict-dir='.$dicfil.' --add-filter-path='.$dicfil;
            }
            $aspell_version = wrap_exec($aspell . ' version');
        }
        if ($aspell_version === false) {
            exit('ASpell would not execute. It is most likely not installed, or a security measure is in place, or file permissions are not correctly set. If on Windows, you may need to give windows\\system32\\cmd.exe execute permissions to the web user.');
        }
        // Old aspell doesn't know about encoding, which means that unicode will be broke, but we should at least let it try.
        $a_ver = array();
        preg_match('/really [aA]spell ([0-9]+)\\.([0-9]+)(?:\\.([0-9]+))?/i', $aspell_version, $a_ver);
        if (!array_key_exists(1, $a_ver)) {
            $a_ver[1] = '1';
        }
        if (!array_key_exists(2, $a_ver)) {
            $a_ver[2] = '0';
        }
        if (!array_key_exists(3, $a_ver)) {
            $a_ver[3] = '0';
        }
        $a_ver = array('major' => (int) $a_ver[1], 'minor' => (int) $a_ver[2], 'release' => (int) $a_ver[3]);
        if ($a_ver['major'] >= 0 && $a_ver['minor'] >= 60) {
            $aspell_args .= ' -H --encoding=utf-8';
        } elseif (preg_match('/--encoding/', wrap_exec($aspell . ' 2>&1')) != 0) {
            $aspell_args .= ' --mode=none --add-filter=sgml --encoding=utf-8';
        } else {
            $aspell_args .= ' --mode=none --add-filter=sgml';
        }
        $aspelldictionaries = $aspell . ' dump dicts';
        $aspellcommand = $aspell . ' ' . $aspell_args . ' < ' . $temptext;
    } else {
        //list($lang,$spelling)=explode('_',$lang);
        $spelling = '';
        $temptext = NULL;
        $aspelldictionaries = NULL;
    }
    // Personal dictionaries
    global $SITE_INFO;
    if (!isset($SITE_INFO)) {
        require_once '../../../../info.php';
    }
    $cookie_member_id = $SITE_INFO['user_cookie'];
    $p_dicts_name = array_key_exists($cookie_member_id, $_COOKIE) ? _filter_naughty_harsh($_COOKIE[$cookie_member_id]) : 'guest';
    $p_dict_path = get_custom_file_base() . '/data_custom/spelling/personal_dicts' . DIRECTORY_SEPARATOR . $p_dicts_name;
    if (!file_exists($p_dict_path)) {
        mkdir($p_dict_path, 02770);
    }
    if (is_null($temptext)) {
        list($lang_stub, ) = explode('_', $lang);
        $charset = str_replace('ISO-', 'iso', str_replace('iso-', 'iso', do_lang('charset')));
        if (DIRECTORY_SEPARATOR == '\\') {
            $aspellcommand = @pspell_new_personal($p_dict_path . '/' . $lang_stub . '.pws', $lang, $spelling, '', $charset);
            if ($aspellcommand === false) {
                $aspellcommand = pspell_new_personal($p_dict_path . '/' . $lang_stub . '.pws', $lang, $spelling, '', $charset);
            }
        } else {
            $aspellconfig = @pspell_config_create($lang, $spelling, '', $charset);
            if ($aspellconfig === false) {
                $aspellconfig = pspell_config_create('en', $spelling, '', $charset);
            }
            pspell_config_personal($aspellconfig, $p_dict_path . '/' . $lang_stub . '.pws');
            pspell_config_repl($aspellconfig, $p_dict_path . '/' . $lang_stub . '.prepl');
            $aspellcommand = @pspell_new_config($aspellconfig);
            if ($aspellcommand === false && $lang != 'en') {
                $aspellconfig = pspell_config_create('en', $spelling, '', $charset);
                pspell_config_personal($aspellconfig, $p_dict_path . '/' . $lang_stub . '.pws');
                pspell_config_repl($aspellconfig, $p_dict_path . '/' . $lang_stub . '.prepl');
                $aspellcommand = pspell_new_config($aspellconfig);
            }
        }
        if (is_null($aspellcommand)) {
            exit;
        }
    }
    return array($aspelldictionaries, $aspellcommand, $temptext, $lang);
}
Ejemplo n.º 3
0
    global $phpdoc, $lang, $current_file;
    if (!fnmatch('*.xml', $filename) || fnmatch("{$phpdoc}{$lang}/functions/*", $filename)) {
        return;
    }
    echo "checking {$filename}...\n";
    $current_file = $filename;
    $file = file_get_contents($filename);
    if (!$file) {
        return;
    }
    $file = preg_replace('/&(.*?);/', '', $file);
    if (trim($file) == '') {
        return;
    }
    $xml = xml_parser_create();
    xml_set_element_handler($xml, 'set_current_element', 'end_current_element');
    xml_set_character_data_handler($xml, 'check_data');
    if (!xml_parse($xml, $file, true)) {
        printf("%s: XML error: %s at line %d\n", $filename, xml_error_string(xml_get_error_code($xml)), xml_get_current_line_number($xml));
    }
    xml_parser_free($xml);
}
if (!function_exists('pspell_new_personal')) {
    echo "You must compile PHP with pspell support for this script to work.\n";
    return;
}
$dict = pspell_new_personal('custom.pws', 'en');
globbetyglob("{$phpdoc}{$lang}", 'check_file');
pspell_save_wordlist($dict);
echo "Wordlist saved.\n";
echo "Processed {$word_count} words.\n";
Ejemplo n.º 4
0
 function checkSpl()
 {
     if (isset($this->pot)) {
         $potFile = $this->pot;
     } else {
         return;
     }
     $lang = $this->lang;
     $data = array();
     if (false && $this->lang) {
         $suggestEnabled = $this->lang != "hu";
         $suggestEnabled = $suggestEnabled && $this->lang != "de";
         echo "<!--";
         $pspell_link = pspell_new($this->lang, "", "", "utf-8", PSPELL_FAST);
         $pspell_links = array();
         echo "LLLLL";
         foreach ($this->spellDictFiles as $spellDictFile) {
             echo "<br />\n" . $spellDictFile . "<br />\n";
             $pspell_link_local = pspell_new_personal($spellDictFiles . "1", $this->lang, "", "", "utf-8");
             if ($pspell_link_local) {
                 $word = "Aktionsskript";
                 //                  $word="Aktionsskript";
                 echo "\n{$pspell_link_local}: {$spellDictFile} : {$word} =";
                 echo pspell_check($pspell_link_local, $word);
                 $word = "COM";
                 echo "\n{$pspell_link_local}: {$spellDictFile} : {$word} =";
                 echo pspell_check($pspell_link_local, $word);
                 $word = "BASE";
                 echo "\n{$pspell_link_local}: {$spellDictFile} : {$word} =";
                 echo pspell_check($pspell_link_local, $word);
                 $word = "Diff";
                 echo "\n{$pspell_link_local}: {$spellDictFile} : {$word} =";
                 echo pspell_check($pspell_link_local, $word);
                 $word = "BABE";
                 echo "\n{$pspell_link_local}: {$spellDictFile} : {$word} =";
                 echo pspell_check($pspell_link_local, $word);
                 $pspell_links[] = $pspell_link_local;
             }
         }
         echo "-->";
         $regexp = "/[A-Za-z0-9\\x{80}-\\x{ffff}]+/u";
         $regexp2 = "/^[A-Za-z]*\$/";
         $regexp3 = "/\\b{$word}\\b/i";
         $preprocessSearch = array("&", "<", ">", "\\n", "\\r", "\\t", "%s", "%d", "%ld", "/");
         $preprocessReplace = array("", " < ", " > ", " \\n ", " \\r ", " \\t ", " %s ", " %d ", " %ld ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ");
         $postprocessSearch = array("\\n");
         $postprocessReplace = array("\\n<br />");
         if ($pspell_link) {
             foreach ($potFile->dictionary as $key => $value) {
                 $orig = $key;
                 if (!isset($orig) || $orig == "") {
                     continue;
                 }
                 $native = $this->dictionary[$key]["text"];
                 if (!isset($native) || $native == "") {
                     continue;
                 }
                 $native = str_replace($preprocessSearch, $preprocessReplace, $native);
                 $orig = str_replace($preprocessSearch, $preprocessReplace, $orig);
                 $natMatch = preg_match_all($regexp, $native, $matchesOnNat, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
                 //                  $string=$native;
                 if ($natMatch) {
                     $match = true;
                     for ($i = 0; $i < count($matchesOnNat[0]); $i++) {
                         $word = $matchesOnNat[0][$i][0];
                         //                          if (!preg_match($regexp2, $word)) {
                         //                              continue;
                         //                          }
                         $wordOk = pspell_check($pspell_link, $word);
                         if (!$wordOk) {
                             //                              echo "<b>$word</b><br />";
                             foreach ($pspell_links as $pspell_link_local) {
                                 $wordOk = pspell_check($pspell_link_local, $word);
                                 //                                  echo "<!--$pspell_link_local, $word = $wordOk --!>\n";
                                 //                                  echo "<!-- DUMP:";
                                 //                                  var_dump($pspell_link_local);
                                 //                                  echo " --!>\n";
                                 //                                  echo "<!-- SET:".isset($pspell_link_local)." --!>\n";
                                 if ($wordOk) {
                                     echo "<!--OK --!>\n";
                                     break;
                                 }
                             }
                         }
                         if (!$wordOk) {
                             if ($suggestEnabled) {
                                 $suggestArr = pspell_suggest($pspell_link, $word);
                                 $suggestStr = implode(", ", $suggestArr);
                                 $matchesOnNat[0][$i]['sugestion'] = 'suggest:' . $suggestStr;
                             }
                             //                              if (strpos($orig, $word)!==false) {
                             //                              $regexp3="/\\b".$word."[$.^A-Za-z0-9]/i";
                             $regexp3 = "/\\b" . $word . "\\b/i";
                             if (preg_match($regexp3, $orig)) {
                                 $mark = MARK_WARNING;
                             } else {
                                 $mark = MARK_ERROR;
                                 $match = false;
                             }
                         } else {
                             $mark = MARK_OK;
                         }
                         $matchesOnNat[0][$i][2] = $mark;
                     }
                     if (!$match) {
                         for ($i = count($matchesOnNat[0]) - 1; $i >= 0; $i--) {
                             if (!isset($matchesOnNat[0][$i][2])) {
                                 continue;
                             }
                             $param = $matchesOnNat[0][$i][0];
                             $pos = $matchesOnNat[0][$i][1];
                             if ($param == "n" && $pos && $native[$pos - 1] == "\\") {
                                 continue;
                             }
                             switch ($matchesOnNat[0][$i][2]) {
                                 case MARK_OK:
                                     $class = "elmark";
                                     break;
                                 case MARK_ERROR:
                                     $class = "elerror";
                                     break;
                                 case MARK_WARNING:
                                     $class = "elwarning";
                                     break;
                             }
                             $replaceStr = "<font class=\"{$class}\">" . $param . "</font>";
                             if (isset($matchesOnNat[0][$i]['sugestion'])) {
                                 $replaceStr = "<acronym title=\"" . $matchesOnNat[0][$i]['sugestion'] . "\">{$replaceStr}</acronym>";
                             }
                             $native = substr($native, 0, $pos) . $replaceStr . substr($native, $pos + strlen($param));
                         }
                         $orig = str_replace($postprocessSearch, $postprocessReplace, $orig);
                         $native = str_replace($postprocessSearch, $postprocessReplace, $native);
                         $lineN = $this->dictionary[$key]["line"];
                         $lineE = $potFile->dictionary[$key]["line"];
                         if (isset($this->dictionary[$key]["flag"]["fuzzy"])) {
                             $lineN .= "(Fuzzy)";
                         }
                         $data[] = array(count($data) + 1, $lineE, $orig, $lineN, $native);
                     }
                     flush();
                 }
             }
             pspell_clear_session($pspell_link);
             $table = new Table();
             $table->name = "Spell check";
             $table->description = "<p>Testing spelling of translation. We use ASPELL dictionaris for PSPELL. <b><i>in development</i></b> </p>";
             $table->header = array("Index", "Line", "English", "Line", "Native");
             $table->data = $data;
             $this->report["spl"] = $table;
         } else {
             $this->report["spl"]["error"] = "Dictionary not found.";
         }
     } else {
         $this->report["spl"]["error"] = "Internal error";
     }
 }