summaryrefslogtreecommitdiff
path: root/www/WebMagick/files/patch-aa
blob: 59d209fb74bf3458f11885010bc7e1e47b6b3cf1 (plain) (blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
Index: webmagick.in
===================================================================
RCS file: /cvsroot/webmagick/WebMagick/webmagick.in,v
retrieving revision 1.117
retrieving revision 1.127
diff -u -r1.117 -r1.127
--- webmagick.in	23 Oct 2002 16:14:47 -0000	1.117
+++ webmagick.in	19 Oct 2003 09:06:14 -0000	1.127
@@ -1,6 +1,6 @@
 #! @PERL@ 
 #
-# $Id: webmagick.in,v 1.117 2002/10/23 16:14:47 clindell Exp $
+# $Id: webmagick.in,v 1.127 2003/10/19 09:06:14 ache Exp $
 #
 # You are looking at the main PERL script for WebMagick, a package to
 # intelligently create HTML and JavaScript index files and imagemaps
@@ -237,6 +237,8 @@
     $opt_webmagickrc,	# Per-directory WebMagick rc file name
     $opt_zoomfilter,
     $opt_pichtml,
+    $opt_pichtmlaltend,
+    $opt_pichtmlaltstart,
     $opt_pichtmlbottom,
     $opt_pichtmlext,
     $opt_pichtmlnav,
@@ -391,6 +393,8 @@
 $opt_date               = 1;    # Output updates date
 
 $opt_pichtml            = 0;    # Write separate HTML for each picture
+$opt_pichtmlaltend      = '';   # Some words to append to ALT
+$opt_pichtmlaltstart    = '';   # Some words to prepend to ALT
 $opt_pichtmlbottom      = '</CENTER>';
 $opt_pichtmlext         = '.html'; # Use .shtml for SSI
 $opt_pichtmlnav         = 0;    # Write navigation into pic's HTML
@@ -492,7 +496,7 @@
 $opt_framemarginwidth	= 1;		# Pixels allocated to frame margin in horizontal direction
 $opt_framemarginheight	= 1;		# Pixels allocated to frame margin in vertical direction
 $opt_framebordersize	= 3 ;		# Pixels allocated to frame border
-$opt_frameborder	= 'YES';	# Enable (YES) or disable (NO) decorative frame borders
+$opt_frameborder        = 1;            # Enable (1) or disable (0) decorative frame borders
 $opt_framestyle		= 1;		# Frame style to use (out of those available)
 
 #
@@ -596,12 +600,11 @@
 # |  |          |
 #  -------------
 $opt_framefmt{1}=
-'<FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+'<FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
  <FRAME SRC=\"${dirframelink}\" NAME=\"${opt_frame_name_dirview}\"
    MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
  <FRAME SRC=\"${pageframelink}\" NAME=\"${opt_frame_name_imageview}\"
-   MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
-</FRAMESET>';
+   MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>';
 $opt_framefmt_frames{1}=2;	# Number of frames expressed by this frame format
 
 # Three frame screen with directories listed in top-left frame,
@@ -616,16 +619,15 @@
 # |  |          |
 #  -------------
 $opt_framefmt{2}=
-'<FRAMESET COLS=\"145,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
- <FRAMESET ROWS=\"20%,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+'<FRAMESET COLS=\"145,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
+ <FRAMESET ROWS=\"20%,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
   <FRAME SRC=\"${dirframelink}\" NAME=\"${opt_frame_name_dirview}\"
     MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
   <FRAME SRC=\"${pageframelink}\" NAME=\"${opt_frame_name_thumbview}\"
     MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
  </FRAMESET>
  <FRAME SRC=\"${imageFrameLink}\" NAME=\"${opt_frame_name_imageview}\"
-   MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
-</FRAMESET>';
+   MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>';
 $opt_framefmt_frames{2}=3;	# Number of frames expressed by this frame format
 
 # Three frame screen with directories listed in left frame,
@@ -640,16 +642,15 @@
 # |  |          |
 #  -------------
 $opt_framefmt{3}=
-'<FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+'<FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
  <FRAME SRC=\"${dirframelink}\" NAME=\"${opt_frame_name_dirview}\"
    MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
- <FRAMESET ROWS=\"150,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+ <FRAMESET ROWS=\"150,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
    <FRAME SRC=\"${pageframelink}\" NAME=\"${opt_frame_name_thumbview}\"
      MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
    <FRAME SRC=\"${imageFrameLink}\" NAME=\"${opt_frame_name_imageview}\"
      MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
- </FRAMESET>
-</FRAMESET>';
+ </FRAMESET>';
 $opt_framefmt_frames{3}=3;	# Number of frames expressed by this frame format
 
 # Three frame screen with directories listed in lower-left frame,
@@ -664,16 +665,15 @@
 # |  |          |
 #  -------------
 $opt_framefmt{4}=
-'<FRAMESET ROWS=\"172,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+'<FRAMESET ROWS=\"172,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
  <FRAME SRC=\"${pageframelink}\" NAME=\"${opt_frame_name_thumbview}\"
    MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
- <FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize}>
+ <FRAMESET COLS=\"132,*\" FRAMEBORDER=${opt_frameborder} BORDER=${opt_framebordersize} FRAMESPACING=${opt_framebordersize}>
    <FRAME SRC=\"${dirframelink}\" NAME=\"${opt_frame_name_dirview}\"
      MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
    <FRAME SRC=\"${imageFrameLink}\" NAME=\"${opt_frame_name_imageview}\"
      MARGINWIDTH=${opt_framemarginwidth} MARGINHEIGHT=${opt_framemarginheight}>
- </FRAMESET>
-</FRAMESET>';
+ </FRAMESET>';
 $opt_framefmt_frames{4}=3;	# Number of frames expressed by this frame format
 
 #
@@ -793,7 +793,7 @@
 		'framemarginwidth=i'	=> \$opt_framemarginwidth,
 		'framemarginheight=i'	=> \$opt_framemarginheight,
 		'framebordersize=i'	=> \$opt_framebordersize,
-		'frameborder=s'		=> \$opt_frameborder,
+		'frameborder=i'         => \$opt_frameborder,
 		'frames!'               => \$opt_frames,
 		'framestyle=i'		=> \$opt_framestyle,
 		'header=s'		=> \$opt_header,
@@ -828,6 +828,8 @@
 		'msg_up=s'              => \$opt_msg_up,
 		'pageindexname=s'	=> \$opt_pageindexname,
 		'pichtml!'              => \$opt_pichtml,
+		'pichtmlaltend=s'       => \$opt_pichtmlaltend,
+		'pichtmlaltstart=s'     => \$opt_pichtmlaltstart,
 		'pichtmlbottom=s'       => \$opt_pichtmlbottom,
 		'pichtmlext=s'          => \$opt_pichtmlext,
 		'pichtmlnav!'           => \$opt_pichtmlnav,
@@ -1619,7 +1621,7 @@
 	 'framemarginwidth'     => !$opt_frames ? 0 : $opt_framemarginwidth,
 	 'framemarginheight'    => !$opt_frames ? 0 : $opt_framemarginheight,
 	 'framebordersize'      => !$opt_frames ? 0 : $opt_framebordersize,
-	 'frameborder'          => !$opt_frames ? "" : $opt_frameborder,
+	 'frameborder'          => !$opt_frames ? 0 : $opt_frameborder,
 	 'frames'               => $opt_frames,
 	 'framestyle'           => !$opt_frames ? 1 : $opt_framestyle,
 	 'header'		=> $opt_header,
@@ -1659,6 +1661,8 @@
 	 'numpages'		=> $numPages,
 	 'pageindexname'        => $opt_pageindexname,
 	 'pichtml'              => $opt_pichtml,
+	 'pichtmlaltend'        => !$opt_pichtml ? "" : $opt_pichtmlaltend,
+	 'pichtmlaltstart'      => !$opt_pichtml ? "" : $opt_pichtmlaltstart,
 	 'pichtmlbottom'        => !$opt_pichtml ? "" : $opt_pichtmlbottom,
 	 'pichtmlext'           => !$opt_pichtml ? "" : $opt_pichtmlext,
 	 'pichtmlnav'           => !$opt_pichtml ? 0 : $opt_pichtmlnav,
@@ -2135,7 +2139,8 @@
     print( INDEX "  <TITLE>${pageTitle}</TITLE>\n" );
 
     # Meta tags
-    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" );
+    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" )
+	if (!$opt_anonymous);
     print( INDEX "  <META NAME=\"Author\" CONTENT=\"${opt_metaauthor}\">\n" )
 	if( "$opt_metaauthor" ne '' );
     print( INDEX "  <META NAME=\"Description\" CONTENT=\"${opt_metadescription}\">\n" )
@@ -2173,20 +2178,17 @@
     print( INDEX $framespechtml );
     print( INDEX "<NOFRAMES>\n" );
     print( INDEX "<BODY\n" );
-    unless ("$opt_stylesheet" ne '')
-    {
-	    print( INDEX "  TEXT=\"${opt_colorfore}\"\n" );
-	    print( INDEX "  BGCOLOR=\"${opt_colorback}\"\n" )
-		if $opt_colorback ne 'false';
-	    print( INDEX "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
-		if defined $iconImageUrls{background};
-	    print( INDEX "  LINK=\"${opt_colorlink}\"\n" );
-	    print( INDEX "  VLINK=\"${opt_colorvlink}\"\n" );
-	    print( INDEX "  ALINK=\"${opt_coloralink}\"");
-    }
+    print( INDEX "  TEXT=\"${opt_colorfore}\"\n" );
+    print( INDEX "  BGCOLOR=\"${opt_colorback}\"\n" )
+	if $opt_colorback ne 'false';
+    print( INDEX "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
+	if defined $iconImageUrls{background};
+    print( INDEX "  LINK=\"${opt_colorlink}\"\n" );
+    print( INDEX "  VLINK=\"${opt_colorvlink}\"\n" );
+    print( INDEX "  ALINK=\"${opt_coloralink}\"");
     print( INDEX ">\n" );
     print( INDEX $indexhtml );
-    print( INDEX "</BODY>\n</NOFRAMES>\n</HTML>" );
+    print( INDEX "</BODY>\n</NOFRAMES>\n</FRAMESET>\n</HTML>" );
     close( INDEX );
 
 
@@ -2224,7 +2226,8 @@
     print( INDEX "  <BASE TARGET=\"$opt_frame_name_top\">\n" );
 
     # Meta tags
-    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" );
+    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" )
+	if (!$opt_anonymous);
     print( INDEX "  <META NAME=\"Author\" CONTENT=\"${opt_metaauthor}\">\n" )
 	if( "$opt_metaauthor" ne '' );
     print( INDEX "  <META NAME=\"Description\" CONTENT=\"${opt_metadescription}\">\n" )
@@ -2242,17 +2245,14 @@
     
     print( INDEX "</HEAD>\n" );
     print( INDEX "<BODY\n" );
-    unless ("$opt_stylesheet" ne '')
-    {
-	    print( INDEX "  TEXT=\"${opt_dircolorfore}\"\n" );
-	    print( INDEX "  BGCOLOR=\"${opt_dircolorback}\"\n" )
-		if $opt_dircolorback ne 'false';
-	    print( INDEX "  BACKGROUND=\"$iconImageUrls{dirbackground}\"\n" )
-		if defined $iconImageUrls{dirbackground};
-	    print( INDEX "  LINK=\"${opt_dircolorlink}\"\n" );
-	    print( INDEX "  VLINK=\"${opt_dircolorvlink}\"\n" );
-	    print( INDEX "  ALINK=\"${opt_dircoloralink}\"" );
-	}
+    print( INDEX "  TEXT=\"${opt_dircolorfore}\"\n" );
+    print( INDEX "  BGCOLOR=\"${opt_dircolorback}\"\n" )
+	if $opt_dircolorback ne 'false';
+    print( INDEX "  BACKGROUND=\"$iconImageUrls{dirbackground}\"\n" )
+	if defined $iconImageUrls{dirbackground};
+    print( INDEX "  LINK=\"${opt_dircolorlink}\"\n" );
+    print( INDEX "  VLINK=\"${opt_dircolorvlink}\"\n" );
+    print( INDEX "  ALINK=\"${opt_dircoloralink}\"" );
     print( INDEX ">\n");
     print( INDEX $pagedirhtml );
     print( INDEX "</BODY></HTML>\n" );
@@ -2361,7 +2361,8 @@
 	if ($opt_frames);
 
     # Meta tags
-    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" );
+    print( INDEX "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" )
+	if (!$opt_anonymous);
     print( INDEX "  <META NAME=\"Author\" CONTENT=\"${opt_metaauthor}\">\n" )
 	if( "$opt_metaauthor" ne '' );
     print( INDEX "  <META NAME=\"Description\" CONTENT=\"${opt_metadescription}\">\n" )
@@ -2379,16 +2380,13 @@
 
     print( INDEX "</HEAD>\n" );
     print( INDEX "<BODY\n" );
-    unless ("$opt_stylesheet" ne '')
-    {
-	    print( INDEX "  TEXT=\"${opt_colorfore}\"\n" );
-	    print( INDEX "  BGCOLOR=\"${opt_colorback}\"\n" );
-	    print( INDEX "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
-		if defined $iconImageUrls{background};
-	    print( INDEX "  LINK=\"${opt_colorlink}\"\n" );
-	    print( INDEX "  VLINK=\"${opt_colorvlink}\"\n" );
-	    print( INDEX "  ALINK=\"${opt_coloralink}\"" );
-    }
+    print( INDEX "  TEXT=\"${opt_colorfore}\"\n" );
+    print( INDEX "  BGCOLOR=\"${opt_colorback}\"\n" );
+    print( INDEX "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
+	if defined $iconImageUrls{background};
+    print( INDEX "  LINK=\"${opt_colorlink}\"\n" );
+    print( INDEX "  VLINK=\"${opt_colorvlink}\"\n" );
+    print( INDEX "  ALINK=\"${opt_coloralink}\"" );
     print( INDEX ">\n");
 
     print( INDEX "${opt_header}\n" ) if ("$opt_header" ne '');
@@ -2397,8 +2395,12 @@
     if( $numimages > 0 ) {
 	# Total HACK!!!
 	if( !$opt_frames || $opt_framestyle == 1 ) {
-	    print( INDEX "<p><FONT SIZE=\"-1\">${opt_msg_index_of_files}\"$imageNames[$pageNumber - 1][0]\" ${opt_msg_index_through}",
-		  " \"$imageNames[$pageNumber - 1][$numimages-1]\"</FONT></p>\n" );
+	    print( INDEX "<p><FONT SIZE=\"-1\">${opt_msg_index_of_files}\"",
+		  escapehtml($imageNames[$pageNumber - 1][0]),
+		  "\" ${opt_msg_index_through}",
+		  " \"",
+		  escapehtml($imageNames[$pageNumber - 1][$numimages-1]),
+		  "\"</FONT></p>\n" );
 	}
 	print( INDEX "$indexbar<BR>\n" );
 
@@ -2433,25 +2435,34 @@
 	
 	    my $pic = $imageNames[$pageNumber - 1][$imageNum];
 	    my $pichtml;
+	    my $altlabel;
 	    my $target = '';
+
 	    if ($opt_pichtml && $opt_frames && "$opt_pichtmltarget" ne '') {
 		$target = " TARGET=\"${opt_pichtmltarget}\"";
 	    }
+	    if (defined($imageLabels{$pic})) {
+		$altlabel = $imageLabels{$pic};
+	    } else {
+		($altlabel = $pic) =~ s/(.*)\.\w+$/$1/i;
+		$altlabel =~ y/_/ /; # Usual space replacement in file name
+	    }
+	    $altlabel = escapehtml($opt_pichtmlaltstart . $altlabel . $opt_pichtmlaltend);
 
 	    if ( $opt_pichtml ) {
 			
 			$pichtml = $pic . $opt_pichtmlext;
-
 			open( PICHTML, ">$pichtml")
 			    || die("$0: Failed to open file $pichtml for output\n$@\n");
 			print( PICHTML "<HTML>\n<HEAD>\n" );
 			# Charset is better before title
 			print( PICHTML "  <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=${opt_metacharset}\">\n" )
 			    if( "$opt_metacharset" ne '' );
-			print( PICHTML "  <TITLE>$pic</TITLE>\n" );
+			print( PICHTML "  <TITLE>${altlabel}</TITLE>\n" );
 
 			# Meta tags
-			print( PICHTML "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" );
+			print( PICHTML "  <META NAME=\"GENERATOR\" CONTENT=\"WebMagick/$webmagickInfo{version} [WebMagick]\">\n" )
+			    if (!$opt_anonymous);
 			print( PICHTML "  <META NAME=\"Author\" CONTENT=\"${opt_metaauthor}\">\n" )
 			    if( "$opt_metaauthor" ne '' );
 			print( PICHTML "  <META NAME=\"Description\" CONTENT=\"${opt_metadescription}\">\n" )
@@ -2469,28 +2480,19 @@
 
 			print( PICHTML "</HEAD>\n" );
 			print( PICHTML "<BODY\n" );
-			unless ("$opt_stylesheet" ne '')
-	    		{
-				print( PICHTML "  TEXT=\"${opt_colorfore}\"\n" );
-				print( PICHTML "  BGCOLOR=\"${opt_colorback}\"\n" );
-				print( PICHTML "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
-				    if defined $iconImageUrls{background};
-				print( PICHTML "  LINK=\"${opt_colorlink}\"\n" );
-				print( PICHTML "  VLINK=\"${opt_colorvlink}\"\n" );
-				print( PICHTML "  ALINK=\"${opt_coloralink}\"");
-			}
+			print( PICHTML "  TEXT=\"${opt_colorfore}\"\n" );
+			print( PICHTML "  BGCOLOR=\"${opt_colorback}\"\n" );
+			print( PICHTML "  BACKGROUND=\"$iconImageUrls{background}\"\n" )
+			    if defined $iconImageUrls{background};
+			print( PICHTML "  LINK=\"${opt_colorlink}\"\n" );
+			print( PICHTML "  VLINK=\"${opt_colorvlink}\"\n" );
+			print( PICHTML "  ALINK=\"${opt_coloralink}\"");
 			print( PICHTML ">\n" );
 
 			print( PICHTML "$opt_pichtmltop") if ("$opt_pichtmltop" ne '');
 
 			if ($opt_pichtmlputtitle) {
-			    print ( PICHTML "${opt_pichtmltitlestart}");
-			    if (defined( $imageLabels{$pic})) {
-				print( PICHTML "$imageLabels{$pic}");
-			    } else {
-				print( PICHTML "$pic");
-			    }
-			    print ( PICHTML "${opt_pichtmltitleend}");
+			    print ( PICHTML "${opt_pichtmltitlestart}${altlabel}${opt_pichtmltitleend}");
 			}
 
 			if ($opt_pichtmlnav) {
@@ -2526,9 +2528,9 @@
 				} else {
 					print ( PICHTML "<A${target} HREF=\"");
 					if ($imageNum == 0 && $pageNumber != 1) {
-						print ( PICHTML $imageNames[$pageNumber - 2][$#{$imageNames[$pageNumber - 2]}]);
+						print ( PICHTML escapeurl($imageNames[$pageNumber - 2][$#{$imageNames[$pageNumber - 2]}]) );
 					} else {
-						print ( PICHTML $imageNames[$pageNumber - 1][${imageNum} - 1]);
+						print ( PICHTML escapeurl($imageNames[$pageNumber - 1][${imageNum} - 1]) );
 					}
 					print ( PICHTML $opt_pichtmlext);
 					print ( PICHTML "\"><IMG SRC=\"$iconImageUrls{'prev'}\"",
@@ -2543,9 +2545,9 @@
 				} else {
 					print ( PICHTML "<A${target} HREF=\"");
 					if (($imageNum == $#{$imageNames[$pageNumber - 1]}) && $pageNumber != $numPages) {
-						print ( PICHTML $imageNames[$pageNumber][0]);
+						print ( PICHTML escapeurl($imageNames[$pageNumber][0]) );
 					} else {
-						print ( PICHTML $imageNames[$pageNumber - 1][${imageNum} + 1]);
+						print ( PICHTML escapeurl($imageNames[$pageNumber - 1][${imageNum} + 1]) );
 					}
 					print ( PICHTML $opt_pichtmlext);
 					print ( PICHTML "\"><IMG SRC=\"$iconImageUrls{'next'}\"",
@@ -2556,10 +2558,10 @@
 				print ( PICHTML "</NOBR><BR>");
 			}
 
-			if ( $pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i ) {
-			    print( PICHTML "<IMG SRC=\"$pic\" ALT=\"\">" );
+			if ($pic =~ /\.(jpg|jpeg?|gif|xbm|png)$/i) {
+			    print( PICHTML "<IMG SRC=\"", escapeurl($pic), "\" ALT=\"${altlabel}\">" );
 			} else {
-			    print( PICHTML "<A HREF=\"", escapeurl($pic), "\"><BIG><B>$pic</B></A> ", fsize($pic), "</BIG>" );
+			    print( PICHTML "<A HREF=\"", escapeurl($pic), "\"><BIG><B>", escapehtml($pic), "</B></A> ", fsize($pic), "</BIG>" );
 			}
 
 			print( PICHTML "$opt_pichtmlbottom\n") if ("$opt_pichtmlbottom" ne '');
@@ -2601,12 +2603,16 @@
 			# TODO: make sure the thumbnails are created, and get some image sizes
 			# TODO: save the labels in a new array, maybe same with sizes
 			if ( $thumbImageSizes{$pic}) {
-				print (INDEX "<IMG SRC=\"", $opt_cachedir, "/", escapeurl($pic), ".\L${opt_cacheformat}", "\" $thumbImageSizes{$pic} BORDER=0>");
+				print (INDEX "<IMG SRC=\"", $opt_cachedir, "/", escapeurl($pic), ".\L${opt_cacheformat}",
+				       "\" $thumbImageSizes{$pic} ALT=\"${altlabel}\" BORDER=0>");
 			} else {
-				print (INDEX "<IMG SRC=\"", escapeurl($pic), "\" BORDER=0>");
+				print (INDEX "<IMG SRC=\"", escapeurl($pic),
+				       "\" ALT=\"${altlabel}\" BORDER=0>");
 			}
 			
-			print (INDEX "</A><BR><FONT SIZE=\"-1\">" . $tableImageLabels{$imageNames[$pageNumber - 1][$imageNum]} . "</FONT></TD>\n");
+			print (INDEX "</A><BR><FONT SIZE=\"-1\">",
+				escapehtml($tableImageLabels{$imageNames[$pageNumber - 1][$imageNum]}),
+				"</FONT></TD>\n");
 						
 			if ($imageNum%$opt_columns == ($opt_columns - 1))
 			{
@@ -4156,25 +4162,29 @@
   --footer           Page footer (imagemap frame) (default to </CENTER>)
   --header           Page header (imagemap frame) (default to <CENTER>)
   --[no]javascript   Enable JavaScript output (default off)
+  --[no]readmevisible Show README.html on first page rather than just linking (default off)
+  --[no]tables       Use HTML tables instead of imagemaps for thumbnails (default off)
+  --title            Page title
+
+Per-image HTML options:
   --[no]pichtml      Per-image HTML file generation (default off)
-  --pichtmlext       Per-image HTML file extension (default .html)
+  --pichtmlaltend    Some words to append to ALT= (default "")
+  --pichtmlaltstart  Some words to prepend to ALT= (default "")
   --pichtmlbottom    Per-image HTML, extra HTML to display below image (default to </CENTER>)
+  --pichtmlext       Per-image HTML file extension (default .html)
   --[no]pichtmlnav   Per-image HTML, show navigation buttons (default off)
   --[no]pichtmlputtitle Put per-image HTML picture title (default on)
   --pichtmltarget    Per-image HTML default frame target
   --pichtmltitleend  End tags for per-image HTML picture title (default </P>)
   --pichtmltitlestart Start tags for per-image HTML picture title (default <P>)
   --pichtmltop       Per-image HTML, extra HTML to display above image (default to <CENTER>)
-  --[no]readmevisible Show README.html on first page rather than just linking (default off)
-  --[no]tables       Use HTML tables instead of imagemaps for thumbnails (default off)
-  --title            Page title
 
 Frame Options:
   --[no]frames       Use frames, if no - single directory collection assumed (default on)
   --framemarginwidth Pixels allocated to frame margin in horizontal direction
   --framemarginheight Pixels allocated to frame margin in vertical direction
   --framebordersize  Pixels allocated to frame border
-  --frameborder      Enable (YES) or disable (NO) decorative frame borders
+  --frameborder      Enable (1) or disable (0) decorative frame borders
   --framestyle       Frame style to use (out of those available)
   --[no]allowconfig  Allow user to configure framestyle, columns and rows (requires javascript and tables) (default off)
 
@@ -4296,6 +4306,7 @@
     s/&/&amp;/g;
     s/>/&gt;/g;
     s/</&lt;/g;
+    s/\"/&quot;/g;  # because we use "xxx" form sometimes
     return( $_ );
 }
 
@@ -4324,22 +4335,10 @@
 # Escape unsafe characters in URLs
 #		
 sub escapeurl {
+    no locale;
     local($_) = @_;
-    s/\%/%25/g;		# % (must substitute first!)
-    s/\"/%22/g;		# "
-    s/\#/%23/g;		# #
-    s/\</%3C/g;		# <
-    s/\>/%3E/g;		# >
-    s/\[/%5B/g;		# [
-    #s/\\/%5C/g;		# \
-    s/\]/%5D/g;		# ]
-    s/\^/%5E/g;		# ^
-    s/\`/%60/g;		# `
-    s/\{/%7B/g;		# {
-    s/\|/%7C/g;		# |
-    s/\}/%7D/g;		# }
-    s/\~/%7E/g;		# ~
-    s/ /%20/g;          # " "
+    # ' is here because some bots (Google) goes crazy on "xxx'xxx"
+    s/([][\x00-\x20"#%'<>^`{|}~\x7F-\xFF])/sprintf("%%%02x", ord($1))/eg;
     s:\\:/:g; # replace \ with / for better URLs
     return( $_ );
 }