<?php /** * * @author 王仁欢 * @email wrh4285@163.com * @date 2015-09-02 * @version 1.0.0 */ include 'library/init.inc.php'; if (!isset($_SESSION['account'])) { echo json_decode(array('error' => 1, 'message' => '请先登陆')); exit; } if (check_cross_domain()) { echo json_decode(array('error' => 1, 'message' => '请从本站提交数据')); exit; } $operation = 'get_children'; $opera = check_action($operation, getPOST('opera')); if ('get_children' == $opera) { $account = trim(getPOST('account')); if ('' == $account) { $current = trim(getPOST('current')); if ('' == $current) { echo json_encode(array('error' => 1, 'message' => '参数错误')); exit; } else { $current = $db->escape($current); $get_member = 'select id, account, parent_id, nickname as parentId from ' . $db->table('member'); $get_member .= ' where account = \'' . $current . '\' limit 1';
} else { if (empty($_SESSION['account'])) { $response['msg'] = '请先登录'; $response['error'] = 2; } else { $response['msg'] = '404:参数错误'; } } echo json_encode($response); exit; } //产品收藏 if ('collection' == $opera) { $product_sn = getPOST('product_sn'); $response = array('error' => 1, 'msg' => ''); if (!check_cross_domain() && !empty($_SESSION['account'])) { if ($product_sn != '') { $product_sn = $db->escape($product_sn); //检查产品的收藏状态 $get_collection = 'select `product_sn` from ' . $db->table('collection') . ' where `account`=\'' . $_SESSION['account'] . '\' and `product_sn`=\'' . $product_sn . '\''; $collection_flag = $db->fetchOne($get_collection) ? true : false; if ($collection_flag) { if (cancel_collection_product($_SESSION['account'], $product_sn)) { $response['error'] = 0; $response['status'] = !$collection_flag; $response['product_sn'] = $product_sn; $response['msg'] = '取消收藏成功'; } else { $response['msg'] = '001:系统繁忙,请稍后再试'; } } else {
foreach ($section_list as $key => $section) { array_push($section_id_array, $section['id']); } } $section_id_str = '(' . implode(',', $section_id_array) . ')'; $get_article_list = 'select * from ' . $db->table('content') . ' where `section_id` in ' . $section_id_str; $get_article_list .= ' and `status` <> 0 order by `order_view` asc, `last_modify` desc'; $page_count = 20; assign('page_count', $page_count); $article_list = $db->fetchAll($get_article_list); $total = count($article_list); $total_page = ceil($total / $page_count); assign('total_page', $total_page); if ('paging' == $opera) { $response = array('error' => 1, 'msg' => ''); if (!check_cross_domain() && isset($_SESSION['account'])) { $page = intval(getPOST('page')); $page = $page > $total_page ? $total_page : $page; $page = $page < 1 ? 1 : $page; $offset = $page_count * ($page - 1); $get_article_list .= ' limit ' . $offset . ',' . $page_count; $article_list = $db->fetchAll($get_article_list); assign('article_list', $article_list); assign('page', $page); $response['content'] = $smarty->fetch('promotion-item.phtml'); $response['sql'] = $get_article_list; $response['error'] = 0; } else { if (empty($_SESSION['account'])) { $response['msg'] = '请先登录'; $response['error'] = 2;
$log->record($url . ',' . $_SERVER['REQUEST_URI']); $url = 'http://' . $_SERVER['HTTP_HOST'] . preg_replace('/d\\/[a-zA-Z].*$/', $url, $_SERVER['REQUEST_URI']); $log->record('target url:' . $url); if (is_weixin() && $_SESSION['openid'] == '') { $oathor_url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_userinfo&state=2048#wechat_redirect'; $url = sprintf($oathor_url, $config['appid'], urlencode($url)); redirect($url); } else { redirect($url); } exit; } $opera = getPOST('opera'); if ($opera == 'get_url') { $response = array('error' => 1, 'msg' => ''); if (true || !check_cross_domain()) { $url = getPOST('url'); $account = getPOST('account'); if ($url == '') { $response['msg'] = '参数为空'; } else { if (!empty($_SESSION['account'])) { $account = $_SESSION['account']; } else { $account = $db->escape($account); } if (!empty($account)) { $get_member_id = 'select `id` from ' . $db->table('member') . ' where `account`=\'' . $account . '\''; $member_id = $db->fetchOne($get_member_id); //检查url是否带有用户参数 if (strpos($url, '?') === false) {