public static void PayVideos(string sID) { try { string sql = "select datediff(second,starttime, watching) span,size/422000 secs, datediff(second,starttime, watching)/((SIZE/422000)+.01) pct,* from tip where paid is null and userid is not null"; if (sID != "") { sql += " and userid='" + BMS.PurifySQL(sID, 100) + "'"; } DataTable dt1 = gData.GetDataTable2(sql); for (int i = 0; i < dt1.Rows.Count; i++) { double nPCT = GetDouble(dt1.Rows[i]["Pct"]); double nRew = GetDouble(dt1.Rows[i]["Amount"]); if (nPCT > 1) { nPCT = 1; } double nAmt = nRew * nPCT; string sCategory = dt1.Rows[i]["Category"].ToString(); string sUserID = dt1.Rows[i]["UserID"].ToString(); // Reward the user DataOps.AdjBalance(nAmt, sUserID, "Video Reward for " + Math.Round(nPCT * 100, 2).ToString() + "% for [" + sCategory + "]"); sql = "Update Tip set Paid = getdate() where id = '" + dt1.Rows[i]["id"].ToString() + "'"; gData.Exec(sql); } } catch (Exception ex) { Log("Unable to pay " + ex.Message); } }
public static string GetComments(string id, Page p) { // Shows the comments section for the object. Also shows the replies to the comments. string sql = "Select * from Comments Inner Join Users on Users.ID = Comments.UserID where comments.ParentID = @id order by comments.added"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@id", id); DataTable dt = gData.GetDataTable(command); string sHTML = "<div><h3>Comments:</h3><br>" + "<table style='padding:10px;' width=73%>" + "<tr><th width=14%>User<th width=10%>Added<th width=64%>Comment</tr>"; for (int i = 0; i < dt.Rows.Count; i++) { SavedObject s = RowToObject(dt.Rows[i]); string sUserPic = DataOps.GetAvatar(s.Props.Picture); string sUserName = NotNull(s.Props.UserName); if (sUserName == "") { sUserName = "******"; } string sBody = ReplaceURLs(s.Props.Body); string div = "<tr><td>" + sUserPic + "<br>" + sUserName + "</br></td><td>" + s.Props.Added.ToString() + "</td><td style='border:1px solid lightgrey'><br>" + sBody + "</td></tr>"; sHTML += div; } sHTML += "</table><table width=100%><tr><th colspan=2><h2>Add a Comment:</h2></tr>"; if (!gUser(p).LoggedIn) { sHTML += "<tr><td><font color=red>Sorry, you must be logged in to add a comment.</td></tr></table></div>"; return(sHTML); } string sButtons = "<tr><td>Comment:</td><td><textarea id='txtComment' name='txtComment' rows=10 style='width: 70%;' cols=70></textarea><br><br><button id='btnSaveComment' name='btnSaveComment' value='Save'>Save Comment</button></tr>"; sButtons += "</table></div>"; sHTML += sButtons; return(sHTML); }
public static string GetTweetList(string sUserId, int days, bool fExcludeUser = false) { if (sUserId == "" || sUserId == null) { sUserId = "BAF8C6FE-E1B2-42FB-0000-4A8289A90CA2"; // system user } string sql = "Select * from Tweet left Join Users on Users.ID = Tweet.UserID left join TweetRead on TweetRead.ParentID=Tweet.ID and TweetRead.UserID = '" + sUserId + "' where tweet.added > getdate()-" + days.ToString() + " order by Tweet.Added desc"; DataTable dt = gData.GetDataTable2(sql); string html = "<table class=saved><tr><th>Read?<th width=20%>User</th><th width=20%>Added<th width=50%>Subject"; if (fExcludeUser) { html = "<table class=saved><tr><th width=20%>User<th width=20%>Added<th width=50%>Subject"; } for (int y = 0; y < dt.Rows.Count; y++) { SavedObject s = RowToObject(dt.Rows[y]); string sUserName = NotNull(s.Props.UserName); if (sUserName == "") { sUserName = "******"; } string sAnchor = "<a href='https://foundation.biblepay.org/TweetView.aspx?id=" + s.Props.id.ToString() + "'>"; string sReadTime = dt.Rows[y]["ReadTime"].ToNonNullString(); bool fBold = sReadTime == "" ? false : true; string sCheckmark = sReadTime != "" ? "<i class='fa fa-check'></i> " : "<i class='fa fa-envelope'></i> "; string div = "<tr>"; if (!fExcludeUser) { div += GetTd2(dt.Rows[y], "ReadTime", sAnchor, sCheckmark, fBold); } div += "<td>" + DataOps.GetAvatar(s.Props.Picture) + " " + sUserName + "</td>"; div += UICommon.GetTd2(dt.Rows[y], "Added", sAnchor, sCheckmark, fBold) + UICommon.GetTd2(dt.Rows[y], "subject", sAnchor, sCheckmark, fBold) + "</tr>"; html += div + "\r\n"; } html += "</table>"; return(html); }
public static DACResult Zinc_QueryOrderStatus(string sZincID) { DACResult r = new DACResult(); r.sError = ""; try { Chilkat.Rest rest = ConnectToZinc(); string jsonOrder = ""; string sResponse = rest.FullRequestString("GET", "/v1/orders/" + sZincID, jsonOrder); if (rest.LastMethodSuccess != true) { Log(rest.LastErrorText); r.sError = "Unable to interface with AMAZON."; return(r); } dynamic oJson = JsonConvert.DeserializeObject <dynamic>(sResponse); // Tracking string sDeliveryDate = GetJsonValue(oJson, "delivery_dates", "date"); string sTrackingURL = GetJsonValue(oJson, "merchant_order_ids", "tracking_url"); if (sTrackingURL != "") { sTrackingURL = sZincID; } string sCode = GetJsonValue(oJson, "code", ""); string msg = GetJsonValue(oJson, "message", ""); msg = msg.Replace("'", ""); string sStatus = ""; if (sCode == "aborted_request") { sStatus = "COMPLETED"; sTrackingURL = sCode; } else if (msg == "One of the products you selected is unavailable.") { sStatus = "COMPLETED"; sTrackingURL = "CUSTOMER REFUNDED"; // Credit the user the amount string sMySql = "Select * from Orders where ZincID = '" + BMS.PurifySQL(sZincID, 40) + "'"; DataTable dtRefunded = gData.GetDataTable2(sMySql); if (dtRefunded.Rows.Count > 0) { double nPriceBBP = GetDouble(dtRefunded.Rows[0]["bbpprice"]); string sSql2 = "Select product_id from products where id='" + dtRefunded.Rows[0]["productid"].ToString() + "'"; string sProdID = gData.GetScalarString2(sSql2, "product_id"); string sNotes = "Full refund for unavailable product for product id " + sProdID; DataOps.AdjBalance(1 * nPriceBBP, DataOps.GetUserRecord(dtRefunded.Rows[0]["UserId"].ToString()).UserId.ToString(), sNotes); NotifyOfMissingProduct(DataOps.GetUserRecord(dtRefunded.Rows[0]["UserId"].ToString()).EmailAddress, sProdID); } } else if (sTrackingURL != "") { sStatus = "OUT_FOR_DELIVERY"; if (sDeliveryDate != "") { System.TimeSpan diffResult = System.DateTime.Now - Convert.ToDateTime(sDeliveryDate); if (diffResult.TotalHours > 1) { sStatus = "COMPLETED"; } } } if (r.sResult != "" || true) { string sql = "Update Orders Set Updated=getdate(),DeliveryDate='" + sDeliveryDate + "', TrackingNumber='" + sTrackingURL + "',Message='" + msg + "',Status = '" + sStatus + "' where ZincID = '" + sZincID + "' and status <> 'COMPLETED'"; gData.Exec(sql); } return(r); } catch (Exception ex) { r.sError = "Unable to find product."; return(r); } }
public static string GetSideBar(Page p) { item = 0; string sKeys = gUser(p).TwoFactorAuthorized ? "<li><a href='AccountEdit.aspx'><i class='fa fa-key'></i></a></li>" : ""; string sMyBalance = ""; try { if (gUser(p).LoggedIn) { double nTotalBalance = DataOps.GetTotalFrom(gUser(p).UserId.ToString(), "Deposit"); sMyBalance = "$ " + ConvertBBPToUSDString(nTotalBalance); } }catch (Exception ex) { Log("Error " + ex.Message); } string html = "<aside class='main-sidebar' id='mySidenav'>"; html += "<section class='sidebar'><div class='user-panel' style='z-index: 9000;'>" + "<a onclick='closeNav();' href = '#' class='sidebar-toggle' data-toggle='offcanvas' role='button'>" + " <i class='fa fa-close'></i></a>" + " <div class='pull-left myavatar'> " + " " + gUser(p).AvatarURL + "" + " </div>" + " <div class='pull-left info'>" + " <p>"+ gUser(p).UserName + "</p>" + " </div>" + " <div class='myicons'><ul>" + sKeys + "</ul>" + sMyBalance + "</div>" + " <!--<div class='myicons'>" + " <ul><li><a href ='showposts' ><i class='fa fa-comments'></i></a></li>" + " <li><a href = 'https://forum.biblepay.org/index.php?action=pm' ><i class='fa fa-envelope'></i></a></li>" + " </ul></div>-->" + " </div>" + " <ul class='sidebar-menu'>"; html += AddMenuOption("Account", "https://forum.biblepay.org/sso.php?source=https://foundation.biblepay.org/Default.aspx;Login.aspx?opt=logout;AccountEdit.aspx;Deposit.aspx;FractionalSanctuaries.aspx", "Log In;Log Out;Account;Deposit/Withdrawal;Fractional Sanctuaries", "fa-unlock-alt"); html += AddMenuOption("Community", "Default.aspx;https://social.biblepay.org/prayer;Dashboard.aspx;ProposalAdd;ProposalsList", "Home;Prayer Requests;Salvation Dashboard;Add Proposal;Proposals List", "fa-ambulance"); html += AddMenuOption("Doctrine", "https://unchained.biblepay.org/Study;https://social.biblepay.org/movies/", "Theological Studies;Christian Videos", "fa-life-ring"); // sPaths = "NFTBrowse?type=christian;NFTBrowse?type=orphan;NFTBrowse?type=general;NFTAdd;NFTList"; //Opensea Version::html += AddMenuOption("NFTs", "https://opensea.io/collection/biblepay?search[sortAscending]=true&search[sortBy]=PRICE&search[toggles][0]=BUY_NOW;https://opensea.io/collection/biblepay-christian?search[sortAscending]=true&search[sortBy]=PRICE&search[toggles][0]=BUY_NOW", "General NFTs;Christian NFTs", "fa-database"); html += AddMenuOption("NFTs", "https://unchained.biblepay.org/NFTBrowse?type=general;https://unchained.biblepay.org/NFTBrowse?type=christian" , "General NFTs;Christian NFTs", "fa-database"); html += AddMenuOption("Orphans", "https://unchained.biblepay.org/NFTBrowse?type=orphan", "NFT Orphans", "fa-child"); html += AddMenuOption("Pool", "Leaderboard.aspx;GettingStarted.aspx;PoolAbout.aspx;BlockHistory.aspx;Viewer.aspx?target=" + System.Web.HttpUtility.UrlEncode("https://minexmr.com/dashboard") + ";MiningCalculator.aspx", "Leaderboard;Getting Started;About;Block History;XMR Inquiry;Mining Calculator", "fa-sitemap"); html += AddMenuOption("Tweets", "TweetList;TweetAdd", "Tweet List;Advertise a Tweet", "fa-line-chart"); // html += AddMenuOption("Admin", "Markup.aspx", "Markup Edit", "fa-wrench"); html += "</section></aside>"; return(html); }
public static bool SendMassDailyTweetReport() { try { System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("1", "2"); // Do not change these values, change the config values. client.Port = 587; client.EnableSsl = true; client.Host = GetBMSConfigurationKeyValue("smtphost"); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(GetBMSConfigurationKeyValue("smtpuser"), GetBMSConfigurationKeyValue("smtppassword")); // First we check to see if we have any tweets that have not been mass notified in 24 hours string sql = "Select count(*) ct from Tweet where added > getdate()-1"; // if none we bail double dLast24 = gData.GetScalarDouble(sql, "ct"); if (dLast24 < 1) { return(true); } // Now we need a manifest of tweets that have gone out in the last 30 days sql = "Select id from tweet where added > getdate()-2 order by added desc"; string TweetID = gData.GetScalarString2(sql, "id"); sql = "Select top 500 * from Users where isnull(emailaddress,'') != '' and Unsubscribe is null and isnull(LastEmail,'1-1-1970') < getdate()-2 and Users.ID not in (Select userid from tweetread where parentid='" + TweetID + "')"; DataTable dt1 = gData.GetDataTable2(sql); MailAddress rTo = new MailAddress("*****@*****.**", "BiblePay Team"); MailAddress r = new MailAddress("*****@*****.**", "BiblePay Team"); MailMessage m = new MailMessage(r, rTo); m.Subject = "My Tweet Report"; m.IsBodyHtml = true; string sData = GetTweetList("", 14, true); string sBody = "<html><br>Dear BiblePay Foundation User, <br><br>You have unread tweets that have been added in the last 14 days. <br><br>This report will show you tweets that our users have paid for that they believe are extremely valuable. <br><br>We will only send this report once per new tweet and only if you have not read the most recent tweet in 24 hours.<br><br>"; sBody += sData; // Append the single tweet string sTweet = DataOps.GetSingleTweet(TweetID); sBody += "<br><br><h3>Our Last Tweet</h3><br><br>" + sTweet; sBody += "<br><br>To unsubscribe from this transactional e-mail, please edit your account settings <a href=https://foundation.biblepay.org/AccountEdit>here</a> and click unsubscribe.<br><br>The BiblePay Tweet Team"; m.Body = sBody; for (int i = 0; i < dt1.Rows.Count; i++) { MailAddress t = new MailAddress(dt1.Rows[i]["EmailAddress"].ToString(), dt1.Rows[i]["UserName"].ToString()); m.Bcc.Add(t); sql = "Update Users set LastEmail=getdate() where id = '" + dt1.Rows[i]["id"].ToString() + "'"; gData.Exec(sql); } try { client.Send(m); return(true); } catch (Exception e) { Console.WriteLine("Error in Send email: {0}", e.Message); return(false); } } catch (Exception ex2) { Log("Cannot send Mass Mail: " + ex2.Message); } return(false); }
/* * public static void AddThumbnails() * { * string sql = "Select * from Rapture where thumbnail is null and url like '%mp4%'"; * DataTable dt = gData.GetDataTable2(sql); * for (int i = 0; i < dt.Rows.Count; i++) * { * string url = dt.Rows[i]["url"].ToString(); * string sID = dt.Rows[i]["id"].ToString(); * string sUserID = dt.Rows[i]["userid"].ToString(); * string sOutFile = "c:\\inetpub\\wwwroot\\Saved\\Uploads\\Thumbnails\\" + sID + ".jpg"; * ConvertMp4ToJpg(url, sOutFile); * FileInfo fi = new FileInfo(sOutFile); * if (fi.Exists) * { * string sSpendAddress = GetBMSConfigurationKeyValue("fundingaddress_mainnet"); * string sSpendPrivKey = GetBMSConfigurationKeyValue("fundingkey_mainnet"); * BiblePayCommon.Common.User u = new BiblePayCommon.Common.User(); * BiblePayCommon.Common.DACResult r1 = BiblePayDLL.Sidechain.UploadFileTypeBlob(false, sOutFile, u); * string sOutURL = r1.Result; * sql = "Update Rapture set Thumbnail='" + sOutURL + "' where id = '" + sID + "'"; * gData.Exec(sql); * } * } * } */ public static void ConvertVideos() { string sVideoPath = GetBMSConfigurationKeyValue("convertvideospath"); if (sVideoPath == "") { return; } // Convert unconverted RequestVideo to Resilient format string sql = "Select * from RequestVideo where status is null"; DataTable dt = gData.GetDataTable2(sql); for (int i = 0; i < dt.Rows.Count; i++) { string url = dt.Rows[i]["url"].ToString(); string sID = dt.Rows[i]["id"].ToString(); string sUserID = dt.Rows[i]["userid"].ToString(); // Convert this particular youtube URL into a rapture video // Then store in the rapture table with an uncategorized category GetVideo(url); string sPath = GetPathFromTube(url); // Convert the path to hash string sNewFileName = "700" + sPath.GetHashCode().ToString() + ".mp4"; if (System.IO.File.Exists(sPath)) { System.IO.FileInfo fi = new FileInfo(sPath); string sHeading = Left(fi.Name, 100); string sNotes = Utils.CleanseHeading(sHeading) + "\r\n\r\n" + Left(DataOps.GetNotes(sPath), 4000); string sSpendAddress = GetBMSConfigurationKeyValue("fundingaddress_mainnet"); string sSpendPrivKey = GetBMSConfigurationKeyValue("fundingkey_mainnet"); BiblePayCommon.Common.User u = new BiblePayCommon.Common.User(); BiblePayCommon.Common.DACResult r1 = BiblePayDLL.Sidechain.UploadFileTypeBlob(false, sPath, u); string sURL = r1.Result; if (sURL != "") { sql = "Insert into Rapture (id,added,Notes,URL,FileName,Category,UserID) values (newid(), getdate(), @notes, @url, @filename, @category, @userid)"; SqlCommand command = new SqlCommand(sql); command.Parameters.AddWithValue("@notes", sNotes); command.Parameters.AddWithValue("@url", sURL); command.Parameters.AddWithValue("@filename", sNewFileName); command.Parameters.AddWithValue("@category", "Miscellaneous"); command.Parameters.AddWithValue("@userid", sUserID); gData.ExecCmd(command); sql = "Update RequestVideo set Status='FILLED' where id = '" + sID + "'"; gData.Exec(sql); // Delete the temporary file System.IO.File.Delete(sPath); } else { sql = "Update RequestVideo set Status='FAILURE' where id = '" + sID + "'"; gData.Exec(sql); } } else { sql = "Update RequestVideo set Status='FILE DOES NOT EXIST' where id = '" + sID + "'"; gData.Exec(sql); } } }