예제 #1
0
function translator_edit($option, $task)
{
    global $_CONFIG, $lang_array, $lang_dir;
    if ($task == 'save_lang' || $task == 'save_lang_apply') {
        $lfile = $lang_dir . "/" . $_REQUEST['language'] . ".php";
        if ($_REQUEST['language'] == 'english') {
            if ($fp = @fopen($lfile, 'w')) {
                fwrite($fp, stripslashes($_REQUEST['def_content']));
                fclose($fp);
                $msg = "Language " . ucfirst($_REQUEST['language']) . " successfully updated!";
            } else {
                $msg = "File {$lfile} could not be created, please check it's permissions'!";
            }
            if ($task == 'save_lang_apply') {
                mosRedirect('index2.php?option=' . $option . "&task=edit_lang&langx=" . $_REQUEST['language'], $msg);
            } else {
                mosRedirect('index2.php?option=' . $option . "&task=lang", $msg);
            }
        } else {
            $lfile = $_REQUEST['lfile'];
            $ldata = $_REQUEST['lang'];
            if ($fp = @fopen($lfile, 'w')) {
                fwrite($fp, "<" . "?php\n");
                foreach ($ldata as $key => $value) {
                    fwrite($fp, "define(\"" . $key . "\",\"" . stripslashes($value) . "\");\n");
                }
                fwrite($fp, "?" . ">");
                fclose($fp);
                $msg = "Language " . ucfirst($_REQUEST['language']) . " successfully updated!";
            } else {
                $msg = "File {$lfile} could not be updated, please check it's permissions'!";
            }
        }
        if ($task == 'save_lang_apply') {
            mosRedirect('index2.php?option=' . $option . "&task=edit_lang&langx=" . $_REQUEST['language'], $msg);
        } else {
            mosRedirect('index2.php?option=' . $option . "&task=lang", $msg);
        }
    }
    $content = "";
    $lang = "";
    $cid = $_REQUEST['cid'];
    $files = $_REQUEST['files'];
    if (is_array($cid)) {
        foreach ($cid as $value) {
            $lang = $files[$value];
        }
    }
    if ($_REQUEST['langx']) {
        $lang = $_REQUEST['langx'];
    }
    if ($fp = fopen($lang_dir . "/english.php", 'r')) {
        while (!feof($fp)) {
            $content .= fread($fp, 1024);
        }
        fclose($fp);
    }
    $file = $lang_dir . "/" . $lang . ".php";
    $dfile = $lang_dir . "/english.php";
    if ($lang == 'english') {
        HTML_cloner::Translator_Edit_DEFAULT($option, $content, $file, $lang);
    } else {
        $def_data = get_lang_data($dfile);
        $cur_data = get_lang_data($file);
        $data = array_merge($def_data, $cur_data);
        HTML_cloner::Translator_Edit($option, $data, $def_data, $file, $lang);
    }
}