0

我有一个包含评论系统的个人资料页面,我现在只允许个人资料的所有者写他们的评论我想让朋友也写怎么做???

在成员表中,我有一个friend_array 字段,其中包含与该用户成为朋友的用户的ID

好友请求系统包括ajax和jquery

代码.php

$blab_form="";
if(isset($_SESSION['user_id']))
{
  if($_SESSION['user_id']==$id)
  {
    $blab_form='
    '.$blab_output_msg.'<br />
                <div style="background-color:#D2F0D3;border:#999 1px solid; padding:8px;">
                <form action="profile.php" method="post" enctype="multipart/form-data" name="blab_form">
                      <textarea name="blab_field" cols="" rows="4"  style="width:100%;">
                      </textarea><br />
                      (220 Char Max)
                      <input type="submit" name="submit" value="Blab"/>
                </form></div>';
        //$sql = mysql_query("DELETE FROM blabing WHERE u_id ='$id'")or die(mysql_error());
  }
}

朋友请求系统

<?php 
//****************friend request system********************//
// for securing the request with  and encryption to be  more secure.
if(isset($_SESSION['wpit']))
{
    $_SESSION['wipt'];
}
$theRundomNum = rand(99999999999999,9999999999999);
$_SESSION['wipt'] = base64_encode($theRundomNum);

//*********for distinguich the users*************//
//if member is a viewer
$friendLink = "";
if(isset($_SESSION['user_id'])&&$_SESSION['user_id']!=$id)
{
     //for quering friend array  for the viewer if he is not the owner 
     $sqlArray = mysql_query("SELECT  friend_array FROM members WHERE user_id ='".$_SESSION['user_id']."' LIMIT 1")or die(mysql_error());
     while($row = mysql_fetch_array($sqlArray))
     {
         $iFriendArray = $row['friend_array'];
     }
     $iFriendArray = explode("," , $iFriendArray);
     if(in_array($id, $iFriendArray))
     {
         $friendLink = '<a href="#" onclick = "return false" onmousedown="javascript:toggleInteractContainers(\'remove_friend\');">Remove Friend</a>';
     }
     else
     {
         $friendLink = '<a href="#" onclick = "return false" onmousedown="javascript:toggleInteractContainers(\'add_friend\');">Add as Friend</a>';
     }
    $interactionBox='<div class="interactionLinksDiv">
     '.$friendLink.' 
    </div>';
}
//if member is the profile ower
else
{
    $interactionBox = '<div class="interactionLinksDiv">
     <a href="#" onclick="return false" onmousedown="javascript:toggleInteractContainers(\'friend_requests\');">Freind Request List</a> </div>';

}
?>
4

1 回答 1

1

if($_SESSION['user_id']==$id)是特定于博客所有者的,对吗?所以你做这个有条件的检查会话ID是否在一个可接受的ID数组中。像这样的东西:

// assuming you already populated the $iFriendArray as outlined in your question
$iFriendArray[] = $id; // add blog owner to the friend array


if(in_array($_SESSION['user_id'], $iFriendArray))
{
    // can comment
}

这已更新为使用您问题中更新的朋友数组。

有任何问题可以随时提问,我可能会更新。

于 2013-05-17T23:07:16.157 回答