Esempio n. 1
0
function add_lang()
{
    global $smarty, $lang;
    $chinese_name = post('chinese_name');
    $foreign_name = post('foreign_name');
    $pack_name = post('pack_name');
    $short_name = post('short_name');
    $index_entrance = post('index_entrance');
    $admin_entrance = post('admin_entrance');
    if ($chinese_name != '' && $foreign_name != '' && $pack_name != '' && $index_entrance != '' && $admin_entrance != '' && $index_entrance != 'index.php' && $admin_entrance != 'admin.php') {
        $var_value = $pack_name . '{v}' . $index_entrance . '{v}' . $admin_entrance . '{v}' . $chinese_name . '{v}' . $foreign_name;
        $obj = new varia();
        $obj->add_var_value('languages', $var_value);
        $site = get_site_info();
        $obj->add_var_value('site_title', $site['title'], $pack_name);
        $obj->add_var_value('site_name', $site['name'], $pack_name);
        $obj->add_var_value('site_record', $site['record'], $pack_name);
        $obj->add_var_value('site_tech', $site['tech'], $pack_name);
        $obj->add_var_value('site_keywords', $site['keywords'], $pack_name);
        $obj->add_var_value('site_description', $site['description'], $pack_name);
        $obj->add_var_value('notice', '', $pack_name, true);
        $obj->add_var_value('service_code', '', $pack_name, true);
        $obj->add_var_value('user_agreement', '', $pack_name, true);
        $obj = new channel();
        $obj->set_where('cha_original = 0');
        $list = $obj->get_list();
        for ($i = 0; $i < count($list); $i++) {
            $obj->clear_value();
            $obj->set_value('cha_lang', $pack_name);
            $obj->set_value('cha_code', $list[$i]['cha_code']);
            $obj->set_value('cha_name', $list[$i]['cha_name']);
            $obj->set_value('cha_original', $list[$i]['cha_original']);
            $obj->add();
        }
        if (!file_exists('languages/' . $pack_name)) {
            copy_dir('languages/' . S_LANG, 'languages/' . $pack_name);
        }
        if (S_MULTILINGUAL) {
            $file = file_get_contents('admin/index.txt');
            $file = str_replace('{$pack_name}', $pack_name, $file);
            $file = str_replace('{$index_entrance}', $index_entrance, $file);
            $file = str_replace('{$admin_entrance}', $admin_entrance, $file);
            file_put_contents($index_entrance, $file);
            $file = file_get_contents('admin/admin.txt');
            $file = str_replace('{$pack_name}', $pack_name, $file);
            $file = str_replace('{$index_entrance}', $index_entrance, $file);
            $file = str_replace('{$admin_entrance}', $admin_entrance, $file);
            file_put_contents($admin_entrance, $file);
        }
        $info_text = '添加语言成功';
    } else {
        $info_text = '的输入不合法,添加语言失败';
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', $lang['return_list']);
    $smarty->assign('link_href', url(array('channel' => 'file', 'mod' => 'lang_lists')));
}
Esempio n. 2
0
function module_channel_add()
{
    global $smarty;
    $obj = new channel();
    $obj->set_where("cha_original = 0");
    $smarty->assign('original', $obj->get_list());
    $arr = array();
    $obj = new channel();
    $obj->set_where("cha_original <> 0");
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $list[$i]['original'] = get_data('channel', $list[$i]['cha_original'], 'cha_code');
    }
    $smarty->assign('channel', $list);
}
Esempio n. 3
0
function get_channel_title()
{
    global $global, $lang;
    $return = '';
    if ($global['url'] != '') {
        $arr = explode('/', $global['url']);
        $str = $arr[1];
        $obj = new channel();
        $obj->set_where("cha_code = '{$str}'");
        $one = $obj->get_one();
        if (count($one)) {
            $return = $one['cha_name'];
        } elseif (isset($lang['channel_' . $str])) {
            $return = $lang['channel_' . $str];
        }
    }
    return $return;
}
Esempio n. 4
0
function do_del_channel($channel_id)
{
    //判断频道是否已存在
    $obj = new channel();
    $obj->set_where('');
    $obj->set_where("cha_id = {$channel_id}");
    $channel = $obj->get_one();
    if (count($channel)) {
        $cha_code = $channel['cha_code'];
        $obj->del();
    } else {
        return 0;
    }
    //删除前台导航(导航管理)
    $obj = new varia();
    $obj->set_where("var_name = 'nav_stage_" . $cha_code . "'");
    $obj->del();
    //删除后台导航(导航管理)
    $obj->set_where('');
    $obj->set_where("var_name = 'nav_admin_" . $cha_code . "'");
    $obj->del();
    //删除后台导航菜单
    $obj = new menu();
    $obj->set_where("men_type = '{$cha_code}'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_header'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-sheet/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-sheet/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-add/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-cat_list/'");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("men_type = 'admin_" . $cha_code . "'");
    $obj->set_where("men_url = '" . $cha_code . "/mod-att_list/'");
    $obj->del();
    //删除前台导航菜单
    $obj = new menu();
    $obj->set_where("men_type = 'header'");
    $obj->set_where("men_url = '" . $cha_code . "/'");
    $obj->del();
    //删除分类
    $obj = new cat_art();
    $obj->set_where('');
    $obj->set_where("cat_channel_id = {$channel_id}");
    $obj->del();
    //删除内容
    $obj = new article();
    $obj->set_where('');
    $obj->set_where("art_channel_id = {$channel_id}");
    $obj->del();
    //删除属性
    $obj = new att_art();
    $obj->set_where('');
    $obj->set_where("att_channel_id = {$channel_id}");
    $obj->del();
    //删除语言包
    $path = 'languages/' . S_LANG . '/admin/' . $cha_code . '.txt';
    if (file_exists($path)) {
        unlink($path);
    }
    $path = 'languages/' . S_LANG . '/index/' . $cha_code . '.txt';
    if (file_exists($path)) {
        unlink($path);
    }
    //修改伪静态文件
    $path = 'admin/module/basic/htaccess.txt';
    if (file_exists($path)) {
        $str = file_get_contents($path);
        $rule = "\n" . 'RewriteRule ^' . $cha_code . '/(.*)$ index.php?/' . $cha_code . '/$1';
        $str = str_replace($rule, '', $str);
        file_put_contents($path, $str);
    }
    return 1;
}
Esempio n. 5
0
function edit_channel_name()
{
    global $smarty;
    for ($i = 0; $i < count($_POST['cha_id']); $i++) {
        $cha_name = strict($_POST['cha_name'][$i]);
        $cha_id = strict($_POST['cha_id'][$i]);
        $obj = new channel();
        $obj->set_value('cha_name', $cha_name);
        $obj->set_where('cha_id = ' . $cha_id);
        $obj->edit();
    }
    $smarty->assign('info_text', '修改频道标题成功');
    $smarty->assign('link_text', '返回上一页');
    $smarty->assign('link_href', url(array('channel' => 'super', 'mod' => 'channel_name')));
}