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_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); } }
dalert($do->errmsg, '', ($need_captcha ? reload_captcha() : '') . ($need_question ? reload_question() : '')); } } else { foreach ($do->fields as $v) { ${$v} = ''; } $content = ''; $catid = 0; $areaid = $cityid; $item = array(); } break; case 'edit': $itemid or message(); $do->itemid = $itemid; $item = $do->get_one(); if (!$item || $item['username'] != $_username) { message(); } if ($MG['edit_limit'] < 0) { message($L['edit_refuse']); } if ($MG['edit_limit'] && $DT_TIME - $item['addtime'] > $MG['edit_limit'] * 86400) { message(lang($L['edit_limit'], array($MG['edit_limit']))); } if ($submit) { if ($item['islink']) { $post['islink'] = 1; } else { if (isset($post['islink'])) { unset($post['islink']);
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'))); }