[go: up one dir, main page]

Menu

[r3]: / data / account.inc.php  Maximize  Restore  History

Download this file

146 lines (132 with data), 6.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/* This file is part of Madcollector.
* Madcollector created by Thomas Andrieu,
* Developped by Mickael Jardet and Thomas Andrieu.
* Madcollector 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.
* Madcollector 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.
*/
require_once LIBS.('classes/user.class.php');
if(($_SESSION['id_user'] == "")||(!isset($_SESSION['id_user'])))
header("Location:index.php");
$idUser = $_SESSION['id_user'];
$header_title = "Your account";
require_once DATA.('header.inc.php');
echo "<div id=\"account_user\"><h1>".$lc_Welcome.", ".$_SESSION['RegUser']."</h1></div>\n";
//Links
echo "<div id=\"user_collection\"><h2><a href=\"index.php?rub=mycollection\">".$lc_Collection."</a> <a href=\"index.php?rub=mycollecpdf\"><img src=\"images/pdf.gif\" alt=\"PDF\"/></a></h2></div>\n";
echo "<div id=\"user_searchlist\"><h2><a href=\"index.php?rub=mysearchlist\">".$lc_Searchlist."</a> <a href=\"index.php?rub=mysearchpdf\"><img src=\"images/pdf.gif\" alt=\"PDF\"/></a></h2></div>\n";
echo "<div id=\"user_selllist\"><h2><a href=\"index.php?rub=myselllist\">".$lc_Selllist."</a> <a href=\"index.php?rub=mysellpdf\"><img src=\"images/pdf.gif\" alt=\"PDF\"/></a></h2></div>\n";
//Form processing
$is_changepass = $_POST['changepass'];
$oldpasswd = $_POST['oldpassword'];
$passwd = $_POST['newpassword'];
$passwordconfirm = $_POST['passwordconfirm'];
if($is_changepass!="")
{
$isOk = true;
if(($oldpasswd=="")||(!isset($oldpasswd)))
{echo "<div id=\"errorpass1\">Please confirm old password.</div>";$isOk=false;}
if(($passwd=="")||($passwd==null))
{echo "<div id=\"errorpass2\">Please enter a new password.</div>";$isOk=false;}
if(($passwordconfirm=="")||(!isset($passwordconfirm)))
{echo "<div id=\"errorpass3\">Please confirm password.</div>";$isOk=false;}
if($passwordconfirm != $passwd)
{echo "<div class=\"errorpass4\">".$lc_ErrMsg_PwDiff.".</div>";$isOk=false;}
if($isOk)
{
$verif= "SELECT * FROM mc_users WHERE id_user='".$_SESSION['id_user']."' and password='".addslashes($oldpasswd)."'" ;
$resultat= $myDB->send_query($verify);
if(!$objLigne=$myDB->get_object($resultat))
echo "<div id=\errorpass5\">".$lc_ErrMsg_PwBad."</div>";
else
{
$update_pass = "UPDATE mc_users SET password='".addslashes($passwd)."' WHERE id_user='".$_SESSION['id_user']."'";
$resultat= $myDB->send_query($update_pass);
$nb_occur = $myDB->num_rows();
if(($nb_occur == -1)||($nb_occur == ""))
{
echo "<div class=\"message\">Error ".$myDB->return_error()." while updating password</div>";
}
else echo "<div class=\"message\">Password successfully updated</div>";
}
}
}
$is_changeaddress = $_POST['changeaddress'];
$newmail = $_POST['email'];
if($is_changeaddress!="")
{
$isOk = true;
if(($newmail=="")||(!isset($newmail)))
{echo "<div class=\"error5\">".$lc_ErrMsg_EmailNull.".</div>";$isOk=false;}
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
if (!eregi($regexp, $newmail))
{echo "<div class=\"error6\">".$lc_ErrMsg_EmailBad.".</div>";$isOk=false;}
if($isOk)
{
$update_email = "UPDATE mc_users SET email='".$newmail."' WHERE id_user='".$_SESSION['id_user']."'";
$resultat= $myDB->send_query($update_email);
$nb_occur = $myDB->num_rows();
if(($nb_occur == -1)||($nb_occur == ""))
echo "<div class=\"message\">Error ".$myDB->return_error()." while updating email</div>";
else echo "<div class=\"message\">Email successfully updated</div>";
}
}
$is_changeallow = $_POST['changeallow'];
$newallow = $_POST['allow'];
if($is_changeallow!="")
{
$update_allow = "UPDATE mc_users SET allow='".$newallow."' WHERE id_user='".$_SESSION['id_user']."'";
$resultat= $myDB->send_query($update_allow);
$nb_occur = $myDB->num_rows();
if(($nb_occur == -1)||($nb_occur == ""))
echo "<div class=\"message\">Error ".$myDB->return_error()." while updating</div>";
else echo "<div class=\"message\">Successfully updated</div>";
}
//------------- User data -------------
$requete_user = 'SELECT id_user,login,email,level,allow FROM mc_users WHERE id_user="'.$_SESSION['id_user'].'" ;';
$envoi_requete_user = $myDB->send_query($requete_user);
$nb_occur = $myDB->num_rows();
if(($nb_occur == 0)||($nb_occur == ""))
{
echo "<div id=\"error7\">ERREUR GRAVE : USER NON TROUVE</div>\n ";
}
$table_user = $myDB->get_array($envoi_requete_user,'NUMERIC');
$myUser = new User($table_user);
echo "<hr/>\n";
echo "<form method=\"POST\">\n";
echo "<h2>Change your password</h2>\n";
echo "<table><tr><td>Old password</td><td><input type=\"password\" name=\"oldpassword\"/></td></tr>\n";
echo " <tr><td>New password</td><td><input type=\"password\" name=\"newpassword\"/></td></tr>\n";
echo " <tr><td>Repeat password</td><td><input type=\"password\" name=\"passwordconfirm\"/></td></tr>\n";
echo " <tr><td></td><td><input type=\"submit\" name=\"changepass\" value=\"".$lc_Update."\" class=\"submit\"/></td></tr>\n";
echo "</table></form>\n";
echo "<hr/>\n";
echo "<form method=\"POST\">\n";
echo "<h2>Change your address</h2>\n";
echo "<table> <tr><td>New address </td>\n";
echo " <td><input type=\"text\" name=\"email\" value=\"";
echo $myUser->email;
echo "\"/></td></td><td>$error[3]</td></tr>\n";
echo " <tr><td></td><td><input type=\"submit\" name=\"changeaddress\" value=\"".$lc_Update."\" class=\"submit\"/></td></td><td></td></tr>\n";
echo "</table></form>\n";
echo "<hr/>\n";
echo "<form method=\"POST\">\n";
echo "<h2>Public profile</h2>\n";
$is_allowed = $myUser->allow;
echo "<table> <tr><td>Public profile *</td>\n";
echo " <td><input type=\"radio\" name=\"allow\" value=\"yes\"";
if($is_allowed=="yes") echo " checked=\"checked\"";
echo "/>yes <input type=\"radio\" name=\"allow\" value=\"no\"";
if($is_allowed=="no") echo " checked=\"checked\"";
echo "/>no </td></tr>\n";
echo " <tr><td></td><td><input type=\"submit\" name=\"changeallow\" value=\"".$lc_Update."\" class=\"submit\"/></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "* Allows people to see your collection, and allows members to contact you for information about issues.";
?>