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); }
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'))); }
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); }
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); }
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); }
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')); }
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; }
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()); }
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; }
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; }
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; } }