X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fpages%2Fannounceidentitypage.cpp;h=83ce674673d05b17c8fcf6f0c8d404f2bd0d43f0;hb=b4f4686250878cdf4fcb2986a2ea6546cba867d1;hp=460302af9b08d9c88873b0214c2a3bef37a29120;hpb=f208e33c29132aacaec448e74341edea1b925a2a;p=fms.git diff --git a/src/http/pages/announceidentitypage.cpp b/src/http/pages/announceidentitypage.cpp index 460302a..83ce674 100644 --- a/src/http/pages/announceidentitypage.cpp +++ b/src/http/pages/announceidentitypage.cpp @@ -1,6 +1,7 @@ #include "../../../include/http/pages/announceidentitypage.h" #include "../../../include/stringfunctions.h" #include "../../../include/datetime.h" +#include "../../../include/global.h" #ifdef XMEM #include @@ -23,7 +24,7 @@ const std::string AnnounceIdentityPage::CreateLocalIdentityDropDown(const std::s st.ResultText(1,name); st.ResultText(2,pubkey); - rval+=""; + rval+=""; st.Step(); } rval+=""; @@ -40,6 +41,8 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, std::string lastid=""; std::string thisid=""; std::string day=""; + int requestindex=0; + bool willshow=false; if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="announce") { @@ -81,12 +84,13 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, content+="
Select Identity : "; content+=CreateLocalIdentityDropDown("localidentityid",""); content+=""; - content+="
Type the answers of a few puzzles"; + content+="
Type the answers of a few puzzles. The puzzles are case sensitive. Getting announced will take some time. DO NOT continuously solve captchas. Solve 30 at most, wait a day, and if your identity has not been announced, repeat until it is."; content+=""; + date.SetToGMTime(); date.Add(0,0,0,-1); - SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+date.Format("%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;"); + SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID,RequestIndex FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+date.Format("%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;"); st.Step(); if(st.RowReturned()==false) @@ -99,8 +103,25 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, st.ResultText(0,uuid); st.ResultText(1,day); st.ResultText(2,thisid); + st.ResultInt(3,requestindex); + + // if we are already inserting a solution for an identity - we shouldn't show any puzzles that are older than the one we are inserting + // get the last index # we are inserting this day from this identity + // if the index here is greater than the index in the st statement, we will skip this puzzle because we are already inserting a puzzle with a greater index + willshow=true; + SQLite3DB::Statement st2=m_db->Prepare("SELECT MAX(RequestIndex) FROM tblIdentityIntroductionInserts INNER JOIN tblIntroductionPuzzleRequests ON tblIdentityIntroductionInserts.UUID=tblIntroductionPuzzleRequests.UUID WHERE tblIdentityIntroductionInserts.Day=? AND tblIdentityIntroductionInserts.UUID IN (SELECT UUID FROM tblIntroductionPuzzleRequests WHERE IdentityID=? AND Day=?) GROUP BY tblIdentityIntroductionInserts.Day;"); + st2.Step(); + if(st2.RowReturned()==true) + { + int index=0; + st2.ResultInt(0,index); + if(index>=requestindex) + { + willshow=false; + } + } - if(thisid!=lastid) + if(willshow && thisid!=lastid) { StringFunctions::Convert(shown,countstr); if(shown>0 && shown%4==0) @@ -113,7 +134,7 @@ const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, content+=""; content+=""; content+="\r\n"; - thisid=lastid; + lastid=thisid; shown++; }