コード例 #1
0
 function getBlockCode_Members()
 {
     global $tmpl;
     // number of profiles
     $max_num = (int) getParam("top_members_max_num");
     //	Get Sex from GET data
     if ($_GET['Sex'] && $_GET['Sex'] != "all") {
         $sex = process_db_input($_GET['Sex']);
         $query_add = " AND `Sex` = '{$sex}'";
     } else {
         $sex = "all";
         $query_add = "";
     }
     $query_add .= ' AND (`Couple`=0 OR `Couple`>`ID`)';
     $query = "\r\n\t\t\tSELECT\r\n\t\t\t\t`Profiles`.*\r\n\t\t\t";
     if ($_GET['members_mode'] == 'online' or $_GET['members_mode'] == 'rand' or $_GET['members_mode'] == 'last' or $_GET['members_mode'] == 'top') {
         $mode = $_GET['members_mode'];
     } else {
         $mode = 'last';
     }
     $aDBTopMenu = array();
     //$menu = '<div class="dbTopMenu">';
     foreach (array('last', 'top', 'online', 'rand') as $myMode) {
         switch ($myMode) {
             case 'online':
                 if ($mode == $myMode) {
                     $filter = " FROM `Profiles` WHERE `DateLastNav` > SUBDATE(NOW(), INTERVAL " . (int) getParam("member_online_time") . " MINUTE) AND `Status` = 'Active' AND `PrimPhoto` != 0 {$query_add} ORDER BY `Couple` ASC";
                 }
                 $modeTitle = _t('_Online');
                 break;
             case 'rand':
                 if ($mode == $myMode) {
                     $filter = " FROM `Profiles` WHERE `Status` = 'Active' AND `PrimPhoto` != 0 {$query_add} ORDER BY `Couple` ASC, RAND()";
                 }
                 $modeTitle = _t('_Random');
                 break;
             case 'last':
                 if ($mode == $myMode) {
                     $filter = " FROM `Profiles` WHERE `Status` = 'Active' {$query_add} ORDER BY `Couple` ASC, `DateReg` DESC";
                 }
                 $modeTitle = _t('_Latest');
                 break;
             case 'top':
                 if ($mode == $myMode) {
                     $oVotingView = new BxTemplVotingView('profile', 0, 0);
                     $aSql = $oVotingView->getSqlParts('`Profiles`', '`ID`');
                     $sqlOrderBy = $oVotingView->isEnabled() ? " ORDER BY `Couple` ASC, (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `DateReg` DESC" : $sqlOrderBy;
                     $sqlFields = $aSql['fields'];
                     $sqlLJoin = $aSql['join'];
                     $filter = "{$sqlFields} FROM `Profiles` {$sqlLJoin} WHERE `Status` = 'Active' AND `pr_rating_count` > 2 {$query_add} {$sqlOrderBy}";
                     $filter2 = " FROM `Profiles` {$sqlLJoin} WHERE `Status` = 'Active' AND `pr_rating_count` > 2 {$query_add} {$sqlOrderBy}";
                 }
                 $modeTitle = _t('_Top');
                 break;
         }
         $aDBTopMenu[$modeTitle] = array('href' => "{$_SERVER['PHP_SELF']}?members_mode={$myMode}", 'dynamic' => true, 'active' => $myMode == $mode);
         /*if( $myMode == $mode )
         			$menu .= "<div class=\"active\">$modeTitle</a></div>";
         		else
         			$menu .= "<div class=\"notActive\"><a href=\"{$_SERVER['PHP_SELF']}?members_mode=$myMode&amp;Sex=$sex\" class=\"top_members_menu\" onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">$modeTitle</a></div>";*/
     }
     /*$menu .= '<div class="clear_both"></div>';
     		$menu .= '</div>';*/
     $ret = '';
     $aNum = db_arr("SELECT COUNT(`Profiles`.`ID`) " . (isset($filter2) ? $filter2 : $filter));
     $num = (int) $aNum[0];
     if ($num) {
         $pages = ceil($num / $max_num);
         $page = (int) $_GET['page'];
         if ($page < 1 or $mode == 'rand') {
             $page = 1;
         }
         if ($page > $pages) {
             $page = $pages;
         }
         $sqlFrom = ($page - 1) * $max_num;
         $limit = " LIMIT {$sqlFrom}, {$max_num}";
         $templ_search = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/topmebers_index.html");
         $result = db_res($query . $filter . $limit);
         $iCounter = 1;
         $ret .= '<div class="clear_both"></div>';
         while ($p_arr = mysql_fetch_array($result)) {
             $ret .= PrintSearhResult($p_arr, $templ_search, 3);
             /*if( ($iCounter % 3) != 0 )
             			$ret .= PrintSearhResult( $p_arr, $templ_search, 1 );
             		else
             			$ret .= PrintSearhResult( $p_arr, $templ_search, 2 );
             		$iCounter++;*/
         }
         $ret .= '<div class="clear_both"></div>';
         $aDBBottomMenu = array();
         if ($pages > 1) {
             //$ret .= '<div class="dbBottomMenu">';
             if ($page > 1) {
                 $prevPage = $page - 1;
                 $aDBBottomMenu[_t('_Back')] = array('href' => "{$_SERVER['PHP_SELF']}?members_mode={$mode}&amp;page={$prevPage}", 'dynamic' => true, 'class' => 'backMembers');
                 /*$ret .= "
                 			<a href=\"{$_SERVER['PHP_SELF']}?members_mode=$mode&amp;page=$prevPage\"
                 			  class=\"backMembers\"
                 			  onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">"._t('_Back')."</a>
                 		";*/
             }
             if ($page < $pages) {
                 $nextPage = $page + 1;
                 $aDBBottomMenu[_t('_Next')] = array('href' => "{$_SERVER['PHP_SELF']}?members_mode={$mode}&amp;page={$nextPage}", 'dynamic' => true, 'class' => 'moreMembers');
                 /*$ret .= "
                 			<a href=\"{$_SERVER['PHP_SELF']}?members_mode=$mode&amp;page=$nextPage\"
                 			  class=\"moreMembers\"
                 			  onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">"._t('_Next')."</a>
                 		";*/
             }
             $sBMViewAllLink = getParam('enable_modrewrite') == 'on' ? "{$site['url']}browse.php" : "{$site['url']}browse.php";
             $aDBBottomMenu[_t('_View All')] = array('href' => $sBMViewAllLink, 'dynamic' => false, 'class' => 'viewAllMembers');
             //$ret .= '</div>';
         }
     } else {
         $ret .= '<div class="no_result">';
         $ret .= '<div>';
         $ret .= _t("_No results found");
         $ret .= '</div>';
         $ret .= '</div>';
     }
     $ret .= '<div class="clear_both"></div>';
     return array($ret, $aDBTopMenu, $aDBBottomMenu);
     //return $ret;
 }
コード例 #2
0
/**
 * Place HTML code for search result
 */
function PageCompPageMainCode()
{
    global $p_num;
    global $gallery_view;
    global $dir;
    global $result;
    global $tmpl;
    global $site;
    global $prof;
    global $enable_match;
    global $logged;
    global $pa_icon_preload;
    global $boxbg2;
    global $profiles_limit;
    global $NickName;
    global $oTemplConfig;
    if ($gallery_view) {
        $out = PageCompGallery();
        return DesignBoxContent(_t("_Gallery"), $out, $oTemplConfig->PageSearcResultGallery_db_num);
    }
    // design box
    $fs = filesize("{$dir['root']}templates/tmpl_{$tmpl}/searchrow.html");
    $f = fopen("{$dir['root']}templates/tmpl_{$tmpl}/searchrow.html", "r");
    $templ_search = fread($f, $fs);
    fclose($f);
    $ret = '';
    if ($profiles_limit > 0) {
        $ret .= '<div class="no_result">';
        $ret .= '<div>';
        $ret .= _t("_SEARCH_RESULT_ALLOWED_PROFILES", $profiles_limit);
        $ret .= '</div>';
        $ret .= '</div>';
    } else {
        $ret .= '';
    }
    // get nickname for IM
    $NickName = getNickName();
    while ($p_arr = mysql_fetch_assoc($result)) {
        $ret .= PrintSearhResult($p_arr, $templ_search, 1);
    }
    return $ret;
}
コード例 #3
0
function PageCodeSearchResult($aParams)
{
    global $oPF;
    global $dir;
    global $tmpl;
    global $bEnZipSearch;
    $sQuery = 'SELECT DISTINCT IF( `Profiles`.`Couple`=0, `Profiles`.`ID`, IF( `Profiles`.`Couple`>`Profiles`.`ID`, `Profiles`.`ID`, `Profiles`.`Couple` ) ) AS `ID` FROM `Profiles` ';
    $sJoin = '';
    $aWhere = array();
    $aMyBlocks = $oPF->aBlocks;
    $aMyBlocks['addSpecial'] = array('Items' => array($oPF->aCache[100][0]['Items'][1], $oPF->aCache[100][0]['Items'][2], $oPF->aCache[100][0]['Items'][38]));
    //collect where request array
    foreach ($aMyBlocks as $iBlockID => $aBlock) {
        foreach ($aBlock['Items'] as $aItem) {
            if (!isset($aParams[$aItem['Name']])) {
                continue;
            }
            if ($iBlockID != 'addSpecial' and ($aItem['Name'] == 'ID' or $aItem['Name'] == 'NickName' or $aItem['Name'] == 'Tags')) {
                continue;
            }
            // skip collecting id, nick and tags for regular blocks, only in special
            $sItemName = $aItem['Name'];
            $mValue = $aParams[$sItemName];
            switch ($aItem['Type']) {
                case 'text':
                case 'area':
                    if ($sItemName == 'Tags') {
                        $sJoin .= " INNER JOIN `Tags` ON (`Tags`.`Type` = 'profile' AND `Tags`.`ID` = `Profiles`.`ID`) ";
                        $aWhere[] = "`Tags`.`Tag` = '" . addslashes($mValue) . "'";
                    } else {
                        $aWhere[] = "`Profiles`.`{$sItemName}` LIKE '%" . addslashes($mValue) . "%'";
                    }
                    break;
                case 'num':
                    $aWhere[] = "`Profiles`.`{$sItemName}` >= {$mValue[0]} AND `Profiles`.`{$sItemName}` <= {$mValue[1]}";
                    break;
                case 'date':
                    $iMin = floor($mValue[0] * 365.25);
                    //for leap years
                    $iMax = floor($mValue[1] * 365.25);
                    $aWhere[] = "DATEDIFF( NOW(), `Profiles`.`{$sItemName}` ) >= {$iMin} AND DATEDIFF( NOW(), `Profiles`.`{$sItemName}` ) <= {$iMax}";
                    //$aWhere[] = "DATE_ADD( `$sItemName`, INTERVAL {$mValue[0]} YEAR ) <= NOW() AND DATE_ADD( `$sItemName`, INTERVAL {$mValue[1]} YEAR ) >= NOW()"; //is it correct statement?
                    break;
                case 'select_one':
                    $sValue = implode(',', $mValue);
                    $aWhere[] = "FIND_IN_SET( `Profiles`.`{$sItemName}`, '" . addslashes($sValue) . "' )";
                    break;
                case 'select_set':
                    $aSet = array();
                    foreach ($mValue as $sValue) {
                        $sValue = addslashes($sValue);
                        $aSet[] = "FIND_IN_SET( '{$sValue}', `Profiles`.`{$sItemName}` )";
                    }
                    $aWhere[] = '( ' . implode(' OR ', $aSet) . ' )';
                    break;
                case 'range':
                    //impl
                    break;
                case 'bool':
                    $aWhere[] = "`Profiles`.`{$sItemName}'";
                    break;
                case 'system':
                    switch ($aItem['Name']) {
                        case 'Couple':
                            if ($mValue == '-1') {
                            } elseif ($mValue) {
                                $aWhere[] = "`Profiles`.`Couple` > `Profiles`.`ID`";
                            } else {
                                $aWhere[] = "`Profiles`.`Couple` = 0";
                            }
                            break;
                        case 'Location':
                            $aFields = explode("\n", $aItem['Extra']);
                            $aKeyw = array();
                            $sValue = addslashes($mValue);
                            foreach ($aFields as $sField) {
                                $aKeyw[] = "`Profiles`.`{$sField}` LIKE '%{$sValue}%'";
                            }
                            $aWhere[] = '( ' . implode(' OR ', $aKeyw) . ')';
                            break;
                        case 'ID':
                            $aWhere[] = "`ID` = {$mValue}";
                            break;
                    }
                    break;
            }
        }
    }
    if ($bEnZipSearch && $aParams['distance'] > 0) {
        $sZip = htmlspecialchars_adv($_REQUEST['zip']);
        $iDistance = (int) $aParams['distance'];
        $sMetric = htmlspecialchars_adv($_REQUEST['metric']);
        $zip = process_db_input(strtoupper(str_replace(' ', '', $zip)), 1);
        $aZipInfo = db_arr("SELECT `Latitude`, `Longitude` FROM `ZIPCodes` WHERE REPLACE(`ZIPCode`,' ','') = '{$sZip}'");
        //echoDbg($aZipInfo);
        if ($aZipInfo) {
            // ZIP code exists
            $miles2km = 0.7;
            // miles/kilometers ratio
            $Miles = $sMetric == "km" ? $iDistance * $miles2km : $iDistance;
            $Latitude = $aZipInfo["Latitude"];
            $Longitude = $aZipInfo["Longitude"];
            $zcdRadius = new RadiusAssistant($Latitude, $Longitude, $Miles);
            //echoDbg($zcdRadius);
            $minLat = $zcdRadius->MinLatitude();
            $maxLat = $zcdRadius->MaxLatitude();
            $minLong = $zcdRadius->MinLongitude();
            $maxLong = $zcdRadius->MaxLongitude();
            $sJoin .= " LEFT JOIN `ZIPCodes` ON UPPER( REPLACE(`Profiles`.`zip`, ' ', '') ) = REPLACE(`ZIPCodes`.`ZIPCode`,' ', '') ";
            $aWhere[] = "`ZIPCodes`.`ZIPCode` IS NOT NULL AND `ZIPCodes`.`Latitude` >= {$minLat} AND `ZIPCodes`.`Latitude` <= {$maxLat} AND `ZIPCodes`.`Longitude` >= {$minLong} AND `ZIPCodes`.`Longitude` <= {$maxLong} ";
        }
    }
    // collect query string
    $aWhere[] = "`Profiles`.`Status` = 'Active'";
    // add online only
    if ($_REQUEST['online_only']) {
        $iOnlineTime = getParam('member_online_time');
        $aWhere[] = "DATE_ADD( `DateLastNav`, INTERVAL {$iOnlineTime} MINUTE ) >= NOW()";
    }
    if ($_REQUEST['photos_only']) {
        $aWhere[] = "`Profiles`.`PrimPhoto`";
    }
    $aWhere[] = "(`Profiles`.`Couple`='0' OR `Profiles`.`Couple`>`Profiles`.`ID`)";
    $sWhere = ' WHERE ' . implode(' AND ', $aWhere);
    //collect the whole query string
    $sQuery = $sQuery . $sJoin . $sWhere;
    //echo $sQuery;
    //make search
    $rProfiles = db_res($sQuery);
    $aProfiles = array();
    while ($aProfile = mysql_fetch_assoc($rProfiles)) {
        $aProfiles[] = $aProfile['ID'];
    }
    $iCountProfiles = count($aProfiles);
    if (!$iCountProfiles) {
        echo '<div class="no_result"><div>' . _t("_NO_RESULTS") . '</div></div>';
    } else {
        //collect pagination
        $iCurrentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
        $iResultsPerPage = isset($_GET['res_per_page']) ? (int) $_GET['res_per_page'] : 10;
        if ($iCurrentPage < 1) {
            $iCurrentPage = 1;
        }
        if ($iResultsPerPage < 1) {
            $iResultsPerPage = 10;
        }
        $iTotalPages = ceil($iCountProfiles / $iResultsPerPage);
        if ($iTotalPages > 1) {
            if ($iCurrentPage > $iTotalPages) {
                $iCurrentPage = $iTotalPages;
            }
            $aOutputProfiles = array_slice($aProfiles, ($iCurrentPage - 1) * $iResultsPerPage, $iResultsPerPage);
            $iCountOutputProfiles = count($aOutputProfiles);
            $iFromResults = ($iCurrentPage - 1) * $iResultsPerPage + 1;
            $sPagination = genSearchPagination($iTotalPages, $iCurrentPage, $iResultsPerPage);
        } else {
            $iFromResults = 1;
            $aOutputProfiles = $aProfiles;
            $iCountOutputProfiles = $iCountProfiles;
            $sPagination = '';
        }
        $iToResults = $iFromResults - 1 + $iCountOutputProfiles;
        $sShowingResults = '<div class="showingResults">' . _t('_Showing results:', $iFromResults, $iToResults, $iCountProfiles) . '</div>';
        echo $sPagination;
        echo $sShowingResults;
        //output search results
        $sTemplSearch = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/searchrow.html");
        foreach ($aOutputProfiles as $iProfID) {
            $aProfileInfo = getProfileInfo($iProfID);
            if ($aProfileInfo['Couple'] > 0) {
                $aProfileInfoC = getProfileInfo($aProfileInfo['Couple']);
                echo PrintSearhResult($aProfileInfo, $sTemplSearch, 1, true, $aProfileInfoC);
            } else {
                echo PrintSearhResult($aProfileInfo, $sTemplSearch);
            }
        }
        echo $sShowingResults;
        echo $sPagination;
    }
}
コード例 #4
0
function PageCompTopMembersContent($sCaption)
{
    global $tmpl;
    // number of profiles
    $max_num = (int) getParam("top_members_max_num");
    //	Get Sex from GET data
    if ($_GET['Sex'] && $_GET['Sex'] != "all") {
        $sex = process_db_input($_GET['Sex']);
        $query_add = " AND `Sex` = '{$sex}'";
    } else {
        $sex = "all";
        $query_add = "";
    }
    $query = "\r\n\t\tSELECT\r\n\t\t\t`Profiles`.*\r\n\t\t";
    if ($_GET['Mode'] == 'online' or $_GET['Mode'] == 'rand' or $_GET['Mode'] == 'last' or $_GET['Mode'] == 'top') {
        $mode = $_GET['Mode'];
    } else {
        $mode = 'last';
    }
    $menu = '<div class="dbTopMenu">';
    foreach (array('last', 'top', 'online', 'rand') as $myMode) {
        switch ($myMode) {
            case 'online':
                if ($mode == $myMode) {
                    $filter = " FROM `Profiles` WHERE `LastNavTime` > SUBDATE(NOW(), INTERVAL " . (int) getParam("member_online_time") . " MINUTE) AND `Status` = 'Active' AND `PrimPhoto` != 0 {$query_add}";
                }
                $modeTitle = _t('_Online');
                break;
            case 'rand':
                if ($mode == $myMode) {
                    $filter = " FROM `Profiles` WHERE `Status` = 'Active' AND `PrimPhoto` != 0 {$query_add} ORDER BY RAND()";
                }
                $modeTitle = _t('_Random');
                break;
            case 'last':
                if ($mode == $myMode) {
                    $filter = " FROM `Profiles` WHERE `Status` = 'Active' {$query_add} ORDER BY `LastReg` DESC";
                }
                $modeTitle = _t('_Latest');
                break;
            case 'top':
                if ($mode == $myMode) {
                    $oVotingView = new BxTemplVotingView('profile', 0, 0);
                    $aSql = $oVotingView->getSqlParts('`Profiles`', '`ID`');
                    $sqlOrderBy = $oVotingView->isEnabled() ? " ORDER BY (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `LastReg` DESC" : $sqlOrderBy;
                    $sqlFields = $aSql['fields'];
                    $sqlLJoin = $aSql['join'];
                    $filter = "{$sqlFields} FROM `Profiles` {$sqlLJoin} WHERE `Status` = 'Active' AND `pr_rating_count` > 2 {$query_add} {$sqlOrderBy}";
                    $filter2 = " FROM `Profiles` {$sqlLJoin} WHERE `Status` = 'Active' AND `pr_rating_count` > 2 {$query_add} {$sqlOrderBy}";
                }
                $modeTitle = _t('_Top');
                break;
        }
        if ($myMode == $mode) {
            $menu .= "<div class=\"active\">{$modeTitle}</a></div>";
        } else {
            $menu .= "<div class=\"notActive\"><a href=\"{$_SERVER['PHP_SELF']}?Mode={$myMode}&amp;Sex={$sex}\" class=\"top_members_menu\" onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">{$modeTitle}</a></div>";
        }
    }
    $menu .= '<div class="clear_both"></div>';
    $menu .= '</div>';
    $ret = '';
    $aNum = db_arr("SELECT COUNT(`Profiles`.`ID`) " . (isset($filter2) ? $filter2 : $filter));
    $num = (int) $aNum[0];
    if ($num) {
        $pages = ceil($num / $max_num);
        $page = (int) $_GET['page'];
        if ($page < 1 or $mode == 'rand') {
            $page = 1;
        }
        if ($page > $pages) {
            $page = $pages;
        }
        $sqlFrom = ($page - 1) * $max_num;
        $limit = " LIMIT {$sqlFrom}, {$max_num}";
        $templ_search = file_get_contents("{$dir['root']}templates/tmpl_{$tmpl}/topmebers_index.html");
        $result = db_res($query . $filter . $limit);
        $iCounter = 1;
        $ret .= '<div class="clear_both"></div>';
        while ($p_arr = mysql_fetch_array($result)) {
            if ($iCounter % 3 != 0) {
                $ret .= PrintSearhResult($p_arr, $templ_search, 1);
            } else {
                $ret .= PrintSearhResult($p_arr, $templ_search, 2);
            }
            $iCounter++;
        }
        $ret .= '<div class="clear_both"></div>';
        if ($pages > 1) {
            $ret .= '<div class="dbBottomMenu">';
            if ($page > 1) {
                $prevPage = $page - 1;
                $ret .= "\r\n\t\t\t\t\t<a href=\"{$_SERVER['PHP_SELF']}?Mode={$mode}&amp;page={$prevPage}\"\r\n\t\t\t\t\t  class=\"backMembers\"\r\n\t\t\t\t\t  onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">" . _t('_Back') . "</a>\r\n\t\t\t\t";
            }
            if ($page < $pages) {
                $nextPage = $page + 1;
                $ret .= "\r\n\t\t\t\t\t<a href=\"{$_SERVER['PHP_SELF']}?Mode={$mode}&amp;page={$nextPage}\"\r\n\t\t\t\t\t  class=\"moreMembers\"\r\n\t\t\t\t\t  onclick=\"getHtmlData( 'show_members', this.href+'&amp;show_only=members'); return false;\">" . _t('_Next') . "</a>\r\n\t\t\t\t";
            }
            $ret .= '</div>';
        }
    } else {
        $ret .= '<div class="no_result">';
        $ret .= '<div>';
        $ret .= _t("_No results found");
        $ret .= '</div>';
        $ret .= '</div>';
    }
    $ret .= '<div class="clear_both"></div>';
    return DesignBoxContent(_t($sCaption), $ret, 1, $menu);
}