Example #1
0
function edit_tailor_cat()
{
    global $smarty;
    $obj = new varia();
    $obj->set_where("var_name = 'tailor_data_cat'");
    $list = $obj->get_list();
    for ($i = 0; $i < count($_POST['varia_id']); $i++) {
        $varia_id = strict($_POST['varia_id'][$i]);
        $data_channel = strict($_POST['data_channel'][$i]);
        $data_cat = strict($_POST['data_cat'][$i]);
        for ($j = 0; $j < count($list); $j++) {
            if ($list[$j]['var_id'] == $varia_id) {
                $arr = explode('|', $list[$j]['var_value']);
                if ($arr[2] != $data_channel || $arr[3] != $data_cat) {
                    $val = $arr[0] . '|' . $arr[1] . '|' . $data_channel . '|' . $data_cat;
                    $obj = new varia();
                    $obj->set_value('var_value', $val);
                    $obj->set_where('var_id = ' . $varia_id);
                    $obj->edit();
                }
                break;
            }
        }
    }
    $smarty->assign('info_text', '修改分类设置成功');
    $smarty->assign('link_text', '返回上一页');
    $smarty->assign('link_href', url(array('channel' => 'data', 'mod' => 'tailor_set')));
}
Example #2
0
function module_set()
{
    global $global, $smarty;
    $smarty->assign('data_username', get_varia('data_username'));
    $smarty->assign('data_password', get_varia('data_password'));
    $obj = new channel();
    $channel = $obj->get_list();
    $smarty->assign('channel', $channel);
    $obj = new varia();
    $obj->set_where("var_name = 'data_cat'");
    $list = $obj->get_list();
    if (count($list)) {
        for ($i = 0; $i < count($list); $i++) {
            $arr = explode('|', $list[$i]['var_value']);
            $cat_setting[$i]['varia_id'] = $list[$i]['var_id'];
            $cat_setting[$i]['server_id'] = $arr[0];
            $cat_setting[$i]['server_name'] = $arr[1];
            $cat_setting[$i]['channel_id'] = $arr[2];
            $cat_setting[$i]['cat_id'] = $arr[3];
        }
    } else {
        $cat_setting = array();
    }
    $smarty->assign('cat_setting', $cat_setting);
    $cat_list = array();
    for ($i = 0; $i < count($cat_setting); $i++) {
        $obj = new cat_art();
        $obj->set_where('cat_channel_id = ' . $cat_setting[$i]['channel_id']);
        $arr = $obj->get_list();
        if (count($arr) > 0) {
            $cat_list[$cat_setting[$i]['server_id']] = $obj->set_cat_order($arr);
        }
    }
    $smarty->assign('cat_list', $cat_list);
}
Example #3
0
function module_nav_add()
{
    global $global, $smarty;
    $obj = new varia();
    $obj->set_where("left(var_name,10) = 'nav_admin_'");
    $arr = $obj->get_list();
    for ($i = 0; $i < count($arr); $i++) {
        if (substr($arr[$i]['var_name'], 4) == $global['type']) {
            $type_name = $arr[$i]['var_value'];
        }
    }
    $smarty->assign('type_name', $type_name);
}
Example #4
0
function del_lang()
{
    $id = post('id');
    $obj = new varia();
    $obj->set_where('');
    $obj->set_where("var_id = {$id}");
    $one = $obj->get_one();
    if (count($one) > 0) {
        $arr = explode('{v}', $one['var_value']);
        $pack_name = $arr[0];
        $index_entrance = $arr[1];
        $admin_entrance = $arr[2];
        if ($index_entrance != 'index.php' && $admin_entrance != 'admin.php') {
            $obj->del();
            $table = array('article', 'att_art', 'att_goo', 'booking', 'cat_art', 'cat_goo', 'channel', 'comment', 'goods', 'link', 'menu', 'message', 'picture', 'research', 'varia');
            //以下表不处理:admin,safe,users
            for ($i = 0; $i < count($table); $i++) {
                $tab = substr($table[$i], 0, 3);
                $obj = new $table[$i]();
                $obj->set_where('');
                $obj->set_where($tab . "_lang = '{$pack_name}'");
                $obj->del();
            }
            if (file_exists($index_entrance)) {
                unlink($index_entrance);
            }
            if (file_exists($admin_entrance)) {
                unlink($admin_entrance);
            }
            if (file_exists('languages/' . $pack_name)) {
                del_dir('languages/' . $pack_name);
            }
            echo 1;
        }
    }
}
Example #5
0
function module_tailor_sheet()
{
    global $global, $smarty;
    $obj = new varia();
    $obj->set_where("var_name = 'tailor_data_cat'");
    $list = $obj->get_list();
    if (count($list)) {
        for ($i = 0; $i < count($list); $i++) {
            $arr = explode('|', $list[$i]['var_value']);
            $cat_list[$i]['server_id'] = $arr[0];
            $cat_list[$i]['server_name'] = $arr[1];
        }
    } else {
        $cat_list = array();
    }
    $smarty->assign('cat_list', $cat_list);
    $data_username = rawurlencode(get_varia('data_username'));
    $data_password = rawurlencode(get_varia('data_password'));
    $cat = get_global('cat');
    $page = get_global('page');
    $prefix = 'data/mod-tailor_sheet';
    $page_sum = 1;
    $sheet = array();
    if ($cat) {
        $prefix = $prefix . '/cat-' . $cat;
    }
    $url = S_SERVER_URL . 'tailor.php?/tailor/cat-' . $cat . '/page-' . $page . '/data_username-' . $data_username . '/data_password-' . $data_password . '/index.html';
    $str = file_get_contents($url);
    $result = json_decode(rawurldecode($str), true);
    if (is_array($result)) {
        if ($result['error'] == 'no') {
            $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;
                }
            }
            $page_sum = $result['page_sum'];
        }
    }
    $smarty->assign('page_sum', $page_sum);
    $smarty->assign('prefix', $prefix);
    $smarty->assign('article', $sheet);
}
Example #6
0
function module_nav_list()
{
    global $smarty;
    $obj = new varia();
    $obj->set_where("left(var_name,10) = 'nav_stage_'");
    $arr = $obj->get_list();
    for ($i = 0; $i < count($arr); $i++) {
        $name = substr($arr[$i]['var_name'], 10);
        $obj = new menu();
        $obj->set_where("men_type = '{$name}'");
        $list[$name] = $obj->get_list();
        $nav[$i]['type'] = $name;
        $nav[$i]['name'] = $arr[$i]['var_value'];
    }
    $smarty->assign('nav', $nav);
    $smarty->assign('list', $list);
}
Example #7
0
function module_lang_lists()
{
    global $smarty;
    $obj = new varia();
    $obj->set_where("var_name = 'languages'");
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $arr = explode('{v}', $list[$i]['var_value']);
        $list[$i]['pack_name'] = $arr[0];
        $list[$i]['index_entrance'] = $arr[1];
        $list[$i]['admin_entrance'] = $arr[2];
        $list[$i]['chinese_name'] = $arr[3];
        $list[$i]['foreign_name'] = $arr[4];
    }
    $smarty->assign('lang_list', $list);
    $smarty->assign('S_LANG', S_LANG);
    $smarty->assign('pack', get_folder_list('languages'));
}
Example #8
0
function get_local_cat()
{
    $obj = new varia();
    $obj->set_where("var_name = 'data_cat'");
    $list = $obj->get_list();
    if (count($list)) {
        for ($i = 0; $i < count($list); $i++) {
            $arr = explode('|', $list[$i]['var_value']);
            $cat_list[$i]['varia_id'] = $list[$i]['var_id'];
            $cat_list[$i]['server_id'] = $arr[0];
            $cat_list[$i]['server_name'] = $arr[1];
            $cat_list[$i]['channel_id'] = $arr[2];
            $cat_list[$i]['cat_id'] = $arr[3];
        }
    } else {
        $cat_list = array();
    }
    return $cat_list;
}
Example #9
0
function module_header()
{
    global $smarty;
    $obj = new varia();
    $obj->set_where("var_name = 'languages'");
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $arr = explode('{v}', $list[$i]['var_value']);
        $list[$i]['pack_name'] = $arr[0];
        $list[$i]['index_entrance'] = $arr[1];
        $list[$i]['admin_entrance'] = $arr[2];
        $list[$i]['chinese_name'] = $arr[3];
        $list[$i]['foreign_name'] = $arr[4];
    }
    $smarty->assign('lang_pack', $list);
    $obj = new menu();
    $obj->set_where("men_type = 'header'");
    $obj->set_field('men_name,men_url');
    $smarty->assign('nav', $obj->get_list());
}
Example #10
0
function set_multilingual()
{
    $val = intval(post('val'));
    edit_config('S_MULTILINGUAL', S_MULTILINGUAL, $val);
    $obj = new varia();
    $obj->set_where("var_name = 'languages'");
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $arr = explode('{v}', $list[$i]['var_value']);
        $pack_name = $arr[0];
        $index_entrance = $arr[1];
        $admin_entrance = $arr[2];
        if ($pack_name == 'zh-cn') {
            continue;
        } elseif ($val == 1) {
            if (!file_exists($index_entrance)) {
                $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);
            }
            if (!file_exists($admin_entrance)) {
                $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);
            }
        } elseif ($val == 0) {
            if (file_exists($index_entrance)) {
                unlink($index_entrance);
            }
            if (file_exists($admin_entrance)) {
                unlink($admin_entrance);
            }
        }
    }
    echo 1;
}
Example #11
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;
}
Example #12
0
function get_site_info()
{
    $site = array();
    $obj = new varia();
    $obj->set_where("(left(var_name,5) = 'site_' or var_name = 'statistical_code' or var_name = 'share_code')");
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        $val = $list[$i]['var_value'];
        switch ($list[$i]['var_name']) {
            case 'site_title':
                $site['title'] = $val;
                break;
            case 'site_admin_title':
                $site['admin_title'] = $val;
                break;
            case 'site_name':
                $site['name'] = $val;
                break;
            case 'site_domain':
                $site['domain'] = $val;
                break;
            case 'site_record':
                $site['record'] = $val;
                break;
            case 'site_record_url':
                $site['record_url'] = $val;
                break;
            case 'site_tech':
                $site['tech'] = $val;
                break;
            case 'site_tech_url':
                $site['tech_url'] = $val;
                break;
            case 'site_keywords':
                $site['keywords'] = $val;
                break;
            case 'site_description':
                $site['description'] = $val;
                break;
            case 'statistical_code':
                $site['statistical_code'] = im_filter($list[$i]['var_text']);
                break;
            case 'share_code':
                $site['share_code'] = im_filter($list[$i]['var_text']);
                break;
        }
    }
    return $site;
}
Example #13
0
function do_gather_tailor()
{
    $id = post('id');
    $data_username = rawurlencode(get_varia('data_username'));
    $data_password = rawurlencode(get_varia('data_password'));
    $url = S_SERVER_URL . 'tailor.php?/tailor/id-' . $id . '/data_username-' . $data_username . '/data_password-' . $data_password . '/index.html';
    $str = file_get_contents($url);
    $result = json_decode(rawurldecode($str), true);
    if (is_array($result)) {
        if ($result['error'] == 'no') {
            $one = $result['one'];
            $local_channel_id = 0;
            $local_cat_id = 0;
            $obj = new varia();
            $obj->set_where("var_name = 'tailor_data_cat'");
            $list = $obj->get_list();
            for ($i = 0; $i < count($list); $i++) {
                $arr = explode('|', $list[$i]['var_value']);
                if ($arr[0] == $one['art_cat_id']) {
                    $local_channel_id = $arr[2];
                    $local_cat_id = $arr[3];
                    break;
                }
            }
            if ($local_channel_id != 0 && $local_cat_id != 0) {
                $site_keywords = get_varia('site_keywords');
                $site_description = get_varia('site_description');
                $obj = new article();
                $obj->set_value('art_title', $one['art_title']);
                $obj->set_value('art_channel_id', $local_channel_id);
                $obj->set_value('art_lang', S_LANG);
                $obj->set_value('art_cat_id', $local_cat_id);
                $obj->set_value('art_author', $one['art_author']);
                $obj->set_value('art_text', $one['art_text']);
                $obj->set_value('art_keywords', $site_keywords);
                $obj->set_value('art_description', $site_description);
                $obj->set_value('art_add_time', time());
                $obj->add();
                echo 1;
            } else {
                echo 2;
            }
        } else {
            echo $result['error'];
        }
    } else {
        echo 0;
    }
}
Example #14
0
function get_lang_info($name, $num)
{
    $len = strlen($name);
    $obj = new varia();
    $obj->set_where("var_name = 'languages'");
    $obj->set_where("left(var_value,{$len}) = '{$name}'");
    $one = $obj->get_one();
    if (count($one) > 0) {
        $arr = explode('{v}', $one['var_value']);
        return $arr[$num - 1];
    } else {
        return '';
    }
}