func init() { var err error Connection, err = sql.Open("sqlite3", option.String("dbpath")) if err != nil { logrus.WithFields(logrus.Fields{ "Path": option.String("dbpath"), }).Error(err) } }
func Patch() { errors, ok := migrate.UpSync("sqlite3://"+option.String("dbpath"), "migrations") if !ok { for _, err := range errors { logrus.WithFields(logrus.Fields{ "Path": option.String("dbpath"), }).Error(err.Error()) } } }
func CheckPatch() uint64 { patch, _ := migrate.Version("sqlite3://"+option.String("dbpath"), "migrations") return patch }
func hashpassword(password string) string { hash := md5.Sum([]byte(password + option.String("passwordsalt"))) password = string(hash[:]) return password }
package server import ( "github.com/ospokemon/ospokemon/option" "net/http" ) var fileserver = http.FileServer(http.Dir(option.String("webpath"))) var PageHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if s := readsession(r); s != nil { s.Refresh() } fileserver.ServeHTTP(w, r) })
func Launch() { routes() go PollSessionExpire() e := http.ListenAndServe(":"+option.String("port"), nil) logrus.Error(e) }