blob: 0389cb0eba8a455ca055e70b3144d116b6e87d4e (
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
|
#!/bin/sh
# (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
# vim:set ft=tcl: \
exec tclsh "$0" "$@"
package require sqlite3
package require ncgi
package require md5
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
# 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 "<body>"
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 "</body>"
# vim: ts=2 sw=2 foldmethod=indent:
|