Location: PHPKode > projects > Slashster > slashster/html/editfriends.php
<?

# Slashster: Open Source Friend of a Friend Software
# Copyright 2004 Mark El-Wakil
# Contact: hide@address.com
# http://seventhcycle.net
#
# This file is part of Slashster.
#
# Slashster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Slashster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Slashster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    import_request_variables("gPc");

    require_once("PageClass.php");

    $mpage = new PageClass("authonly");  
    $mpage->MembersOnly();
    $mpage->Initialize("authremainder"); 

    $msg = "";

    if ($delete)
    {
        $lvl = $mpage->UserDistance($delete);
        
        if ($lvl != 1)
        {
             $msg = "This Person is not your friend.";
             $mpage->ClosePage();
        }
        else
        {
             $sql = "select * from UserTable where Id = \"$delete\"";
             $nn = $mpage->DoQuery($sql,1);
             $nn = $nn[0];

             $msg  = "Are you sure you wish to delete $nn[Fname]?";
             $msg .= "<BR>[<a href=\"editfriends.php\">Cancel</a>]&nbsp;&nbsp;&nbsp;";
             $msg .= "[<a href=\"editfriends.php?id=$delete\">Delete</a>]";
        }

    } 
    elseif ($id)
    {
        $lvl = $mpage->UserDistance($id);
     
        if ($lvl != 1)
        {
             $msg = "This Person is not your friend.";
             $mpage->ClosePage();
        }
        else
        {
             $sql = "delete from FriendTable where Start=$mpage->IdNum && End=\"$id\" ";
             $mpage->DoQuery($sql);

             $sql = "delete from FriendTable where End=$mpage->IdNum && Start=\"$id\" ";
             $mpage->DoQuery($sql);

             $sql = "update UserTable set UpdNow=1 where Id = " . $mpage->IdNum;
             $mpage->DoQuery($sql); 

             $sql = "update UserTable set UpdNow=1 where Id = \"$id\" ";
             $mpage->DoQuery($sql);


             $sql = "select * from UserTable where Id = \"$delete\"";
             $nn = $mpage->DoQuery($sql,1);
             $nn = $nn[0];

             $msg  = "$nn[Fname] is no longer your friend.";

             unset($mpage->Friend[1][$id]);
        }
    }


    $sql = "select UserTable.* from FriendTable 
            left join UserTable on FriendTable.End = UserTable.Id
            where Start=$mpage->IdNum";

    $r = $mpage->DoQuery($sql,1);

?>

<? if ($msg) { ?>


<P><BR>
<table border=4 bordercolor=red cellspacing=0 cellpadding=5px width=600 align=center>
<tr><td style="font: bold 16px arial; color:red;">
<?= $msg ?>
</td></tr>
</table>

<? } ?>


<BR>
<table width=600 border=1 align=center cellspacing=0>


<? if (!sizeof($r)) { ?>

<tr><td>You have no friends</td></tr>

<? } ?>


<? 
   for ($x = 0; $x < sizeof($r); $x++) 
   { 
       $s = $r[$x];
       if ($x % 2 == 0) echo "<tr>";
?>

<td>

<table width=100% cellspacing=0 cellpadding=0>
<tr><td width=100 valign=center>
<a href="user.php?id=<?= $s[Id] ?>"
><img border=0 src="userpics/<?= $mpage->PicPr($s[PicDefault], $s[Id]) ?>-b.jpg" width=80 height=60></a>
</td><td width=100>
<a href="user.php?id=<?= $s[Id] ?>"
><?= $s[Fname] ?> <?= substr($s[Lname],0,1) ?></a>.

</td><td width=100>
<small>[<a href="editfriends.php?delete=<?= $s[Id] ?>">Delete Friend</a>]</small>
</td></tr>
</table>

</td>

<?
       if ($x % 2 == 1) echo "</tr>";
   }

   if ($x % 2 == 1) echo "<td>&nbsp;</td></tr>";

?>

</table>
<table cellspacing=0 cellpadding=0 border=0 width=600 align=center>

<tr><td colspan=2>

<BR>
<a class="submit" href="main.php">&nbsp;&nbsp;Go 
Home&nbsp;&nbsp;</a>
<BR><BR>

</td></tr>
</table>
<BR>




<? $mpage->ClosePage(); ?>

Return current item: Slashster