<?php
$file = __FILE__;
include ("inc/inc_common.php");
include ("inc/inc_connect.php");
include ("inc/inc_admincheck.php");
include ("inc/inc_getdate.php");
include ("inc/inc_forumname.php");
$page = "Editing Profile";
$pagelink = $file;
include("inc/inc_setonline.php");
$title = "Edit Profile";
if ($action == "update")
{
    if ($showemail == "ON")
    {
        $showemail == "";
    }
    else
    {
        $showemail == "ON";
    }

    if ($avatarb != "")
    {
        $avatar = $avatarb;
    }

    if ($Keynav == 1)
    {
        $keyboardnavigation = 1;
    }

    if ($Keynav == 0)
    {
        $keyboardnavigation = 0;
    }

    $query = "UPDATE $userstable SET strforename = '$forename', strSurname = '$surname', strEmail = '$email',   strAvatar = '$avatar', strPhoto = '$photo', strHomepage = '$homepage', ynShowOnline = '$online', ynShowEmail = '$emailon', strIcqNumber = '$icq', strMsnName = '$msn', strYahooId = '$yahoo', memBiography = '$biog', strLocation = '$location', memSig = '$signature', strOccupation = '$occupation', intBirthDay = '$birthday', intBirthMonth = '$birthmonth', intKeyNav = '$Keynav', intShowTime = '$ShowTime', strProfile1Answer = '$profile1', strProfile2Answer = '$profile2', strProfile3Answer = '$profile3', strProfile4Answer = '$profile4', strHardware = '$hardware', strConnection = '$connection' WHERE strName='$gfcookie[1]'";
    mysql_query( $query, $link )
    or die ( "Could not add data to \"$userstable\" table. Please contact a GrimForum admin and show them this error:".mysql_error() );
}
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<hmtl>
<head>
<meta name=\"AUTHOR\" content=\"Matt Squirrell\">
<meta name=\"COPYRIGHT\" content=\"(c)2002 HSMX Web Design\">
<meta name=\"CONTACT\" content=\"grimforum@hsmx.com\">
<title>$title</title>
<META name=\"description\" content=\"$metadescription\">
<META name=\"keywords\" content=\"GrimForum, HSMX, Web Design, $metakeywords\">";
if ($keyboardnavigation == 1)
{
    print "<SCRIPT LANGUAGE=\"JavaScript\">

    <!-- Begin
    var key = new Array();  // Define key launcher pages here
    key['f'] = \"forums.php\";
    key['b'] = \"buddymenu.php\";
    key['a'] = \"active_topics.php\";
    key['i'] = \"inbox.php\";
    key['m'] = \"members.php\";

    function getKey(keyStroke) {
    isNetscape=(document.layers);
    eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
    which = String.fromCharCode(eventChooser).toLowerCase();
    for (var i in key) if (which == i) window.location = key[i];
    }
    document.onkeypress = getKey;
    //  End -->
    </script>";
}

$result=mysql_query("SELECT * FROM $admintable");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $keyboardnavigation = $a_row->strKeyboardNavigation;
}

print "</head>";

include ("inc/inc_body.php");
$title = "Edit Profile";
include ("inc/inc_title.php");

print "</centeR><table border=0 width=\"100%\" cellpadding=1 cellspacing=0><tr><td  width=\"20%\">
<table border=0 cellpadding=1 cellspacing=0><tr><td>
<font face=\"$font\" size=$fontsize><image src=\"images/folder_icon.gif\">&nbsp;<a href=\"index.php\">$name1&nbsp;Home</a>
</td></tr>
<tr><td><image src=\"images/folder_line.gif\">
<font face=\"$font\" size=$fontsize><image src=\"images/open_folder_icon.gif\">&nbsp;Edit Profile</td></tr>
</table>
</td><td><center>";

include ("inc/inc_navigation.php");
include ("inc/inc_newmailsdisplay.php");

//end of include files...

$result=mysql_query("SELECT * FROM $userstable WHERE strName = '$gfcookie[1]'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    if ($a_row->intKeyNav == 1)
    {
        $chkeynav = "checked";
    }
    if ($a_row->ynShowOnline == "ON")
    {
        $chshowonline = "checked";
    }
    if ($a_row->ynShowEmail == "ON")
    {
        $chshowemail = "checked";
    }
    if ($a_row->intShowTime == 1)
    {
        $chshowtime = "checked";
    }

    $posts = $a_row->intPosts;

    $avatar = $a_row->strAvatar;
    $email = $a_row->strEmail;
    $forename = $a_row->strForename;
    $surname = $a_row->strSurname;
    $signature = $a_row->memSig;
    $www = $a_row->strHomepage;
    $location = $a_row->strLocation;
    $occupation = $a_row->strOccupation;
    $icq = $a_row->strIcqNumber;
    $msn = $a_row->strMsnName;
    $yahoo = $a_row->strYahooId;
    $connection = $a_row->strConnection;
    $hardware = $a_row->strHardware;
    $photo = $a_row->strPhoto;
    $birthday = $a_row->intBirthDay;
    $birthmonth = $a_row->intBirthMonth;

    $profile1 = $a_row->strProfile1;
    $profile1an = $a_row->strProfile1Answer;
    $profile2 = $a_row->strProfile2;
    $profile2an = $a_row->strProfile2Answer;
    $profile3 = $a_row->strProfile3;
    $profile3an = $a_row->strProfile3Answer;
    $profile4 = $a_row->strProfile4;
    $profile4an = $a_row->strProfile4Answer;

}

print "</td></tr></table><br>
<center><font face=\"$font\" size=$fontsize><a href=\"javascript:history.back( )\">Click here</a> to go back without making any changes.<bR>
<a href=\"forumsub.php\">Click here</a> to change which forums you wish to view.<br>";
if ($postsforavatar > $posts)
{
    $left = $postsforavatar - $posts;
    print "You must make at least $postsforavatar posts before you can use a custom avatar! $left to go!";
    $setav = 0;
}
else
{
    $setav = 1;
}

print "<br><br><form method=\"post\" action=\"editprofile.php?action=update\">


<table border=0 width=\"100%\" cellpadding=0 cellspacing=0><tr><td align=\"center\" valign=\"top\" width=\"35%\">

<table border=1 bordercolor=\"$bordercolor\" width=\"80%\" cellpadding=5 cellspacing=0 bgcolor=\"$fgcolour\"><tr><td align=\"center\"><font size=\"$fontsizeb\" color=\"$fontcolor\" face=\"$font\"><br>
<b>Forum Options</b><bR><br>
<table border=0 width=\"100%\" cellpadding=0 cellspacing=0 style=\"font-family: $font; font-size: $fontpoint; color: $fontcolor\">";


$result=mysql_query("SELECT * FROM $admintable");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    if ($a_row->strKeyboardNavigation == 1)
    {
        print "<tr>
        <td align=\"center\">Use Keyboard Navigation</td>
        <td><input type=\"checkbox\" $chkeynav name=\"Keynav\" value=\"1\"></td>
        </tr>";
    }
}


print "<tr>
<td align=\"center\">Don't Let People Email Me</td>
<td><input type=\"checkbox\" $chshowemail name=\"emailon\" value=\"ON\"></td>
</tr>
<tr>
<td align=\"center\">Show When I Am Online</td>
<td><input type=\"checkbox\" $chshowonline name=\"online\" value=\"ON\"></td>
</tr>
</table></td></tr></table>";

if ($setav == 1)
{
    print "<br><br><br><table border=1 bordercolor=\"$bordercolor\" width=\"80%\" cellpadding=5 cellspacing=0 bgcolor=\"$fgcolour\"><tr><td align=\"center\"><font size=\"$fontsizeb\" color=\"$fontcolor\" face=\"$font\"><br>
    <b>Avatar Options</b><font size=\"$fontsize\"><bR><br>
    Choose Avatar ($avatar)";

    ?>

    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="100%">
    <select
    name="avatar" size="1">
    <option value="<?php print "$avatar"; ?>">No Change</option>
    <option value="images/1px_spacer.gif">None</option>
    <?php

    include ("inc/inc_avatars.php");
    ?>


    </select></p>
    </td>
    </tr>
    <tr>
    <td width="100%"><p align="center"><img src="<?php print "$avatar"; ?>" name="avatars"></td>
    </tr>
</table>

    <?
    print "<br>


    Avatar URL<br>
    <input type=\"text\" onfocus=\"document.onkeypress=function(){};\" name=\"avatarb\" size=\"20\" style=\"background-image: url('images/textbox_background.gif')\"><br><br>";


    if ($allowavatarupload == 1)
    {
        print "<a href=\"uploadavatar.php\">Upload my avatar</a><br><br>";
    }




    print "</td></tr></table>";
}
print "</td><td valign=\"top\" align=\"center\" width=\"65%\">

<table border=1 bordercolor=\"$bordercolor\" width=\"80%\" cellpadding=5 cellspacing=0 bgcolor=\"$fgcolour\"><tr><td align=\"center\"><font size=\"$fontsizeb\" color=\"$fontcolor\" face=\"$font\"><br>
<b>Profile Options</b><bR><br>
<table border=0 width=\"100%\" cellpadding=1 cellspacing=0 style=\"font-family: $font; font-size: $fontpoint; color: $fontcolor\">
<tr>
<td align=\"center\" width=\"50%\">Email Address</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"color: #FFFFFF; background-image: url('images/textbox_background_red.gif')\" name=\"email\" value=\"$email\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Forename</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"forename\" value=\"$forename\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Surname</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"surname\" value=\"$surname\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Signature</td>
<td><textarea onfocus=\"document.onkeypress=function(){};\" rows=3 name=\"signature\" cols=25 style=\"background-image: url('images/textarea_background.gif')\">$signature</textarea></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Homepage</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"homepage\" value=\"$www\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Location</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"location\" value=\"$location\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Occupation</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"occupation\" value=\"$occupation\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">MSN ID</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"msn\" value=\"$msn\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">ICQ Number</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"icq\" value=\"$icq\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Yahoo! ID</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"yahoo\" value=\"$yahoo\"></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Photo URL</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"photo\" value=\"$photo\"></td>
</tr>


";
if ($profile1 != "")
{
    print "<tr>
    <td align=\"center\" width=\"50%\">$profile1</td>
    <td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"profile1\" value=\"$profile1an\"></td>
    </tr>";
}
if ($profile2 != "")
{
    print "<tr>
    <td align=\"center\" width=\"50%\">$profile2</td>
    <td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"profile2\" value=\"$profile2an\"></td>
    </tr>";
}
if ($profile3 != "")
{
    print "<tr>
    <td align=\"center\" width=\"50%\">$profile3</td>
    <td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"profile3\" value=\"$profile3an\"></td>
    </tr>";
}
if ($profile4 != "")
{
    print "<tr>
    <td align=\"center\" width=\"50%\">$profile4</td>
    <td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=30 style=\"background-image: url('images/textbox_background.gif')\" name=\"profile4\" value=\"$profile4an\"></td>
    </tr>";
}
print "<tr>
<td align=\"center\" width=\"50%\">Connection</td>
<td><select name=\"connection\">";
if ($connection == "28.8K")
{
    print "<option selected>28.8K</option>";
}
else
{
    print "<option>28.8K</option>";
}
if ($connection == "56K")
{
    print "<option selected>56K</option>";
}
else
{
    print "<option>56K</option>";
}
if ($connection == "ISDN")
{
    print "<option selected>ISDN</option>";
}
else
{
    print "<option>ISDN</option>";
}
if ($connection == "Cable")
{
    print "<option selected>Cable</option>";
}
else
{
    print "<option>Cable</option>";
}
if ($connection == "ADSL")
{
    print "<option selected>ADSL</option>";
}
else
{
    print "<option>ADSL</option>";
}
if ($connection == "T1")
{
    print "<option selected>T1</option>";
}
else
{
    print "<option>T1</option>";
}

if ($birthday == "")
{
    $birthday = "Day (1-31)";
}
if ($birthmonth == "")
{
    $birthmonth = "Month (1-12)";
}

print "</td>
</tr>

<tr>
<td align=\"center\" width=\"50%\">Computer Hardware</td>
<td><textarea onfocus=\"document.onkeypress=function(){};\" rows=3 name=\"hardware\" cols=25 style=\"background-image: url('images/textarea_background.gif')\">$hardware</textarea></td>
</tr>
<tr>
<td align=\"center\" width=\"50%\">Birthday</td>
<td><input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=14 style=\"background-image: url('images/textbox_background.gif')\" name=\"birthday\" value=\"$birthday\">&nbsp;<input type=\"text\" onfocus=\"document.onkeypress=function(){};\" size=14 style=\"background-image: url('images/textbox_background.gif')\" name=\"birthmonth\" value=\"$birthmonth\"></td>
</tr>

</table><bR></td></tr></table><br><br>
";

print "</table><br><br><input type=\"submit\" value=\"&nbsp;Update My Profile!&nbsp;\"></form>";
include ("inc/inc_footer.php");
?>