Location: PHPKode > projects > Slashster > slashster/html/usersearch.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");

    $r = array();

    $errmsg = ""; 
   
    if ($searchall)
    {
        $email = trim($email);
        $fname = trim($fname);
        $lname = trim($lname);

        if (!$email && !$fname && !$lname)
        {
            $errmsg = "Please enter in an email address, or first and last name.";
        }
 
        if (!$errmsg && !$email && !$fname && $lname)
        {
            $errmsg = "Please enter a First Name";
        }

        if (!$errmsg && !$email && $fname && !$lname) 
        {
            $errmsg = "Please enter a Last Name";
        }

        if (!$errmsg) 
        {
            $sql = ($email)
                 ? "Email = \"$email\""
                 : "Fname = \"$fname\" AND Lname = \"$lname\"";
 
            $sql = "select * from UserTable where $sql order by Id desc";
            $r = $mpage->DoQuery($sql,1);
        }

    }


?>

<BR>
<table width=700 border=0>
<tr><td width=700 valign=top>

<form method=post>

<b class="title1">User Search</b>
<br>

<small>[<a href="people.php">Find People</a>]</small>
&nbsp;&nbsp;
<small>[<a href="searchinterest.php">Search By Interest</a>]</small>



<BR><BR>

<? if ($errmsg) { ?>

<P>
<table border=4 bordercolor=red cellspacing=0 cellpadding=5px>
<tr><td style="font: bold 16px arial; color:red;">
Error: <?= $errmsg ?>
</td></tr>
</table>
<P>

<? } ?>


<table border=1 cellspacing=0>
<tr><td width=300 valign=middle align=center class="stdfilling">

<B>Search All Users</b>

<form>
<table>
<tr><td>Email Address:</td>
    <td><input name="email" value="<?= htmlentities($email) ?>"></td>
</tr>
<tr><td>First Name:</td>
    <td><input name="fname" value="<?= htmlentities($fname) ?>"></td>
</tr> 
<tr><td>Last Name:</td>
    <td><input name="lname" value="<?= htmlentities($lname) ?>"></td>
</tr> 
</table>

<input name="searchall" type="submit" class="submit" value="Search!">

</form>

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


<BR><BR><BR>
<table width=300 cellspacing=0 cellpadding=4 border=0>
<? foreach ($r as $s) { ?>
<tr><td class="stdfilling" width=58 align=center>
<img width=48 height=36 src="userpics/<?= $mpage->PicPr($s[PicDefault], $s[Id]) ?>-c.jpg"></td>
    <td class="stdfilling">
    <a href="user.php?id=<?= $s[Id] ?>"><?= $s[Fname] ?> 
    <?= substr($s[Lname],0,1) ?>.</a>
    </td>
    <td class="stdfilling">
    <? $status = $mpage->UserDistance($s[Id]); ?>

    <? if (!$status) { ?>
      This is you... duh.
    <? } elseif ($status == 1) { ?>
      This is your friend.
    <? } else { ?>
      [<a href="addfriendrequest.php?id=<?= $s[Id] ?>">Add as a friend</a>]
    <? } ?>
</td>
</tr>

<? } ?>
</table>

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


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

Return current item: Slashster