2013-05-17 55 views
0

我有一個包含評論系統的個人資料頁面,我只允許個人資料的主人現在寫下他們的評論我想讓朋友也可以寫出如何做到這一點? ?只允許朋友在他們的個人資料頁面發表評論

在部件表

我有包含是朋友與該用戶

朋友請求系統的用戶的ID包括AJAX和jQuery

code.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()); 
    } 
} 
一個friend_array場

friend_request_system

<?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>'; 

} 
?> 
+1

我們需要更多代碼 – samayo

+0

更多代碼?作爲什麼? – user2394498

+0

like'friend_array' .., – samayo

回答

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 
} 

這已更新爲使用您的問題中更新的朋友陣列。

任何問題隨時問,我可能會更新。

相關問題