コード例 #1
0
ファイル: match.inc.php プロジェクト: dalinhuang/shopexts
function getProfilesMatch($iPID1 = 0, $iPID2 = 0)
{
    $iPID1 = (int) $iPID1;
    $iPID2 = (int) $iPID2;
    if (!$iPID1 or !$iPID2) {
        return 0;
    }
    if ($iPID1 == $iPID2) {
        return 0;
    }
    $aProf1 = getProfileInfo($iPID1);
    $aProf2 = getProfileInfo($iPID2);
    if (empty($aProf1) || empty($aProf2)) {
        return 0;
    }
    $iMatch = 0;
    $aMathFields = getMatchFields();
    foreach ($aMathFields as $sKey => $aFields) {
        $bRes = false;
        if ($aProf1[$aFields['Name']]) {
            if ($aMathFields[$aFields['MatchField']]['Name'] == 'DateOfBirth') {
                $bRes = age($aProf1['DateOfBirth']) == age($aProf2['DateOfBirth']);
            } else {
                $bRes = $aProf1[$aFields['Name']] == $aProf2[$aMathFields[$aFields['MatchField']]['Name']];
            }
        }
        if ($bRes) {
            $iMatch += (int) $aFields['MatchPercent'];
        }
    }
    return $iMatch;
}
コード例 #2
0
ファイル: match.inc.php プロジェクト: Gotgot59/dolphin.pro
function getProfilesMatch($iPID1 = 0, $iPID2 = 0)
{
    if (!getParam('enable_match')) {
        return 0;
    }
    $iPID1 = (int) $iPID1;
    $iPID2 = (int) $iPID2;
    if (!$iPID1 or !$iPID2) {
        return 0;
    }
    if ($iPID1 == $iPID2) {
        return 0;
    }
    $aProf1 = getProfileInfo($iPID1);
    $aProf2 = getProfileInfo($iPID2);
    if (empty($aProf1) || empty($aProf2)) {
        return 0;
    }
    $iMatch = 0;
    $aMathFields = getMatchFields();
    foreach ($aMathFields as $sKey => $aFields) {
        $bRes = false;
        if ($aProf1[$aFields['Name']]) {
            if ($aMathFields[$aFields['MatchField']]['Name'] == 'DateOfBirth') {
                $bRes = age($aProf1['DateOfBirth']) == age($aProf2['DateOfBirth']);
            } elseif ($aMathFields[$aFields['MatchField']]['Type'] == 'select_set' || $aFields['Type'] == 'select_set') {
                $a1 = explode(',', $aProf1[$aFields['Name']]);
                $a2 = explode(',', $aProf2[$aMathFields[$aFields['MatchField']]['Name']]);
                $bRes = array_intersect($a1, $a2);
            } else {
                $bRes = $aProf1[$aFields['Name']] == $aProf2[$aMathFields[$aFields['MatchField']]['Name']];
            }
        }
        if ($bRes) {
            $iMatch += (int) $aFields['MatchPercent'];
        }
    }
    return $iMatch;
}