get_session_stmt,err=db.Prepare("SELECT `uid`, `name`, `group`, `is_super_admin`, `session` FROM `users` WHERE `uid` = ? AND `session` = ? AND `session` <> ''")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing create_topic statement.")
create_topic_stmt,err=db.Prepare("INSERT INTO topics(title,createdAt,lastReplyAt,createdBy) VALUES(?,?,0,?)")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing create_reply statement.")
create_reply_stmt,err=db.Prepare("INSERT INTO replies(tid,content,createdAt,createdBy) VALUES(?,?,?,?)")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing edit_topic statement.")
edit_topic_stmt,err=db.Prepare("UPDATE topics SET title = ? WHERE tid = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing edit_reply statement.")
edit_reply_stmt,err=db.Prepare("UPDATE replies SET content = ? WHERE rid = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing delete_reply statement.")
delete_reply_stmt,err=db.Prepare("DELETE FROM replies WHERE rid = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing login statement.")
login_stmt,err=db.Prepare("SELECT `uid`, `name`, `password`, `salt` FROM `users` WHERE `name` = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing update_session statement.")
update_session_stmt,err=db.Prepare("UPDATE users SET session = ? WHERE uid = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing logout statement.")
logout_stmt,err=db.Prepare("UPDATE users SET session = '' WHERE uid = ?")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing set_password statement.")
set_password_stmt,err=db.Prepare("UPDATE users SET password = ?, salt = ? WHERE uid = ?")
iferr!=nil{
log.Fatal(err)
}
// Add an admin version of register_stmt with more flexibility
// create_account_stmt, err = db.Prepare("INSERT INTO
log.Print("Preparing register statement.")
register_stmt,err=db.Prepare("INSERT INTO users(`name`,`password`,`salt`,`group`,`is_super_admin`,`session`) VALUES(?,?,?,0,0,?)")
iferr!=nil{
log.Fatal(err)
}
log.Print("Preparing get_session statement.")
username_exists_stmt,err=db.Prepare("SELECT `name` FROM `users` WHERE `name` = ?")
iferr!=nil{
log.Fatal(err)
}
}
funcmain(){
varerrerror
init_database(err);
log.Print("Loading the custom pages.")
err=filepath.Walk("pages/",add_custom_page)
iferr!=nil{
log.Fatal(err)
}
// In a directory to stop it clashing with the other paths