This repository has been archived on 2023-09-19. You can view files and clone it, but cannot push or open issues or pull requests.
AcmlmboardZero/editprofile.php

161 lines
7.7 KiB
PHP

<?php
require("function.php");
require("layout.php");
if(!$loguserid){
print "$header<br>
<table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
";
print "
$tccell1"."You are not logged in!";
print "<br>Click <a href=index.php>here</a> to return to the board.";
print"
</td>
</tr>
</table>
$footer";
die();
}
$user=mysqli_fetch_array(mysqli_query($con,"SELECT * FROM users WHERE id=$loguserid"));
print $header;
if ($_POST[action]=="") {
print "<br>
<table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
<FORM ACTION=\"editprofile.php\" NAME=\"REPLIER\" METHOD=\"POST\">";
$check1="";
$check2="";
$check3="";
if ($loguserid) {
if($user[sex]==0){ $check1="checked=1"; }
elseif($user[sex]==1){ $check2="checked=1"; }
elseif($user[sex]==2){ $check3="checked=1"; }
$sexlist="<INPUT type=radio NAME=sex value=0 $check1> Male&nbsp;&nbsp;&nbsp;";
$sexlist.="<INPUT type=radio NAME=sex value=1 $check2> Female&nbsp;&nbsp;&nbsp;";
$sexlist.="<INPUT type=radio NAME=sex value=2 $check3> N/A&nbsp;&nbsp;&nbsp;";
$replytable="$tccellha$tccellhb"."&nbsp;</font></td>";
$replytable.="$tccellh"."&nbsp;</td>$tccellh"."&nbsp;</td><tr>";
$replytable.="$tccell1"."<b>User name:</td>";
$replytable.="$tccell2"."</center>".$user[name]."</td><tr>";
$replytable.="$tccell1"."<b>Password:</b>$smallfont<br></center>&nbsp;You can change your password by entering a new one here.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=PASSWORD autocomplete=new-password NAME=\"password\" SIZE=13 MAXLENGTH=13 ></td><tr>";
$replytable.="$tccell1"."<b>Sex:</b>$smallfont<br></center>&nbsp;Male or female ... (or N/A if you don't want to tell it)</td>";
$replytable.="$tccell2"."</center>$sexlist</td><tr>";
$replytable.="$tccell1"."<b>User picture:</b>$smallfont<br></center>&nbsp;The full URL of the image showing up below your username in posts. Leave it blank if you don't want to use a picture. The picture is resized to 60 in width.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"picture\" VALUE=\"".$user[picture]."\" SIZE=60 MAXLENGTH=100></td><tr>";
$replytable.="$tccell1"."<b>Email address:</b>$smallfont<br></center>&nbsp;This is only shown in your profile; you don't have to enter it if you don't want to.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"email\" VALUE=\"".$user[email]."\" SIZE=60 MAXLENGTH=60></td><tr>";
$replytable.="$tccell1"."<b>Homepage URL:</b>$smallfont<br></center>&nbsp;Your homepage URL, if you have one.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"homepage\" VALUE=\"".$user[homepageurl]."\" SIZE=60 MAXLENGTH=80></td><tr>";
$replytable.="$tccell1"."<b>Homepage Name:</b>$smallfont<br></center>&nbsp;Your homepage name, if you have one.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"homepagename\" VALUE=\"".$user[homepagename]."\" SIZE=60 MAXLENGTH=80></td><tr>";
$replytable.="$tccell1"."<b>ICQ number:</b>$smallfont<br></center>&nbsp;Your ICQ number, if you have one.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=NUMBER NAME=\"icq\" VALUE=\"".$user[icq]."\" SIZE=10 MAXLENGTH=10></td><tr>";
$replytable.="$tccell1"."<b>Post Header:</b>$smallfont<br></center>&nbsp;This will get added at the beginning of each post you make.</td>";
$replytable.="$tccell2"."</center><TEXTAREA NAME=\"postheader\" ROWS=5 COLS=60 WRAP=VIRTUAL>".str_replace("<br>","
",$user[postheader])."</TEXTAREA></td><tr>";
$replytable.="$tccell1"."<b>Signature:</b>$smallfont<br></center>&nbsp;This will get added at the end of each post you make. This should preferably kept to a small enough size.</td>";
$replytable.="$tccell2"."</center><TEXTAREA NAME=\"signature\" ROWS=5 COLS=60 WRAP=VIRTUAL>".str_replace("<br>","
",$user[signature])."</TEXTAREA></td><tr>";
$replytable.="$tccell1"."<b>Bio:</b>$smallfont<br></center>&nbsp;Some information about yourself, showing up in your profile.</td>";
$replytable.="$tccell2"."</center><TEXTAREA NAME=\"bio\" ROWS=5 COLS=60 WRAP=VIRTUAL>".str_replace("<br>","
",$user[bio])."</TEXTAREA></td><tr>";
$replytable.="$tccell1"."<b>Timezone offset:</b>$smallfont<br></center>&nbsp;How many hours you're offset from the time on the board (".date("m-d-y h:i A",time()).").</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=TEXT NAME=\"timezone\" VALUE=\"".$user[timezone]."\" SIZE=5 MAXLENGTH=5></td><tr>";
$replytable.="$tccell1"."<b>Posts per page:</b>$smallfont<br></center>&nbsp;The maximum number of posts you want to be shown in a page in threads.</td>";
$replytable.="$tccell2"."</center><INPUT TYPE=NUMBER NAME=\"postsperpage\" VALUE=\"".$user[postsperpage]."\" SIZE=5 MAXLENGTH=5></td><tr>";
$replytable.="$tccell1"."<b>Scheme:</b>$smallfont<br></center>&nbsp;The scheme you want to use.</td>";
$replytable.="$tccell2"."</center><select name=scheme>";
$schemes=mysqli_query($con,"SELECT * FROM schemes");
while($scheme=mysqli_fetch_array($schemes)) {
if ($scheme[id]==$user[scheme]) {
$selected="selected";
} else {
$selected="";
}
print "$selectedscheme[id]";
$replytable.="<option value=\"$scheme[id]\" $selected>$scheme[name]</option>";
}
$replytable.="</select></td><tr>";
$replytable.="$tccell1"."</td>";
$replytable.="$tccell2"."</center>
<INPUT TYPE=HIDDEN NAME=\"action\" VALUE=\"saveprofile\">
<INPUT TYPE=HIDDEN NAME=\"userid\" VALUE=\"$userid\">
<INPUT TYPE=Submit NAME=\"submit\" VALUE=\"Edit profile\"></td></table></td></table></FORM>";
} else {
$replytable.="$tccell1"."Couldn't go to edit your profile. Either you didn't enter an ".
"existing username, or you haven't entered the right password for the username.".
"<br>Click <a href=index.php>here</a> to return to the board.";
}
print "$replytable";
}
if ($_POST[action]=="saveprofile") {
print "<br>
<table border=0 bgcolor=$tableborder width=$tablewidth align=center cellpadding=0 cellspacing=0>
<td>
<table border=0 cellpadding=2 cellspacing=1 width=100% bgcolor=$tableborder>
";
$signature=str_replace("
","<br>",$_POST[signature]);
$bio=str_replace("
","<br>",$_POST[bio]);
$postheader=str_replace("
","<br>",$_POST[postheader]);
if (!$_POST[password]) $password=$user[password];
else {
$password=password_hash("$_POST[password]", PASSWORD_BCRYPT);
$pass = password_hash($password . $_SERVER[REMOTE_ADDR],PASSWORD_BCRYPT);
setcookie('logpassword',$pass);
}
$sql = "UPDATE users SET password = ?, sex = ?, picture = ?, timezone = ?, postsperpage = ?, email = ?, icq = ?, signature = ?, bio = ?, homepageurl = ?, homepagename = ?, postheader = ?, scheme = ? WHERE id = $loguserid";
if($stmt = mysqli_prepare($con, $sql)){
mysqli_stmt_bind_param($stmt,"sssssssssssss", $password, $_POST[sex], $_POST[picture], $_POST[timezone], $_POST[postsperpage], $_POST[email], $_POST[icq], $signature, $bio, $_POST[homepage], $_POST[homepagename], $postheader, $_POST[scheme]) or mysqli_error($con);
mysqli_stmt_execute($stmt) or mysqli_error($con);
print "$tccell1"."Thank you, ".$user[name].", for editing your profile.".
"<br>Click <a href=index.php>here</a> to return to the board.</td></table>";
}
else {
print "$tccell1"."Failed!";
print "<br>Click <a href=index.php>here</a> to return to the board.";
}
print "
</td>
</table>
";
}
print $footer;
?>