summaryrefslogtreecommitdiff
path: root/forum/utils/profile.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/profile.php')
-rw-r--r--forum/utils/profile.php91
1 files changed, 49 insertions, 42 deletions
diff --git a/forum/utils/profile.php b/forum/utils/profile.php
index f7595ed..d96b8c2 100644
--- a/forum/utils/profile.php
+++ b/forum/utils/profile.php
@@ -1,45 +1,52 @@
<?php
-include_once($UTIL_DIR . "/error.php");
+function profile()
+{
+ global $action, $_FILES, $current_user, $UTIL_DIR;
+ include_once($UTIL_DIR . "/error.php");
+
+ $str = "";
-if($action == "update") {
-// $current_user->username = $username;
- $current_user->name = $name;
- $current_user->email = $email;
- // $current_user->avatar = $avatar;
- $current_user->signature = stripslashes($signature);
- if($password != "") {
- if($password == $password_confirm) {
- $current_user->password = sha1(md5($password));
- } else {
- error("Passwords do not match - thus not changed!");
- }
- }
+ if($action == "update") {
+ global $name, $email, $signature, $password, $password_confirm, $users;
+ // $current_user->username = $username;
+ $current_user->name = $name;
+ $current_user->email = $email;
+ // $current_user->avatar = $avatar;
+ $current_user->signature = stripslashes($signature);
+ if($password != "") {
+ if($password == $password_confirm) {
+ $current_user->password = sha1(md5($password));
+ } else {
+ error("Passwords do not match - thus not changed!");
+ }
+ }
+
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ if(!file_exists("gfx/avatars")) mkdir("gfx/avatars");
+ // Prepend username to prevent overwriting of other users avatars.
+ $filename = $current_user->username . "_" . $_FILES['userfile']['name'];
+ if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar);
+ move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename);
+ $current_user->avatar = $filename;
+ }
+
+ $users->write();
+ }
- if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
- if(!file_exists("gfx/avatars")) mkdir("gfx/avatars");
- // Prepend username to prevent overwriting of other users avatars.
- $filename = $current_user->username . "_" . $_FILES['userfile']['name'];
- if($current_user->avatar) unlink("gfx/avatars/" . $current_user->avatar);
- move_uploaded_file($_FILES['userfile']['tmp_name'], "gfx/avatars/" . $filename);
- $current_user->avatar = $filename;
- }
-
-
- $users->write();
-}
-?>
-
-<form method="post" enctype="multipart/form-data" action="?mode=profile&amp;action=update"><?php
- /*Username: <input name="username" value="<?php echo $current_user->username; ?>"><br/> */ ?>
- Name: <input name="name" value="<?php echo $current_user->name; ?>"><br/>
- New password: <input type="password" name="password" value=""><br/>
- Confirm password: <input type="password" name="password_confirm" value=""><br/>
- E-Mail: <input name="email" value="<?php echo $current_user->email; ?>"><br/>
- Avatar:<br/>
- <img alt="Avatar" src="gfx/avatars/<?php echo $current_user->avatar; ?>"/><br/>
- <input name="userfile" type="file"><br/>
- Signature:<br/>
- <textarea name="signature" cols="60" rows="2"><?php echo $current_user->signature ?></textarea><br/>
- <br/>
- <button type="submit">Update</button>
-</form>
+ $str .= "<form method=\"post\" enctype=\"multipart/form-data\" action=\"?mode=profile&amp;action=update\">";
+ //$str .= " Username: <input name=\"username\" value=\"" . $current_user->username . "\"<br/>";
+ $str .= " Name: <input name=\"name\" value=\"" . $current_user->name . "\"><br/>";
+ $str .= " New password: <input type=\"password\" name=\"password\" value=\"\"><br/>";
+ $str .= " Confirm password: <input type=\"password\" name=\"password_confirm\" value=\"\"><br/>";
+ $str .= " E-Mail: <input name=\"email\" value=\"" . $current_user->email . "\"><br/>";
+ $str .= " Avatar:<br/>";
+ $str .= " <img alt=\"Avatar\" src=\"gfx/avatars/" . $current_user->avatar . "\"/><br/>";
+ $str .= " <input name=\"userfile\" type=\"file\"><br/>";
+ $str .= " Signature:<br/>";
+ $str .= " <textarea name=\"signature\" cols=\"60\" rows=\"2\">". $current_user->signature . "</textarea><br/>";
+ $str .= " <br/>";
+ $str .= " <button type=\"submit\">Update</button>";
+ $str .= "</form>";
+
+ return $str;
+} \ No newline at end of file