This commit is contained in:
98
Pages/Request.cshtml
Normal file
98
Pages/Request.cshtml
Normal file
@@ -0,0 +1,98 @@
|
||||
@page
|
||||
@model RequestModel
|
||||
@{
|
||||
ViewData["Title"] = "Request";
|
||||
}
|
||||
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="jumbotron text-center">
|
||||
<h2>Request AyaNova subscription trial account</h2>
|
||||
</div>
|
||||
<div>
|
||||
<form class="form form-horizontal" method="post">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="SubRequest.Name" class="col-md-3 right">Name:</label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="SubRequest.Name" class="form-control" required autofocus />
|
||||
<span asp-validation-for="SubRequest.Name"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="SubRequest.Company" class="col-md-3 right">Company:</label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="SubRequest.Company" placeholder="Your Company Name" class="form-control"
|
||||
required />
|
||||
<span asp-validation-for="SubRequest.Company"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="SubRequest.Email" class="col-md-3 right">Email:</label>
|
||||
<div class="col-md-9">
|
||||
<input asp-for="SubRequest.Email" placeholder="email@you.com" class="form-control"
|
||||
required />
|
||||
<span asp-validation-for="SubRequest.Email"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label asp-for="SubRequest.DataCenter" class="col-md-3 right">Data center (closest to
|
||||
you):</label>
|
||||
<div class="col-md-9">
|
||||
<select asp-for="SubRequest.DataCenter" asp-items="Model.DataCenters"></select>
|
||||
<span asp-validation-for="SubRequest.DataCenter"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Button -->
|
||||
<div class="form-group">
|
||||
|
||||
<label class="col-md-4 control-label" for="Send"></label>
|
||||
<div class="col-md-4">
|
||||
<div class="g-recaptcha" data-callback="imNotARobot"
|
||||
data-sitekey="6LcH7GUUAAAAAJIDf_JDZolSv__xN6oqr9Dx79zs">
|
||||
</div>
|
||||
<button id="btnsubmit" type="submit" class="btn btn-info">Send us your request</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!--start bottom container-->
|
||||
<div class="container text-center">
|
||||
<div class="row">
|
||||
<hr>
|
||||
<small><span> © 2022 Ground Zero Tech-Works, Inc</span>
|
||||
|
||||
<br>
|
||||
<span><a href="https://ayanova.com/r/privacy.htm">Privacy Policy</a></span></small>
|
||||
</div>
|
||||
</div>
|
||||
<!--end bottom container-->
|
||||
185
Pages/Request.cshtml.cs
Normal file
185
Pages/Request.cshtml.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
//for captcha:
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace contact.Pages
|
||||
{
|
||||
[BindProperties(SupportsGet = true)]
|
||||
public class RequestFormModel
|
||||
{
|
||||
public RequestFormModel()
|
||||
{
|
||||
DataCenter = "SF";
|
||||
}
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string Company { get; set; }
|
||||
|
||||
[Required, EmailAddress]
|
||||
public string Email { get; set; }
|
||||
[Required]
|
||||
public string DataCenter { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class RequestModel : PageModel
|
||||
{
|
||||
// public string DataCenter { get; set; }
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public RequestFormModel SubRequest { get; set; }
|
||||
|
||||
public List<SelectListItem> DataCenters { get; } = new List<SelectListItem>
|
||||
{
|
||||
new SelectListItem { Value = "SF", Text = "San Francisco" },
|
||||
new SelectListItem { Value = "NY", Text = "New York" },
|
||||
new SelectListItem { Value = "TOR", Text = "Toronto" },
|
||||
new SelectListItem { Value = "AMS", Text = "Amsterdam" },
|
||||
new SelectListItem { Value = "LON", Text = "London" },
|
||||
new SelectListItem { Value = "FFT", Text = "Frankfurt" },
|
||||
new SelectListItem { Value = "SNG", Text = "Singapore" },
|
||||
new SelectListItem { Value = "BNG", Text = "Bangalore" },
|
||||
};
|
||||
|
||||
private readonly IConfiguration _configuration;
|
||||
public RequestModel(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public ActionResult OnPost()
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return Page();
|
||||
}
|
||||
|
||||
|
||||
if (!ReCaptchaPassed(
|
||||
Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
|
||||
_configuration.GetSection("GoogleReCaptcha:secret").Value
|
||||
))
|
||||
{
|
||||
//Return a fail code that will hopefully take us off the spammers list
|
||||
return StatusCode(500);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//fuck those spammers
|
||||
//2022-05-06 changes to get rid of jumbo lead magnet spammer but still force him to pay someone to manually enter the stuff
|
||||
//ideally it should read from a text file here but this is a quickie fix while Joyce is on important viha phone call
|
||||
var blocks = new List<string>();
|
||||
blocks.Add("google");
|
||||
blocks.Add("jumboleadmagnet");//<--fuck this guy in particular, keeps spamming
|
||||
blocks.Add("boostleadgeneration");
|
||||
//ericjonesmyemail@gmail.com
|
||||
var companyname = SubRequest.Company.ToLowerInvariant();
|
||||
foreach (string s in blocks)
|
||||
{
|
||||
if (companyname.Contains(s))
|
||||
{
|
||||
goto skipspam;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SendMail();
|
||||
|
||||
skipspam:
|
||||
return Redirect("https://ayanova.com/docs/ay-evaluate/");
|
||||
}
|
||||
|
||||
|
||||
private void SendMail()
|
||||
{
|
||||
var MessageBody = $"Name:\r\n{SubRequest.Name}\r\n\r\nCompany:\r\n{SubRequest.Company}\r\n\r\nDataCenter:\r\n{SubRequest.DataCenter}";
|
||||
|
||||
//SEND TO US
|
||||
using (var message = new MailMessage())
|
||||
{
|
||||
message.To.Add(new MailAddress("support@ayanova.com"));
|
||||
message.From = new MailAddress(SubRequest.Email);
|
||||
message.Subject = $"Trial request from {SubRequest.Company}";
|
||||
message.Body = MessageBody;
|
||||
using (var smtpClient = new SmtpClient("smtp.fastmail.com"))
|
||||
{
|
||||
|
||||
smtpClient.Host = "smtp.fastmail.com";
|
||||
smtpClient.Port = 587;
|
||||
smtpClient.UseDefaultCredentials = false;
|
||||
//testing
|
||||
smtpClient.EnableSsl = true;
|
||||
|
||||
// smtpClient.Port=465;
|
||||
// smtpClient.DeliveryMethod= SmtpDeliveryMethod.Network;
|
||||
|
||||
|
||||
|
||||
//NOTE: Do not use the noreply email address to send mail, it crashes the server somehow
|
||||
|
||||
//******************************************************************************************************************
|
||||
//******************************************************************************************************************
|
||||
//TEST CRASH
|
||||
// smtpClient.Credentials = new System.Net.NetworkCredential("noreply@ayanova.com", "91768700489f8edd28aa71e3e0f4073eba54ce83c4c1a6a910700fa94094ddfd");
|
||||
|
||||
|
||||
//FASTMAIL CHANGES
|
||||
//Fastmail server names and ports help page: https://www.fastmail.help/hc/en-us/articles/1500000278342
|
||||
//APP Password created in fastmail for smtp use only labelled 'contact-form': cnea8agl6nlx5j7l
|
||||
|
||||
//try using from as support@onayanova.com
|
||||
//try domain version if this still won't work
|
||||
smtpClient.Credentials = new System.Net.NetworkCredential("support@onayanova.com", "cnea8agl6nlx5j7l");
|
||||
//******************************************************************************************************************
|
||||
//******************************************************************************************************************
|
||||
|
||||
smtpClient.Send(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void OnGet()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool ReCaptchaPassed(string gRecaptchaResponse, string secret)
|
||||
{
|
||||
HttpClient httpClient = new HttpClient();
|
||||
var res = httpClient.GetAsync($"https://www.google.com/recaptcha/api/siteverify?secret={secret}&response={gRecaptchaResponse}").Result;
|
||||
if (res.StatusCode != HttpStatusCode.OK)
|
||||
{
|
||||
// logger.LogError("Error while sending request to ReCaptcha");
|
||||
return false;
|
||||
}
|
||||
|
||||
string JSONres = res.Content.ReadAsStringAsync().Result;
|
||||
dynamic JSONdata = JObject.Parse(JSONres);
|
||||
if (JSONdata.success != "true")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user