#!/usr/bin/perl
#########################################
# #
# Gallery mod #
# for YaBB SP1.1 and 1.31 #
# Copyright by Le Trong Hoang #
# #
#########################################
$url=$ENV{'QUERY_STRING'};
$urlstd=$cgi.";action=gallery";
$sepe=" ";
&init;
my $albumdir="$galleryabs/$mbcode/$albumname";
my $muser=";moduser=$INFO{'moduser'}";
if(!$INFO{'moduser'}) { $muser=""; }
sub Gallery {
&readinfo;
if($username eq "Guest") {
if($allowgst==0) { &fatal_error("$txt{'223'}"); }
else { $mbacc=1; }
}
else { if($mbacc==0 && $allowgst==0) { &fatal_error("$txt{'1'}"); } }
$yymain .= qq~
~;
&template;
exit;
}
sub init {
$descrip_on=$ad_descrip_on;
$descrip=$ad_descrip;
$fotograf_on=$ad_fotograf_on;
$fotograf=$ad_fotograf;
$caption_on=$ad_caption_on;
$view_on=$ad_view_on;
$ftheight=$ad_ft_height;
$ftcol=$ad_ft_col;
$thumbs_on=$ad_thumbs_on;
$zip_on=$ad_zip_on;
fopen(FILE,"$memberdir/gallerymb.txt");
@Gallerymb = ;
chomp(@Gallerymb);
close(FILE);
foreach (@Gallerymb) {
@Mbinfo=split(" ",$_);
if($INFO{'useralbum'} eq $Mbinfo[0]) { $usercode=$Mbinfo[1]; }
if($_ =~ /^$username /) { $mbcode=$Mbinfo[1]; $mbcodeo=$Mbinfo[1]; $mbacc=substr($Mbinfo[2],0,1); $mbupl=substr($Mbinfo[2],1,1); $mbpub=substr($Mbinfo[2],2,1); $mbmod=substr($Mbinfo[2],3,1); }
}
fopen(FILE,"$memberdir/galleryalb.txt");
@Galleryalb = ;
chomp(@Galleryalb);
close(FILE);
fopen(FILE,"$memberdir/gallerypub.txt");
@Gallerypub = ;
chomp(@Gallerypub);
close(FILE);
if($INFO{'useralbum'}) { foreach(@Gallerypub) { if($_ =~ /^$usercode /) { push(@Gpub,$_); } } @Gallerypub=@Gpub; }
opendir(DIR, $galleryabs) || die "$galleryabs: $!";
@Mbalbums = readdir(DIR);
closedir(DIR);
foreach(@Mbalbums) {
if($mbcode eq $_) { last; }
else { mkdir("$galleryabs/$mbcode",0777); chmod(0777,"$galleryabs/$mbcode"); }
}
$mbdir="$galleryabs/$mbcode";
opendir(DIR, $mbdir) || die "$mbdir: $!";
@Albums = readdir(DIR);
closedir(DIR);
my @Albus=@Albums;
$conalbum=0;
$congalfoto=0;
$congalsize=0;
foreach(@Albus) {
if($_ eq "." || $_ eq ".." || $_ eq "_vti_cnt") { splice(@Albums,$albnum,1); next; }
else { if($INFO{'album'} eq $_) { $albumname=$_; } $conalbum++; }
$albumdir="$mbdir/$_";
opendir(DIR, $albumdir) || die "$albumdir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
foreach(@Elements) { if($_ ne "." && $_ ne ".." && $_ ne "_vti_cnt" && $_ !~ /^$ad_th_name/ && $_ !~ /\.zip/ && $_ !~ /\.tar/) { $congalfoto++; } my @Inf=stat("$albumdir/$_"); $congalsize+=$Inf[7]; }
}
if($mbmod && $INFO{'moduser'} && !$INFO{'useralbum'}) {
$albumname=$INFO{'album'};
$guser=$INFO{'moduser'};
foreach(@Gallerymb) { if($_ =~ /^$guser /) { @Galluser=split(/ /,$_); $mbcode=$Galluser[1]; $mbdir="$galleryabs/$mbcode"; last; } }
}
}
sub readinfo {
if($ad_thumbs_on) { $thumbs=$ad_th_name; }
else { $thumbs=""; }
if($INFO{'pubalbum'}) {
$albumname=$INFO{'pubalbum'};
foreach(@Gallerypub) { if(index($_,$albumname) >=0) { @Pubs=split(/ /,$_); $mbcode=$Pubs[0]; } }
$albumdir="$galleryabs/$mbcode/$albumname";
}
foreach(@Galleryalb) {
if($_ =~ /$mbcode $albumname /) {
@Albinfo=split(" ",$_);
last;
}
}
if($allowset) {
$descrip_on=$Albinfo[2];
if($ad_descrip_on && $descrip_on) { if($Albinfo[3]) { $Albinfo[3] =~ s/_/ /g; $descrip=$Albinfo[3]; } }
$fotograf_on=$Albinfo[4];
if($ad_fotograf_on && $fotograf_on) { if($Albinfo[5]) { $Albinfo[5] =~ s/_/ /g; $fotograf=$Albinfo[5]; } }
$caption_on=$Albinfo[6];
$view_on=$Albinfo[7];
if($ad_view_on && $view_on) { $fotoheight=$Albinfo[8]; }
if($ad_view_on && $view_on && $ftcol) { $fotocol=$Albinfo[9]; }
$thumbs_on=$Albinfo[10];
if($ad_thumbs_on && $thumbs_on) { $thumbs=$ad_th_name; }
else { $thumbs=""; }
$zip_on=$Albinfo[11];
}
@caps=split("°°°",$Albinfo[12]);
foreach(@caps) { my @cp=split("°°",$_); push(@capfiles,$cp[0]); push(@captions,$cp[1]); }
foreach(@captions) { $_ =~ s/°/ /g; }
}
sub showdescrip {
$yymain .= qq~~;
if($ad_descrip_on) {
if($descrip_on && ($INFO{'album'} || $INFO{'pubalbum'})) { $yymain .= qq~$descrip~; }
else { $yymain .= qq~$ad_descrip~; }
}
$yymain .= qq~ | ~;
if($username eq "Guest" && $url eq "board=;action=gallery") { $fotograf=0; }
if($ad_fotograf_on) {
$yymain .= qq~~;
if($ad_fotograf || $fotograf) {
$yymain .= qq~ ~;
if($fotograf_on && ($INFO{'album'} || $INFO{'pubalbum'})) { $yymain .= qq~$fotograf~; }
else { $yymain .= qq~$ad_fotograf~; }
}
$yymain .= qq~ |
~;
}
else { if($ad_descrip_on && $descrip_on) { $yymain .= qq~~; } }
}
sub showalbums {
$pubstrg=" |
";
foreach(@Gallerypub) {
@Pubs=split(/ /,$_);
if($albumname eq $Pubs[1]) { $pubstrg .= "![$galltxt{]($imagesdir/albpubop.gif) | $_ |
~;
$albnum++;
}
}
$yymain .= qq~$pubstrg~;
if($mbmod && !$INFO{'useralbum'}) {
my @Membnames;
my @Membcodes;
foreach(@Gallerymb) {
@Membs=split(/ /,$_);
push(@Membnames,$Membs[0]);
push(@Membcodes,$Membs[1]);
}
$yymain .= qq~ |
~;
foreach(@Galleryalb) {
@Allalbs=split(/ /,$_);
for(my $p=0;$p<=$#Membcodes;$p++) {
if($Membcodes[$p]==$Allalbs[0]) {
foreach (@Gallerypub) {
if($_ eq "$Allalbs[0] $Allalbs[1]") { $pubind="2"; $albalt="$galltxt{'47'}"; last; }
else { $pubind=""; $albalt="$galltxt{'46'}"; }
}
$yymain .= qq~ $Allalbs[1] [$Membnames[$p]] |
~;
}
}
}
}
}
sub showmain {
if($url eq "board=;action=gallery" || ($INFO{'useralbum'} && !$INFO{'pubalbum'})) {
$yymain .= qq~~;
}
if($INFO{'pubalbum'}) { $albumdir="$galleryabs/$mbcode/$albumname"; }
opendir(DIR, $albumdir) || die "$albumdir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
$albumdir="$galleryrel/$mbcode/$albumname";
foreach(@Elements) {
@Inf=stat("$albumdir/$_");
$size=$size+$Inf[7];
if($_ eq "." || $_ eq ".." || $_ eq "_vti_cnt" || $_ =~ /^$ad_th_name/) { next; }
elsif($_ =~ /\.zip/ || $_ =~ /\.tar/) { $zip=$_; }
else { push(@Fotos,$_); }
}
$confoto=@Fotos;
$consize=$size;
if($INFO{'modify'} eq "editinfo" && $allowset && $username ne "Guest" && $mbacc) {
my $enable="
";
my $disable="
";
$yymain .= qq~
~;
}
@Fotos=sort(@Fotos);
my @capsort;
my @capfilesort;
my $count=0;
foreach(@Fotos) { for(my $c=0;$c<=$#captions;$c++) { if($_ eq $capfiles[$c]) { $capsort[$count]=$captions[$c]; $capfilesort[$count]=$capfiles[$c]; } } $count++; }
my @captions=@capsort;
my @capfiles=@capfilesort;
$findex=0;
if(($INFO{'album'} && (!$INFO{'modify'} || $INFO{'modify'} eq "fotoren" || $INFO{'modify'} eq "fotodel" || $INFO{'modify'} eq "editinfo")) || $INFO{'pubalbum'}) {
if($INFO{'modify'} eq "fotoren" && $username ne "Guest" && $mbacc) { $yymain .= qq~~;
}
if($INFO{'modify'} eq "fotodel" && ($mbupl || $mbmod)) {
$yymain .= qq~
$galltxt{'36'}$sepe$sepe~;
$yymain .= qq~~;
}
}
if($INFO{'modify'} eq "editinfo" && $username ne "Guest" && $mbacc && @Fotos) { $yymain .= qq~~; }
}
elsif($INFO{'modify'} eq "albcrt" && $username ne "Guest" && $mbacc && ($mbupl || $mbmod)) {
if($maxalbum && $conalbum==$maxalbum) { fatal_error("$galltxt{'75'}"); }
$yymain .= qq~~;
}
elsif($INFO{'modify'} eq "albren" && $username ne "Guest" && $mbacc) { $yymain .= qq~~; }
elsif($INFO{'modify'} eq "albdel" && $username ne "Guest" && $mbacc && ($mbupl || $mbmod)) { $yymain .= qq~~; }
elsif($INFO{'modify'} eq "albpub" && $username ne "Guest" && $mbacc && ($mbpub || $mbmod)) {
if(!$mbpub && !$mbmod) { $yymain .= qq~
~; &fatal_error("$txt{'1'}"); }
$unpub=$galltxt{'34'};
foreach(@Gallerypub) { if(index($_,$albumname) >= 0) { my @Pubs=split(/ /,$_); if($mbcode==$Pubs[0]) { $unpub=$galltxt{'56'}; } last; } }
$unpub=lcfirst($unpub);
$yymain .= qq~~;
}
elsif($INFO{'modify'} eq "fotoupl" && $username ne "Guest" && $mbacc && ($mbupl || $mbmod)) {
$yymain .= qq~
|
$galltxt{'45'} |
$galltxt{'57'} $galltxt{'58'} |
$galltxt{'57'} $galltxt{'59'} |
$galltxt{'38'} $galltxt{'58'} |
$galltxt{'38'} $galltxt{'59'} |
$galltxt{'60'} |
$maxalbum |
$maxfoto |
$maxsize |
$maxgalfoto |
$maxgalsize |
$galltxt{'61'} | $conalbum | $confoto | $consize | $congalfoto | $congalsize |
~;
if($ad_thumbs_on && $thumbs_on) { $yymain .= qq~
$galltxt{'73'} $ad_th_name~; }
my $enupl;
if((!$ad_zip_on || !$zip_on || $zip) && (($maxfoto && $confoto==$maxfoto) || ($maxgalfoto && $congalfoto==$maxgalfoto))) { $enupl=0; }
else { $enupl=1; }
if($enupl) {
$yymain .= qq~~;
}
}
}
sub albcrt {
$FORM{'crtalbum'} =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
$FORM{'crtalbum'} =~ s/[#%+,\/:.?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$FORM{'crtalbum'} =~ s/ /_/g;
$FORM{'crtalbum'} =~ s/ä/ae/g;
$FORM{'crtalbum'} =~ s/ö/oe/g;
$FORM{'crtalbum'} =~ s/ü/ue/g;
$FORM{'crtalbum'} = lc($FORM{'crtalbum'});
foreach(@Galleryalb) {
my @albs=split(" ",$_);
if($albs[1] eq $FORM{'crtalbum'}) { $exist=1; last;}
}
if($exist) { &fatal_error("$galltxt{'71'}"); }
mkdir("$galleryabs/$mbcode/$FORM{'crtalbum'}",0777);
chmod(0777,"$galleryabs/$mbcode/$FORM{'crtalbum'}");
if(!$ad_descrip) { $ad_descrip="0"; }
$ad_descrip =~ s/ /_/g;
if(!$ad_fotograf) { $ad_fotograf="0"; }
$ad_fotograf =~ s/ /_/g;
if(!$ad_ft_height) { $ad_ft_height="0"; }
$new="$mbcode $FORM{'crtalbum'} $ad_descrip_on $ad_descrip $ad_fotograf_on $ad_fotograf $ad_caption_on $ad_view_on $ad_ft_height $ad_ft_col 0 $ad_zip_on";
@Newalbs=@Galleryalb;
$count=0;
foreach(@Galleryalb) {
my @albs=split(" ",$_);
if($albs[0]==$mbcode) { splice(@Newalbs,$count,0,$new); $exist=1; last;}
$count++;
}
if(!$exist) { push(@Newalbs,$new); }
$count=0;
foreach(@Galleryalb) {
if($Newalbs[$count]) { $Newalbs[$count]="$Newalbs[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Newalbs;
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'crtalbum'}$muser~;
&redirectexit;
}
sub albren {
$FORM{'renalbum2'} =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
$FORM{'renalbum2'} =~ s/[#%+,\/:.?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$FORM{'renalbum2'} =~ s/ /_/g;
$FORM{'renalbum2'} =~ s/ä/ae/g;
$FORM{'renalbum2'} =~ s/ö/oe/g;
$FORM{'renalbum2'} =~ s/ü/ue/g;
$FORM{'renalbum2'} = lc($FORM{'renalbum2'});
foreach(@Galleryalb) {
my @albs=split(" ",$_);
if($albs[1] eq $FORM{'renalbum2'}) { $exist=1; last;}
}
if($exist) { &fatal_error("$galltxt{'72'}"); }
$rendir="$galleryabs/$mbcode/$FORM{'renalbum'}";
$rendir2="$galleryabs/$mbcode/$FORM{'renalbum2'}";
rename($rendir,$rendir2);
@Newpubs=@Gallerypub;
$count=0;
foreach(@Gallerypub) {
if(index($_,"$mbcode $FORM{'renalbum'}") >= 0) { $Newpubs[$count]="$mbcode $FORM{'renalbum2'}"; }
if($Newpubs[$count]) { $Newpubs[$count]="$Newpubs[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/gallerypub.txt");
print FILE @Newpubs;
close(FILE);
@Albsinfo=@Galleryalb;
$count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'renalbum'}") >= 0) {
my @string=split(/ /,$_);
$string[1]=$FORM{'renalbum2'};
my $new=join(" ",@string);
splice(@Albsinfo,$count,1,$new);
}
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'renalbum2'}$muser~;
&redirectexit;
}
sub albdel {
my $deldir="$galleryabs/$mbcode/$FORM{'delalbum'}";
opendir(DIR,$deldir) || die "$deldir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
foreach(@Elements) { unlink("$deldir/$_"); }
rmdir($deldir);
my @Newpubs=@Gallerypub;
my $count=0;
foreach(@Gallerypub) {
if(index($_,"$mbcode $FORM{'delalbum'}") >= 0) { splice(@Newpubs,$count,1); }
if($Newpubs[$count]) { $Newpubs[$count]="$Newpubs[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/gallerypub.txt");
print FILE @Newpubs;
close(FILE);
my @Albsinfo=@Galleryalb;
my $count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'delalbum'}") >= 0) { splice(@Albsinfo,$count,1); }
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
$yySetLocation = qq~$urlstd~;
&redirectexit;
}
sub albpub {
my @Newpubs=@Gallerypub;
my @pub=("$mbcode $FORM{'pubalbum'}\n");
$count=0;
foreach(@Gallerypub) {
if($_ eq "$mbcode $FORM{'pubalbum'}") { splice(@Newpubs,$count,1); $exist=1; }
if($Newpubs[$count]) { $Newpubs[$count]="$Newpubs[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/gallerypub.txt");
if(!$exist) { push(@pub,@Newpubs); print FILE @pub; }
else { print FILE @Newpubs; }
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'pubalbum'}$muser~;
&redirectexit;
}
sub fotoupl {
use CGI;
my $query = new CGI;
$uplalbum = $query->param('uplalbum');
my $upldir="$galleryabs/$mbcode/$uplalbum";
opendir(DIR,$upldir) || die "$upldir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
my @Inf;
foreach(@Elements) {
@Inf=stat("$upldir/$_");
$size=$size+$Inf[7];
}
$consize=$size;
$zipfile = $query->param('uplzip');
my $zname = $zipfile;
$zname =~ s/.*\\//g;
$zname =~ s/[#%+,\/:?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$zname =~ s/ /_/g;
$zname =~ s/ä/ae/g;
$zname =~ s/ö/oe/g;
$zname =~ s/ü/ue/g;
$zname=lc($zname);
if($zname =~ /\.zip/ || $zname =~ /\.tar/) {
$write_zip = "$upldir/$zname";
fopen(ZDAT,">$write_zip");
binmode $zipfile;
binmode ZDAT;
while (read($zipfile,my $buffer,1024)) { print ZDAT $buffer; }
fclose(ZDAT);
my @Inf=stat("$write_zip");
$consize=$consize+$Inf[7];
$congalsize=$congalsize+$Inf[7];
if(($maxsize && $consize>$maxsize) || ($maxgalsize && $congalsize>$maxgalsize)) {
unlink("$write_zip");
fatal_error("$galltxt{'76'}");
}
}
my @Newfiles;
for(my $x=1;$x<=5;$x++) {
$feld = "uplfoto".$x;
my $file = $query->param($feld);
my $fname = $file;
$fname =~ s/.*\\//g;
$fname =~ s/[#%+\/:,?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$fname =~ s/ /_/g;
$fname =~ s/ä/ae/g;
$fname =~ s/ö/oe/g;
$fname =~ s/ü/ue/g;
$fname=lc($fname);
if($fname =~ /\.jpg/ || $fname =~ /\.gif/ || $fname =~ /\.png/) {
push(@Newfiles,$fname);
$write_file = "$upldir/$fname";
fopen(DAT,">$write_file");
binmode $file;
binmode DAT;
while (read($file,my $buffer,1024)) { print DAT $buffer; }
fclose(DAT);
}
my @Inf=stat("$write_file");
$consize=$consize+$Inf[7];
$congalsize=$congalsize+$Inf[7];
if(($maxsize && $consize>$maxsize) || ($maxgalsize && $congalsize>$maxgalsize)) {
unlink("$write_file");
fatal_error("$galltxt{'76'}");
}
}
for(my $x=0;$x<=$#Newfiles;$x++) { $Newfiles[$x]="$Newfiles[$x]°°0"; }
my @Albsinfo=@Galleryalb;
my $count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'modalbum'}") >= 0) {
my @Alb=split(/ /,$_);
if($Alb[12]) {
my @caps=split(/°°°/,$Alb[12]);
push(@caps,@Newfiles);
@caps=sort(@caps);
$Alb[12]=join("°°°",@caps);
}
$Albsinfo[$count]=join(" ",@Alb);
}
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
$yySetLocation = qq~$urlstd;album=$uplalbum$muser~;
&redirectexit;
}
sub fotoren {
$FORM{'renfoto2'} =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
$FORM{'renfoto2'} =~ s/[#%+\/:?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$FORM{'renfoto2'} =~ s/ä/ae/g;
$FORM{'renfoto2'} =~ s/ö/oe/g;
$FORM{'renfoto2'} =~ s/ü/ue/g;
my $rendir="$galleryabs/$mbcode/$FORM{'modalbum'}";
opendir(DIR,$rendir) || die "$rendir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
foreach(@Elements) { if($_ ne "." && $_ ne ".." && $_ ne "_vti_cnt" && $_ !~ /^$ad_th_name/ && $_ !~ /\.tar/ && $_ !~ /\.zip/) { push(@Fotos,$_); } }
@Fotos=sort(@Fotos);
my @Rename=split(/, /,$FORM{'foto'});
my @Oldnames=split(/, /,$FORM{'renfoto'});
my @Newnames=split(/, /,$FORM{'renfoto2'});
foreach(@Newnames) {
$_ =~ s/,//g;
$_ =~ s/ /_/g;
$_ = lc($_);
if(index($FORM{'renfoto'},$_) >= 0 && ($_ =~ /\.jpg/ || $_ =~ /\.png/ || $_ =~ /\.gif/) ) { &fatal_error("$galltxt{'71'}"); }
}
my $type;
foreach(@Rename) {
$type=substr($Fotos[$_],length($Fotos[$_])-4,4);
if($Newnames[$_] && $Newnames[$_] =~ /$type$/) { rename("$rendir/$Fotos[$_]","$rendir/$Newnames[$_]"); rename("$rendir/$ad_th_name$Fotos[$_]","$rendir/$ad_th_name$Newnames[$_]"); }
else { $error=1; }
}
$FORM{'renzip2'} =~ s/.+\\([^\\]+)$|.+\/([^\/]+)$/$1/;
$FORM{'renzip2'} =~ s/[#%+\/:,?"<>'|@°^();!§$=`\^°²³{\[\]}´*~]//g;
$FORM{'renzip2'} =~ s/ä/ae/g;
$FORM{'renzip2'} =~ s/ö/oe/g;
$FORM{'renzip2'} =~ s/ü/ue/g;
$type=substr($FORM{'renzip'},length($FORM{'renzip'})-4,4);
if($FORM{'zip'} && $FORM{'renzip2'} =~ /$type$/) { rename("$rendir/$FORM{'renzip'}","$rendir/$FORM{'renzip2'}") }
elsif($FORM{'renzip2'} !~ /$type$/ && $FORM{'renzip2'}) { $error=1; }
my @Albsinfo=@Galleryalb;
my $count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'modalbum'}") >= 0) {
@Alb=split(/ /,$_);
for(my $x=0;$x<=$#Newnames;$x++) { if($Newnames[$x]) { $Alb[12] =~ s/$Oldnames[$x]/$Newnames[$x]/g; } }
$Albsinfo[$count]=join(" ",@Alb);
}
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
if($error) { &fatal_error("$galltxt{'72'}"); }
$yySetLocation = qq~$urlstd;album=$FORM{'modalbum'}$muser;modify=fotoren~;
&redirectexit;
}
sub fotodel {
my $deldir="$galleryabs/$mbcode/$FORM{'modalbum'}";
opendir(DIR,$deldir) || die "$deldir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
foreach(@Elements) { if($_ ne "." && $_ ne ".." && $_ ne "_vti_cnt" && $_ !~ /^$ad_th_name/ && $_ !~ /\.tar/ && $_ !~ /\.zip/) { push(@Fotos,$_); } }
@Fotos=sort(@Fotos);
@Delete=split(/, /,$FORM{'foto'});
foreach(@Delete) { unlink("$deldir/$Fotos[$_]"); unlink("$deldir/$ad_th_name$Fotos[$_]"); }
if($FORM{'zip'}) { unlink("$deldir/$FORM{'zip'}"); }
my @Albsinfo=@Galleryalb;
my $count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'modalbum'}") >= 0) {
my @Alb=split(/ /,$_);
if($Alb[12]) {
my @caps=split(/°°°/,$Alb[12]);
for(my $x=0;$x<=$#Delete;$x++) { splice(@caps,$Delete[$x],1); }
$Alb[12]=join("°°°",@caps);
}
$Albsinfo[$count]=join(" ",@Alb);
}
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'modalbum'}$muser;modify=fotodel~;
&redirectexit;
}
sub editinfo {
my $albstr="$mbcode $FORM{'infalbum'}";
if($FORM{'use_descrip'}) { $albstr.=" $FORM{'use_descrip'}" }
else { $albstr.=" 0" }
if($FORM{'description'}) { $FORM{'description'} =~ s/"/'/g; $FORM{'description'} =~ s/ /_/g; $albstr.=" $FORM{'description'}"; }
else { $albstr.=" 0" }
if($FORM{'use_fotograf'}) { $albstr.=" $FORM{'use_fotograf'}" }
else { $albstr.=" 0" }
if($FORM{'fotografer'}) { $FORM{'fotografer'} =~ s/"/'/g; $FORM{'fotografer'} =~ s/ /_/g; $albstr.=" $FORM{'fotografer'}"; }
else { $albstr.=" 0" }
if($FORM{'use_caption'}) { $albstr.=" $FORM{'use_caption'}" }
else { $albstr.=" 0" }
if($FORM{'use_view'}) { $albstr.=" $FORM{'use_view'}" }
else { $albstr.=" 0" }
if($FORM{'ft_height'}) {
if($FORM{'ft_height'} =~ /\D/) { $albstr.=" 0" }
else { $albstr.=" $FORM{'ft_height'}"; }
}
else { $albstr.=" 0" }
if($FORM{'rownum'}) {
if($FORM{'rownum'} =~ /\D/) { $albstr.=" 0" }
else { $albstr.=" $FORM{'rownum'}"; }
}
else { $albstr.=" 0" }
if($FORM{'use_thumbs'}) { $albstr.=" $FORM{'use_thumbs'}" }
else { $albstr.=" 0" }
if($FORM{'use_zip'}) { $albstr.=" $FORM{'use_zip'}" }
else { $albstr.=" 0" }
my @Albsinfo=@Galleryalb;
my $new=1;
my $count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'infalbum'}") >= 0) { my @Old=split(/ /,$_); splice(@Albsinfo,$count,1,"$albstr $Old[12]\n"); $new=0; }
if($Albsinfo[$count]) { $Albsinfo[$count]="$Albsinfo[$count]\n"; }
$count++;
}
if($new==1) { push(@Albsinfo,"$albstr\n"); }
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Albsinfo;
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'infalbum'}$muser~;
&redirectexit;
}
sub caption {
my $capdir="$galleryabs/$mbcode/$FORM{'modalbum'}";
opendir(DIR,$capdir) || die "$capdir: $!";
my @Elements = readdir(DIR);
closedir(DIR);
foreach(@Elements) { if($_ ne "." && $_ ne ".." && $_ ne "_vti_cnt" && $_ !~ /^$ad_th_name/ && $_ !~ /\.tar/ && $_ !~ /\.zip/) { push(@Fotos,$_); } }
@Fotos=sort(@Fotos);
$FORM{'capfoto'} =~ s/[°]//g;
my @cpts=split(/\, /,$FORM{'capfoto'});
my @cptfiles=split(/, /,$FORM{'foto'});
my @newcaps;
for(my $x=0;$x<=$#cptfiles;$x++) {
if(!$cpts[$x]) { $cpts[$x]=0 }
$newcaps[$x]="$cptfiles[$x]°°$cpts[$x]";
}
my $new=join("°°°",@newcaps);
my @Inform=@Galleryalb;
$count=0;
foreach(@Galleryalb) {
if(index($_,"$mbcode $FORM{'modalbum'}") >= 0) {
my @Albinf=split(" ",$_);
splice(@Albinf,12,1,$new);
$Albinf[12] =~ s/ /°/g;
$Albinf[12] =~ s/"/'/g;
my $infstr=join(" ",@Albinf);
splice(@Inform,$count,1,$infstr);
}
if($Inform[$count]) { $Inform[$count]="$Inform[$count]\n"; }
$count++;
}
fopen(FILE,">$memberdir/galleryalb.txt");
print FILE @Inform;
close(FILE);
$yySetLocation = qq~$urlstd;album=$FORM{'modalbum'}$muser~;
&redirectexit;
}
1;