#!/usr/bin/perl
# CFiles v2.0 beta
# Copyright � 2002-2004 Sean McCrindle
do "./gp32_settings.pl";
use DBI;
use CGI qw/:cgi/;
$CGI::POST_MAX = $upload_max * 1024;
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
##############################################
# Beyond Here Lie Dragons - Don't Edit Below #
##############################################
($dsn) = "DBI:mysql:$SQL_DB:$SQL_Server";
($dbh, $sth);
(@ary);
$ctable = $SQL_Pre . "cats";
$dtable = $SQL_Pre . "deadlinks";
$ftable = $SQL_Pre . "files";
$ltable = $SQL_Pre . "licences";
$mtable = $SQL_Pre . "comments";
$gtable = $SQL_Pre . "groups";
$utable = "users2";
$ptable = $SQL_Pre . "pending";
$stable = $SQL_Pre . "stats";
$fstable = $SQL_Pre . "sends";
$cfversion = "CFiles 2.0-b10";
$dbh = DBI->connect($dsn, $SQL_User, $SQL_Pass, { RaiseError => 1,AutoCommit => 1 }) or die $DBI::errstr;
$cfusth = $dbh->prepare(qq{ SELECT groups FROM $ctable WHERE id=? });
sub frontpage {
if ("$cfpd[1]" eq "") {
precursor();
catlinks($cfhomecat,0);
catlist($cfhomecat,0);
filelist(0,$cfhomecat);
catpage;
cfheader($h39);
content($h39);
footer();
} elsif (($cfpd[1] <= 5) && ($cfpd[1] >= 0)) {
if ($cfpd[1] == 0) {
if ($cfpd[4] ne "") {
if ($cfpd[5] ne "") {
precursor();
if ($ucp[0] == 1) {
catlinks($cfpd[4],1);
fileinfo($cfpd[5],$cfpd[4]);
cfheader($h40);
content($h40);
footer();
} else {cferror();}
} else {
precursor();
if ($ucp[0] == 1) {
catlinks($cfpd[4],0);
catlist($cfpd[4],0);
filelist($cfpd[3],$cfpd[4]);
catpage();
cfheader($h39);
content($h39);
footer();
} else {cferror();}
}
} else {
precursor();
if ($ucp[0] == 1) {
catlinks($cfhomecat,0);
catlist($cfhomecat,0);
filelist($cfpd[3],$cfhomecat);
catpage();
cfheader($h39);
content($h39);
footer();
} else {cferror();}
}
} elsif ($cfpd[1] == 1) {
precursor();
if ($ucp[1] == 1) {
if ($cfpd[2] == 0) {
$licstatus = lic_check($cfpd[5]);
if ($licstatus == 0) {
catlinks($cfpd[4],1);
filedl($cfpd[5]);
cfheader($h41);
content($h41);
footer();
} elsif ($licstatus == 1) {
catlinks($cfpd[4],1);
licprint();
cfheader($h42);
content($h42);
footer();
} elsif ($licstatus == 2) {
catlinks($cfpd[4],1);
filedl($cfpd[5]);
cfheader($h41);
content($h41);
footer();
}
} elsif ($cfpd[2] == 1) {
$licset = &licset();
if ($licset == 0) {
$cfpd[1] = 0;
$cfpd[2] = 0;
$cfpd[3] = 0;
@loc = split(/\?/,$ENV{'HTTP_REFERER'});
$location = "$loc[0]" . "?$cfpd[0],$cfpd[1],$cfpd[2],$cfpd[3],$cfpd[4]";
print "Location: $location\n\n";
} elsif ($licset == 1) {
catlinks($cfpd[4],1);
filedl($cfpd[5]);
cfheader($h41);
content($h41);
footer();
} elsif ($licset == 2) {
$cfpd[1] = 0;
$cfpd[2] = 0;
@loc = split(/\?/,$ENV{'HTTP_REFERER'});
$location = "$loc[0]" . "?$cfpd[0],$cfpd[1],$cfpd[2],$cfpd[3],$cfpd[4]";
print "Location: $location\n\n";
}
} elsif ($cfpd[2] == 2) {
if ($cfpd[5] ne "") {
my ($location, $fsize);
$query = qq{ SELECT url,size FROM $ftable WHERE id=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($cfpd[5]);
$sth->bind_columns(undef, \$location, \$fsize);
$sth->fetch;
$query = qq{ UPDATE $ftable SET downloads=downloads+1 WHERE id=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($cfpd[5]);
$query = qq{ UPDATE $ctable SET filesdown=filesdown+1,bytesdown=bytesdown+$fsize WHERE id=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($cfpd[4]);
$query = qq{ UPDATE $stable SET statdata=statdata+1 WHERE statname='filesdown' };
$sth = $dbh->prepare ( $query );
$sth->execute ();
$query = qq{ UPDATE $stable SET statdata=statdata+$fsize WHERE statname='bytesdown' };
$sth = $dbh->prepare ( $query );
$sth->execute ();
if ($loggedin == 1) {
my ($dls, @downloads);
$query = qq{ SELECT downloads,bytesdown,filesdown FROM $utable WHERE handle=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($user);
$sth->bind_col(1, \$dls);
while ($sth->fetch) { @downloads = split(/:/,$dls); }
push(@downloads,$cfpd[5]);
my $downloads = join(':',@downloads);
$query = qq{ UPDATE $utable SET downloads=?, bytesdown=bytesdown+$fsize, filesdown=filesdown+1 WHERE handle=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($downloads,$user);
}
if ($sqlv == 1) {
$query = qq{ OPTIMIZE TABLES $ftable, $ctable, $stable, $utable };
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->finish ();
}
print "Location: $location\n\n";
}
}
} else {cferror();}
} elsif ($cfpd[1] == 2) {
precursor();
if ($ucp[2] == 1) {
if ($cfpd[4] ne "") {
if ($cfpd[5] ne "") {
catlinks($cfpd[4],1);
rate($cfpd[5]);
}
}
} else {cferror();}
} elsif ($cfpd[1] == 3) {
precursor();
if ($ucp[3] == 1) {
catlinks($cfpd[4],1);
comment($cfpd[5]);
} else {cferror();}
} elsif ($cfpd[1] == 4) {
if ($cfpd[2] == 1) {
$user = param("user");
$pass = param("pass");
my $cf_frem = param("remember");
$loggedin = precursor($user,$pass);
catlinks($cfpd[4],1);
if ($loggedin == 1) {
if ($cf_frem eq "on") {
$c = new CGI::Cookie(-name => 'CF_ID',-value => "$user:$pass",-expires => '+3M',-secure => 0);
} else {
$c = new CGI::Cookie(-name => 'CF_ID',-value => "$user:$pass",-secure => 0);
}
print "Set-Cookie: $c\n";
resultspage("$h117: $h137",$h137);
} elsif ($loggedin == 2) {
cferror("$h70: $m44.");
} elsif ($loggedin == 3) {
cferror("$h70: $m45.");
} elsif ($loggedin == 4) {
cferror("$h70: $m46.");
} elsif ($loggedin == 5) {
cferror("$h70: $m47.");
} else {
cferror("$h70: $m48.");
}
} elsif ($cfpd[2] == 0) {
precursor();
catlinks($cfpd[4],1);
$c = new CGI::Cookie(-name => 'CF_ID',-value => "",-secure => 0);
@utmp = split(/\?/,$ENV{'HTTP_REFERER'});
$loc = "$utmp[0]" . "?$cfpd[0],0,0,0";
print "Set-Cookie: $c\n";
print "Location: $loc\n\n";
}
} elsif ($cfpd[1] == 5) {
precursor();
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_register(); } elsif ($cfpd[2] == 1) { register(); }
}
} elsif (($cfpd[1] <= 39) && ($cfpd[1] >= 6)) {
do "./gp32_admin.pl";
if ($cfpd[1] == 6) {
precursor();
if ($ucp[8] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { &form_addfile(); } elsif ($cfpd[2] == 1) { addfile(); }
} else {cferror();}
} elsif ($cfpd[1] == 7) {
precursor();
if ($ucp[9] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selectfile($cfpd[4],1); } elsif ($cfpd[2] == 1) { form_removefile($cfpd[4]); } elsif ($cfpd[2] == 2) { removefile($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 8) {
precursor();
if ($ucp[10] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selectfile($cfpd[4],2); } elsif ($cfpd[2] == 1) { form_editfile(); } elsif ($cfpd[2] == 2) { editfile(); }
} else {cferror();}
} elsif ($cfpd[1] == 9) {
precursor();
if ($ucp[11] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_imprt($cfpd[4]); } elsif ($cfpd[2] == 1) { imprt($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 10) {
precursor();
if ($ucp[12] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_addcat(); } elsif ($cfpd[2] == 1) { addcat(); }
} else {cferror();}
} elsif ($cfpd[1] == 11) {
precursor();
if ($ucp[13] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_removecat($cfpd[4]); } elsif ($cfpd[2] == 1) { removecat($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 12) {
precursor();
if ($ucp[14] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selectcat($cfpd[4]); } elsif ($cfpd[2] == 1) { form_editcat(); } elsif ($cfpd[2] == 2) { editcat(); }
} else {cferror();}
} elsif ($cfpd[1] == 13) {
precursor();
catlinks($cfpd[4],1);
# if ($ucp[15] == 1) {
if ($cfpd[2] == 0) { form_addlic(); } elsif ($cfpd[2] == 1) { addlic(); }
# } else {cferror();}
} elsif ($cfpd[1] == 14) {
precursor();
if ($ucp[16] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_removelic(2); } elsif ($cfpd[2] == 1) { removelic($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 15) {
precursor();
if ($ucp[17] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selectlic(2); } elsif ($cfpd[2] == 1) { form_editlic($cfpd[4]); } elsif ($cfpd[2] == 2) { editlic($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 16) {
precursor();
if ($ucp[18] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_adduser(); } elsif ($cfpd[2] == 1) { adduser($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 17) {
precursor();
if ($ucp[19] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_finduser(1); } elsif ($cfpd[2] == 1) { form_selectuser(1); } elsif ($cfpd[2] == 2) { form_removeuser(); } elsif ($cfpd[2] == 3) { removeuser(); }
} else {cferror();}
} elsif ($cfpd[1] == 18) {
precursor();
if ($ucp[20] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_finduser(2); } elsif ($cfpd[2] == 1) { form_selectuser(2); } elsif ($cfpd[2] == 2) { form_edituser(); } elsif ($cfpd[2] == 3) { edituser(); }
} else {cferror();}
} elsif ($cfpd[1] == 19) {
precursor();
if ($ucp[21] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_addgroup(); } elsif ($cfpd[2] == 1) { addgroup(); }
} else {cferror();}
} elsif ($cfpd[1] == 20) {
precursor();
if ($ucp[22] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selgroup(1); } elsif ($cfpd[2] == 1) { form_removegroup(); } elsif ($cfpd[2] == 2) { removegroup(); }
} else {cferror();}
} elsif ($cfpd[1] == 21) {
precursor();
if ($ucp[23] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selgroup(2); } elsif ($cfpd[2] == 1) { form_editgroup(); } elsif ($cfpd[2] == 2) { editgroup($cfpd[4]); }
} else {cferror();}
} elsif ($cfpd[1] == 22) {
precursor();
if ($ucp[6] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selrevs("S"); } elsif ($cfpd[2] == 1) { form_revsub(); } elsif ($cfpd[2] == 2) { revsub(); }
} else {cferror();}
} elsif ($cfpd[1] == 23) {
precursor();
if ($ucp[7] == 1) {
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_selrevs("U"); } elsif ($cfpd[2] == 1) { form_revupd(); } elsif ($cfpd[2] == 2) { revupd(); }
} else {cferror();}
} elsif ($cfpd[1] == 24) {
precursor();
catlinks($cfpd[4],1);
if ($loggedin == 1) {
if ($cfpd[2] == 0) { form_profile(); } elsif ($cfpd[2] == 1) { profile(); }
} else {cferror();}
} elsif ($cfpd[1] == 25) {
precursor();
catlinks($cfpd[4],1);
if ($loggedin == 1) {
if ($cfpd[2] == 0) { form_subfile(); } elsif ($cfpd[2] == 1) { subfile(); }
} else {cferror();}
} elsif ($cfpd[1] == 26) {
precursor();
catlinks($cfpd[4],1);
if ($loggedin == 1) {
if ($cfpd[2] == 0) { form_selectfile($cfpd[4],"3"); } elsif ($cfpd[2] == 1) { form_updfile(); } elsif ($cfpd[2] == 2) { updfile(); }
} else {cferror();}
} elsif ($cfpd[1] == 27) {
precursor();
catlinks($cfpd[4],1);
if ($ucp[27] == 1) { deadlink_report(); } else { cferror(); }
} elsif ($cfpd[1] == 28) {
precursor();
catlinks($cfpd[4],1);
if ($ucp[28] == 1) {
if ($cfpd[2] == 0) { form_expimp(); } elsif ($cfpd[2] == 1) {
if ($cfpd[3] == 0) { prompt_impdb(); } elsif ($cfpd[3] == 1) { impdb(); } else {cferror();}
} elsif ($cfpd[2] == 2) {
if ($cfpd[3] == 0) { expdb(); } else {cferror();}
} else {cferror();}
} else {cferror();}
} elsif ($cfpd[1] == 29) {
precursor();
catlinks($cfpd[4],1);
$test = "test $ucp[29]";
if ($ucp[29] == 1) {
if ($cfpd[2] == 0) { form_uemail(); } elsif ($cfpd[2] == 1) { uemail(); } else { cferror(); }
} else {cferror();}
} elsif ($cfpd[1] == 30) {
precursor();
catlinks($cfpd[4],1);
if ($cfpd[2] == 0) { form_sendpass(); } elsif ($cfpd[2] == 1) { sendpass(); } else { cferror(); }
} elsif ($cfpd[1] == 31) {
precursor();
catlinks($cfpd[4],1);
if ($ucp[27] == 1) { gen_deadlinks(); } else { cferror(); }
} elsif ($cfpd[1] == 32) {
precursor();
catlinks($cfpd[4],1);
if ($loggedin == 1) { if ($cfpd[2] == 0) { form_report_deadlink(); } elsif ($cfpd[2] == 1) { report_deadlink(); } else { cferror(); } } else { cferror(); }
} else { &resultspage("$h70: $h168",$h168); }
} elsif (($cfpd[1] <= 41) && ($cfpd[1] >= 40)) {
if ($cfpd[1] == 40) {
precursor();
catlinks($cfpd[4],1);
search();
} elsif ($cfpd[1] == 41) {
cflanguage();
}
} else { &resultspage("$h70: $h168",$h168); }
}
sub stats {
my ($cfsdate,$id,$fname,$catid,$cfdt,$stdata,$cfsdata,$mday,$mon,$year,$cfsdate, $cfs_sscr);
($mostrecent, $noteworthy, $topdownloads, $toprated);
$stdata = grabfile("$template_path/stats_mostrecent.$template_ext");
my $query = qq{ SELECT id,$statnames,fdate,catid,screenshot FROM $ftable ORDER BY fdate DESC LIMIT $numrecent };
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_columns(undef, \$id, \$fname, \$cfdt, \$catid, \$cfs_sscr);
while ($sth->fetch) {
if (length($fname) > $statchars) { $fname = substr($fname,0,$statchars) . $stattrunc; }
(undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = gmtime($cfdt);
$year = substr($year,1,3);
$mday = sprintf("%02d",$mday);
$mon = sprintf("%02d",$mon+1);
$cfsdate = $date_format;
$cfsdate =~ s/DD/$mday/goc;
$cfsdate =~ s/MM/$mon/goc;
$cfsdate =~ s/YYYY/$year/goc;
$cfsdata = $stdata;
$cfsdata =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cfsdata =~ s/\%\%MOSTRECENTVALUE\%\%/$cfsdate/goc;
$cfsdata =~ s/\%\%MRURL\%\%/?$cfpd[0],0,0,0,$catid,$id/goc;
$cfsdata =~ s/\%\%MRNAME\%\%/$fname/goc;
$cfsdata =~ s/\%\%SSURL\%\%/$ss_url$cfs_sscr/goc;
$mostrecent .= $cfsdata;
}
$stdata = grabfile("$template_path/stats_noteworthy.$template_ext");
my $query = qq{ SELECT id,$statnames,comments,catid FROM $ftable ORDER BY comments DESC LIMIT $numnoteworthy};
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_columns(undef, \$id, \$fname, \$cfdt, \$catid);
while ($sth->fetch) {
if (length($fname) > $statchars) { $fname = substr($fname,0,$statchars) . $stattrunc; }
$cfsdata = $stdata;
$cfsdata =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cfsdata =~ s/\%\%NOTEWORTHYVALUE\%\%/$cfdt/goc;
$cfsdata =~ s/\%\%NWURL\%\%/?$cfpd[0],0,0,0,$catid,$id/goc;
$cfsdata =~ s/\%\%NWNAME\%\%/$fname/goc;
$noteworthy .= $cfsdata;
}
$stdata = grabfile("$template_path/stats_topdownloads.$template_ext");
my $query = qq{ SELECT id,$statnames,downloads,catid,screenshot FROM $ftable ORDER BY downloads DESC LIMIT $numdownloads};
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_columns(undef, \$id, \$fname, \$cfdt, \$catid, \$cfs_sscr);
while ($sth->fetch) {
if (length($fname) > $statchars) { $fname = substr($fname,0,$statchars) . $stattrunc; }
$cfdt = commify($cfdt);
$cfsdata = $stdata;
$cfsdata =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cfsdata =~ s/\%\%TOPDOWNLOADSVALUE\%\%/$cfdt/goc;
$cfsdata =~ s/\%\%TDURL\%\%/?$cfpd[0],0,0,0,$catid,$id/goc;
$cfsdata =~ s/\%\%TDNAME\%\%/$fname/goc;
$cfsdata =~ s/\%\%SSURL\%\%/$ss_url$cfs_sscr/goc;
$topdownloads .= $cfsdata;
}
$stdata = grabfile("$template_path/stats_toprated.$template_ext");
my $query = qq{ SELECT id,$statnames,rating,catid FROM $ftable ORDER BY rating DESC LIMIT $numrated};
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_columns(undef, \$id, \$fname, \$cfdt, \$catid);
while ($sth->fetch) {
if (length($fname) > $statchars) { $fname = substr($fname,0,$statchars) . $stattrunc; }
$cfsdata = $stdata;
$cfsdata =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cfsdata =~ s/\%\%TOPRATEDVALUE\%\%/$cfdt/goc;
$cfsdata =~ s/\%\%TRURL\%\%/?$cfpd[0],0,0,0,$catid,$id/goc;
$cfsdata =~ s/\%\%TRNAME\%\%/$fname/goc;
$toprated .= $cfsdata;
}
}
sub stattblchk {
my $query = qq{ SELECT * FROM $stable };
$sth = $dbh->prepare ( $query );
my($cf_sname,$cf_sdata);
$sth->execute ();
$sth->bind_columns(undef, \$cf_sname, \$cf_sdata);
while ($sth->fetch) {
if ($cf_sname eq "filesdown") {
$tfdown = commify($cf_sdata);
if ($cf_sdata == 1) {$tfdown .= " $h36";} else {$tfdown .= " $h37";}
} elsif ($cf_sname eq "bytesdown") {
$tbdown = filesize($cf_sdata);
} elsif ($cf_sname eq "members") {
$memnum = commify($cf_sdata);
$memnum .= " $h148";
}
$totaldls = "$h141 $tfdown ($tbdown)";
}
}
sub form_register {
$content = grabfile("$template_path/form_register.$template_ext");
$formurl = "?$cfpd[0],5,1";
$content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$content =~ s/\%\%REGMSG\%\%/$m13/goc;
$content =~ s/\%\%BYTES\%\%/$CF_clsize/goc;
$content =~ s/\%\%FILES\%\%/$CF_clfiles/goc;
$content =~ s/\%\%CATDESC\%\%/$catldesc/goc;
$content =~ s/\%\%FORMURL\%\%/$formurl/goc;
$content =~ s/\%\%CATLINKS\%\%/$catlinks/goc;
$content =~ s/\%\%MESSAGE\%\%/$_[0]/goc;
$content =~ s/\%\%FNVAL\%\%/$_[1]/goc;
$content =~ s/\%\%LNVAL\%\%/$_[2]/goc;
$content =~ s/\%\%HVAL\%\%/$_[3]/goc;
$content =~ s/\%\%EVAL\%\%/$_[4]/goc;
$content =~ s/\%\%FNNAME\%\%/$h67/goc;
$content =~ s/\%\%LNNAME\%\%/$h68/goc;
$content =~ s/\%\%HNAME\%\%/$h8/goc;
$content =~ s/\%\%PNAME\%\%/$h9/goc;
$content =~ s/\%\%PNAME2\%\%/$h75/goc;
$content =~ s/\%\%ENAME\%\%/$h71/goc;
$content =~ s/\%\%REGNAME\%\%/$h2/goc;
&cfheader($h2);
&content($h2);
&footer();
}
sub register {
my $cf_rfn = param("fname");
my $cf_rln = param("lname");
my $cf_run = param("handle");
my $cf_rem = param("email");
if ($cf_rfn ne "") {
if ($cf_rln ne "") {
if ($cf_run ne "") {
if ($cf_rem ne "") {
$hlen = length($cf_run);
$_ = $cf_run;
$hch = m/\W/;
if (($hlen >= 2) && ($hch == 0)) {
my $uid;
$query = qq{ SELECT COUNT(id) FROM $utable WHERE handle=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($cf_run);
$sth->bind_col(1, \$uid);
$sth->fetch;
if ($uid == 0) {
$query = qq{ SELECT COUNT(id) FROM $utable WHERE email=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($cf_rem);
$sth->bind_col(1, \$uid);
$sth->fetch;
if ($uid == 0) {
my $password = ew_passgen(7);
my $cf_mcont = grabfile("$template_path/email_register.$template_ext");
$cf_mcont =~ s/\%\%SUBJECT\%\%/$h164/goc;
$cf_mcont =~ s/\%\%SITENAME\%\%/$sitename/goc;
$cf_mcont =~ s/\%\%FIRSTNAME\%\%/$cf_rfn/goc;
$cf_mcont =~ s/\%\%LASTNAME\%\%/$cf_rln/goc;
$cf_mcont =~ s/\%\%UNAME\%\%/$h8/goc;
$cf_mcont =~ s/\%\%PNAME\%\%/$h9/goc;
$cf_mcont =~ s/\%\%USERNAME\%\%/$cf_run/goc;
$cf_mcont =~ s/\%\%PASSWORD\%\%/$password/goc;
$cf_mcont =~ s/\%\%HEADER\%\%/$h164/goc;
$cf_mcont =~ s/\%\%MESSAGE1\%\%/$m59/goc;
$cf_mcont =~ s/\%\%MESSAGE2\%\%/$m58/goc;
require "$libpath/Bulkmail.pm";
$cf_mres = mailer($cf_rem,$cf_mcont,$h164);
if ($cf_mres eq "OK") {
$query = qq{ SELECT groupname FROM $gtable WHERE defreg='1' ORDER BY groupname };
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_col(1, \$uid);
while ($sth->fetch) { push(@formgroups,$uid); }
$formgroups = join(',',@formgroups);
$date = time;
$query = qq{ INSERT INTO $utable (id,firstname,lastname,handle,password,email,udate,groups) VALUES ('0',?,?,?,?,?,?,?) };
$sth = $dbh->prepare ( $query );
$sth->execute ($cf_rfn,$cf_rln,$cf_run,$password,$cf_rem,$date,$formgroups);
$query = qq{ UPDATE $stable SET statdata=statdata+1 WHERE statname='members' };
$sth = $dbh->prepare ( $query );
$sth->execute ();
if ($reg_emailnote == 1) {
$cf_mcont = grabfile("$template_path/email_regnote.$template_ext");
$cf_mcont =~ s/\%\%SUBJECT\%\%/$sitename $h153/goc;
$cf_mcont =~ s/\%\%FIRSTNAME\%\%/$cf_rfn/goc;
$cf_mcont =~ s/\%\%LASTNAME\%\%/$cf_rln/goc;
$cf_mcont =~ s/\%\%UNAME\%\%/$h8/goc;
$cf_mcont =~ s/\%\%PNAME\%\%/$h9/goc;
$cf_mcont =~ s/\%\%USERNAME\%\%/$cf_run/goc;
$cf_mcont =~ s/\%\%EMNAME\%\%/$h71/goc;
$cf_mcont =~ s/\%\%EMAIL\%\%/$cf_rem/goc;
$cf_mcont =~ s/\%\%PASSWORD\%\%/$password/goc;
$cf_mcont =~ s/\%\%HEADER\%\%/$h153/goc;
mailer($cf_amail,$cf_mcont,$h153);
}
$pagetitle =~ s/\%\%OPERATION\%\%/$_[0]/goc;
&resultspage("$h117: $h138 - $cf_run. $m50 $cf_rem",$h138);
} else {form_register("$h70: $m70.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m2.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m3.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m5.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m6.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m9.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m10.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
} else {form_register("$h70: $m11.",$cf_rfn,$cf_rln,$cf_run,$cf_rem);}
}
sub ew_passgen {
my $passwordsize = shift;
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..$passwordsize;
return $randpassword;
}
sub cfheader {
print "Content-type: text/html\n\n";
$pagetitle =~ s/\%\%OPERATION\%\%/$_[0]/goc;
my $cfhead = grabfile("$template_path/header.$template_ext");
$cfhead =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cfhead =~ s/\%\%RSSURL\%\%/$rss_url/goc;
$cfhead =~ s/\%\%PAGETITLE\%\%/$pagetitle/goc;
print "$test\n";
print $cfhead;
}
sub footer {
my $cffoot = grabfile("$template_path/footer.$template_ext");
$cffoot =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cffoot =~ s/\%\%THEMEDESIGN\%\%/$h82/goc;
print $cffoot;
}
sub content {
if ($statswitch == 1) { stats(); }
if ($user ne "") { $cf_wmsg = "Browsing as $user"; } else { $cf_wmsg = "Browsing as Guest"; }
my $cffp = grabfile("$template_path/main.$template_ext");
$cffp =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cffp =~ s/\%\%POWERED\%\%/$h51/goc;
$cffp =~ s/\%\%CFVERSION\%\%/$cfversion/goc;
$cffp =~ s/\%\%FNNAME\%\%/$h146/goc;
$cffp =~ s/\%\%TITLENAME\%\%/$h165/goc;
$cffp =~ s/\%\%WELCOME\%\%/$cf_wmsg/goc;
$cffp =~ s/\%\%ANAME\%\%/$h63/goc;
$cffp =~ s/\%\%DESCNAME\%\%/$h65/goc;
$cffp =~ s/\%\%SRCHNAME\%\%/$h7/goc;
$cffp =~ s/\%\%LFORMURL\%\%/?$cfpd[0],41,0,0,$cfpd[4]/goc;
$cffp =~ s/\%\%SFORMURL\%\%/?$cfpd[0],40,0,0,$cfpd[4]/goc;
$cffp =~ s/\%\%RATINGSNAME\%\%/$h6/goc;
$cffp =~ s/\%\%RATINGS\%\%/$toprated/goc;
$cffp =~ s/\%\%DOWNLOADSNAME\%\%/$h5/goc;
$cffp =~ s/\%\%DOWNLOADS\%\%/$topdownloads/goc;
$cffp =~ s/\%\%LATESTNAME\%\%/$h3/goc;
$cffp =~ s/\%\%LATEST\%\%/$mostrecent/goc;
$cffp =~ s/\%\%COMMENTSNAME\%\%/$h4/goc;
$cffp =~ s/\%\%COMMENTS\%\%/$noteworthy/goc;
$cffp =~ s/\%\%MESSAGE\%\%/$_[1]/goc;
$cffp =~ s/\%\%PAGETITLE\%\%/$_[0]/goc;
$cffp =~ s/\%\%FUNCTIONS\%\%/$funcbox/goc;
$cffp =~ s/\%\%CONTENT\%\%/$content/goc;
print $cffp;
}
sub cferror {
if ("$_[0]" ne "") { $cferr = "$_[0]"; } else { $cferr = "$m1."; }
$cont = "$h56";
$content = grabfile("$template_path/page_resultspage.$template_ext");
$content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$content =~ s/\%\%BYTES\%\%/$CF_clsize/goc;
$content =~ s/\%\%FILES\%\%/$CF_clfiles/goc;
$content =~ s/\%\%CATDESC\%\%/$catldesc/goc;
$content =~ s/\%\%CONTINUE\%\%/$cont/goc;
$content =~ s/\%\%CATLINKS\%\%/$catlinks/goc;
$content =~ s/\%\%MESSAGE\%\%/$cferr/goc;
&cfheader($h70);
&content($h70);
&footer();
}
sub resultspage {
if ("$cfpd[5]" ne "") { $cont = "$h56"; } else { $cont = "$h56"; }
$content = grabfile("$template_path/page_resultspage.$template_ext");
$content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$content =~ s/\%\%BYTES\%\%/$CF_clsize/goc;
$content =~ s/\%\%FILES\%\%/$CF_clfiles/goc;
$content =~ s/\%\%CATDESC\%\%/$catldesc/goc;
$content =~ s/\%\%CONTINUE\%\%/$cont/goc;
$content =~ s/\%\%CATLINKS\%\%/$catlinks/goc;
$content =~ s/\%\%MESSAGE\%\%/$_[0]/goc;
cfheader($_[1]);
content($_[1]);
footer();
}
sub mailer {
open(MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: $_[0]\n";
print MAIL "From: $mailaddress ($sitename)\n";
print MAIL "Subject: $_[2]\n\n";
print MAIL "$_[1]";
close(MAIL);
$bulk = Mail::Bulkmail->new(
"Smtp" => "gp2x.de",
"Domain" => "www.gp2x.de",
"LIST" => [$_[0]],
"From" => "$mailaddress ($sitename)",
"Subject" => "$_[2]",
"Message" => "$_[1]",
);
$bulk->BAD(\@bad);
Mail::Bulkmail::bulkmail($bulk);
$test = "test @bad" . Mail::Bulkmail::error();
if ((Mail::Bulkmail::error() ne "") || (@bad > 0)) {return Mail::Bulkmail::error();} else {return "OK";}
}
sub catpage {
$content = grabfile("$template_path/page_catpage.$template_ext");
$content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$content =~ s/\%\%TOTALDLS\%\%/$totaldls/goc;
$content =~ s/\%\%CATBOX\%\%/$catbox/goc;
$content =~ s/\%\%FILEBOX\%\%/$filebox/goc;
$content =~ s/\%\%BYTES\%\%/$CF_clsize/goc;
$content =~ s/\%\%FILES\%\%/$CF_clfiles/goc;
$content =~ s/\%\%CATDESC\%\%/$catldesc/goc;
$content =~ s/\%\%CATLINKS\%\%/$catlinks/goc;
$content =~ s/\%\%MESSAGE\%\%/$message/goc;
}
sub ucperms {
my (@perms,$cf_grps,@ups,$cgroup);
$cfusth->execute($_[0]);
$cfusth->bind_col(1, \$cf_grps);
while ($cfusth->fetch) {
foreach $cgroup (split(/\,/,$cf_grps)) {
foreach $uperm (@uperms) {
@ups = split(/:/, $uperm);
if ($cgroup eq $ups[0]) {
if ($ups[1] == 1) {$perms[0] = 1;} # View
if ($ups[2] == 1) {$perms[1] = 1;} # Download
if ($ups[3] == 1) {$perms[2] = 1;} # Rate
if ($ups[4] == 1) {$perms[3] = 1;} # Add Comment
if ($ups[5] == 1) {$perms[4] = 1;} # Remove Comment
if ($ups[6] == 1) {$perms[5] = 1;} # Edit Comments
if ($ups[7] == 1) {$perms[6] = 1;} # Review Submissions
if ($ups[8] == 1) {$perms[7] = 1;} # Review Updates
if ($ups[9] == 1) {$perms[8] = 1;} # Add File
if ($ups[10] == 1) {$perms[9] = 1;} # Remove File
if ($ups[11] == 1) {$perms[10] = 1;} # Edit File
if ($ups[12] == 1) {$perms[11] = 1;} # Import Files
if ($ups[13] == 1) {$perms[12] = 1;} # Add Cat
if ($ups[14] == 1) {$perms[13] = 1;} # Remove Cat
if ($ups[15] == 1) {$perms[14] = 1;} # Edit Cat
if ($ups[16] == 1) {$perms[15] = 1;} # Add Licence
if ($ups[17] == 1) {$perms[16] = 1;} # Remove Licence
if ($ups[18] == 1) {$perms[17] = 1;} # Edit Licence
if ($ups[19] == 1) {$perms[18] = 1;} # Add User
if ($ups[20] == 1) {$perms[19] = 1;} # Remove User
if ($ups[21] == 1) {$perms[20] = 1;} # Edit User
if ($ups[22] == 1) {$perms[21] = 1;} # Add Group
if ($ups[23] == 1) {$perms[22] = 1;} # Remove Group
if ($ups[24] == 1) {$perms[23] = 1;} # Edit Group
if ($ups[25] == 1) {$perms[24] = 1;} # Add Group
if ($ups[26] == 1) {$perms[25] = 1;} # Remove Group
if ($ups[27] == 1) {$perms[26] = 1;} # Edit Group
if ($ups[28] == 1) {$perms[27] = 1;} # Deadlink Report
if ($ups[29] == 1) {$perms[28] = 1;} # Export/Import
if ($ups[30] == 1) {$perms[29] = 1;} # Email Users
}
}
}
}
return @perms
}
sub catlist {
my ($cf_cid,$cf_ccn,$cf_cdsc,$cf_csz,$cf_cfs,$cname,$cdata1,$cfiles,$cf_clist,$cf_cdate,$cf_updd,$cf_addd,$cf_od,$cf_nt);
my (@cperms,@cf_clist,@cname) = ();
my $cf_subcs = 0;
my $query = qq{ SELECT id,catname,description,size,files,cdate,upddate FROM $ctable WHERE parentid='$_[0]' ORDER BY catname };
$sth = $dbh->prepare ( $query );
$sth->execute ();
$sth->bind_columns(undef, \$cf_cid, \$cf_ccn, \$cf_cdsc, \$cf_csz, \$cf_cfs, \$cf_cdate, \$cf_updd);
while ($sth->fetch) { push(@cf_clist, "$cf_cid�$cf_ccn�$cf_cdsc�$cf_csz�$cf_cfs�$cf_cdate�$cf_updd�$cf_addd"); $cf_subcs++;}
$cf_cd = time - $cf_newdays * 86400;
$cdata = grabfile("$template_path/row_cat.$template_ext");
if ($catcolumns == 1) {
$catbox = grabfile("$template_path/box_cats.$template_ext");
} elsif ($catcolumns == 2) {
if (($cf_subcs > 0) && ($cf_subcs > $splitcatsafter)) {
$catbox = grabfile("$template_path/box_cats_split.$template_ext");
if ($cf_subcs > 1) {$cf_subcs = $cf_subcs / 2;}
$cf_a = $cf_subcs;
while ($cf_a > 0) {
($cf_cid,$cf_ccn,$cf_cdsc,$cf_csz,$cf_cfs,$cf_cdate,$cf_updd) = split(/\�/,$cf_clist[0]);
@cperms = ucperms($cf_cid);
if ($cperms[0] == 1) {
if ($cf_cdate > $cf_cd) {$cf_nt = $cf_newtag;} else {$cf_nt = "";}
if ($cf_updd > $cf_cd) {$cf_od = $cf_updtag;} else {$cf_od = "";}
$cfiles = commify($cf_cfs);
$cf_csz = filesize($cf_csz);
if ($cf_cfs == 1) { $cfiles .= " $h36"; } else { $cfiles .= " $h37"; }
@cname = split(/:/, $cf_ccn);
$cname = pop(@cname);
$cdata1 = $cdata;
$cdata1 =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cdata1 =~ s/\%\%SIZE\%\%/$cf_csz/goc;
$cdata1 =~ s/\%\%FILES\%\%/$cfiles/goc;
$cdata1 =~ s/\%\%NEWTAG\%\%/$cf_nt/goc;
$cdata1 =~ s/\%\%UPDATEDTAG\%\%/$cf_od/goc;
$cdata1 =~ s/\%\%CATDESC\%\%/$cf_cdsc/goc;
$cdata1 =~ s/\%\%CATNAME\%\%/
$cname/goc;
$cdata1 =~ s/\%\%CATLINK\%\%/?$cfpd[0],0,0,0,$cf_cid/goc;
$cf_clist1 .= $cdata1;
}
shift(@cf_clist);
$cf_a--;
}
} else {$catbox = grabfile("$template_path/box_cats.$template_ext");}
}
foreach $cf_cat (@cf_clist) {
($cf_cid,$cf_ccn,$cf_cdsc,$cf_csz,$cf_cfs,$cf_cdate,$cf_updd) = split(/\�/,$cf_cat);
@cperms = ucperms($cf_cid);
if ($cperms[0] == 1) {
if ($cf_cdate > $cf_cd) {$cf_nt = $cf_newtag;} else {$cf_nt = "";}
if ($cf_updd > $cf_cd) {$cf_od = $cf_updtag;} else {$cf_od = "";}
$cfiles = commify($cf_cfs);
$cf_csz = filesize($cf_csz);
if ($cf_cfs == 1) { $cfiles .= " $h36"; } else { $cfiles .= " $h37"; }
@cname = split(/:/, $cf_ccn);
$cname = pop(@cname);
$cdata1 = $cdata;
$cdata1 =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$cdata1 =~ s/\%\%SIZE\%\%/$cf_csz/goc;
$cdata1 =~ s/\%\%FILES\%\%/$cfiles/goc;
$cdata1 =~ s/\%\%NEWTAG\%\%/$cf_nt/goc;
$cdata1 =~ s/\%\%UPDATEDTAG\%\%/$cf_od/goc;
$cdata1 =~ s/\%\%CATDESC\%\%/$cf_cdsc/goc;
$cdata1 =~ s/\%\%CATNAME\%\%/
$cname/goc;
$cdata1 =~ s/\%\%CATLINK\%\%/?$cfpd[0],0,0,0,$cf_cid/goc;
$cf_clist2 .= $cdata1;
}
}
$catbox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$catbox =~ s/\%\%CNAME\%\%/$h58/goc;
$catbox =~ s/\%\%SNAME\%\%/$h31/goc;
$catbox =~ s/\%\%FNAME\%\%/$h37/goc;
$catbox =~ s/\%\%CATEGORIES1\%\%/$cf_clist1/goc;
$catbox =~ s/\%\%CATEGORIES2\%\%/$cf_clist2/goc;
}
sub catlinks {
my (@tmpcatn, $cname, $cf_cid);
my @pnames = split(/:/, $CF_catname);
if ($_[1] == 0) {$cname = pop(@pnames);}
my $cf1sth = $dbh->prepare(qq{ SELECT id FROM $ctable WHERE catname=? });
foreach $name (@pnames) {
push(@tmpcatn, $name);
$cf1sth->execute(join(':', @tmpcatn));
$cf1sth->bind_col(1, \$cf_cid);
while ($cf1sth->fetch) { $catlinks .= "$name : "; }
}
if ($_[1] == 0) { $catlinks .= $cname; }
}
sub filelist {
my (@cf_slinks,$cf_nt,$cf_od,$cf_updd,$cf_addd,$cfsdate,$cf_sp,$rfdata,$cf_flist,$cf_id,$cf_fname,$cf_date,$cf_size,$cf_dls,$cf_rating,$cf_cdsc,$cf_sscr,$cf_coms,$mday,$mon,$year);
my $s1name = "$h30";
my $s2name = "$h29";
my $s3name = "$h31";
my $s4name = "$h32";
my $s5name = "$h33";
my $s6name = "$h34";
if ($_[0] == 0) {
$sortby = "title";
$s1name = $h30;
} elsif ($_[0] == 1) {
$sortby = "fdate DESC";
$s2name = $h29;
} elsif ($_[0] == 2) {
$sortby = "size DESC";
$s3name = $h31;
} elsif ($_[0] == 3) {
$sortby = "rating DESC";
$s4name = $h32;
} elsif ($_[0] == 4) {
$sortby = "downloads DESC";
$s5name = $h33;
} elsif ($_[0] == 5) {
$sortby = "comments DESC";
$s6name = $h34;
}
my $fdata = grabfile("$template_path/row_file.$template_ext");
my $cf_fs = $cfpd[2] * $numsearchresults;
my ($cf_tr,$cf_fr) = 0;
my $cf_cd = time - $cf_newdays * 86400;
my $query = qq{ SELECT id,$filelist_names,fdate,size,downloads,rating,description,screenshot,comments,upddate FROM $ftable WHERE catid=? ORDER BY $sortby };
$sth = $dbh->prepare ( $query );
$sth->execute ($_[1]);
$sth->bind_columns(undef, \$cf_id, \$cf_fname, \$cf_date, \$cf_size, \$cf_dls, \$cf_rating, \$cf_cdsc, \$cf_sscr, \$cf_coms, \$cf_updd);
while ($sth->fetch) {
if (($cf_tr >= $cf_fs) && ($cf_fr <= $numsearchresults)) {
if (length($cf_cdsc) > $filedesc_chars) { $cf_cdsc = substr($cf_cdsc, 0, $filedesc_chars) . $filedesc_trunc; }
if (length($cf_fname) > $filelist_chars) { $cf_fname = substr($cf_fname, 0, $filelist_chars) . $filelist_trunc; }
(undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = gmtime($cf_date);
$year += 1900;
$mday = sprintf("%02d",$mday);
$mon = sprintf("%02d",$mon+1);
$cfsdate = $date_format;
$cfsdate =~ s/DD/$mday/goc;
$cfsdate =~ s/MM/$mon/goc;
$cfsdate =~ s/YYYY/$year/goc;
$cf_size = filesize($cf_size);
$cf_dls = commify($cf_dls);
if ($cf_date > $cf_cd) {$cf_nt = $cf_newtag;} else {$cf_nt = "";}
if ($cf_updd > $cf_cd) {$cf_od = $cf_updtag;} else {$cf_od = "";}
$cf_cdsc =~ s/\015?\012/
/g;
$rfdata = $fdata;
$rfdata =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$rfdata =~ s/\%\%FILENAME\%\%/$cf_fname/goc;
$rfdata =~ s/\%\%NEWTAG\%\%/$cf_nt/goc;
$rfdata =~ s/\%\%UPDATEDTAG\%\%/$cf_od/goc;
$rfdata =~ s/\%\%FILELINK\%\%/?$cfpd[0],0,0,0,$_[1],$cf_id/goc;
$rfdata =~ s/\%\%DATE\%\%/$cfsdate/goc;
$rfdata =~ s/\%\%SIZE\%\%/$cf_size/goc;
$rfdata =~ s/\%\%DOWNLOADS\%\%/$cf_dls/goc;
$rfdata =~ s/\%\%RATING\%\%/$cf_rating/goc;
$rfdata =~ s/\%\%COMMENTS\%\%/$cf_coms/goc;
$rfdata =~ s/\%\%DESCRIPTION\%\%/$cf_cdsc/goc;
$rfdata =~ s/\%\%SSURL\%\%/$ss_url$cf_sscr/goc;
$cf_flist .= $rfdata;
$cf_tr++;
$cf_fr++;
} else { $cf_tr++; }
}
if ($cf_tr > $numsearchresults) { $cf_sp = $cf_tr / $numsearchresults; } else { $cf_sp = 1; }
$cf_sp = roundup($cf_sp);
if ($cf_sp > 1) {
while ($cf_sp > 0) {
my $t = $cf_sp - 1;
if ($t == $cfpd[2]) { push(@cf_slinks, $cf_sp); } else { push(@cf_slinks, "$cf_sp"); }
$cf_sp--;
}
@cf_slinks = reverse @cf_slinks;
$cf_slinks = join(', ', @cf_slinks);
$cf_slinks = "$h151 $cf_slinks";
}
if ($cf_flist ne "") {
$filebox = grabfile("$template_path/box_files.$template_ext");
$filebox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$filebox =~ s/\%\%NEXT\%\%/$cf_slinks/goc;
$filebox =~ s/\%\%S1NAME\%\%/$s1name/goc;
$filebox =~ s/\%\%S2NAME\%\%/$s2name/goc;
$filebox =~ s/\%\%S3NAME\%\%/$s3name/goc;
$filebox =~ s/\%\%S4NAME\%\%/$s4name/goc;
$filebox =~ s/\%\%S5NAME\%\%/$s5name/goc;
$filebox =~ s/\%\%S6NAME\%\%/$s6name/goc;
$filebox =~ s/\%\%CATDLS\%\%/$catdls/goc;
$filebox =~ s/\%\%FILES\%\%/$cf_flist/goc;
}
}
sub timeform {
if ($_[0] > 86400) {
$_[0] = $_[0] / 24 / 60 / 60;
$_[0] = sprintf("%1.2f",$_[0]);
@_ = split(/\./,$_[0]);
return "$_[0] days, " . sprintf("%1.f",$_[1]) . " hours"
} elsif ($_[0] > 3600) {
$_[0] = $_[0] / 60 / 60;
$_[0] = sprintf("%1.2f",$_[0]);
@_ = split(/\./,$_[0]);
return "$_[0] hours, " . sprintf("%1.f",$_[1]) . " mins"
} elsif ($_[0] > 60) {
$_[0] = $_[0] / 60;
$_[0] = sprintf("%1.2f",$_[0]);
@_ = split(/\./,$_[0]);
return "$_[0] mins, " . sprintf("%1.f",$_[1]) . " secs"
} else {return sprintf("%1.1f",$_[0]) . " secs"}
}
sub fileinfo {
my ($title,$cfsdata,$comdata,$comline,$fileid,$filename,$date,$size,$downloads,$rating,$description,$author,$website,$version,$licence,$ssname,$comments,$rating_raw,$mday,$mon,$year,$cf_updd,$cf_od,$cf_oss,$cost);
my $query = qq{ SELECT id,filename,fdate,size,downloads,rating,description,author,website,version,licence,screenshot,comments,rating_raw,title,upddate,oss,cost FROM $ftable WHERE id=? };
$sth = $dbh->prepare ( $query );
$sth->execute ($_[0]);
$sth->bind_columns(undef, \$fileid, \$filename, \$date, \$size, \$downloads, \$rating, \$description, \$author, \$website, \$version, \$licence, \$ssname, \$comments, \$rating_raw, \$title, \$cf_updd, \$cf_oss, \$cost);
while ($sth->fetch) {
(undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = gmtime($date);
$year += 1900;
$mday = sprintf("%02d",$mday);
$mon = sprintf("%02d",$mon+1);
$cfsdate = $date_format;
$cfsdate =~ s/DD/$mday/goc;
$cfsdate =~ s/MM/$mon/goc;
$cfsdate =~ s/YYYY/$year/goc;
$cf_dtime1 = timeform($size / 5500);
$cf_dtime2 = timeform($size / 13000);
$cf_dtime3 = timeform($size / 27000);
$cf_dtime4 = timeform($size / 52000);
$cf_dtime5 = timeform($size / 105000);
$size = filesize($size);
$downloads = commify($downloads);
}
my $cf_cd = time - $cf_newdays * 86400;
if ($date > $cf_cd) {$cf_nt = $cf_newtag;} else {$cf_nt = "";}
if ($cf_updd > $cf_cd) {$cf_od = $cf_updtag;} else {$cf_od = "";}
my @cf_oss = split(/\,/,$cf_oss);
$cf_oss = "";
foreach $cf_os (@cf_oss) {$cf_oss .= "$cf_os
";}
@rr = split(/:/,$rating_raw);
if ("@rr" eq "") {$votes = "(0 $h139)";} else {$votes = "(" . @rr . " $h139)";}
$cnote = "$h187";
if ($comments > 0) {
$comname = "$comments $h34";
$comsdata = grabfile("$template_path/row_comment.$template_ext");
my $query = qq{ SELECT poster,userip,comment,mdate FROM $mtable WHERE fileid=? ORDER BY mdate };
$sth = $dbh->prepare ( $query );
$sth->execute ($_[0]);
while (@ary = $sth->fetchrow_array ()){
$comline = $comsdata;
$comline =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc;
$comline =~ s/\%\%AUTHOR\%\%/$ary[0]/goc;
$comline =~ s/\%\%USERIP\%\%/$ary[1]/goc;
$comline =~ s/\%\%COMMENT\%\%/$ary[2]/goc;
$comdata .= $comline;
}
} else {$comname = "0 $h34";}
$combox = grabfile("$template_path/box_comments.$template_ext");
if ($ucp[3] == 1) {
$commentform = "
| Comment: |