'; } else { return ""; } } function age( $birth_date ) { if ( $birth_date == "0000-00-00" ) return _t("_uknown"); $bd = explode( "-", $birth_date ); $age = date("Y") - $bd[0] - 1; $arr[1] = "m"; $arr[2] = "d"; for ( $i = 1; $arr[$i]; $i++ ) { $n = date( $arr[$i] ); if ( $n < $bd[$i] ) break; if ( $n > $bd[$i] ) { ++$age; break; } } return $age; } /** * Print code for membership status * $memberID - member ID * $offer_upgrade - will this code be printed at [c]ontrol [p]anel */ function GetMembershipStatus($memberID, $offer_upgrade = true) { $ret = ''; $membership_info = getMemberMembershipInfo($memberID); $viewMembershipActions = "
("._t("_VIEW_MEMBERSHIP_ACTIONS").")
"; // Show colored membership name if ( $membership_info['ID'] == MEMBERSHIP_ID_STANDARD ) { $ret .= _t( "_MEMBERSHIP_STANDARD" ). $viewMembershipActions; if ( $offer_upgrade ) $ret .= " ". _t( "_MEMBERSHIP_UPGRADE_FROM_STANDARD" ); } else { $ret .= "{$membership_info['Name']}$viewMembershipActions"; $days_left = (int)( ($membership_info['DateExpires'] - time()) / (24 * 3600) ); if(!is_null($membership_info['DateExpires'])) { $ret .= ( $days_left > 0 ) ? _t( "_MEMBERSHIP_EXPIRES_IN_DAYS", $days_left ) : _t( "_MEMBERSHIP_EXPIRES_TODAY", date( "H:i", $membership_info['DateExpires'] ), date( "H:i" ) ); } else { $ret.= _t("_MEMBERSHIP_EXPIRES_NEVER"); } } return $ret; } function isAutoApproval( $sAction ) { $autoApproval_ifPhoto = ( 'on' == getParam("autoApproval_ifPhoto") ); $autoApproval_ifSound = ( 'on' == getParam("autoApproval_ifSound") ); $autoApproval_ifVideo = ( 'on' == getParam("autoApproval_ifVideo") ); $autoApproval_ifProfile = ( 'on' == getParam("autoApproval_ifProfile") ); $autoApproval_ifJoin = ( 'on' == getParam("autoApproval_ifJoin") ); switch ( $sAction ) { case 'photo': return $autoApproval_ifPhoto; case 'sound': return $autoApproval_ifSound; case 'video': return $autoApproval_ifVideo; case 'profile': return $autoApproval_ifProfile; case 'join': return $autoApproval_ifJoin; default: return false; } } function deleteUserDataFile( $userID ) { global $aUser; $bUseCacheSystem = ( getParam('enable_cache_system') == 'on' ) ? true : false; if (!$bUseCacheSystem) return false; $userID = (int)$userID; $fileName = BX_DIRECTORY_PATH_CACHE . 'user' . $userID . '.php'; if( file_exists($fileName) ) { unlink($fileName); } } function createUserDataFile( $userID ) { global $aUser; $bUseCacheSystem = ( getParam('enable_cache_system') == 'on' ) ? true : false; if (!$bUseCacheSystem) return false; $userID = (int)$userID; $fileName = BX_DIRECTORY_PATH_CACHE . 'user' . $userID . '.php'; if( $userID > 0 ) { $aPreUser = getProfileInfoDirect ($userID); if( isset( $aPreUser ) and is_array( $aPreUser ) and $aPreUser) { $sUser = ' $value ) $sUser .= '$aUser[' . $userID . '][\'' . $key . '\']' . ' = ' . '\'' . str_replace( $replaceWhat, $replaceTo, $value ) . '\'' . ";\n"; $sUser .= "\n" . '?>'; if( $file = fopen( $fileName, "w" ) ) { fwrite( $file, $sUser ); fclose( $file ); @chmod ($fileName, 0666); @include( $fileName ); return true; } else return false; } } else return false; } /** * Check whether the requested profile is active or not. */ function isProfileActive($iId = 0) { $aProfile = getProfileInfo($iId); if($aProfile === false || empty($aProfile)) return false; return $aProfile['Status'] == 'Active'; } function getProfileInfoDirect ($iProfileID) { return $GLOBALS['MySQL']->getRow("SELECT * FROM `Profiles` WHERE `ID`='" . $iProfileID . "' LIMIT 1"); } function getProfileInfo($iProfileID = 0, $checkActiveStatus = false, $forceCache = false) { global $aUser; $iProfileID = !empty($iProfileID) ? (int)$iProfileID : getLoggedId(); if(!$iProfileID) return false; if(!isset( $aUser[$iProfileID]) || !is_array($aUser[$iProfileID]) || $forceCache) { $sCacheFile = BX_DIRECTORY_PATH_CACHE . 'user' . $iProfileID . '.php'; if( !file_exists( $sCacheFile ) || $forceCache ) { if( !createUserDataFile( $iProfileID ) ) { return getProfileInfoDirect ($iProfileID); } } @include( $sCacheFile ); } if( $checkActiveStatus and $aUser[$iProfileID]['Status'] != 'Active' ) return false; return $aUser[$iProfileID]; } /* osed only for xmlrpc */ function getNewLettersNum( $iID ) { $sqlQuery = " SELECT COUNT(`Recipient`) FROM `sys_messages` WHERE `Recipient`='$iID' AND `New`='1' AND NOT FIND_IN_SET('Recipient', `Trash`) "; return (int)db_value($sqlQuery); } /*function for inner using only $ID - profile ID $iFrStatus - friend status (1 - approved, 0 - wait) $iOnline - filter for last nav moment (in minutes) $sqlWhere - add sql Conditions, should beginning from AND */ function getFriendNumber($iID, $iFrStatus = 1, $iOnline = 0, $sqlWhere = '') { $sqlAdd = ''; if ($iOnline > 0) $sqlAdd = " AND (p.`DateLastNav` > SUBDATE(NOW(), INTERVAL " . $iOnline . " MINUTE))"; if (strlen($sqlWhere) > 0) $sqlAdd .= $sqlWhere; $sqlQuery = " SELECT COUNT(p.`ID`) FROM `Profiles` AS p LEFT JOIN `sys_friend_list` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = {$iFrStatus}) LEFT JOIN `sys_friend_list` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = {$iFrStatus}) WHERE 1 AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL) {$sqlAdd} "; return (int)db_value($sqlQuery); } function getMyFriendsEx($iID, $sWhereParam = '', $sSortParam = '', $sqlLimit = '') { $sJoin = $sOrderBy = ''; switch($sSortParam) { case 'activity' : // DateLastLogin $sOrderBy = 'ORDER BY p.`DateLastLogin`'; break; case 'activity_desc' : // DateLastLogin $sOrderBy = 'ORDER BY p.`DateLastLogin` DESC'; break; case 'last_nav' : // DateLastNav $sOrderBy = 'ORDER BY p.`DateLastNav`'; break; case 'last_nav_desc' : // DateLastNav $sOrderBy = 'ORDER BY p.`DateLastNav` DESC'; break; case 'date_reg' : // DateReg $sOrderBy = 'ORDER BY p.`DateReg`'; break; case 'date_reg_desc' : // DateReg $sOrderBy = 'ORDER BY p.`DateReg` DESC'; break; case 'image' : // Avatar $sOrderBy = 'ORDER BY p.`Avatar` DESC'; break; case 'rate' : // `sys_profile_rating`.`pr_rating_sum $sOrderBy = 'ORDER BY `sys_profile_rating`.`pr_rating_sum`'; $sJoin = 'LEFT JOIN `sys_profile_rating` ON p.`ID` = `sys_profile_rating`.`pr_id`'; break; default : // DateLastLogin $sOrderBy = 'ORDER BY p.`DateLastLogin`'; break; } $sLimit = ($sqlLimit == '') ? '' : /*"LIMIT 0, " .*/ $sqlLimit; $iOnlineTime = (int)getParam( "member_online_time" ); $sqlQuery = " SELECT p.*, if(`DateLastNav` > SUBDATE(NOW( ), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`, UNIX_TIMESTAMP(p.`DateLastLogin`) AS 'TS_DateLastLogin', UNIX_TIMESTAMP(p.`DateReg`) AS 'TS_DateReg' FROM `Profiles` AS p {$sJoin} INNER JOIN (SELECT IF( '{$iID}' = f.`ID` , f.`Profile` , f.`ID` ) AS `ID` FROM `sys_friend_list` AS `f` WHERE 1 AND (f.`Profile` = '{$iID}' OR f.`ID` = '{$iID}') AND `Check` = 1) AS `f` ON (`f`.`ID` = `p`.`ID`) {$sWhereParam} {$sOrderBy} {$sLimit} "; $aFriends = array(); $vProfiles = db_res($sqlQuery); while ($aProfiles = mysql_fetch_assoc($vProfiles)) { $aFriends[$aProfiles['ID']] = array($aProfiles['ID'], $aProfiles['TS_DateLastLogin'], $aProfiles['TS_DateReg'], $aProfiles['Rate'], $aProfiles['DateLastNav'], $aProfiles['is_online']); } return $aFriends; } /* * The function returns NickName by given ID. If no ID specified, it tryes to get if from _COOKIE['memberID']; */ function getNickName( $ID = '' ) { if ( !$ID && (int)$_COOKIE['memberID'] ) $ID = $_COOKIE['memberID']; if ( !$ID ) return ''; $arr = getProfileInfo( $ID ); return $arr['NickName']; } /* * The function returns Password by given ID. */ function getPassword( $ID = '' ) { if ( !(int)$ID ) return ''; $arr = getProfileInfo( $ID ); return $arr['Password']; } function getProfileLink( $iID, $sLinkAdd = '' ) { $aProfInfo = getProfileInfo( $iID ); $iID = ($aProfInfo['Couple'] > 0 && $aProfInfo['ID'] > $aProfInfo['Couple']) ? $aProfInfo['Couple'] : $iID; return (getParam('enable_modrewrite') == 'on') ? BX_DOL_URL_ROOT . getNickName($iID) . ( $sLinkAdd ? "?{$sLinkAdd}" : '' ) : BX_DOL_URL_ROOT . 'profile.php?ID='.$iID . ( $sLinkAdd ? "&{$sLinkAdd}" : '' ); } function periodic_check_ban() { //Cleaning Ban table $CheckSQL = " SELECT `sys_admin_ban_list`.* FROM `sys_admin_ban_list` WHERE ( `DateTime` + INTERVAL `Time` SECOND < NOW() ) "; $vCheckBanRes = db_res($CheckSQL); while ( $aCheckBanRes = mysql_fetch_assoc($vCheckBanRes) ) { $sDeleteBanSQL = "DELETE FROM `sys_admin_ban_list` WHERE `ProfID`='{$aCheckBanRes['ProfID']}'"; db_res($sDeleteBanSQL); } } function isLoggedBanned($iCurUserID = 0) { $iCCurUserID = ($iCurUserID>0) ? $iCurUserID : (int)$_COOKIE['memberID']; if ($iCCurUserID) { $CheckSQL = " SELECT * FROM `sys_admin_ban_list` WHERE `ProfID`='{$iCCurUserID}' "; db_res($CheckSQL); if (db_affected_rows()>0) { return true; } } return false; } function bx_login($iId, $bRememberMe = false) { $sPassword = getPassword($iId); $aUrl = parse_url($GLOBALS['site']['url']); $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/'; $sHost = ''; $iCookieTime = $bRememberMe ? time() + 24*60*60*30 : 0; setcookie("memberID", $iId, $iCookieTime, $sPath, $sHost); $_COOKIE['memberID'] = $iId; setcookie("memberPassword", $sPassword, $iCookieTime, $sPath, $sHost, false, true /* http only */); $_COOKIE['memberPassword'] = $sPassword; db_res("UPDATE `Profiles` SET `DateLastLogin`=NOW(), `DateLastNav`=NOW() WHERE `ID`='" . $iId . "'"); createUserDataFile($iId); require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'); $oZ = new BxDolAlerts('profile', 'login', $iId); $oZ->alert(); return getProfileInfo($iId); } function bx_logout($bNotify = true) { $aUrl = explode('/', $_SERVER['REQUEST_URI']); if (in_array('java_photo_uploader', $aUrl) || in_array('add_objects', $aUrl)) return; if($bNotify && isMember()) { require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'); $oZ = new BxDolAlerts('profile', 'logout', (int)$_COOKIE['memberID']); $oZ->alert(); } $aUrl = parse_url($GLOBALS['site']['url']); $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/'; setcookie('memberID', '', time() - 96 * 3600, $sPath); setcookie('memberPassword', '', time() - 96 * 3600, $sPath); unset($_COOKIE['memberID']); unset($_COOKIE['memberPassword']); } function setSearchStartAge($iMin) { if ($iMin <= 0) return false; $GLOBALS['MySQL']->query("update `sys_profile_fields` set `Min` = $iMin where `Name` = 'DateOfBirth'"); require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolPFM.php'); $oCacher = new BxDolPFMCacher(); $oCacher -> createCache(); return true; } function setSearchEndAge($iMax) { if ($iMax <= 0) return false; $GLOBALS['MySQL']->query("update `sys_profile_fields` set `Max` = $iMax where `Name` = 'DateOfBirth'"); require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolPFM.php'); $oCacher = new BxDolPFMCacher(); $oCacher -> createCache(); return true; } check_logged();