예제 #1
0
파일: sheet.php 프로젝트: jechiy/xiu-cms
function module_sheet()
{
    global $global, $smarty;
    $cat = get_global('cat');
    $page = get_global('page');
    $prefix = 'data/mod-sheet';
    if ($cat) {
        $prefix = $prefix . '/cat-' . $cat;
    }
    $url = S_SERVER_URL . '?/data/cat-' . $cat . '/page-' . $page . '/index.html';
    $str = file_get_contents($url);
    $result = json_decode(rawurldecode($str), true);
    if (is_array($result)) {
        $server_cat_list = $result['cat_list'];
        $sheet = $result['sheet'];
        for ($i = 0; $i < count($sheet); $i++) {
            $obj = new article();
            $obj->set_where("art_title = '" . $sheet[$i]['art_title'] . "'");
            if ($obj->get_count()) {
                $sheet[$i]['is_exist'] = 1;
            } else {
                $sheet[$i]['is_exist'] = 0;
            }
        }
        $smarty->assign('page_sum', $result['page_sum']);
        $smarty->assign('prefix', $prefix);
    } else {
        $server_cat_list = array();
        $sheet = array();
    }
    $smarty->assign('article', $sheet);
    $cat_list = get_local_cat();
    if (count($cat_list) < count($server_cat_list)) {
        for ($i = 0; $i < count($server_cat_list); $i++) {
            $flag = false;
            for ($j = 0; $j < count($cat_list); $j++) {
                if ($server_cat_list[$i]['cat_id'] == $cat_list[$j]['server_id']) {
                    $flag = true;
                    if ($server_cat_list[$i]['cat_name'] != $cat_list[$j]['server_name']) {
                        $val = $server_cat_list[$i]['cat_id'] . '|' . $server_cat_list[$i]['cat_name'] . '|' . $cat_list[$i]['channel_id'] . '|' . $cat_list[$i]['cat_id'];
                        $obj = new varia();
                        $obj->set_value('var_value', $val);
                        $obj->set_where('var_id = ' . $cat_list[$i]['varia_id']);
                        $obj->edit();
                    }
                    break;
                }
            }
            if (!$flag) {
                $val = $server_cat_list[$i]['cat_id'] . '|' . $server_cat_list[$i]['cat_name'] . '|0|0';
                $obj = new varia();
                $obj->set_value('var_name', 'data_cat');
                $obj->set_value('var_value', $val);
                $obj->add();
            }
        }
        $cat_list = get_local_cat();
    }
    $smarty->assign('cat_list', $cat_list);
}
예제 #2
0
파일: deal.php 프로젝트: jechiy/xiu-cms
function add_contact()
{
    global $smarty, $lang;
    $cue = post('cue');
    $content = post('content');
    $val = $cue . '{v}' . $content;
    $obj = new varia();
    $obj->set_value('var_name', 'contact');
    $obj->set_value('var_value', $val);
    $obj->set_value('var_lang', S_LANG);
    $obj->add();
    $smarty->assign('info_text', '添加联系方式成功');
    $smarty->assign('link_text', $lang['return_list']);
    $smarty->assign('link_href', url(array('channel' => 'basic', 'mod' => 'contact_list')));
}
예제 #3
0
파일: deal.php 프로젝트: jechiy/xiu-cms
function add_tailor_cat()
{
    global $smarty;
    $server_id = post('server_id');
    $server_name = post('server_name');
    $data_channel = post('data_channel');
    $data_cat = post('data_cat');
    if (is_numeric($server_id) && is_numeric($data_channel) && is_numeric($data_cat)) {
        $val = $server_id . '|' . $server_name . '|' . $data_channel . '|' . $data_cat;
        $obj = new varia();
        $obj->set_value('var_name', 'tailor_data_cat');
        $obj->set_value('var_value', $val);
        $obj->add();
        $info_text = '修改分类设置成功';
    } else {
        $info_text = '对不起,您所提交的数据有误';
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', '返回列表页');
    $smarty->assign('link_href', url(array('channel' => 'data', 'mod' => 'tailor_set')));
}
예제 #4
0
파일: function.php 프로젝트: jechiy/xiu-cms
function do_add_channel($original, $cha_code, $cha_name, $word_1, $word_2)
{
    //判断频道是否已存在
    $obj = new channel();
    $obj->set_where('');
    $obj->set_where("cha_code = '{$cha_code}'");
    $channel = $obj->get_one();
    if (count($channel)) {
        return 0;
    }
    //添加频道记录
    $cha_original = get_id('channel', 'cha_code', $original);
    $obj = new channel();
    $obj->set_value('cha_code', $cha_code);
    $obj->set_value('cha_name', $cha_name);
    $obj->set_value('cha_original', $cha_original);
    $obj->set_value('cha_lang', S_LANG);
    $obj->add();
    $obj = new varia();
    //添加前台导航(导航管理)
    if ($original == 'about') {
        $obj->set_value('var_name', 'nav_stage_' . $cha_code);
        $obj->set_value('var_value', $cha_name);
        $obj->add();
    }
    //添加后台导航(导航管理)
    $obj->clear_value();
    $obj->set_value('var_name', 'nav_admin_' . $cha_code);
    $obj->set_value('var_value', $cha_name);
    $obj->add();
    //添加后台导航菜单
    $obj = new menu();
    $obj->set_value('men_type', 'admin_header');
    $obj->set_value('men_name', $cha_name);
    $obj->set_value('men_url', $cha_code . '/mod-sheet/');
    $obj->add();
    $obj->clear_value();
    $obj->set_value('men_type', 'admin_' . $cha_code);
    $obj->set_value('men_name', $cha_name . '列表');
    $obj->set_value('men_url', $cha_code . '/mod-sheet/');
    $obj->add();
    $obj->clear_value();
    $obj->set_value('men_type', 'admin_' . $cha_code);
    $obj->set_value('men_name', '添加' . $cha_name);
    $obj->set_value('men_url', $cha_code . '/mod-add/');
    $obj->add();
    if ($original == 'article' || $original == 'goods') {
        $obj->clear_value();
        $obj->set_value('men_type', 'admin_' . $cha_code);
        $obj->set_value('men_name', $cha_name . '分类');
        $obj->set_value('men_url', $cha_code . '/mod-cat_list/');
        $obj->add();
    }
    if ($original == 'goods') {
        $obj->clear_value();
        $obj->set_value('men_type', 'admin_' . $cha_code);
        $obj->set_value('men_name', $cha_name . '属性');
        $obj->set_value('men_url', $cha_code . '/mod-att_list/');
        $obj->add();
    }
    //添加前台导航菜单
    $obj = new menu();
    $obj->set_value('men_lang', S_LANG);
    $obj->set_value('men_type', 'header');
    $obj->set_value('men_name', $cha_name);
    $obj->set_value('men_url', $cha_code . '/');
    $obj->add();
    //添加属性
    if ($original == 'download') {
        $obj = new att_art();
        $obj->set_where('');
        $obj->set_where("att_channel_id = {$cha_original}");
        $list = $obj->get_list();
        $channel_id = get_id('channel', 'cha_code', $cha_code);
        for ($i = 0; $i < count($list); $i++) {
            $obj->clear_value();
            $obj->set_value('att_channel_id', $channel_id);
            $obj->set_value('att_lang', $list[$i]['att_lang']);
            $obj->set_value('att_code', $list[$i]['att_code']);
            $obj->set_value('att_name', $list[$i]['att_name']);
            $obj->add();
        }
    }
    //创建语言包
    $path = 'languages/' . S_LANG . '/admin/';
    if (file_exists($path . $original . '.txt')) {
        $str = file_get_contents($path . $original . '.txt');
        $str = str_replace($word_1, $word_2, $str);
        file_put_contents($path . $cha_code . '.txt', $str);
    }
    $path = 'languages/' . S_LANG . '/index/';
    if (file_exists($path . $original . '.txt')) {
        $str = file_get_contents($path . $original . '.txt');
        $str = str_replace($word_1, $word_2, $str);
        file_put_contents($path . $cha_code . '.txt', $str);
    }
    //修改伪静态文件
    $path = 'admin/module/basic/htaccess.txt';
    if (file_exists($path)) {
        $str = file_get_contents($path);
        $str .= "\n" . 'RewriteRule ^' . $cha_code . '/(.*)$ index.php?/' . $cha_code . '/$1';
        $str = str_replace("\n\n", "\n", $str);
        file_put_contents($path, $str);
    }
    return 1;
}