Loading src/admin.cpp +32 −30 Changes for src/admin.cpp: 32 added lines, 30 removed lines. Original line number Diff line number Diff line Loading @@ -406,13 +406,15 @@ namespace authdb { curform.parse(curreq); std::shared_ptr<authdb::AuthData> curec=std::make_shared<authdb::AuthData>(uid); std::shared_ptr<authdb::AuthData::Record> curec=std::make_shared<authdb::AuthData::Record>(); std::copy(&uid.value[0],&uid.value[sizeof(uuid_t)],&curec->ruid[0]); for (libhttppp::HttpForm::MultipartForm::Data* curformdat = curform.MultipartFormData.getFormData(); curformdat; curformdat = curformdat->nextData()) { curec->Data.type=UserData; curec->Data.storage=EmptyStorage; curec->type=UserData; curec->storage=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); curdispo; curdispo=curdispo->nextContentDisposition() Loading @@ -435,15 +437,15 @@ namespace authdb { [](unsigned char c){ return std::tolower(c); }); if(key=="name"){ strcpy(curec->Data.fieldname,curdispo->getValue()); strcpy(curec->fieldname,curdispo->getValue()); } if(key=="filename"){ curec->Data.storage=BinaryStorage; curec->storage=BinaryStorage; } } if(curec->Data.storage==EmptyStorage){ if(curec->storage==EmptyStorage){ bool numeric=true; for(auto t : curformdat->Value){ Loading @@ -454,59 +456,59 @@ namespace authdb { } if(numeric) curec->Data.storage=IntStorage; curec->storage=IntStorage; else curec->Data.storage=TextStorage; curec->storage=TextStorage; } if(curec->Data.storage==TextStorage) { if(curec->storage==TextStorage) { curformdat->Value.push_back('\0'); if(strcmp(curec->Data.fieldname,"pwhash")==0){ Hash hash; if(strcmp(curec->fieldname,"pwhash")==0){ sha512 hash; std::string pwhash,inpw; std::copy(curformdat->Value.begin(),curformdat->Value.end(), std::back_inserter(inpw)); hash.hash(inpw,pwhash); curec->Data.datasize=pwhash.length()+1; curec->Data.data=new char[curec->Data.datasize]; std::copy(pwhash.begin(),pwhash.end(),curec->Data.data); curec->Data.data[pwhash.length()]='\0'; curec->datasize=pwhash.length()+1; curec->data=new char[curec->datasize]; std::copy(pwhash.begin(),pwhash.end(),curec->data); curec->data[pwhash.length()]='\0'; editrec->append(*curec); delete[] curec->Data.data; delete[] curec->data; }else{ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; curec->datasize=curformdat->Value.size(); curec->data=new char[curec->datasize]; std::copy(curformdat->Value.begin(), curformdat->Value.end(),curec->Data.data); curformdat->Value.end(),curec->data); editrec->append(*curec); delete[] curec->Data.data; delete[] curec->data; } }else if(curec->Data.storage==BinaryStorage){ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; }else if(curec->storage==BinaryStorage){ curec->datasize=curformdat->Value.size(); curec->data=new char[curec->datasize]; std::copy( curformdat->Value.begin(), curformdat->Value.end(), curec->Data.data curec->data ); editrec->append(*curec); delete[] curec->Data.data; }else if(curec->Data.storage==IntStorage){ delete[] curec->data; }else if(curec->storage==IntStorage){ curformdat->Value.push_back('\0'); curec->Data.datasize=sizeof(int); curec->Data.data=new char[sizeof(int)]; curec->datasize=sizeof(int); curec->data=new char[sizeof(int)]; int val=atoi(curformdat->Value.data()); std::copy( reinterpret_cast<char*>(&val), reinterpret_cast<char*>(&val+sizeof(int)), curec->Data.data curec->data ); editrec->append(*curec); delete[] reinterpret_cast<int*>(curec->Data.data); delete[] reinterpret_cast<int*>(curec->data); } } Loading Loading
src/admin.cpp +32 −30 Changes for src/admin.cpp: 32 added lines, 30 removed lines. Original line number Diff line number Diff line Loading @@ -406,13 +406,15 @@ namespace authdb { curform.parse(curreq); std::shared_ptr<authdb::AuthData> curec=std::make_shared<authdb::AuthData>(uid); std::shared_ptr<authdb::AuthData::Record> curec=std::make_shared<authdb::AuthData::Record>(); std::copy(&uid.value[0],&uid.value[sizeof(uuid_t)],&curec->ruid[0]); for (libhttppp::HttpForm::MultipartForm::Data* curformdat = curform.MultipartFormData.getFormData(); curformdat; curformdat = curformdat->nextData()) { curec->Data.type=UserData; curec->Data.storage=EmptyStorage; curec->type=UserData; curec->storage=EmptyStorage; for(libhttppp::HttpForm::MultipartForm::Data::ContentDisposition *curdispo=curformdat->getDisposition(); curdispo; curdispo=curdispo->nextContentDisposition() Loading @@ -435,15 +437,15 @@ namespace authdb { [](unsigned char c){ return std::tolower(c); }); if(key=="name"){ strcpy(curec->Data.fieldname,curdispo->getValue()); strcpy(curec->fieldname,curdispo->getValue()); } if(key=="filename"){ curec->Data.storage=BinaryStorage; curec->storage=BinaryStorage; } } if(curec->Data.storage==EmptyStorage){ if(curec->storage==EmptyStorage){ bool numeric=true; for(auto t : curformdat->Value){ Loading @@ -454,59 +456,59 @@ namespace authdb { } if(numeric) curec->Data.storage=IntStorage; curec->storage=IntStorage; else curec->Data.storage=TextStorage; curec->storage=TextStorage; } if(curec->Data.storage==TextStorage) { if(curec->storage==TextStorage) { curformdat->Value.push_back('\0'); if(strcmp(curec->Data.fieldname,"pwhash")==0){ Hash hash; if(strcmp(curec->fieldname,"pwhash")==0){ sha512 hash; std::string pwhash,inpw; std::copy(curformdat->Value.begin(),curformdat->Value.end(), std::back_inserter(inpw)); hash.hash(inpw,pwhash); curec->Data.datasize=pwhash.length()+1; curec->Data.data=new char[curec->Data.datasize]; std::copy(pwhash.begin(),pwhash.end(),curec->Data.data); curec->Data.data[pwhash.length()]='\0'; curec->datasize=pwhash.length()+1; curec->data=new char[curec->datasize]; std::copy(pwhash.begin(),pwhash.end(),curec->data); curec->data[pwhash.length()]='\0'; editrec->append(*curec); delete[] curec->Data.data; delete[] curec->data; }else{ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; curec->datasize=curformdat->Value.size(); curec->data=new char[curec->datasize]; std::copy(curformdat->Value.begin(), curformdat->Value.end(),curec->Data.data); curformdat->Value.end(),curec->data); editrec->append(*curec); delete[] curec->Data.data; delete[] curec->data; } }else if(curec->Data.storage==BinaryStorage){ curec->Data.datasize=curformdat->Value.size(); curec->Data.data=new char[curec->Data.datasize]; }else if(curec->storage==BinaryStorage){ curec->datasize=curformdat->Value.size(); curec->data=new char[curec->datasize]; std::copy( curformdat->Value.begin(), curformdat->Value.end(), curec->Data.data curec->data ); editrec->append(*curec); delete[] curec->Data.data; }else if(curec->Data.storage==IntStorage){ delete[] curec->data; }else if(curec->storage==IntStorage){ curformdat->Value.push_back('\0'); curec->Data.datasize=sizeof(int); curec->Data.data=new char[sizeof(int)]; curec->datasize=sizeof(int); curec->data=new char[sizeof(int)]; int val=atoi(curformdat->Value.data()); std::copy( reinterpret_cast<char*>(&val), reinterpret_cast<char*>(&val+sizeof(int)), curec->Data.data curec->data ); editrec->append(*curec); delete[] reinterpret_cast<int*>(curec->Data.data); delete[] reinterpret_cast<int*>(curec->data); } } Loading