Permalink
Browse files

Small changes and bugfixes from OSDN coding frenzy.

  • Loading branch information...
1 parent 511f638 commit a959e738b33f01b6e60357444dd5c505da59736b @pudge pudge committed Aug 14, 2000
View
@@ -1,6 +1,6 @@
package Bundle::Slash;
-$Bundle::Slash::VERSION = '1.0.6';
+$Bundle::Slash::VERSION = '1.0.7';
1;
@@ -22,6 +22,8 @@ Bundle::LWP - URI,HTML::Parser,MIME::Base64
Bundle::DBI - Storable
+DBI::FAQ
+
Bundle::DBD::mysql - Data::ShowTable
Date::Parse - TimeDate
View
@@ -532,9 +532,7 @@ sub getUser {
}
# Do we want the index stuff?
- if (!$ENV{SCRIPT_NAME} || $ENV{SCRIPT_NAME} =~ /index/) {
- getExtraStuff('index');
- }
+ getExtraStuff('index');
} else {
getAnonCookie();
@@ -677,7 +675,7 @@ sub setCookie {
my %cookie = (
-name => $name,
-path => $I{cookiepath},
- -value => $val,
+ -value => $val || '',
);
$cookie{-expires} = '+1y' unless $session;
@@ -969,7 +967,7 @@ EOT
$cursor->finish;
return $tablestuff if $notable;
- fancybox(200, 'Poll', $tablestuff, 'c');
+ fancybox($I{fancyboxwidth}, 'Poll', $tablestuff, 'c');
}
@@ -1527,18 +1525,14 @@ EOT
########################################################
sub getAd {
- return "<!--#perl sub=\"sub { require Slash; use Slash; print Slash::getAd(); }\" -->"
+ my $num = $_[0] || 1;
+
+ return qq|<!--#perl sub="sub { use Slash; print Slash::getAd($num); }" -->|
unless $ENV{SCRIPT_NAME};
anonLog() unless $ENV{SCRIPT_NAME} =~ /\.pl/; # Log non .pl pages
- my $ad .= <<EOT;
-<center>
-$ENV{AD_BANNER_1}
-</center>
-<p>
-EOT
- return $ad;
+ return $ENV{"AD_BANNER_$num"};
}
########################################################
@@ -1603,7 +1597,7 @@ EOT
}
if ($I{run_ads}) {
- $adhtml = getAd();
+ $adhtml = getAd(1);
}
my $topics;
@@ -1692,8 +1686,17 @@ sub fancybox {
my($width, $title, $contents) = @_;
return unless $title && $contents;
- my $mainwidth = $width-4;
+ my $tmpwidth = $width;
+ my $pct = 1 if $tmpwidth =~ s/%$//;
+ # used in some blocks
+ my $mainwidth = $tmpwidth-4;
my $insidewidth = $mainwidth-8;
+ if ($pct) {
+ for ($mainwidth, $insidewidth) {
+ $_ .= '%';
+ }
+ }
+
my $execme = getWidgetBlock('fancybox');
print eval $execme;
print "\nError:$@\n" if $@;
@@ -1716,8 +1719,16 @@ sub portalbox {
my $execme = getWidgetBlock('portalmap');
$title = eval $execme if $bid;
- my $mainwidth = $width-4;
+ my $tmpwidth = $width;
+ my $pct = 1 if $tmpwidth =~ s/%$//;
+ # used in some blocks
+ my $mainwidth = $tmpwidth-4;
my $insidewidth = $mainwidth-8;
+ if ($pct) {
+ for ($mainwidth, $insidewidth) {
+ $_ .= '%';
+ }
+ }
$execme = getWidgetBlock('fancybox');
my $e = eval $execme;
View
@@ -1,8 +1,13 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -sw
# get recent comments
-# pudge@pobox.com, 2000.06.02
+# pudge@pobox.com, 2000.06.02 - 2000.08.14
+# call with -sid to print by sid, not just date
+# call with -cid to direct URL to specific CID, not entire article
+
+use vars qw(@a $sid $cid %I);
use lib '..';
+use strict;
use Slash;
*I = getSlashConf;
@@ -12,33 +17,61 @@ my $comm = sqlSelectMany(
'', 'ORDER BY date DESC LIMIT ' . (shift || 30)
);
-my $len = 38 + length($I{rootdir});
+my($cidlink, $scriptname, $baselen);
+if ($cid) {
+ $cidlink = '&cid=';
+ $scriptname = 'comments';
+ $baselen = 43;
+} else {
+ $cidlink = '#';
+ $scriptname = 'article';
+ $baselen = 38;
+}
+my $len = $baselen + length($I{rootdir});
my $lines = '-' x $len;
my $lts = '<' x ($len-3);
+my(%sids, %dates);
init();
-while (@a = $comm->fetchrow) {
- push @a, "$I{rootdir}/article.pl?sid=$a[0]#$a[1]";
- write;
+while (my @data = $comm->fetchrow) {
+ my $cidlink =
+ @a = (@data, "$I{rootdir}/$scriptname.pl?sid=$data[0]$cidlink$data[1]");
+ if ($sid) {
+ push @{$sids{$data[0]}}, [@a];
+ $dates{$data[0]} = $data[3]
+ if !$dates{$data[0]}
+ || $dates{$data[0]} lt $data[3];
+ } else {
+ write;
+ }
+}
+
+if ($sid) {
+ for my $sid (sort { $dates{$b} cmp $dates{$a} } keys %dates) {
+ for (sort { $b->[0] cmp $a->[0] } @{$sids{$sid}}) {
+ @a = @$_;
+ write;
+ }
+ }
}
print <<EOT; # footer
-+------------------+--------+-------+---------------------+$lines+
++------------------+------+-------+---------------------+$lines+
EOT
sub init {
eval <<EOT;
format STDOUT_TOP =
-+------------------+--------+-------+---------------------+$lines+
-| sid | cid | uid | date | url${\(' ' x ($len-4))}|
-+------------------+--------+-------+---------------------+$lines+
++------------------+------+-------+---------------------+$lines+
+| sid | cid | uid | date | url${\(' ' x ($len-4))}|
++------------------+------+-------+---------------------+$lines+
.
EOT
eval <<EOT;
format STDOUT =
-| \@<<<<<<<<<<<<<<< | \@<<<<< | \@<<<< | \@<<<<<<<<<<<<<<<<<< | \@$lts |
+| \@<<<<<<<<<<<<<<< | \@<<< | \@<<<< | \@<<<<<<<<<<<<<<<<<< | \@$lts |
\@a
.
EOT
View
@@ -27,6 +27,8 @@
###############################################################################
use strict;
use vars '%I';
+use File::Basename;
+use File::Path;
use Slash;
*I = getSlashConf();
@@ -157,7 +159,7 @@ for (@{$E}) {
"$I{basedir}/$section/$sid"."_F.shtml");
unlink("$I{basedir}/$section/$sid.shtml")
- or die "Can't unlink $I{basedir}/$section/$sid.shtml: $!";
+ or warn "Can't unlink $I{basedir}/$section/$sid.shtml: $!";
symlink("$I{basedir}/$section/${sid}_F.shtml", "$I{basedir}/$section/$sid.shtml")
or die "Can't symlink $I{basedir}/$section/${sid}_F.shtml -> $sid.shtml";
$I{dbh}->do("DELETE FROM comments WHERE sid='$sid'");
@@ -224,18 +226,14 @@ EOT
sub prog2file {
my($c, $f) = @_;
-# print "$c $f\n";
-
my $d = `$c`;
- $d =~ s/[\t\n\r\s ]+/ /g;
+ my $dir = dirname($f);
+ mkpath($dir, 0, 0755) unless -e $dir;
if (length($d) > 0) {
+ local *F;
open F, ">$f" or die "Can't open $f: $!";
print F $d;
close F;
- # Do some scp's
- # system("scp $d root@linux360.dn.net:$d");
- # system("scp $d root@linux361.dn.net:$d");
- # system("scp $d root@linux362.dn.net:$d"); # Only do 362 first!
return "1";
} else {
View
@@ -745,19 +745,19 @@ sub colorEdit {
<TR>
<TD>Background color 1 \$I{bg}[1]</TD>
<TD><INPUT TYPE="TEXT" WIDTH="12" NAME="bg1" VALUE="$colors[5]"></TD>
- <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[5]">Background color 1 \$I{fg}[1]</FONT></TD>
+ <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[5]">Background color 1 \$I{bg}[1]</FONT></TD>
<TD BGCOLOR="$colors[5]">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TD>
<TR>
<TD>Background color 2 \$I{bg}[2]</TD>
<TD><INPUT TYPE="TEXT" WIDTH="12" NAME="bg2" VALUE="$colors[6]"></TD>
- <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[6]">Background color 2 \$I{fg}[2]</FONT></TD>
+ <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[6]">Background color 2 \$I{bg}[2]</FONT></TD>
<TD BGCOLOR="$colors[6]">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR>
<TD>Background color 3 \$I{bg}[3]</TD>
<TD><INPUT TYPE="TEXT" WIDTH="12" NAME="bg3" VALUE="$colors[7]"></TD>
- <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[7]">Background color 3 \$I{fg}[3]</FONT></TD>
+ <TD><FONT FACE="ARIAL,HELVETICA" SIZE="+1" COLOR="$colors[7]">Background color 3 \$I{bg}[3]</FONT></TD>
<TD BGCOLOR="$colors[7]">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR>
@@ -1183,7 +1183,7 @@ sub editstory {
$S->{relatedtext} = getRelated("$S->{title} $S->{bodytext} $S->{introtext}")
. otherLinks($S->{aid}, $S->{tid});
- fancybox(200, 'Related Links', $S->{relatedtext});
+ fancybox($I{fancyboxwidth}, 'Related Links', $S->{relatedtext});
$I{query}->param('relatedtext', $S->{relatedtext});
$I{query}->hidden('relatedtext');
@@ -1202,7 +1202,7 @@ sub editstory {
$I{currentSection} = $tmp;
print '</TD><TD WIDTH="220" VALIGN="TOP">';
- fancybox(200,'Related Links', $S->{relatedtext});
+ fancybox($I{fancyboxwidth},'Related Links', $S->{relatedtext});
$I{query}->param('relatedtext', $S->{relatedtext});
print '</TD></TR></TABLE>';
@@ -1313,14 +1313,15 @@ sub editstory {
print <<EOT;
Extended Copy<BR>
- <TEXTAREA NAME="bodytext" COLS="70" WRAP="VIRTUAL" ROWS="10">$bodytext</TEXTAREA><BR>
-Import Image (don't even both trying this yet :)<BR>
- <INPUT TYPE="file" NAME="importme"><BR>
+ <TEXTAREA NAME="bodytext" COLS="70" WRAP="VIRTUAL" ROWS="40">$bodytext</TEXTAREA><BR>
<!-- end edit story -->
EOT
+#Import Image (don't even both trying this yet :)<BR>
+# <INPUT TYPE="file" NAME="importme"><BR>
+
editbuttons($newarticle);
}
View
@@ -80,10 +80,10 @@ sub main {
pollbooth($I{F}{sid}) if sqlSelect('qid', 'pollquestions', "qid='$S->{sid}'");
# Related Links
- fancybox(200, 'Related Links', $S->{relatedtext});
+ fancybox($I{fancyboxwidth}, 'Related Links', $S->{relatedtext});
# Display this section's Section Block (if Found)
- fancybox(200, $SECT->{title}, getblock($SECT->{section}));
+ fancybox($I{fancyboxwidth}, $SECT->{title}, getblock($SECT->{section}));
print qq!</TD></TR><TR><TD COLSPAN="3">\n!;
@@ -156,7 +156,7 @@ sub pleaseLogin {
my $block = eval prepBlock getblock('userlogin');
$block =~ s/index\.pl/article.pl?sid=$I{F}{sid}/;
$block =~ s/\$I{rootdir}/$I{rootdir}/g;
- fancybox(200, "$I{sitename} Login", $block);
+ fancybox($I{fancyboxwidth}, "$I{sitename} Login", $block);
}
##################################################################
@@ -192,7 +192,7 @@ sub yourArticle {
$m .= "<P> $I{U}{mylinks} ";
- fancybox(200, $I{U}{aid} || $I{U}{nickname}, $m);
+ fancybox($I{fancyboxwidth}, $I{U}{aid} || $I{U}{nickname}, $m);
}
##################################################################
@@ -52,14 +52,14 @@ sub main {
my $b;
while (my($block, $title, $bid, $url) = $c->fetchrow) {
if ($bid eq "mysite") {
- $b = portalbox(200, "$I{U}{nickname}'s Slashbox",
+ $b = portalbox($I{fancyboxwidth}, "$I{U}{nickname}'s Slashbox",
$I{U}{mylinks} || $block
);
} elsif ($bid =~ /_more$/) {
} elsif ($bid eq "userlogin") {
} else {
- $b = portalbox(200, $title, $block, "", $url);
+ $b = portalbox($I{fancyboxwidth}, $title, $block, "", $url);
}
print $b;
View
@@ -41,9 +41,11 @@ sub main {
# $I{F}{mode} = $I{U}{mode}="dynamic" if $ENV{SCRIPT_NAME};
for ($I{F}{op}) {
- /^u$/ and upBid($I{F}{bid});
- /^d$/ and dnBid($I{F}{bid});
- /^x$/ and rmBid($I{F}{bid});
+ my $c;
+ upBid($I{F}{bid}), $c++ if /^u$/;
+ dnBid($I{F}{bid}), $c++ if /^d$/;
+ rmBid($I{F}{bid}), $c++ if /^x$/;
+ redirect($ENV{SCRIPT_NAME}) if $c;
}
my $SECT = getSection($I{F}{section});
@@ -176,24 +178,24 @@ sub displayStandardBlocks {
foreach my $bid (@boxes) {
if ($bid eq 'mysite') {
print portalbox(
- 200, "$I{U}{nickname}'s Slashbox",
+ $I{fancyboxwidth}, "$I{U}{nickname}'s Slashbox",
$I{U}{mylinks} || 'This is your user space. Love it.',
$bid
);
} elsif ($bid =~ /_more$/) {
- print portalbox(200,"Older Stuff",
+ print portalbox($I{fancyboxwidth},"Older Stuff",
getOlderStories($olderStuff, $SECT),
$bid) if $olderStuff;
} elsif ($bid eq "userlogin" && $I{U}{uid} > 0) {
# Don't do nuttin'
} elsif ($bid eq "userlogin") {
my $SB = $I{boxBank}{$bid};
my $B = eval prepBlock $I{blockBank}{$bid};
- print portalbox(200, $SB->{title}, $B, $SB->{bid}, $SB->{url});
+ print portalbox($I{fancyboxwidth}, $SB->{title}, $B, $SB->{bid}, $SB->{url});
} else {
my $SB = $I{boxBank}{$bid};
my $B = $I{blockBank}{$bid};
- print portalbox(200, $SB->{title}, $B, $SB->{bid}, $SB->{url});
+ print portalbox($I{fancyboxwidth}, $SB->{title}, $B, $SB->{bid}, $SB->{url});
}
}
}
Oops, something went wrong.

0 comments on commit a959e73

Please sign in to comment.