function import2glossary()
{
    global $site, $keel_id, $class_path;
    include_once $class_path . 'lang_functions.inc.php';
    ######################
    # set local_file_name
    if (preg_match("/^[^\\?]*\\//", $_SERVER["SCRIPT_FILENAME"], $matches)) {
        $doc_root = $matches[0];
        $doc_root = preg_replace("/\\/admin\\//i", "", $doc_root);
    }
    # if export
    $local_file_name = $doc_root . $site->CONF['file_path'] . "/language" . $keel_id . "_local.csv";
    ########################
    # 1. import_type = UPLOAD : file given by user
    if ($site->fdat[import_type] == "upload") {
        if ($_FILES['file']['tmp_name'] != 'none') {
            if (move_uploaded_file($_FILES['file']['tmp_name'], $local_file_name)) {
                #print $site->sys_sona(array(sona => "msg: Language file uploaded", tyyp=>"admin")).".";
                #print "<br>";
            } else {
                $errors[] = $site->sys_sona(array(sona => "ERROR: File upload error", tyyp => "admin"));
            }
        } else {
            $errors[] = "ERROR: " . $site->sys_sona(array(sona => "filename", tyyp => "editor")) . " " . $site->sys_sona(array(sona => "missing", tyyp => "admin"));
        }
    } else {
        if ($site->fdat[import_type] == "download") {
            $url = $site->CONF[protocol] . $site->hostname . $site->wwwroot;
            $remote_file = "http://extranet.saurus.ee/register/download_lang_file4.php?lang_id=" . $keel_id . "&url=" . $url . "/&license_key=" . $site->license;
            $response = fopen_url_auth($remote_file, 'register', 'register', 'Saurus CMS ' . $site->cms_version);
            if ($response === false) {
                $errors[] = "SYSTEM ERROR: The requested URL not found";
            } else {
                # Salvestame lang-file local-kataloogis
                // siin mingit vea checki ei peaks olema???
                $local_file = fopen($local_file_name, "w");
                fwrite($local_file, $response);
                fclose($local_file);
            }
        } elseif ($site->fdat['import_type'] == "cvs") {
            $exportfile = import_cvs();
            #echo $exportfile;
            # Salvestame lang-file local-kataloogis
            $local_file = fopen($local_file_name, "w");
            fwrite($local_file, $exportfile);
            fclose($local_file);
        }
    }
    # 3. import_type = CVS : import dictionary from CVS master copy (only for Saurus)
    ########################
    if (!import_dict_from_file($local_file_name, $site->fdat['overwrite_user_translations'] ? true : false, $site->fdat['delete_old_data'] ? true : false)) {
        echo '<span style="color: red;">Dictionary import failed.</span>';
    } else {
        echo '<span>Dictionary import complete.</span>';
    }
    @unlink($local_file_name);
}
 /**
  * Polls Saurus server with site info for statistics about installed version and URL, can be turned off from config.php by defining: disable_site_polling = 1
  *
  * @param integer $accessed_by
  */
 function site_polling($accessed_by)
 {
     if (!$this->CONF['disable_site_polling']) {
         $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $this->hostname . $this->wwwroot;
         # ping register.saurus.ee with version info
         $latest_ver = fopen_url_auth($this->site_poll_url . "?url=" . $url . "&license_key=" . $this->license . "&ver=" . $this->cms_version . "&accessed_by=" . $accessed_by, 'register', 'register', 'Saurus CMS ' . $this->cms_version);
     }
 }