d976a192fb
Revamped the configuration system. If you have trouble installing this, try installing my fork of gopsutil with `go get` and delete the users_penalties table from the schema folder. That stuff will be cleaned up in the next commit. Fixed an issue with the links for the Uncategorised forum being broken. Swapped out NOW() for UTC_TIMESTAMP() in MySQL queries. We now get an error message when the server goes down for whatever reason. The template compiler now supports pointers. Swapped out shirou/gopsutil for a fork locked on an older and more stable commit of the same library. Fixed a bug where the preprocessor didn't play nice with empty CSS files. Added the site name to the navbar. Added more things to .gitignore Laid the foundations for the next commit.
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
/* Under heavy development */
|
|
/* Copyright Azareal 2017 - 2018 */
|
|
package main
|
|
|
|
import "fmt"
|
|
import "strings"
|
|
import "database/sql"
|
|
import _ "github.com/go-sql-driver/mysql"
|
|
|
|
// We don't need SSL to run an installer... Do we?
|
|
var db_sslmode = "disable"
|
|
|
|
func _set_pgsql_adapter() {
|
|
db_port = "5432"
|
|
init_database = _init_pgsql
|
|
}
|
|
|
|
func _init_pgsql() (err error) {
|
|
_db_password := db_password
|
|
if _db_password != "" {
|
|
_db_password = " password=" + _pg_escape_bit(_db_password)
|
|
}
|
|
db, err = sql.Open("postgres", "host='" + _pg_escape_bit(db_host) + "' port='" + _pg_escape_bit(db_port) + "' user='" + _pg_escape_bit(db_username) + "' dbname='" + _pg_escape_bit(db_name) + "'" + _db_password + " sslmode='" + db_sslmode + "'")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println("Successfully connected to the database")
|
|
|
|
// TO-DO: Create the database, if it doesn't exist
|
|
|
|
return nil
|
|
}
|
|
|
|
func _pg_escape_bit(bit string) string {
|
|
// TO-DO: Write a custom parser, so that backslashes work properly in the sql.Open string. Do something similar for the database driver, if possible?
|
|
return strings.Replace(bit,"'","\\'",-1)
|
|
} |