[go: up one dir, main page]

Menu

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

Download this file

229 lines (207 with data), 9.0 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
/* This file is part of Madcollector.
* Madcollector created by Thomas Andrieu,
* Developped by 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
* 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 = $locales["Menu_Account"];
if(($_GET['format']=="")||(!isset($_GET['format'])))
require_once THEME.('header.inc.php');
if($_GET['format']=="xml")
{
header("Content-Type: application/xml");
echo '<?xml version="1.0" ?><usersettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="'.LIBS.'schema/usersettings.xsd">';
}
//-------------------------------------
// PROCESS
//-------------------------------------
if((isset($_SESSION['id_user']))&&(isset($_POST['account_submit'])))
{
$isOk = true;
$isPassUpdate = false;
if($_POST['newpassword']!="")
{
$isPassUpdate = true;
if(($_POST['oldpassword']=="")||(!isset($_POST['oldpassword'])))
{
array_push($error_messages,$locales["ErrMsg_Confirm_Old"]);
$isOk=false;
}
if(($_POST['passwordconfirm']=="")||(!isset($_POST['passwordconfirm'])))
{
array_push($error_messages,$locales["ErrMsg_Confirm_New"]);
$isOk=false;
}
if($_POST['passwordconfirm'] != $_POST['newpassword'])
{
array_push($error_messages,$locales["ErrMsg_PwDiff"]);
$isOk=false;
}
if($isOk)
{
$verify_old_pwd= "SELECT * FROM ".$cfg_table_prefix."users WHERE id_user='".$_SESSION['id_user']."' and password=MD5('".$_POST['oldpassword']."')" ;
$result_verify_old_pwd= mysql_query($verify_old_pwd,$DB_connexion);
if(!$objLigne=mysql_fetch_object($result_verify_old_pwd))
{
array_push($error_messages,$locales["ErrMsg_PwBad"]);
$isOk=false;
}
mysql_free_result($result_verify_old_pwd);
}
}
if(($_POST['email']=="")||(!isset($_POST['email'])))
{
array_push($error_messages,$locales["ErrMsg_EmailNull"]);
$isOk=false;
}
$regexp = "/^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/";
if (!preg_match($regexp, $_POST['email']))
{
array_push($error_messages,$locales["ErrMsg_EmailBad"]);
$isOk=false;
}
if($isOk)
{
$posted_accountsettings_names_array = $_POST["posted_accountsettings_names"];
for($i=0;$i<sizeOf($posted_accountsettings_names_array);$i++)
{
if($i>0) $update_user .= ", ";
else $update_user = "UPDATE ".$cfg_table_prefix."users SET ";
$update_user .= $posted_accountsettings_names_array[$i]."='".$_POST[$posted_accountsettings_names_array[$i]]."'";
}
if($isPassUpdate)
$update_user .= ",password=MD5('".addslashes($_POST['newpassword'])."')";
$update_user .= " WHERE id_user='".$_SESSION['id_user']."'";
$resultat_update_user= mysql_query($update_user,$DB_connexion);
if(!$resultat_update_user)
array_push($error_messages,$locales["ErrMsg_SQL_Update_User"]." : ".mysql_error($DB_connexion));
}
}
//------------- User data -------------
$requete_user = 'SELECT * FROM '.$cfg_table_prefix.'users WHERE id_user="'.$_SESSION['id_user'].'" ;';
$envoi_requete_user = mysql_query($requete_user,$DB_connexion);
if(!$envoi_requete_user)
{
array_push($error_messages,$locales["ErrMsg_SQL_User_Not_Found"]);
}
$table_user = mysql_fetch_array($envoi_requete_user, MYSQL_BOTH);
$myUser = new User($table_user);
mysql_free_result($envoi_requete_user);
//-------------------------------------
// DISPLAY
//-------------------------------------
for($i=0;$i<sizeOf($error_messages);$i++)
{
echo "<div class=\"error\">".$error_messages[$i]."</div>\n";
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<div class=\"ul-navig\"><ul>\n";
echo "<li class=\"selected\">".$locales["Menu_Account"]."</li>";
//Links
echo "<li><a href=\"index.php?rub=mycollection&action=collected\">".$locales["Collection"]."</a></li>";
echo "<li><a href=\"index.php?rub=mycollection&action=searched\">".$locales["Searchlist"]."</a></li>";
echo "<li><a href=\"index.php?rub=mycollection&action=forsale\">".$locales["Selllist"]."</a></li>";
echo "<li><a href=\"index.php?rub=profile&id_user=".$_SESSION['id_user']."\">".$locales["Profile"]."</a></li>";
echo "</ul></div>\n";
echo "<br/>\n\n";
echo "<form method=\"post\">\n";
echo "<h2>".$locales["UserPassWord"]."</h2>\n";
echo '<p id="old_password">'.$locales["UserOldPassWord"]." : <input type=\"password\" name=\"oldpassword\"/></p>\n";
echo '<p id="new_password">'.$locales["UserNewPassWord"]." : <input type=\"password\" name=\"newpassword\"/></p>\n";
echo '<p id="confirm_new_password">'.$locales["UserConfirmPassword"]." : <input type=\"password\" name=\"passwordconfirm\"/></p>\n";
echo "<br/>\n\n";
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["UserEmail"]."</h2>\n";
echo '<p id="user_mail">'.$locales["UserEmail"]." : <input type=\"text\" name=\"email\" value=\"";
echo $myUser->email;
echo '"/><input type="hidden" name="posted_accountsettings_names[]" value="email"/></p>'."\n" ;
echo "<br/>\n\n";
}
if($_GET['format']=="xml"){
echo "<email>".$myUser->email."</email>";
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["UserPublicProfile"]."</h2>\n";
echo '<p id="user_public_profile">'.$locales["UserPublicProfile"]."* : <input type=\"radio\" name=\"public_profile\" value=\"Y\"";
if($myUser->public_profile=="Y") echo " checked=\"checked\"";
echo "/>".$locales["Yes"]." <input type=\"radio\" name=\"public_profile\" value=\"N\"";
if($myUser->public_profile=="N") echo " checked=\"checked\"";
echo "/>".$locales["No"].' </p><input type="hidden" name="posted_accountsettings_names[]" value="public_profile"/>';
echo "<p>* ".$locales["Explain_Public_Profile"]."</p>";
echo "<br/>\n";
}
if($_GET['format']=="xml"){
echo '<public_profile value="'.$myUser->public_profile.'"/>';
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["Allow_PM"]."</h2>\n";
echo '<p id="user_allow_PM">'.$locales["Allow_PM"]." : <input type=\"radio\" name=\"allow_PM\" value=\"Y\"";
if($myUser->allow_PM=="Y") echo " checked=\"checked\"";
echo "/>".$locales["Yes"]." <input type=\"radio\" name=\"allow_PM\" value=\"N\"";
if($myUser->allow_PM=="N") echo " checked=\"checked\"";
echo "/>".$locales["No"].' </p><input type="hidden" name="posted_accountsettings_names[]" value="allow_PM"/>';
echo "<br/>\n\n";
}
if($_GET['format']=="xml"){
echo '<allow_PM value="'.$myUser->allow_PM.'"/>';
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["Allow_ML"]."</h2>\n";
echo '<p id="user_allow_ML">'.$locales["Allow_ML"]." : <input type=\"radio\" name=\"allow_ML\" value=\"Y\"";
if($myUser->allow_ML=="Y") echo " checked=\"checked\"";
echo "/>".$locales["Yes"]." <input type=\"radio\" name=\"allow_ML\" value=\"N\"";
if($myUser->allow_ML=="N") echo " checked=\"checked\"";
echo "/>".$locales["No"].' </p><input type="hidden" name="posted_accountsettings_names[]" value="allow_ML"/>';
echo "<br/>\n\n";
}
if($_GET['format']=="xml"){
echo '<allow_ML value="'.$myUser->allow_ML.'"/>';
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["Language"]."</h2>\n";
echo '<p id="user_language"><select name="language">';
if($fp = fopen("locales/lc.locales","r"))
{
while (!feof($fp))
{
$ligne = fgets($fp, 4096);
if (preg_match("/^(.+):(.+)$/", $ligne, $regs)) {
echo "<option value=\"".$regs[1]."\"";
if($regs[1]==$myUser->language) echo " selected=\"selected\"";
echo ">".$regs[2]."</option>";
}
}
fclose($fp);
}
echo '</select><input type="hidden" name="posted_accountsettings_names[]" value="language"/></p>';
echo "<br/>\n\n";
}
if($_GET['format']=="xml"){
echo '<language value="'.$myUser->language.'"/>';
}
if(($_GET['format']=="")||(!isset($_GET['format']))) {
echo "<h2>".$locales["UserSignature"]."</h2>\n";
echo '<p id="user_signature"><textarea name="signature">'.preg_replace('/<br \/>/', "", $myUser->signature).'</textarea><input type="hidden" name="posted_accountsettings_names[]" value="signature"/></p>'."\n";
echo "<p><input type=\"submit\" name=\"account_submit\" value=\"".$locales["Update"]."\" class=\"submit\"/></p>\n";
echo "</form>\n\n";
}
if($_GET['format']=="xml"){
echo '<signature>'.htmlspecialchars($myUser->signature).'</signature>';
}
if(($_GET['format']=="")||(!isset($_GET['format'])))
require_once THEME.('footer.inc.php');
if($_GET['format']=="xml")
echo '</usersettings>';
?>