#!/usr/local/bin/tclsh set infos { \ ############################################################ # PUSH.CGI V1 WRITEN BY PIERRE-MIKAEL LEGRIS # # IN TCL SCRIPT # # Create animations using multipart/x-mixed-replace # # The animation is based on the access time of files # # This program is designed to be used with a camera that # # Would be able to store pictures in a folder # # # # The program parse this folder and give 3 choices # # 1 - View a sequence a determinate from a date to another # # On the animation part, choose the START date # # The STOP Date and the time to wait between pictures # # 2 - View images when they arrive in the folder # # If you choose the Live button you'll see the last # # image which arrived in the folder "Images". As I'm # # not updating images you won't see any animation ;-) # # 3 - View a determinate picture # # # # push.cgi MUST be used with nph-putpic.cgi # # # # I don't think this is working with IExplorer # ############################################################ } ## Set the path where push.cgi can find the pictures ## Must end with "/" set path "Images/" ## Set the type of picture to display : jpg , gif set type_of_pict "jpg" ######## Nothing Need to be changed below this line ######### set pict_path "$path*.$type_of_pict" set date_list "" ### The procedure that parse picts by dates ### proc tri_picts {} { global date_list picta pict_path set picts [glob $pict_path] set picta(0) "0" foreach pict $picts { set pict_date [file mtime $pict] set date_list "$date_list $pict_date" set same_date [array get picta "$pict_date"] if {$same_date != "" } { set picta($pict_date) "$picta($pict_date) $pict" } else { set picta($pict_date) "$pict" } } set date_list [lsort -integer $date_list] } ### End of tri_picts ### ### Proc which create the default web page ### proc page_default {} { global date_list picta puts "See an animation
" set previous_date 0 puts "
" puts "Start: " set rev_date_list [lsort -integer -decreasing $date_list] set previous_date 0 puts "End:
" puts "Frequency: seconds



" puts "Live
" puts "
" puts "Checking frequency" puts "minutes" puts "seconds



" puts "See an Image" set previous_date 0 foreach date_value $rev_date_list { if {$date_value != $previous_date} { set ofile [array get picta "$date_value"] foreach pfile [lindex $ofile 1] { puts "
[clock format [lindex $ofile 0]]" puts "$pfile" } } set previous_date $date_value } } ### End page_default ### Parse the date sent by the POST method ### proc convert_time {time} { set s1 [split $time "+"] set s3 [split [lindex $s1 3] {}] proc tcut { pos s3} { return "[lindex $s3 $pos][lindex $s3 [incr pos]]" } set h_m_s "[tcut 0 $s3]:[tcut 5 $s3]:[tcut 10 $s3]" return [clock scan "[lrange $s1 0 2] $h_m_s [lrange $s1 4 5]" ] } ### End of convert_time ### Main part of the program ### #### Web page header puts "Content-type: text/html\n\n" puts "PUSH.CGI" puts "" puts "" # parse file by date tri_picts if {$env(REQUEST_METHOD) == "GET"} { puts "

PUSH


$infos
" puts "DOWNLOAD

" page_default } else { set query [read stdin $env(CONTENT_LENGTH)] set s_query [split $query "&="] if {[lindex [split $query "="] 0] == "debut"} { set d_deb [convert_time [lindex $s_query 1]] set d_fin [convert_time [lindex $s_query 3]] set ssleep [lindex $s_query end] if {$d_deb > $d_fin} { puts "The starting date must be before the Ending date" } else { puts "
SEQUENCE

" puts "From:[clock format $d_deb]
" puts "To:[clock format $d_fin]
" puts "
" puts "" puts "
" } } else { set ssleep [expr {[lindex $s_query 1] * 60 + [lindex $s_query 3]}] puts "
LIVE

" puts "Checking for images every $ssleep seconds" puts "
" puts "" puts "
" } puts "back" } puts ""