public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $share_id = intval($GLOBALS['request']['share_id']); //没有分享ID直接退出 if ($share_id == 0) { $root['status'] = -2; output($root); } $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $is_relay = intval($GLOBALS['request']['is_relay']); $parent_id = intval($GLOBALS['request']['parent_id']); if ($parent_id > 0) { $parent_reply = $GLOBALS['db']->getRow("select id,user_id,user_name from " . DB_PREFIX . "topic_reply where id = " . $parent_id); } $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['user_login_status'] = 0; $root['info'] = "请先登录"; output($root); } $root['user_login_status'] = 1; $topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $share_id); if (empty($topic)) { $root['status'] = -3; output($root); } $reply_data = array(); $reply_data['topic_id'] = $share_id; $reply_data['user_id'] = intval($user_data['id']); $reply_data['user_name'] = $user_data['user_name']; $reply_data['reply_id'] = intval($parent_reply['id']); $reply_data['reply_user_id'] = intval($parent_reply['user_id']); $reply_data['reply_user_name'] = strim($parent_reply['user_name']); $reply_data['create_time'] = get_gmtime(); $reply_data['is_effect'] = 1; $reply_data['is_delete'] = 0; $reply_data['content'] = valid_str($content); $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_reply", $reply_data); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set reply_count = reply_count + 1,last_time = " . get_gmtime() . ",last_user_id=" . $user_data['id'] . " where id = " . $share_id); increase_user_active($user_data['id'], "转发了一则分享"); if ($is_relay == 1) { $cnt = $topic['content'] . "@" . $user_data['user_name'] . " 评论:" . valid_str($content); $id = insert_topic($cnt, $title = "", $type = "", $group = "", $relay_id = $share_id, $fav_id = 0); if ($id) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($id)); } } $root['return'] = 1; $root['status'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $page = intval($GLOBALS['request']['page']) > 0 ? intval($GLOBALS['request']['page']) : 1; $page_size = 20; $limit = ($page - 1) * $page_size . "," . $page_size; $user_id = intval($GLOBALS['user_info']['id']); $sql = "select group_key,count(group_key) as total from " . DB_PREFIX . "msg_box \r\n\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) \r\n\t\t\t\tgroup by group_key \r\n\t\t\t\torder by system_msg_id desc,max(create_time) desc limit " . $limit; $sql_count = "select count(distinct(group_key)) from " . DB_PREFIX . "msg_box \r\n\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1))"; $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { $list[$k] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_box where group_key = '" . $v['group_key'] . "' and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) order by create_time desc limit 1"); $list[$k]['total'] = $v['total']; if ($list[$k]['system_msg_id'] > 0) { $sys_msgs[] = array("mid" => $list[$k]['group_key'], "uid" => $list[$k]['to_user_id'], "status" => 1, "title" => $list[$k]['title'], "time" => pass_date($list[$k]['create_time'])); } else { $msg_list[] = array("content" => $list[$k]['content'], "uid" => $list[$k]['from_user_id'], "user_name" => $list[$k]['from_user_id'] == $user_data['id'] ? "我" : $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . intval($list[$k]['from_user_id'])), "user_avatar" => get_abs_img_root(get_muser_avatar($list[$k]['from_user_id'], "big")), "tuid" => $list[$k]['to_user_id'], "tuser_name" => $list[$k]['to_user_id'] == $user_data['id'] ? "我" : $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . intval($list[$k]['to_user_id'])), "tuser_avatar" => get_abs_img_root(get_muser_avatar($list[$k]['to_user_id'], "big")), "time" => pass_date($list[$k]['create_time']), "msg_count" => $list[$k]['total'], "mlid" => $list[$k]['group_key']); } } $count = $GLOBALS['db']->getOne($sql_count); $root['return'] = 1; $root['sys_msgs'] = $sys_msgs; $root['msg_list'] = $msg_list; //分页 $page_info['page'] = $page; $page_info['page_total'] = ceil($count / $page_size); $root['page'] = $page_info; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } $comment_id = intval($GLOBALS['request']['id']); $comment_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic_reply where id = " . $comment_id); if ($comment_data['user_id'] != intval($user_data['id'])) { $root['return'] = 0; $root['info'] = "这条评论是其他会员的"; output($root); } $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic_reply where id = " . $comment_id); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set reply_count = reply_count - 1 where id = " . $comment_data['topic_id']); $root['return'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $home_uid = intval($GLOBALS['request']['uid']); $home_user_info_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $home_uid . " and is_effect = 1 and is_delete = 0"); if (!$home_user_info_data) { $root['info'] = "非法的会员"; output($root); } $user_info['uid'] = $user_data['id']; $user_info['email'] = $user_data['email']; $user_info['user_name'] = $user_data['user_name']; $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['user'] = $user_info; $home_user_info['uid'] = $home_user_info_data['id']; $home_user_info['email'] = $home_user_info_data['email']; $home_user_info['user_name'] = $home_user_info_data['user_name']; $home_user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($home_user_info_data['id'], "big")); $home_user_info['fans'] = $home_user_info_data['focused_count']; $home_user_info['follows'] = $home_user_info_data['focus_count']; $home_user_info['photos'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic_image where user_id = " . $home_user_info_data['id']); $home_user_info['favs'] = $GLOBALS['db']->getOne("select sum(fav_count) from " . DB_PREFIX . "topic where user_id = " . $home_user_info_data['id']); $root['home_user'] = $home_user_info; $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; $follow_list = $GLOBALS['db']->getAll("select focused_user_id as id,focused_user_name as user_name from " . DB_PREFIX . "user_focus where focus_user_id = " . $home_user_info_data['id'] . " order by id desc limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_focus where focus_user_id = " . $home_user_info_data['id']); $follows = array(); foreach ($follow_list as $k => $v) { $follows[$k]['uid'] = $v['id']; $follows[$k]['user_name'] = $v['user_name']; $follows[$k]['fans'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_focus where focused_user_id = " . $v['id']); $follows[$k]['user_avatar'] = get_abs_img_root(get_muser_avatar($v['id'], "big")); if ($v['id'] == $user_data['id']) { $follows[$k]['is_follow'] = -1; } else { $focus_uid = intval($v['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_info['uid'] . " and focused_user_id = " . $focus_uid); if ($focus_data) { $follows[$k]['is_follow'] = 1; } else { $follows[$k]['is_follow'] = 0; } } } $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); $root['item'] = $follows; $root['return'] = 1; $root['status'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $event_id = intval($GLOBALS['request']['event_id']); //没有分享ID直接退出 if ($event_id == 0) { $root['status'] = 0; $root['info'] = "不存在的活动ID"; output($root); } $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['status'] = 0; $root['user_login_status'] = 0; $root['info'] = "请先登录"; output($root); } $root['user_login_status'] = 1; $event_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "event where is_effect = 1 and id = " . $event_id); if (empty($event_info)) { $root['status'] = 0; $root['info'] = "不存在的活动ID"; output($root); } $reply_data = array(); $reply_data['rel_table'] = "event"; $reply_data['rel_id'] = intval($event_id); $reply_data['content'] = valid_str($content); if (app_conf("USER_MESSAGE_AUTO_EFFECT") == 0) { $message_effect = 0; } else { $message_effect = 1; //$message_type['is_effect']; } $reply_data['is_effect'] = $message_effect; $reply_data['create_time'] = get_gmtime(); $reply_data['user_id'] = intval($user_data['id']); $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $reply_data); increase_user_active($user_data['id'], "点评了一个活动"); $title = "对" . $event_info['name'] . "发表了点评"; $url_route = array('rel_app_index' => 'youhui', 'rel_route' => 'edetail', 'rel_param' => 'id=' . $event_info['id']); $tid = insert_topic($reply_data['content'], $title, "eventcomment", $group = "", $relay_id = 0, $fav_id = 0, $group_data = "", $attach_list = array(), $url_route); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($tid)); } $GLOBALS['db']->query("update " . DB_PREFIX . "event set reply_count = reply_count+1 where id =" . $event_id); $root['status'] = 1; $root['info'] = "感谢您的点评"; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $page = intval($GLOBALS['request']['page']) > 0 ? intval($GLOBALS['request']['page']) : 1; $page_size = 20; $limit = ($page - 1) * $page_size . "," . $page_size; $user_id = intval($GLOBALS['user_info']['id']); $group_key = addslashes(trim($GLOBALS['request']['mid'])); $sql = "select count(*) as count,max(system_msg_id) as system_msg_id,max(id) as id from " . DB_PREFIX . "msg_box \r\n\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) \r\n\t\t\t\tand group_key = '" . $group_key . "'"; $row = $GLOBALS['db']->getRow($sql); if ($row['count'] == 0) { $root['return'] = 0; } elseif ($row['system_msg_id'] > 0) { //系统消息,仅查看 $data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_box where id = " . $row['id'] . " and is_delete = 0"); $GLOBALS['db']->query("update " . DB_PREFIX . "msg_box set is_read = 1 where id = " . $row['id']); $root['return'] = 1; $root['msg'] = array('mid' => $group_key, 'title' => $data['title'], 'message' => $data['content'], 'time' => pass_date($data['create_time'])); } else { $root['return'] = 1; $root['lid'] = $group_key; //消息记录 $sql = "select * from " . DB_PREFIX . "msg_box \r\n\t\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) \r\n\t\t\t\t\tand group_key = '" . $group_key . "' \r\n\t\t\t\t\torder by create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "msg_box \r\n\t\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) and group_key = '" . $group_key . "'"; $upd_sql = "update " . DB_PREFIX . "msg_box set is_read = 1 \r\n\t\t\t\t\twhere is_delete = 0 and ((to_user_id = " . $user_id . " and `type` = 0) or (from_user_id = " . $user_id . " and `type` = 1)) \r\n\t\t\t\t\tand group_key = '" . $group_key . "' "; $GLOBALS['db']->query($upd_sql); $list = $GLOBALS['db']->getAll($sql); foreach ($list as $k => $v) { if ($v['to_user_id'] != $user_id) { $dest_user_id = $v['to_user_id']; break; } if ($v['from_user_id'] != $user_id) { $dest_user_id = $v['from_user_id']; break; } } $dest_user_name = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $dest_user_id); $root['title'] = "与" . $dest_user_name . "的交流"; $root['t_name'] = $dest_user_name; $count = $GLOBALS['db']->getOne($sql_count); $page_info['page'] = $page; $page_info['page_total'] = ceil($count / $page_size); $root['page'] = $page_info; $msg_list = array(); foreach ($list as $k => $v) { $msg_list[] = array("miid" => $v['id'], "mlid" => $v['group_key'], "uid" => $v['from_user_id'], "message" => $v['content'], "time" => pass_date($v['create_time']), "tuid" => $v['to_user_id'], "tuser_name" => $v['to_user_id'] == $user_id ? "我" : $dest_user_name, "tuser_avatar" => get_abs_img_root(get_muser_avatar($v['to_user_id'], "big")), "content" => $v['content'], "user_name" => $v['from_user_id'] == $user_id ? "我" : $dest_user_name, "user_avatar" => get_abs_img_root(get_muser_avatar($v['from_user_id'], "big"))); } $root['msg_list'] = $msg_list; } output($root); }
public function dologin() { if (!$_POST) { app_redirect("404.html"); exit; } if (!check_hash_key()) { showErr("非法请求!", $ajax); } foreach ($_POST as $k => $v) { $_POST[$k] = htmlspecialchars(addslashes($v)); } $ajax = intval($_REQUEST['ajax']); $_POST['user_pwd'] = strim(FW_DESPWD($_POST['user_pwd'])); require_once APP_ROOT_PATH . "system/libs/user.php"; if (check_ipop_limit(CLIENT_IP, "user_dologin", intval(app_conf("SUBMIT_DELAY")))) { $result = do_login_user($_POST['email'], $_POST['user_pwd']); } else { showErr($GLOBALS['lang']['SUBMIT_TOO_FAST'], $ajax, url("shop", "authorized#login")); } if ($result['status']) { $s_user_info = es_session::get("authorized_info"); $jump_url = url("index", "authorized#account"); $s_user_info = es_session::get("authorized_info"); if ($ajax == 1) { $return['status'] = 1; $return['info'] = $GLOBALS['lang']['LOGIN_SUCCESS']; $return['data'] = $result['msg']; $return['jump'] = $jump_url; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result', $result['msg']); showSuccess($GLOBALS['lang']['LOGIN_SUCCESS'], $ajax, $jump_url); } } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = $GLOBALS['lang']['USER_NOT_EXIST']; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = $GLOBALS['lang']['PASSWORD_ERROR']; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = $GLOBALS['lang']['USER_NOT_VERIFY']; if (app_conf("MAIL_ON") == 1 && $ajax == 0) { $GLOBALS['tmpl']->assign("page_title", $err); $GLOBALS['tmpl']->assign("user_info", $result['user']); $GLOBALS['tmpl']->display("verify_user.html"); exit; } } showErr($err, $ajax); } }
public function do_login() { $aqj_id = trim($_POST['log_aqjid']); $user_mobile = trim($_POST['log_mobile']); $user_pwd = trim($_POST['log_pwd']); $result = do_login_user($user_mobile, $user_pwd); $user_ap_partner = array(); $user_ap_partner['user_id'] = $result['user']['id']; $user_ap_partner['partner_id'] = 2; $user_ap_partner['partner_user_id'] = $aqj_id; $user_ap_partner['create_time'] = time(); $GLOBALS['db']->autoExecute(DB_PREFIX . "ap_partner_user", $user_ap_partner); app_redirect(url("aps")); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $uid = intval($user_data['id']); if ($uid == 0) { $root['info'] = "请先登陆"; output($root); } $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $user_info['uid'] = $user_data['id']; $user_info['email'] = $user_data['email']; $user_info['user_name'] = $user_data['user_name']; $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['home_user'] = $root['user'] = $user_info; //关注的用户ID $uids = $GLOBALS['db']->getOne("select group_concat(focused_user_id) from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_data['id'] . " order by rand() limit 50"); if ($uids) { $uids .= ",0"; } else { $uids = "0"; } $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id in (" . $uids . ") order by create_time desc limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and user_id in (" . $uids . ") "); foreach ($topic_list as $k => $v) { $topic_list[$k] = m_get_topic_item($v); if ($v['fav_id'] > 0 || $v['relay_id'] > 0) { $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']); } if ($relay_share) { $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share); } } $root = array(); $root['return'] = 1; $root['item'] = $topic_list; $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $user_info['uid'] = $user_data['id']; $user_info['email'] = $user_data['email']; $user_info['user_name'] = $user_data['user_name']; $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; $list = $GLOBALS['db']->getAll("select id,user_name,daren_title from " . DB_PREFIX . "user where is_delete = 0 and is_effect = 1 and is_daren = 1 order by id desc limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where is_delete = 0 and is_effect = 1 and is_daren = 1 "); $darens = array(); foreach ($list as $k => $v) { $darens[$k]['uid'] = $v['id']; $darens[$k]['user_name'] = $v['user_name']; if ($v['daren_title'] != '') { $darens[$k]['user_name'] .= "[" . $v['daren_title'] . "]"; } $darens[$k]['fans'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user_focus where focused_user_id = " . $v['id']); $darens[$k]['user_avatar'] = get_abs_img_root(get_muser_avatar($v['id'], "big")); if ($v['id'] == $user_data['id']) { $darens[$k]['is_follow'] = -1; } else { $focus_uid = intval($v['id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_info['uid'] . " and focused_user_id = " . $focus_uid); if ($focus_data) { $darens[$k]['is_follow'] = 1; } else { $darens[$k]['is_follow'] = 0; } } } $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); $root['item'] = $darens; $root['return'] = 1; $root['status'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $id = intval($GLOBALS['request']['share_id']); $page = intval($GLOBALS['request']['page']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $root = array(); $root['return'] = 1; $res = m_get_topic_reply($id, $page); $root['item'] = $res['list']; $root['page'] = $res['page']; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $uid = intval($user_data['id']); if ($uid == 0) { $root['return'] = 0; $root['info'] = "请先登陆"; output($root); } $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; //输出回复 $sql = "select r.* from " . DB_PREFIX . "topic_reply as r left join " . DB_PREFIX . "topic as t on r.topic_id = t.id \r\n\t\t\t\twhere (t.user_id = " . $uid . " or r.user_id = " . $uid . ") and r.is_effect = 1 and r.is_delete = 0 \r\n\t\t\t\torder by r.create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "topic_reply as r left join " . DB_PREFIX . "topic as t on r.topic_id = t.id \r\n\t\t\t\twhere (t.user_id = " . $uid . " or r.user_id = " . $uid . ") and r.is_effect = 1 and r.is_delete = 0"; $list = $GLOBALS['db']->getAll($sql); $total = $GLOBALS['db']->getOne($sql_count); $comment_list = array(); foreach ($list as $k => $v) { $comment_list[$k]['comment_id'] = $v['id']; $comment_list[$k]['share_id'] = $v['topic_id']; $comment_list[$k]['uid'] = $v['user_id']; $comment_list[$k]['parent_id'] = $v['reply_id']; $comment_list[$k]['content'] = $v['content']; $comment_list[$k]['create_time'] = $v['create_time']; $topic = $GLOBALS['db']->getRow("select user_name,content from " . DB_PREFIX . "topic where id = " . $v['topic_id']); $comment_list[$k]['scontent'] = "//@" . $topic['user_name'] . ":" . $topic['content']; $comment_list[$k]['user_name'] = $v['user_name']; $comment_list[$k]['user_avatar'] = get_abs_img_root(get_muser_avatar($v['user_id'], "big")); $comment_list[$k]['time'] = pass_date($v['create_time']); $comment_list[$k]['parse_expres'] = get_parse_expres($comment_list[$k]['content'] . $comment_list[$k]['scontent']); $comment_list[$k]['parse_user'] = get_parse_user($comment_list[$k]['content'] . $comment_list[$k]['scontent']); } $root['item'] = $comment_list; $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); $root['return'] = 1; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } //$func_name = strim($GLOBALS['request']['type'])."_".strim($GLOBALS['request']['login_type']); $func_name = strim($GLOBALS['request']['login_type']); $func_name(); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $username = strim($GLOBALS['request']['user_name']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); if ($GLOBALS['user_info']) { $user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where user_name = '" . $username . "'"); $content = htmlspecialchars(addslashes(trim($GLOBALS['request']['message']))); send_user_msg("", $content, intval($GLOBALS['user_info']['id']), $user_id, get_gmtime()); $root['return'] = 1; } else { $root['return'] = 0; $root['info'] = "请先登录"; } output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $uid = intval($user_data['id']); if ($uid == 0) { $root['info'] = "请先登陆"; output($root); } $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $user_info['uid'] = $user_data['id']; $user_info['email'] = $user_data['email']; $user_info['user_name'] = $user_data['user_name']; $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['home_user'] = $root['user'] = $user_info; $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; $user_name = $user_data['user_name']; $user_name_unicode = str_to_unicode_string($user_name); $condition = " match(user_name_match) against('" . $user_name_unicode . "' IN BOOLEAN MODE) "; $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition . " order by create_time desc limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition); foreach ($topic_list as $k => $v) { $topic_list[$k] = m_get_topic_item($v); if ($v['fav_id'] > 0 || $v['relay_id'] > 0) { $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']); } if ($relay_share) { $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share); } } $root = array(); $root['return'] = 1; $root['item'] = $topic_list; $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $uid = intval($GLOBALS['request']['uid']); if ($uid == 0) { $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $uid = $user_data['id']; } $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $page_size = 20; $limit = ($page - 1) * $page_size . "," . $page_size; $root = array(); $root['return'] = 1; $condition = " 1 = 1 "; $sort = ""; $condition .= " and user_id = " . $uid . " and fav_id <> 0 "; $sort .= " order by t.create_time desc "; $sql = "select t.id,t.fav_id,t.origin_id from " . DB_PREFIX . "topic as t where " . $condition . $sort . " limit " . $limit; $sql_total = "select count(*) from " . DB_PREFIX . "topic as t where " . $condition; $total = $GLOBALS['db']->getOne($sql_total); $result = $GLOBALS['db']->getAll($sql); $share_list = array(); foreach ($result as $k => $v) { $share_list[$k]['share_id'] = $v['fav_id']; $image = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic_image where topic_id = " . $v['origin_id'] . " limit 1"); $share_list[$k]['img'] = get_abs_img_root(get_spec_image($image['o_path'], 200, 0, 0)); $share_list[$k]['height'] = floor($image['height'] * (200 / $image['width'])); } $root['item'] = $share_list; //分页 $page_info['page'] = $page; $page_info['page_total'] = ceil($total / $page_size); $root['page'] = $page_info; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $uid = intval($GLOBALS['request']['uid']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } //开始关注 $user_id = intval($user_data['id']); $focus_uid = $uid; if ($user_id != $focus_uid) { $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if (!$focus_data && $user_id > 0 && $focus_uid > 0) { $focused_user_name = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $focus_uid); $focus_data = array(); $focus_data['focus_user_id'] = $user_id; $focus_data['focused_user_id'] = $focus_uid; $focus_data['focus_user_name'] = $GLOBALS['user_info']['user_name']; $focus_data['focused_user_name'] = $focused_user_name; $GLOBALS['db']->autoExecute(DB_PREFIX . "user_focus", $focus_data, "INSERT"); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count + 1 where id = " . $user_id); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count + 1 where id = " . $focus_uid); } elseif ($focus_data && $user_id > 0 && $focus_uid > 0) { $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count - 1 where id = " . $user_id); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count - 1 where id = " . $focus_uid); } } //开始关注 $root['status'] = 1; output($root); }
public function user_register() { require_once APP_ROOT_PATH . "system/libs/user.php"; $return = $this->mobile_register_check_all(); if ($return['status'] == 0) { ajax_return($return); } $user_data = $_POST; foreach ($_POST as $k => $v) { $user_data[$k] = strim($v); } $user_data['is_effect'] = 1; if (app_conf("USER_VERIFY") == 2) { if ($user_data["mobile"] == "") { $data[] = array("type" => "form_error", "field" => "mobile", "info" => "请输入手机号码"); ajax_return(array("status" => 0, "data" => $data)); } if ($user_data["verify_coder"] == "") { $data[] = array("type" => "form_error", "field" => "verify_coder", "info" => "请输入验证码"); ajax_return(array("status" => 0, "data" => $data)); } if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "mobile_verify_code where mobile ='" . $user_data['mobile'] . "' and verify_code='" . $user_data["verify_coder"] . "' order by create_time desc") == 0) { $data[] = array("type" => "form_error", "field" => "verify_coder", "info" => "验证码错误"); ajax_return(array("status" => 0, "data" => $data)); } if (app_conf("SMS_ON") == 1) { $user_data['is_effect'] = 1; } else { $user_data['is_effect'] = 0; } } $res = save_mobile_user($user_data); if ($res['status'] == 1) { if (!check_ipop_limit(get_client_ip(), "user_do_register", 5)) { showErr("提交太快", 1); } $user_id = intval($res['data']); $user_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); if ($user_info['is_effect'] == 1) { //send_register_success(0,$user_data); do_login_user($user_data['user_name'], $user_data['user_pwd']); ajax_return(array("status" => 1, "jump" => get_gopreview())); } else { ajax_return(array("status" => 0, "info" => "请等待管理员审核")); } } else { $error = $res['data']; if ($error['field_name'] == "user_name") { $data[] = array("type" => "form_success", "field" => "user_name", "info" => ""); $field_name = "会员帐号"; } if ($error['field_name'] == "mobile") { $data[] = array("type" => "form_success", "field" => "mobile", "info" => ""); $field_name = "手机号码"; } if ($error['error'] == EMPTY_ERROR) { $error_info = "不能为空"; $type = "form_tip"; } if ($error['error'] == FORMAT_ERROR) { $error_info = "格式有误"; $type = "form_error"; } if ($error['error'] == EXIST_ERROR) { $error_info = "已存在"; $type = "form_error"; } $data[] = array("type" => $type, "field" => $error['field_name'], "info" => $field_name . $error_info); ajax_return(array("status" => 0, "data" => $data, "info" => "")); } }
public function do_api_login() { $api_info = es_session::get("api_user_info"); if (!$api_info) { app_redirect_preview(); } if (!$_POST) { app_redirect(APP_ROOT . "/"); } foreach ($_POST as $k => $v) { $_POST[$k] = strim($v); } $ajax = intval($_REQUEST['ajax']); if (!check_ipop_limit(get_client_ip(), "user_do_api_login", 5)) { showErr("提交太快", $ajax); } require_once APP_ROOT_PATH . "system/libs/user.php"; $result = do_login_user($_POST['email'], $_POST['user_pwd']); if ($result['status']) { $s_user_info = es_session::get("user_info"); $GLOBALS['db']->query("update " . DB_PREFIX . "user set " . $api_info['field'] . " = '" . $api_info['name'] . "'," . $api_info['token_field'] . " = '" . $api_info['token'] . "'," . $api_info['secret_field'] . " = '" . $api_info['secret'] . "'," . $api_info['url_field'] . " = '" . $api_info['url'] . "' where id = " . $s_user_info['id']); $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_weibo where user_id = " . intval($s_user_info['id']) . " and weibo_url = '" . $api_info['url'] . "'"); update_user_weibo(intval($s_user_info['id']), $api_info['url']); if ($ajax == 0 && trim(app_conf("INTEGRATE_CODE")) == '') { $redirect = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : url("index"); app_redirect($redirect); } else { $jump_url = get_gopreview(); if ($ajax == 1) { $return['status'] = 1; $return['info'] = "登录成功"; $return['data'] = $result['msg']; $return['jump'] = $jump_url; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result', $result['msg']); showSuccess("登录成功", $ajax, $jump_url); } } } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = "会员不存在"; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = "密码错误"; } showErr($err, $ajax); } }
public function wx_do_register() { $user_info = array(); $user_info['mobile'] = strim($_REQUEST['mobile']); $user_info['verify_coder_email'] = strim($_REQUEST['verify_coder_email']); $user_info['verify_coder'] = strim($_REQUEST['verify_coder']); $user_info['wx_openid'] = strim($_REQUEST['wx_openid']); $user_info['user_name'] = strim($_REQUEST['user_name']); $user_info['province'] = strim($_REQUEST['province']); $user_info['email'] = strim($_REQUEST['email']); $user_info['city'] = strim($_REQUEST['city']); $user_info['sex'] = strim($_REQUEST['sex']); if (app_conf('USER_VERIFY') == 2 || app_conf('USER_VERIFY') == 4) { if (!$user_info['mobile']) { $data['status'] = 0; $data['info'] = "手机号码为空"; ajax_return($data); } if ($user_info['verify_coder'] == "") { $data['status'] = 0; $data['info'] = "手机验证码为空"; ajax_return($data); } //判断验证码是否正确============================= if ($GLOBALS['db']->getOne("SELECT count(*) FROM " . DB_PREFIX . "mobile_verify_code WHERE mobile=" . $user_info['mobile'] . " AND verify_code='" . $user_info['verify_coder'] . "'") == 0) { $data['status'] = 0; $data['info'] = "手机验证码错误"; ajax_return($data); } $user = get_user_has('mobile', $user_info['mobile']); } require_once APP_ROOT_PATH . "system/libs/user.php"; if ($user) { if ($user_info['wx_openid']) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set wx_openid='" . $user_info['wx_openid'] . "' where id=" . $user['id']); } $user_id = $user['id']; } else { if (app_conf("USER_VERIFY") != 2) { if (!$user_info['email']) { $data['status'] = 0; $data['info'] = "邮箱为空"; ajax_return($data); } if (!check_email($user_info['email'])) { $data['status'] = 0; $data['info'] = "邮箱格式错误"; ajax_return($data); } if (app_conf('USER_VERIFY') == 1 || app_conf('USER_VERIFY') == 4) { if ($user_info['verify_coder_email'] == "") { $data['status'] = 0; $data['info'] = "邮件验证码为空"; ajax_return($data); } } $user = get_user_has('email', $user_info['email']); } if ($user) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set wx_openid='" . $user_info['wx_openid'] . "' where id=" . $user['id']); $user_id = $user['id']; } else { $has_user_name = get_user_has('user_name', $user_info['user_name']); if ($has_user_name) { $user_info['user_name'] = $user_info['user_name'] . rand(10000, 99999); } if ($user_info['sex'] == 0) { $user_info['sex'] = -1; } elseif ($user_info['sex'] == 1) { $user_info['sex'] = 1; } else { $user_info['sex'] = 0; } //开启邮箱验证 if (app_conf("USER_VERIFY") != 3) { $user_info['is_effect'] = 1; } else { $user_info['is_effect'] = 0; } $user_info['create_time'] = get_gmtime(); $user_info['update_time'] = get_gmtime(); //新建用户 使用验证码作为密码 $user_info['user_pwd'] = $user_info['verify_coder']; //$GLOBALS['db']->autoExecute(DB_PREFIX."user",$user_info,"INSERT"); $res = save_user($user_info); if ($res['status'] == 0) { $data['status'] = 0; $data['info'] = $res['data']['field_name'] . '错误'; ajax_return($data); } $user_id = intval($res['data']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set user_name='" . strim($_REQUEST['user_name']) . "_" . $user_id . "' where id=" . $user_id); } } $user_info_new = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); if ($user_info_new['is_effect'] == 1) { if ($user_info_new['mobile']) { $name = $user_info_new['mobile']; } elseif ($user_info_new['email']) { $name = $user_info_new['email']; } else { $name = $user_info_new['user_name']; } $result = do_login_user($name, $user_info_new['user_pwd']); ajax_return(array("status" => 1, "info" => $result['msg'], "jump" => url_wap("index"))); } else { ajax_return(array("status" => 0, "info" => "请等待管理员审核")); } }
public function dologin() { if (!$_POST) { app_redirect("404.html"); exit; } foreach ($_POST as $k => $v) { $_POST[$k] = htmlspecialchars(addslashes($v)); } $ajax = intval($_REQUEST['ajax']); if (!check_hash_key()) { showErr("非法请求!", $ajax); } //验证码 if (app_conf("VERIFY_IMAGE") == 1) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if ($verify != $session_verify) { showErr($GLOBALS['lang']['VERIFY_CODE_ERROR'], $ajax, url("shop", "user#login")); } } require_once APP_ROOT_PATH . "system/libs/user.php"; $_POST['user_pwd'] = trim(FW_DESPWD($_POST['user_pwd'])); if (check_ipop_limit(CLIENT_IP, "user_dologin", intval(app_conf("SUBMIT_DELAY")))) { $result = do_login_user($_POST['email'], $_POST['user_pwd']); } else { showErr($GLOBALS['lang']['SUBMIT_TOO_FAST'], $ajax, url("shop", "user#login")); } if ($result['status']) { $s_user_info = es_session::get("user_info"); if (intval($_POST['auto_login']) == 1) { //自动登录,保存cookie $user_data = $s_user_info; es_cookie::set("user_name", $user_data['email'], 3600 * 24 * 30); es_cookie::set("user_pwd", md5($user_data['user_pwd'] . "_EASE_COOKIE"), 3600 * 24 * 30); } if ($ajax == 0 && trim(app_conf("INTEGRATE_CODE")) == '') { $redirect = $_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : url("index"); app_redirect($redirect); } else { $jump_url = get_gopreview(); $s_user_info = es_session::get("user_info"); if ($s_user_info['ips_acct_no'] == "" && app_conf("OPEN_IPS")) { if ($ajax == 1) { $return['status'] = 2; $return['info'] = "本站需绑定第三方托管账户,是否马上去绑定"; $return['data'] = $result['msg']; $return['jump'] = $jump_url; $return['jump1'] = APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $s_user_info['id']; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result', $result['msg']); showSuccess($GLOBALS['lang']['LOGIN_SUCCESS'], $ajax, $jump_url); } } else { if ($ajax == 1) { $return['status'] = 1; $return['info'] = $GLOBALS['lang']['LOGIN_SUCCESS']; $return['data'] = $result['msg']; $return['jump'] = $jump_url; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result', $result['msg']); showSuccess($GLOBALS['lang']['LOGIN_SUCCESS'], $ajax, $jump_url); } } } } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = $GLOBALS['lang']['USER_NOT_EXIST']; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = $GLOBALS['lang']['PASSWORD_ERROR']; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = $GLOBALS['lang']['USER_NOT_VERIFY']; if (app_conf("MAIL_ON") == 1 && $ajax == 0) { $GLOBALS['tmpl']->assign("page_title", $err); $GLOBALS['tmpl']->assign("user_info", $result['user']); $GLOBALS['tmpl']->display("verify_user.html"); exit; } } showErr($err, $ajax); } }
public function dologin() { if (!$_POST) { app_redirect("404.html"); exit; } foreach ($_POST as $k => $v) { $_POST[$k] = htmlspecialchars(addslashes($v)); } $ajax = intval($_REQUEST['ajax']); //验证码 /*if(app_conf("VERIFY_IMAGE")==1) { $verify = md5(trim($_REQUEST['verify'])); $session_verify = es_session::get('verify'); if($verify!=$session_verify) { showErr($GLOBALS['lang']['VERIFY_CODE_ERROR'],$ajax,url("shop","user#login")); } }*/ require_once APP_ROOT_PATH . "system/libs/manageagency.php"; if (check_ipop_limit(get_client_ip(), "user_dologin", intval(app_conf("SUBMIT_DELAY")))) { $result = do_login_user($_POST['email'], $_POST['user_pwd']); } else { showErr($GLOBALS['lang']['SUBMIT_TOO_FAST'], $ajax, url("shop", "manageagency#login")); } if ($result['status']) { $s_user_info = es_session::get("user_info"); $jump_url = url("index", "manageagency#account"); $s_user_info = es_session::get("manageagency_info"); /*if($s_user_info['ips_acct_no']=="" && app_conf("OPEN_IPS")){ if($ajax==1) { $return['status'] = 2; $return['info'] = "本站需绑定第三方托管账户,是否马上去绑定"; $return['data'] = $result['msg']; $return['jump'] = $jump_url; $return['jump1'] = APP_ROOT."/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=".$s_user_info['id']; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result',$result['msg']); showSuccess($GLOBALS['lang']['LOGIN_SUCCESS'],$ajax,$jump_url); } }*/ //else{ if ($ajax == 1) { $return['status'] = 1; $return['info'] = $GLOBALS['lang']['LOGIN_SUCCESS']; $return['data'] = $result['msg']; $return['jump'] = $jump_url; ajax_return($return); } else { $GLOBALS['tmpl']->assign('integrate_result', $result['msg']); showSuccess($GLOBALS['lang']['LOGIN_SUCCESS'], $ajax, $jump_url); } //} } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = $GLOBALS['lang']['USER_NOT_EXIST']; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = $GLOBALS['lang']['PASSWORD_ERROR']; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = $GLOBALS['lang']['USER_NOT_VERIFY']; if (app_conf("MAIL_ON") == 1 && $ajax == 0) { $GLOBALS['tmpl']->assign("page_title", $err); $GLOBALS['tmpl']->assign("user_info", $result['user']); $GLOBALS['tmpl']->display("verify_user.html"); exit; } } showErr($err, $ajax); } }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 //var_dump($GLOBALS); $result = do_login_user($email, $pwd); var_dump($result); if ($result['status']) { $user_data = es_session::get('user_info'); $root['return'] = 1; $root['user_login_status'] = 1; //用户登陆状态:1:成功登陆;0:未成功登陆 $root['info'] = "用户登陆成功"; $root['uid'] = $user_data['id']; $root['user_name'] = $user_data['user_name']; $root['user_email'] = $user_data['email']; $root['user_money'] = $user_data['money']; $root['user_money_format'] = format_price($user_data['money']); //用户金额 $root['home_user']['fans'] = $user_data['focused_count']; $root['home_user']['photos'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic_image where user_id = " . $user_data['id']); $root['home_user']['goods'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $user_data['id'] . " and topic_group = 'Fanwe' and is_delete = 0 and is_effect = 1"); $root['home_user']['follows'] = $user_data['focus_count']; $root['home_user']['favs'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $user_data['id'] . " and fav_id <> 0"); $root['home_user']['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); if (strim($GLOBALS['request']['sina_id']) != '') { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where sina_id = '" . strim($GLOBALS['request']['sina_id']) . "'") == 0) { $access_token = trim($GLOBALS['request']['access_token']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_id = '" . strim($GLOBALS['request']['sina_id']) . "',sina_token = '" . $access_token . "' where id = " . $user_data['id']); } } if (strim($GLOBALS['request']['tencent_id']) != '') { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where tencent_id = '" . strim($GLOBALS['request']['tencent_id']) . "'") == 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set tencent_id = '" . strim($GLOBALS['request']['tencent_id']) . "' where id = " . $user_data['id']); $openid = trim($GLOBALS['request']['openid']); $openkey = trim($GLOBALS['request']['openkey']); $access_token = trim($GLOBALS['request']['access_token']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token ='" . $access_token . "',t_openkey = '" . $openkey . "',t_openid = '" . $openid . "', login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . " where id =" . $user_data['id']); } } } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = "会员不存在"; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = "密码错误"; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = "会员未通过验证"; } $root['return'] = 0; $root['user_login_status'] = 0; //用户登陆状态:1:成功登陆;0:未成功登陆 $root['info'] = $err; $root['uid'] = 0; $root['user_name'] = $email; $root['user_email'] = $email; } if (strim($GLOBALS['request']['sina_id']) != '') { $root['login_type'] = "Sina"; } if (strim($GLOBALS['request']['tencent_id']) != '') { $root['login_type'] = "Tencent"; } $root['act'] = "login"; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/model/user.php"; $email = strim($GLOBALS['request']['email']); //用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); //密码 $city_name = strim($GLOBALS['request']['city_name']); //城市名称 if ($email != "" && $pwd != "") { $result = do_login_user($email, $pwd); if ($result['status']) { $user_data = es_session::get('user_info'); $root['return'] = 1; $root['user_login_status'] = 1; //用户登陆状态:1:成功登陆;0:未成功登陆 $root['info'] = "用户登陆成功"; $root['uid'] = $user_data['id']; $root['user_name'] = $user_data['user_name']; $root['user_pwd'] = $user_data['user_pwd']; $root['user_email'] = $user_data['email']; $root['user_money'] = $user_data['money']; $root['user_money_format'] = format_price($user_data['money']); //用户金额 $root['user_score'] = $user_data['score']; //用户积分 $root['home_user']['fans'] = $user_data['focused_count']; $root['home_user']['photos'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic_image where user_id = " . $user_data['id']); $root['home_user']['goods'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $user_data['id'] . " and topic_group = 'Fanwe' and is_delete = 0 and is_effect = 1"); $root['home_user']['follows'] = $user_data['focus_count']; $root['home_user']['favs'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where user_id = " . $user_data['id'] . " and fav_id <> 0"); $root['home_user']['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); if (strim($GLOBALS['request']['sina_id']) != '') { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where sina_id = '" . strim($GLOBALS['request']['sina_id']) . "'") == 0) { $access_token = trim($GLOBALS['request']['access_token']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set sina_id = '" . strim($GLOBALS['request']['sina_id']) . "',sina_token = '" . $access_token . "' where id = " . $user_data['id']); } } if (strim($GLOBALS['request']['tencent_id']) != '') { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where tencent_id = '" . strim($GLOBALS['request']['tencent_id']) . "'") == 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set tencent_id = '" . strim($GLOBALS['request']['tencent_id']) . "' where id = " . $user_data['id']); $openid = trim($GLOBALS['request']['openid']); $openkey = trim($GLOBALS['request']['openkey']); $access_token = trim($GLOBALS['request']['access_token']); $GLOBALS['db']->query("update " . DB_PREFIX . "user set t_access_token ='" . $access_token . "',t_openkey = '" . $openkey . "',t_openid = '" . $openid . "', login_ip = '" . get_client_ip() . "',login_time= " . get_gmtime() . " where id =" . $user_data['id']); } } if (strim($GLOBALS['request']['qq_id']) != '') { if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "user where qq_id = '" . strim($GLOBALS['request']['qq_id']) . "'") == 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set qq_id = '" . strim($GLOBALS['request']['qq_id']) . "' where id = " . $user_data['id']); } } } else { if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = "会员不存在"; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = "密码错误"; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = "会员未通过验证"; } $root['return'] = 0; $root['user_login_status'] = 0; //用户登陆状态:1:成功登陆;0:未成功登陆 $root['info'] = $err; $root['uid'] = 0; $root['user_name'] = $email; $root['user_email'] = $email; } if (strim($GLOBALS['request']['sina_id']) != '') { $root['login_type'] = "Sina"; } if (strim($GLOBALS['request']['tencent_id']) != '') { $root['login_type'] = "Tencent"; } } else { $root['return'] = 0; $root['user_login_status'] = 0; //用户登陆状态:1:成功登陆;0:未成功登陆 $root['info'] = "用户或密码不能为空"; $root['uid'] = 0; $root['user_name'] = $email; } if ($email) { $root['page_title'] = "我的账户"; $root['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); } else { $root['page_title'] = "登陆"; $api = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "api_login where class_name = 'Qqv2'"); if ($api) { $class_name = $api['class_name']; if (file_exists(APP_ROOT_PATH . "system/api_login/" . $class_name . "_api.php")) { require_once APP_ROOT_PATH . "system/api_login/" . $class_name . "_api.php"; $api_class = $class_name . "_api"; $api_obj = new $api_class($api); $url = $api_obj->get_api_url(); //$root['qq_login1'] = $url; $domain = app_conf("PUBLIC_DOMAIN_ROOT") == '' ? get_domain() . APP_ROOT . $GLOBALS['IMG_APP_ROOT'] : app_conf("PUBLIC_DOMAIN_ROOT"); $url = str_replace("./public/", $domain . "/public/", $url); $url = str_replace('sjmapi/', '', $url); $root['qq_login'] = $url; } } } $root['city_name'] = $city_name; $root['act'] = "login"; output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $root = array(); $content = strim($GLOBALS['request']['content']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); if (intval($user_data['id']) == 0) { $root['return'] = 0; $root['info'] = "请先登录"; output($root); } if (isset($_FILES['image_1'])) { //开始上传 //上传处理 //创建comment目录 if (!is_dir(APP_ROOT_PATH . "public/comment")) { @mkdir(APP_ROOT_PATH . "public/comment"); @chmod(APP_ROOT_PATH . "public/comment", 0777); } $dir = to_date(get_gmtime(), "Ym"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "d"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } $dir = $dir . "/" . to_date(get_gmtime(), "H"); if (!is_dir(APP_ROOT_PATH . "public/comment/" . $dir)) { @mkdir(APP_ROOT_PATH . "public/comment/" . $dir); @chmod(APP_ROOT_PATH . "public/comment/" . $dir, 0777); } if (app_conf("IS_WATER_MARK") == 1) { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 1, 1); } else { $img_result = save_image_upload($_FILES, "image_1", "comment/" . $dir, $whs = array('thumb' => array(100, 100, 1, 0)), 0, 1); } if (app_conf("PUBLIC_DOMAIN_ROOT") != '') { $paths = pathinfo($img_result['topic_image']['url']); $path = str_replace("./", "", $paths['dirname']); $filename = $paths['basename']; $pathwithoupublic = str_replace("public/", "", $path); $syn_url = app_conf("PUBLIC_DOMAIN_ROOT") . "/es_file.php?username="******"IMAGE_USERNAME") . "&password="******"IMAGE_PASSWORD") . "&file=" . get_domain() . APP_ROOT . "/" . $path . "/" . $filename . "&path=" . $pathwithoupublic . "/&name=" . $filename . "&act=0"; @file_get_contents($syn_url); } require_once APP_ROOT_PATH . "system/utils/es_imagecls.php"; $image = new es_imagecls(); $info = $image->getImageInfo($img_result['image_1']['path']); $image_data['width'] = intval($info[0]); $image_data['height'] = intval($info[1]); $image_data['name'] = valid_str($_FILES['image_1']['name']); $image_data['filesize'] = filesize($img_result['image_1']['path']); $image_data['create_time'] = get_gmtime(); $image_data['user_id'] = intval($GLOBALS['user_info']['id']); $image_data['user_name'] = addslashes($GLOBALS['user_info']['user_name']); $image_data['path'] = $img_result['image_1']['thumb']['thumb']['url']; $image_data['o_path'] = $img_result['image_1']['url']; $GLOBALS['db']->autoExecute(DB_PREFIX . "topic_image", $image_data); $image_id = intval($GLOBALS['db']->insert_id()); //end 上传 } if ($image_id > 0) { $attach_list = array(array("id" => $image_id, "type" => "image")); } else { $attach_list = array(); } $id = insert_topic(valid_str($content), $title = "", $type = "", $group = "", $relay_id = 0, $fav_id = 0, $group_data = array(), $attach_list); if ($id) { increase_user_active($user_data['id'], "发表了一则分享"); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($id)); } $syn_data['content'] = $content; //$syn_data['img'] = get_abs_img_root($GLOBALS['db']->getOne("select o_path from ".DB_PREFIX."topic_image where id = ".intval($image_id))); $syn_data['img'] = $GLOBALS['db']->getOne("select o_path from " . DB_PREFIX . "topic_image where id = " . intval($image_id)); if ($syn_data['img']) { $syn_data['img'] = APP_ROOT_PATH . $syn_data['img']; } //开始同步 if (intval($GLOBALS['request']['is_syn_sina'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_sina = 1 where id = ".intval($user_data['id'])); //$func_name = strim($GLOBALS['request']['type'])."_Sina"; //$result_sina = $func_name($syn_data); $result_sina = Sina($syn_data); $ext_info = ""; if (!$result_sina['status']) { if (intval($result_sina['code']) == 21316 || intval($result_sina['code']) == 21317) { $ext_info .= " 请先绑定新浪微博"; } if (intval($result_sina['code']) == 21314 || intval($result_sina['code']) == 21315) { $ext_info .= " 新浪微博授权过期"; } } } if (intval($GLOBALS['request']['is_syn_tencent'])) { //$GLOBALS['db']->query("update ".DB_PREFIX."user set is_syn_tencent = 1 where id = ".intval($user_data['id'])); // $func_name = strim($GLOBALS['request']['type'])."_Tencent"; // $result_tencent = $func_name($syn_data); $result_tencent = Tencent($syn_data); if (!$result_tencent['status']) { if (intval($result_tencent['code']) == 0) { $ext_info .= " 请先绑定腾讯微博"; } if (intval($result_tencent['code']) == 14) { $ext_info .= " 腾讯微博未实名认证"; } if (intval($result_tencent['code']) == 10017 || intval($result_tencent['code']) == 10018 || intval($result_tencent['code']) == 10019 || intval($result_tencent['code']) == 36 || intval($result_tencent['code']) == 37 || intval($result_tencent['code']) == 38) { $ext_info .= " 腾讯微博授权过期"; } } } $root['return'] = 1; $root['status'] = 1; $root['info'] = "发布成功" . $ext_info; output($root); }
public function aqj_do_login() { $aqj_id = trim($_POST['log_aqjid']); $user_mobile = trim($_POST['log_mobile']); $user_pwd = trim($_POST['log_pwd']); require_once APP_ROOT_PATH . "system/libs/user.php"; $result = do_login_user($user_mobile, $user_pwd); if ($result['status'] == "1") { //登录成功,跳转到积分商城, $xlc_user = $GLOBALS['db']->getRow("select id,mobile,user_pwd from " . DB_PREFIX . "user where mobile='" . $user_mobile . "'"); $aqj_user = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "ap_partner_user where user_id=" . $xlc_user['id']); if ($aqj_user) { //存在新乐筹用户,更新绑定 $user_ap_partner = array(); $user_ap_partner['partner_user_id'] = $aqj_id; $user_ap_partner['edit_time'] = time(); $GLOBALS['db']->autoExecute(DB_PREFIX . "ap_partner_user", $user_ap_partner, "UPDATE", "id=" . intval($aqj_user['id'])); } else { //插入新用户 $user_ap_partner = array(); $user_ap_partner['user_id'] = $result['user']['id']; $user_ap_partner['partner_id'] = 2; $user_ap_partner['partner_user_id'] = $aqj_id; $user_ap_partner['create_time'] = time(); $GLOBALS['db']->autoExecute(DB_PREFIX . "ap_partner_user", $user_ap_partner); } $result['msg'] = "登录中..."; $result['jump'] = url_wap("deals", array('aqjid' => $aqj_id, 'm' => $user_mobile, 'isap' => 1)); } else { //提示登录失败 switch ($result['data']) { case "1": $result['msg'] = '对不起,帐户不存在。'; break; case "2": $result['msg'] = '对不起,帐户密码错误。'; break; case "3": $result['msg'] = '对不起,帐户未激活。'; break; } } ajax_return($result); }
public function wx_do_register() { $user_info = array(); $referer = $_REQUEST['referer']; $user_info['mobile'] = strim($_REQUEST['mobile']); //$user_info['verify_coder']=strim($_REQUEST['code']); $user_info['wx_openid'] = strim($_REQUEST['wx_openid']); $user_info['user_name'] = strim($_REQUEST['user_name']); $user_info['province'] = strim($_REQUEST['province']); $user_info['email'] = strim($_REQUEST['email']); $user_info['city'] = strim($_REQUEST['city']); $user_info['sex'] = strim($_REQUEST['sex']); $user_pwd = $_REQUEST['password']; $user_new_pwd = $_REQUEST['new_password']; if (!$user_info['mobile']) { $data['status'] = 0; $data['info'] = "手机号码为空"; ajax_return($data); } /* if($user_info['verify_coder']==""){ $data['status'] = 0; $data['info'] = "手机验证码为空"; ajax_return($data); } */ if ($user_pwd == "") { $data['status'] = 0; $data['info'] = "密码为空"; ajax_return($data); } if (strlen($user_pwd) < 4 || strlen($user_pwd) > 12) { $data['status'] = 0; $data['info'] = "密码请输入4~12个字符"; ajax_return($data); } if ($user_pwd != $user_new_pwd) { $data['status'] = 0; $data['info'] = "确认密码与密码不符"; ajax_return($data); } /* //判断验证码是否正确============================= if($GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."mobile_verify_code WHERE mobile=".$user_info['mobile']." AND verify_code='".$user_info['verify_coder']."'")==0){ $data['status'] = 0; $data['info'] = "手机验证码错误"; ajax_return($data); } */ $user = get_user_has('mobile', $user_info['mobile']); require_once APP_ROOT_PATH . "system/libs/user.php"; if ($user) { $GLOBALS['db']->query("update " . DB_PREFIX . "user set wx_openid='" . $user_info['wx_openid'] . "' where id=" . $user['id']); $user_id = $user['id']; } else { /* if(!$user_info['email']) { $data['status'] = 0; $data['info'] = "邮箱为空"; ajax_return($data); } if(!check_email($user_info['email'])){ $data['status'] = 0; $data['info'] = "邮箱格式错误"; ajax_return($data); } $has_email=get_user_has('email',$user_info['email']); if($has_email){ $data['status'] = 0; $data['info'] = "邮箱已存在,请重新填写"; ajax_return($data); } */ $has_user_name = get_user_has('user_name', $user_info['user_name']); if ($has_user_name) { $user_info['user_name'] = $user_info['user_name'] . rand(10000, 99999); } if ($user_info['sex'] == 0) { $user_info['sex'] = -1; } elseif ($user_info['sex'] == 1) { $user_info['sex'] = 1; } else { $user_info['sex'] = 0; } //开启邮箱验证 if (app_conf("USER_VERIFY") == 0 || app_conf("USER_VERIFY") == 2) { $user_info['is_effect'] = 1; } else { $user_info['is_effect'] = 0; } $user_info['create_time'] = get_gmtime(); $user_info['update_time'] = get_gmtime(); //新建用户 使用验证码作为密码 $user_info['user_pwd'] = $user_pwd; //$GLOBALS['db']->autoExecute(DB_PREFIX."user",$user_info,"INSERT"); $res = save_user($user_info); statistics('register'); $user_id = intval($res['data']); } $user_info_new = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user where id = " . $user_id); if ($user_info_new['is_effect'] == 1) { $result = do_login_user($user_info_new['mobile'], $user_info_new['user_pwd']); ajax_return(array("status" => 1, "info" => $result['msg'], "jump" => $referer)); } else { if (app_conf("USER_VERIFY") == 1) { ajax_return(array("status" => 1, "jump" => url_wap("user#mail_check", array('uid' => $user_id)))); } else { if (app_conf("USER_VERIFY") == 3) { ajax_return(array("status" => 0, "info" => "请等待管理员审核")); } } } }
function user_login($username_email, $pwd) { require_once APP_ROOT_PATH . "system/libs/user.php"; if (check_ipop_limit(get_client_ip(), "user_dologin", intval(app_conf("SUBMIT_DELAY")))) { $result = do_login_user($username_email, $pwd); } else { //showErr($GLOBALS['lang']['SUBMIT_TOO_FAST'],$ajax,url("shop","user#login")); $result['status'] = 0; $result['msg'] = $GLOBALS['lang']['SUBMIT_TOO_FAST']; return $result; } if ($result['status']) { //$GLOBALS['user_info'] = $result["user"]; return $result; } else { $GLOBALS['user_info'] = null; unset($GLOBALS['user_info']); if ($result['data'] == ACCOUNT_NO_EXIST_ERROR) { $err = $GLOBALS['lang']['USER_NOT_EXIST']; } if ($result['data'] == ACCOUNT_PASSWORD_ERROR) { $err = $GLOBALS['lang']['PASSWORD_ERROR']; } if ($result['data'] == ACCOUNT_NO_VERIFY_ERROR) { $err = $GLOBALS['lang']['USER_NOT_VERIFY']; } $result['msg'] = $err; return $result; } }
user_login(); $user_info = es_session::get('user_info'); $request_param['session_id'] = es_session::id(); require_once APP_ROOT_PATH . 'system/utils/weixin.php'; if ($_REQUEST['code'] && $_REQUEST['state'] == 1 && $m_config['wx_app_key'] && $m_config['wx_app_secret'] && !$user_info) { require_once APP_ROOT_PATH . 'system/model/user.php'; $weixin = new weixin($m_config['wx_app_key'], $m_config['wx_app_secret'], get_domain() . APP_ROOT . "/wap/index.php"); global $wx_info; $wx_info = $weixin->scope_get_userinfo($_REQUEST['code']); $GLOBALS['tmpl']->assign('wx_info', $wx_info); //用户未登陆 if ($wx_info['openid']) { $wx_user_info = get_user_has('wx_openid', $wx_info['openid']); if ($wx_user_info) { //如果会员存在,直接登录 do_login_user($wx_user_info['mobile'], $wx_user_info['user_pwd']); } else { //会员不存在进入登录流程 $class = 'user_wx_register'; //app_redirect(wap_url('index','user_wx_register')); } } } else { if ($is_weixin && !$user_info && $m_config['wx_app_key'] && $m_config['wx_app_secret'] && $class != 'user_wx_register' && $class != 'register_verify_phone' && $class != 'wx_do_register') { //echo $class;exit; $weixin_2 = new weixin($m_config['wx_app_key'], $m_config['wx_app_secret'], get_domain() . $_SERVER["REQUEST_URI"]); $wx_url = $weixin_2->scope_get_code(); app_redirect($wx_url); } } //获取模板文件的名称
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $id = intval($GLOBALS['request']['share_id']); $result = do_login_user($email, $pwd); $GLOBALS['user_info'] = $user_data = es_session::get('user_info'); $user_data['id'] = intval($user_data['id']); $act2 = strim($GLOBALS['request']['act_2']); $source = strim($GLOBALS['request']['source']); $source = str_replace("来自", "", $source); $topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where id = " . $id); if ($topic) { switch ($act2) { case 'follow': //开始关注 $user_id = intval($user_data['id']); $focus_uid = intval($topic['user_id']); if ($user_id != $focus_uid) { $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); if (!$focus_data && $user_id > 0 && $focus_uid > 0) { $focused_user_name = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id = " . $focus_uid); $focus_data = array(); $focus_data['focus_user_id'] = $user_id; $focus_data['focused_user_id'] = $focus_uid; $focus_data['focus_user_name'] = $GLOBALS['user_info']['user_name']; $focus_data['focused_user_name'] = $focused_user_name; $GLOBALS['db']->autoExecute(DB_PREFIX . "user_focus", $focus_data, "INSERT"); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count + 1 where id = " . $user_id); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count + 1 where id = " . $focus_uid); } elseif ($focus_data && $user_id > 0 && $focus_uid > 0) { $GLOBALS['db']->query("delete from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_id . " and focused_user_id = " . $focus_uid); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focus_count = focus_count - 1 where id = " . $user_id); $GLOBALS['db']->query("update " . DB_PREFIX . "user set focused_count = focused_count - 1 where id = " . $focus_uid); } } //开始关注 break; case 'collect': //开始喜欢 if ($topic['user_id'] != intval($user_data['id'])) { $fav_topic = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where fav_id = " . $id . " and user_id = " . intval($user_data['id'])); if ($fav_topic) { $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic where id = " . $fav_topic['id']); $GLOBALS['db']->query("update " . DB_PREFIX . "topic set fav_count = fav_count - 1 where id = " . $id); if ($id != $topic['origin_id']) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set fav_count = fav_count - 1 where id = " . $topic['origin_id']); } $GLOBALS['db']->query("delete from " . DB_PREFIX . "topic_image where topic_id = " . $fav_topic['id']); $topic['fav_count'] -= 1; } else { $tid = insert_topic($cnt = "", $title = "", $type = "", $group = "", $r = 0, $f = $id); if ($tid) { $GLOBALS['db']->query("update " . DB_PREFIX . "topic set source_name = '" . $source . "' where id = " . intval($tid)); } $topic['fav_count'] += 1; } } //end喜欢 break; } $share_item = m_get_topic_item($topic); if ($topic['user_id'] == $user_data['id']) { $share_item['is_follow_user'] = -1; } else { $focus_uid = intval($topic['user_id']); $focus_data = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_focus where focus_user_id = " . $user_data['id'] . " and focused_user_id = " . $focus_uid); if ($focus_data) { $share_item['is_follow_user'] = 1; } else { $share_item['is_follow_user'] = 0; } $share_item['is_collect_share'] = $GLOBALS['db']->getOne("select count(id) from " . DB_PREFIX . "topic where fav_id = " . $topic['id'] . " and user_id = " . $user_data['id']); } $share_item['comments'] = m_get_topic_reply($topic['id'], 1); $share_item['collects'] = m_get_topic_fav($topic['id']); $share_item['imgs'] = m_get_topic_img($topic); $root = array(); $root['return'] = 1; $root['item'] = $share_item; } else { $root['return'] = 0; } output($root); }