parent
509082fad3
commit
d77606506c
13
README.md
13
README.md
|
@ -5,6 +5,11 @@ A super fast forum software written in Go.
|
||||||
The initial code-base was forked from one of my side projects, and converted from the web framework it was using.
|
The initial code-base was forked from one of my side projects, and converted from the web framework it was using.
|
||||||
|
|
||||||
|
|
||||||
|
# Features
|
||||||
|
Basic Forum Functionality
|
||||||
|
|
||||||
|
Custom Pages
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
|
@ -23,6 +28,8 @@ go install golang.org/x/crypto/bcrypt
|
||||||
|
|
||||||
Tweak the config.go file and put your database details in there.
|
Tweak the config.go file and put your database details in there.
|
||||||
|
|
||||||
|
Set the password column of your user account in the database to what you want your password to be. The system will encrypt your password when you login for the first time.
|
||||||
|
|
||||||
|
|
||||||
# Run the program
|
# Run the program
|
||||||
|
|
||||||
|
@ -38,8 +45,6 @@ Oh my, you caught me right at the start of this project. There's nothing to see
|
||||||
|
|
||||||
More moderation features.
|
More moderation features.
|
||||||
|
|
||||||
Fix the login system. It broke during the switch in frameworks.
|
|
||||||
|
|
||||||
Fix the bug where errors are sent off in raw HTML rather than formatted HTML.
|
Fix the bug where errors are sent off in raw HTML rather than formatted HTML.
|
||||||
|
|
||||||
Add an alert system.
|
Add an alert system.
|
||||||
|
@ -51,3 +56,7 @@ Add a complex permissions system.
|
||||||
Add a settings system.
|
Add a settings system.
|
||||||
|
|
||||||
Add a plugin system.
|
Add a plugin system.
|
||||||
|
|
||||||
|
Revamp the system for serving static files to make it much faster.
|
||||||
|
|
||||||
|
Tweak the CSS to make it responsive.
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Database details
|
// Database details
|
||||||
|
var dbhost = "127.0.0.1"
|
||||||
var dbuser = "root"
|
var dbuser = "root"
|
||||||
var dbpassword = "password"
|
var dbpassword = "password"
|
||||||
var dbname = "grosolo"
|
var dbname = "grosolo"
|
||||||
|
var dbport = "3306" // You probably won't need to change this
|
||||||
|
|
|
@ -35,7 +35,7 @@ func init_database(err error) {
|
||||||
if(dbpassword != ""){
|
if(dbpassword != ""){
|
||||||
dbpassword = ":" + dbpassword
|
dbpassword = ":" + dbpassword
|
||||||
}
|
}
|
||||||
db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(127.0.0.1:3306)/" + dbname)
|
db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ func init_database(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
_ = get_session_stmt // Bug fix, compiler isn't recognising this despite it being used, probably because it's hidden behind if statements
|
|
||||||
|
|
||||||
log.Print("Preparing create_topic statement.")
|
log.Print("Preparing create_topic statement.")
|
||||||
create_topic_stmt, err = db.Prepare("INSERT INTO topics(title,createdAt,lastReplyAt,createdBy) VALUES(?,?,0,?)")
|
create_topic_stmt, err = db.Prepare("INSERT INTO topics(title,createdAt,lastReplyAt,createdBy) VALUES(?,?,0,?)")
|
||||||
|
@ -150,7 +149,7 @@ func main(){
|
||||||
http.HandleFunc("/topic/edit/submit/", route_edit_topic) //POST
|
http.HandleFunc("/topic/edit/submit/", route_edit_topic) //POST
|
||||||
|
|
||||||
// Custom Pages
|
// Custom Pages
|
||||||
http.HandleFunc("/pages/:name/", route_custom_page)
|
http.HandleFunc("/pages/", route_custom_page)
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
http.HandleFunc("/accounts/login/", route_login)
|
http.HandleFunc("/accounts/login/", route_login)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<html></html>
|
Testing
|
|
@ -27,7 +27,7 @@ func route_overview(w http.ResponseWriter, r *http.Request){
|
||||||
|
|
||||||
func route_custom_page(w http.ResponseWriter, r *http.Request){
|
func route_custom_page(w http.ResponseWriter, r *http.Request){
|
||||||
user := SessionCheck(w,r)
|
user := SessionCheck(w,r)
|
||||||
name := r.URL.Path[len("/edit/"):]
|
name := r.URL.Path[len("/pages/"):]
|
||||||
|
|
||||||
val, ok := custom_pages[name];
|
val, ok := custom_pages[name];
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -594,16 +594,17 @@ func route_login_submit(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = update_session_stmt.Exec(session, user.ID)
|
_, err = update_session_stmt.Exec(session, uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InternalError(err,w,r,user)
|
InternalError(err,w,r,user)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Successful Login")
|
log.Print("Successful Login")
|
||||||
cookie := http.Cookie{"uid",strconv.Itoa(uid),"/","",time.Now(),"",0,true,false,"",[]string{}}
|
log.Print("Session: " + session)
|
||||||
|
cookie := http.Cookie{Name: "uid",Value: strconv.Itoa(uid),Path: "/",MaxAge: year}
|
||||||
http.SetCookie(w,&cookie)
|
http.SetCookie(w,&cookie)
|
||||||
cookie = http.Cookie{"session",session,"/","",time.Now(),"",0,true,false,"",[]string{}}
|
cookie = http.Cookie{Name: "session",Value: session,Path: "/",MaxAge: year}
|
||||||
http.SetCookie(w,&cookie)
|
http.SetCookie(w,&cookie)
|
||||||
http.Redirect(w,r, "/", http.StatusSeeOther)
|
http.Redirect(w,r, "/", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
@ -697,9 +698,9 @@ func route_register_submit(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cookie := http.Cookie{"uid",strconv.FormatInt(lastId, 10),"/","",time.Now(),"",0,true,false,"",[]string{}}
|
cookie := http.Cookie{Name: "uid",Value: strconv.FormatInt(lastId, 10),Path: "/",MaxAge: year}
|
||||||
http.SetCookie(w,&cookie)
|
http.SetCookie(w,&cookie)
|
||||||
cookie = http.Cookie{"session",session,"/","",time.Now(),"",0,true,false,"",[]string{}}
|
cookie = http.Cookie{Name: "session",Value: session,Path: "/",MaxAge: year}
|
||||||
http.SetCookie(w,&cookie)
|
http.SetCookie(w,&cookie)
|
||||||
http.Redirect(w,r, "/", http.StatusSeeOther)
|
http.Redirect(w,r, "/", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue