Avatars Upload 0.2 For YaBB 1 Gold - SP 1.1 !!! Before installing this version please uninstall previous version !!! Changes in v0.2 (30/09/2002) - Fixed error with bad saving settings - Now all uploaded avatars pics saved with name of uploaded them user. Thanks to Dave Baughman for help in bug hunting and ideas ;o) About mod: Allow users to upload avatar pics to forum. Admins can set limits on size and dimensions of uploaded pics. Admins can permit or deny to upload pics. Pics can be in gif, jpg and png formats. Pics are uploaded in a special subdirectory created in avatars directory and can be used only by user who uploaded them. After uploading a new picture the old one is erased. Installing: Uninstal previously installed versions of this mod. After setting this mod an admin needs to configure its properties in "Admin/Forum Preferences and Settings" section. All errors and request please send to my email: ryoko@tut.by 2002. Ryoko[Anibel] Ryoko [Anibel] mailto:ryoko@tut.by Sources/Subs.pl my $query = new CGI; $query = new CGI; #Ryoko upload avatars mod changed Sources/Profile.pl
$images = ""; foreach $line (sort @contents){ $images = ""; # Ryoko upload avatars mod begin if ($can_upload_pic && $memsettings[13] =~ m|$personal_dir/(.+)|i) { $images .= qq~ $txt{'475'} ~; $picupl{'01'} ~; if ($can_upload_pic){ $yymain .= qq~ $picupl{'02'} ~; } if( $member{'userpicpersonalcheck'} && ( $member{'userpicpersonal'} =~ m/\.gif\Z/i || $member{'userpicpersonal'} =~ m/\.jpg\Z/i || $member{'userpicpersonal'} =~ m/\.jpeg\Z/i || $member{'userpicpersonal'} =~ m/\.png\Z/i ) ) { $member{'userpic'} = $member{'userpicpersonal'}; } #Ryoko upload avatars mod begin if($can_upload_pic && ($member{type_userpic} eq 'file') && (my $flhn=$query->param('pic_file'))){ local *info=$query->uploadInfo($flhn); my $type = $info{'Content-Type'}; if ($type!~m#image/(gif|pjpeg|jpeg|png|x-png)#){ &fatal_error("$picupl{'03'} $type."); } if ($flhn=~/([^\/\\]+)\.(\w+)$/){ my ($fn, $fe, $fname)=(lc($member{'username'}),lc($2)); for my $ext ('gif', 'jpg', 'png', 'jpeg'){ next if $ext eq $fe; $fname="$facesdir/$personal_dir/$fn.$ext"; if (-e $fname){ unlink($fname) || &fatal_error("$picupl{'10'} '$fname': $!"); } } $fname="$personal_dir/$fn.$fe"; if (open (FH, ">$facesdir/$fname")){ binmode FH; my ($buffer, $fs, $sz, $imgx, $imgy); while ($sz=read($flhn,$buffer,1024)) { ($imgx, $imgy)=getsize($type,$buffer) unless $imgx; print FH $buffer; $fs+=$sz; last if $max_upload_size && $fs > $max_upload_size; } #$member{'usertext'}="$imgx x $imgy"; close FH; chmod(0666, "$facesdir/$fname"); if ($max_upload_size && $fs > $max_upload_size) { unlink "$facesdir/$fname"; &fatal_error("$picupl{'04'}" ); } if (($userpic_width && $imgx > $userpic_width) || ($userpic_height && $imgy > $userpic_height)) { unlink "$facesdir/$fname"; &fatal_error("$picupl{'05'} $imgx x $imgy px."); } $member{'userpic'} = "$fname"; } } close $flhn; }elsif( $member{type_userpic} eq 'url' && ( $member{'userpicpersonal'} =~ m/\.(gif|jpg|jpeg|png)\Z/i ) ) { $member{'userpic'} = $member{'userpicpersonal'}; } #Ryoko upload avatars mod end 1; # Ryoko upload avatars mod begin sub getsize { my ($type, $buf)=@_; if ($type=~/image\/pjpeg/){ if ($buf=~/\377[\300-\311]..\010(....)/){ my ($x,$y)=unpack('nn',$1); return ($x, $y); } }elsif($type=~/image\/gif/){ if ($buf=~/^GIF8[79]a(....)/){ my ($x,$y)=unpack('vv',$1); return ($x, $y); } }elsif($type=~/image\/x-png/){ if ($buf=~/IHDR(.{8})/){ my ($x,$y)=unpack('NN',$1); return ($x, $y); } } return (1,1); } # Ryoko upload avatars mod end Sources/AdminEdit.pl my($snfchecked, $fls1, $fls2, $fls3, $utfchecked, $truncchecked, $mts1, $mts2, $mts3, $tsl6, $tsl5, $tsl4, $tsl3, $tsl2, $tsl1); my($cupchecked); #Ryoko upload avatars mod if ($timeselected == 6) { $tsl6 = " selected" } elsif ($timeselected == 5) { $tsl5 = " selected" } elsif ($timeselected == 4) { $tsl4 = " selected" } elsif ($timeselected == 3) { $tsl3 = " selected" } elsif ($timeselected == 2) { $tsl2 = " selected" } else { $tsl1 = " selected" } if ($can_upload_pic) {$cupchecked = " checked"}; #Ryoko upload avatars mod if (!$personal_dir) {$personal_dir = "personal"}; #Ryoko upload avatars mod if (!$max_upload_size) {$max_upload_size = 20480};#Ryoko upload avatars mod $picupl{'06'} $picupl{'08'} $picupl{'07'} my @onoff = qw/ allowpics showyabbcbutt showbdescrip maintenance guestaccess insert_original enable_ubbc enable_news enable_guestposting enable_notification showlatestmember showrecentbar showmarkread showmodify showuserpic showusertext showgenderimage shownewsfader MenuType curposlinks profilebutton autolinkurls emailpassword RegAgree emailwelcome allow_hide_email usetempfile faketruncation emailnewpass/; push(@onoff, "can_upload_pic"); #Ryoko upload avatars mod $userpic_limits =~ s/\"/\'/g; #Ryoko upload avatars mod begin $can_upload_pic = $FORM{'can_upload_pic'} || '0'; $personal_dir = $FORM{'personal_dir'} || 'personal'; $max_upload_size = $FORM{'max_upload_size'} || 20480; if (!(-d "$facesdir/$personal_dir")){ mkdir("$facesdir/$personal_dir", 0777) || &fatal_error("$picupl{'09'} $!"); } #Ryoko upload avatars mod end \$timeout = $timeout; # Minimum time between 2 postings from the same IP #Ryoko upload avatars mod \$can_upload_pic = $can_upload_pic; # Allow to upload avatars pics \$personal_dir = "$personal_dir"; # Subdirectory in avtars directory where to place uploaded pictures \$max_upload_size = "$max_upload_size"; # Size limit of uploaded pics. english.lng $txt{'796'} = "Your Instant Messages:"; #Ryoko upload avatars mod strings $picupl{'01'} = "URL to my pic:"; $picupl{'02'} = "Upload my pic:"; $picupl{'03'} = "Wrong file type. Only files in gif, jpg and png formats are accepted. Your file is recognized as:"; $picupl{'04'} = "Size of uploaded pic exceeds the limit of $max_upload_size bytes."; $picupl{'05'} = "Dimensions of uploaded pic exceed the limit of $userpic_width x $userpic_height px.
Your pic dimensions are recognized as:"; $picupl{'06'} = "Allow to upload users pics"; $picupl{'07'} = "Uploaded userpics Directory"; $picupl{'08'} = "Userpic size (0 = disable limit)"; $picupl{'09'} = "Can't create directory '$facedir/$personal_dir':"; $picupl{'10'} = "Can't delete file ";