Example #1
0
function wfSajaxSearch($term)
{
    global $wgContLang, $wgOut;
    $limit = 16;
    $l = new Linker();
    $term = str_replace(' ', '_', $wgContLang->ucfirst($wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)))));
    if (strlen(str_replace('_', '', $term)) < 3) {
        return;
    }
    $db =& wfGetDB(DB_SLAVE);
    $res = $db->select('page', 'page_title', array('page_namespace' => 0, "page_title LIKE '" . $db->strencode($term) . "%'"), "wfSajaxSearch", array('LIMIT' => $limit + 1));
    $r = "";
    $i = 0;
    while (($row = $db->fetchObject($res)) && ++$i <= $limit) {
        $nt = Title::newFromDBkey($row->page_title);
        $r .= '<li>' . $l->makeKnownLinkObj($nt) . "</li>\n";
    }
    if ($i > $limit) {
        $more = '<i>' . $l->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsg('moredotdotdot'), "namespace=0&from=" . wfUrlEncode($term)) . '</i>';
    } else {
        $more = '';
    }
    $subtitlemsg = Title::newFromText($term) ? 'searchsubtitle' : 'searchsubtitleinvalid';
    $subtitle = $wgOut->parse(wfMsg($subtitlemsg, wfEscapeWikiText($term)));
    #FIXME: parser is missing mTitle !
    $term = htmlspecialchars($term);
    $html = '<div style="float:right; border:solid 1px black;background:gainsboro;padding:2px;"><a onclick="Searching_Hide_Results();">' . wfMsg('hideresults') . '</a></div>' . '<h1 class="firstHeading">' . wfMsg('search') . '</h1><div id="contentSub">' . $subtitle . '</div><ul><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchcontaining', $term), "search={$term}&fulltext=Search") . '</li><li>' . $l->makeKnownLink($wgContLang->specialPage('Search'), wfMsg('searchnamed', $term), "search={$term}&go=Go") . "</li></ul><h2>" . wfMsg('articletitles', $term) . "</h2>" . '<ul>' . $r . '</ul>' . $more;
    $response = new AjaxResponse($html);
    $response->setCacheDuration(30 * 60);
    return $response;
}
Example #2
0
function js_unescape($cmd)
{
    // --------------
    // only one level nested arrays
    $i = 0;
    $pos = 0;
    $ret = array();
    while (true) {
        $i++;
        if ($i > 100) {
            break;
        }
        $pos1 = strpos($cmd, '~', $pos);
        $pos2 = strpos($cmd, '!!', $pos1);
        $pos3 = strpos($cmd, '[', $pos1);
        if ($pos1 === 0 || $pos >= strlen($cmd)) {
            break;
        }
        if ($pos3 === false || $pos2 < $pos3) {
            $ret[urldecode(substr($cmd, $pos, $pos1 - $pos))] = urldecode(substr($cmd, $pos1 + 1, $pos2 - $pos1 - 1));
            $pos = $pos2 + 2;
        } else {
            $pos4 = strpos($cmd, ']', $pos3);
            $ret[urldecode(substr($cmd, $pos, $pos1 - $pos))] = js_unescape(substr($cmd, $pos3 + 1, $pos4 - $pos3 - 1));
            $pos = $pos4 + 3;
        }
    }
    return $ret;
}
function wfSajaxSearch($term)
{
    global $wgContLang, $wgOut, $wgUser, $wgCapitalLinks, $wgMemc;
    $limit = 16;
    $sk = $wgUser->getSkin();
    $output = '';
    $term = trim($term);
    $term = $wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)));
    if ($wgCapitalLinks) {
        $term = $wgContLang->ucfirst($term);
    }
    $term_title = Title::newFromText($term);
    $memckey = $term_title ? wfMemcKey('ajaxsearch', md5($term_title->getFullText())) : wfMemcKey('ajaxsearch', md5($term));
    $cached = $wgMemc->get($memckey);
    if (is_array($cached) && $cached['version'] == AJAX_SEARCH_VERSION) {
        $response = new AjaxResponse($cached['html']);
        $response->setCacheDuration(30 * 60);
        return $response;
    }
    $r = $more = '';
    $canSearch = true;
    $results = PrefixSearch::titleSearch($term, $limit + 1);
    foreach (array_slice($results, 0, $limit) as $titleText) {
        $r .= '<li>' . $sk->makeKnownLink($titleText) . "</li>\n";
    }
    // Hack to check for specials
    if ($results) {
        $t = Title::newFromText($results[0]);
        if ($t && $t->getNamespace() == NS_SPECIAL) {
            $canSearch = false;
            if (count($results) > $limit) {
                $more = '<i>' . $sk->makeKnownLinkObj(SpecialPage::getTitleFor('Specialpages'), wfMsgHtml('moredotdotdot')) . '</i>';
            }
        } else {
            if (count($results) > $limit) {
                $more = '<i>' . $sk->makeKnownLinkObj(SpecialPage::getTitleFor("Allpages", $term), wfMsgHtml('moredotdotdot')) . '</i>';
            }
        }
    }
    $valid = (bool) $term_title;
    $term_url = urlencode($term);
    $term_diplay = htmlspecialchars($valid ? $term_title->getFullText() : $term);
    $subtitlemsg = $valid ? 'searchsubtitle' : 'searchsubtitleinvalid';
    $subtitle = wfMsgWikiHtml($subtitlemsg, $term_diplay);
    $html = '<div id="searchTargetHide"><a onclick="Searching_Hide_Results();">' . wfMsgHtml('hideresults') . '</a></div>' . '<h1 class="firstHeading">' . wfMsgHtml('search') . '</h1><div id="contentSub">' . $subtitle . '</div>';
    if ($canSearch) {
        $html .= '<ul><li>' . $sk->makeKnownLink($wgContLang->specialPage('Search'), wfMsgHtml('searchcontaining', $term_diplay), "search={$term_url}&fulltext=Search") . '</li><li>' . $sk->makeKnownLink($wgContLang->specialPage('Search'), wfMsgHtml('searchnamed', $term_diplay), "search={$term_url}&go=Go") . "</li></ul>";
    }
    if ($r) {
        $html .= "<h2>" . wfMsgHtml('articletitles', $term_diplay) . "</h2>" . '<ul>' . $r . '</ul>' . $more;
    }
    $wgMemc->set($memckey, array('version' => AJAX_SEARCH_VERSION, 'html' => $html), 30 * 60);
    $response = new AjaxResponse($html);
    $response->setCacheDuration(30 * 60);
    return $response;
}
function wfSajaxSearchArticleFCKeditor($term)
{
    global $wgContLang, $wgExtraNamespaces;
    $limit = 10;
    $ns = NS_MAIN;
    $term = $wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)));
    if (strpos(strtolower($term), 'category:') === 0) {
        $ns = NS_CATEGORY;
        $term = substr($term, 9);
        $prefix = 'Category:';
    } elseif (strpos(strtolower($term), ':category:') === 0) {
        $ns = NS_CATEGORY;
        $term = substr($term, 10);
        $prefix = ':Category:';
    } elseif (strpos(strtolower($term), 'media:') === 0) {
        $ns = NS_IMAGE;
        $term = substr($term, 6);
        $prefix = 'Media:';
    } elseif (strpos(strtolower($term), ':image:') === 0) {
        $ns = NS_IMAGE;
        $term = substr(strtolower($term), 7);
        $prefix = ':Image:';
    } elseif (strpos($term, ':') && is_array($wgExtraNamespaces)) {
        $pos = strpos($term, ':');
        $find_ns = array_search(substr($term, 0, $pos), $wgExtraNamespaces);
        if ($find_ns) {
            $ns = $find_ns;
            $prefix = substr($term, 0, $pos + 1);
            $term = substr($term, $pos + 1);
        }
    }
    $term1 = str_replace(' ', '_', $wgContLang->ucfirst($term));
    $term2 = str_replace(' ', '_', $wgContLang->lc($term));
    $term3 = str_replace(' ', '_', $wgContLang->uc($term));
    $term4 = str_replace(' ', '_', $wgContLang->ucfirst($term2));
    $term = $term1;
    if (strlen(str_replace('_', '', $term)) < 3) {
        return '';
    }
    $dbr = wfGetDB(DB_SLAVE);
    $res = $dbr->select('page', 'page_title', array('page_namespace' => $ns, "page_title LIKE '%" . $dbr->strencode($term1) . "%' " . "OR (page_title LIKE '%" . $dbr->strencode($term2) . "%') " . "OR (page_title LIKE '%" . $dbr->strencode($term3) . "%') " . "OR (page_title LIKE '%" . $dbr->strencode($term4) . "%') "), __METHOD__, array('LIMIT' => $limit + 1));
    $ret = '';
    $i = 0;
    while (($row = $dbr->fetchObject($res)) && ++$i <= $limit) {
        if (isset($prefix) && !is_null($prefix)) {
            $ret .= $prefix;
        }
        $ret .= $row->page_title . "\n";
    }
    $term = htmlspecialchars($term);
    return $ret;
}
function wfSajaxSearchCategoryCKeditor($term)
{
    //09.01.14 RL $term added
    global $wgContLang;
    //09.01.14 RL
    $term = $wgContLang->checkTitleEncoding($wgContLang->recodeInput(js_unescape($term)));
    //09.01.14 RL
    $ns = NS_CATEGORY;
    //=14
    $dbr = wfGetDB(DB_SLAVE);
    /** @todo FIXME: should use Database class */
    //09.01.14 RL->
    $term1 = $wgContLang->ucfirst($term);
    $term2 = $wgContLang->lc($term);
    $term3 = $wgContLang->uc($term);
    $term4 = $wgContLang->ucfirst($term2);
    $term = $term1;
    if ($term != "") {
        // $search will be added to mysql query string below
        $searchr = "AND ( tmpSelectCat1.cl_to LIKE '%" . $dbr->strencode($term1) . "%' " . "OR (LOWER(CONVERT(tmpSelectCat1.cl_to, CHAR)) LIKE '%" . $dbr->strencode($term2) . "%') " . "OR (UPPER(CONVERT(tmpSelectCat1.cl_to, CHAR)) LIKE '%" . $dbr->strencode($term3) . "%') " . "OR (tmpSelectCat1.cl_to LIKE '%" . $dbr->strencode($term4) . "%') " . ") ";
    } else {
        $searchr = "";
    }
    //09.01.14 RL<-
    $m_sql = "SELECT tmpSelectCat1.cl_to AS title FROM " . $dbr->tableName('categorylinks') . " AS tmpSelectCat1 " . "LEFT JOIN " . $dbr->tableName('page') . " AS tmpSelectCatPage ON ( tmpSelectCat1.cl_to = tmpSelectCatPage.page_title " . "AND tmpSelectCatPage.page_namespace ={$ns} ) " . "LEFT JOIN " . $dbr->tableName('categorylinks') . " AS tmpSelectCat2 ON tmpSelectCatPage.page_id = tmpSelectCat2.cl_from " . "WHERE tmpSelectCat2.cl_from IS NULL " . $searchr . " " . "GROUP BY tmpSelectCat1.cl_to";
    $res = $dbr->query($m_sql, __METHOD__);
    $ret = '';
    $i = 0;
    while ($row = $dbr->fetchObject($res)) {
        $ret .= $row->title . "\n";
        $sub = explode("\n", wfSajaxSearchCategoryChildrenCKeditor($row->title));
        foreach ($sub as $subrow) {
            if (strlen($subrow) > 0) {
                $ret .= ' ' . $subrow . "\n";
            }
        }
    }
    return $ret;
}
Example #6
0
<?php

$output = false;
require_once "../system/security.php";
require_once $sys_folder . "/libs/phpDB.php";
require_once $sys_folder . "/libs/phpDBLib.php";
$lstParams = js_unescape($cmd);
if ($lstParams['db'] == '') {
    $lstParams['db'] = 'template1';
}
$tmp = split(":", $_SESSION['ses_database']);
$sys_dbType = 'postgres';
$sys_dbIP = $tmp[0];
$sys_dbPort = $tmp[1];
$sys_dbLogin = $tmp[2];
$sys_dbPass = $tmp[3];
$sys_dbName = $lstParams['db'];
$db = new phpDBConnection($sys_dbType);
$db->connect($sys_dbIP, $sys_dbLogin, $sys_dbPass, $sys_dbName, $sys_dbPort);
require "features.php";
switch ($lstParams['req_name'] . "::" . $lstParams['req_cmd']) {
    case "viewScript::edit_get_data":
        $vw = split("\\.", $lstParams['view']);
        $sql = "SELECT definition FROM pg_views\n\t\t\t\tWHERE viewname = '" . $vw[2] . "'\n\t\t\t\t\tAND schemaname = '" . $vw[1] . "'";
        $rs = $db->execute($sql);
        $sql = $rs->fields[0];
        // -- process edit
        print "document.getElementById('sql').value = \"CREATE OR REPLACE VIEW " . $lstParams['view'] . " AS \\n" . addslashes($sql) . "\";";
        print "top.elements['viewScript'].dataReceived();";
        break;
    case "viewData::lst_get_data":
function wfLog($args)
{
    global $wgContLang;
    wfDebug("log1:{$args}\n");
    $args = $wgContLang->recodeInput(js_unescape($args));
    wfDebug("log2:{$args}\n");
}
Example #8
0
require_once dirname(__FILE__) . "/../include/common.inc.php";
require_once SLINEDATA . "/webinfo.php";
//添加结伴信息.
if ($dopost == 'addjieban') {
    $aid = GetLastAid('#@__leave');
    $time = time();
    $title = "{$leavename}拼团结伴信息";
    $leaveip = GetIP();
    $sql = "insert into #@__leave(webid,aid,leavename,qq,msn,email,title,content,leaveip,telephone,ishidden,addtime) values({$sys_webid},'{$aid}','{$leavename}','{$qq}','{$msn}','{$email}','{$title}','{$content}','{$leaveip}','{$telephone}','{$ishidden}','{$time}')";
    if ($dsql->ExecuteNoneQuery($sql)) {
        echo 'ok';
    }
}
//获取目的地信息
if ($dopost == 'getDest') {
    $keyword = js_unescape($keyword);
    $rule = "/^[a-zA-Z]+\$/i";
    if (!preg_match($rule, $keyword)) {
        $sql = "select kindname from #@__destinations where isopen='1' and kindname like '%{$keyword}%' limit 0,10";
        $res = $dsql->getAll($sql);
        $str = '';
        foreach ($res as $row) {
            $row['kindname'] = str_replace($keyword, '<b>' . $keyword . '</b>', $row['kindname']);
            $str .= $row['kindname'] . ',';
        }
        $str = substr($str, 0, strlen($str) - 1);
    } else {
        $str = matchPinyin($keyword, 'place');
    }
    echo $str;
}
Example #9
0
function tag_search($tagname, $sex, $tagid)
{
    global $_MooClass, $dbTablePre, $userid, $user_arr, $last_login_time;
    $returnurl = 'index.php?' . $_SERVER['QUERY_STRING'];
    //返回的url
    //$searchtable = $sex=='0' ? 'membersfastadvance_man' : 'membersfastadvance_women';
    $searchtable = 'members_search';
    /* 以下分页参数设置 */
    //note  每页显示个数
    if (isset($_GET['condition']) && $_GET['condition'] == '2') {
        $pagesize = 6;
    } else {
        if (isset($_GET['condition']) && $_GET['condition'] == '3') {
            $pagesize = 16;
        } else {
            $pagesize = 6;
        }
    }
    if (isset($_GET['m']) && $_GET['m'] == 'js') {
        $linktag = js_unescape(MooGetGPC('linktag', 'string', 'G'));
    } else {
        $linktag = str_replace(' ', '+', MooGetGPC('linktag', 'string', 'G'));
        $linktag = base64_decode($linktag);
    }
    //=============取 当前 登录 网站用户的IP地址  对应所在 地区begin====================================
    $work_city = getLocalArea();
    //exit($linktag);
    //note 获得第几页
    $page = 1;
    if (isset($_GET['page'])) {
        $page = intval(max(1, $_GET['page']));
    }
    $offset = ($page - 1) * $pagesize;
    /*******排序方式********/
    $sortway = isset($_GET['sortway']) ? $_GET['sortway'] : '1';
    //echo $sortway;
    //$sortway = intval($sortway);
    //note 普通会员搜索结果还是按照以前的排序,高级、钻石会员搜索结果按照本站注册的排序
    //	if($user_arr["s_cid"]=="40"){
    //		if($sortway == '1'){
    //			//note 默认排序
    //			$sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`city_star` DESC,images_ischeck desc ";
    //		}elseif($sortway == '2'){
    //			//note 最新注册的排序
    //			$sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`regdate`  DESC,s_cid asc ,images_ischeck desc ";
    //		}elseif($sortway == '3'){
    //			//note 按照诚信等级排序
    //			$sort = "ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`certification` DESC,s_cid asc,images_ischeck desc ";
    //		}else{
    //			//note 默认排序
    //			$sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`city_star` DESC,s_cid asc ,images_ischeck desc";
    //		}
    //	}else{
    //		if($sortway == '1'){
    //			//note 默认排序
    //			$sort = " ORDER BY `city_star` DESC,usertype asc,s_cid asc ";
    //		}elseif($sortway == '2'){
    //			//note 最新注册的排序
    //			$sort = " ORDER BY `regdate`  DESC,usertype asc,s_cid asc ";
    //		}elseif($sortway == '3'){
    //			//note 按照诚信等级排序
    //			$sort = "ORDER BY `certification` DESC,usertype asc,s_cid asc ";
    //		}else{
    //			//note 默认排序
    //			$sort = " ORDER BY `city_star` DESC,usertype asc,s_cid asc ";
    //		}
    //	}
    $cond = array();
    $user = array();
    //note 年龄标签搜索
    if ($tagname == 'age') {
        switch ($tagid) {
            case '1':
                $bsql = " AND `birthyear` > '1984' AND `birthyear` < '1991'";
                $birth_start = 1984;
                $birth_end = 1991;
                break;
            case '2':
                $bsql = " AND `birthyear` > '1974' AND `birthyear` < '1983'";
                $birth_start = 1974;
                $birth_end = 1983;
                break;
            case '3':
                $bsql = " AND `birthyear` > '1964' AND `birthyear` < '1973'";
                $birth_start = 1964;
                $birth_end = 1973;
                break;
            case '4':
                $bsql = " AND `birthyear` > '1954' AND `birthyear` < '1963'";
                $birth_start = 1954;
                $birth_end = 1963;
                break;
            case '5':
                $bsql = " AND `birthyear` > '1949' AND `birthyear` < '1953'";
                $birth_start = 1949;
                $birth_end = 1953;
                break;
            case '6':
                $bsql = " AND `birthyear` < '1949' ";
                $birth_start = 1900;
                $birth_end = 1948;
                break;
            default:
                $bsql = "";
                $birth_start = 1900;
                $birth_end = 1991;
                break;
        }
        $cond[] = array('birthyear', array($birth_start, $birth_end), false);
        $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
        $total = 0;
        if (isset($rs['total_found'])) {
            $total = $rs['total_found'];
        }
        if ($total > 600) {
            $total = 600;
        }
        $total_pages = ceil($total / $pagesize);
        $page = min($page, $total_pages);
        if ($total > 0) {
            $ids = array();
            if (isset($rs['ids'])) {
                $ids = $rs['ids'];
            }
            if (!empty($ids)) {
                $ids_str = implode(',', $ids);
                $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                $user = userbasicadd($user);
            }
            $recommend = array();
            if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                //推荐会员信息
                $ids2 = $rs['ids2'];
                $ids_str2 = implode(',', $ids2);
                $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                shuffle($recommend_list);
                $recommend = array_slice($recommend_list, 0, 6);
            }
        }
        //note 查询出来的总数
        /*
                $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` where is_lock = 1 and `gender` = '$sex' $bsql");
                $total = $total_count["count"];
                if ($total > 600) {
                    $total = 600;
                }*/
        //		$total = 600;
        //
        $total_pages = ceil($total / $pagesize);
        $page = min($page, $total_pages);
        $start = 0;
        //
        //        //note limit查询开始位置
        //        $start = ($page - 1) * $pagesize;
        //        if ($total - $start < $pagesize) {
        //            $pagesize = $total - $start;
        //        }
        //        if ($total > 0) {
        //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' $bsql $sort LIMIT $start,$pagesize");
        //			$user = userbasicadd($user);
        //            //推荐会员信息
        //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` b where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' $bsql and b.is_vote='1' LIMIT 6");
        //            shuffle($recommend_list);
        //
        //            $recommend = array_slice($recommend_list, 0,6);
        //        }
        //note 收入标签搜索
    } else {
        if ($tagname == 'salary') {
            switch ($tagid) {
                case '1':
                    $ssql = " AND `salary` >= '7'";
                    $sal_type = '7|8|9';
                    break;
                case '2':
                    $ssql = " AND `salary` >= '5' AND `salary` <= '6'";
                    $sal_type = '5|6';
                    break;
                case '3':
                    $ssql = " AND `salary` = '4'";
                    $sal_type = '4';
                    break;
                case '4':
                    $ssql = " AND `salary` <= '3'";
                    $sal_type = '1|2|3';
                    break;
            }
            $cond[] = array('salary', $sal_type, false);
            $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
            $total = 0;
            if (isset($rs['total_found'])) {
                $total = $rs['total_found'];
            }
            if ($total > 600) {
                $total = 600;
            }
            $total_pages = ceil($total / $pagesize);
            $page = min($page, $total_pages);
            if ($total > 0) {
                $ids = array();
                if (isset($rs['ids'])) {
                    $ids = $rs['ids'];
                }
                if (!empty($ids)) {
                    $ids_str = implode(',', $ids);
                    $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                    $user = userbasicadd($user);
                }
                $recommend = array();
                if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                    //推荐会员信息
                    $ids2 = $rs['ids2'];
                    $ids_str2 = implode(',', $ids2);
                    $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                    shuffle($recommend_list);
                    $recommend = array_slice($recommend_list, 0, 6);
                }
            }
            /*
                    //note 查询出来的总数
                    $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` where is_lock = 1 and `gender` = '$sex' $ssql");
                    //$total = $_MooClass['MooMySQL']->numRows($query);
                    $total = $total_count["count"];
                    if ($total > 600) {
                        $total = 600;
                    }
            */
            //		$total = 600;
            //
            //        $total_pages = ceil($total / $pagesize);
            //        $page = min($page, $total_pages);
            //
            //        //note limit查询开始位置
            //        $start = ($page - 1) * $pagesize;
            //        if ($total - $start < $pagesize) {
            //            $pagesize = $total - $start;
            //        }
            //
            //        if ($total > 0) {
            //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' $ssql  $sort LIMIT $start,$pagesize");
            //			$user = userbasicadd($user);
            //            //推荐会员信息
            //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` b where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' $ssql  and b.is_vote='1' LIMIT 6");
            //            shuffle($recommend_list);
            //            $recommend = array_slice($recommend_list, 0, 6);
            //        }
            //note 学历标签搜索
        } else {
            if ($tagname == 'education') {
                switch ($tagid) {
                    case '1':
                        $ssql = " AND `education` = '7'";
                        $edu = '7';
                        break;
                    case '2':
                        $ssql = " AND `education` = '6'";
                        $edu = '6';
                        break;
                    case '3':
                        $ssql = " AND `education` = '5'";
                        $edu = '5';
                        break;
                    case '4':
                        $ssql = " AND `education` = '4'";
                        $edu = '4';
                        break;
                    case '5':
                        $ssql = " AND `education` = '3'";
                        $edu = '3';
                        break;
                }
                $cond[] = array('education', $edu, false);
                $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                $total = 0;
                if (isset($rs['total_found'])) {
                    $total = $rs['total_found'];
                }
                if ($total > 600) {
                    $total = 600;
                }
                $total_pages = ceil($total / $pagesize);
                $page = min($page, $total_pages);
                if ($total > 0) {
                    $ids = array();
                    if (isset($rs['ids'])) {
                        $ids = $rs['ids'];
                    }
                    if (!empty($ids)) {
                        $ids_str = implode(',', $ids);
                        $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                        $user = userbasicadd($user);
                    }
                    $recommend = array();
                    if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                        //推荐会员信息
                        $ids2 = $rs['ids2'];
                        $ids_str2 = implode(',', $ids2);
                        $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                        shuffle($recommend_list);
                        $recommend = array_slice($recommend_list, 0, 6);
                    }
                }
                /*
                        //note 查询出来的总数
                        $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` where is_lock = 1 and `gender` = '$sex' $ssql");
                        $total = $total_count["count"];
                        if ($total > 600) {
                            $total = 600;
                        }
                */
                //		$total = 600;
                //
                //        $total_pages = ceil($total / $pagesize);
                //        $page = min($page, $total_pages);
                //
                //        //note limit查询开始位置
                //        $start = ($page - 1) * $pagesize;
                //        if ($total - $start < $pagesize) {
                //            $pagesize = $total - $start;
                //        }
                //        if ($total > 0) {
                //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' $ssql  $sort LIMIT $start,$pagesize");
                //			$user = userbasicadd($user);
                //            //推荐会员信息
                //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` b where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' $ssql LIMIT 6");
                //            shuffle($recommend_list);
                //            $recommend = array_slice($recommend_list, 0, 6);
                //        }
                //note 车房标签搜索
            } else {
                if ($tagname == 'housvehicle') {
                    switch ($tagid) {
                        case '1':
                            $ssql = " from {$dbTablePre}" . $searchtable . " where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND vehicle = '1'";
                            $cond[] = array('vehicle', '1', false);
                            break;
                        case '2':
                            $ssql = " from {$dbTablePre}" . $searchtable . " where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND (`house` = '2' OR `house` = '4')";
                            $cond[] = array('house', '2|4', false);
                            break;
                    }
                    $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                    $total = 0;
                    if (isset($rs['total_found'])) {
                        $total = $rs['total_found'];
                    }
                    if ($total > 600) {
                        $total = 600;
                    }
                    $total_pages = ceil($total / $pagesize);
                    $page = min($page, $total_pages);
                    if ($total > 0) {
                        $ids = array();
                        if (isset($rs['ids'])) {
                            $ids = $rs['ids'];
                        }
                        if (!empty($ids)) {
                            $ids_str = implode(',', $ids);
                            $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                            $user = userbasicadd($user);
                        }
                        $recommend = array();
                        if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                            //推荐会员信息
                            $ids2 = $rs['ids2'];
                            $ids_str2 = implode(',', $ids2);
                            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                            shuffle($recommend_list);
                            $recommend = array_slice($recommend_list, 0, 6);
                        }
                    }
                    /*
                            //note 查询出来的总数
                            $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count" . $ssql);
                            $total = $total_count["count"];
                            if ($total > 600) {
                                $total = 600;
                            }
                    */
                    //		$total = 600;
                    //
                    //        $total_pages = ceil($total / $pagesize);
                    //        $page = min($page, $total_pages);
                    //
                    //        //note limit查询开始位置
                    //        $start = ($page - 1) * $pagesize;
                    //        if ($total - $start < $pagesize) {
                    //            $pagesize = $total - $start;
                    //        }
                    ////		echo $ssql;die;
                    //        if ($total > 0) {
                    //            $user = $_MooClass['MooMySQL']->getAll("select * " . $ssql . $sort . " LIMIT " . $start . "," . $pagesize);
                    //			$user = userbasicadd($user);
                    //            //推荐会员信息
                    //			switch ($tagid) {
                    //				case '1':
                    //					$ssql = " from {$dbTablePre}members_search s, {$dbTablePre}members_base sf where images_ischeck='1' and is_lock='1' and s.uid=sf.uid AND `gender` = '{$sex}' AND s.vehicle = '1'";
                    //					break;
                    //				case '2':
                    //					$ssql = " from {$dbTablePre}members_search where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND (`house` = '2' OR `house` = '4')";
                    //					break;
                    //			}
                    //            $recommend_list = $_MooClass['MooMySQL']->getAll("select * " . $ssql . " and is_vote='1' LIMIT 6");
                    //
                    //            shuffle($recommend_list);
                    //            $recommend = array_slice($recommend_list, 0, 6);
                    //        }
                    //note 城市标签搜索
                } else {
                    if ($tagname == 'city') {
                        //        if ($tagid == '10102000' || $tagid == '10103000' || $tagid == '10105000' || $tagid == '10132000' || $tagid == '10133000' || $tagid == '10134000') {
                        //
                        //*
                        //        //note 查询出来的总数
                        //            $query = $_MooClass['MooMySQL']->getOne("select count(1) as num from `{$dbTablePre}members` where is_lock = 1 and `gender` = '$sex' AND `province` = '$tagid'");
                        //            $total = $query['num'];
                        //            if ($total > 600) {
                        //                $total = 600;
                        //            }
                        //			*/
                        //			$total = 600;
                        //
                        //            $total_pages = ceil($total / $pagesize);
                        //            $page = min($page, $total_pages);
                        //
                        //            //note limit查询开始位置
                        //            $start = ($page - 1) * $pagesize;
                        //            if ($total - $start < $pagesize) {
                        //                $pagesize = $total - $start;
                        //            }
                        //            if ($start < 0) {
                        //                $start = 0;
                        //            }
                        //            $csql = "select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '$sex' AND `province` = '{$tagid}' $sort LIMIT $start,$pagesize";
                        //            $csql2 = "select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '$sex' AND `province` = '{$tagid}' LIMIT 20";
                        //        } else {
                        //			/*
                        //            //note 查询出来的总数
                        //            $total_count = $_MooClass['MooMySQL']->getOne("select count(1) as num from `{$dbTablePre}members` where is_lock = 1 and `gender` = '$sex' AND `city` = '$tagid'");
                        //            $total = $total_count["num"];
                        //			*/
                        //			$total = 600;
                        //
                        //            $is_data = true;
                        //            if ($total == 0) {
                        //                $is_data = false;
                        //                $province = substr($tagid, 0, 5) . "000";
                        //                $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members_search` where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `province` = '{$province}'");
                        //                $total = $total_count["count"];
                        //            }
                        //			/*
                        //            if ($total > 600) {
                        //                $total = 600;
                        //            }
                        //			*/
                        //            $total_pages = ceil($total / $pagesize);
                        //            $page = min($page, $total_pages);
                        //
                        //            //note limit查询开始位置
                        //            $start = ($page - 1) * $pagesize;
                        //            if ($total - $start < $pagesize) {
                        //                $pagesize = $total - $start;
                        //            }
                        //            if ($start < 0) {
                        //                $start = 0;
                        //            }
                        //
                        $cond[] = array('province', $tagid, false);
                        $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                        if (!isset($rs['ids']) || empty($rs['ids'])) {
                            $cond = array();
                            $cond[] = array('city', $tagid, false);
                            $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                        }
                        $total = 0;
                        if (isset($rs['total_found'])) {
                            $total = $rs['total_found'];
                        }
                        if ($total > 600) {
                            $total = 600;
                        }
                        $total_pages = ceil($total / $pagesize);
                        $page = min($page, $total_pages);
                        if ($total > 0) {
                            $ids = array();
                            if (isset($rs['ids'])) {
                                $ids = $rs['ids'];
                            }
                            if (!empty($ids)) {
                                $ids_str = implode(',', $ids);
                                $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                $user = userbasicadd($user);
                            }
                            $recommend = array();
                            if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                //推荐会员信息
                                $ids2 = $rs['ids2'];
                                $ids_str2 = implode(',', $ids2);
                                $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                shuffle($recommend_list);
                                $recommend = array_slice($recommend_list, 0, 6);
                            }
                        }
                        //            if ($is_data) {
                        //                $csql = "select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `city` = '{$tagid}' $sort LIMIT $start,$pagesize";
                        //                $csql2 = "select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` b where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' AND s.`city` = '{$tagid}' and b.is_vote='1' LIMIT 6";
                        //            } else {
                        //                $province = substr($tagid, 0, 5) . "000";
                        //                $csql = "select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `province` = '$province' $sort LIMIT $start,$pagesize";
                        //                $csql2 = "select uid,gender,mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `province` = '$province' and is_vote='1'  LIMIT 6";
                        //            }
                        //        }
                        //        if ($total > 0) {
                        //            $user = $_MooClass['MooMySQL']->getAll($csql);
                        //			$user = userbasicadd($user);
                        //            //推荐会员信息
                        //            $recommend_list = $_MooClass['MooMySQL']->getAll($csql2);
                        //            shuffle($recommend_list);
                        //            $recommend = array_slice($recommend_list, 0, 6);
                        //        }
                        //note 职业标签搜索
                    } else {
                        if ($tagname == 'occupation') {
                            switch ($tagid) {
                                case '1':
                                    $osql = " AND s.`occupation` = '7'";
                                    $o_cond = '7';
                                    break;
                                case '2':
                                    $osql = " AND s.`occupation` = '26'";
                                    $o_cond = '26';
                                    break;
                                case '3':
                                    $o_cond = '5|16|17|40';
                                    $osql = " AND (s.`occupation` = '5' OR s.`occupation` = '16' OR s.`occupation` = '17' OR s.`occupation` = '40')";
                                    break;
                                case '4':
                                    $osql = "  AND (s.`occupation` = '21' OR s.`occupation` = '14')";
                                    $o_cond = '14|21';
                                    break;
                                case '5':
                                    $osql = "  AND (s.`occupation` = '34' OR s.`occupation` = '33')";
                                    $o_cond = '33|34';
                                    break;
                                case '6':
                                    $osql = "  AND (s.`occupation` = '22' OR s.`occupation` = '11')";
                                    $o_cond = '11|22';
                                    break;
                                case '7':
                                    $osql = "  AND (s.`occupation` = '2' OR s.`occupation` = '41')";
                                    $o_cond = '2|41';
                                    break;
                                case '8':
                                    $osql = "  AND s.`occupation` = '1'";
                                    $o_cond = '1';
                                    break;
                                case '9':
                                    $osql = " AND (s.`occupation` = '3' OR s.`occupation` = '4' OR s.`occupation` = '9' OR s.`occupation` = '24' OR s.`occupation` = '99')";
                                    $o_cond = '3|4|9|24|99';
                                    break;
                                case '10':
                                    $osql = "  AND s.`occupation` = '10'";
                                    $o_cond = '10';
                                    break;
                                case '11':
                                    $osql = "  AND s.`occupation` = '27'";
                                    $o_cond = '27';
                                    break;
                                case '12':
                                    $osql = " AND (s.`occupation` = '28' OR s.`occupation` = '29' OR s.`occupation` = '39' OR s.`occupation` = '42')";
                                    $o_cond = '28|29|39|42';
                                    break;
                                case '13':
                                    $osql = " AND (s.`occupation` = '6' OR s.`occupation` = '18' OR s.`occupation` = '19')";
                                    $o_cond = '6|18|19';
                                    break;
                                case '14':
                                    $osql = " AND s.`occupation` = '23'";
                                    $o_cond = '23';
                                    break;
                            }
                            $cond[] = array('occupation', $o_cond, false);
                            $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                            $total = 0;
                            if (isset($rs['total_found'])) {
                                $total = $rs['total_found'];
                            }
                            if ($total > 600) {
                                $total = 600;
                            }
                            $total_pages = ceil($total / $pagesize);
                            $page = min($page, $total_pages);
                            if ($total > 0) {
                                $ids = array();
                                if (isset($rs['ids'])) {
                                    $ids = $rs['ids'];
                                }
                                if (!empty($ids)) {
                                    $ids_str = implode(',', $ids);
                                    $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                    $user = userbasicadd($user);
                                }
                                $recommend = array();
                                if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                    //推荐会员信息
                                    $ids2 = $rs['ids2'];
                                    $ids_str2 = implode(',', $ids2);
                                    $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                    shuffle($recommend_list);
                                    $recommend = array_slice($recommend_list, 0, 6);
                                }
                            }
                            //		echo $osql;die;
                            //		echo "select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `uid` = sf.`uid` AND `gender` = '$sex' $osql";die;
                            /*
                                    //note 查询出来的总数
                                    $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and s.`uid` = sf.`uid` AND `gender` = '$sex' $osql");
                                    $total = $total_count["count"];
                                    if ($total > 600) {
                                        $total = 600;
                                    }
                            */
                            //		$total = 600;
                            //
                            //        $total_pages = ceil($total / $pagesize);
                            //        $page = min($page, $total_pages);
                            //
                            //        //note limit查询开始位置
                            //        $start = ($page - 1) * $pagesize;
                            //        if ($total - $start < $pagesize) {
                            //            $pagesize = $total - $start;
                            //        }
                            //        if ($total > 0) {
                            //            $csql = "select * from {$dbTablePre}".$searchtable." s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and s.`uid` = sf.`uid` AND s.`gender` = '{$sex}' $osql  $sort LIMIT $start,$pagesize";
                            //            $csql2 = "select s.uid,gender,mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and s.`uid` = sf.`uid` AND `gender` = '{$sex}' $osql and  is_vote='1'  LIMIT 6";
                            //            $user = $_MooClass['MooMySQL']->getAll($csql);
                            //			$user = userbasicadd($user);
                            //            //推荐会员信息
                            //            $recommend_list = $_MooClass['MooMySQL']->getAll($csql2);
                            //
                            //            shuffle($recommend_list);
                            //            $recommend = array_slice($recommend_list, 0, 6);
                            //        }
                            //note 血型标签搜索
                        } else {
                            if ($tagname == 'bloodtype') {
                                $cond[] = array('bloodtype', $tagid, false);
                                $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                                $total = 0;
                                if (isset($rs['total_found'])) {
                                    $total = $rs['total_found'];
                                }
                                if ($total > 600) {
                                    $total = 600;
                                }
                                $total_pages = ceil($total / $pagesize);
                                $page = min($page, $total_pages);
                                if ($total > 0) {
                                    $ids = array();
                                    if (isset($rs['ids'])) {
                                        $ids = $rs['ids'];
                                    }
                                    if (!empty($ids)) {
                                        $ids_str = implode(',', $ids);
                                        $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                        $user = userbasicadd($user);
                                    }
                                    $recommend = array();
                                    if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                        //推荐会员信息
                                        $ids2 = $rs['ids2'];
                                        $ids_str2 = implode(',', $ids2);
                                        $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                        shuffle($recommend_list);
                                        $recommend = array_slice($recommend_list, 0, 6);
                                    }
                                }
                                /*
                                        //note 查询出来的总数
                                        $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `gender` = '$sex' AND s.`uid` = sf.`uid` AND sf.`bloodtype` = '$tagid'");
                                        $total = $total_count["count"];
                                        if ($total > 600) {
                                            $total = 600;
                                        }
                                */
                                //		$total = 600;
                                //
                                //        $total_pages = ceil($total / $pagesize);
                                //        $page = min($page, $total_pages);
                                //
                                //        //note limit查询开始位置
                                //        $start = ($page - 1) * $pagesize;
                                //        if ($total - $start < $pagesize) {
                                //            $pagesize = $total - $start;
                                //        }
                                //        if ($total > 0) {
                                //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND bloodtype = '{$tagid}'  $sort LIMIT $start,$pagesize");
                                //			$user = userbasicadd($user);
                                //            //推荐会员信息
                                //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,gender,mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and `gender` = '$sex' AND s.`uid` = sf.`uid` AND s.`bloodtype` = '{$tagid}' and is_vote='1'  LIMIT 6");
                                //            shuffle($recommend_list);
                                //            $recommend = array_slice($recommend_list, 0, 6);
                                //        }
                                //note 星座标签搜索
                            } else {
                                if ($tagname == 'constellation') {
                                    $cond[] = array('constellation', $tagid, false);
                                    $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                                    $total = 0;
                                    if (isset($rs['total_found'])) {
                                        $total = $rs['total_found'];
                                    }
                                    if ($total > 600) {
                                        $total = 600;
                                    }
                                    $total_pages = ceil($total / $pagesize);
                                    $page = min($page, $total_pages);
                                    if ($total > 0) {
                                        $ids = array();
                                        if (isset($rs['ids'])) {
                                            $ids = $rs['ids'];
                                        }
                                        if (!empty($ids)) {
                                            $ids_str = implode(',', $ids);
                                            $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                            $user = userbasicadd($user);
                                        }
                                        $recommend = array();
                                        if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                            //推荐会员信息
                                            $ids2 = $rs['ids2'];
                                            $ids_str2 = implode(',', $ids2);
                                            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                            shuffle($recommend_list);
                                            $recommend = array_slice($recommend_list, 0, 6);
                                        }
                                    }
                                    /*
                                            //note 查询出来的总数
                                            $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `gender` = '$sex' AND s.`uid` = sf.`uid` AND sf.`constellation` = '$tagid'");
                                            $total = $total_count["count"];
                                            if ($total > 600) {
                                                $total = 600;
                                            }
                                    */
                                    //		$total = 600;
                                    //
                                    //        $total_pages = ceil($total / $pagesize);
                                    //        $page = min($page, $total_pages);
                                    //
                                    //        //note limit查询开始位置
                                    //        $start = ($page - 1) * $pagesize;
                                    //        if ($total - $start < $pagesize) {
                                    //            $pagesize = $total - $start;
                                    //        }
                                    //        if ($total > 0) {
                                    //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `constellation` = '{$tagid}'  $sort LIMIT $start,$pagesize");
                                    //			$user = userbasicadd($user);
                                    //            //推荐会员信息
                                    //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,gender,mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and `gender` = '{$sex}' AND s.`uid` = sf.`uid` AND s.`constellation` = '{$tagid}' and is_vote='1' LIMIT 6");
                                    //            shuffle($recommend_list);
                                    //            $recommend = array_slice($recommend_list, 0, 6);
                                    //        }
                                    //note 生肖标签搜索
                                } else {
                                    if ($tagname == 'animalyear') {
                                        $cond[] = array('animalyear', $tagid, false);
                                        $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                                        $total = 0;
                                        if (isset($rs['total_found'])) {
                                            $total = $rs['total_found'];
                                        }
                                        if ($total > 600) {
                                            $total = 600;
                                        }
                                        $total_pages = ceil($total / $pagesize);
                                        $page = min($page, $total_pages);
                                        if ($total > 0) {
                                            $ids = array();
                                            if (isset($rs['ids'])) {
                                                $ids = $rs['ids'];
                                            }
                                            if (!empty($ids)) {
                                                $ids_str = implode(',', $ids);
                                                $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                                $user = userbasicadd($user);
                                            }
                                            $recommend = array();
                                            if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                                //推荐会员信息
                                                $ids2 = $rs['ids2'];
                                                $ids_str2 = implode(',', $ids2);
                                                $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                                shuffle($recommend_list);
                                                $recommend = array_slice($recommend_list, 0, 6);
                                            }
                                        }
                                        /*
                                                //note 查询出来的总数
                                                $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `gender` = '$sex' AND s.`uid` = sf.`uid` AND sf.`animalyear` = '$tagid'");
                                                $total = $total_count["count"];
                                                if ($total > 600) {
                                                    $total = 600;
                                                }
                                        */
                                        //		$total = 600;
                                        //
                                        //        $total_pages = ceil($total / $pagesize);
                                        //        $page = min($page, $total_pages);
                                        //
                                        //        //note limit查询开始位置
                                        //        $start = ($page - 1) * $pagesize;
                                        //        if ($total - $start < $pagesize) {
                                        //            $pagesize = $total - $start;
                                        //        }
                                        //
                                        //        if ($total > 0) {
                                        //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `animalyear` = '{$tagid}'  $sort LIMIT $start,$pagesize");
                                        //			$user = userbasicadd($user);
                                        //            //推荐会员信息
                                        //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,gender,sf.mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and `gender` = '{$sex}' AND s.`uid` = sf.`uid` AND s.`animalyear` = '{$tagid}' and sf.is_vote='1' LIMIT 6");
                                        //            shuffle($recommend_list);
                                        //            $recommend = array_slice($recommend_list, 0, 6);
                                        //        }
                                        //note 体型标签搜索
                                    } else {
                                        if ($tagname == 'body') {
                                            $cond[] = array('body', $tagid, false);
                                            $rs = SearchByTag($sex, $sortway, $cond, $offset, $pagesize);
                                            $total = 0;
                                            if (isset($rs['total_found'])) {
                                                $total = $rs['total_found'];
                                            }
                                            if ($total > 600) {
                                                $total = 600;
                                            }
                                            $total_pages = ceil($total / $pagesize);
                                            $page = min($page, $total_pages);
                                            if ($total > 0) {
                                                $ids = array();
                                                if (isset($rs['ids'])) {
                                                    $ids = $rs['ids'];
                                                }
                                                if (!empty($ids)) {
                                                    $ids_str = implode(',', $ids);
                                                    $user = $_MooClass['MooMySQL']->getAll("select s.*,b.mainimg from {$dbTablePre}" . $searchtable . " s left join {$dbTablePre}members_base b on s.uid=b.uid where s.uid in ({$ids_str})");
                                                    $user = userbasicadd($user);
                                                }
                                                $recommend = array();
                                                if (isset($rs['ids2']) && !empty($rs['ids2'])) {
                                                    //推荐会员信息
                                                    $ids2 = $rs['ids2'];
                                                    $ids_str2 = implode(',', $ids2);
                                                    $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,b.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` b on s.uid=b.uid where s.uid in ({$ids_str2})");
                                                    shuffle($recommend_list);
                                                    $recommend = array_slice($recommend_list, 0, 6);
                                                }
                                            }
                                            /*
                                                    //note 查询出来的总数
                                                    $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `gender` = '$sex' AND s.`uid` = sf.`uid` AND sf.`body` = '$tagid'");
                                                    $total = $total_count["count"];
                                                    if ($total > 600) {
                                                        $total = 600;
                                                    }
                                            */
                                            //		$total = 600;
                                            //
                                            //        $total_pages = ceil($total / $pagesize);
                                            //        $page = min($page, $total_pages);
                                            //
                                            //        //note limit查询开始位置
                                            //        $start = ($page - 1) * $pagesize;
                                            //        if ($total - $start < $pagesize) {
                                            //            $pagesize = $total - $start;
                                            //        }
                                            //        if ($total > 0) {
                                            //            $user = $_MooClass['MooMySQL']->getAll("select * from {$dbTablePre}".$searchtable." where images_ischeck='1' and is_lock='1' and `gender` = '{$sex}' AND `body` = '{$tagid}'  $sort LIMIT $start,$pagesize");
                                            //			$user = userbasicadd($user);
                                            //            //推荐会员信息
                                            //            $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,gender,sf.mainimg,city_star,images_ischeck,s_cid,nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and `gender` = '{$sex}' AND s.`uid` = sf.`uid` AND s.`body` = '{$tagid}'  and is_vote='1'  LIMIT 6");
                                            //            shuffle($recommend_list);
                                            //            $recommend = array_slice($recommend_list, 0, 6);
                                            //        }
                                            //note 性格标签搜索
                                        } else {
                                            if ($tagname == 'nature') {
                                                /*
                                                        //note 查询出来的总数
                                                        $total_count = $_MooClass['MooMySQL']->getOne("select count(*) as count from `{$dbTablePre}members` s,`{$dbTablePre}memberfield` sf where is_lock = 1 and `gender` = '$sex' AND s.`uid` = sf.`uid` AND sf.`nature` = '$tagid'");
                                                        $total = $total_count["count"];
                                                        if ($total > 600) {
                                                            $total = 600;
                                                        }
                                                */
                                                if ($sortway == '1') {
                                                    //note 默认排序
                                                    $sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`city_star` DESC,images_ischeck desc ";
                                                } elseif ($sortway == '2') {
                                                    //note 最新注册的排序
                                                    $sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`regdate`  DESC,s_cid asc ,images_ischeck desc ";
                                                } elseif ($sortway == '3') {
                                                    //note 按照诚信等级排序
                                                    $sort = "ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`certification` DESC,s_cid asc,images_ischeck desc ";
                                                } else {
                                                    //note 默认排序
                                                    $sort = " ORDER BY city<>'{$work_city}',city desc,s_cid asc,pic_num desc,`city_star` DESC,s_cid asc ,images_ischeck desc";
                                                }
                                                $total = 600;
                                                $total_pages = ceil($total / $pagesize);
                                                $page = min($page, $total_pages);
                                                //note limit查询开始位置
                                                $start = ($page - 1) * $pagesize;
                                                if ($total - $start < $pagesize) {
                                                    $pagesize = $total - $start;
                                                }
                                                if ($total > 0) {
                                                    $user = $_MooClass['MooMySQL']->getAll("select s.*,sf.mainimg from `{$dbTablePre}members_search` s left join `{$dbTablePre}members_base` sf on s.uid=sf.uid where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' AND s.`uid` = sf.`uid` AND sf.`nature` = '{$tagid}' {$sort} LIMIT {$start},{$pagesize}");
                                                    $user = userbasicadd($user);
                                                    //推荐会员信息
                                                    $recommend_list = $_MooClass['MooMySQL']->getAll("select s.uid,s.gender,sf.mainimg,s.city_star,s.images_ischeck,s.s_cid,s.nickname  from `{$dbTablePre}members_search` s,`{$dbTablePre}members_base` sf where s.images_ischeck='1' and s.is_lock='1' and s.`gender` = '{$sex}' AND s.`uid` = sf.`uid` AND sf.`nature` = '{$tagid}'  and s.is_vote='1' LIMIT 6");
                                                    shuffle($recommend_list);
                                                    $recommend = array_slice($recommend_list, 0, 6);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (count($user) == '0') {
        require MooTemplate('public/search_error', 'module');
        exit;
    }
    if (isset($_GET['condition']) && $_GET['condition'] == '2') {
        $pagesize = 6;
        $condition = '2';
        $htm = 'search_tag_page';
    } else {
        if (isset($_GET['condition']) && $_GET['condition'] == '3') {
            $pagesize = 16;
        } else {
            $pagesize = 6;
        }
    }
    //	print_r($recommend);die;
    //note 选择不同的显示模式
    if (isset($_GET['condition']) && $_GET['condition'] == '2') {
    } else {
        if (isset($_GET['condition']) && $_GET['condition'] == '3') {
            $condition = '3';
            $htm = 'search_tag_photo';
        } else {
            $condition = '2';
            $htm = 'search_tag_page';
        }
    }
    include MooTemplate('public/' . $htm, 'module');
}