#!/bin/sh # (C) 2010 by Eugeniy Mikhailov, # vim:set ft=tcl: \ exec tclsh "$0" "$@" # require Tcl version of at least 8.5 since I use 'ni' and 'in' in expressions for lists package require Tcl 8.5 package require sqlite3 package require ncgi package require md5 set execution_start_time [clock microseconds] source ./GradeBook_lib.tcl ::ncgi::parse # defaults set sortCol LastName set user guest set password guest set action defaultview # defaults end # read cookies set user [::ncgi::cookie user] set sortCol [::ncgi::cookie sortCol] set password [::ncgi::cookie password] set action [::ncgi::value action defaultview] # end of read cookies # get hostname if { [catch {set host_name $env(SERVER_NAME)} errStat] } { set request_uri unknown} # script uri if { [catch {set script_name $env(SCRIPT_NAME)} errStat] } { set script_name unknown} # figure out course db filename if { [catch {set request_uri $env(REQUEST_URI)} errStat] } { set request_uri unknown} regsub -all $script_name $request_uri "" coursedbfname regsub -all {\?.*$} $coursedbfname "" coursedbfname regsub -all {^/} $coursedbfname "" coursedbfname set script_name "$script_name/$coursedbfname" set timestamp [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"] #CreateGradesTable db #CreateAccessRightsTable db dbg [::ncgi::names] 4 # logon and logoff actions are granted to everyone if { $action == "logon" } { set action [ LogMeOn ] } if { $action == "logoff" } { LogMeOff; set action defaultview } dbg "===== Connection at $timestamp for user $user =====" ::ncgi::header htmlHeader puts "" set dbfile "courses/$coursedbfname" dbg "DB filename: $dbfile" if { ($coursedbfname ne "") && [file exists $dbfile] } { sqlite3 db $dbfile set permission_list [AccessGroupRights db $user $password] htmlTop $permission_list ChoseAction $action $permission_list $user } else { htmlErrorMsg "No requested database {$coursedbfname}. Please, check your url" dbg "Attemt to access non existing database: {$dbfile}" } htmlFooter $permission_list puts "" # vim: ts=2 sw=2 foldmethod=indent: