Index: openacs-4/packages/acs-subsite/www/shared/1pixel.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/shared/1pixel.tcl,v diff -u -r1.2 -r1.2.2.1 --- openacs-4/packages/acs-subsite/www/shared/1pixel.tcl 13 Mar 2002 22:50:53 -0000 1.2 +++ openacs-4/packages/acs-subsite/www/shared/1pixel.tcl 6 May 2003 07:05:10 -0000 1.2.2.1 @@ -1,40 +1,55 @@ # 1pixel.tcl,v 1.1.2.2 2000/02/03 10:00:24 ron Exp -# File: index.tcl -# Date: 28 Nov 1999 -# Author: Jon Salz -# Description: Generates a 1-pixel GIF image with a certain color. -# Inputs: r g b +ad_page_contract { + Generates a 1-pixel GIF image with a certain color. + + @author Jon Salz + @creation-date 28 Nov 1999 + @cvs-id $Id$ +} { + r:integer + g:integer + b:integer +} + ReturnHeaders "image/gif" -set_the_usual_form_variables +if { [catch { + set file [open "[acs_package_root_dir "acs-subsite"]/www/shared/1pixel.header"] + ns_writefp $file + close $file -set file [open "[acs_package_root_dir "acs-subsite"]/www/shared/1pixel.header"] -ns_writefp $file -close $file + if { [util_aolserver_2_p] } { + if { $r == 0 } { set r 1 } + if { $g == 0 } { set g 1 } + if { $b == 0 } { set b 1 } -if { [util_aolserver_2_p] } { - if { $r == 0 } { set r 1 } - if { $g == 0 } { set g 1 } - if { $b == 0 } { set b 1 } + ns_write "[format "%c%c%c" $r $g $b]" + } else { + # Can't figure out how to write binary data using AOLserver 3 (it + # insist on UTF8-encoding it). So we write to a file, then dump + # the file's contents. - ns_write "[format "%c%c%c" $r $g $b]" -} else { - # Can't figure out how to write binary data using AOLserver 3 (it - # insist on UTF8-encoding it). So we write to a file, then dump - # the file's contents. + set file_name [ns_tmpnam] + ns_log "Notice" "logging to $file_name" + set file [open $file_name w+] + fconfigure $file -encoding binary + puts -nonewline $file "[format "%c%c%c" $r $g $b]" + seek $file 0 + ns_writefp $file + close $file + ns_unlink $file_name + } - set file_name [ns_tmpnam] - ns_log "Notice" "logging to $file_name" - set file [open $file_name w+] - fconfigure $file -encoding binary - puts -nonewline $file "[format "%c%c%c" $r $g $b]" - seek $file 0 + set file [open "[acs_package_root_dir "acs-subsite"]/www/shared/1pixel.footer"] ns_writefp $file close $file - ns_unlink $file_name -} -set file [open "[acs_package_root_dir "acs-subsite"]/www/shared/1pixel.footer"] -ns_writefp $file -close $file +} errMsg] } { + # Ignore simple i/o errors, which probably just mean that the user surfed on + # to some other page before we finished serving + if { ![string equal $errMsg {i/o failed}] } { + global errorInfo + ns_log Error "$errMsg\n$errorInfo" + } +}