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(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/security.dat"
27 #define SEQUENCE_FILE_NAME \
28 std::string(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.dat"
29 #define SEQUENCE_OUT_FILE_NAME \
30 std::string(__ENV__("SERVICE_DATA_PATH")) + "/OtsWizardData/sequence.out"
31 #define USER_DATA_PATH std::string(__ENV__("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)
64 : xdaq::Application(s)
66 , supervisorClass_(getApplicationDescriptor()->getClassName())
67 , supervisorClassNoNamespace_(supervisorClass_.substr(
68 supervisorClass_.find_last_of(
":") + 1,
69 supervisorClass_.length() - supervisorClass_.find_last_of(
":")))
71 __COUT__ <<
"Constructor started." << __E__;
73 INIT_MF(
"OtsConfigurationWizard");
76 mkdir((std::string(__ENV__(
"SERVICE_DATA_PATH"))).c_str(), 0755);
77 mkdir((std::string(__ENV__(
"SERVICE_DATA_PATH")) +
"/OtsWizardData").c_str(), 0755);
79 GatewaySupervisor::indicateOtsAlive();
82 xgi::bind(
this, &WizardSupervisor::Default,
"Default");
83 xgi::bind(
this, &WizardSupervisor::verification,
"Verify");
84 xgi::bind(
this, &WizardSupervisor::request,
"Request");
85 xgi::bind(
this, &WizardSupervisor::requestIcons,
"requestIcons");
86 xgi::bind(
this, &WizardSupervisor::editSecurity,
"editSecurity");
87 xgi::bind(
this, &WizardSupervisor::UserSettings,
"UserSettings");
88 xgi::bind(
this, &WizardSupervisor::tooltipRequest,
"TooltipRequest");
90 &WizardSupervisor::toggleSecurityCodeGeneration,
91 "ToggleSecurityCodeGeneration");
93 &WizardSupervisor::supervisorSequenceCheck,
94 "SupervisorSequenceCheck",
97 &WizardSupervisor::supervisorLastConfigGroupRequest,
98 "SupervisorLastConfigGroupRequest",
102 __COUT__ <<
"Constructor complete." << __E__;
106 WizardSupervisor::~WizardSupervisor(
void) { destroy(); }
109 void WizardSupervisor::init(
void)
114 allowedFileUploadTypes_.push_back(
"image/png");
115 matchingFileUploadTypes_.push_back(
"png");
116 allowedFileUploadTypes_.push_back(
"image/jpeg");
117 matchingFileUploadTypes_.push_back(
"jpeg");
118 allowedFileUploadTypes_.push_back(
"image/gif");
119 matchingFileUploadTypes_.push_back(
"gif");
120 allowedFileUploadTypes_.push_back(
"image/bmp");
121 matchingFileUploadTypes_.push_back(
"bmp");
122 allowedFileUploadTypes_.push_back(
"application/pdf");
123 matchingFileUploadTypes_.push_back(
"pdf");
124 allowedFileUploadTypes_.push_back(
"application/zip");
125 matchingFileUploadTypes_.push_back(
"zip");
126 allowedFileUploadTypes_.push_back(
"text/plain");
127 matchingFileUploadTypes_.push_back(
"txt");
131 void WizardSupervisor::requestIcons(xgi::Input* in, xgi::Output* out)
133 cgicc::Cgicc cgi(in);
135 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
138 if(securityCode_.compare(submittedSequence) != 0)
140 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
141 << time(0) << std::endl;
146 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
160 *out <<
"Configure,CFG,0,1,icon-Configure.png,/urn:xdaq-application:lid=280/,/"
162 <<
",Table Editor,TBL,0,1,icon-ControlsDashboard.png,"
163 "/urn:xdaq-application:lid=280/?configWindowName=tableEditor,/"
165 <<
",Icon Editor,ICON,0,1,icon-IconEditor.png,"
166 "/WebPath/html/ConfigurationGUI_subset.html?urn=280&subsetBasePath=DesktopIconTable&"
167 "recordAlias=Icons&groupingFieldList=Status%2CForceOnlyOneInstance%2CRequiredPermissionLevel,/"
169 <<
",Security Settings,SEC,1,1,icon-SecuritySettings.png,"
170 "/WebPath/html/SecuritySettings.html,/User Settings"
172 <<
",Edit User Data,USER,1,1,icon-EditUserData.png,/WebPath/html/EditUserData.html,/User Settings"
174 <<
",Console,C,1,1,icon-Console.png,/urn:xdaq-application:lid=260/,/"
177 <<
",Front-end Wizard,CFG,0,1,icon-Configure.png,"
178 "/WebPath/html/RecordWiz_ConfigurationGUI.html?urn=280&recordAlias=Front%2Dend,Config Wizards"
180 <<
",Processor Wizard,CFG,0,1,icon-Configure.png,"
181 "/WebPath/html/RecordWiz_ConfigurationGUI.html?urn=280&recordAlias=Processor,Config Wizards"
183 <<
",Block Diagram,CFG,0,1,icon-Configure.png,"
184 "/WebPath/html/ConfigurationSubsetBlockDiagram.html?urn=280,Config Wizards"
187 <<
",Code Editor,CODE,0,1,icon-CodeEditor.png,/urn:xdaq-application:lid=240/,/"
190 <<
",State Machine Screenshot,FSM-SS,1,1,icon-StateMachine.png,"
191 "/WebPath/images/windowContentImages/state_machine_screenshot.png,/Documentation"
217 void WizardSupervisor::verification(xgi::Input* in, xgi::Output* out)
219 cgicc::Cgicc cgi(in);
220 std::string submittedSequence = CgiDataUtilities::getData(cgi,
"code");
221 __COUT__ <<
"submittedSequence=" << submittedSequence <<
" " << time(0) << std::endl;
223 std::string securityWarning =
"";
225 if(securityCode_.compare(submittedSequence) != 0)
227 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
229 *out <<
"Invalid code.";
235 __COUT__ <<
"*** Successfully authenticated security sequence "
236 <<
"@ " << time(0) << std::endl;
241 securityWarning =
"&secure=False";
245 *out <<
"<!DOCTYPE HTML><html lang='en'><head><title>ots wiz</title>" <<
248 "<link rel='apple-touch-icon' sizes='57x57' href='/WebPath/images/otsdaqIcons/apple-icon-57x57.png'>\
249 <link rel='apple-touch-icon' sizes='60x60' href='/WebPath/images/otsdaqIcons/apple-icon-60x60.png'>\
250 <link rel='apple-touch-icon' sizes='72x72' href='/WebPath/images/otsdaqIcons/apple-icon-72x72.png'>\
251 <link rel='apple-touch-icon' sizes='76x76' href='/WebPath/images/otsdaqIcons/apple-icon-76x76.png'>\
252 <link rel='apple-touch-icon' sizes='114x114' href='/WebPath/images/otsdaqIcons/apple-icon-114x114.png'>\
253 <link rel='apple-touch-icon' sizes='120x120' href='/WebPath/images/otsdaqIcons/apple-icon-120x120.png'>\
254 <link rel='apple-touch-icon' sizes='144x144' href='/WebPath/images/otsdaqIcons/apple-icon-144x144.png'>\
255 <link rel='apple-touch-icon' sizes='152x152' href='/WebPath/images/otsdaqIcons/apple-icon-152x152.png'>\
256 <link rel='apple-touch-icon' sizes='180x180' href='/WebPath/images/otsdaqIcons/apple-icon-180x180.png'>\
257 <link rel='icon' type='image/png' sizes='192x192' href='/WebPath/images/otsdaqIcons/android-icon-192x192.png'>\
258 <link rel='icon' type='image/png' sizes='32x32' href='/WebPath/images/otsdaqIcons/favicon-32x32.png'>\
259 <link rel='icon' type='image/png' sizes='96x96' href='/WebPath/images/otsdaqIcons/favicon-96x96.png'>\
260 <link rel='icon' type='image/png' sizes='16x16' href='/WebPath/images/otsdaqIcons/favicon-16x16.png'>\
261 <link rel='manifest' href='/WebPath/images/otsdaqIcons/manifest.json'>\
262 <meta name='msapplication-TileColor' content='#ffffff'>\
263 <meta name='msapplication-TileImage' content='/ms-icon-144x144.png'>\
264 <meta name='theme-color' content='#ffffff'>"
268 <<
"<frameset col='100%' row='100%'><frame src='/WebPath/html/Wizard.html?urn="
269 << this->getApplicationDescriptor()->getLocalId() << securityWarning
270 <<
"'></frameset></html>";
274 void WizardSupervisor::generateURL()
276 defaultSequence_ =
true;
279 FILE* fp = fopen((SEQUENCE_FILE_NAME).c_str(),
"r");
282 __COUT_INFO__ <<
"Sequence length file found: " << SEQUENCE_FILE_NAME
285 fgets(line, 100, fp);
286 sscanf(line,
"%d", &length);
291 defaultSequence_ =
false;
297 <<
"(Reverting to default wiz security) Sequence length file NOT found: "
298 << SEQUENCE_FILE_NAME << std::endl;
302 __COUT__ <<
"Sequence length = " << length << std::endl;
306 const char alphanum[] =
308 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
309 "abcdefghijklmnopqrstuvwxyz";
311 for(
int i = 0; i < length; ++i)
313 securityCode_ += alphanum[rand() % (
sizeof(alphanum) - 1)];
316 __COUT__ << __ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
317 << __ENV__(
"PORT") <<
"/urn:xdaq-application:lid="
318 << this->getApplicationDescriptor()->getLocalId()
319 <<
"/Verify?code=" << securityCode_ << std::endl;
325 fp = fopen((SEQUENCE_OUT_FILE_NAME).c_str(),
"w");
328 fprintf(fp,
"%s", securityCode_.c_str());
332 __COUT_ERR__ <<
"Sequence output file NOT found: " << SEQUENCE_OUT_FILE_NAME
338 void WizardSupervisor::printURL(
WizardSupervisor* ptr, std::string securityCode)
340 INIT_MF(
"ConfigurationWizard");
345 std::this_thread::sleep_for(std::chrono::seconds(2));
346 __COUT__ << __ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
347 << __ENV__(
"PORT") <<
"/urn:xdaq-application:lid="
348 << ptr->getApplicationDescriptor()->getLocalId()
349 <<
"/Verify?code=" << securityCode << std::endl;
354 void WizardSupervisor::destroy(
void)
360 void WizardSupervisor::tooltipRequest(xgi::Input* in, xgi::Output* out)
362 cgicc::Cgicc cgi(in);
364 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
367 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
370 if(securityCode_.compare(submittedSequence) != 0)
372 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
384 if(Command ==
"check")
386 WebUsers::tooltipCheckForUsername(WebUsers::DEFAULT_ADMIN_USERNAME,
388 CgiDataUtilities::getData(cgi,
"srcFile"),
389 CgiDataUtilities::getData(cgi,
"srcFunc"),
390 CgiDataUtilities::getData(cgi,
"srcId"));
392 else if(Command ==
"setNeverShow")
394 WebUsers::tooltipSetNeverShowForUsername(
395 WebUsers::DEFAULT_ADMIN_USERNAME,
397 CgiDataUtilities::getData(cgi,
"srcFile"),
398 CgiDataUtilities::getData(cgi,
"srcFunc"),
399 CgiDataUtilities::getData(cgi,
"srcId"),
400 CgiDataUtilities::getData(cgi,
"doNeverShow") ==
"1" ?
true :
false,
401 CgiDataUtilities::getData(cgi,
"temporarySilence") ==
"1" ?
true :
false);
404 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
406 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
410 void WizardSupervisor::toggleSecurityCodeGeneration(xgi::Input* in, xgi::Output* out)
412 cgicc::Cgicc cgi(in);
414 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
415 __COUT__ <<
"Got to Command = " << Command << std::endl;
417 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
420 if(securityCode_.compare(submittedSequence) != 0)
422 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
428 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
434 if(Command ==
"TurnGenerationOn")
436 __COUT__ <<
"Turning automatic URL Generation on with a sequence depth of 16!"
438 std::ofstream outfile((SEQUENCE_FILE_NAME).c_str());
439 outfile <<
"16" << std::endl;
451 std::string securityCode) { printURL(ptr, securityCode); },
456 xmldoc.addTextElementToData(
"Status",
"Generation_Success");
459 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
461 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
467 xoap::MessageReference WizardSupervisor::supervisorSequenceCheck(
468 xoap::MessageReference message)
472 parameters.addParameter(
"sequence");
473 SOAPUtilities::receive(message, parameters);
475 std::string submittedSequence = parameters.getValue(
"sequence");
479 std::map<std::string , WebUsers::permissionLevel_t> permissionMap;
481 if(securityCode_ == submittedSequence)
482 permissionMap.emplace(
483 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
484 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_ADMIN));
487 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
490 permissionMap.emplace(
491 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
492 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_INACTIVE));
497 retParameters.addParameter(
"Permissions", StringMacros::mapToString(permissionMap));
499 return SOAPUtilities::makeSOAPMessageReference(
"SequenceResponse", retParameters);
507 xoap::MessageReference WizardSupervisor::supervisorLastConfigGroupRequest(
508 xoap::MessageReference message)
511 parameters.addParameter(
"ActionOfLastGroup");
512 SOAPUtilities::receive(message, parameters);
514 return GatewaySupervisor::lastConfigGroupRequestHandler(parameters);
518 void WizardSupervisor::Default(xgi::Input* in, xgi::Output* out)
520 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
522 *out <<
"Unauthorized Request.";
526 void WizardSupervisor::request(xgi::Input* in, xgi::Output* out)
528 cgicc::Cgicc cgiIn(in);
530 std::string submittedSequence = CgiDataUtilities::postData(cgiIn,
"sequence");
533 if(securityCode_.compare(submittedSequence) != 0)
535 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
536 << time(0) << std::endl;
541 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
546 std::string requestType = CgiDataUtilities::getData(cgiIn,
"RequestType");
547 __COUTV__(requestType);
553 if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz")
557 __COUT_WARN__ << requestType <<
" requestType received! " << __E__;
558 __MOUT_WARN__ << requestType <<
" requestType received! " << __E__;
562 if(requestType ==
"gatewayLaunchOTS")
563 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_OTS", &cfgMgr);
564 else if(requestType ==
"gatewayLaunchWiz")
565 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_WIZ", &cfgMgr);
569 __SS__ <<
"requestType Request, " << requestType <<
", not recognized."
574 catch(
const std::runtime_error& e)
576 __SS__ <<
"An error was encountered handling requestType '" << requestType
577 <<
"':" << e.what() << __E__;
578 __COUT__ <<
"\n" << ss.str();
579 xmlOut.addTextElementToData(
"Error", ss.str());
583 __SS__ <<
"An unknown error was encountered handling requestType '" << requestType
585 <<
"Please check the printouts to debug." << __E__;
586 __COUT__ <<
"\n" << ss.str();
587 xmlOut.addTextElementToData(
"Error", ss.str());
591 xmlOut.outputXmlDocument(
592 (std::ostringstream*)out,
599 void WizardSupervisor::editSecurity(xgi::Input* in, xgi::Output* out)
602 cgicc::Cgicc cgi(in);
603 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
604 std::string submittedSecurity = CgiDataUtilities::postData(cgi,
"selection");
605 std::string securityFileName = SECURITY_FILE_NAME;
608 if(securityCode_.compare(submittedSequence) != 0)
610 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
616 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
620 if(submittedSecurity !=
"")
622 __COUT__ <<
"Selection exists!" << std::endl;
623 __COUT__ << submittedSecurity << std::endl;
625 if(submittedSecurity ==
"ResetAllUserData")
627 WebUsers::deleteUserData();
628 __COUT__ <<
"Turning URL Generation back to default!" << std::endl;
631 std::ofstream newFile((SEQUENCE_FILE_NAME).c_str());
632 newFile <<
"4" << std::endl;
637 std::string securityCode) { printURL(ptr, securityCode); },
641 *out <<
"Default_URL_Generation";
643 else if(submittedSecurity ==
"ResetAllUserTooltips")
645 WebUsers::resetAllUserTooltips();
646 *out << submittedSecurity;
649 else if(submittedSecurity ==
"DigestAccessAuthentication" ||
650 submittedSecurity ==
"NoSecurity")
652 std::ofstream writeSecurityFile;
654 writeSecurityFile.open(securityFileName.c_str());
655 if(writeSecurityFile.is_open())
656 writeSecurityFile << submittedSecurity;
658 __COUT__ <<
"Error writing file!" << std::endl;
660 writeSecurityFile.close();
664 __COUT_ERR__ <<
"Invalid submittedSecurity string: " << submittedSecurity
672 std::ifstream securityFile;
674 std::string security =
"";
677 securityFile.open(securityFileName.c_str());
686 security =
"DigestAccessAuthentication";
688 if(securityFile.is_open())
691 while(std::getline(securityFile, line))
699 securityFile.close();
705 void WizardSupervisor::UserSettings(xgi::Input* in, xgi::Output* out)
708 cgicc::Cgicc cgi(in);
709 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
710 std::string securityFileName = SECURITY_FILE_NAME;
712 if((Command = CgiDataUtilities::postData(cgi,
"RequestType")) ==
"")
713 Command = cgi(
"RequestType");
715 __COUT__ << Command << std::endl;
716 __COUT__ <<
"We are vewing Users' Settings!" << std::endl;
719 if(securityCode_.compare(submittedSequence) != 0)
721 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
723 __COUT__ << submittedSequence << std::endl;
728 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
733 uint64_t activeSessionIndex;
735 uint8_t userPermissions;
739 __COUT__ <<
"Action exists!" << std::endl;
740 __COUT__ << Command << std::endl;
742 if(Command ==
"Import")
761 __COUT__ << cgi(
"Entry") << std::endl;
762 __COUT__ << cgi(
"Filename") << std::endl;
763 __COUT__ << cgi(
"Imported_File") << std::endl;
765 const std::vector<cgicc::FormFile> files = cgi.getFiles();
766 __COUT__ <<
"FormFiles: " <<
sizeof(files) << std::endl;
767 __COUT__ <<
"Number of files: " << files.size() << std::endl;
769 for(
unsigned int i = 0; i < files.size(); ++i)
771 std::string filename = USER_DATA_PATH + files[i].getFilename();
772 __COUT__ << filename << std::endl;
773 std::ofstream myFile;
774 myFile.open(filename.c_str());
775 files[0].writeToStream(myFile);
778 __COUT__ << files[0].getFilename() << std::endl;
779 __COUT__ <<
"********************Files Begin********************"
781 for(
unsigned int i = 0; i < files.size(); ++i)
783 __COUT__ << files[i].getDataType() << std::endl;
785 __COUT__ <<
"*********************Files End*********************"
792 else if(Command ==
"Export")
794 __SS__ <<
"This has been commented out due to problems compiling. Contact "
838 __COUT__ <<
"Command request not recognized: " << Command << std::endl;
850 std::string WizardSupervisor::validateUploadFileType(
const std::string fileType)
852 for(
unsigned int i = 0; i < allowedFileUploadTypes_.size(); ++i)
853 if(allowedFileUploadTypes_[i] == fileType)
854 return matchingFileUploadTypes_[i];
862 void WizardSupervisor::cleanUpPreviews()
864 std::string userData = (std::string)USER_DATA_PATH;
866 DIR* dir = opendir(userData.c_str());
869 __COUT__ <<
"Error - User Data directory missing: " << userData << std::endl;
873 struct dirent* entry;
874 time_t dirCreateTime;
881 if(strcmp(entry->d_name,
".") != 0 && strcmp(entry->d_name,
"..") != 0 &&
882 strcmp(entry->d_name,
".svn") != 0)
885 for(i = 0; i < strlen(entry->d_name); ++i)
886 if(entry->d_name[i] ==
'_')
888 entry->d_name[i] =
' ';
891 sscanf(entry->d_name,
"%li", &dirCreateTime);
893 if((time(0) - dirCreateTime) > USER_DATA_EXPIRATION_TIME)
895 __COUT__ <<
"Expired" << std::endl;
897 entry->d_name[i] =
'_';
899 __COUT__ <<
"rm -rf " << USER_DATA_PATH + (std::string)entry->d_name
902 system(((std::string)(
"rm -rf " + userData + (std::string)entry->d_name))
914 void WizardSupervisor::savePostPreview(std::string& subject,
916 const std::vector<cgicc::FormFile>& files,
931 std::string userDataPath = (std::string)USER_DATA_PATH + (std::string)fileIndex;
933 __COUT__ <<
"userDataPath " << userDataPath << std::endl;
934 if(-1 == mkdir(userDataPath.c_str(), 0755))
937 xmldoc->addTextElementToData(XML_STATUS,
938 "Failed - directory could not be generated.");