function follow($connection, $id_user, $sess_usr) { if (is_exist($id_user, $connection) === 1 && is_friends($sess_usr, $connection, $id_user) === 0) { $stmt = $connection->prepare("update users set followed=followed+1 where id=?"); $stmt1 = $connection->prepare("update users set following=following+1 where id=?"); $stmt2 = $connection->prepare("insert into friends(id_user,id_friend) values(?,?)"); $stmt->bind_param("i", $id_user); $stmt1->bind_param("i", $sess_usr); $stmt2->bind_param("ii", $sess_usr, $id_user); $stmt->execute(); $stmt1->execute(); $stmt2->execute(); return 1; } else { return 0; } }
/** * Make friends * * @param $iProfileId integer * @return void */ function _makeFriends($iProfileId) { if (!$this->_oConfig->bAutoFriends) { return; } try { //get friends from facebook $aFacebookFriends = $this->oFacebook->api('/me/friends/'); } catch (FacebookApiException $e) { return; } //process friends if (!empty($aFacebookFriends) && is_array($aFacebookFriends)) { $aFacebookFriends = array_shift($aFacebookFriends); foreach ($aFacebookFriends as $iKey => $aFriend) { $iFriendId = $this->_oDb->getProfileId($aFriend['id']); if ($iFriendId && !is_friends($iProfileId, $iFriendId)) { //add to friends list $this->_oDb->makeFriend($iProfileId, $iFriendId); //create system alert $oZ = new BxDolAlerts('friend', 'accept', $iProfileId, $iFriendId); $oZ->alert(); } } } }
function GetPostNewCommentPermission($aPostData) { $bCanPostComment = true; $bFriend = is_friends($this->iVisitorID, $aPostData['OwnerID']); $bOwner = $this->iVisitorID == $aPostData['OwnerID'] ? true : false; switch ($this->iCType) { case 2: if ($aPostData['PostCommentPermission'] == 'public' || $bFriend || $bOwner || $this->bAdminMode) { $bCanPostComment = true; } else { $bCanPostComment = false; } break; } return $bCanPostComment; }
/** * Make friends * * @param $iProfileId integer * @return void */ function _makeFriends($iProfileId) { if (!$this->_oConfig->bAutoFriends) { return; } try { //get friends from facebook $oFriendsResponse = $this->oFacebook->get('/me/friends?limit=50'); } catch (Facebook\Exceptions\FacebookResponseException $e) { return; } catch (Facebook\Exceptions\FacebookSDKException $e) { return; } // paginate through the result $oPagesEdge = $oFriendsResponse->getGraphEdge(); do { foreach ($oPagesEdge as $oPage) { $aFriend = $oPage->asArray(); $iFriendId = $this->_oDb->getProfileId($aFriend['id']); if ($iFriendId && !is_friends($iProfileId, $iFriendId)) { //add to friends list $this->_oDb->makeFriend($iProfileId, $iFriendId); //create system alert $oZ = new BxDolAlerts('friend', 'accept', $iProfileId, $iFriendId); $oZ->alert(); } } } while ($oPagesEdge = $this->oFacebook->next($oPagesEdge)); }
/** * Generate a Block of searching result by Tag (GET is tagKey) * * @return HTML presentation of data */ function GenSearchResult() { global $site; $iCheckedMemberID = $this->aBlogConf['visitorID']; $sRestrictRes = $this->CheckRestrictionToView($iCheckedMemberID); if ($sRestrictRes != '') { return $sRestrictRes; } $bNoProfileMode = isset($_REQUEST['ownerID']) || isset($_REQUEST['ownerName']) ? false : true; $sRetHtml = ''; $sSearchedTag = process_db_input($_REQUEST['tagKey']); $iMemberID = $this->defineUserId(); $sDateFormatPhp = getParam('php_date_format'); $sTagsC = _t('_Tags'); $sNoBlogC = _t('_No blogs available'); $sBlogPosts = ''; $sWhereAddon = $iMemberID > 0 ? "AND `BlogCategories`.`OwnerID` = {$iMemberID}" : ''; $sOwnerAddAp = $iMemberID == $this->aBlogConf['visitorID'] ? '' : "AND `PostStatus`='approval'"; $sBlogPostsSQL = "\n\t\t\tSELECT `BlogPosts`. * , `BlogCategories`.`CategoryName`, `BlogCategories`.`CategoryUri`, `BlogCategories`.`CategoryID`, `BlogCategories`.`OwnerID` AS 'OwnID'\n\t\t\tFROM `BlogPosts` \n\t\t\tINNER JOIN `BlogCategories` ON `BlogCategories`.`CategoryID` = `BlogPosts`.`CategoryID` \n\t\t\tWHERE 1 \n\t\t\t{$sWhereAddon}\n\t\t\t{$sOwnerAddAp}\n\t\t"; $vBlogPosts = db_res($sBlogPostsSQL); while ($aResSQL = mysql_fetch_assoc($vBlogPosts)) { $sDateTime = date($sDateFormatPhp, strtotime($aResSQL['BlogDate'])); $oCmts = new BxDolCmts('blogposts', $aResSQL['PostID']); $iCountBlogComments = $oCmts->getObjectCommentsCount(); $sTagsCommas = $aResSQL['Tags']; $aTags = split(',', $sTagsCommas); if (in_array($sSearchedTag, $aTags)) { $sProfNickName = getNickName($aResSQL['OwnID']); if ($iMemberID > 0) { $aUser = array('Permalink' => $sProfNickName, 'Link' => $aResSQL['OwnID']); } else { $aUser = ''; } foreach ($aTags as $sTagKey) { $sTagLink = $this->genBlogLink('search_by_tag', $aUser, '', '', $sTagKey); $sTagsHrefs .= <<<EOF <a href="{$sTagLink}" >{$sTagKey}</a> EOF; } $sActions = ''; if (($this->aBlogConf['visitorID'] == $aBlogsRes['OwnerID'] || $this->bAdminMode == TRUE) && $iMemberID > 0) { $sLink = $this->genBlogFormUrl(); $sActions = <<<EOF <div class="fr"> \t\t<a href="{$sLink}" onclick="javascript: UpdateField('EditPostID','{$aResSQL['PostID']}');document.forms.command_edit_post.submit();return false;" style="text-transform:none;">{$sEditC}</a> \t\t<a href="{$sLink}" onclick="javascript: if (confirm('{$sSureC}')) {UpdateField('DeletePostID','{$aResSQL['PostID']}');UpdateField('DOwnerID','{$aBlogsRes['OwnerID']}');document.forms.command_delete_post.submit(); } return false;" style="text-transform:none;">{$sDeleteC}</a> </div> EOF; } $sProfileLink = $iMemberID > 0 ? '' : "<a href=" . getProfileLink($aResSQL['OwnID']) . ">" . $sProfNickName . "</a>"; $bFriend = is_friends($this->aBlogConf['visitorID'], $aResSQL['OwnID']); $bOwner = $this->aBlogConf['visitorID'] == $aResSQL['OwnID'] ? true : false; if ('friends' == $aResSQL['PostReadPermission'] && !$bFriend && !$bOwner && !$this->bAdminMode) { $sMsgBox = MsgBox(_t('_this_blog_only_for_friends')); $sBlogPosts .= <<<EOF <div class="clear_both"></div> \t<img src="{$site['icons']}lock.gif" alt="" class="marg_icon" style="float:right;position:relative;" /> \t{$sMsgBox} <div class="clear_both"></div> EOF; } else { $aUser = array('Permalink' => $sProfNickName, 'Link' => $aResSQL['OwnID']); $aPost = array('Permalink' => $aResSQL['PostUri'], 'Link' => $aResSQL['PostID']); $aCat = array('Permalink' => $aResSQL['CategoryUri'], 'Link' => $aResSQL['CategoryID']); $sPostLink = $this->genBlogLink('show_member_post', $aUser, '', $aPost); $sCatLink = $this->genBlogLink('show_member_blog', $aUser, $aCat, $aPost); $sBlogPosts .= <<<EOF <div class="cls_res_info_p1"> \t<div class="cls_res_thumb"> \t\t<a class="actions" href="{$sPostLink}"> \t\t\t{$aResSQL['PostCaption']} \t\t</a> \t</div> \t{$sActions} \t<div class="clear_both"></div> </div> <div class="fr_small_gray_centered"> \t{$sProfileLink} \t<span style="vertical-align:middle;"><img src="{$site['icons']}clock.gif" style="position:static;margin-right:7px;" alt="{$sDateTime}" /></span>{$sDateTime} \t<span style="vertical-align:middle;"><img src="{$site['icons']}add_comment.gif" alt="{$sAddCommentC}" title="{$sAddCommentC}" style="position:static;margin-right:7px;" /></span>{$iCountBlogComments} comments \t<span style="vertical-align:middle;"><img src="{$site['icons']}folder_small.png" style="position:static;margin-right:7px;" /></span> \t<a href="{$sCatLink}"> \t\t{$aResSQL['CategoryName']} \t</a> </div> <div class="cls_res_info_p1"> \t{$aResSQL['PostText']} </div> <div class="cls_res_info_p1"> \t<span style="vertical-align:middle;"><img src="{$site['icons']}tag_small.png" style="position:static;margin-right:7px;" alt="" /></span>{$sTagsC}: {$sTagsHrefs} </div> <br /> EOF; } } else { //return MsgBox(_t('_Sorry, nothing found')); } } if ($sBlogPosts == '') { $sBlogPosts = MsgBox(_t('_Sorry, nothing found')); } $sContentSect = DesignBoxContent($sTagsC . ' - ' . $sSearchedTag, $sBlogPosts, 1); if ($bNoProfileMode == false) { $sRightSect = ''; if ($iMemberID > 0 && ($a = $this->GetProfileData($iMemberID))) { $sBlogsSQL = "\n\t\t\t\t\tSELECT `Blogs`. * , `Profiles`.`Nickname` \n\t\t\t\t\tFROM `Blogs` \n\t\t\t\t\tINNER JOIN `Profiles` ON `Blogs`.`OwnerID` = `Profiles`.`ID`\n\t\t\t\t\tWHERE `Blogs`.`OwnerID` = {$iMemberID}\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"; $aBlogsRes = db_arr($sBlogsSQL); if (mysql_affected_rows() == 0) { $sNoBlogC = MsgBox($sNoBlogC); $sRetHtml = <<<EOF <div> \t<div class="clear_both"></div> \t<div class="{$sWidthClass}"> \t\t{$sNoBlogC} \t</div> \t<div class="clear_both"></div> </div> <div class="clear_both"></div> EOF; } else { $sRightSect = $this->GenMemberDescrAndCat($aBlogsRes); $sWidthClass = $iMemberID > 0 ? 'cls_info_left' : 'cls_res_thumb'; $sRetHtml = $this->Templater($sContentSect, $sRightSect, $sWidthClass); } } else { $sRetHtml = MsgBox(_t('_Profile Not found Ex')); } } else { $sRetHtml = <<<EOF <div> \t<div class="clear_both"></div> \t<div class="{$sWidthClass}"> \t\t{$sContentSect} \t</div> \t<div class="clear_both"></div> </div> <div class="clear_both"></div> EOF; } return $sRetHtml; }
public static function fillProfileArray($a, $sImage = 'icon', $iIdViewer = 0) { if (!$iIdViewer) { $iIdViewer = (int) $_COOKIE['memberID']; } $sImageKey = ucfirst($sImage); $sImage = BxDolXMLRPCUtil::getThumbLink($a['ID'], $sImage); bx_import('BxDolAlbums'); $oBxDolXMLRPCMedia = new BxDolXMLRPCMedia(); $aRet = array('user_title' => new xmlrpcval($GLOBALS['oFunctions']->getUserTitle($a['ID'])), 'user_info' => new xmlrpcval($GLOBALS['oFunctions']->getUserInfo($a['ID']) . ' '), 'user_location' => new xmlrpcval(BxDolXMLRPCUtil::getUserLocation($a) . ' '), 'user_friend' => new xmlrpcval(is_friends($a['ID'], (int) $iIdViewer) ? 1 : 0), 'ID' => new xmlrpcval($a['ID']), 'Title' => new xmlrpcval($GLOBALS['oFunctions']->getUserTitle($a['ID'])), 'Nick' => new xmlrpcval($a['NickName']), 'Sex' => new xmlrpcval($a['Sex']), 'Age' => new xmlrpcval(age($a['DateOfBirth'])), 'Country' => new xmlrpcval(_t($GLOBALS['aPreValues']['Country'][$a['Country']]['LKey'])), 'City' => new xmlrpcval($a['City']), 'CountPhotos' => new xmlrpcval($oBxDolXMLRPCMedia->_getMediaCount('photo', $iId, $iIdViewer)), 'CountVideos' => new xmlrpcval($oBxDolXMLRPCMedia->_getMediaCount('video', $iId, $iIdViewer)), 'CountSounds' => new xmlrpcval($oBxDolXMLRPCMedia->_getMediaCount('music', $iId, $iIdViewer)), 'CountFriends' => new xmlrpcval(getFriendNumber($a['ID'])), $sImageKey => new xmlrpcval($sImage)); bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('mobile', 'user_info2', $a['ID'], $iIdViewer, array('profile' => &$a, 'return_data' => &$aRet)); $oZ->alert(); return $aRet; }
function getScriptFriendCancel($iId, $iMemberId, $bShowResult = true) { if (!isLogged() || $iId == $iMemberId || !is_friends($iId, $iMemberId)) { return; } $sOnResult = $bShowResult ? "\$('#ajaxy_popup_result_div_" . $iId . "').html(sData);" : "document.location.href=document.location.href;"; return "\$.post('list_pop.php?action=remove_friend', {ID: " . $iId . "}, function(sData){" . $sOnResult . "}); return false;"; }
function _checkBlogPermission($iAction) { $iPostID = $this->getId(); $sBlogPostFr = db_value("SELECT `PostCommentPermission` FROM `BlogPosts` WHERE `BlogPosts`.`PostID` = '{$iPostID}'"); if ($sBlogPostFr == 'friends') { $iOwnerID = db_value("SELECT `BlogCategories`.`OwnerID` FROM `BlogPosts` INNER JOIN `BlogCategories` ON `BlogCategories`.`CategoryID` = `BlogPosts`.`CategoryID` WHERE `BlogPosts`.`PostID` = '{$iPostID}'"); return is_friends($this->_getAuthorId(), $iOwnerID); } return $this->checkAction($iAction); }
function displaySearchUnit($aResSQL) { $iVisitorID = (int) $_COOKIE['memberID']; $oMain = $this->getBlogsMain(); $sTagsSmallIcon = $sClockIcon = $sCommentsIcon = $sCategoryIcon = ''; if ($oMain->_oTemplate) { $sTagsSmallIcon = $oMain->_oTemplate->getIconUrl('tgs.png'); $sClockIcon = $oMain->_oTemplate->getIconUrl('clock.png'); $sCommentsIcon = $oMain->_oTemplate->getIconUrl('comments.png'); $sCategoryIcon = $oMain->_oTemplate->getIconUrl('folder_small.png'); } $iPostID = (int) $aResSQL['id']; $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL; $bPossibleToView = $oMain->oPrivacy->check('view', $iPostID, $oMain->_iVisitorID); if (!$bPossibleToView) { return $oMain->_oTemplate->parseHtmlByName('browse_unit_private.html', array('extra_css_class' => '')); } $sCategories = $aResSQL['Categories']; $aCategories = $oMain->getTagLinks($aResSQL['Categories'], 'category', CATEGORIES_DIVIDER); $sFriendStyle = ''; $sPostVote = ''; $sPostMode = ''; $sVotePostRating = $this->oRate->getJustVotingElement(0, 0, $aResSQL['Rate']); $aProfileInfo = getProfileInfo($aResSQL['ownerId']); $sOwnerNickname = process_line_output($aProfileInfo['NickName']); $sCategoryName = $aResSQL['Categories']; $sPostLink = $this->getCurrentUrl('file', $iPostID, $aResSQL['uri']) . $sCategoryUrlAdd; $sAllCategoriesLinks = ''; if (count($aCategories) > 0) { foreach ($aCategories as $iKey => $sCatValue) { $sCatLink = $this->getCurrentUrl('category', title2uri($sCatValue), title2uri($sCatValue), array('ownerId' => $aResSQL['ownerId'], 'ownerName' => $sOwnerNickname)); $sCatName = process_line_output($sCatValue); $aAllCategoriesLinks[] = '<a href="' . $sCatLink . '">' . $sCatName . '</a>'; } $aAllCategoriesLinkHrefs = implode(", ", $aAllCategoriesLinks); $sAllCategoriesLinks = <<<EOF <span class="margined"> \t<span>{$aAllCategoriesLinkHrefs}</span> </span> EOF; } $sAdminCheck = $sAdminStatus = ''; if ($this->bShowCheckboxes) { $sAdminCheck = <<<EOF <div class="browseCheckbox"><input id="ch{$iPostID}" type="checkbox" name="bposts[]" value="{$iPostID}" /></div> EOF; $sPostStatus = process_line_output($aResSQL['PostStatus']); $sAdminStatus = <<<EOF ({$sPostStatus}) EOF; } $sPostCaption = process_line_output($aResSQL['title']); $sPostCaptionHref = <<<EOF <a class="actions" href="{$sPostLink}">{$sPostCaption}</a>{$sAdminStatus} EOF; if ($this->iPostViewType == 3) { $sFriendStyle = "2"; $sPostMode = '_post'; $sPostCaptionHref = '<div class="actions">' . $sPostCaption . '</div>'; } $sDateTime = defineTimeInterval($aResSQL['date']); //$oCmtsView = new BxTemplCmtsView ('blogposts', (int)$iPostID); $iCommentsCnt = (int) $aResSQL['CommentsCount']; $sAuthor = ''; if ($this->iPostViewType == 2) { $sAuthor = getProfileLink($aResSQL['ownerId']); $sAuthor = '<a href="' . $sAuthor . '">' . $sOwnerNickname . '</a>'; } $sTagsCommas = $aResSQL['tag']; //$aTags = split(',', $sTagsCommas); $aTags = preg_split("/[;,]/", $sTagsCommas); //search by tag skiping if ($this->sSearchedTag != '' && in_array($this->sSearchedTag, $aTags) == false) { return; } $sTagsHrefs = ''; $aTagsHrefs = array(); foreach ($aTags as $sTagKey) { if ($sTagKey != '') { $sTagLink = $this->getCurrentUrl('tag', $iPostID, htmlspecialchars(title2uri($sTagKey))); $sTagsHrefAny = <<<EOF <a href="{$sTagLink}" title="{$sTagKey}">{$sTagKey}</a> EOF; $aTagsHrefs[] = $sTagsHrefAny; } } $sTagsHrefs = implode(", ", $aTagsHrefs); $sTags = <<<EOF <span class="margined"> \t<span>{$sTagsHrefs}</span> </span> EOF; $sPostText = process_html_output($aResSQL['bodyText']); //$sPostText = addslashes( clear_xss( trim( process_pass_data($aResSQL['bodyText'])))); $bFriend = is_friends($iVisitorID, $aResSQL['ownerId']); $bOwner = $iVisitorID == $aResSQL['ownerId'] ? true : false; $sOwnerThumb = $sPostPicture = ''; if ($aResSQL['PostPhoto'] && $this->iPostViewType == 3) { $sSpacerName = getTemplateIcon('spacer.gif'); $sPostPicture = <<<EOF <div class="marg_both_left"> \t<img alt="{$aResSQL['PostPhoto']}" style="width:{$this->iThumbSize}px; height:{$this->iThumbSize}px; background-image: url({$sBlogsImagesUrl}big_{$aResSQL['PostPhoto']});cursor:pointer;" src="{$sSpacerName}" onclick="javascript: window.open( '{$sBlogsImagesUrl}orig_{$aResSQL['PostPhoto']}', 'blog post', 'width={$this->iImgSize}, height={$this->iImgSize}, menubar=no,status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no' );" /> </div> EOF; } if ($this->iPostViewType == 4) { $sOwnerThumb = $GLOBALS['oFunctions']->getMemberIcon($aResSQL['ownerId'], 'left'); } if ($this->iPostViewType == 4 || $this->iPostViewType == 1) { $iBlogLimitChars = (int) getParam('max_blog_preview'); $iBlogLimitChars = 200; if (strlen($aResSQL['bodyText']) > $iBlogLimitChars) { //$sLinkMore = "... <a href=\"".$sPostLink."\">"._t('_Read more')."</a>"; $sLinkMore = ''; $sPostText = html_entity_decode(process_line_output($aResSQL['bodyText'])); $sPostText = mb_substr(strip_tags($sPostText), 0, $iBlogLimitChars); } } $aUnitReplace = array(); $aUnitReplace['checkbox'] = $sAdminCheck; $aUnitReplace['post_caption'] = $sPostCaptionHref; $aUnitReplace['author'] = $sAuthor; $aUnitReplace['clock_icon'] = $sClockIcon; $aUnitReplace['post_date'] = strtolower($sDateTime); $aUnitReplace['category_icon'] = $sCategoryIcon; $aUnitReplace['all_categories'] = $sAllCategoriesLinks; $aUnitReplace['comments_icon'] = $sCommentsIcon; $aUnitReplace['comments_count'] = $iCommentsCnt; $aUnitReplace['post_tags'] = $sTags; $aUnitReplace['friend_style'] = $sFriendStyle; $aUnitReplace['post_uthumb'] = $sOwnerThumb; $aUnitReplace['post_picture2'] = $sPostPicture; $aUnitReplace['post_description'] = $sPostText; $aUnitReplace['post_vote'] = $sVotePostRating; $aUnitReplace['post_mode'] = $sPostMode; return $oMain->_oTemplate->parseHtmlByTemplateName('blogpost_unit', $aUnitReplace); }