function module_sheet() { global $global, $smarty; $prefix = $global['channel'] . '/mod-sheet'; if (isset($global['field'])) { $prefix = $prefix . '/field-' . $global['field']; } if (isset($global['key'])) { $prefix = $prefix . '/key-' . $global['key']; } $obj = new article(); $obj->set_where('art_channel_id = ' . $global['channel_id']); if (isset($global['key'])) { $obj->set_where($global['field'] . " like '%" . url_decode($global['key']) . "%'"); } $obj->set_page_size(10); $obj->set_page_num($global['page']); $sheet = $obj->get_sheet(); for ($i = 0; $i < count($sheet); $i++) { $sheet[$i]['cat_name'] = get_data('cat_art', $sheet[$i]['art_cat_id'], 'cat_name'); } set_link($obj->get_page_sum()); $smarty->assign('article', $sheet); $smarty->assign('prefix', $prefix); }
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); }
function module_article_list() { global $smarty; $obj = new cat_art(); $obj->set_where('cat_best = 1'); $best_cat = $obj->get_list(); $art_list = array(); if (count($best_cat) > 0) { $smarty->assign('show_all_art', 0); $list_len = get_varia('index_art_list_len'); for ($i = 0; $i < count($best_cat); $i++) { $cat_id = $best_cat[$i]['cat_id']; $best_cat[$i]['channel'] = get_data('channel', $best_cat[$i]['cat_channel_id'], 'cha_code'); $family = implode(',', get_cat_family('cat_art', $cat_id)); $obj = new article(); $obj->set_field('art_id,art_title,art_add_time'); $obj->set_where("art_cat_id in ({$family})"); $obj->set_page_size($list_len ? $list_len : 5); $list = $obj->get_list(); for ($j = 0; $j < count($list); $j++) { $list[$j]['short_title'] = cut_str($list[$j]['art_title'], 22); } $art_list[$cat_id] = $list; unset($obj); } $smarty->assign('best_art_cat', $best_cat); $smarty->assign('art_list', $art_list); } else { $smarty->assign('show_all_art', 1); } }
function module_best_article() { global $smarty; $obj = new article(); $obj->set_field('art_id,art_channel_id,art_title,art_add_time'); $obj->set_where('art_best = 1'); $obj->set_page_size(10); $list = $obj->get_list(); for ($i = 0; $i < count($list); $i++) { $list[$i]['channel'] = get_data('channel', $list[$i]['art_channel_id'], 'cha_code'); $list[$i]['short_title'] = cut_str($list[$i]['art_title'], 16); } $smarty->assign('best_article', $list); }
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_edit() { global $global, $smarty; $obj = new article(); $obj->set_where('art_id = ' . $global['id']); $one = $obj->get_one(); $smarty->assign('article', $one); $smarty->assign('editor_text', $one['art_text']); $list = array(); $obj = new cat_art(); $obj->set_where('cat_channel_id = ' . $global['channel_id']); $arr = $obj->get_list(); if (count($arr) > 0) { $list = $obj->set_cat_order($arr); } $smarty->assign('cat_list', $list); $smarty->assign('upl_date', date('Ymd')); }
function module_search_main() { global $global, $smarty; $global['key'] = url_decode($global['key']); $list_len = get_varia('art_list_len'); $obj = new article(); $obj->set_field('art_id,art_channel_id,art_title,art_add_time'); $obj->set_where("art_title like '%" . $global['key'] . "%'"); $obj->set_page_size($list_len ? $list_len : 20); $obj->set_page_num($global['page']); $sheet = $obj->get_sheet(); for ($i = 0; $i < count($sheet); $i++) { $sheet[$i]['channel'] = get_data('channel', $sheet[$i]['art_channel_id'], 'cha_code'); $sheet[$i]['short_title'] = cut_str($sheet[$i]['art_title'], 42); } set_link($obj->get_page_sum()); $smarty->assign('search', $sheet); }
function module_article_main() { global $global, $smarty; if (!$global['id']) { $art_best = get_global('best'); $prefix = get_data('channel', $global['channel_id'], 'cha_code'); $list_len = get_varia('art_list_len'); $obj = new article(); $obj->set_where('art_channel_id = ' . $global['channel_id']); if ($global['cat']) { $family = implode(',', get_cat_family('cat_art', $global['cat'])); $obj->set_where("art_cat_id in ({$family})"); $prefix .= '/cat-' . $global['cat']; } if ($art_best) { $obj->set_where('art_best = 1'); $prefix .= '/best-1'; } $obj->set_page_size($list_len ? $list_len : 20); $obj->set_page_num($global['page']); $sheet = $obj->get_sheet(); for ($i = 0; $i < count($sheet); $i++) { $sheet[$i]['short_title'] = cut_str($sheet[$i]['art_title'], 42); } set_link($obj->get_page_sum()); $smarty->assign('show_sheet', 1); $smarty->assign('article', $sheet); $smarty->assign('prefix', $prefix); } else { $obj = new article(); $obj->set_field('art_id,art_title,art_author,art_add_time,art_text'); $obj->set_where('art_channel_id = ' . $global['channel_id']); $obj->set_where('art_id = ' . $global['id']); $one = $obj->get_one(); $smarty->assign('article', $one); $obj = new article(); $obj->set_field('art_id,art_title'); $obj->set_where('art_channel_id = ' . $global['channel_id']); $obj->set_where('art_id < ' . $global['id']); $one = $obj->get_one(); if (count($one)) { $smarty->assign('next_id', $one['art_id']); $smarty->assign('next_title', cut_str($one['art_title'], 15)); } else { $smarty->assign('next_id', ''); $smarty->assign('next_title', ''); } $obj = new article(); $obj->set_field('art_id,art_title'); $obj->set_where('art_channel_id = ' . $global['channel_id']); $obj->set_where('art_id > ' . $global['id']); $obj->set_order(''); $obj->set_order('art_top', 'asc'); $obj->set_order('art_index', 'asc'); $obj->set_order('art_id', 'asc'); $one = $obj->get_one(); if (count($one)) { $smarty->assign('prev_id', $one['art_id']); $smarty->assign('prev_title', cut_str($one['art_title'], 15)); } else { $smarty->assign('prev_id', ''); $smarty->assign('prev_title', ''); } $obj = new varia(); $smarty->assign('share_code', im_filter($obj->get_value('share_code', true))); $smarty->assign('show_sheet', 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; }
function add_or_edit_article() { global $global, $smarty, $lang; $art_id = post('art_id'); $art_title = post('art_title'); $art_cat_id = post('art_cat_id'); $art_author = post('art_author'); $att_url = post('file_path'); $art_text = post('editor', 'loose'); $art_keywords = post('art_keywords'); $art_description = post('art_description'); $art_add_time = time(); $arr = array(); $obj = new att_art(); $obj->set_where(''); $obj->set_where('att_channel_id = ' . $global['channel_id']); $att = $obj->get_list(); for ($i = 0; $i < count($att); $i++) { $att_value = post($att[$i]['att_code']); if ($att_value != '') { $arr[$att[$i]['att_id']] = $att_value; } } $art_attribute = rawurlencode(json_encode($arr)); if ($art_cat_id == '') { $art_cat_id = 0; } $art_text = str_replace('<p><br/></p>', '', $art_text); $art_text = str_replace('<p><br /></p>', '', $art_text); $art_description = cut_str($art_description, 250); $obj = new article(); $obj->set_value('art_title', $art_title); $obj->set_value('art_cat_id', $art_cat_id); $obj->set_value('art_author', $art_author); $obj->set_value('art_text', $art_text); $obj->set_value('art_keywords', $art_keywords); $obj->set_value('art_description', $art_description); $obj->set_value('art_add_time', $art_add_time); $obj->set_value('art_attribute', $art_attribute); if ($art_id != '') { $obj->set_where("art_id = {$art_id}"); $obj->edit(); $info_text = $lang['edit_article_success']; } else { $obj->set_value('art_channel_id', $global['channel_id']); $obj->set_value('art_lang', S_LANG); $obj->add(); $info_text = $lang['add_article_success']; } if (intval(get_varia('single_page_static'))) { $page_id = $art_id; if ($page_id == '') { $obj->set_where("art_add_time = {$art_add_time}"); $one = $obj->get_one(); if (count($one)) { $page_id = $one['art_id']; } } if ($page_id != '') { $domain = get_domain(); $page_url = 'http://' . $domain . S_ROOT . url(array('channel' => $global['channel'], 'id' => $page_id)); $html = file_get_contents($page_url); } } $smarty->assign('info_text', $info_text); $smarty->assign('link_text', $lang['return_list']); $smarty->assign('link_href', url(array('channel' => $global['channel'], 'mod' => 'sheet'))); }