Exemple #1
0
func adminSupportOpen(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	userId, err := strconv.Atoi(mux.Vars(r)["id"])
	if err != nil {
		lobster.RedirectMessage(w, r, "/admin/support", L.FormattedError("invalid_user"))
		return
	}
	user := lobster.UserDetails(userId)
	if user == nil {
		lobster.RedirectMessage(w, r, "/admin/support", L.FormattedError("user_not_found"))
		return
	}

	if r.Method == "POST" {
		form := new(AdminSupportOpenForm)
		err := decoder.Decode(form, r.PostForm)
		if err != nil {
			http.Redirect(w, r, fmt.Sprintf("/admin/support/open/%d", userId), 303)
			return
		}

		ticketId, err := ticketOpen(form.UserId, form.Name, form.Message, true)
		if err != nil {
			lobster.RedirectMessage(w, r, fmt.Sprintf("/admin/support/open/%d", userId), L.FormatError(err))
		} else {
			http.Redirect(w, r, fmt.Sprintf("/admin/support/%d", ticketId), 303)
		}
		return
	}

	params := new(AdminSupportOpenParams)
	params.Frame = frameParams
	params.User = user
	params.Token = lobster.CSRFGenerate(session)
	lobster.RenderTemplate(w, "admin", "support_open", params)
}
Exemple #2
0
func panelSupportOpen(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	if r.Method == "POST" {
		form := new(SupportOpenForm)
		err := decoder.Decode(form, r.PostForm)
		if err != nil {
			http.Redirect(w, r, "/panel/support/open", 303)
			return
		}

		ticketId, err := ticketOpen(session.UserId, form.Name, form.Message, false)
		if err != nil {
			lobster.RedirectMessage(w, r, "/panel/support/open", L.FormatError(err))
		} else {
			lobster.LogAction(session.UserId, lobster.ExtractIP(r.RemoteAddr), "Open ticket", fmt.Sprintf("Subject: %s; Ticket ID: %d", form.Name, ticketId))
			http.Redirect(w, r, fmt.Sprintf("/panel/support/%d", ticketId), 303)
		}
		return
	}

	lobster.RenderTemplate(
		w,
		"panel",
		"support_open",
		lobster.PanelFormParams{Frame: frameParams, Token: lobster.CSRFGenerate(session)},
	)
}
Exemple #3
0
func (this *SolusVM) handleConsole(w http.ResponseWriter, r *http.Request, db *lobster.Database, session *lobster.Session, frameParams lobster.FrameParams) {
	params := ConsoleParams{}
	params.Frame = frameParams
	params.Host = r.URL.Query().Get("host")
	params.Port = r.URL.Query().Get("port")
	params.Username = r.URL.Query().Get("username")
	params.Password = r.URL.Query().Get("password")
	lobster.RenderTemplate(w, "panel", "solusvm_console", params)
}
Exemple #4
0
func (this *PaypalPayment) Payment(w http.ResponseWriter, r *http.Request, frameParams lobster.FrameParams, userId int, username string, amount float64) {
	cfg := lobster.GetConfig()
	frameParams.Scripts = append(frameParams.Scripts, "paypal")
	params := &PaypalTemplateParams{
		Frame:     frameParams,
		Business:  this.business,
		Amount:    amount,
		UserId:    userId,
		NotifyUrl: cfg.Default.UrlBase + PAYPAL_CALLBACK,
		ReturnUrl: this.returnUrl,
		Currency:  cfg.Billing.Currency,
	}
	lobster.RenderTemplate(w, "panel", "paypal", params)
}
Exemple #5
0
func (sp *StripePayment) form(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	cents, _ := strconv.ParseInt(r.URL.Query().Get("cents"), 10, 64)
	user := lobster.UserDetails(session.UserId)
	cfg := lobster.GetConfig()
	params := &StripeTemplateParams{
		Frame:    frameParams,
		Token:    lobster.CSRFGenerate(session),
		Key:      sp.publishableKey,
		Cents:    cents,
		Currency: cfg.Billing.Currency,
		Amount:   float64(cents) / 100,
		Email:    user.Email,
	}
	lobster.RenderTemplate(w, "panel", "stripe", params)
}
Exemple #6
0
func adminSupportTicket(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	ticketId, err := strconv.Atoi(mux.Vars(r)["id"])
	if err != nil {
		lobster.RedirectMessage(w, r, "/admin/support", L.FormattedError("invalid_ticket"))
		return
	}
	ticket := TicketDetails(session.UserId, ticketId, true)
	if ticket == nil {
		lobster.RedirectMessage(w, r, "/admin/support", L.FormattedError("ticket_not_found"))
		return
	}

	params := AdminSupportTicketParams{}
	params.Frame = frameParams
	params.Ticket = ticket
	params.Token = lobster.CSRFGenerate(session)
	lobster.RenderTemplate(w, "admin", "support_ticket", params)
}
Exemple #7
0
func adminSupport(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	params := AdminSupportParams{}
	params.Frame = frameParams
	params.Tickets = TicketListAll()
	lobster.RenderTemplate(w, "admin", "support", params)
}
Exemple #8
0
func panelSupport(w http.ResponseWriter, r *http.Request, session *lobster.Session, frameParams lobster.FrameParams) {
	params := SupportParams{}
	params.Frame = frameParams
	params.Tickets = TicketList(session.UserId)
	lobster.RenderTemplate(w, "panel", "support", params)
}