1 #include "otsdaq/WizardSupervisor/WizardSupervisor.h"
3 #include "otsdaq/GatewaySupervisor/GatewaySupervisor.h"
5 #include "otsdaq/Macros/CoutMacros.h"
6 #include "otsdaq/MessageFacility/MessageFacility.h"
8 #include <xdaq/NamespaceURI.h>
9 #include "otsdaq/CgiDataUtilities/CgiDataUtilities.h"
10 #include "otsdaq/SOAPUtilities/SOAPCommand.h"
11 #include "otsdaq/SOAPUtilities/SOAPUtilities.h"
12 #include "otsdaq/WebUsersUtilities/WebUsers.h"
13 #include "otsdaq/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-Physics.gif,"
191 "/WebPath/images/windowContentImages/state_machine_screenshot.png,/Documentation"
194 <<
",Redmine Project for otsdaq,RED,2,1,../otsdaqIcons/android-icon-36x36.png,"
195 "https://cdcvs.fnal.gov/redmine/projects/otsdaq,/Documentation"
197 <<
",Homepage for otsdaq,OTS,2,1,../otsdaqIcons/android-icon-36x36.png,"
198 "https://otsdaq.fnal.gov,/Documentation"
224 void WizardSupervisor::verification(xgi::Input* in, xgi::Output* out)
226 cgicc::Cgicc cgi(in);
227 std::string submittedSequence = CgiDataUtilities::getData(cgi,
"code");
228 __COUT__ <<
"submittedSequence=" << submittedSequence <<
" " << time(0) << std::endl;
230 std::string securityWarning =
"";
232 if(securityCode_.compare(submittedSequence) != 0)
234 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
236 *out <<
"Invalid code.";
242 __COUT__ <<
"*** Successfully authenticated security sequence "
243 <<
"@ " << time(0) << std::endl;
248 securityWarning =
"&secure=False";
252 *out <<
"<!DOCTYPE HTML><html lang='en'><head><title>ots wiz</title>" <<
255 "<link rel='apple-touch-icon' sizes='57x57' href='/WebPath/images/otsdaqIcons/apple-icon-57x57.png'>\
256 <link rel='apple-touch-icon' sizes='60x60' href='/WebPath/images/otsdaqIcons/apple-icon-60x60.png'>\
257 <link rel='apple-touch-icon' sizes='72x72' href='/WebPath/images/otsdaqIcons/apple-icon-72x72.png'>\
258 <link rel='apple-touch-icon' sizes='76x76' href='/WebPath/images/otsdaqIcons/apple-icon-76x76.png'>\
259 <link rel='apple-touch-icon' sizes='114x114' href='/WebPath/images/otsdaqIcons/apple-icon-114x114.png'>\
260 <link rel='apple-touch-icon' sizes='120x120' href='/WebPath/images/otsdaqIcons/apple-icon-120x120.png'>\
261 <link rel='apple-touch-icon' sizes='144x144' href='/WebPath/images/otsdaqIcons/apple-icon-144x144.png'>\
262 <link rel='apple-touch-icon' sizes='152x152' href='/WebPath/images/otsdaqIcons/apple-icon-152x152.png'>\
263 <link rel='apple-touch-icon' sizes='180x180' href='/WebPath/images/otsdaqIcons/apple-icon-180x180.png'>\
264 <link rel='icon' type='image/png' sizes='192x192' href='/WebPath/images/otsdaqIcons/android-icon-192x192.png'>\
265 <link rel='icon' type='image/png' sizes='32x32' href='/WebPath/images/otsdaqIcons/favicon-32x32.png'>\
266 <link rel='icon' type='image/png' sizes='96x96' href='/WebPath/images/otsdaqIcons/favicon-96x96.png'>\
267 <link rel='icon' type='image/png' sizes='16x16' href='/WebPath/images/otsdaqIcons/favicon-16x16.png'>\
268 <link rel='manifest' href='/WebPath/images/otsdaqIcons/manifest.json'>\
269 <meta name='msapplication-TileColor' content='#ffffff'>\
270 <meta name='msapplication-TileImage' content='/ms-icon-144x144.png'>\
271 <meta name='theme-color' content='#ffffff'>"
275 <<
"<frameset col='100%' row='100%'><frame src='/WebPath/html/Wizard.html?urn="
276 << this->getApplicationDescriptor()->getLocalId() << securityWarning
277 <<
"'></frameset></html>";
281 void WizardSupervisor::generateURL()
283 defaultSequence_ =
true;
286 FILE* fp = fopen((SEQUENCE_FILE_NAME).c_str(),
"r");
289 __COUT_INFO__ <<
"Sequence length file found: " << SEQUENCE_FILE_NAME
292 fgets(line, 100, fp);
293 sscanf(line,
"%d", &length);
298 defaultSequence_ =
false;
304 <<
"(Reverting to default wiz security) Sequence length file NOT found: "
305 << SEQUENCE_FILE_NAME << std::endl;
309 __COUT__ <<
"Sequence length = " << length << std::endl;
313 const char alphanum[] =
315 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
316 "abcdefghijklmnopqrstuvwxyz";
318 for(
int i = 0; i < length; ++i)
320 securityCode_ += alphanum[rand() % (
sizeof(alphanum) - 1)];
323 __COUT__ << __ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
324 << __ENV__(
"PORT") <<
"/urn:xdaq-application:lid="
325 << this->getApplicationDescriptor()->getLocalId()
326 <<
"/Verify?code=" << securityCode_ << std::endl;
332 fp = fopen((SEQUENCE_OUT_FILE_NAME).c_str(),
"w");
335 fprintf(fp,
"%s", securityCode_.c_str());
339 __COUT_ERR__ <<
"Sequence output file NOT found: " << SEQUENCE_OUT_FILE_NAME
345 void WizardSupervisor::printURL(
WizardSupervisor* ptr, std::string securityCode)
347 INIT_MF(
"ConfigurationWizard");
352 std::this_thread::sleep_for(std::chrono::seconds(2));
353 __COUT__ << __ENV__(
"OTS_CONFIGURATION_WIZARD_SUPERVISOR_SERVER") <<
":"
354 << __ENV__(
"PORT") <<
"/urn:xdaq-application:lid="
355 << ptr->getApplicationDescriptor()->getLocalId()
356 <<
"/Verify?code=" << securityCode << std::endl;
361 void WizardSupervisor::destroy(
void)
367 void WizardSupervisor::tooltipRequest(xgi::Input* in, xgi::Output* out)
369 cgicc::Cgicc cgi(in);
371 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
374 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
377 if(securityCode_.compare(submittedSequence) != 0)
379 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
391 if(Command ==
"check")
393 WebUsers::tooltipCheckForUsername(WebUsers::DEFAULT_ADMIN_USERNAME,
395 CgiDataUtilities::getData(cgi,
"srcFile"),
396 CgiDataUtilities::getData(cgi,
"srcFunc"),
397 CgiDataUtilities::getData(cgi,
"srcId"));
399 else if(Command ==
"setNeverShow")
401 WebUsers::tooltipSetNeverShowForUsername(
402 WebUsers::DEFAULT_ADMIN_USERNAME,
404 CgiDataUtilities::getData(cgi,
"srcFile"),
405 CgiDataUtilities::getData(cgi,
"srcFunc"),
406 CgiDataUtilities::getData(cgi,
"srcId"),
407 CgiDataUtilities::getData(cgi,
"doNeverShow") ==
"1" ?
true :
false,
408 CgiDataUtilities::getData(cgi,
"temporarySilence") ==
"1" ?
true :
false);
411 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
413 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
417 void WizardSupervisor::toggleSecurityCodeGeneration(xgi::Input* in, xgi::Output* out)
419 cgicc::Cgicc cgi(in);
421 std::string Command = CgiDataUtilities::getData(cgi,
"RequestType");
422 __COUT__ <<
"Got to Command = " << Command << std::endl;
424 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
427 if(securityCode_.compare(submittedSequence) != 0)
429 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
435 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
441 if(Command ==
"TurnGenerationOn")
443 __COUT__ <<
"Turning automatic URL Generation on with a sequence depth of 16!"
445 std::ofstream outfile((SEQUENCE_FILE_NAME).c_str());
446 outfile <<
"16" << std::endl;
458 std::string securityCode) { printURL(ptr, securityCode); },
463 xmldoc.addTextElementToData(
"Status",
"Generation_Success");
466 __COUT__ <<
"Command Request, " << Command <<
", not recognized." << std::endl;
468 xmldoc.outputXmlDocument((std::ostringstream*)out,
false,
true);
474 xoap::MessageReference WizardSupervisor::supervisorSequenceCheck(
475 xoap::MessageReference message)
479 parameters.addParameter(
"sequence");
480 SOAPUtilities::receive(message, parameters);
482 std::string submittedSequence = parameters.getValue(
"sequence");
486 std::map<std::string , WebUsers::permissionLevel_t> permissionMap;
488 if(securityCode_ == submittedSequence)
489 permissionMap.emplace(
490 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
491 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_ADMIN));
494 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
497 permissionMap.emplace(
498 std::pair<std::string /*groupName*/, WebUsers::permissionLevel_t>(
499 WebUsers::DEFAULT_USER_GROUP, WebUsers::PERMISSION_LEVEL_INACTIVE));
504 retParameters.addParameter(
"Permissions", StringMacros::mapToString(permissionMap));
506 return SOAPUtilities::makeSOAPMessageReference(
"SequenceResponse", retParameters);
514 xoap::MessageReference WizardSupervisor::supervisorLastConfigGroupRequest(
515 xoap::MessageReference message)
518 parameters.addParameter(
"ActionOfLastGroup");
519 SOAPUtilities::receive(message, parameters);
521 return GatewaySupervisor::lastConfigGroupRequestHandler(parameters);
525 void WizardSupervisor::Default(xgi::Input* in, xgi::Output* out)
527 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
529 *out <<
"Unauthorized Request.";
533 void WizardSupervisor::request(xgi::Input* in, xgi::Output* out)
535 cgicc::Cgicc cgiIn(in);
537 std::string submittedSequence = CgiDataUtilities::postData(cgiIn,
"sequence");
540 if(securityCode_.compare(submittedSequence) != 0)
542 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match! "
543 << time(0) << std::endl;
548 __COUT__ <<
"***Successfully authenticated security sequence. " << time(0)
553 std::string requestType = CgiDataUtilities::getData(cgiIn,
"RequestType");
554 __COUTV__(requestType);
565 if(requestType ==
"gatewayLaunchOTS" || requestType ==
"gatewayLaunchWiz")
570 __COUT_WARN__ << requestType <<
" requestType received! " << __E__;
571 __MOUT_WARN__ << requestType <<
" requestType received! " << __E__;
575 if(requestType ==
"gatewayLaunchOTS")
576 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_OTS", &cfgMgr);
577 else if(requestType ==
"gatewayLaunchWiz")
578 GatewaySupervisor::launchStartOTSCommand(
"LAUNCH_WIZ", &cfgMgr);
580 else if(requestType ==
"addDesktopIcon")
582 GatewaySupervisor::handleAddDesktopIconRequest(
"admin", cgiIn, xmlOut);
586 __SS__ <<
"requestType Request '" << requestType <<
"' not recognized."
591 catch(
const std::runtime_error& e)
593 __SS__ <<
"An error was encountered handling requestType '" << requestType
594 <<
"':" << e.what() << __E__;
595 __COUT__ <<
"\n" << ss.str();
596 xmlOut.addTextElementToData(
"Error", ss.str());
600 __SS__ <<
"An unknown error was encountered handling requestType '" << requestType
602 <<
"Please check the printouts to debug." << __E__;
603 __COUT__ <<
"\n" << ss.str();
604 xmlOut.addTextElementToData(
"Error", ss.str());
609 unsigned int occurance = 0;
610 std::string err = xmlOut.getMatchingValue(
"Error", occurance++);
613 __COUT_ERR__ <<
"'" << requestType <<
"' ERROR encountered: " << err << __E__;
614 __MOUT_ERR__ <<
"'" << requestType <<
"' ERROR encountered: " << err << __E__;
615 err = xmlOut.getMatchingValue(
"Error", occurance++);
620 xmlOut.outputXmlDocument(
621 (std::ostringstream*)out,
628 void WizardSupervisor::editSecurity(xgi::Input* in, xgi::Output* out)
631 cgicc::Cgicc cgi(in);
632 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
633 std::string submittedSecurity = CgiDataUtilities::postData(cgi,
"selection");
634 std::string securityFileName = SECURITY_FILE_NAME;
637 if(securityCode_.compare(submittedSequence) != 0)
639 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
645 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
649 if(submittedSecurity !=
"")
651 __COUT__ <<
"Selection exists!" << std::endl;
652 __COUT__ << submittedSecurity << std::endl;
654 if(submittedSecurity ==
"ResetAllUserData")
656 WebUsers::deleteUserData();
657 __COUT__ <<
"Turning URL Generation back to default!" << std::endl;
660 std::ofstream newFile((SEQUENCE_FILE_NAME).c_str());
661 newFile <<
"4" << std::endl;
666 std::string securityCode) { printURL(ptr, securityCode); },
670 *out <<
"Default_URL_Generation";
672 else if(submittedSecurity ==
"ResetAllUserTooltips")
674 WebUsers::resetAllUserTooltips();
675 *out << submittedSecurity;
678 else if(submittedSecurity ==
"DigestAccessAuthentication" ||
679 submittedSecurity ==
"NoSecurity")
681 std::ofstream writeSecurityFile;
683 writeSecurityFile.open(securityFileName.c_str());
684 if(writeSecurityFile.is_open())
685 writeSecurityFile << submittedSecurity;
687 __COUT__ <<
"Error writing file!" << std::endl;
689 writeSecurityFile.close();
693 __COUT_ERR__ <<
"Invalid submittedSecurity string: " << submittedSecurity
701 std::ifstream securityFile;
703 std::string security =
"";
706 securityFile.open(securityFileName.c_str());
715 security =
"DigestAccessAuthentication";
717 if(securityFile.is_open())
720 while(std::getline(securityFile, line))
728 securityFile.close();
734 void WizardSupervisor::UserSettings(xgi::Input* in, xgi::Output* out)
737 cgicc::Cgicc cgi(in);
738 std::string submittedSequence = CgiDataUtilities::postData(cgi,
"sequence");
739 std::string securityFileName = SECURITY_FILE_NAME;
741 if((Command = CgiDataUtilities::postData(cgi,
"RequestType")) ==
"")
742 Command = cgi(
"RequestType");
744 __COUT__ << Command << std::endl;
745 __COUT__ <<
"We are vewing Users' Settings!" << std::endl;
748 if(securityCode_.compare(submittedSequence) != 0)
750 __COUT__ <<
"Unauthorized Request made, security sequence doesn't match!"
752 __COUT__ << submittedSequence << std::endl;
757 __COUT__ <<
"***Successfully authenticated security sequence." << std::endl;
762 uint64_t activeSessionIndex;
764 uint8_t userPermissions;
768 __COUT__ <<
"Action exists!" << std::endl;
769 __COUT__ << Command << std::endl;
771 if(Command ==
"Import")
790 __COUT__ << cgi(
"Entry") << std::endl;
791 __COUT__ << cgi(
"Filename") << std::endl;
792 __COUT__ << cgi(
"Imported_File") << std::endl;
794 const std::vector<cgicc::FormFile> files = cgi.getFiles();
795 __COUT__ <<
"FormFiles: " <<
sizeof(files) << std::endl;
796 __COUT__ <<
"Number of files: " << files.size() << std::endl;
798 for(
unsigned int i = 0; i < files.size(); ++i)
800 std::string filename = USER_DATA_PATH + files[i].getFilename();
801 __COUT__ << filename << std::endl;
802 std::ofstream myFile;
803 myFile.open(filename.c_str());
804 files[0].writeToStream(myFile);
807 __COUT__ << files[0].getFilename() << std::endl;
808 __COUT__ <<
"********************Files Begin********************"
810 for(
unsigned int i = 0; i < files.size(); ++i)
812 __COUT__ << files[i].getDataType() << std::endl;
814 __COUT__ <<
"*********************Files End*********************"
821 else if(Command ==
"Export")
823 __SS__ <<
"This has been commented out due to problems compiling. Contact "
867 __COUT__ <<
"Command request not recognized: " << Command << std::endl;
879 std::string WizardSupervisor::validateUploadFileType(
const std::string fileType)
881 for(
unsigned int i = 0; i < allowedFileUploadTypes_.size(); ++i)
882 if(allowedFileUploadTypes_[i] == fileType)
883 return matchingFileUploadTypes_[i];
891 void WizardSupervisor::cleanUpPreviews()
893 std::string userData = (std::string)USER_DATA_PATH;
895 DIR* dir = opendir(userData.c_str());
898 __COUT__ <<
"Error - User Data directory missing: " << userData << std::endl;
902 struct dirent* entry;
903 time_t dirCreateTime;
910 if(strcmp(entry->d_name,
".") != 0 && strcmp(entry->d_name,
"..") != 0 &&
911 strcmp(entry->d_name,
".svn") != 0)
914 for(i = 0; i < strlen(entry->d_name); ++i)
915 if(entry->d_name[i] ==
'_')
917 entry->d_name[i] =
' ';
920 sscanf(entry->d_name,
"%li", &dirCreateTime);
922 if((time(0) - dirCreateTime) > USER_DATA_EXPIRATION_TIME)
924 __COUT__ <<
"Expired" << std::endl;
926 entry->d_name[i] =
'_';
928 __COUT__ <<
"rm -rf " << USER_DATA_PATH + (std::string)entry->d_name
931 system(((std::string)(
"rm -rf " + userData + (std::string)entry->d_name))
943 void WizardSupervisor::savePostPreview(std::string& subject,
945 const std::vector<cgicc::FormFile>& files,
960 std::string userDataPath = (std::string)USER_DATA_PATH + (std::string)fileIndex;
962 __COUT__ <<
"userDataPath " << userDataPath << std::endl;
963 if(-1 == mkdir(userDataPath.c_str(), 0755))
966 xmldoc->addTextElementToData(XML_STATUS,
967 "Failed - directory could not be generated.");