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

    $msg = "";
    $errmsg = "";




    foreach ($_POST as $k=>$v) $_POST[$k] = trim($v);
    extract($_POST);

    if ($submit)
    {
         $repeat = 0;


         if (!$repeat && !in_array($gender, array(1,2)))
         {
              $repeat = 1;
              $errmsg = "Please tell us if you're male or female.";
         }

         if (!$dating && !$relatn)
         {
             $drgender=0;
         }

         if (!$repeat && !in_array($drgender, array(1,2,3)) && ($dating || $relatn)  )
         {
              $repeat = 1;
              $errmsg = "Please enter your dating / relationship gender interest";
         }

         if (!$friends && !$netbud)
         {
             $fngender=0;
         }

         if (!$repeat && !in_array($fngender, array(1,2,3)) && ($friends || $netbud))
         {
              $repeat = 1;
              $errmsg = "Please enter your friend / netbuddy gender interest";
         }

         if (!$repeat && !in_array($month, array(1,2,3,4,5,6,7,8,9,10,11,12)))
         {
              $repeat = 1;
              $errmsg = "What month were you born?";    
         }

         $day = floor($day);

         if (!$repeat && ( ($day < 1) || ($day > 31) ) )   
         {
              $repeat = 1;
              $errmsg = "What day were you born?";                          
         }

         if (!$repeat && ( ($year < date("Y")-100) || ($day > date("Y")-12) ) )
         {
              $repeat = 1;
              $errmsg = "What year were you born (Ages 13-100 allowed)?";
         }

         if (!$repeat)
         {
              $mkt = mktime(1,1,1, $month, 1, $year);
              $dim = date("t",$mkt);
              
              if ($day > $dim)
              {
                 $repeat = 1;
                 $errmsg = "There were only $dim days in the month of $month / $year";
              }
         }

         if (!$repeat && !in_array($meetme, array(1,2,3,4)))
         {
              $repeat = 1;
              $errmsg = "Please enter your plans on meeting / calling / chatting people on this site";
         }


    }










    if (!$errmsg && $submit)
    {
          $datestatus = (in_array($datestatus, array(1,2,3,4,5))) ? $datestatus : 0;


          $sql = "update UserTable set
                         Gender = \"$gender\",
                         Birthday = \"". sprintf("%04d-%02d-%02d", $year,$month,$day)."\",
                         Dating  = \"$dating\",  
                         Relatn  = \"$relatn\",
                         Friends = \"$friends\",
                         Netbud  = \"$netbud\",
                         DrGender = \"$drgender\",
                         FnGender = \"$fngender\",
                         MeetMe   = \"$meetme\",
                         Datestatus = \"$datestatus\",
                         Country    = \"$country\",
                         Zipcode    = \"$zipcode\",
                         Job        = \"$job\",
                         Interests  = \"$interests\",
                         BBSSig     = \"$bbssig\"
                  where Id = $mpage->IdNum";
          $mpage->DoQuery($sql);

          $sql = "update UserTable set Age = (YEAR(CURDATE())-YEAR(Birthday)) - (RIGHT(CURDATE(),5)<RIGHT(BirthDay,5))
                    where Id = $mpage->IdNum";
          $mpage->DoQuery($sql);


          if ($mpage->user[Verified])
          {
              $errmsg = "Your stats have been updated";
          }
          else
          { 
              header("Location: invite.php?" . sid);
              exit;
          }

    }


    $mpage->Initialize("authremainder");


    $sql = "select *, UNIX_TIMESTAMP(Birthday) as UT 
            from UserTable where Id = $mpage->IdNum";
    $r = $mpage->DoQuery($sql,1);
    $r = $r[0];

?>

<P>
<span class="title1">Your User Setup</span>

<? if ($errmsg) { ?>

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

<? } ?>

<P>&nbsp;<small>[<a href="editaccount.php">Account Settings</a>]</small>


<form method=post>



<?



$gender = ($_POST[gender]) ? $gender : $r[Gender];


$dating   = ($_POST[dating])   ? $dating   : $r[Dating];
$relatn   = ($_POST[relatn])   ? $relatn   : $r[Relatn];
$drgender = ($_POST[drgender]) ? $drgender : $r[DrGender];

$friends  = ($_POST[friends])  ? $friends  : $r[Friends];
$netbud   = ($_POST[netbud])   ? $netbud   : $r[Netbud];
$fngender = ($_POST[fngender]) ? $fngender : $r[FnGender];



?>

<table cellpadding=0 cellspacing=0 width=600 border=1>

<tr>
<td class="stdtable" width=150><b>Gender</b></td>
<td class="stdfilling" width=150>

<input name=gender type=radio value=1 <?= ($gender == "1") ? "checked" : "" ?>>Male
<BR>
<input name=gender type=radio value=2 <?= ($gender == "2") ? "checked" : "" ?>>Female

</td>
</tr>

<tr><td class="stdtable" rowspan=2>
  <B>I want to meet people for:</b>
</td><td class="stdfilling">

    <table width=300 cellspacing=0>
    <tr><td width=120>
        <input name="dating" type="checkbox" value="1" <?= ($dating == "1") ? "checked" : "" ?>>Dating
    <BR><input name="relatn" type="checkbox" value="1" <?= ($relatn == "1") ? "checked" : "" ?>>Relationship

    </td><td width=180>
    <input name="drgender" type="radio" value="1" <?= ($drgender == "1") ? "checked" : "" ?>>Men
    <input name="drgender" type="radio" value="2" <?= ($drgender == "2") ? "checked" : "" ?>>Women
    <BR>
    <input name="drgender" type="radio" value="3" <?= ($drgender == "3") ? "checked" : "" ?>>Men & Women

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

</td></tr>
<tr><td class="stdfilling">

    <table width=300 cellspacing=0>
    <tr><td width=120>
        <input name="friends" type="checkbox" value="1" <?= ($friends == "1") ? "checked" : "" ?>>Friends
    <BR><input name="netbud"  type="checkbox" value="1" <?= ($netbud  == "1") ? "checked" : "" ?>>Net Buddy

    </td><td width=180>
    <input name="fngender" type="radio" value="1" <?= ($fngender == "1") ? "checked" : "" ?>>Men
    <input name="fngender" type="radio" value="2" <?= ($fngender == "2") ? "checked" : "" ?>>Women
    <BR>
    <input name="fngender" type="radio" value="3" <?= ($fngender == "3") ? "checked" : "" ?>>Men & Women

    </td>
    </tr>

    </table>


</td></tr>

<?
   $bdd = explode("-",$r[Birthday]);

   $month = ($month) ? $month : $bdd[1];
   $day   = ($day)   ? $day   : $bdd[2];
   $year  = ($year)  ? $year  : $bdd[0];

?>

<tr><td class="stdtable">

<B>My Birthday:</b>

</td><td class="stdfilling">
<BR>
&nbsp;&nbsp;<select name="month">
  <option value="">-----------
  <?
      for ($x = 1; $x <= 12; $x++) { 
         $dt = mktime(1,1,1, $x, 1, 2000);
         ?>
             <option value="<?= $x ?>" <?= ($month == $x) ? "selected" : "" ?>> 
               (<?= sprintf("%02d", $x) ?>) <?= date("M", $dt) ?> 
         <?
      }
  ?>
</select>
<select name="day">
  <option value="">--
  <? for ($x = 1; $x <= 31; $x++) { ?>
     <option value="<?= sprintf("%02d", $x) ?>" <?= ($day == $x) ? "selected" : "" ?> > <?= sprintf("%02d", $x) ?>        
  <? } ?>
</select>
<select name="year">
  <option value="">----
  <? for ($x = date("Y") - 12; $x >= date("Y") - 100; $x--) { ?>
     <option value="<?= $x ?>" <?= ($year == $x) ? "selected" : "" ?>> <?= $x ?>
  <? } ?>  
</select>
<BR><BR>
</td></tr>


<tr><td class="stdtable">

<B>The people I talk to on here I may: </b>
</td><td class="stdfilling">

<BR>&nbsp;&nbsp;<select name="meetme">
  <option value="">--Choose one--
  <option value="1" <?= ($r[MeetMe] == 1) ? "selected" : "" ?>>Chat online only
  <option value="2" <?= ($r[MeetMe] == 2) ? "selected" : "" ?>>Call on the phone
  <option value="3" <?= ($r[MeetMe] == 3) ? "selected" : "" ?>>Meet if they're in the area.
  <option value="4" <?= ($r[MeetMe] == 4) ? "selected" : "" ?>>Might travel and meet up.

</select>
<BR><BR>

</td></tr>

<tr><td colspan=2 class="stdaltfilling" align=center><span class="title1">Optional Information</span></td></tr>


<tr>
<td class="stdaltfilling" width=150><B>Dating Status:</b></td>
<td class="stdfilling" width=450>
         <input name="datestatus" type="radio" value="0" <?=
      (!$r[Datestatus]) ? "checked" : "" ?>>Unspecified
     <BR><input name="datestatus" type="radio" value="1" <?=
      ($r[Datestatus] == 1) ? "checked" : "" ?>>Single
     <BR><input name="datestatus" type="radio" value="2" <?= 
      ($r[Datestatus] == 2) ? "checked" : "" ?>>Light Dating         
     <BR><input name="datestatus" type="radio" value="3" <?= 
      ($r[Datestatus] == 3) ? "checked" : "" ?>>Relationship    
     <BR><input name="datestatus" type="radio" value="4" <?= 
      ($r[Datestatus] == 4) ? "checked" : "" ?>>Engaged
     <BR><input name="datestatus" type="radio" value="5" <?=
      ($r[Datestatus] == 5) ? "checked" : "" ?>>Married
</td>
</tr>


<tr>
<td class="stdaltfilling" width=150><B>Country:</b></td>
<td class="stdfilling" width=450>
         &nbsp;<input name="country" value="<?= htmlentities($r[Country]) ?>">
</td>
</tr>

<tr>
<td class="stdaltfilling" width=150><B>Zip / Postal Code:</b></td>      
<td class="stdfilling" width=450>
         &nbsp;<input name="zipcode" value="<?= htmlentities($r[Zipcode]) ?>">                
</td>
</tr>

<tr>
<td class="stdaltfilling" width=150><b>Job:</b></td>
<td class="stdfilling" width=450>
         &nbsp;<input name="job" value="<?= htmlentities($r[Job]) ?>">
</td>
</tr>

<tr>
<td class="stdaltfilling" width=150><B>Interests:</b></td>
<td class="stdfilling" width=450>
<small>(Separate these entries by commas, Beavis)</small><BR>
         &nbsp;<input name="interests" value="<?= htmlentities($r[Interests]) ?>">
</td>
</tr>

<tr>
<td class="stdaltfilling" width=150><B>BBS Signature:</b><BR>
<small>(255 chars max, no html)</small>
</td>
<td class="stdfilling" width=450>
&nbsp;<textarea name="bbssig" rows=4 cols=50>
<?= htmlentities($r[BBSSig]) ?>
</textarea>
</td>
</tr>


</table>

<BR>
<div style="width:600px" align=center>

<input class="submit" type="submit" value="submit" name="submit">

</div>


</form>

<form method=get action="main.php">
<div style="width:600px" align=center>
<input class="submit" type="submit" value="Cancel" >
</div>
</form>




<? $mpage->ClosePage() ?>

<?

Return current item: Slashster