function row($uid, $make = 1) { $row = array(); $uid = jfilter($uid, 'int'); if ($uid > 0) { $row = $this->info($uid); if ($row && $make) { $row = jsg_member_make($row); } } return $row; }
function Main() { if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) { $this->Messager($this->MemberHandler->GetError(), null); } $act_list = array(); if ($this->Config['company_enable']) { $act_list['company'] = '同单位'; } if (!$this->Config['profile_search_close']) { $act_list['search'] = '同城用户'; } if (!$this->Config['profile_maybe_friend_close']) { $act_list['maybe_friend'] = '同兴趣'; } if (!$this->Config['profile_usertag_close']) { $act_list['usertag'] = '同类人'; } if (!$this->Config['profile_role_close']) { $act_list['role'] = '同分组'; } if (false == jconf::get('invite', 'link_display_none')) { $act_list['invite'] = '邀请好友'; } $act = $this->Code; $member = $this->Member; if ($member['medal_id']) { $medal_list = $this->TopicLogic->GetMedal($member['medal_id'], $member['uid']); } $member_nickname = $member['nickname']; if ('invite' == $act) { $sql = "delete from `" . TABLE_PREFIX . "invite` where `fuid`<'1' and `dateline`>'0' and `dateline`<'" . (time() - 86400 * 7) . "'"; $this->DatabaseHandler->Query($sql); $sql = "select count(*) as my_invite_count from `" . TABLE_PREFIX . "invite` where `uid`='{$member['uid']}'"; $query = $this->DatabaseHandler->Query($sql); $row = $query->GetRow(); $my_invite_count = $row['my_invite_count']; $can_invite_count = max(0, $this->Config['invite_count_max'] - $my_invite_count); if ($my_invite_count > 0) { $per_page_num = 5; $query_link = "index.php?mod=" . ($_GET['mod_original'] ? get_safe_code($_GET['mod_original']) : $this->Module) . ($this->Code ? "&code={$this->Code}" : ""); $_config = array('return' => 'array'); $page_arr = page($my_invite_count, $per_page_num, $query_link, $_config); $sql = "select i.*,m.province,m.city,m.topic_count,m.fans_count,m.nickname as fusername from `" . TABLE_PREFIX . "invite` i\r\n\t\t\t\t\t\tleft join `" . TABLE_PREFIX . "members` m on m.uid = i.fuid\r\n\t\t\t\t\t \twhere i.`uid`='{$member['uid']}' order by i.`id` desc {$page_arr['limit']}"; $query = $this->DatabaseHandler->Query($sql); $invite_list = array(); while (false != ($row = $query->GetRow())) { $row['from_area'] = $row['province'] ? $row['province'] . ' ' . $row['city'] : '无'; $row['face'] = face_get($row['fuid']); $invite_list[] = $row; } $invite_list = buddy_follow_html($invite_list, 'fuid'); } $MEMBER_INVITE_CODE = ''; if (!$this->Config['invite_count_max'] || $this->Config['invite_count_max'] > $member['invite_count']) { $MEMBER_INVITE_CODE = $member['invitecode']; } if (!$MEMBER_INVITE_CODE) { $MEMBER_INVITE_CODE = random(16); $sql = "update `" . TABLE_PREFIX . "members` set `invitecode`='{$MEMBER_INVITE_CODE}' where `uid`='" . MEMBER_ID . "'"; $this->DatabaseHandler->Query($sql); } $inviteURL = "index.php?mod=member&code=" . urlencode(MEMBER_ID . "_" . $MEMBER_INVITE_CODE); $inviteURL = get_invite_url($inviteURL, $this->Config['site_url']); $invite = jconf::get('invite'); $invite_msg = empty($invite) ? '' : jstripslashes($invite['invite_msg']); if (!empty($invite_msg)) { $replaces = array('nickname' => $member['nickname'], 'inviteurl' => $inviteURL, 'invite_num' => $this->Config['invite_limit'], 'site_name' => $this->Config['site_name']); foreach ($replaces as $key => $val) { $invite_msg = str_replace("#" . $key . "#", $val, $invite_msg); } } } elseif ('maybe_friend' == $act) { $my_favorite_tags = jlogic('tag_favorite')->my_favorite_tags(MEMBER_ID, 20); if ($my_favorite_tags) { $uids = jlogic('tag_favorite')->favorite_uids($my_favorite_tags, 30); if ($uids) { $p = array('uid' => MEMBER_ID, 'touid' => $uids, 'result_count' => count($uids)); $buddyids = get_buddyids($p); $sql = "select `uid`,`ucuid`,`username`,`face_url`,`face`,`province`,`city`,`fans_count`,`topic_count`,`validate`,`nickname` from `" . TABLE_PREFIX . "members` where `uid` in('" . implode("','", $uids) . "')"; $query = $this->DatabaseHandler->Query($sql); $member_list = array(); while (false != ($row = $query->GetRow())) { $buddy_status = isset($buddyids[$row['uid']]); if (!$buddy_status && MEMBER_ID != $row['uid']) { $row['follow_html'] = follow_html($row['uid'], $buddy_status); $row = jsg_member_make($row); $member_list[$row['uid']] = $row; $tag_favorite_uids[$row['uid']] = $row['uid']; } } } } $user_favorite = array(); if ($tag_favorite_uids) { $user_favorite = jlogic('tag_favorite')->my_favorite($tag_favorite_uids, 100); } } elseif ('usertag' == $act) { $per_page_num = 10; $query_link = 'index.php?mod=profile&code=usertag'; $order = " order by `fans_count` desc "; $sql = "select * from `" . TABLE_PREFIX . "user_tag_fields` where `uid` = '" . MEMBER_ID . "'"; $query = $this->DatabaseHandler->Query($sql); $mytag = array(); $user_tagid = array(); while (false != ($row = $query->GetRow())) { $mytag[] = $row; $user_tagid[$row['tag_id']] = $row['tag_id']; } if ($user_tagid) { $sql = "select * from `" . TABLE_PREFIX . "user_tag_fields` where `uid` != '" . MEMBER_ID . "' and `tag_id` in (" . jimplode($user_tagid) . ") "; $query = $this->DatabaseHandler->Query($sql); $member_uids = array(); while (false != ($row = $query->GetRow())) { $member_uids[$row['uid']] = $row['uid']; } $where = $where_list = " where `uid` in (" . jimplode($member_uids) . ")"; } if ($member_uids) { $member_list = array(); $sql = "select count(*) as `total_record` from `" . TABLE_PREFIX . "members` {$where}"; $total_record = DB::result_first($sql); if ($total_record > 0) { $_config = array('return' => 'array'); $page_arr = page($total_record, $per_page_num, $query_link, $_config); $member_list = $this->TopicLogic->GetMember("{$where} {$order} {$page_arr['limit']}", "`uid`,`ucuid`,`username`,`nickname`,`face_url`,`face`,`fans_count`,`topic_count`,`province`,`city`,`validate`"); $member_list = buddy_follow_html($member_list); } $sql = "select * from `" . TABLE_PREFIX . "user_tag_fields` {$where}"; $query = $this->DatabaseHandler->Query($sql); $member_tag = array(); while (false != ($row = $query->GetRow())) { $member_tag[] = $row; } } $mytag = $this->_MyUserTag(MEMBER_ID); } else { $per_page_num = 10; $query_link = 'index.php?mod=profile&code=' . $act; $where_list = array(); if ('search' == $act) { $province_name = $member['province']; $city_name = $member['city']; $area_name = $member['area']; $street_name = $member['street']; $province = $this->Get['province']; $city = $this->Get['city']; $area = $this->Get['area']; $street = $this->Get['street']; if ($province) { $province_name = DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '{$province}'"); if ($city) { $city_name = DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '{$city}'"); if ($area) { $area_name = DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '{$area}'"); if ($street) { $street_name = DB::result_first("select name from " . TABLE_PREFIX . "common_district where id = '{$street}'"); } else { $street_name = ''; } } else { $area_name = ''; $street_name = ''; } } else { $city_name = ''; $area_name = ''; $street_name = ''; } } if (empty($where_list)) { if ($province_name) { $where_list['province'] = "`province`='" . addslashes("{$province_name}") . "'"; $query_link .= "&province=" . $province; if ($city_name) { $where_list['city'] = "`city`='" . addslashes("{$city_name}") . "'"; $query_link .= "&city=" . $city; if ($area_name) { $where_list['area'] = "`area`='" . addslashes("{$area_name}") . "'"; $query_link .= "&area=" . $area; if ($street_name) { $where_list['street'] = "`street`='" . addslashes("{$street_name}") . "'"; $query_link .= "&street=" . $street; } } } } } $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "common_district where `upid` = '0' order by list"); while ($rsdb = $query->GetRow()) { $province_arr[$rsdb['id']]['value'] = $rsdb['id']; $province_arr[$rsdb['id']]['name'] = $rsdb['name']; if ($member['province'] == $rsdb['name']) { $province_id = $rsdb['id']; } } $province_id = $province ? $province : $province_id; $province_list = jform()->Select("province", $province_arr, $province_id, "onchange=\"changeProvince();\""); $hid_area = ''; $hid_city = ''; $hid_street = ''; if (!$province && $province_id) { if ($member['city']) { $hid_city = DB::result_first("select id from " . TABLE_PREFIX . "common_district where name = '{$member['city']}' and upid = '{$province_id}'"); } if ($hid_city) { if ($member['area']) { $hid_area = DB::result_first("select id from " . TABLE_PREFIX . "common_district where name = '{$member['area']}' and upid = '{$hid_city}'"); } if ($hid_area) { if ($member['street']) { $hid_street = DB::result_first("select id from " . TABLE_PREFIX . "common_district where name = '{$member['street']}' and upid = '{$hid_area}'"); } } } } $hid_city = $city ? $city : $hid_city; $hid_area = $area ? $area : $hid_area; $hid_street = $street ? $street : $hid_street; } elseif ('company' == $act && $this->Config['company_enable'] && @is_file(ROOT_PATH . 'include/logic/cp.logic.php')) { global $_J; $companyid = jget('companyid', 'int'); $departmentid = jget('departmentid', 'int'); $jobid = jget('jobid', 'int'); if ($companyid < 1 && $departmentid < 1 && $jobid < 1) { $companyid = (int) $_J['member']['companyid']; $departmentid = (int) $_J['member']['departmentid']; $jobid = (int) $_J['member']['jobid']; } $company_list = jlogic('cp')->get_cp_html($companyid); if ($this->Config['department_enable']) { $department_list = jlogic('cp')->get_cp_html($departmentid, 'department', $companyid); } $job_list = jlogic('job')->get_job_select($jobid); if ($companyid > 0) { $where_list['company'] = "`companyid`='" . $companyid . "'"; $query_link .= '&companyid=' . $companyid; } if ($departmentid > 0) { $where_list['department'] = "`departmentid`='" . $departmentid . "'"; $query_link .= '&departmentid=' . $departmentid; } if ($jobid > 0) { $where_list['job'] = "`jobid`='" . $jobid . "'"; $query_link .= '&jobid=' . $jobid; } } else { global $_J; $roleid = $this->Get['roleid'] ? (int) $this->Get['roleid'] : ($_J['role_id'] ? $_J['role_id'] : 0); $roles = jlogic('channel')->get_user_role(); $role_list = jform()->Select("roleid", $roles, $roleid, ""); if ($roleid) { $where_list['role'] = "`role_id`='" . $roleid . "'"; $query_link .= "&roleid=" . $roleid; } } $member_list = array(); if ($where_list) { $where = empty($where_list) ? null : ' WHERE ' . implode(' AND ', $where_list) . ' '; $order = " order by `uid` desc "; $sql = "select count(*) as `total_record` from `" . TABLE_PREFIX . "members` {$where} "; $total_record = DB::result_first($sql); if ($total_record > 0) { $_config = array('return' => 'array'); $page_arr = page($total_record, $per_page_num, $query_link, $_config); $uids = array(); $member_list = $this->TopicLogic->GetMember("{$where} {$order} {$page_arr['limit']}", "`uid`,`ucuid`,`username`,`nickname`,`face_url`,`face`,`fans_count`,`topic_count`,`province`,`city`,`aboutme`"); foreach ($member_list as $_m) { $uids[$_m['uid']] = $_m['uid']; } if ($uids && MEMBER_ID > 0) { $member_list = buddy_follow_html($member_list); $province = isset($_GET['province']) ? $province : $member['province']; $city = isset($_GET['city']) ? $city : $member['city']; $sql = "select * from (select * from `" . TABLE_PREFIX . "topic` where `uid` in (" . jimplode($uids) . ") and `type` != 'reply' order by `dateline` desc) a group by `uid` "; $query = $this->DatabaseHandler->Query($sql); $tids = array(); while (false != ($row = $query->GetRow())) { $tids[$row['tid']] = $row['tid']; } $topic_list = $this->TopicLogic->Get($tids); } } } $gender_radio = jform()->Radio('gender', array(0 => array('name' => '不限', 'value' => 0), 1 => array('name' => '男', 'value' => 1), 2 => array('name' => '女', 'value' => 2)), $gender); } $this->Title = $act_list[$act]; include template('social/profile_main'); }
function GetMember() { global $_J; $this->MemberFields = array(); if ($this->sid) { $sql = ''; if ($this->ID) { $sql = "SELECT * FROM " . DB::table("members") . " `M` LEFT JOIN " . DB::table("memberfields") . " `MF` ON MF.uid=M.uid\r\n\t\t\t\t\t\tLEFT JOIN " . DB::table("sessions") . " `S` ON S.uid=M.uid\r\n\t\t\t\t\tWHERE M.uid='{$this->ID}' AND M.password='******' AND S.sid='{$this->sid}' AND\r\n\t\t\t\t\t\tCONCAT_WS('.', S.ip1, S.ip2, S.ip3, S.ip4)='{$_J['client_ip']}'"; } else { if (!$this->no_record_guest) { $sql = "SELECT * FROM " . DB::table("sessions") . " WHERE sid='{$this->sid}' AND CONCAT_WS('.', ip1, ip2, ip3, ip4)='{$_J['client_ip']}'"; } } if ($sql) { $this->MemberFields = DB::fetch_first($sql); } if ($this->MemberFields && !$this->ID && $this->MemberFields['uid'] > 0) { $row = DB::fetch_first("SELECT * FROM " . DB::table("members") . " `M` LEFT JOIN " . DB::table("memberfields") . " `MF` ON MF.uid=M.uid WHERE M.uid='{$this->MemberFields['uid']}'"); if ($row) { $this->MemberFields = array_merge($row, $this->MemberFields); } } } $this->SessionExists = $this->MemberFields && $this->MemberFields['uid'] == $this->ID ? true : false; if (!$this->SessionExists) { jsg_setcookie('sid', '', -311040000); if ($this->ID) { $sql = "SELECT * FROM " . DB::table("members") . " `M` LEFT JOIN " . DB::table("memberfields") . " `MF` ON MF.uid=M.uid\r\n\t\t\t\t\tWHERE M.uid='{$this->ID}' AND M.password='******'"; $this->MemberFields = DB::fetch_first($sql); if (!$this->MemberFields) { jsg_setcookie('auth', '', -311040000); } } else { jsg_setcookie('auth', '', -311040000); } $this->sid = $this->MemberFields['sid'] = random(6); } $this->MemberFields['role_id'] = (int) $this->MemberFields['role_id']; if ($this->MemberFields['role_id'] < 1) { $this->MemberFields = array_merge($this->MemberFields, jtable('role')->guest()); } else { $role = jtable('role')->row($this->MemberFields['role_id']); if ($role) { $this->MemberFields = array_merge($this->MemberFields, $role); } } if ($this->MemberFields['uid'] > 0) { $this->MemberFields = jsg_member_make($this->MemberFields); } $_J['uid'] = $this->MemberFields['uid']; $_J['username'] = $this->MemberFields['username']; $_J['nickname'] = $this->MemberFields['nickname']; $_J['role_id'] = $this->MemberFields['role_id']; $_J['member'] =& $this->MemberFields; }
function MakeAll($list, $make_row = 1, $verify = 0) { if (!$list) { return array(); } $tids = array(); $uids = array(); $videoids = array(); $musicids = array(); $rewardids = array(); $imageids = array(); foreach ($list as $k => $v) { if (is_array($v) && count($v) && ($v['tid'] > 0 || $verify > 0)) { if ($make_row) { $v = $this->Make($v, 1); } if ($v['uid'] > 0) { $uids[$v['uid']] = $v['uid']; } if ($v['touid'] > 0) { $uids[$v['touid']] = $v['touid']; } if ($v['videoid'] > 0) { $videoids[$v['videoid']] = $v['videoid']; } if ($v['musicid'] > 0) { $musicids[$v['musicid']] = $v['musicid']; } if ($v['item'] == 'reward' && $v['type'] == 'first' && $v['item_id'] > 0) { $rewardids[$v['item_id']] = $v['item_id']; } if ($v['imageid']) { $i = explode(",", $v['imageid']); if ($i) { foreach ($i as $key => $val) { $imageids[$val] = $val; } } } if ($v['attachid']) { $i = explode(",", $v['attachid']); if ($i) { foreach ($i as $key => $val) { $attachids[$val] = $val; } } } } $list[$k] = $v; } $member_list = array(); if ($uids) { $sql = "SELECT\r\n M.`uid`,\r\n M.`ucuid`,\r\n M.`username`,\r\n M.`nickname`,\r\n M.`signature`,\r\n M.`face_url`,\r\n M.`face`,\r\n M.`validate`,\r\n M.`role_id`,\r\n M.`validate_category`,\r\n M.`level`,\r\n MF.validate_true_name,\r\n MF.validate_remark\r\nFROM " . DB::table('members') . " M\r\n LEFT JOIN " . DB::table('memberfields') . " MF\r\n ON MF.uid = M.uid\r\nWHERE M.uid IN('" . implode("','", $uids) . "')"; $query = DB::query($sql); while (false != ($row = DB::fetch($query))) { $member_list[$row['uid']] = jsg_member_make($row); } } $video_list = array(); if ($videoids) { $sql = "SELECT\r\n `id`,\r\n `video_hosts`,\r\n `video_link`,\r\n `video_img`,\r\n `video_img_url`,\r\n `video_url`\r\nFROM " . DB::table('topic_video') . "\r\nWHERE `id` IN('" . implode("','", $videoids) . "')"; $query = DB::query($sql); while (false != ($row = DB::fetch($query))) { $video_list[$row['id']] = $row; } } $music_list = array(); if ($musicids) { $sql = "SELECT\r\n `id`,\r\n `music_url`,\r\n `xiami_id`\r\nFROM " . DB::table('topic_music') . "\r\nWHERE `id`IN('" . implode("','", $musicids) . "')"; $query = DB::query($sql); while (false != ($row = DB::fetch($query))) { $music_list[$row['id']] = $row; } } $reward_list = array(); if ($rewardids) { $sql = " select `id`,`tid`,`event_image`,`image` from `" . DB::table('reward') . "` where `id` IN (" . jimplode($rewardids) . ") "; $query = DB::query($sql); while (false != ($row = DB::fetch($query))) { if ($row['event_image'] || $row['image']) { if (!$row['event_image']) { $row['event_image'] = $row['image']; } if (!$rewarImageList[$row['event_image']]) { $rewarImageList[$row['event_image']] = DB::result_first(" select `image` from `" . TABLE_PREFIX . "reward_image` where `id` = '{$row['event_image']}'"); $rewarImageList[$row['event_image']] = $rewarImageList[$row['event_image']] ? $rewarImageList[$row['event_image']] : './images/reward_noPic.gif'; } $row['event_image'] = $rewarImageList[$row['event_image']]; } else { $row['event_image'] = './images/reward_noPic.gif'; } $reward_list[$row['id']] = $row; } } $image_list = array(); if ($imageids) { $image_list = jlogic('image')->image_list($imageids); } $attach_list = array(); if ($attachids) { $attach_list = jlogic('attach')->attach_list($attachids); } if ($member_list || $video_list || $music_list || $reward_list || $image_list || $attach_list) { foreach ($list as $k => $v) { if (is_array($v) && count($v) && ($v['tid'] > 0 || $verify > 0)) { if ($v['uid'] > 0 && $member_list[$v['uid']]) { $v = array_merge($v, $member_list[$v['uid']]); } if ($v['touid'] > 0 && $member_list[$v['touid']]) { if ($v['tousername'] != $member_list[$v['touid']]['nickname']) { jtable('topic')->update(array('tousername' => $member_list[$v['touid']]['nickname']), $v['tid']); } } if ($v['videoid'] > 0 && $video_list[$v['videoid']]) { $v['VideoID'] = $video_list[$v['videoid']]['id']; $v['VideoHosts'] = $video_list[$v['videoid']]['video_hosts']; $v['VideoLink'] = $video_list[$v['videoid']]['video_link']; $v['VideoUrl'] = $video_list[$v['videoid']]['video_url']; if ($video_list[$v['videoid']]['video_img']) { $v['VideoImg'] = ($video_list[$v['videoid']]['video_img_url'] ? $video_list[$v['videoid']]['video_img_url'] : $GLOBALS['_J']['config']['site_url']) . '/' . $video_list[$v['videoid']]['video_img']; } else { $v['VideoImg'] = $GLOBALS['_J']['config']['site_url'] . '/images/vd.gif'; } } if ($v['musicid'] > 0 && $music_list[$v['musicid']]) { $v['MusicID'] = $music_list[$v['musicid']]['id']; $v['MusicUrl'] = $music_list[$v['musicid']]['music_url']; $v['xiami_id'] = $music_list[$v['musicid']]['xiami_id']; } if ($v['item'] == 'reward' && $v['type'] == 'first' && $reward_list[$v['item_id']]['tid'] == $v['tid']) { $v['is_reward'] = 1; $v['reward_image'] = $reward_list[$v['item_id']]['event_image']; $r_url = $GLOBALS['_J']['config']['site_url'] . '/index.php?mod=reward&code=detail&id=' . $v['item_id']; $reward_url = ' 更多信息尽在<a href="' . $r_url . '">' . $r_url . '</a>'; $v['content'] = $v['content'] . $reward_url; } if ($v['imageid'] && $image_list) { $i_arr = explode(",", $v['imageid']); foreach ($i_arr as $image_id) { $v['image_list'][$image_id] = $image_list[$image_id]; } } if ($v['attachid'] && $attach_list) { $a_arr = explode(",", $v['attachid']); foreach ($a_arr as $attach_id) { $v['attach_list'][$attach_id] = $attach_list[$attach_id]; } } } if ($v['anonymous']) { $v = $this->_anonymous($v); } $list[$k] = $v; } } return $list; }
function getBlackList($param) { $uid = MEMBER_ID; $id = intval($param['max_id']); $where_sql = " bl.uid='{$uid}' "; $order_sql = " bl.id DESC "; $limit = intval($param['limit']); $count = DB::result_first("SELECT COUNT(*)\r\n\t\t\t\t\t\t\t\t FROM " . DB::table('blacklist') . " AS bl\r\n\t\t\t\t\t\t\t\t LEFT JOIN " . DB::table("members") . " AS m\r\n\t\t\t\t\t\t\t\t USING(uid)\r\n\t\t\t\t\t\t\t\t WHERE {$where_sql}"); if ($count > 0) { $member_list = array(); if ($id > 0) { $where_sql .= " AND bl.id<{$id} "; } $query = DB::query("SELECT bl.id AS bl_id,m.uid,m.nickname,m.username,m.face,m.fans_count,m.signature,m.topic_count,m.province,m.city\r\n\t\t\t\t\t\t\t\tFROM " . DB::table('blacklist') . " AS bl\r\n\t\t\t\t\t\t\t\tLEFT JOIN " . DB::table("members") . " AS m\r\n\t\t\t\t\t\t\t\tON bl.touid = m.uid\r\n\t\t\t\t\t\t\t\tWHERE {$where_sql}\r\n\t\t\t\t\t\t\t\tORDER BY {$order_sql}\r\n\t\t\t\t\t\t\t\tLIMIT {$limit} "); while ($row = DB::fetch($query)) { $raw = jsg_member_make($row); $raw['friendship'] = -1; $member_list[] = $raw; } if (empty($member_list)) { return 401; } else { $member_list = array_values($member_list); $tmp_ary = $member_list; $tmp = array_pop($tmp_ary); $max_id = $tmp['bl_id']; $r = array('total_record' => $count, 'member_list' => $member_list, 'max_id' => $max_id); return $r; } } return 400; }
function get_bbs($param) { if (BBS_ENABLE) { if ($this->BbsType == 'discuz') { $table_p = DZ_BBS_VER == 'dzx' ? BBSDB::table('forum_post') : BBSDB::table('posts'); $table_t = DZ_BBS_VER == 'dzx' ? BBSDB::table('forum_thread') : BBSDB::table('threads'); $table_f = DZ_BBS_VER == 'dzx' ? BBSDB::table('home_favorite') : BBSDB::table('favorites'); $table_ff = DZ_BBS_VER == 'dzx' ? BBSDB::table('forum_forum') : BBSDB::table('forums'); $furl = DZ_BBS_VER == 'dzx' ? '/forum.php?mod=forumdisplay&fid=' : '/forumdisplay.php?fid='; $turl = DZ_BBS_VER == 'dzx' ? '/forum.php?mod=viewthread&tid=' : '/viewthread.php?tid='; $lurl = DZ_BBS_VER == 'dzx' ? '/forum.php?mod=redirect&tid=' : '/redirect.php?tid='; $where_sql = " p.invisible >=0 "; $order_by = " t.lastpost DESC "; if (!empty($param['where'])) { if ($param['where'] == 'favorites') { if (DZ_BBS_VER == 'dzx') { $where_sql .= " AND p.first = 1 AND p.fid IN (SELECT id FROM {$table_f} WHERE idtype = 'fid' AND uid = " . MEMBER_UCUID . ") "; } else { $where_sql .= " AND p.first = 1 AND p.fid IN (SELECT fid FROM {$table_f} WHERE tid = '0' AND uid = " . MEMBER_UCUID . ") "; } $order_by = " p.pid DESC "; } elseif ($param['where'] == 'favorite') { if (DZ_BBS_VER == 'dzx') { $where_sql .= " AND p.first = 1 AND p.tid IN (SELECT id FROM {$table_f} WHERE idtype = 'tid' AND uid = " . MEMBER_UCUID . ") "; } else { $where_sql .= " AND p.first = 1 AND p.tid IN (SELECT tid FROM {$table_f} WHERE fid = '0' AND uid = " . MEMBER_UCUID . ") "; } } elseif ($param['where'] == 'all') { $where_sql .= " AND p.first = 1 "; if ($fids = $this->_get_member_fid()) { $where_sql .= " AND p.fid NOT IN (" . $fids . ") "; } $order_by = " p.pid DESC "; } elseif ($param['where'] == 'thread') { $where_sql .= " AND p.first = 1 AND p.authorid = " . MEMBER_UCUID; } elseif ($param['where'] == 'reply') { $where_sql .= " AND p.first = 0 AND p.authorid = " . MEMBER_UCUID; $order_by = " p.pid DESC "; } } } elseif ($this->BbsType == 'phpwind') { $table_ff = BBSDB::table('forums'); $where_sql = ' p.fid !=0 '; $furl = '/thread.php?fid='; $turl = '/read.php?tid='; $lurl = '/read.php?tid='; if (!empty($param['where'])) { if ($param['where'] == 'favorite') { $table_p = BBSDB::table('collection'); $where_sql = " p.type ='postfavor' AND p.uid = " . MEMBER_UCUID; } elseif ($param['where'] == 'all') { $table_p = BBSDB::table('threads'); } elseif ($param['where'] == 'thread') { $table_p = BBSDB::table('threads'); $where_sql .= " AND p.authorid = " . MEMBER_UCUID; } elseif ($param['where'] == 'reply') { $table_p = BBSDB::table('posts'); $where_sql .= " AND p.authorid = " . MEMBER_UCUID; } else { return false; } } } $total_record = BBSDB::result_first("SELECT COUNT(*) FROM {$table_p} AS p WHERE {$where_sql} LIMIT 1000"); if ($total_record > 0) { if ($param['perpage']) { $page_arr = page($total_record, $param['perpage'], $param['page_url'], array('return' => 'array')); $limit_sql = $page_arr['limit']; } else { if ($param['limit']) { $limit_sql = ' LIMIT ' . $param['limit']; } } if ($this->BbsType == 'discuz') { $query = BBSDB::query("SELECT p.pid,p.tid,p.fid,p.authorid,p.author,p.subject,p.message,p.dateline,p.first,t.author AS t_username,t.subject AS t_title,t.dateline AS t_dateline,t.authorid AS t_authorid,t.replies,t.lastpost,ff.name FROM {$table_p} p LEFT JOIN {$table_t} t ON p.tid = t.tid LEFT JOIN {$table_ff} ff ON p.fid = ff.fid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); } elseif ($this->BbsType == 'phpwind') { if ($param['where'] == 'favorite') { $table_fc = BBSDB::table('collection'); $table_t = BBSDB::table('tmsgs'); $table_p = BBSDB::table('threads'); $where_sql = " p.tid IN(SELECT typeid FROM {$table_fc} WHERE type ='postfavor' AND uid = " . MEMBER_UCUID . ")"; $order_by = ' p.lastpost DESC '; $query = BBSDB::query("SELECT p.tid,p.tid AS pid,p.lastpost,p.tid AS first,p.fid,p.authorid,p.authorid AS t_authorid,p.author,p.subject,t.content AS message,p.postdate AS dateline,p.replies,ff.name FROM {$table_p} p LEFT JOIN {$table_t} t ON p.tid = t.tid LEFT JOIN {$table_ff} ff ON p.fid = ff.fid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); } elseif ($param['where'] == 'all') { $table_t = BBSDB::table('tmsgs'); $table_p = BBSDB::table('threads'); $order_by = ' p.tid DESC '; $query = BBSDB::query("SELECT p.tid,p.tid AS pid,p.lastpost,p.tid AS first,p.fid,p.authorid,p.authorid AS t_authorid,p.author,p.subject,t.content AS message,p.postdate AS dateline,p.replies,ff.name FROM {$table_p} p LEFT JOIN {$table_t} t ON p.tid = t.tid LEFT JOIN {$table_ff} ff ON p.fid = ff.fid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); } elseif ($param['where'] == 'thread') { $table_t = BBSDB::table('tmsgs'); $table_p = BBSDB::table('threads'); $where_sql .= " AND p.authorid = " . MEMBER_UCUID; $order_by = ' p.lastpost DESC '; $query = BBSDB::query("SELECT p.tid AS pid,p.lastpost,p.tid AS first,p.tid,p.fid,p.authorid,p.authorid AS t_authorid,p.author,p.subject,t.content AS message,p.postdate AS dateline,p.replies,ff.name FROM {$table_p} p LEFT JOIN {$table_t} t ON p.tid = t.tid LEFT JOIN {$table_ff} ff ON p.fid = ff.fid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); } elseif ($param['where'] == 'reply') { $table_p = BBSDB::table('posts'); $table_t = BBSDB::table('threads'); $where_sql .= " AND p.authorid = " . MEMBER_UCUID; $order_by = ' p.pid DESC '; $query = BBSDB::query("SELECT p.pid,t.lastpost,p.tid,p.fid,p.authorid,p.author,p.subject,p.content AS message,p.postdate AS dateline,t.author AS t_username,t.subject AS t_title,t.postdate AS t_dateline,t.authorid AS t_authorid,t.replies,ff.name FROM {$table_p} p LEFT JOIN {$table_t} t ON p.tid = t.tid LEFT JOIN {$table_ff} ff ON p.fid = ff.fid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); } } $topic_list = array(); while ($value = BBSDB::fetch($query)) { if ($user_lists[$value['authorid']]) { $p_m_user = $user_lists[$value['authorid']]; } else { $p_user = $this->TopicLogic->GetMember($this->_getuid($value['authorid']), "`uid`,`ucuid`,`nickname`,`face`,`level`,`signature`,`validate`,`validate_category`"); $p_m_user = empty($p_user) ? array() : jsg_member_make($p_user); $user_lists[$value['authorid']] = $p_m_user; } if ($user_lists[$value['t_authorid']]) { $t_m_user = $user_lists[$value['t_authorid']]; } else { $t_user = $this->TopicLogic->GetMember($this->_getuid($value['t_authorid']), "`uid`,`ucuid`,`nickname`,`face`,`level`,`signature`,`validate`,`validate_category`"); $t_m_user = empty($t_user) ? array() : jsg_member_make($t_user); $user_lists[$value['t_authorid']] = $t_m_user; } $topic_list[$value['pid']]['pid'] = $value['pid']; $topic_list[$value['pid']]['dateline'] = my_date_format2($value['dateline']); $topic_list[$value['pid']]['t_dateline'] = my_date_format2($value['t_dateline']); $topic_list[$value['pid']]['lastpost'] = my_date_format2($value['lastpost']); $topic_list[$value['pid']]['content'] = $this->_format($value['message']); $topic_list[$value['pid']]['content_full'] = $this->_format($value['message'], 'long'); $topic_list[$value['pid']]['t_title'] = $this->_format($value['t_title']); $topic_list[$value['pid']]['title'] = $this->_format($value['subject']); $topic_list[$value['pid']]['face'] = $p_m_user['face']; $topic_list[$value['pid']]['level'] = $p_m_user['level']; $topic_list[$value['pid']]['t_nickname'] = empty($t_m_user['nickname']) ? $value['t_username'] : $t_m_user['nickname']; $topic_list[$value['pid']]['nickname'] = empty($p_m_user['nickname']) ? $value['author'] : $p_m_user['nickname']; $topic_list[$value['pid']]['bbsurl'] = BBS_API_URL . $turl . $value['tid']; $topic_list[$value['pid']]['lasturl'] = BBS_API_URL . $lurl . $value['tid'] . '&goto=lastpost#lastpost'; $topic_list[$value['pid']]['replys'] = $value['replies']; $topic_list[$value['pid']]['username'] = $value['author']; $topic_list[$value['pid']]['first'] = $value['first']; $topic_list[$value['pid']]['t_username'] = $value['t_username']; $topic_list[$value['pid']]['longtext'] = $this->_format($value['message'], 'islong'); $topic_list[$value['pid']]['forumtitle'] = $value['name']; $topic_list[$value['pid']]['forumurl'] = BBS_API_URL . $furl . $value['fid']; $topic_list[$value['pid']]['uid'] = $p_m_user['uid']; $topic_list[$value['pid']]['tid'] = $value['pid']; $topic_list[$value['pid']]['rid'] = $value['tid']; $topic_list[$value['pid']]['tuid'] = $t_m_user['uid']; $topic_list[$value['pid']]['signature'] = $p_m_user['signature']; $topic_list[$value['pid']]['validate_html'] = $p_m_user['validate_html']; $topic_list[$value['pid']]['t_validate_html'] = $t_m_user['validate_html']; } $info = array('list' => $topic_list, 'count' => $total_record, 'page' => $page_arr); return $info; } } return false; }
function get_cms($param) { if (CMS_ENABLE) { $table_p = CMSDB::table('archives'); $table_t = CMSDB::table('arctype'); $table_c = CMSDB::table('addonarticle'); $table = CMSDB::table('feedback'); $turl = "/plus/list.php?tid="; $furl = "/plus/view.php?aid="; $curl = "/plus/feedback.php?aid="; $where_sql = " p.arcrank =0 "; $order_by = " p.id DESC "; $total_record = CMSDB::result_first("SELECT COUNT(*) FROM {$table_p} AS p WHERE {$where_sql} LIMIT 1000"); if ($total_record > 0) { if ($param['perpage']) { $page_arr = page($total_record, $param['perpage'], $param['page_url'], array('return' => 'array')); $limit_sql = $page_arr['limit']; } else { if ($param['limit']) { $limit_sql = ' LIMIT ' . $param['limit']; } } $query = CMSDB::query("SELECT p.id,p.typeid,p.title,p.writer,p.description,p.pubdate,t.typename,c.body FROM {$table_p} p LEFT JOIN {$table_t} t ON p.typeid = t.id LEFT JOIN {$table_c} c ON p.id = c.aid WHERE {$where_sql} ORDER BY {$order_by} {$limit_sql} "); $topic_list = array(); while ($value = CMSDB::fetch($query)) { if ($user_lists[$value['writer']]) { $p_m_user = $user_lists[$value['writer']]; } else { $p_user = $this->TopicLogic->GetMember($this->_getuid($value['writer']), "`uid`,`ucuid`,`nickname`,`face`,`level`,`signature`,`validate`,`validate_category`"); $p_m_user = empty($p_user) ? array() : jsg_member_make($p_user); $user_lists[$value['writer']] = $p_m_user; } $replytime = CMSDB::result_first("SELECT dtime FROM {$table} WHERE aid = '" . $value['id'] . "' order by id DESC LIMIT 1"); $topic_list[$value['id']]['pid'] = $value['id']; $topic_list[$value['id']]['replys'] = CMSDB::result_first("SELECT COUNT(*) FROM {$table} WHERE aid = '" . $value['id'] . "'"); $topic_list[$value['id']]['replytime'] = $replytime ? my_date_format2($replytime) : my_date_format2($value['pubdate']); $topic_list[$value['id']]['replyurl'] = CMS_API_URL . $curl . $value['id']; $topic_list[$value['id']]['dateline'] = my_date_format2($value['pubdate']); $topic_list[$value['id']]['content'] = $this->_format($value['description']); $topic_list[$value['id']]['content_full'] = $this->_format($value['body'], 'long'); $topic_list[$value['id']]['title'] = $this->_format($value['title']); $topic_list[$value['id']]['face'] = $p_m_user['face']; $topic_list[$value['id']]['level'] = $p_m_user['level']; $topic_list[$value['id']]['nickname'] = empty($p_m_user['nickname']) ? $value['writer'] : $p_m_user['nickname']; $topic_list[$value['id']]['cmsurl'] = CMS_API_URL . $furl . $value['id']; $topic_list[$value['id']]['username'] = $value['writer']; $topic_list[$value['id']]['longtext'] = $this->_format($value['body'], 'islong'); $topic_list[$value['id']]['typetitle'] = $value['typename']; $topic_list[$value['id']]['typeurl'] = CMS_API_URL . $turl . $value['typeid']; $topic_list[$value['id']]['uid'] = $p_m_user['uid']; $topic_list[$value['id']]['tid'] = $value['id']; $topic_list[$value['id']]['signature'] = $p_m_user['signature']; $topic_list[$value['id']]['validate_html'] = $p_m_user['validate_html']; } $info = array('list' => $topic_list, 'count' => $total_record, 'page' => $page_arr); return $info; } } return false; }
function AtUser() { $limit = jget('limit', 'int'); if ($limit < 1 || $limit > 100) { $limit = 10; } $nickname = jget('q', 'txt'); $from = jget('from'); $type = jget('type'); $acode = jget('acode'); $id = jget('id', 'int'); $inkey = jget('key'); $nickname = get_safe_code($nickname); $nl = strlen($nickname); $rets = array(); $uids = array(); if ($acode == 'bud') { $uids = jtable('buddy_follow_group_relation')->get_my_group_uids(MEMBER_ID, $id); $rets = DB::fetch_all("SELECT `uid`, `nickname`, `ucuid`, `face` FROM " . DB::table('members') . " WHERE uid IN(" . jimplode($uids) . ") ORDER BY `topic_count` DESC\tLIMIT 10 "); } elseif ($acode == 'rec') { $rets = DB::fetch_all("SELECT `uid`, `nickname`, `ucuid`, `face` FROM " . DB::table('members') . " WHERE `media_id`='{$id}' ORDER BY `media_order_id` DESC\tLIMIT 10 "); } elseif ($acode == 'budn') { $buddyids = get_buddyids(array('uid' => MEMBER_ID, 'result_count' => 10, 'gids' => '')); $rets = DB::fetch_all("SELECT `uid`, `nickname`, `ucuid`, `face` FROM " . DB::table('members') . " WHERE uid IN(" . jimplode($buddyids) . ") ORDER BY `topic_count` DESC\tLIMIT 10 "); } else { if ($nl < 1 || $nl > 50) { #一周内我经常AT的人 $rets = jtable('topic_mention')->my_hot_at(MEMBER_ID, $limit); } else { $cache_id = 'ajax/misc/AtUser-' . $nickname; if (false === ($rets = cache_db('get', $cache_id))) { $where_sql = " " . build_like_query("nickname", $nickname) . " "; $rets = DB::fetch_all("SELECT `uid`, `nickname`, `ucuid`, `face`\r\n\t\t\t\t\t\t\t\t\tFROM " . DB::table('members') . "\r\n\t\t\t\t\t\t\t\t\tWHERE {$where_sql}\r\n\t\t\t\t\t\t\t\t\tORDER BY `fans_count` DESC, `lastactivity` DESC\r\n\t\t\t\t\t\t\t\t\tLIMIT {$limit} "); cache_db('set', $cache_id, $rets, 3600); } } } if ($rets) { foreach ($rets as $row) { $row = jsg_member_make($row); if ($from == 'admin') { echo "<li>{$row['nickname']}</li>"; } elseif ($from == 'web') { echo "<li onclick=\"atcin_user('{$inkey}','{$row[nickname]}','{$type}');\"><img onerror='javascript:faceError(this);' src='{$row['face']}'><span>{$row['nickname']}</span></li>"; } else { echo "{$row['nickname']}|{$row['uid']}|{$row['face']}\n"; } } } exit; }
function jsg_member_get($p, $mark = 1, $cache = 1) { if ($cache && $p['uid'] && $p['uid'] == MEMBER_ID && $GLOBALS['_J']['member']) { return array('list' => array($GLOBALS['_J']['member'])); } static $S_members = array(); if ($cache) { $cache_id = md5(serialize($p) . $mark); if (isset($S_members[$cache_id])) { return $S_members[$cache_id]; } } $wheres = array(); $ws = array('uid' => 1, 'username' => 1, 'nickname' => 1, 'email' => 1, 'phone' => 1, 'province' => 1, 'city' => 1, 'role_id' => 1, 'ucuid' => 1, 'invite_uid' => 1); foreach ($p as $k => $v) { if (isset($ws[$k])) { $vs = (array) $v; $wheres[$k] = " `{$k}` IN ('" . implode("','", $vs) . "') "; } } $sql_where = $wheres ? " WHERE " . implode(" AND ", $wheres) : ""; $count = max(0, (int) $p['count']); if ($count < 1) { $count = DB::result_first("SELECT COUNT(*) AS `count` FROM " . DB::table('members') . " {$sql_where} "); } $rets = array(); if ($count > 0) { $page = array(); $sql_limit = ''; if ($p['per_page_num']) { $page = page($count, $p['per_page_num'], $p['page_url'], array('return' => 'Array', 'extra' => $p['page_extra'])); $sql_limit = " {$page['limit']} "; } elseif ($p['limit']) { if (false !== strpos(strtolower($p['limit']), 'limit ')) { $sql_limit = " {$p['limit']} "; } else { $sql_limit = " LIMIT {$p['limit']} "; } } elseif ($p['count']) { $sql_limit = " LIMIT {$p['count']} "; } $sql_order = ''; if ($p['order']) { if (false !== strpos(strtolower($p['order']), 'order by ')) { $sql_order = " {$p['order']} "; } else { $sql_order = " ORDER BY {$p['order']} "; } } $sql_fields = $p['fields'] ? $p['fields'] : "*"; $query = DB::query("SELECT {$sql_fields} FROM " . DB::table('members') . " {$sql_where} {$sql_order} {$sql_limit} "); $list = array(); while (false != ($r = DB::fetch($query))) { if ($mark) { $r = jsg_member_make($r); } $list[] = $r; } DB::free_result($query); if ($list) { if ($mark) { $list = buddy_follow_html($list, 'uid', true === IN_JISHIGOU_WAP ? 'wap_follow_html' : 'follow_html'); } $rets = array('count' => $count, 'list' => $list, 'page' => $page); } } if ($cache && $cache_id) { $S_members[$cache_id] = $rets; } return $rets; }