version 0.0.1
[fms.git] / src / freenet / introductionpuzzleremover.cpp
1 #include "../../include/freenet/introductionpuzzleremover.h"\r
2 \r
3 #ifdef XMEM\r
4         #include <xmem.h>\r
5 #endif\r
6 \r
7 IntroductionPuzzleRemover::IntroductionPuzzleRemover()\r
8 {\r
9         m_lastchecked.SetToGMTime();\r
10 }\r
11 \r
12 void IntroductionPuzzleRemover::Process()\r
13 {\r
14         DateTime now;\r
15         DateTime date;\r
16         now.SetToGMTime();\r
17         date.SetToGMTime();\r
18 \r
19         // check once a day\r
20         if(m_lastchecked<(now-1.0))\r
21         {\r
22 \r
23                 date.Add(0,0,0,-2);\r
24 \r
25                 // delete all puzzles 2 or more days old\r
26                 m_db->Execute("DELETE FROM tblIntroductionPuzzleInserts WHERE Day<='"+date.Format("%Y-%m-%d")+"';");\r
27                 m_db->Execute("DELETE FROM tblIntroductionPuzzleRequests WHERE Day<='"+date.Format("%Y-%m-%d")+"';");\r
28 \r
29                 m_lastchecked=now;\r
30         }\r
31 }\r
32 \r
33 void IntroductionPuzzleRemover::RegisterWithThread(FreenetMasterThread *thread)\r
34 {\r
35         thread->RegisterPeriodicProcessor(this);\r
36 }\r