From e9192b3d42660a5781101df4357d276318151e8a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 2 Aug 2013 17:14:41 -0500 Subject: cgi-bin & lib --- lib/profile.pm | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 lib/profile.pm (limited to 'lib/profile.pm') 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!!; + print qq!!; + print qq!); + + print qq(); + + print qq(
\n!; + + print qq!
! if ($image != -1); + + print qq(); + profile_row("name", $$profile{realname}); + my $email = $$profile{email}; + $email =~ s/\@/ at<\/i> /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 seen", "active now"); } + else + { profile_row("last seen", verbosedate($$profile{lastseen})); } + if (($USER->{username} ne $uname) && $loggedin) + { + profile_row("· · · ·", + qq[send $uname a message]); + } + print "
"; + + if ($files != -1) + { + user_image_gallery({ files => $files, vertical => 1, count => 8 }); + } + + print qq(
\n); + + if ($threads != -1) + { + print qq!!; + print qq(); + print qq(); + thread_box({ threads => $threads, kw => 'USER', dosum => 0, dohead => 0 }); + if ($files != -1) + { + print qq(); + print qq(); + print qq(); + file_list($files, 0, 1, 0); + } + print "
 threads by $uname

 
 files by $uname

\n"; + print "

\n\n"; + } + + print qq(

); + + footer(); + } + +sub profile_row + { + my ($k, $v) = @_; + print "$k · $v"; + } + +# 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...
"; + system($MV_PATH, "$data_path/profile/$username.jpg", $data_path."/profile/".$username."-old.jpg"); + } + + $messages .= "updating profile pic for $username to $filename...
"; + 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; + -- cgit v1.2.3-70-g09d2