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

?>

<BR>
<table width=700 border=0>
<tr><td width=200 valign=top>
  <? Side() ?>
</td><td valign=top>
  <?= Main() ?>
</td></tr>
</table>

<?
   $mpage->ClosePage();

function Side()
{ 
  extract($_POST);

  if (!$submit)
  {
      $onlyphotos = 1;
      $dst = array(1,2,3,4,5);
      $chkal = 1;
  }

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

  if (!is_array($dst)) $dst = array();


?>

<script>

function chkall()
{
   v = document.frm
 
   if (v.chkal.checked)
   {
       for(i=0;i<v.elements.length;i++)
       {
           if(v.elements[i].name=="dst[]")
           {
               if(!v.elements[i].checked) v.elements[i].click();
           }
       }
   }


}

function chkoff(vt)
{
   if (!vt.checked)
   {
      v = document.frm.chkal
      if (v.checked) v.click()
   } 
}



</script>

<table cellspacing=0 cellpadding=5 width=195 border=0>
<tr><td class="stdtable" align=center><B>Find People</b></td></tr>
<tr><td class="stdaltfilling" align=center>

<small><BR></small>
<span class="stdfilling">&nbsp;&nbsp;&nbsp;&nbsp;<a 
href="usersearch.php"><B>User Search</b></a>&nbsp;&nbsp;&nbsp;</span><BR><BR>

<span class="stdfilling">&nbsp;&nbsp;&nbsp;&nbsp;<a
href="searchinterest.php"><small>Search By Interests</b></a>&nbsp;&nbsp;&nbsp;</span><BR><BR>
</td></tr>

<form method=post name=frm>
<tr><td class="stdaltfilling">

<B>Show:</b><BR>
<input name="onlyphotos" type="checkbox" value=1 <?=
($onlyphotos) ? "checked" : "" ?>>Only people with photos<BR>
&nbsp;<input name="disp" type="radio" value=0 <?= ($disp) ? "" : "checked" ?>>Just Photos<BR>
&nbsp;<input name="disp" type="radio" value=1 <?= ($disp) ? "checked" : "" ?>>Photos and Info<BR>



<B>People who are:</b><BR>
&nbsp;<input name="gender" type="radio" value=0 <?= (!$gender) ? "checked" : "" ?>>Either<BR>  
&nbsp;<input name="gender" type="radio" value=1 <?= ($gender == 1) ? "checked" : "" ?>>Men<BR>    
&nbsp;<input name="gender" type="radio" value=2 <?= ($gender == 2) ? "checked" : "" ?>>Women<BR>  

<hr>


<B>Interested In Meeting<BR>People For:</b><BR>

<table cellspacing=0 cellpadding=0 width=100%>
<tr><td>
        <small>All</small></td></tr>
<tr><td colspan=2><hr></td></tr>

<tr><td><input name="intr1" type="checkbox" <?= ($intr1) ? "checked" : "" ?>>
        <small>Dating</small></td>
    <td><input name="intr2" type="checkbox" <?= ($intr2) ? "checked" : "" ?>>
        <small>Men</small></td>
</tr>
<tr><td><input name="intr3" type="checkbox" <?= ($intr3) ? "checked" : "" ?>>
        <small>Relationship</small></td>
    <td><input name="intr4" type="checkbox" <?= ($intr4) ? "checked" : "" ?>>
        <small>Women</small></td>
</tr>

<tr><td colspan=2><hr></td></tr>


<tr><td><input name="intr5" type="checkbox" <?= ($intr5) ? "checked" : "" ?>>
        <small>Friends</small></td>
    <td><input name="intr6" type="checkbox" <?= ($intr6) ? "checked" : "" ?>>
        <small>Men</small></td>
</tr>
<tr><td><input name="intr7" type="checkbox" <?= ($intr7) ? "checked" : "" ?>>
        <small>Netbuddy</small></td>
    <td><input name="intr8" type="checkbox" <?= ($intr8) ? "checked" : "" ?>>
        <small>Women</small></td>
</tr>


</table>





<hr>

&nbsp;&nbsp;<B>Age:</b>&nbsp;&nbsp;
<input name="age1" style="width:40px" maxlength=2 value="<?= htmlentities($age1) ?>">
&nbsp;to&nbsp;
<input name="age2" style="width:40px" maxlength=2 value="<?= htmlentities($age2) ?>"><BR>


<BR><B>Dating Status:</b><BR>
&nbsp;<input name="chkal" onclick="chkall()" type="checkbox" value=1 <?= ($chkal) ? "checked" : "" ?>>Any<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=0 <?= (in_array("0", $dst)) ? "checked" : "" ?>>Unspecified<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=1 <?= (in_array(1, $dst)) ? "checked" : "" ?>>Single<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=2 <?= (in_array(2, $dst)) ? "checked" : "" ?>>Light Dating<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=3 <?= (in_array(3, $dst)) ? "checked" : "" ?>>Relationship<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=4 <?= (in_array(4, $dst)) ? "checked" : "" ?>>Engaged<BR>
&nbsp;<input name="dst[]" onclick="chkoff(this)" type="checkbox" value=5 <?= (in_array(5, $dst)) ? "checked" : "" ?>>Married<BR>

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

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


<BR><BR>
<center>
<input class="submit" name="submit" type="submit" value="Search">
</center>

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




</table>



<? } 


function Main()
{
   global $mpage;


   if (!sizeof($mpage->Friend[1]))
   { ?>

<p class="title1">Sorry</p>

<P>You don't have any friends within your network, so performing a search
for people on this page serves no purpose.

<P><?= $mpage->sys[sitename] ?> only allows you to search / interface for people within your friend
network (meaning your friends, their friends, their friends, etc).  

<P>If you're looking for a specific person outside of your friend network, go to
the <a href="usersearch.php">User Search</a> page.

<P>Otherwise, <a href="invite.php">Invite</a> some of your friends to join the party.


   <? return; }

   extract($_POST);
   $qupush = array();


   if ($submit)
   {
       $numperpage = 50;
       $page = ($page >=1) ? floor($page) : 1;

       $limit = "limit " . (($page-1) * $numperpage) . ", $numperpage";

       $sql = "select SQL_CALC_FOUND_ROWS * from UserTable where ";

       if ($onlyphotos)
          array_push($qupush, "(PicDefault != 0)");

       if ( in_array($gender, array(1,2)) )
          array_push($qupush, "(Gender = $gender)");

       if ($age1 > 10 && $age1 < 100)
          array_push($qupush, "(Age >= ".floor($age1).")");

       if ($age2 > 10 && $age2 < 100)
          array_push($qupush, "(Age <= ".floor($age2).")");

       $dst = (sizeof($dst)) ? $dst : array(0,1,2,3,4,5);
       array_push($qupush, "(Datestatus IN (".join(",",$dst)."))");



       if (($intr1 || $intr3) && ($intr2 || $intr4))
       {
            $dtrr = array();
            $dtrs = array();

            if ($intr1) array_push($dtrs, "(Dating=1)");
            if ($intr3) array_push($dtrs, "(Relatn=1)");

            if ($intr2) array_push($dtrr, 1);
            if ($intr4) array_push($dtrr, 2);
            array_push($dtrr, 3); 

            array_push($qupush, "(".join("||", $dtrs).")");
            array_push($qupush, "DrGender IN (".join(",",$dtrr).")");
       }


       if (($intr5 || $intr6) && ($intr7 || $intr8))
       {
            $dtrr = array();
            $dtrs = array();
            
            if ($intr5) array_push($dtrs, "(Friends=1)");
            if ($intr7) array_push($dtrs, "(Netbud=1)");
            
            if ($intr6) array_push($dtrr, 1);
            if ($intr8) array_push($dtrr, 2);
            array_push($dtrr, 3);            
        
            array_push($qupush, "(".join("||", $dtrs).")");
            array_push($qupush, "FnGender IN (".join(",",$dtrr).")");
       }




       $sql .= join(" AND ", $qupush);

       if (sizeof($qupush)) $sql .= " AND ";


       $frr = array();

       for ($x = $mindegsep; $x <= $maxdegsep; $x++)
          $frr = array_merge($frr, $mpage->Friend[$x]);

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


       $sql .= "Id IN (".join(",",$frr).") order by Id desc $limit";

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

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

       $numpages = ceil($fnd / $numperpage);
   }
   else
   {
       $r = array();
   }

?>


<table border=0 width=500 cellspacing=0 cellpadding=3px>

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

<tr><td>No Users Found</td></tr>

<? } elseif (sizeof($r)) { ?>

<tr><td colspan=2 align=center>

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

<table width=100% cellspacing=0 cellpadding=0 border=0>
<form method=post>
<tr><td><B>Showing 


<?= $tv ?>-<?= $tv + min(sizeof($r), $numperpage) - 1 ?> 
of <?= $fnd ?> people found</b></td>
    <td align=right>

<select name="page">
<? for ($x = 1; $x <= $numpages; $x++) { ?>
  <option value="<?= $x ?>" <?= ($page == $x) ? "selected" : "" ?>>Page <?= $x ?>
<? } ?>
</select>
<input name="submit" type="submit" class="submit" value="Go">

</td></tr>
<? foreach ($_POST as $k => $v) { ?>

   <? if (is_array($_POST[$k])) {
      foreach ($v as $vv) { ?>
          <input name="<?= $k ?>[]" type=hidden value="<?= htmlentities($vv) ?>">
      <? }
      } else { ?>
     <input name="<?= $k ?>" type=hidden value="<?= htmlentities($v) ?>">
   <? } ?>
<? } ?>
</form>
</table>


</td></tr>

<? } ?>



<? if (!$disp) { 

   echo "<tr><td><table cellspacing=0 cellpadding=0>";

   for ($x = 0; $x < sizeof($r); $x++)
   {
       if ($x % 5 == 0) echo "\n<tr>\n";
       ?>  
          <td width=90 align=center class="stdaltfilling"><BR>
              <a href="user.php?id=<?= $r[$x][Id] ?>">
              <img border=0 width=80 height=60 src="userpics/<?= $mpage->PicPr($r[$x][PicDefault], $r[$x][Id]) ?>-b.jpg"></a>
              <BR>
                  <small><a href="user.php?id=<?= $r[$x][Id] ?>"><?= $r[$x][Fname] ?>
                  <?= substr($r[$x][Lname], 0, 1) ?></a></small>
          </td>
       <?
       if ($x % 5 == 4) echo "\n</tr>\n";
   }

   for ($x; $x % 5 != 0; $x++)
   {
      echo "<td width=90 class=\"stdaltfilling\">&nbsp;</td>";
      if ($x % 5 == 4) echo "\n</tr>\n";
   }


   echo "</table></td></tr></table>";
   return; 

} 
?>







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

<?

}



?>
Return current item: Slashster