16/05/2004, 11:53
|
| | | Fecha de Ingreso: noviembre-2003 Ubicación: Villa Luro, Ciudad Autónoma de Buenos Aires, Argentina.
Mensajes: 95
Antigüedad: 21 años Puntos: 0 | |
Código:
#!/usr/bin/perl
use lib "./lib";
use CGI;
use strict;
use CGI::Carp qw(fatalsToBrowser);
use sitevariables;
use common;
use lang;
package dft;
our $cur = CGI::new();
print "Content-type:text/html\n\n";
our $mode = $cur->param('mode');
our $onpage = $cur->param('page');
our $content;
if ($mode eq "single"){
$content .= viewsingle();
}elsif($mode eq "viewone"){
$content .= viewone();
}else{
$content .= viewall();
}
print cmn::printpage($svb::templatefile,$content);
sub viewall{
my ($return,$filetype,$temp,$printfiles,@lines,$num);
$num = 1;
$return .= "\n<center>
<table width=100%>
<tr>
<td width=70%>
<center>
$svb::fontheader$svb::title</b></font>
</center>
</td>
<td align=right>
<form method=get action=search.cgi>
<input type=text name=searchfor>
<input type=submit value='$lang::search_blogs'>
</form>
</td>
</tr>
<tr>
<td valign=top colspan=2>\n";
open (INFILE, "./$svb::post_template")||cmn::dienice("$lang::read_file_error - ./$svb::post_template\: $!!");
while (<INFILE>){
$temp .= $_;
}
close INFILE;
$temp =~ s/<!--*-->//;
open (INFILE, "./data.blog")||cmn::dienice("$lang::read_file_error - ./data.blog\: $!!");
@lines = <INFILE>;
close INFILE;
my $total = @lines;
my $countpages = 1;
if ($total > $svb::page){
$return .= "<br><br><p align=right>$svb::fontsmall$lang::page <a href=index.cgi?page=$countpages>1</a> ";
while ($total-($svb::page*$countpages) > 0){
$countpages++;
$return .= "<a href=index.cgi?page=$countpages>$countpages</a> ";
}
$return .= "</font></p>";
}
@lines = reverse @lines;
if(!@lines){
$return .= "<div style='margin-left: 40px\;'>$svb::fontsmall$lang::noposts</font>"
}
my $count4;
if($onpage > 1){
while ($count4 < $svb::page*($onpage-1)){
shift @lines;
$count4++;
}
}
foreach (@lines){
if($num <= $svb::page){
chomp ($_);
my $temp2 = "\n\n
<table>
<tr>
<td>
$temp
</td>
</tr>
</table>\n\n\n";
my ($date,$title,$text) = split(/###/,$_);
$text =~ s/\n/<br>\n/ig;
my @files = glob("$svb::htmlsystempath/$date*");
foreach (@files){
$_ =~ s/.*\/(\d+-\d+\.[\w\d]+)/$1/ig;
if($_ =~ /(\.wmv|\.mpg|\.mov|\.avi|\.rm|\.ra|\.asf|\.moov|\.movie)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/movie.png border=0 alt='$lang::movie'></a> ";
}elsif($_ =~ /(\.jpg|\.gif|\.tif|\.png|\.bmp|\.jpeg)$/ig){
$temp2 =~ s/\[picture\]/<img src=$svb::htmlpath\/$_ align=$svb::picalign>/ig;
}elsif($_ =~ /(\.pcx|\.pict|\.pdf|\.ps|\.prn|\.eps)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/image.png border=0 alt='$lang::image'></a> ";
}elsif($_ =~ /(\.doc|\.rtf|\.wps|\.txt|\.htm|\.html|\.shtml|\.pwd|\.wks|\.wpd|\.wri|\.hed|\.lwp|\.wp|\.pp|\.sxc|\.sxi)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/document.png border=0 alt='$lang::text_document'></a> ";
}elsif($_ =~ /(\.tar|\.tar.gz\.tgz|\.bz2|\.bz|\.zip|\.cab)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/archive.png border=0 alt='$lang::archive'></a> ";
}elsif($_ =~ /(\.c|\.cpp|\.cxx|\.h|\.o|\.p|\.pl|\.pm|\.cgi|\.php|\.asp|\.prg|\.sc|\.asm|\.cob
|\.cpi|\.cv|\.sh|\.tsh|\.csh|\.scp)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/code.png border=0 alt='$lang::code'></a> ";
}elsif($_ =~ /(\.wdb|\.adb|\.cdx|\.dbc|\.dbf|\.dbt|\.mdb|\.ntf|\.dif|\.slk|\.syl|\.wkq|\.wkr|\.xls)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/database.png border=0 alt='$lang::dbss'></a> ";
}elsif($_ =~ /(\.au|\.mp3|\.wav|\.ogg|\.aif|\.wma|\.ra|\.ram|\.cda|\.mp2|\.snd|\.voc|\.mod|\.mid|\.midi)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/audio.png border=0 alt='$lang::audio'></a> ";
}else{
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/unknown.png border=0 alt='$lang::unknown'></a> ";
}
} # foreach @files
if(length($text) > $svb::textmax && $svb::textmax > 0){
$text = substr($text,0,$svb::textmax);
$text =~ s/\b\w+$/\.\.\./ig;
$text =~ s/ $//ig;
$text .= "...";
}
my $pdate = cmn::mydate($date);
$temp2 =~ s/\[date\]/$pdate/ig;
$temp2 =~ s/\[readmore\]/<a href=index.cgi?mode=viewone&blog=$date>$lang::fulltext<\/a>/ig;
$temp2 =~ s/\[text\]/$text/ig;
$temp2 =~ s/\[title\]/$title/ig;
$temp2 =~ s/\[picture\]//ig;
if (!$filetype){
$filetype = " $lang::noattachedfiles";
}
$temp2 =~ s/\[attachedfiles\]/$filetype/ig;
my $cstring;
if (!(-e "./comments/$date.txt")){
$cstring = "<a href=comments.cgi?blog=$date>$lang::postcomments<\/a>";
}else{
$cstring = "<a href=comments.cgi?blog=$date> $lang::postcomments</a> - " . ifcomments($date) . " $lang::total"
}
$temp2 =~ s/\[comments\]/$cstring/ig;
$return .= $temp2;
undef $printfiles;
undef $temp2;
undef $filetype;
$num++;
} # if $num <= $svb::page
} # foreach @lines
my $countpages = 1;
if ($total > $svb::page){
$return .= "<p align=right>$svb::fontsmall$lang::page <a href=index.cgi?page=$countpages>1</a> ";
while ($total-($svb::page*$countpages) > 0){
$countpages++;
$return .= "<a href=index.cgi?page=$countpages>$countpages</a> ";
}
$return .= "</font></p>";
}
$return .= "
</td>
</tr>
</table>";
return $return;
} # sub viewall
sub viewone{
my ($return,$filetype,$temp,$printfiles,@lines);
my $blog = $cur->param('blog');
$return .= "\n<center>
<table width=100%>
<tr>
<td width=70%>
<center>
$svb::fontheader$svb::title</b></font>
</center>
</td>
<td align=right>
<form method=get action=search.cgi>
<input type=text name=searchfor>
<input type=submit value='$lang::search_blogs'>
</form>
</td>
</tr>
<tr>
<td valign=top colspan=2>\n";
open (INFILE, "./$svb::post_template")||cmn::dienice("$lang::read_file_error - ./$svb::post_template\: $!!");
while (<INFILE>){
$temp .= $_;
}
close INFILE;
$temp =~ s/<!--*-->//;
open (INFILE, "./data.blog")||cmn::dienice("$lang::read_file_error - ./data.blog\: $!!");
@lines = <INFILE>;
close INFILE;
@lines = reverse @lines;
foreach (@lines){
chomp ($_);
my $temp2 = "\n\n
<br><br>
<table>
<tr>
<td>
$temp
</td>
</tr>
</table>\n\n\n";
my ($date,$title,$text) = split(/###/,$_);
if($date == $blog){
$text =~ s/\n/<br>\n/ig;
my @files = glob("$svb::htmlsystempath/$date*");
foreach (@files){
$_ =~ s/.*\/(\d+-\d+\.[\w\d]+)/$1/ig;
if($_ =~ /(\.wmv|\.mpg|\.mov|\.avi|\.rm|\.ra|\.asf|\.moov|\.movie)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/movie.png border=0 alt='$lang::movie'></a> ";
}elsif($_ =~ /(\.jpg|\.gif|\.tif|\.png|\.bmp|\.jpeg)$/ig){
$temp2 =~ s/\[picture\]/<img src=$svb::htmlpath\/$_ align=$svb::picalign>/ig;
}elsif($_ =~ /(\.pcx|\.pict|\.pdf|\.ps|\.prn|\.eps)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/image.png border=0 alt='$lang::image'></a> ";
}elsif($_ =~ /(\.doc|\.rtf|\.wps|\.txt|\.htm|\.html|\.shtml|\.pwd|\.wks|\.wpd|\.wri|\.hed|\.lwp|\.wp|\.pp|\.sxc|\.sxi)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/document.png border=0 alt='$lang::text_document'></a> ";
}elsif($_ =~ /(\.tar|\.tar.gz\.tgz|\.bz2|\.bz|\.zip|\.cab)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/archive.png border=0 alt='$lang::archive'></a> ";
}elsif($_ =~ /(\.c|\.cpp|\.cxx|\.h|\.o|\.p|\.pl|\.pm|\.cgi|\.php|\.asp|\.prg|\.sc|\.asm|\.cob
|\.cpi|\.cv|\.sh|\.tsh|\.csh|\.scp)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/code.png border=0 alt='$lang::code'></a> ";
}elsif($_ =~ /(\.wdb|\.adb|\.cdx|\.dbc|\.dbf|\.dbt|\.mdb|\.ntf|\.dif|\.slk|\.syl|\.wkq|\.wkr|\.xls)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/database.png border=0 alt='$lang::dbss'></a> ";
}elsif($_ =~ /(\.au|\.mp3|\.wav|\.ogg|\.aif|\.wma|\.ra|\.ram|\.cda|\.mp2|\.snd|\.voc|\.mod|\.mid|\.midi)$/ig){
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/audio.png border=0 alt='$lang::audio'></a> ";
}else{
$filetype .= "<a href=$svb::htmlpath/$_><img src=$svb::htmlpicpath/unknown.png border=0 alt='$lang::unknown'></a> ";
}
} # foreach @files
Lo corté ahí pero sigue...
Última edición por SEF; 16/05/2004 a las 11:55 |