Esempio n. 1
0
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)
	}
}
Esempio n. 2
0
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())
		}
	}
}
Esempio n. 3
0
func CheckPatch() uint64 {
	patch, _ := migrate.Version("sqlite3://"+option.String("dbpath"), "migrations")

	return patch
}
Esempio n. 4
0
func hashpassword(password string) string {
	hash := md5.Sum([]byte(password + option.String("passwordsalt")))
	password = string(hash[:])
	return password
}
Esempio n. 5
0
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)
})
Esempio n. 6
0
func Launch() {
	routes()
	go PollSessionExpire()
	e := http.ListenAndServe(":"+option.String("port"), nil)
	logrus.Error(e)
}