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

    if (($_SERVER[SERVER_PORT] != 443) && $mpage->sys[securenbl])
    {
        $url = $mpage->sys[secureurl];
        $url .= $_SERVER[SCRIPT_NAME];
        $url .= "?" . $_SERVER[QUERY_STRING] . "&" . sid;

        header("Location: $url");
        exit;
    }




    $msg = "";
    $errmsg = "";
    $cssid = array();

    $sql = "select * from CSS order by Name ASC";
    $css = $mpage->DoQuery($sql,1);
    
    foreach ($css as $csss) array_push($cssid, $csss[Id]);
    $cssopt = (in_array($cssopt, $cssid)) ? $cssopt : 1;



    if ($submit)
    {
         $email = strtolower($email);
         $fname = trim(strip_tags($fname));
         $lname = trim(strip_tags($lname));

         if (!preg_match ("/^[\w\.\-]+\@[\w\.\-]+\.[a-z]{2,4}$/i", $email))
         {
             $errmsg = "Invalid email";
         }

         if (!$errmsg && !strlen($fname))
         {
             $errmsg = "No first name given.";
         }

         if (!$errmsg && !strlen($lname))
         {
             $errmsg = "No last name given.";
         }

         if (!$errmsg && ($email != $mpage->user[Email]))
         {
             $pwd = md5($passwd . $mpage->user[Salt]);

             if ($pwd != $mpage->user[Pass])
             {
                $errmsg = "Bad password";
             }
         }


    }

    if ($errmsg)
    {
        $msg = "Error: " . $errmsg 
             . "<BR><small style=\"color:black;\">Your stats haven't been updated</small>";
    }

    if ($submit && !$errmsg)
    {
          $sql = "select Id from RSS order by Id asc"; 
          $RSSS = $mpage->DoQuery($sql);
          foreach ($RSSS as $GGGG => $SSSS) $RSSS[$GGGG] = $SSSS[0];

          $rs = array();

          for ($x = 1; $x <= 5; $x++)
          {
              $r1 = $_POST["rss".$x];
              $r2 = $_POST["rssc".$x];

              if (in_array($r1, $RSSS) || $r1 == "0")
              {
                 $r2 = ($r2 >= 1 && $r2 <= 10) ? floor($r2) : 5;

                 array_push($rs, "$r1|$r2");
              }
          }

          $MailOften = ( in_array( $MailOften, array(1,2)) ) ? $MailOften : 1;

          $sql = "update UserTable set Fname = \"$fname\", Lname=\"$lname\",
                  RSS = \"".join(",", $rs)."\", CSS=\"$cssopt\", SessionAES = \"$SessionAES\",
                  MailOften = \"$MailOften\"
                  where Id = $mpage->IdNum";
          $mpage->DoQuery($sql);
 
          $mpage->CSS = $cssopt;

          $msg = "Your stats have been updated";
          
          if ($email != $mpage->user[Email])
          {
              $sql = "update UserTable set Verified = 0, Email=\"$email\"
                  where Id = $mpage->IdNum";
              $mpage->DoQuery($sql);

              $msg .= "<BR><small style=\"color:black;\">You will have to reverify your 
                       email.</small>";
          }

          $mpage->Initialize("authonly");
    }

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

   
    $sql = "select * from RSS order by Id asc";
    $rss = $mpage->DoQuery($sql,1);

    $mpage->Initialize("authremainder");

?>

<P>
<span class="title1">Account Setup</span>

<? if ($msg) { ?>

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

<? } ?>

<P>
<P>&nbsp;<small>[<a href="<?= $mpage->stdurl ?>usersetup.php">Edit Profile</a>]</small>    

&nbsp;<small>[<a href="changepassword.php">Change Password</a>]</small>

<script>

function validate(v)
{
   if (v.email.value.length == 0)
   {
       alert("Please enter an email address, or press RESET to keep it the same")
       return false
   }

   if (v.fname.value.length == 0)
   {
       alert("Please enter a first name")
       return false
   }

   if (v.lname.value.length == 0)
   {
       alert("Please enter a last name")
       return false
   }

   if ((v.passwd.value.length == 0) && (v.emailchk.value != v.email.value))
   {
       alert("Please enter an password if you're going to change your email")
       return false
   }

   return true

}


</script>



<form name=frm onsubmit="return validate(this)" method=post>
<table cellpadding=0 cellspacing=0 width=600>
<tr>
<td class="stdtable" width=150><B>Email Address:</b></td>
<td class="stdfilling" width=450>
<input name="email" value="<?= ($email) ? $email : $r[Email] ?>" style="width:250px">
<input name="emailchk" value="<?= $mpage->user[Email] ?>" type="hidden">
</td>
</tr>

<tr>      
<td class="stdtable" width=150><B>First Name:</b></td>
<td class="stdfilling" width=450>
<input name="fname" value="<?= ($fname) ? $fname : $r[Fname] ?>" style="width:250px">
</td>
</tr>

<tr>
<td class="stdtable" width=150><B>Last Name:</b></td>   
<td class="stdfilling" width=450>
<input name="lname" value="<?= ($lname) ? $lname : $r[Lname] ?>" style="width:250px">
</td>
</tr>

<tr> 
<td class="stdtable" width=150><B>Password:</b></td>
<td class="stdfilling" width=450>
<input name="passwd" type="password" style="width:250px">
<BR>&nbsp;<small>Required to change information on this page.</small>
</td>
</tr>


<tr>
<td class="stdtable" width=150><B>Color / Theme:</b></td>
<td class="stdfilling" width=450>
<BR>&nbsp;&nbsp;<select name="cssopt">
  <? foreach ($css as $c) { ?>
    <option value="<?= $c[Id] ?>" <?= ($c[Id] == $mpage->CSS) ? "selected" : "" ?>><?= $c[Name] ?>
  <? } ?>
</select><BR><BR>
</td>
</tr>

MailOften


<tr>
<td class="stdtable" width=150><B>Notify Me Of New Messages:</b></td>
<td class="stdfilling" width=450>
<BR>&nbsp;&nbsp;<select name="MailOften">
    <option value="1" <?= ($mpage->user[MailOften] == 1) ? "selected" : "" ?>>Every Message</option>
    <option value="2" <?= ($mpage->user[MailOften] == 2) ? "selected" : "" ?>>Daily</option>
</select><BR><BR>
</td>
</tr>



<tr>
<td class="stdtable" width=150><b>RSS Feeds:</b></td> 
<td class="stdfilling" width=450><BR>

<?
   $exp = explode(",", $mpage->user[RSS]);

?>


<? for($x = 0; $x < 5; $x++) { 

   $ex = $exp[$x];
   $e  = explode("|",$ex);

?>

RSS Feed #<?= $x+1 ?>
   <select name="rss<?= $x+1 ?>">
       <option value = "">No Feed</option>
       <option value = "0" <?= ($e[0] == "0") ? "selected" : "" ?>>Random Feed

       <? foreach ($rss as $rsa) { ?>
          <option value = "<?= $rsa[Id] ?>" <?= ($e[0] == $rsa[Id]) ? "selected" : "" ?>><?= $rsa[Name] ?>
       <? } ?>
   </select>

   <select name="rssc<?= $x+1 ?>">
        <? for ($y = 1; $y <= 10; $y++) { ?>
           <option value="<?= $y ?>" <?= ($y == $e[1]) ? "selected" 
            : "" ?>>Show <?= $y ?> Update<?= ($y == 1) ? "" : "s" ?>
        <? } ?>
   </select>

<BR><BR>

<? } ?>


</td>
</tr>


<tr><td class="stdtable"><B>Store AES Key in Session</b></td>
    <td class="stdfilling">

<table width=100%><tr><td width=60>

<select name="SessionAES">
   <option value=0 <?= (!$mpage->user[SessionAES]) ? "selected" : "" ?>>No
   <option value=1 <?= ($mpage->user[SessionAES])  ? "selected" : "" ?>>Yes
</select>

</td><td>

This determines whether or not your AES key will be stored along with your Session.
When checked to yes, you are not required to enter in a password for your encrypted messages.
This is slightly less secure, but convenient when receiving lots of encrypted email.

<P>The default for this is <B>NO</b>.

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


</td></tr>





</table>

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

<input class="submit" type="submit" value="submit" name="submit">
&nbsp;&nbsp;
<input class="submit" type="reset" value="reset">

</div>


</form>





<? $mpage->ClosePage() ?>


Return current item: Slashster