summaryrefslogtreecommitdiff
path: root/forum
diff options
context:
space:
mode:
authordeva <deva>2008-10-27 14:58:26 +0000
committerdeva <deva>2008-10-27 14:58:26 +0000
commitbdad9a1ba9e68c016759374fb24059f571d98435 (patch)
treeb732966e22b4bf4ca244c30d7d30d069c0fb1f9c /forum
parent3b5656db543462ec1f126d0d97b1ee1ba25c782e (diff)
Added customizable avatars (users can now upload their own).
Diffstat (limited to 'forum')
-rw-r--r--forum/utils/profile.php46
1 files changed, 24 insertions, 22 deletions
diff --git a/forum/utils/profile.php b/forum/utils/profile.php
index 7f8372c..a8676b4 100644
--- a/forum/utils/profile.php
+++ b/forum/utils/profile.php
@@ -5,7 +5,7 @@ if($action == "update") {
// $current_user->username = $username;
$current_user->name = $name;
$current_user->email = $email;
- $current_user->avatar = $avatar;
+ // $current_user->avatar = $avatar;
$current_user->signature = $signature;
if($password != "") {
if($password == $password_confirm) {
@@ -14,29 +14,31 @@ if($action == "update") {
error("Passwords do not match - thus not changed!");
}
}
+
+ if(is_uploaded_file($_FILES['userfile']['tmp_name'])) {
+ if(!file_exists("gfx/avatars")) mkdir("gfx/avatars");
+ $filename = $_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" 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: <select name="avatar">
-<?php
-$dir = opendir("gfx/avatars");
-while($avatar = readdir($dir)) {
- if($avatar != "." && $avatar != "..") {
-?> <option value="<?php echo $avatar ?>" <?php if($current_user->avatar == $avatar) echo selected; ?>><?php echo $avatar ?></option>
-<?php
- }
-}
-?>
-</select><br/>
-Signature:<br/>
-<textarea name="signature" cols="60" rows="2"><?php echo $current_user->signature ?></textarea><br/>
-<br/>
-<button type="submit">Update</button>
+<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>