<?php

if (IS_POST)
{
    $elangs = is_array($_POST['elangs']) ? $_POST['elangs'] : array();
    isset($conf['sys_langs'][$_POST['lang']]) or yun_error('默认语言不存在');
    in_array($_POST['lang'], $elangs) or yun_error('默认语言不能隐藏');
    $conf['sys_elangs'] = array();
    foreach ($elangs as $v)
    {
        $conf['sys_elangs'][$v] = $_POST['name'][$v];
    }

    $arr = array();
    foreach ($conf['sys_elangs'] as $k => $v)
    {
        $arr[intval($_POST['order'][$k])][$k] = $v;
    }

    ksort($arr);
    $conf['sys_elangs'] = array();
    foreach ($arr as $v)
    {
        foreach ($v as $k => $v2)
        {
            $conf['sys_elangs'][$k] = $v2;
        }
    }
    set_conf('sys_lang', $_POST['lang']);
    set_conf('sys_elangs', $conf['sys_elangs']);
    yun_succeed('提交成功', url(RPGM . 'lang/'));
}
arg(array_diff_key($conf['sys_langs'], $conf['sys_elangs']));

?>