예제 #1
0
 /**
  * Get privacy object instance by object name
  * @param $sObject object name
  * @return object instance or false on error
  */
 public static function getObjectInstance($sObject)
 {
     if (isset($GLOBALS['bxDolClasses']['BxDolPrivacy!' . $sObject])) {
         return $GLOBALS['bxDolClasses']['BxDolPrivacy!' . $sObject];
     }
     $aObject = BxDolPrivacyQuery::getPrivacyObject($sObject);
     if (!$aObject || !is_array($aObject)) {
         return false;
     }
     $sClass = 'BxTemplPrivacy';
     if (!empty($aObject['override_class_name'])) {
         $sClass = $aObject['override_class_name'];
         if (!empty($aObject['override_class_file'])) {
             require_once BX_DIRECTORY_PATH_ROOT . $aObject['override_class_file'];
         }
     }
     $o = new $sClass($aObject);
     return $GLOBALS['bxDolClasses']['BxDolPrivacy!' . $sObject] = $o;
 }
예제 #2
0
 function addObjectToAlbum(&$oAlbums, $sAlbumUri, $iObjId, $bUpdateCounter = true, $iAuthorId = 0, $aAlbumParams = array())
 {
     if (!$iAuthorId) {
         $iAuthorId = $this->_iOwnerId;
     }
     $iObjId = (int) $iObjId;
     $aAlbumInfo = $oAlbums->getAlbumInfo(array('fileUri' => uriFilter($sAlbumUri), 'owner' => $iAuthorId), array('ID'));
     if (is_array($aAlbumInfo) && count($aAlbumInfo) > 0) {
         $iAlbumID = (int) $aAlbumInfo['ID'];
     } else {
         if (isset($aAlbumParams['privacy'])) {
             $iPrivacy = (int) $aAlbumParams['privacy'];
         } elseif ($sAlbumUri == $oAlbums->getAlbumDefaultName()) {
             $iPrivacy = BX_DOL_PG_HIDDEN;
         } else {
             bx_import('BxDolPrivacyQuery');
             $oPrivacy = new BxDolPrivacyQuery();
             $iPrivacy = $oPrivacy->getDefaultValueModule($this->oModule->_oConfig->getUri(), 'album_view');
             if (!$iPrivacy) {
                 $iPrivacy = BX_DOL_PG_NOBODY;
             }
         }
         $aData = array('caption' => $sAlbumUri, 'owner' => $iAuthorId, 'AllowAlbumView' => $iPrivacy);
         $iAlbumID = $oAlbums->addAlbum($aData, false);
     }
     $oAlbums->addObject($iAlbumID, $iObjId, $bUpdateCounter);
 }
예제 #3
0
 function getGroupName($mixedId)
 {
     if ('m' == $mixedId[0]) {
         require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
         $a = getMembershipInfo(substr($mixedId, 1));
         return $a && isset($a['Name']) ? $a['Name'] : 'undefined';
     } else {
         bx_import('BxDolPrivacyQuery');
         $oPrivacyQuery = new BxDolPrivacyQuery();
         $a = $oPrivacyQuery->getGroupsBy(array('type' => 'id', 'id' => $mixedId));
         return $a && (int) $a['owner_id'] == 0 ? _t('_ps_group_' . $a['id'] . '_title') : $a['title'];
     }
 }
 function createProfile($aData, $bSendMails = true, $iMainMemberID = 0)
 {
     if (!$aData or !is_array($aData) or empty($aData)) {
         return false;
     }
     unset($aData['Couple']);
     unset($aData['Captcha']);
     unset($aData['TermsOfUse']);
     unset($aData['ProfilePhoto']);
     /* @var $this ->oPF BxDolProfileFields */
     $this->oPF = new BxDolProfileFields(100);
     if (!$this->oPF->aArea) {
         echo 'Profile Fields cache not loaded. Cannot continue.';
         return false;
     }
     $this->aItems = $this->oPF->aArea[0]['Items'];
     if ($iMainMemberID) {
         $aMainMember = $this->getProfileInfo($iMainMemberID);
     } else {
         $aMainMember = false;
     }
     // begin profile info collecting
     $aNewProfile = array();
     foreach ($this->aItems as $aItem) {
         $sItemName = $aItem['Name'];
         if (array_key_exists($sItemName, $aData)) {
             $aNewProfile[$sItemName] = $aData[$sItemName];
         } elseif ($aMainMember and array_key_exists($sItemName, $aMainMember) and $aItem['Type'] != 'system') {
             if ($aItem['Unique']) {
                 $aNewProfile[$sItemName] = $this->genUniqueValue($sItemName, $aMainMember[$sItemName]);
             } else {
                 $aNewProfile[$sItemName] = $aMainMember[$sItemName];
             }
         } else {
             switch ($aItem['Type']) {
                 case 'pass':
                     $aNewProfile[$sItemName] = $this->genRandomPassword();
                     break;
                 case 'num':
                     $aNewProfile[$sItemName] = (int) $aItem['Default'];
                     break;
                 case 'bool':
                     $aNewProfile[$sItemName] = (bool) $aItem['Default'];
                     break;
                 case 'system':
                     switch ($sItemName) {
                         case 'ID':
                             //set automatically
                         //set automatically
                         case 'Captcha':
                             //not been inserted
                         //not been inserted
                         case 'Location':
                             //not been inserted
                         //not been inserted
                         case 'Keyword':
                             //not been inserted
                         //not been inserted
                         case 'TermsOfUse':
                             //not been inserted
                             //pass
                             break;
                         case 'DateReg':
                             $aNewProfile[$sItemName] = date('Y-m-d H:i:s');
                             // set current date
                             break;
                         case 'DateLastEdit':
                         case 'DateLastLogin':
                             $aNewProfile[$sItemName] = '0000-00-00';
                             break;
                         case 'Couple':
                             $aNewProfile[$sItemName] = $aMainMember ? $iMainMemberID : 0;
                             //if main member exists, set him as a couple link
                             break;
                         case 'Featured':
                             $aNewProfile[$sItemName] = false;
                             break;
                         case 'Status':
                             if (getParam('autoApproval_ifNoConfEmail') == 'on') {
                                 if (getParam('autoApproval_ifJoin') == 'on' && !(getParam('sys_dnsbl_enable') && 'approval' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join'))) {
                                     $aNewProfile[$sItemName] = 'Active';
                                 } else {
                                     $aNewProfile[$sItemName] = 'Approval';
                                 }
                             } else {
                                 $aNewProfile[$sItemName] = 'Unconfirmed';
                             }
                             break;
                     }
                     break;
                 default:
                     $aNewProfile[$sItemName] = $aItem['Default'];
             }
         }
     }
     //we completed collecting
     // set default language
     $aNewProfile['LangID'] = getLangIdByName(getCurrentLangName());
     // set default privacy
     bx_import('BxDolPrivacyQuery');
     $oPrivacy = new BxDolPrivacyQuery();
     $aNewProfile['allow_view_to'] = $oPrivacy->getDefaultValueModule('profile', 'view_block');
     $sSet = $this->collectSetString($aNewProfile);
     $sQuery = "INSERT INTO `Profiles` SET \n{$sSet}";
     $rRes = db_res($sQuery);
     if ($rRes) {
         $iNewID = db_last_id();
         $this->createProfileCache($iNewID);
         if ($aMainMember) {
             $this->updateProfile($iMainMemberID, array('Couple' => $iNewID));
         }
         //set main member's couple. they will be linked each other
         //collect status text
         if ($bSendMails and !$aMainMember) {
             //send mail only to main member, not to couple
             $sStatusText = $aNewProfile['Status'];
             if (getParam('autoApproval_ifNoConfEmail') == 'on') {
                 if ('Active' == $sStatusText) {
                     $this->sendActivationMail($iNewID);
                 } else {
                     $this->sendApprovalMail($iNewID);
                 }
             } else {
                 if (!$this->sendConfMail($iNewID)) {
                     $sStatusText = 'NotSent';
                 }
             }
         } else {
             $sStatusText = 'OK';
         }
         //set crypted password
         $sSalt = genRndSalt();
         $this->updateProfile($iNewID, array('Password' => encryptUserPwd($aNewProfile['Password'], $sSalt), 'Salt' => $sSalt));
         bx_member_ip_store($iNewID);
         return array($iNewID, $sStatusText);
     } else {
         return array(false, 'Failed');
     }
 }
예제 #5
0
 /**
  * Create new profile;
  *
  * @param  : $aProfileInfo (array) - remote profile's information;
  *
  * @param  : $sAlternativeName (string) - profiles alternative nickname;
  * @return : error string or error or profile info array on success
  */
 function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true)
 {
     $sCountry = '';
     $sCity = '';
     // join by invite only
     if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) {
         return _t('_registration by invitation only');
     }
     // convert fields
     $aProfileFields = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName);
     if (empty($aProfileFields['Email'])) {
         return _t('_Incorrect Email');
     }
     // antispam check
     bx_import('BxDolStopForumSpam');
     $oBxDolStopForumSpam = new BxDolStopForumSpam();
     if (2 == getParam('ipBlacklistMode') && bx_is_ip_blocked()) {
         return _t('_Sorry, your IP been banned');
     } elseif ('on' == getParam('sys_dnsbl_enable') && 'block' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join oauth') || $oBxDolStopForumSpam->isSpammer(array('email' => $aProfileFields['Email'], 'ip' => getVisitorIP(false)), 'join oauth')) {
         return sprintf(_t('_sys_spam_detected'), BX_DOL_URL_ROOT . 'contact.php');
     }
     // check fields existence;
     foreach ($aProfileFields as $sKey => $mValue) {
         if (!$this->_oDb->isFieldExist($sKey)) {
             // (field not existence) remove from array;
             unset($aProfileFields[$sKey]);
         }
     }
     // add some system values
     $sNewPassword = genRndPwd();
     $sPasswordSalt = genRndSalt();
     $aProfileFields['Password'] = encryptUserPwd($sNewPassword, $sPasswordSalt);
     $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER;
     $aProfileFields['DateReg'] = date('Y-m-d H:i:s');
     // set current date;
     $aProfileFields['Salt'] = $sPasswordSalt;
     // set default privacy
     bx_import('BxDolPrivacyQuery');
     $oPrivacy = new BxDolPrivacyQuery();
     $aProfileFields['allow_view_to'] = $oPrivacy->getDefaultValueModule('profile', 'view_block');
     // check if user with the same email already exists
     $iExistingProfileId = $this->_oDb->isEmailExisting($aProfileFields['Email']);
     // check redirect page
     if ('join' == $this->_oConfig->sRedirectPage && !$iExistingProfileId) {
         return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true);
     }
     // create new profile
     if ($iExistingProfileId) {
         $iProfileId = $iExistingProfileId;
     } else {
         $iProfileId = $this->_oDb->createProfile($aProfileFields);
     }
     $oProfileFields = new BxDolProfilesController();
     // remember remote profile id for created member
     $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']);
     // check profile status;
     if (!$iExistingProfileId) {
         if (getParam('autoApproval_ifNoConfEmail') == 'on') {
             if (getParam('autoApproval_ifJoin') == 'on') {
                 $sProfileStatus = 'Active';
                 if (!empty($aProfileInfo['email'])) {
                     $oProfileFields->sendActivationMail($iProfileId);
                 }
             } else {
                 $sProfileStatus = 'Approval';
                 if (!empty($aProfileInfo['email'])) {
                     $oProfileFields->sendApprovalMail($iProfileId);
                 }
             }
         } else {
             if (!empty($aProfileInfo['email'])) {
                 $oProfileFields->sendConfMail($iProfileId);
                 $sProfileStatus = 'Unconfirmed';
             } else {
                 if (getParam('autoApproval_ifJoin') == 'on') {
                     $sProfileStatus = 'Active';
                 } else {
                     $sProfileStatus = 'Approval';
                 }
             }
         }
         // update profile's status;
         $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus);
         $oProfileFields->createProfileCache($iProfileId);
         // send email notification
         if (!empty($aProfileInfo['email'])) {
             $oEmailTemplate = new BxDolEmailTemplates();
             $aTemplate = $oEmailTemplate->getTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iProfileId);
             $aNewProfileInfo = getProfileInfo($iProfileId);
             $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword);
             sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus);
         }
         // update location
         if (BxDolModule::getInstance('BxWmapModule')) {
             BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId));
         }
         // create system event
         $oZ = new BxDolAlerts('profile', 'join', $iProfileId);
         $oZ->alert();
     }
     // store IP
     bx_member_ip_store($iProfileId);
     // auto-friend members if they are already friends on remote site
     if ($isAutoFriends && method_exists($this, '_makeFriends')) {
         $this->_makeFriends($iProfileId);
     }
     // set logged
     if ($isSetLoggedIn) {
         $aProfile = getProfileInfo($iProfileId);
         $this->setLogged($iProfileId, $aProfile['Password'], '', false);
     }
     return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $iExistingProfileId ? true : false);
 }
예제 #6
0
 function registerMember()
 {
     $oPC = new BxDolProfilesController();
     $oZ = new BxDolAlerts('profile', 'before_join', 0, 0, $this->aValues[0]);
     $oZ->alert();
     $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]);
     if (empty($aProfile1['NickName'])) {
         $aProfile1['NickName'] = uriGenerate(empty($aProfile1['FirstName']) ? genRndPwd(10, false) : $aProfile1['FirstName'], 'Profiles', 'NickName');
     }
     list($iId1, $sStatus1) = $oPC->createProfile($aProfile1);
     //--- check whether profile was created successfully or not
     if (!$iId1) {
         if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) {
             @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']);
         }
         return array(false, 'Fail');
     }
     //--- check for couple profile
     if ($this->bCouple) {
         $aProfile2 = $this->oPF->getProfileFromValues($this->aValues[1]);
         list($iId2, $sStatus2) = $oPC->createProfile($aProfile2, false, $iId1);
         if (!$iId2) {
             $oPC->deleteProfile($iId1);
             return array(false, 'Fail');
         }
     }
     bx_login($iId1);
     check_logged();
     //--- upload profile photo
     if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) {
         if ('sys_avatar' == getParam('sys_member_info_thumb') && BxDolRequest::serviceExists('avatar', 'set_image_for_cropping')) {
             BxDolService::call('avatar', 'set_image_for_cropping', array($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']));
         } elseif (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
             bx_import('BxDolPrivacyQuery');
             $oPrivacy = new BxDolPrivacyQuery();
             $aFileInfo = array('medTitle' => _t('_sys_member_thumb_avatar'), 'medDesc' => _t('_sys_member_thumb_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getUsername($iId1), getParam('bx_photos_profile_album_name')), 'albumPrivacy' => $oPrivacy->getDefaultValueModule('photos', 'album_view'));
             BxDolService::call('photos', 'perform_photo_upload', array($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader');
         }
     }
     if (BxDolModule::getInstance('BxWmapModule')) {
         BxDolService::call('wmap', 'response_entry_add', array('profiles', $iId1));
     }
     //--- create system event
     bx_import('BxDolAlerts');
     $oZ = new BxDolAlerts('profile', 'join', $iId1, 0, array('status_text' => &$sStatus1));
     $oZ->alert();
     return array($iId1, $sStatus1);
 }
예제 #7
0
 function addAlbum($aData = array(), $bCheck = true)
 {
     if ($bCheck) {
         $iCheck = $this->_checkAlbumExistence($aData);
         if ($iCheck != 0) {
             return $iCheck;
         }
     }
     $iOwner = (int) $aData['owner'];
     if (isset($aData['AllowAlbumView'])) {
         $iAllowAlbumView = (int) $aData['AllowAlbumView'];
     } elseif (strpos($aData['caption'], getUsername($iOwner)) !== false) {
         bx_import('BxDolPrivacyQuery');
         $oPrivacy = new BxDolPrivacyQuery();
         $iAllowAlbumView = $oPrivacy->getDefaultValueModule(str_replace('bx_', '', $this->sType), 'album_view');
         if (!$iAllowAlbumView) {
             $iAllowAlbumView = BX_DOL_PG_ALL;
         }
     } else {
         $iAllowAlbumView = BX_DOL_PG_NOBODY;
     }
     $sUri = $this->getCorrectUri($aData['caption'], $iOwner, $bCheck);
     $GLOBALS['MySQL']->res("INSERT INTO  `{$this->sAlbumTable}` SET " . $this->_getSqlPart(array('Caption' => $aData['caption'], 'Uri' => $sUri, 'Location' => $aData['location'], 'Description' => $aData['description'], 'AllowAlbumView' => $iAllowAlbumView, 'Type' => $this->sType, 'Owner' => $iOwner, 'Status' => 'active', 'Date' => time(), 'LastObjId' => isset($aData['lastObjId']) ? (int) $aData['last_obj'] : 0)));
     $iResult = $GLOBALS['MySQL']->lastId();
     if ($iResult > 0) {
         $oAlert = new BxDolAlerts('album', 'add', $iResult, $iOwner, array('Type' => $this->sType, 'Uri' => $sUri));
         $oAlert->alert();
         $oAlert = new BxDolAlerts($this->sType, 'addAlbum', $iResult, $iOwner, array('Uri' => $sUri));
         $oAlert->alert();
     }
     return $iResult;
 }
예제 #8
0
 function _uploadImage($iProfileId = 0)
 {
     $iProfileId = (int) $iProfileId;
     $sImagePath = BX_AVA_DIR_TMP . ($iProfileId ? $iProfileId : $this->_iProfileId) . BX_AVA_EXT;
     $i = strrpos($_FILES['image']['name'], '.');
     if (false === $i) {
         return false;
     }
     $sExt = strtolower(substr($_FILES['image']['name'], $i + 1));
     if (!in_array($sExt, $this->_aAllowedExt)) {
         return false;
     }
     if (move_uploaded_file($_FILES['image']['tmp_name'], $sImagePath)) {
         if ($_POST['copy_to_profile_photos']) {
             if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
                 bx_import('BxDolPrivacyQuery');
                 $oPrivacy = new BxDolPrivacyQuery();
                 $aFileInfo = array('medTitle' => _t('_bx_ava_avatar'), 'medDesc' => _t('_bx_ava_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getUsername($iProfileId), getParam('bx_photos_profile_album_name')), 'albumPrivacy' => $oPrivacy->getDefaultValueModule('photos', 'album_view'));
                 $_POST[BX_DOL_UPLOADER_EP_PREFIX . 'album'] = uriFilter($aFileInfo['album']);
                 BxDolService::call('photos', 'perform_photo_upload', array($sImagePath, $aFileInfo, false), 'Uploader');
             }
         }
         return IMAGE_ERROR_SUCCESS == imageResize($sImagePath, '', BX_AVA_PRE_RESIZE_W, BX_AVA_PRE_RESIZE_H, true) ? true : false;
     }
     return false;
 }