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

    $errmsg = "";
    $r = array();


    

    if (strlen($searchtxt))
    {
        if (strlen($searchtxt) < 4)
            $errmsg = "String must be at least 4 characters long";
    }

    if (!$errmsg && strlen($searchtxt))
    {
         $numperpage = 20;
         $page = ($page >=1) ? floor($page) : 1;
            
         $limit = "limit " . (($page-1) * $numperpage) . ", $numperpage";


         $degsep = (in_array($degsep, array(1,2,3,4))) ? $degsep : 4;

         $tarr = array();                 
       
         for ($x = 0; $x <= $degsep; $x++)
             $tarr = array_merge($tarr, $mpage->Friend[$x]);


         $tarr = array_merge($mpage->Friend[1], $mpage->Friend[2],
                             $mpage->Friend[3], $mpage->Friend[4]);

         $tarr = (sizeof($tarr)) ? $tarr : array(0);


         $sql = "select SQL_CALC_FOUND_ROWS *,
                   MATCH (Interests) AGAINST (\"$searchtxt\") as m
                   from UserTable where "
              . "  MATCH (Interests) AGAINST (\"$searchtxt\") " 
              . "  AND Id IN (".join(",", $tarr).") order by m desc $limit
         ";

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

         $sql = "select FOUND_ROWS()";
         $cnt = $mpage->DoQuery($sql);
         $cnt = $cnt[0][0];

         $numpages = ceil($cnt / $numperpage);


         if (!sizeof($r))
         {
            $errmsg = "No matches found";
         }
    }


?>

<BR>
<form method=post>
<table width=600 border=0 align=center>
<tr><td width=600 valign=top>

<span class="title1">Search By Interest</span>

<P>

<input name="searchtxt" value="<?= htmlentities($searchtxt) ?>">

<BR><BR>
Social distance<BR>
<select name="degsep">
 <option value=1 <?= ($degsep == 1) ? "selected" : "" ?>>1 degree of separation
 <option value=2 <?= ($degsep == 2) ? "selected" : "" ?>>2 degrees of separation
 <option value=3 <?= ($degsep == 3) ? "selected" : "" ?>>3 degrees of separation
 <option value=4 <?= ($degsep == 4) ? "selected" : "" ?>>4 degrees of separation
</select>

<BR><BR><input type="submit" class="submit" value="Search!">


<P>

<? 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>
            
<? } ?>


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

<table width=500 border=0 cellspacing=0>
<tr><td>

<? $tv = (($page-1) * $numperpage)+1; ?>
       

Showing <?= $tv ?>-<?= $tv + min(sizeof($r), $numperpage) - 1 ?> of <?= $cnt ?> Entr<?= ($cnt == 1) ? "y" : "ies" ?>

</td>

<form method=post>
<td align=right>
<select name="page">
 <? for ($x=1; $x <= $numpages; $x++) { ?>
   <option value="<?= $x ?>">Page <?= $x ?>
 <? } ?>
</select>

<input name="submit" type="submit" class="submit" value="go">
<input name="searchtxt" value="<?= htmlentities($searchtxt) ?>" type="hidden">



</td>
</form>

</tr>
</table>

<? } ?>


<table width=500 border=0 cellspacing=0>
<? foreach ($r as $s) { ?>



<tr><td width=90 align=center class="stdfilling">
      
<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 valign=top class="stdfilling"><a href="user.php?id=<?= $s[Id] ?>"><B><?= $s[Fname] ?></b></a>
<BR>
<table><tr><td>
<small>
         
<B><?= ($s[Gender] == 1) ? "Male" : "Female" ?></b>,

<? if ($s[Datestatus] == 0) { ?>
Unspecified
<? } elseif ($s[Datestatus] == 1) { ?>
Single
<? } elseif ($s[Datestatus] == 2) { ?>
  Light Dating
<? } elseif ($s[Datestatus] == 3) { ?>
  Relationship
<? } elseif ($s[Datestatus] == 4) { ?>
  Engaged
<? } elseif ($s[Datestatus] == 5) { ?>
  Married
<? } ?>
         
<BR>Interested in Meeting People for:<BR>
&nbsp;&nbsp;

<?    
      if ($s[Dating]) echo "Dating";
      if ($s[Dating] && $s[Relatn]) echo ", ";
      if ($s[Relatn]) echo "Relationship";
      if ($s[Dating] || $s[Relatn])
      {
         echo " <B>with ";
         if     ($s[DrGender] == 1) echo "Men";
         elseif ($s[DrGender] == 2) echo "Women";
         else                       echo "Men and Women";
         echo "</b>";
      }

      if ($s[Dating] || $s[Relatn]) echo "<BR>&nbsp;&nbsp; ";

  
      if ($s[Friends]) echo "Friends";
      if ($s[Friends] && $s[Netbud]) echo ", ";
      if ($s[Netbud]) echo "Net Buddy";
      if ($s[Friends] || $s[Relatn])
      {
         echo " <B>with ";
         if     ($s[FnGender] == 1) echo "Men";
         elseif ($s[FnGender] == 2) echo "Women";
         else                       echo "Men and Women";
         echo "</b>";
      }
      
      
?>
<BR><B>Age:</b> <?= $s[Age] ?>
      
       
         
</small>
</td></tr></table>
         
         
</td></tr>


<? } ?>
</table>

<BR><BR>

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

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

Return current item: Slashster