summaryrefslogtreecommitdiff
path: root/lib/profile.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/profile.pm')
-rw-r--r--lib/profile.pm127
1 files changed, 127 insertions, 0 deletions
diff --git a/lib/profile.pm b/lib/profile.pm
new file mode 100644
index 0000000..1e20a78
--- /dev/null
+++ b/lib/profile.pm
@@ -0,0 +1,127 @@
+##################################
+# PROFILE ########################
+
+sub show_profile
+ {
+ my ($uname) = @_;
+ my $loggedin = ($USER != -1);
+ my $profile = get_user_profile($uname);
+ my $files = get_user_files($uname);
+ my $threads = get_threads_by_user($uname);
+ my $keywords = get_keywords();
+ my $image = get_profile_image($uname, $AVATAR_PROFILE_PREFIX);
+
+ print qq!<table border=0 cellpadding=0 cellspacing=0 width="100%">!;
+ print qq!<tr>!;
+ print qq!<td style="width: 300px; padding: 5px; vertical-align: top;">\n!;
+
+ print qq!<img src="$image"><br>! if ($image != -1);
+
+ print qq(<table border=0 cellpadding=0 cellspacing=0>);
+ profile_row("name", $$profile{realname});
+ my $email = $$profile{email};
+ $email =~ s/\@/&nbsp;<i>at<\/i>&nbsp;/i;
+ profile_row("email", $email) if ($loggedin);
+ profile_row("aim", $$profile{aim}) if ($$profile{aim} && $loggedin);
+ profile_row("phone", $$profile{phone}) if ($$profile{phone} && $loggedin);
+ profile_row("location", $$profile{location}) if ($$profile{location});
+ my %tzs = ( -5 => eastern, -6 => central, -8 => pacific, 0 => englandish);
+ profile_row("timezone", $tzs{$profile->{timezone}}) if (exists $tzs{$profile->{timezone}});
+ if ((time - $$profile{lastseen}) < 60)
+ { profile_row("last&nbsp;seen", "<b>active&nbsp;now</b>"); }
+ else
+ { profile_row("last&nbsp;seen", verbosedate($$profile{lastseen})); }
+ if (($USER->{username} ne $uname) && $loggedin)
+ {
+ profile_row("&middot; &middot; &middot; &middot;",
+ qq[<a href="$BUCKY/message/$uname">send $uname a message</a>]);
+ }
+ print "</table>";
+
+ if ($files != -1)
+ {
+ user_image_gallery({ files => $files, vertical => 1, count => 8 });
+ }
+
+ print qq(</td>);
+
+ print qq(<td style="padding: 10px; vertical-align: top; text-align: center;">\n);
+
+ if ($threads != -1)
+ {
+ print qq!<table border=0 cellpadding=0 cellspacing=0 class="threadmain" width="100%">!;
+ print qq(<tr><td colspan=255><big>&nbsp;threads by $uname</big></td></tr>);
+ print qq(<tr><td colspan=255><hr noshade color="$BUCKY_COLOR_HR" style="padding: 0px; margin: 2px;"></td></tr>);
+ thread_box({ threads => $threads, kw => 'USER', dosum => 0, dohead => 0 });
+ if ($files != -1)
+ {
+ print qq(<tr><td colspan=255><big>&nbsp;</big></td></tr>);
+ print qq(<tr><td colspan=255><big>&nbsp;files by $uname</big></td></tr>);
+ print qq(<tr><td colspan=255><hr noshade color="$BUCKY_COLOR_HR" style="padding: 0px; margin: 2px;"></td></tr>);
+ file_list($files, 0, 1, 0);
+ }
+ print "</table>\n";
+ print "<p>\n\n";
+ }
+
+ print qq(</td></tr>);
+
+ print qq(</table>);
+
+ footer();
+ }
+
+sub profile_row
+ {
+ my ($k, $v) = @_;
+ print "<tr><td align=right valign=top nobreak><small>$k&nbsp;&middot;&nbsp;</small></td><td align=left valign=top>$v</td></tr>";
+ }
+
+# moves files around
+sub update_profile_image
+ {
+ my ($username) = @_;
+ $filename = $input->{userpic};
+
+ return if (! -e $temp_path."/".$filename);
+ if ($filename =~ /temp_$/)
+ { system($RM_PATH, $temp_path."/".$filename); return; }
+
+ if (-e $data_path."/profile/".$username.".jpg")
+ {
+ print "moving old profile pic...<br>";
+ system($MV_PATH, "$data_path/profile/$username.jpg", $data_path."/profile/".$username."-old.jpg");
+ }
+
+ $messages .= "updating profile pic for $username to $filename...<br>";
+ system($MV_PATH, "$temp_path/$filename", "$data_path/profile/$username.jpg");
+
+ update_profile_thumb($username);
+
+ return 1;
+ }
+
+# creates avatars
+sub update_profile_thumb
+ {
+ my ($username) = @_;
+
+ if (!-e "$data_path/profile/$username.jpg")
+ {
+ $messages .= "/profile/$username.jpg does not exist!" if $DEBUG;
+ return -1;
+ }
+
+ my $profile_image =
+ {
+ filename => "$username.jpg",
+ thread => "profile"
+ };
+
+ make_image_thumb({file => $profile_image, maxwidth => $AVATAR_PROFILE_WIDTH, maxheight => $AVATAR_PROFILE_HEIGHT, key => $AVATAR_PROFILE_PREFIX});
+ make_square_thumb($profile_image, $AVATAR_BIG_WIDTH, $AVATAR_BIG_PREFIX);
+ make_square_thumb($profile_image, $AVATAR_MED_WIDTH, $AVATAR_MED_PREFIX);
+ }
+
+1;
+