1 #include "otsdaq-core/WizardSupervisor/WizardSupervisor.h"
3 #include "otsdaq-core/GatewaySupervisor/GatewaySupervisor.h"
5 #include "otsdaq-core/Macros/CoutMacros.h"
6 #include "otsdaq-core/MessageFacility/MessageFacility.h"
8 #include <xdaq/NamespaceURI.h>
9 #include "otsdaq-core/CgiDataUtilities/CgiDataUtilities.h"
10 #include "otsdaq-core/SOAPUtilities/SOAPCommand.h"
11 #include "otsdaq-core/SOAPUtilities/SOAPUtilities.h"
12 #include "otsdaq-core/WebUsersUtilities/WebUsers.h"
13 #include "otsdaq-core/XmlUtilities/HttpXmlDocument.h"
25 #define SECURITY_FILE_NAME \
26 std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/security.dat"
27 #define SEQUENCE_FILE_NAME \
28 std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.dat"
29 #define SEQUENCE_OUT_FILE_NAME \
30 std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.out"
31 #define USER_DATA_PATH std::string(getenv("SERVICE_DATA_PATH")) + std::string("/")
34 #define XML_STATUS "editUserData_status"
36 #define XML_ADMIN_STATUS "logbook_admin_status"
37 #define XML_MOST_RECENT_DAY "most_recent_day"
38 #define XML_EXPERIMENTS_ROOT "experiments"
39 #define XML_EXPERIMENT "experiment"
40 #define XML_ACTIVE_EXPERIMENT "active_experiment"
41 #define XML_EXPERIMENT_CREATE "create_time"
42 #define XML_EXPERIMENT_CREATOR "creator"
44 #define XML_LOGBOOK_ENTRY "logbook_entry"
45 #define XML_LOGBOOK_ENTRY_SUBJECT "logbook_entry_subject"
46 #define XML_LOGBOOK_ENTRY_TEXT "logbook_entry_text"
47 #define XML_LOGBOOK_ENTRY_FILE "logbook_entry_file"
48 #define XML_LOGBOOK_ENTRY_TIME "logbook_entry_time"
49 #define XML_LOGBOOK_ENTRY_CREATOR "logbook_entry_creator"
50 #define XML_LOGBOOK_ENTRY_HIDDEN "logbook_entry_hidden"
51 #define XML_LOGBOOK_ENTRY_HIDER "logbook_entry_hider"
52 #define XML_LOGBOOK_ENTRY_HIDDEN_TIME "logbook_entry_hidden_time"
54 #define XML_PREVIEW_INDEX "preview_index"
55 #define LOGBOOK_PREVIEW_FILE "preview.xml"
60 #define __MF_SUBJECT__ "Wizard"
63 WizardSupervisor::WizardSupervisor(xdaq::ApplicationStub* s)
throw(
64 xdaq::exception::Exception)
65 : xdaq::Application(s)
67 , supervisorClass_(getApplicationDescriptor()->getClassName())
68 , supervisorClassNoNamespace_(supervisorClass_.substr(
69 supervisorClass_.find_last_of(
":") + 1,
70 supervisorClass_.length() - supervisorClass_.find_last_of(
":")))
72 __COUT__ <<
"Constructor started." << __E__;
74 INIT_MF(
"OtsConfigurationWizard");
77 mkdir((std::string(getenv(
"SERVICE_DATA_PATH"))).c_str(), 0755);
78 mkdir((std::string(getenv(
"SERVICE_DATA_PATH")) +
"/OtsWizardData").c_str(), 0755);
80 GatewaySupervisor::indicateOtsAlive();
83 xgi::bind(
this, &WizardSupervisor::Default,
"Default");
84 xgi::bind(
this, &WizardSupervisor::verification,
"Verify");
85 xgi::bind(
this, &WizardSupervisor::request,
"Request");
86 xgi::bind(
this, &WizardSupervisor::requestIcons,
"requestIcons");
87 xgi::bind(
this, &WizardSupervisor::editSecurity,
"editSecurity");
88 xgi::bind(
this, &WizardSupervisor::UserSettings,
"UserSettings");
89 xgi::bind(
this, &WizardSupervisor::tooltipRequest,
"TooltipRequest");
91 &WizardSupervisor::toggleSecurityCodeGeneration,
92 "ToggleSecurityCodeGeneration");
94 &WizardSupervisor::supervisorSequenceCheck,
95 "SupervisorSequenceCheck",
98 &WizardSupervisor::supervisorLastConfigGroupRequest,
99 "SupervisorLastConfigGroupRequest",
103 __COUT__ <<
"Constructor complete." << __E__;
107 WizardSupervisor::~WizardSupervisor(
void) { destroy(); }
110 void WizardSupervisor::init(
void)
115 allowedFileUploadTypes_.push_back(
"image/png");
116 matchingFileUploadTypes_.push_back(
"png");
117 allowedFileUploadTypes_.push_back(
"image/jpeg");
118 matchingFileUploadTypes_.push_back(
"jpeg");
119 allowedFileUploadTypes_.push_back(
"image/gif");
120 matchingFileUploadTypes_.push_back(
"gif");
121 allowedFileUploadTypes_.push_back(
"image/bmp");
122 matchingFileUploadTypes_.push_back(
"bmp");
123 allowedFileUploadTypes_.push_back(
"application/pdf");
124 matchingFileUploadTypes_.push_back(
"pdf");
125 allowedFileUploadTypes_.push_back(
"application/zip");
126 matchingFileUploadTypes_.push_back(
"zip");
127 allowedFileUploadTypes_.push_back(
"text/plain");
128 matchingFileUploadTypes_.push_back(
"txt");
132 void WizardSupervisor::requestIcons(xgi::Input* in,
133 xgi::Output* out)
throw(xgi::exception::Exception)
135 cgicc::Cgicc cgi(in);
137 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
140 if(securityCode_.compare(submittedSequence) != 0)
142 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
143 << time(0) << std::endl;
148 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
161 *out <<
"Configure,CFG,0,1,icon-Configure.png,/urn:xdaq-application:lid=280/,/"
163 "Editor,TBL,0,1,icon-IconEditor.png,/urn:xdaq-application:lid=280/"
164 "?configWindowName=tableEditor,/"
166 "Settings,SEC,1,1,icon-SecuritySettings.png,/WebPath/html/"
167 "SecuritySettings.html,/User Settings"
169 "Data,USER,1,1,icon-EditUserData.png,/WebPath/html/EditUserData.html,/User "
173 ",Console,C,1,1,icon-Console.png,/urn:xdaq-application:lid=260/,/" <<
184 "Wizard,CFG,0,1,icon-Configure.png,/WebPath/html/"
185 "RecordWiz_ConfigurationGUI.html?urn=280&recordAlias=Front%2Dend,Config Wizards"
187 "Wizard,CFG,0,1,icon-Configure.png,/WebPath/html/"
188 "RecordWiz_ConfigurationGUI.html?urn=280&recordAlias=Processor,Config Wizards"
190 "Diagram,CFG,0,1,icon-Configure.png,/WebPath/html/"
191 "ConfigurationSubsetBlockDiagram.html?urn=280,Config Wizards"
199 ",Code Editor,CODE,0,1,icon-CodeEditor.png,/urn:xdaq-application:lid=240/,/"
206 void WizardSupervisor::verification(xgi::Input* in,
207 xgi::Output* out)
throw(xgi::exception::Exception)
209 cgicc::Cgicc cgi(in);
210 std::string submittedSequence = CgiDataUtilities::getData(cgi,
"code");
211 __COUT__ <<
"submittedSequence=" << submittedSequence <<
" " << time(0) << std::endl;
213 std::string securityWarning =
"";
215 if(securityCode_.compare(submittedSequence) != 0)
217 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
219 *out <<
"Invalid code.";
225 __COUT__ <<
"*** Successfully authenticated security sequence "
226 <<
"@ " << time(0) << std::endl;
231 securityWarning =
"&secure=False";
235 *out <<
"<!DOCTYPE HTML><html lang='en'><head><title>ots wiz</title>" <<
238 "<link rel='apple-touch-icon' sizes='57x57' href='/WebPath/images/otsdaqIcons/apple-icon-57x57.png'>\
239 <link rel='apple-touch-icon' sizes='60x60' href='/WebPath/images/otsdaqIcons/apple-icon-60x60.png'>\
240 <link rel='apple-touch-icon' sizes='72x72' href='/WebPath/images/otsdaqIcons/apple-icon-72x72.png'>\
241 <link rel='apple-touch-icon' sizes='76x76' href='/WebPath/images/otsdaqIcons/apple-icon-76x76.png'>\
242 <link rel='apple-touch-icon' sizes='114x114' href='/WebPath/images/otsdaqIcons/apple-icon-114x114.png'>\
243 <link rel='apple-touch-icon' sizes='120x120' href='/WebPath/images/otsdaqIcons/apple-icon-120x120.png'>\
244 <link rel='apple-touch-icon' sizes='144x144' href='/WebPath/images/otsdaqIcons/apple-icon-144x144.png'>\
245 <link rel='apple-touch-icon' sizes='152x152' href='/WebPath/images/otsdaqIcons/apple-icon-152x152.png'>\
246 <link rel='apple-touch-icon' sizes='180x180' href='/WebPath/images/otsdaqIcons/apple-icon-180x180.png'>\
247 <link rel='icon' type='image/png' sizes='192x192' href='/WebPath/images/otsdaqIcons/android-icon-192x192.png'>\
248 <link rel='icon' type='image/png' sizes='32x32' href='/WebPath/images/otsdaqIcons/favicon-32x32.png'>\
249 <link rel='icon' type='image/png' sizes='96x96' href='/WebPath/images/otsdaqIcons/favicon-96x96.png'>\
250 <link rel='icon' type='image/png' sizes='16x16' href='/WebPath/images/otsdaqIcons/favicon-16x16.png'>\
251 <link rel='manifest' href='/WebPath/images/otsdaqIcons/manifest.json'>\
252 <meta name='msapplication-TileColor' content='#ffffff'>\
253 <meta name='msapplication-TileImage' content='/ms-icon-144x144.png'>\
254 <meta name='theme-color' content='#ffffff'>"
258 <<
"<frameset col='100%' row='100%'><frame src='/WebPath/html/Wizard.html?urn="
259 << this->getApplicationDescriptor()->getLocalId() << securityWarning
260 <<
"'></frameset></html>";
264 void WizardSupervisor::generateURL()
266 defaultSequence_ =
true;
269 FILE* fp = fopen((SEQUENCE_FILE_NAME).c_str(),
"r");
272 __COUT_INFO__ <<
"Sequence length file found: " << SEQUENCE_FILE_NAME
275 fgets(line, 100, fp);
276 sscanf(line,
"%d", &length);
281 defaultSequence_ =
false;
287 <<
"(Reverting to default wiz security) Sequence length file NOT found: "
288 << SEQUENCE_FILE_NAME << std::endl;
292 __COUT__ <<
"Sequence length = " << length << std::endl;
296 static const char alphanum[] =
298 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
299 "abcdefghijklmnopqrstuvwxyz";
301 for(
int i = 0; i < length; ++i)
303 securityCode_ += alphanum[rand() % (
sizeof(alphanum) - 1)];
306 __COUT__ << getenv(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
307 << getenv(
"PORT") <<
"/urn:xdaq-application:lid="
308 << this->getApplicationDescriptor()->getLocalId()
309 <<
"/Verify?code=" << securityCode_ << std::endl;
315 fp = fopen((SEQUENCE_OUT_FILE_NAME).c_str(),
"w");
318 fprintf(fp,
"%s", securityCode_.c_str());
322 __COUT_ERR__ <<
"Sequence output file NOT found: " << SEQUENCE_OUT_FILE_NAME
328 void WizardSupervisor::printURL(
WizardSupervisor* ptr, std::string securityCode)
330 INIT_MF(
"ConfigurationWizard");
335 std::this_thread::sleep_for(std::chrono::seconds(2));
336 __COUT__ << getenv(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
337 << getenv(
"PORT") <<
"/urn:xdaq-application:lid="
338 << ptr->getApplicationDescriptor()->getLocalId()
339 <<
"/Verify?code=" << securityCode << std::endl;
344 void WizardSupervisor::destroy(
void)
350 void WizardSupervisor::tooltipRequest(xgi::Input* in,
351 xgi::Output* out)
throw(xgi::exception::Exception)
353 cgicc::Cgicc cgi(in);
355 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
356 __COUT__ <<
"Command = " << Command << std::endl;
358 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
361 if(securityCode_.compare(submittedSequence) != 0)
363 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
369 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
375 if(Command ==
"check")
377 WebUsers::tooltipCheckForUsername(WebUsers::DEFAULT_ADMIN_USERNAME,
379 CgiDataUtilities::getData(cgi,
"srcFile"),
380 CgiDataUtilities::getData(cgi,
"srcFunc"),
381 CgiDataUtilities::getData(cgi,
"srcId"));
383 else if(Command ==
"setNeverShow")
385 WebUsers::tooltipSetNeverShowForUsername(
386 WebUsers::DEFAULT_ADMIN_USERNAME,
388 CgiDataUtilities::getData(cgi,
"srcFile"),
389 CgiDataUtilities::getData(cgi,
"srcFunc"),
390 CgiDataUtilities::getData(cgi,
"srcId"),
391 CgiDataUtilities::getData(cgi,
"doNeverShow") ==
"1" ?
true :
false,
392 CgiDataUtilities::getData(cgi,
"temporarySilence") ==
"1" ?
true :
false);
395 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
397 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
401 void WizardSupervisor::toggleSecurityCodeGeneration(
402 xgi::Input* in, xgi::Output* out)
throw(xgi::exception::Exception)
404 cgicc::Cgicc cgi(in);
406 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
407 __COUT__ <<
"Got to Command = " << Command << std::endl;
409 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
412 if(securityCode_.compare(submittedSequence) != 0)
414 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
420 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
426 if(Command ==
"TurnGenerationOn")
428 __COUT__ <<
"Turning automatic URL Generation on with a sequence depth of 16!"
430 std::ofstream outfile((SEQUENCE_FILE_NAME).c_str());
431 outfile <<
"16" << std::endl;
443 std::string securityCode) { printURL(ptr, securityCode); },
448 xmldoc.addTextElementToData(
"Status",
"Generation_Success");
451 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
453 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
459 xoap::MessageReference WizardSupervisor::supervisorSequenceCheck(
460 xoap::MessageReference message)
throw(xoap::exception::Exception)
464 parameters.addParameter(
"sequence");
465 SOAPUtilities::receive(message, parameters);
467 std::string submittedSequence = parameters.getValue(
"sequence");
471 std::map<std::string , WebUsers::permissionLevel_t> permissionMap;
473 if(securityCode_ == submittedSequence)
474 permissionMap.emplace(
475 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
476 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_ADMIN));
479 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
482 permissionMap.emplace(
483 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
484 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_INACTIVE));
489 retParameters.addParameter(
"Permissions", StringMacros::mapToString(permissionMap));
491 return SOAPUtilities::makeSOAPMessageReference(
"SequenceResponse", retParameters);
499 xoap::MessageReference WizardSupervisor::supervisorLastConfigGroupRequest(
500 xoap::MessageReference message)
throw(xoap::exception::Exception)
503 parameters.addParameter(
"ActionOfLastGroup");
504 SOAPUtilities::receive(message, parameters);
506 return GatewaySupervisor::lastConfigGroupRequestHandler(parameters);
510 void WizardSupervisor::Default(xgi::Input* in,
511 xgi::Output* out)
throw(xgi::exception::Exception)
513 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
515 *out <<
"Unauthorized Request.";
519 void WizardSupervisor::request(xgi::Input* in,
520 xgi::Output* out)
throw(xgi::exception::Exception)
522 cgicc::Cgicc cgiIn(in);
524 std::string submittedSequence = CgiDataUtilities::postData(cgiIn,
"sequence");
527 if(securityCode_.compare(submittedSequence) != 0)
529 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
530 << time(0) << std::endl;
535 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
540 std::string requestType = CgiDataUtilities::getData(cgiIn,
"RequestType");
541 __COUTV__(requestType);
547 if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz")
551 __COUT_WARN__ << requestType <<
" requestType received! " << __E__;
552 __MOUT_WARN__ << requestType <<
" requestType received! " << __E__;
556 if(requestType ==
"gatewayLaunchOTS")
557 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_OTS", &cfgMgr);
558 else if(requestType ==
"gatewayLaunchWiz")
559 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_WIZ", &cfgMgr);
563 __SS__ <<
"requestType Request, " << requestType <<
", not recognized."
568 catch(
const std::runtime_error& e)
570 __SS__ <<
"An error was encountered handling requestType '" << requestType
571 <<
"':" << e.what() << __E__;
572 __COUT__ <<
"\n" << ss.str();
573 xmlOut.addTextElementToData(
"Error", ss.str());
577 __SS__ <<
"An unknown error was encountered handling requestType '" << requestType
579 <<
"Please check the printouts to debug." << __E__;
580 __COUT__ <<
"\n" << ss.str();
581 xmlOut.addTextElementToData(
"Error", ss.str());
585 xmlOut.outputXmlDocument(
586 (std::ostringstream*)out,
593 void WizardSupervisor::editSecurity(xgi::Input* in,
594 xgi::Output* out)
throw(xgi::exception::Exception)
597 cgicc::Cgicc cgi(in);
598 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
599 std::string submittedSecurity = CgiDataUtilities::postData(cgi,
"selection");
600 std::string securityFileName = SECURITY_FILE_NAME;
603 if(securityCode_.compare(submittedSequence) != 0)
605 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
611 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
615 if(submittedSecurity !=
"")
617 __COUT__ <<
"Selection exists!" << std::endl;
618 __COUT__ << submittedSecurity << std::endl;
620 if(submittedSecurity ==
"ResetAllUserData")
622 WebUsers::deleteUserData();
623 __COUT__ <<
"Turning URL Generation back to default!" << std::endl;
626 std::ofstream newFile((SEQUENCE_FILE_NAME).c_str());
627 newFile <<
"4" << std::endl;
632 std::string securityCode) { printURL(ptr, securityCode); },
636 *out <<
"Default_URL_Generation";
638 else if(submittedSecurity ==
"ResetAllUserTooltips")
640 WebUsers::resetAllUserTooltips();
641 *out << submittedSecurity;
644 else if(submittedSecurity ==
"DigestAccessAuthentication" ||
645 submittedSecurity ==
"NoSecurity")
647 std::ofstream writeSecurityFile;
649 writeSecurityFile.open(securityFileName.c_str());
650 if(writeSecurityFile.is_open())
651 writeSecurityFile << submittedSecurity;
653 __COUT__ <<
"Error writing file!" << std::endl;
655 writeSecurityFile.close();
659 __COUT_ERR__ <<
"Invalid submittedSecurity string: " << submittedSecurity
667 std::ifstream securityFile;
669 std::string security =
"";
672 securityFile.open(securityFileName.c_str());
681 security =
"DigestAccessAuthentication";
683 if(securityFile.is_open())
686 while(std::getline(securityFile, line))
694 securityFile.close();
700 void WizardSupervisor::UserSettings(xgi::Input* in,
701 xgi::Output* out)
throw(xgi::exception::Exception)
704 cgicc::Cgicc cgi(in);
705 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
706 std::string securityFileName = SECURITY_FILE_NAME;
708 if((Command = CgiDataUtilities::postData(cgi,
"RequestType")) ==
"")
709 Command = cgi(
"RequestType");
711 __COUT__ << Command << std::endl;
712 __COUT__ <<
"We are vewing Users' Settings!" << std::endl;
715 if(securityCode_.compare(submittedSequence) != 0)
717 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
719 __COUT__ << submittedSequence << std::endl;
724 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
729 uint64_t activeSessionIndex;
731 uint8_t userPermissions;
735 __COUT__ <<
"Action exists!" << std::endl;
736 __COUT__ << Command << std::endl;
738 if(Command ==
"Import")
757 __COUT__ << cgi(
"Entry") << std::endl;
758 __COUT__ << cgi(
"Filename") << std::endl;
759 __COUT__ << cgi(
"Imported_File") << std::endl;
761 const std::vector<cgicc::FormFile> files = cgi.getFiles();
762 __COUT__ <<
"FormFiles: " <<
sizeof(files) << std::endl;
763 __COUT__ <<
"Number of files: " << files.size() << std::endl;
765 for(
unsigned int i = 0; i < files.size(); ++i)
767 std::string filename = USER_DATA_PATH + files[i].getFilename();
768 __COUT__ << filename << std::endl;
769 std::ofstream myFile;
770 myFile.open(filename.c_str());
771 files[0].writeToStream(myFile);
774 __COUT__ << files[0].getFilename() << std::endl;
775 __COUT__ <<
"********************Files Begin********************"
777 for(
unsigned int i = 0; i < files.size(); ++i)
779 __COUT__ << files[i].getDataType() << std::endl;
781 __COUT__ <<
"*********************Files End*********************"
788 else if(Command ==
"Export")
790 __SS__ <<
"This has been commented out due to problems compiling. Contact "
834 __COUT__ <<
"Command request not recognized: " << Command << std::endl;
846 std::string WizardSupervisor::validateUploadFileType(
const std::string fileType)
848 for(
unsigned int i = 0; i < allowedFileUploadTypes_.size(); ++i)
849 if(allowedFileUploadTypes_[i] == fileType)
850 return matchingFileUploadTypes_[i];
858 void WizardSupervisor::cleanUpPreviews()
860 std::string userData = (std::string)USER_DATA_PATH;
862 DIR* dir = opendir(userData.c_str());
865 __COUT__ <<
"Error - User Data directory missing: " << userData << std::endl;
869 struct dirent* entry;
870 time_t dirCreateTime;
877 if(strcmp(entry->d_name,
".") != 0 && strcmp(entry->d_name,
"..") != 0 &&
878 strcmp(entry->d_name,
".svn") != 0)
881 for(i = 0; i < strlen(entry->d_name); ++i)
882 if(entry->d_name[i] ==
'_')
884 entry->d_name[i] =
' ';
887 sscanf(entry->d_name,
"%li", &dirCreateTime);
889 if((time(0) - dirCreateTime) > USER_DATA_EXPIRATION_TIME)
891 __COUT__ <<
"Expired" << std::endl;
893 entry->d_name[i] =
'_';
895 __COUT__ <<
"rm -rf " << USER_DATA_PATH + (std::string)entry->d_name
898 system(((std::string)(
"rm -rf " + userData + (std::string)entry->d_name))
910 void WizardSupervisor::savePostPreview(std::string& subject,
912 const std::vector<cgicc::FormFile>& files,
927 std::string userDataPath = (std::string)USER_DATA_PATH + (std::string)fileIndex;
929 __COUT__ <<
"userDataPath " << userDataPath << std::endl;
930 if(-1 == mkdir(userDataPath.c_str(), 0755))
933 xmldoc->addTextElementToData(XML_STATUS,
934 "Failed - directory could not be generated.");