Added ability to use {{.URL}} and {{.From}} in landing pages

pull/382/head
Jordan Wright 2016-09-15 00:27:10 -05:00
parent bfb7fd11e8
commit 7740bb3e95
1 changed files with 19 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"log" "log"
"net" "net"
"net/http" "net/http"
"net/mail"
"net/url" "net/url"
"os" "os"
"strings" "strings"
@ -222,7 +223,24 @@ func PhishHandler(w http.ResponseWriter, r *http.Request) {
Logger.Println(err) Logger.Println(err)
http.NotFound(w, r) http.NotFound(w, r)
} }
err = tmpl.Execute(&htmlBuff, rs) f, err := mail.ParseAddress(c.SMTP.FromAddress)
if err != nil {
Logger.Println(err)
}
fn := f.Name
if fn == "" {
fn = f.Address
}
rsf := struct {
models.Result
URL string
From string
}{
rs,
c.URL + "?rid=" + rs.RId,
fn,
}
err = tmpl.Execute(&htmlBuff, rsf)
if err != nil { if err != nil {
Logger.Println(err) Logger.Println(err)
http.NotFound(w, r) http.NotFound(w, r)