Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Feb 20, 2023
1 parent a2b05da commit 90ed054
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 36 deletions.
19 changes: 12 additions & 7 deletions Merchant/B2PAY.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async public Task<ActionResult> Index(string email)
["order_number"] = CrypTo.md5(DateTime.Now.ToBinary().ToString()),
["type_payment"] = "merchant",
["usr"] = "new",
["custom_field"] = email,
["custom_field"] = email.ToLower().Trim(),
["callback_url"] = CrypTo.Base64($"{AppInit.Host(HttpContext)}/b2pay/callback"),
["success_url"] = CrypTo.Base64($"{AppInit.Host(HttpContext)}/buy/success.html"),
["error_url"] = CrypTo.Base64($"{AppInit.Host(HttpContext)}/buy/error.html")
Expand Down Expand Up @@ -63,7 +63,7 @@ async public Task<ActionResult> Callback()
if (!AppInit.conf.Merchant.B2PAY.enable)
return StatusCode(403);

string orderNumber = string.Empty;
string orderNumber = string.Empty, status = string.Empty;
if (HttpContext.Request.Method == HttpMethods.Post && HttpContext.Request.ContentLength > 0)
{
var buffer = new byte[Convert.ToInt32(HttpContext.Request.ContentLength)];
Expand All @@ -72,17 +72,22 @@ async public Task<ActionResult> Callback()
var requestContent = Encoding.UTF8.GetString(buffer);
await System.IO.File.AppendAllTextAsync("merchant/log/b2pay.txt", requestContent + "\n\n\n");

status = Regex.Match(requestContent, "\"status\":\"([^\"]+)\"").Groups[1].Value;
orderNumber = Regex.Match(requestContent, "\"orderNumber\":\"([^\"]+)\"").Groups[1].Value;
}

if (string.IsNullOrWhiteSpace(orderNumber) || !System.IO.File.Exists($"merchant/invoice/b2pay/{orderNumber}"))
if (status != "approved" || string.IsNullOrWhiteSpace(orderNumber) || !System.IO.File.Exists($"merchant/invoice/b2pay/{orderNumber}"))
return StatusCode(403);

var invoice = JsonConvert.DeserializeObject<Dictionary<string, string>>(await System.IO.File.ReadAllTextAsync($"merchant/invoice/b2pay/{orderNumber}"));
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{invoice["custom_field"].ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},b2pay\n");
string users = await System.IO.File.ReadAllTextAsync("merchant/users.txt");

if (!AppInit.conf.accsdb.accounts.Contains(invoice["custom_field"].ToLower()))
AppInit.cacheconf.Item2 = default;
if (!users.Contains($",b2pay,{orderNumber}"))
{
var invoice = JsonConvert.DeserializeObject<Dictionary<string, string>>(await System.IO.File.ReadAllTextAsync($"merchant/invoice/b2pay/{orderNumber}"));
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{invoice["custom_field"].ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},b2pay,{orderNumber}\n");

AppInit.conf.accsdb.accounts.Add(invoice["custom_field"]);
}

return Content("YES");
}
Expand Down
14 changes: 9 additions & 5 deletions Merchant/CryptoCloud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async public Task<ActionResult> Index(string email)
["shop_id"] = AppInit.conf.Merchant.CryptoCloud.SHOPID,
//["currency"] = "USD",
//["order_id"] = CrypTo.md5(DateTime.Now.ToBinary().ToString()),
["email"] = email
["email"] = email.ToLower().Trim()
};

var root = await HttpClient.Post<JObject>("https://api.cryptocloud.plus/v1/invoice/create", new System.Net.Http.FormUrlEncodedContent(postParams), addHeaders: new List<(string name, string val)>()
Expand Down Expand Up @@ -65,11 +65,15 @@ async public Task<ActionResult> Callback(string invoice_id)
if (root == null || root.Value<string>("status") != "success" || root.Value<string>("status_invoice") != "paid")
return StatusCode(403);

var invoice = JsonConvert.DeserializeObject<Dictionary<string, string>>(await System.IO.File.ReadAllTextAsync($"merchant/invoice/cryptocloud/{invoice_id}"));
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{invoice["email"].ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},cryptocloud\n");
string users = await System.IO.File.ReadAllTextAsync("merchant/users.txt");

if (!AppInit.conf.accsdb.accounts.Contains(invoice["email"].ToLower()))
AppInit.cacheconf.Item2 = default;
if (!users.Contains($",cryptocloud,{invoice_id}"))
{
var invoice = JsonConvert.DeserializeObject<Dictionary<string, string>>(await System.IO.File.ReadAllTextAsync($"merchant/invoice/cryptocloud/{invoice_id}"));
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{invoice["email"].ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},cryptocloud,{invoice_id}\n");

AppInit.conf.accsdb.accounts.Add(invoice["email"]);
}

return StatusCode(200);
}
Expand Down
14 changes: 9 additions & 5 deletions Merchant/FreeKassa.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async public Task<ActionResult> Index(string email)

string transid = DateTime.Now.ToBinary().ToString().Replace("-", "");

await System.IO.File.WriteAllTextAsync($"merchant/invoice/freekassa/{transid}", email);
await System.IO.File.WriteAllTextAsync($"merchant/invoice/freekassa/{transid}", email.ToLower().Trim());

string hash = CrypTo.md5($"{AppInit.conf.Merchant.FreeKassa.shop_id}:{AppInit.conf.Merchant.accessCost}:{AppInit.conf.Merchant.FreeKassa.secret}:USD:{transid}");
return Redirect("https://pay.freekassa.ru/" + $"?m={AppInit.conf.Merchant.FreeKassa.shop_id}&oa={AppInit.conf.Merchant.accessCost}&o={transid}&s={hash}&currency=USD");
Expand All @@ -39,11 +39,15 @@ async public Task<ActionResult> Callback(string AMOUNT, long MERCHANT_ORDER_ID,

if (CrypTo.md5($"{AppInit.conf.Merchant.FreeKassa.shop_id}:{AMOUNT}:{AppInit.conf.Merchant.FreeKassa.secret}:{MERCHANT_ORDER_ID}") == SIGN)
{
string email = await System.IO.File.ReadAllTextAsync($"merchant/invoice/freekassa/{MERCHANT_ORDER_ID}");
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{email.ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},freekassa\n");
string users = await System.IO.File.ReadAllTextAsync("merchant/users.txt");

if (!AppInit.conf.accsdb.accounts.Contains(email.ToLower()))
AppInit.cacheconf.Item2 = default;
if (!users.Contains($",freekassa,{MERCHANT_ORDER_ID}"))
{
string email = await System.IO.File.ReadAllTextAsync($"merchant/invoice/freekassa/{MERCHANT_ORDER_ID}");
await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{email.ToLower()},{DateTime.UtcNow.AddYears(1).ToFileTimeUtc()},freekassa,{MERCHANT_ORDER_ID}\n");

AppInit.conf.accsdb.accounts.Add(email);
}

return Content("YES");
}
Expand Down
3 changes: 1 addition & 2 deletions Merchant/Litecoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ async static Task ChekTransactions()

await System.IO.File.AppendAllTextAsync("merchant/users.txt", $"{email},{DateTime.UtcNow.AddDays(addday).ToFileTimeUtc()},litecoin\n");

if (!AppInit.conf.accsdb.accounts.Contains(email))
AppInit.cacheconf.Item2 = default;
AppInit.conf.accsdb.accounts.Add(email);
}
catch { }
}
Expand Down
18 changes: 12 additions & 6 deletions Online/OnlineApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.Caching.Memory;
using System;
using IO = System.IO;
using System.Reflection;

namespace Lampac.Controllers
{
Expand Down Expand Up @@ -159,7 +160,7 @@ public ActionResult LifeEvents(long id)

[HttpGet]
[Route("lite/events")]
async public Task<ActionResult> Events(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial = -1, bool life = false)
async public Task<ActionResult> Events(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial = -1, bool life = false, string account_email = null)
{
string online = string.Empty;
bool isanime = original_language == "ja";
Expand All @@ -170,13 +171,18 @@ async public Task<ActionResult> Events(long id, string imdb_id, long kinopoisk_i
{
foreach (var item in AppInit.modules)
{
foreach (var mod in item.online)
if (item.online.enable)
{
if (mod.enable)
try
{
if (serial == -1 || isanime && mod.anime || serial == 1 && mod.serial || serial == 0 && mod.movie)
online += "{\"name\":\"" + mod.name + "\",\"url\":\"" + mod.url + "\"},";
if (item.assembly.GetType(item.online.@namespace) is Type t && t.GetMethod("Events") is MethodInfo m)
{
string result = (string)m.Invoke(null, new object[] { host, account_email, id, imdb_id, kinopoisk_id, title, original_title, original_language, year, source, serial });
if (!string.IsNullOrWhiteSpace(result))
online += result;
}
}
catch { }
}
}
}
Expand All @@ -187,7 +193,7 @@ async public Task<ActionResult> Events(long id, string imdb_id, long kinopoisk_i
if (!string.IsNullOrWhiteSpace(conf.VoKino.token) && (serial == -1 || serial == 0))
online += "{\"name\":\"" + (conf.VoKino.displayname ?? "VoKino") + "\",\"url\":\"{localhost}/vokino\"},";

if (!string.IsNullOrWhiteSpace(conf.KinoPub.token))
if (conf.KinoPub.enable)
online += "{\"name\":\"" + (conf.KinoPub.displayname ?? "KinoPub") + "\",\"url\":\"{localhost}/kinopub\"},";

if (conf.Filmix.enable)
Expand Down
2 changes: 1 addition & 1 deletion Shared/AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Lampac
public class AppInit
{
#region conf
public static (AppInit, DateTime) cacheconf = default;
static (AppInit, DateTime) cacheconf = default;

public static AppInit conf
{
Expand Down
2 changes: 2 additions & 0 deletions Shared/Models/LITE/KinoPubSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public KinoPubSettings(string apihost = null)
this.apihost = apihost;
}

public bool enable { get; set; }

public string displayname { get; set; }

public string apihost { get; set; }
Expand Down
10 changes: 1 addition & 9 deletions Shared/Models/Module/OnlineMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ public class OnlineMod
{
public bool enable { get; set; }

public string name { get; set; }

public string url { get; set; }

public bool movie { get; set; }

public bool serial { get; set; }

public bool anime { get; set; }
public string @namespace { get; set; }
}
}
2 changes: 1 addition & 1 deletion Shared/Models/Module/RootModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RootModule

public Assembly assembly { get; set; }

public List<OnlineMod> online { get; set; } = new List<OnlineMod>();
public OnlineMod online { get; set; } = new OnlineMod();

public List<SisiMod> sisi { get; set; } = new List<SisiMod>();

Expand Down

0 comments on commit 90ed054

Please sign in to comment.