summaryrefslogtreecommitdiff
path: root/www/devcon/show.cgi
blob: c8123b38e0f28801d9665d609cd225a02d595c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl

use File::Basename;

$cgi = basename $0;

print "Content-Type: text/html\n\n";

$image = $ARGV[0];

$image =~ /img(\d+)/;

print "<html><head><title>Rockbox - Photo $1</title></head>\n";
print "<body bgcolor=black text=white link=white vlink=gray>\n";

if ($image eq "" ) {
    print "<p>No image specified\n";
    exit;
}

print "<h1>&nbsp;</h1><div align=center><img src=$image>\n";

# compressed image
if ( $image =~ /img(\d+).jpg/ ) {
    $num = $1;
    for $i ( 1 .. 10 ) {
	$prev = sprintf("%04d",$num-$i);
	last if ( -f "img$prev.jpg" ); 
    }
    if ( $prev == $num-10 ) {
	undef $prev;
    }

    for $i ( 1 .. 20 ) { 
	$next = sprintf("%04d",$num+$i);
	print "<!-- Trying $next -->\n";
	last if ( -f "img$next.jpg" );
    }
    if ( $next == $num+20 ) {
	undef $next;
    }

    if ( -f "bildtext.txt" ) {
	open FILE, "<bildtext.txt";
	@txt = <FILE>;
	close FILE;
	@match = grep /^$num: /, @txt;
	if ( $match[0] =~ /^$num: (.*)/ ) {
	    print "<p><i>$1</i>\n";
	}
    }


    print "<p>\n";
    print "<a href=$cgi?img$prev.jpg>&lt; Previous</a>  &nbsp; \n" if ( $prev );
    print "<a href=.>Index</a>\n";
    if ( -f "IMG_$num.JPG" ) {
        $size = int( (stat("IMG_$num.JPG"))[7] / 1024 );
	print " &nbsp; <a href=IMG_$num.JPG>Fullsize ($size kB)</a>\n";
    }

    print " &nbsp; <a href=$cgi?img$next.jpg>Next &gt;</a>\n" if ( $next );

}

# showing fullsize already
elsif ( $image =~ /IMG_(\d+).JPG/ ) {
    $num = $1;
    for $i ( 1 .. 10 ) {
	$prev = sprintf("%04d",$num-$i);
	last if ( -f "IMG_$prev.JPG" ); 
    }
    if ( $prev == $num-10 ) {
	undef $prev;
    }

    for $i ( 1 .. 20 ) { 
	$next = sprintf("%04d",$num+$i);
	print "<!-- Trying $next -->\n";
	last if ( -f "IMG_$next.JPG" );
    }
    if ( $next == $num+20 ) {
	undef $next;
    }

    print "<p>\n";
    print "<a href=$cgi?IMG_$prev.JPG>&lt; Previous</a>  &nbsp; \n" if ( $prev );
    print "<a href=.>Index</a>\n";
    if ( -f "img$num.jpg" ) {
        $size = int( (stat("img$num.jpg"))[7] / 1024 );
	print " &nbsp; <a href=img$num.jpg>Small ($size kB)</a>\n";
    }

    print " &nbsp; <a href=$cgi?IMG_$next.JPG>Next &gt;</a>\n" if ( $next );
}
print "</div></body></html>\n";