Exemplo n.º 1
0
function youAbleLike(&$l, $num = 0)
{
    global $_MooClass, $dbTablePre, $user_arr, $memcached;
    //note 你喜欢的人,以同地区条件查询,如果城市是0,就查询省,如果省为0就查询国家
    //note 在后面注册功能完善后,有了国家,就要判断国家
    //$user1 = UserInfo();
    $user1 = $user_arr;
    $gender = $user1['gender'] == '1' ? '0' : '1';
    if (18 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 30 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 1;
    }
    if (31 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 35 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 2;
    }
    if (36 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 40 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 3;
    }
    if (41 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 50 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 4;
    }
    if (51 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 60 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 5;
    }
    if (61 <= date("Y") - $user1['birthyear'] && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 6;
    }
    if ($user1['birthyear'] == '' || $user1['birthyear'] == 0) {
        $age = 1;
    }
    if ($user1["province"] == '' || $user1["province"] == 0 || $user1["province"] == -1) {
        $user1["province"] = 10103000;
    }
    $file = $age . "_" . $gender . "_" . $user1["province"] . "_" . $user1["city"];
    //     $cache_file = MOOPHP_DATA_DIR.'/cache/cache_' . $file . '.php';
    $data = $memcached->get($file);
    if (!$data) {
        updateVoteFeel("", "", $user1['province'], $user1['city'], $age, $gender);
        $data = $memcached->get($file);
    }
    if (empty($data)) {
        return $data;
    }
    $l = count($data);
    //shuffle($data);
    $data = array_slice($data, $num, 5);
    for ($j = 0; $j < 5; $j++) {
        //if(MOOPHP_ALLOW_FASTDB){
        if (isset($data[$j])) {
            $able_like[$j] = MooMembersData($data[$j]);
        }
        //MooFastdbGet('members_search','uid',$data[$j]);
        //}
    }
    //echo $cache_file.'<br>';
    //print_r($able_like);
    return $able_like;
}
Exemplo n.º 2
0
function ableLike($num = '12')
{
    global $_MooClass, $dbTablePre, $user_arr, $memcached, $userid;
    //note 你喜欢的人,以同地区条件查询,如果城市是0,就查询省,如果省为0就查询国家
    //note 在后面注册功能完善后,有了国家,就要判断国家
    //$user1 = UserInfo();
    $uid = $_GET['uid'] = isset($_GET['uid']) ? $_GET['uid'] : '';
    if ($uid) {
        $userid = $mem_uid = $memcached->get('uid_' . $uid);
    }
    $and_uuid = isset($_GET['uuid']) ? $_GET['uuid'] : '';
    $checkuuid = check_uuid($and_uuid, $userid);
    if (!$checkuuid) {
        $error = "uuid_error";
        echo return_data($error, false);
        exit;
    }
    $limit = 12;
    $page = $_GET['page'] = empty($_GET['page']) ? 0 : $_GET['page'];
    $user_arr = MooMembersData($userid);
    $user1 = $user_arr;
    $gender = $user1['gender'] == '1' ? '0' : '1';
    if (18 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 30 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 1;
    }
    if (31 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 35 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 2;
    }
    if (36 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 40 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 3;
    }
    if (41 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 50 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 4;
    }
    if (51 <= date("Y") - $user1['birthyear'] && date("Y") - $user1['birthyear'] <= 60 && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 5;
    }
    if (61 <= date("Y") - $user1['birthyear'] && $user1['birthyear'] != '' && $user1['birthyear'] != 0) {
        $age = 6;
    }
    if ($user1['birthyear'] == '' || $user1['birthyear'] == 0) {
        $age = 1;
    }
    if ($user1["province"] == '' || $user1["province"] == 0 || $user1["province"] == -1) {
        $user1["province"] = 10103000;
    }
    $file = $age . "_" . $gender . "_" . $user1["province"] . "_" . $user1["city"];
    //     $cache_file = MOOPHP_DATA_DIR.'/cache/cache_' . $file . '.php';
    $data = $memcached->get($file);
    if (!$data) {
        updateVoteFeel("", "", $user1['province'], $user1['city'], $age, $gender);
        $data = $memcached->get($file);
    }
    if (empty($data)) {
        $error = "empty";
        echo return_data($error, false);
        exit;
    }
    $offset = ($page - 1) * 12;
    $count = count($data);
    if ($limit > $count) {
        $limit = $count;
    }
    //		shuffle($data);
    $data = array_slice($data, $offset, $limit);
    for ($j = 0; $j < 12; $j++) {
        //if(MOOPHP_ALLOW_FASTDB){
        if (isset($data[$j])) {
            $able_like[$j] = MooMembersData($data[$j]);
        }
        //MooFastdbGet('members_search','uid',$data[$j]);
        //}
    }
    foreach ($able_like as $k => $u) {
        $mainimg = MooGetphoto($u['uid'], $style = "com");
        $users[] = array('uid' => $u['uid'], 'nickname' => $u['nickname'], 'birthyear' => $u['birthyear'], 'height' => $u['height'], 'salary' => $u['salary'], 'province' => $u['province'], 'city' => $u['city'], 'mainimg' => $mainimg, 'gender' => $u['gender']);
    }
    echo return_data($users);
    exit;
}
Exemplo n.º 3
0
/**
 * ��ȡҪ���5���
 * param $user_arr array
 * param $sex int
 * param $age int
 * param $vote_key array
 */
function getMemberByVote($user_arr, $sex, $age, $vote_key) {
	global $user_arr,$memcached;
	$file = $age . "_" . $sex . "_" . $user_arr["province"] . "_" . $user_arr["city"];
	//echo $file;exit;
// 	$cache_file = MOOPHP_DATA_DIR.'/cache/cache_' . $file . '.php';
	
	$data = array();
	// ��ȡ����ֵ
	if (!$data = $memcached->get($file)){
		updateVoteFeel("", "", $user_arr["province"], $user_arr["city"], $age, $sex);
		$data = $memcached->get($file);
	}
	
//	if (empty($data)) {
//		// ���ǹ���ʱ��Ĭ�ϸ��Ϻ�10103000
//		if ($user_arr["province"] == 2 && substr($user_arr["city"], 3) == 0) {
//			$default_city = 10103000;
//			$file = $age . "_" . $sex . "_" . $default_city;
//			$cache_file = MOOPHP_DATA_DIR.'/cache/cache_' . $file . '.php';
//			
//			if (file_exists($cache_file) && filemtime($cache_file) + 86400 > time()) {
//				$data = require_once($cache_file);
//			} else {
//				updateVoteFeel("", "", $default_city, 0, $age, $sex, $file);
//				
//				$data = @require_once($cache_file);
//			}
//		}
//	}
	if (isset($vote_key[$file])) {
		$return[1] = array_slice($data, 1 + array_search($vote_key[$file], array_keys($data)), 5);
	} else {
		$return[1] = array_slice($data, 0 , 5);
	}
	if(isset($return[1][0])){
		$key = array_search($return[1][0], $data);
		$return[0] = $key;
	}
	return $return;
}