summaryrefslogtreecommitdiff
path: root/AddDummyUsers2db.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'AddDummyUsers2db.tcl')
-rwxr-xr-xAddDummyUsers2db.tcl51
1 files changed, 51 insertions, 0 deletions
diff --git a/AddDummyUsers2db.tcl b/AddDummyUsers2db.tcl
new file mode 100755
index 0000000..07c1e58
--- /dev/null
+++ b/AddDummyUsers2db.tcl
@@ -0,0 +1,51 @@
+#!/bin/sh
+# (C) 2011 by Eugeniy Mikhailov, <evgmik@gmail.com>
+# vim:set ft=tcl: \
+exec tclsh "$0" "$@"
+
+package require sqlite3
+package require md5
+
+set class [lindex $argv 0]
+if { $class eq "" } {
+ set class dummy_class
+}
+
+set dbfile $class
+
+sqlite3 db $dbfile
+
+proc dbg {msg {level 1}} {
+ if { $level <=2 } {
+ set fid [open log a+]
+ puts $fid $msg
+ close $fid
+ }
+}
+
+proc htmlErrorMsg { msg } {
+ puts "<div class=\"errormsg\">error: $msg</div>"
+}
+
+proc AddUserNonWeb { first_name last_name user_name password_hash {group_name {guest}} {id_number {}} {section_num {} } } {
+ set eval_str [concat INSERT INTO GradesTable (FirstName, LastName, UserName, PasswordHash, GroupName, IdNum, SectionNum) VALUES('$first_name', '$last_name', '$user_name', '$password_hash', '$group_name', '$id_number', '$section_num')]
+ set err [catch {db eval $eval_str } errStat]
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "the following error happen: $errStat" 3
+ }
+}
+
+
+#AddUserNonWeb first_name last_name user_name password_hash group_name id_number section_num i
+# dummy users
+AddUserNonWeb Ins "Instruch I" instructor [::md5::md5 -hex qwerty] instructor
+AddUserNonWeb Ta "Taevich, I" ta [::md5::md5 -hex qwerty] ta
+AddUserNonWeb Dan "Dandanovich" dan [::md5::md5 -hex qwerty] student
+AddUserNonWeb Ale "Alevna" ale [::md5::md5 -hex qwerty] student
+AddUserNonWeb Jon "Jonovich" jon [::md5::md5 -hex qwerty] student
+AddUserNonWeb Ale "Alevna" ale {} student
+
+
+
+# vim: ts=2 sw=2 foldmethod=indent: