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 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_static_set() { global $smarty; $smarty->assign('S_HALF_STATIC', S_HALF_STATIC); $smarty->assign('S_SHAM_STATIC', S_SHAM_STATIC); $smarty->assign('S_PURE_STATIC', S_PURE_STATIC); $smarty->assign('single_page_static', get_varia('single_page_static')); }
function module_safe_set() { global $smarty; $smarty->assign('safe_admin_login_hours', get_varia('safe_admin_login_hours')); $smarty->assign('safe_admin_login_times', get_varia('safe_admin_login_times')); $smarty->assign('safe_message_hours', get_varia('safe_message_hours')); $smarty->assign('safe_message_times', get_varia('safe_message_times')); $smarty->assign('safe_comment_hours', get_varia('safe_comment_hours')); $smarty->assign('safe_comment_times', get_varia('safe_comment_times')); }
function module_other() { global $smarty; $smarty->assign('S_SESSION', S_SESSION); $smarty->assign('index_art_list_len', get_varia('index_art_list_len')); $smarty->assign('art_list_len', get_varia('art_list_len')); $smarty->assign('sentmail', intval(get_varia('sentmail'))); $smarty->assign('sentmail_smtp', get_varia('sentmail_smtp')); $smarty->assign('sentmail_send', get_varia('sentmail_send')); $smarty->assign('sentmail_password', get_varia('sentmail_password')); $smarty->assign('sentmail_receive', get_varia('sentmail_receive')); }
function initial($table) { global $global, $smarty, $lang; $smarty->assign('global', $global); $smarty->assign('lang', $lang); $smarty->assign('version', get_varia('version')); $smarty->assign('sit' . 'e_ti' . 'tle', get_dec_str()); $smarty->assign('S_ROOT', S_ROOT); $smarty->assign('S_TPL_PATH', S_ROOT . S_TPL_PATH); $smarty->assign('S_LANG', S_LANG); $smarty->assign('S_MULTILINGUAL', S_MULTILINGUAL); $smarty->registerPlugin('function', 'run', 'run'); $smarty->registerPlugin('function', 'url', 'url'); }
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_add() { global $global, $smarty; $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('editor_text', ''); $smarty->assign('site_keywords', get_varia('site_keywords')); $smarty->assign('site_description', get_varia('site_description')); $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 initial($table) { global $global, $smarty, $lang; $tab = substr($table, 0, 3); if (check_copr() && !$global['id']) { $page_title = ''; $cat_name = ''; $keywords = get_varia('site_keywords'); $describe = get_varia('site_description'); } else { $global['cat'] = get_data($table, $global['id'], $tab . '_cat_id'); if (!($page_title = get_data($table, $global['id'], $tab . '_title'))) { $page_title = get_data($table, $global['id'], $tab . '_name'); } $cat_name = get_data('cat_' . $tab, $global['cat'], 'cat_name'); $keywords = get_data($table, $global['id'], $tab . '_keywords'); $describe = get_data($table, $global['id'], $tab . '_description'); } if ($global['cat']) { $cat_name = get_data('cat_' . $tab, $global['cat'], 'cat_name'); } $global['entrance'] = get_lang_info(S_LANG, 2); $global['entrance'] = $global['entrance'] == 'index.php' ? '' : $global['entrance']; $smarty->assign('global', $global); $smarty->assign('lang', $lang); $smarty->assign('version', get_varia('version')); $smarty->assign('site_title', get_varia('site_title')); $smarty->assign('channel_title', get_channel_title()); $smarty->assign('page_title', $page_title); $smarty->assign('cat_name', $cat_name); $smarty->assign('keywords', $keywords); $smarty->assign('describe', $describe); $smarty->assign('S_ROOT', S_ROOT); $smarty->assign('S_TPL_PATH', S_ROOT . S_TPL_PATH); $smarty->assign('S_LANG', S_LANG); $smarty->assign('S_MULTILINGUAL', S_MULTILINGUAL); $smarty->registerPlugin('function', 'run', 'run'); $smarty->registerPlugin('function', 'url', 'url'); }
function add_comment() { safe('comment'); global $global, $smarty, $lang; $channel = post('channel'); $com_page_id = post('page_id'); $com_username = post('username'); $com_email = post('email'); $com_rank = post('rank'); $com_text = post('text'); if ($channel == '' || $com_page_id == '' || $com_username == '' || $com_email == '' || $com_rank == '' || $com_text == '') { $info_text = $lang['submit_error_info']; } else { $com_channel_id = get_id('channel', 'cha_code', $channel); $com_add_time = time(); $obj = new comment(); $obj->set_value('com_channel_id', $com_channel_id); $obj->set_value('com_page_id', $com_page_id); $obj->set_value('com_username', $com_username); $obj->set_value('com_email', $com_email); $obj->set_value('com_rank', $com_rank); $obj->set_value('com_text', $com_text); $obj->set_value('com_add_time', $com_add_time); $obj->set_value('com_show', 0); $obj->set_value('com_lang', S_LANG); $obj->add(); if (intval(get_varia('sentmail'))) { $email_title = '您的网站有了新的评论'; $str = get_data($channel, $com_page_id, substr($channel, 0, 3) . '_title'); $email_text = '评论:《' . $str . '》<br />' . $com_text; call_send_email($email_title, $email_text, $com_username, $com_email); } $info_text = $lang['submit_comment']; } $smarty->assign('info_text', $info_text); $smarty->assign('link_text', $lang['go_back']); $smarty->assign('link_href', url(array('channel' => $channel, 'id' => $com_page_id))); }
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 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'))); }
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; } }
function step_count() { $sum = 8; //计算产品单页数 $num = get_single_page_sum('goods', 'goods'); //计算产品无分类页数 $page_size = intval(get_varia('img_list_len')); $sum += get_page_sum($num, $page_size); //计算产品分类页数 $sum += get_sheet_page_sum('goods', 'goods', $page_size); //计算文章单页数 $num = get_single_page_sum('article', 'article'); //计算文章无分类页数 $page_size = intval(get_varia('art_list_len')); $sum += get_page_sum($num, $page_size); //计算文章分类页数 $sum += get_sheet_page_sum('article', 'article', $page_size); //计算关于我们单页数 $num = get_single_page_sum('article', 'about'); //计算人才招聘页数 $num = get_single_page_sum('article', 'recruit'); $sum += get_page_sum($num, 5); //计算下载中心页数 $num = get_single_page_sum('article', 'download'); $sum += get_page_sum($num, 5); //计算在线留言页数 $num = get_single_page_sum('message', 'message'); $sum += get_page_sum($num, 5); return $sum; }
function safe($action) { $ip = get_ip(); $hours = intval(get_varia('safe_' . $action . '_hours')); $times = intval(get_varia('safe_' . $action . '_times')); $time = time() - $hours * 60 * 60; $obj = new safe(); $obj->set_where("saf_action = '{$action}'"); $obj->set_where("saf_time < {$time}"); $obj->del(); $obj->set_where(''); $obj->set_where("saf_ip = '{$ip}'"); $obj->set_where("saf_action = '{$action}'"); if ($obj->get_count() > $times - 1) { header('location:./safe.html'); exit; } else { $obj->set_value("saf_ip", $ip); $obj->set_value("saf_action", $action); $obj->set_value("saf_time", time()); $obj->add(); } }