#!/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: 
"; } else {$commentform = "";} $combox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $combox =~ s/\%\%COMNAME\%\%/$comname/goc; $combox =~ s/\%\%CNOTE\%\%/$cnote/goc; $combox =~ s/\%\%COMMENTS\%\%/$comdata/goc; # There follows some alterations added by The Booboo # This has been altered to try and fix a bug in the comments system. if ($loggedin == 1) { $combox =~ s/\%\%COMMENTFORM\%\%/$commentform/goc; } else { $combox =~ sprintf("Please log in or register if you'd like to make a comment on this item!"); } # end of alterations by The Booboo. To return things the way they were, # delete the line above and uncomment the line below # $combox =~ s/\%\%COMMENTFORM\%\%/$commentform/goc; my $query = qq{ SELECT rated FROM $utable WHERE handle=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($user); $sth->bind_col(1, \$rated); while ($sth->fetch) { foreach $urtmp (split(/:/,$rated)) { if ($urtmp == $fileid) {$prerated = 1;} } } if (($ucp[2] == 1) && ($prerated != 1)) { $rateform = "
"; } if ($ucp[1] == 1) { $dllink = "$h59"; } if ($loggedin == 1) {$deadlink = "?$cfpd[0],32,0,0,$cfpd[4],$cfpd[5]"; $deadlinkname = $h177;} else {($deadlink,$deadlinkname) = ""} $content = grabfile("$template_path/page_fileinfo.$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/\%\%RATEFORM\%\%/$rateform/goc; $content =~ s/\%\%DEADLINK\%\%/$deadlink/goc; $content =~ s/\%\%DEADLINKNAME\%\%/$deadlinkname/goc; $content =~ s/\%\%NEWTAG\%\%/$cf_nt/goc; $content =~ s/\%\%UPDATEDTAG\%\%/$cf_od/goc; $content =~ s/\%\%56KTIME\%\%/$cf_dtime1/goc; $content =~ s/\%\%128KTIME\%\%/$cf_dtime2/goc; $content =~ s/\%\%256KTIME\%\%/$cf_dtime3/goc; $content =~ s/\%\%512KTIME\%\%/$cf_dtime4/goc; $content =~ s/\%\%1024KTIME\%\%/$cf_dtime5/goc; $content =~ s/\%\%OSS\%\%/$cf_oss/goc; $content =~ s/\%\%FNNAME\%\%/$h30/goc; $content =~ s/\%\%DNAME\%\%/$h29/goc; $content =~ s/\%\%SNAME\%\%/$h31/goc; $content =~ s/\%\%ANAME\%\%/$h63/goc; $content =~ s/\%\%VNAME\%\%/$h77/goc; $content =~ s/\%\%WNAME\%\%/$h62/goc; $content =~ s/\%\%DLNAME\%\%/$h33/goc; $content =~ s/\%\%RNAME\%\%/$h32/goc; $content =~ s/\%\%CNAME\%\%/$h34/goc; $content =~ s/\%\%COMMENTBOX\%\%/$combox/goc; $content =~ s/\%\%DESCNAME\%\%/$h65/goc; $content =~ s/\%\%DLLINK\%\%/$dllink/goc; $content =~ s/\%\%FILENAME\%\%/$filename/goc; $content =~ s/\%\%FILETITLE\%\%/$title/goc; $content =~ s/\%\%COSTNAME\%\%/$h181/go; $content =~ s/\%\%COST\%\%/$cost/goc; $content =~ s/\%\%LNAME\%\%/$h80/goc; $content =~ s/\%\%LICENCE\%\%/$licence/goc; $content =~ s/\%\%DATE\%\%/$cfsdate/goc; $content =~ s/\%\%SIZE\%\%/$size/goc; $content =~ s/\%\%AUTHOR\%\%/$author/goc; $content =~ s/\%\%VOTES\%\%/$votes/goc; $content =~ s/\%\%VERSION\%\%/$version/goc; $content =~ s/\%\%WEBSITE\%\%/$website/goc; $content =~ s/\%\%DOWNLOADS\%\%/$downloads/goc; $content =~ s/\%\%RATING\%\%/$rating/goc; $description =~ s/\015?\012/
/g; $content =~ s/\%\%DESCRIPTION\%\%/$description/goc; $content =~ s/\%\%SSURL\%\%/$ssname<\/A>/goc; $content =~ s/\%\%DESC\%\%/$description/goc; $content =~ s/\%\%CATLINKS\%\%/$catlinks/goc; $content =~ s/\%\%MESSAGE\%\%/$message/goc; } sub filedlnew { if ($_[0] ne "") { my @cf_ths = split(/\//,$ENV{HTTP_REFERER}); my @cf_the = split(/\./,$cf_ths[2]); if ($cf_the[0] eq "www") { shift(@cf_the); $cf_ths[2] = join('.',@cf_the); } if ($cf_ths[2] eq $host) { my ($filename, $size, $prov, $provl, $title); my $query = qq{ SELECT filename,size,provider,providerlink,title FROM $ftable WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($_[0]); $sth->bind_columns(undef, \$filename, \$size, \$prov, \$provl, \$title); $sth->fetch; my ($cf_found, $cf_dt, $cf_dpu) = 0; $query = qq{ SELECT COUNT(id) FROM $fstable WHERE ip=? AND fileid=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($ENV{REMOTE_ADDR},$_[0]); $sth->bind_col(1, \$cf_fnd); $sth->fetch; if ($cf_fnd == 0) { my $sdate = time; if ($user eq "") {$user = "Guest";} $query = qq{ INSERT INTO $fstable (id,ip,handle,fileid,sendstatus,sdate,filename,filesize) VALUES ('0',?,?,?,'2',?,?,?) }; $sth = $dbh->prepare ( $query ); $sth->execute ($ENV{REMOTE_ADDR},$user,$cfpd[5],$sdate,$filename,$size); } $size = filesize($size); $query = qq{ SELECT COUNT(id) FROM $fstable WHERE sendstatus='2' OR sendstatus='3' }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_col(1, \$cf_found); $sth->fetch; if ($cf_found < $downloads_total) {$cf_dt = 0;} $cf_found = 0; $query = qq{ SELECT COUNT(id) FROM $fstable WHERE ip=? AND sendstatus='2' OR sendstatus='3' }; $sth = $dbh->prepare ( $query ); $sth->execute ($ENV{REMOTE_ADDR}); $sth->bind_col(1, \$cf_found); $sth->fetch; if ($cf_found < $downloads_per_user) {$cf_dpu = 0;} $cf_fd = ""; $cf_fd1 = "cfdl.cgi"; $content = grabfile("$template_path/page_filedl.$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/\%\%DLNAME\%\%/$h64/goc; $content =~ s/\%\%FD\%\%/$cf_fd/goc; $content =~ s/\%\%URL\%\%/cfdl.cgi/goc; $content =~ s/\%\%FILENAME\%\%/$filename/goc; $content =~ s/\%\%FILETITLE\%\%/$title/goc; $content =~ s/\%\%FILEURL\%\%/?$cfpd[0],0,$cfpd[2],$cfpd[3],$cfpd[4],$cfpd[5]/goc; $content =~ s/\%\%SIZE\%\%/$size/goc; $content =~ s/\%\%PROVIDERM\%\%/$h60/goc; $content =~ s/\%\%PROVIDER\%\%/$prov<\/A>/goc; $content =~ s/\%\%DLSTARTURL\%\%/$h72<\/A>/goc; $content =~ s/\%\%DLSTARTM\%\%/$h61/goc; $content =~ s/\%\%CATLINKS\%\%/$catlinks/goc; cfheader($h41); content($h41); footer(); } else { &resultspage("$h70: $m72",$h41); } } else { &resultspage("$h70: $m57",$h41); } } sub filedl { my ($filename, $size, $prov, $provl, $title); my $query = qq{ SELECT filename,size,provider,providerlink,title FROM $ftable WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($_[0]); $sth->bind_columns(undef, \$filename, \$size, \$prov, \$provl, \$title); while ($sth->fetch) { $size = filesize($size); } $content = grabfile("$template_path/page_filedl.$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/\%\%DLNAME\%\%/$h64/goc; $content =~ s/\%\%URL\%\%/\?$cfpd[0],1,2,$cfpd[3],$cfpd[4],$cfpd[5]/goc; $content =~ s/\%\%FILENAME\%\%/$filename/goc; $content =~ s/\%\%FILETITLE\%\%/$title/goc; $content =~ s/\%\%FILEURL\%\%/?$cfpd[0],0,0,0,$cfpd[4],$cfpd[5]/goc; $content =~ s/\%\%SIZE\%\%/$size/goc; $content =~ s/\%\%PROVIDERM\%\%/$h60/goc; $content =~ s/\%\%PROVIDER\%\%/$prov<\/A>/goc; $content =~ s/\%\%DLSTARTURL\%\%/$h72<\/A>/goc; $content =~ s/\%\%DLSTARTM\%\%/$h61/goc; $content =~ s/\%\%CATLINKS\%\%/$catlinks/goc; } sub lic_check { my $query = qq{ SELECT id,filename,size,licence FROM $ftable WHERE id='$_[0]' }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_columns(undef, \$fileid, \$filename, \$size, \$licence); $sth->fetch; $size = filesize($size); if ($licence eq "None") { return "0"; } else { %cookies = fetch CGI::Cookie; if (defined $cookies{'CFL_ID'}) {$id = $cookies{'CFL_ID'}->value;} else {$id = "";} @fids = split(/:/, $id); $m = 0; foreach $n (@fids) { if ($n == $_[0]) { $m++; } } if ($m > 0) { return "2"; } else { my $query = qq{ SELECT content FROM $ltable WHERE name=? ORDER BY name DESC }; $sth = $dbh->prepare ( $query ); $sth->execute ($licence); $sth->bind_col(1, \$lcontent); $sth->fetch; return "1"; } } } sub lic_checkold { my $query = qq{ SELECT id,filename,size,licence FROM $ftable WHERE id='$_[0]' }; $sth = $dbh->prepare ( $query ); $sth->execute (); while (@ary = $sth->fetchrow_array ()){ $filename = $ary[1]; $fileid = $ary[0]; $size = filesize($ary[2]); $licence = $ary[3]; } return "0"; } sub licprint { if (defined $cfpd[5]) {$formurl = "?$cfpd[0],1,1,0,$cfpd[4],$cfpd[5]";} else {$formurl = "?$cfpd[0],1,1,0,$cfpd[4]";} $content = grabfile("$template_path/page_licence.$template_ext"); $content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $content =~ s/\%\%AGREEMESSAGE\%\%/$h76/goc; $content =~ s/\%\%BYTES\%\%/$CF_clsize/goc; $content =~ s/\%\%FILES\%\%/$CF_clfiles/goc; $content =~ s/\%\%CATDESC\%\%/$catldesc/goc; $content =~ s/\%\%ACCNAME\%\%/$h159/goc; $content =~ s/\%\%DECNAME\%\%/$h160/goc; $content =~ s/\%\%FNAME\%\%/$h30/goc; $content =~ s/\%\%SNAME\%\%/$h31/goc; $content =~ s/\%\%FORMURL\%\%/$formurl/goc; $content =~ s/\%\%RFORMURL\%\%/$rformurl/goc; $content =~ s/\%\%FILENAME\%\%/$filename/goc; $content =~ s/\%\%SIZE\%\%/$size/goc; $content =~ s/\%\%LICENCE\%\%/$lcontent/goc; $content =~ s/\%\%FILEID\%\%/$fileid/goc; $content =~ s/\%\%CATLINKS\%\%/$catlinks/goc; } sub licset { my $cf_lid = param("FID"); my $cf_lsc = param("Submit2"); if ($cf_lid ne "") { if ($cf_lsc ne "") { my $query = qq{ SELECT licence,catid FROM $ftable WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($cf_lid); while (@ary = $sth->fetchrow_array ()){ $lic = "$ary[0]"; $pid = "$ary[1]"; } if ($cf_lsc eq $h159) { if ($lic ne "None") { %cookies = fetch CGI::Cookie; if (defined $cookies{'CFL_ID'}) { $id = $cookies{'CFL_ID'}->value; } else { $id = ""; } @fids = split(/:/, $id); $g = 0; foreach $fid (@fids) { if ($fid == $cf_lid) { $g++; } } if ($g == 0) { if ($ucp[1] == 1) { if ($pid == $cfpd[4]) { unshift(@fids, $cf_lid); $fids = join(':', @fids); $c = new CGI::Cookie(-name => 'CFL_ID',-value => "$fids",-expires => '+1M',); print "Set-Cookie: $c\n"; return 1 } else { return 0 } } else { return 0 } } else { return 1 } } else { return 1 } } elsif ($cf_lsc eq "Decline") { return 2 } } } } sub precursor { if ($cfpd[0] == 0) { $deflang = $langpath . "english.lang"; } elsif ($cfpd[0] == 1) { $deflang = $langpath . "spanish.lang"; } elsif ($cfpd[0] == 2) { $deflang = $langpath . "french.lang"; } elsif ($cfpd[0] == 3) { $deflang = $langpath . "italian.lang"; } elsif ($cfpd[0] == 4) { $deflang = $langpath . "german.lang"; } elsif ($cfpd[0] == 5) { $deflang = $langpath . "russian.lang"; } elsif ($cfpd[0] == 6) { $deflang = $langpath . "portugese.lang"; } do "$deflang"; my ($parentname, $catldesc, $groups, $cf_cfd, $catfdown, $catbdown, $cf_clf, @cgroups, $catfdown); my $query = qq{ SELECT description,catname,groups,filesdown,bytesdown,files,size FROM $ctable WHERE id='$cfpd[4]' }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_columns(undef, \$catldesc, \$CF_catname, \$groups, \$cf_cfd, \$catbdown, \$cf_clf, \$CF_clsize); while ($sth->fetch) { @cgroups = split(/\,/, $groups); $catfdown = commify($cf_cfd); if ($cf_cfd == 1) {$catfdown .= " $h36";} else {$catfdown .= " $h37";} $catbdown = filesize($catbdown); $catdls = "$h142 $catfdown ($catbdown)"; $CF_clfiles = commify($cf_clf); if ($cf_clf == 1) { $CF_clfiles .= " $h36"; } else { $CF_clfiles .= " $h37"; } $CF_clsize = filesize($CF_clsize); } $pagetitle =~ s/\%\%SITENAME\%\%/$sitename/goc; $pagetitle =~ s/\%\%CATEGORY\%\%/$CF_catname/goc; my $query = qq{ SHOW VARIABLES LIKE 'version' }; $sth = $dbh->prepare ( $query ); my($ss_ver); $sth->execute (); $sth->bind_col(2, \$ss_ver); $sth->fetch; my @sql_v = split(/\./,$ss_ver); $sqlv = 0; if ($sql_v[0] == 3) { if ($sql_v[1] > 23) { $sqlv = 1; } elsif ($sql_v[1] == 23) { if ($sql_v[2] >= 30) { $sqlv = 1; } } } elsif ($sql_v[0] > 3) { $sqlv = 1; } stattblchk(); if (defined $_[0]) { $user = $_[0]; $pass = $_[1]; } elsif (defined $cookies{'CF_ID'}) { ($user, $pass) = split(/:/, $cookies{'CF_ID'}->value); } if (($user ne "") && ($pass ne "")) { $loggedin = check_user($user,$pass); if ($loggedin == 1) { funcbox($cfpd[4]); } else { loginbox($cfpd[4]); } } else { loginbox($cfpd[4]); } return $loggedin } sub loginbox { @uperms; my ($cf_grp,$cf_perm,$formurl); my $query = qq{ SELECT groupname,permissions FROM $gtable WHERE defnoreg='1' }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_columns(undef, \$cf_grp, \$cf_perm); while ($sth->fetch) { push(@uperms,"$cf_grp:$cf_perm"); } @ucp = ucperms($_[0],@uperms); if (defined $cfpd[5]) {$formurl = "$cfpd[0],4,1,0,$cfpd[4],$cfpd[5]";} else {$formurl = "$cfpd[0],4,1,0,$cfpd[4]";} $funcbox = grabfile("$template_path/box_login.$template_ext"); $funcbox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $funcbox =~ s/\%\%USERS\%\%/$memnum/goc; $funcbox =~ s/\%\%REGURL\%\%/?$cfpd[0],5,0,$cfpd[3],$cfpd[4]/goc; $funcbox =~ s/\%\%FORMURL\%\%/$formurl/goc; $funcbox =~ s/\%\%USERNAME\%\%/$h8/goc; $funcbox =~ s/\%\%PASSNAME\%\%/$h9/goc; $funcbox =~ s/\%\%LOGINNAME\%\%/$h1/goc; $funcbox =~ s/\%\%REGNAME\%\%/$h2/goc; $funcbox =~ s/\%\%MEMNAME\%\%/$h10/goc; $funcbox =~ s/\%\%EMAILPASSNAME\%\%/$h11 $h12<\/A>/goc; } sub cflanguage { if (defined param("jumpList")) { my $cf_ls = param("jumpList"); if (($cf_ls >= 0) && ($cf_ls <= 6)) { $cfpd[0] = $cf_ls; $cfpd[1] = 0; $cfpd[2] = 0; my $c = new CGI::Cookie(-name => 'CF_LANG',-value => "$cf_ls",-expires => '+3M',-secure => 0); print "Set-Cookie: $c\n"; frontpage(); } else {print "Location: $ENV{'HTTP_REFERER'}\n\n";} } else {print "Location: $ENV{'HTTP_REFERER'}\n\n";} } sub funcbox { @uperms; my ($cf_dlinks,$fn_perm,$rsbn_perm,$rsgn_perm,$ubdown,$ufdown,@groups,$cf_perms,$cf_status,$formurl); if (defined $cfpd[5]) {$fn_perm = ",$cfpd[5]";} else {$fn_perm = "";} my $query = qq{ SELECT groups,filesdown,bytesdown FROM $utable WHERE handle="$user" }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_columns(undef, \$cf_grp, \$ufdown, \$ubdown); while ($sth->fetch) { if ($ufdown == 1) {$ufdown .= " $h36";} else {$ufdown .= " $h37";} $ubdown = filesize($ubdown); @groups = split(/\,/,$cf_grp); } my $cf1sth = $dbh->prepare(qq{ SELECT permissions FROM $gtable WHERE groupname=? }); foreach $group (@groups) { $cf1sth->execute($group); $cf1sth->bind_columns(undef, \$cf_perms); while (@ary = $cf1sth->fetchrow_array ()) { push(@uperms, "$group:$cf_perms"); } } @ucp = ucperms($_[0],@uperms); if (($ucp[6] == 1) || ($ucp[7] == 1)) { my ($a,$b) = 0; my $CF_ctmp = "$CF_catname:%"; $query = qq{ SELECT filestatus FROM $ptable WHERE cats=? OR cats LIKE ? }; $sth = $dbh->prepare ( $query ); $sth->execute ($CF_catname,$CF_ctmp); $sth->bind_col(1, \$cf_status); while ($sth->fetch) { if ($cf_status eq "S") { $a++; } elsif ($cf_status eq "U") { $b++; } } $query = qq{ SELECT COUNT(id) FROM $dtable }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_col(1, \$cf_dlinks); $sth->fetch; if (($a > 0) && ($ucp[6] == 1)) {$rsbn_perm = "$h50 ($a)";} if (($b > 0) && ($ucp[7] == 1)) {$rsgn_perm = "$h50 ($b)";} } if ($ucp[8] == 1) {$afn_perm = "$h23";} if ($ucp[9] == 1) {$rfn_perm = "$h24";} if ($ucp[10] == 1) {$efn_perm = "$h25";} if ($ucp[11] == 1) {$ifn_perm = "$h48";} if ($ucp[12] == 1) {$acn_perm = "$h20";} if ($ucp[13] == 1) {$rcn_perm = "$h21";} if ($ucp[14] == 1) {$ecn_perm = "$h22";} if ($ucp[15] == 1) {$aln_perm = "$h26";} if ($ucp[16] == 1) {$rln_perm = "$h27";} if ($ucp[17] == 1) {$eln_perm = "$h28";} if ($ucp[18] == 1) {$aun_perm = "$h14";} if ($ucp[19] == 1) {$run_perm = "$h15";} if ($ucp[20] == 1) {$eun_perm = "$h16";} if ($ucp[21] == 1) {$agn_perm = "$h17";} if ($ucp[22] == 1) {$rgn_perm = "$h18";} if ($ucp[23] == 1) {$egn_perm = "$h19";} if (($cf_dlinks > 0) && ($ucp[27] == 1)) { $vdl_perm = "$h169 ($cf_dlinks)"; } if ($ucp[27] == 1) {$gdl_perm = "$h173";} if ($ucp[28] == 1) {$ie_perm = "$h170";} if ($ucp[29] == 1) {$email_perm = "$h174";} if ($ucp[30] == 1) {$gn_perm = "$h175";} $pfn_perm = "$h52"; $sfn_perm = "$h53"; $scn_perm = "$h54"; $sbn_perm = "$h55"; if (defined $cfpd[5]) {$formurl = "$cfpd[0],4,0,0,$cfpd[4],$cfpd[5]";} else {$formurl = "$cfpd[0],4,0,0,$cfpd[4]";} $funcbox = grabfile("$template_path/box_functions.$template_ext"); $funcbox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $funcbox =~ s/\%\%USERS\%\%/$memnum/goc; $funcbox =~ s/\%\%DLNAME\%\%/$h69/goc; $funcbox =~ s/\%\%FILESDOWN\%\%/$ufdown/goc; $funcbox =~ s/\%\%BYTESDOWN\%\%/$ubdown/goc; $funcbox =~ s/\%\%LOGOUTURL\%\%/$formurl/goc; $funcbox =~ s/\%\%ADDCAT\%\%/$acn_perm/goc; $funcbox =~ s/\%\%REMCAT\%\%/$rcn_perm/goc; $funcbox =~ s/\%\%EDITCAT\%\%/$ecn_perm/goc; $funcbox =~ s/\%\%ADDFILE\%\%/$afn_perm/goc; $funcbox =~ s/\%\%REMFILE\%\%/$rfn_perm/goc; $funcbox =~ s/\%\%EDITFILE\%\%/$efn_perm/goc; $funcbox =~ s/\%\%IMPFILE\%\%/$ifn_perm/goc; $funcbox =~ s/\%\%ADDLIC\%\%/$aln_perm/goc; $funcbox =~ s/\%\%REMLIC\%\%/$rln_perm/goc; $funcbox =~ s/\%\%EDITLIC\%\%/$eln_perm/goc; $funcbox =~ s/\%\%ADDUSER\%\%/$aun_perm/goc; $funcbox =~ s/\%\%REMUSER\%\%/$run_perm/goc; $funcbox =~ s/\%\%EDITUSER\%\%/$eun_perm/goc; $funcbox =~ s/\%\%ADDGROUP\%\%/$agn_perm/goc; $funcbox =~ s/\%\%REMGROUP\%\%/$rgn_perm/goc; $funcbox =~ s/\%\%EDITGROUP\%\%/$egn_perm/goc; $funcbox =~ s/\%\%REVIEWSUBS\%\%/$rsbn_perm/goc; $funcbox =~ s/\%\%REVIEWSUGS\%\%/$rsgn_perm/goc; $funcbox =~ s/\%\%PROFILE\%\%/$pfn_perm/goc; $funcbox =~ s/\%\%SUBMITFILE\%\%/$sfn_perm/goc; $funcbox =~ s/\%\%SUGGESTCAT\%\%/$scn_perm/goc; $funcbox =~ s/\%\%SUBSCRIBE\%\%/$sbn_perm/goc; $funcbox =~ s/\%\%GENDEADLINK\%\%/$gdl_perm/goc; $funcbox =~ s/\%\%VIEWDEADLINK\%\%/$vdl_perm/goc; $funcbox =~ s/\%\%IMPEXP\%\%/$ie_perm/goc; $funcbox =~ s/\%\%USEREMAIL\%\%/$email_perm/goc; $funcbox =~ s/\%\%GENNEWS\%\%/$gn_perm/goc; $funcbox =~ s/\%\%FUNCNAME\%\%/$h49/goc; $funcbox =~ s/\%\%LOGOUTNAME\%\%/$h43/goc; } sub rate { $cfpd[1] = 0; my $cf_fid = param("fileid"); my $cf_frt = param("rating"); if ($cf_frt ne "") { if ($cf_fid ne "") { my $query = qq{ SELECT rated FROM $utable WHERE handle=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($user); while (@ary = $sth->fetchrow_array ()){ @rated = split(/:/,$ary[0]); } $prerated = 0; foreach $urtmp (@rated) { if ($urtmp == $cf_fid) {$prerated = 1;} } if ($prerated == 0) { my $query = qq{ SELECT rating_raw FROM $ftable WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($cf_fid); while (@ary = $sth->fetchrow_array ()){ @rawrating = split(/:/,$ary[0]); } $numrates = 0; $ratetmp = 0; push(@rawrating,$cf_frt); foreach $rating (@rawrating) { $numrates++; $ratetmp = $ratetmp + $rating; } if ($numrates > 0) { $averate = $ratetmp / $numrates; } else {$averate = 0;} $rr = join(':',@rawrating); my $query = qq{ UPDATE $ftable SET rating=?, rating_raw=? WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($averate,$rr,$cf_fid); push(@rated, $cf_fid); $ur = join(':',@rated); my $query = qq{ UPDATE $utable SET rated=? WHERE handle=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($ur,$user); &resultspage("$h117: $h140",$h140); } else {&formreturn("$h70: $m12","1");} } else {&formreturn("$h70: $m13","1");} } else {&formreturn("$h70: $m14","1");} } sub comment { my $cf_fid = param("fileid"); my $cf_fcom = param("comment"); if ($cf_fid ne "") { if ($cf_fcom ne "") { my $query = qq{ SELECT comments,cats FROM $ftable WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($cf_fid); while (@ary = $sth->fetchrow_array ()){ $comments = $ary[0]; $comcat = $ary[1]; } $comments++; my $query = qq{ UPDATE $ftable SET comments=? WHERE id=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($comments,$cf_fid); $date = time(); $userip= $ENV{REMOTE_ADDR}; my $query = qq{ INSERT INTO $mtable (fileid, poster, comment, mdate, userip) VALUES (?, ?, ?, ?, ?) }; $sth = $dbh->prepare ( $query ); $sth->execute ($cf_fid,$user,$cf_fcom,$date,$userip); &resultspage("$h117: $h136",$h136); } else {&formreturn("$m15","1")} } else {&formreturn("$m13","1")} } sub search { my $cf_sm = param("smethod"); my $cf_st = param("Terms"); if (($cf_sm eq "") && (defined $cookies{'CF_S'})) { ($cf_sm, $cf_st) = split(/:/, $cookies{'CF_S'}->value); } if ($cf_sm ne "") { if ($cf_st ne "") { if ($cf_sm eq "name") { $sterm = "filename LIKE '%$cf_st%' ORDER BY filename"; } elsif ($cf_sm eq "desc") { $sterm = "description LIKE '%$cf_st%' ORDER BY description"; } elsif ($cf_sm eq "author") { $sterm = "author LIKE '%$cf_st%' ORDER BY author"; } elsif ($cf_sm eq "title") { $sterm = "title LIKE '%$cf_st%' ORDER BY title"; } $content = grabfile("$template_path/page_search.$template_ext"); my $searchrow = grabfile("$template_path/row_searchresults.$template_ext"); my ($searchdata, $line, $cf_id, $cf_fn, $cf_aut, $cf_dsc, $cf_cid); my $nsres = $cfpd[2] * $numsearchresults; my ($a, $b) = 0; my $query = qq{ SELECT id,filename,author,description,catid FROM $ftable WHERE $sterm }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_columns(undef, \$cf_id, \$cf_fn, \$cf_aut, \$cf_dsc, \$cf_cid); while ($sth->fetch) { if (($b >= $nsres) && ($a < $numsearchresults)) { $line = $searchrow; $line =~ s/\%\%FNAME\%\%/$cf_fn<\/A>/goc; $line =~ s/\%\%AUTHOR\%\%/$cf_aut/goc; $line =~ s/\%\%DESCRIPTION\%\%/$cf_dsc/goc; $searchdata .= $line; $a++; $b++; } else {$b++;} } my $c = $nsres + $numsearchresults; my $h = $nsres + 1; if ($b > 0) { $searchbox = grabfile("$template_path/box_searchresults.$template_ext"); $searchbox =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $searchbox =~ s/\%\%FNNAME\%\%/$h30/goc; $searchbox =~ s/\%\%AUTHOR\%\%/$h63/goc; $searchbox =~ s/\%\%DESCRIPTION\%\%/$h65/goc; $searchbox =~ s/\%\%RESULTS\%\%/$searchdata/goc; if ($b > $c) { $numres = "$h to $c of $b"; } else {$numres = "$h to $b of $b";} } else {$numres = "$h145";} my (@cf_slinks, $cf_sp); if ($b > $numsearchresults) { $cf_sp = $b / $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"; } $content =~ s/\%\%TEMPLATEURL\%\%/$template_url/goc; $content =~ s/\%\%MESSAGE\%\%/$message/goc; $content =~ s/\%\%NUMRESULTS\%\%/$numres/goc; $content =~ s/\%\%BYTES\%\%/$CF_clsize/goc; $content =~ s/\%\%FILES\%\%/$CF_clfiles/goc; $content =~ s/\%\%CATDESC\%\%/$catldesc/goc; $content =~ s/\%\%RESULTSBOX\%\%/$searchbox/goc; $content =~ s/\%\%NEXTLINK\%\%/$cf_slinks/goc; $content =~ s/\%\%PREVLINK\%\%/$prvlnk/goc; $content =~ s/\%\%CATLINKS\%\%/$catlinks/goc; my $c = new CGI::Cookie(-name => 'CF_S',-value => "$cf_sm:$cf_st",-secure => 0); print "Set-Cookie: $c\n"; &cfheader($h147); &content($h147); &footer(); } else { print "Location: $ENV{'HTTP_REFERER'}\n\n"; } } else { print "Location: $ENV{'HTTP_REFERER'}\n\n"; } } sub filesize { if ($_[0] >= 1000000000) { my $text = $_[0] / 1000000000; $text = sprintf("%.3f",$text); return "$text GB" } elsif ($_[0] >= 1000000) { my $text = $_[0] / 1000000; $text = sprintf("%.2f",$text); return "$text MB" } elsif ($_[0] >= 1000) { my $text = $_[0] / 1000; $text = sprintf("%.1f",$text); return "$text KB" } else { return "$_[0] B" } } sub commify { $text = reverse shift; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text; } my ($cf_cntmp); sub grabfile { open(FILE,$_[0]) || die "Cannot open template: $_[0]"; $_ = -s $_[0]; sysread(FILE,$cf_cntmp,$_); close(FILE); return $cf_cntmp } sub slashify { if ($_[0] ne "") { my $len = length($_[0]); $len--; my $lastchar = substr($_[0], $len); if ($lastchar eq "/") {return "$_[0]"} else { my $g = "$_[0]" . "/"; return $g } } else {return "/"} } sub roundup { my $n = shift; return(($n == int($n)) ? $n : int($n + 1)) } sub check_user { if ($_[0] ne "") { if ($_[1] ne "") { my ($handle, $password, $b); my $query = qq{ SELECT password FROM $utable WHERE handle=? }; $sth = $dbh->prepare ( $query ); $sth->execute ($_[0]); $sth->bind_col(1, \$password); while ($sth->fetch) {$b++;} if ($password eq $_[1]) { return 1 } else { if ($b > 0) {return 2} else {return 5} } } else { return 3 } } else { return 4 } } @cfpd = split(/\,/, $ENV{'QUERY_STRING'}); %cookies = fetch CGI::Cookie; if (defined $cookies{'CF_LANG'}) { if (($cookies{'CF_LANG'}->value >= 0) && ($cookies{'CF_LANG'}->value <= 1)) { $cfpd[0] = $cookies{'CF_LANG'}->value; } else { if ($cfpd[0] eq "") {$cfpd[0] = $deflangid;} } } else { if ($cfpd[0] eq "") {$cfpd[0] = $deflangid;} } if ($cfpd[1] eq "") {$cfpd[1] = 0;} if ($cfpd[2] eq "") {$cfpd[2] = 0;} if ($cfpd[3] eq "") {$cfpd[3] = 0;} if ($cfpd[4] eq "") { my $query = qq{ SELECT id FROM $ctable WHERE parentid='-' }; $sth = $dbh->prepare ( $query ); $sth->execute (); $sth->bind_col(1, \$cfhomecat); $sth->fetch; $cfpd[4] = $cfhomecat; } frontpage(); $dbh->disconnect (); $dbh->disconnect ();