void CXml::CreateUploadXml (void *pNote) { ASSERT (!m_szUploadXml.IsEmpty ()); ASSERT (pNote != NULL); CNote *note = (CNote *) pNote; // Create the xml for one note CString szXML, szTemp; m_szUploadXml += _T("<note>"); szTemp.Format (_T("<noteversion>%d</noteversion>"),note->GetNoteVersion ()); m_szUploadXml += szTemp; szTemp.Format (_T("<noteid>%s</noteid>"), StringEncode (note->GetNoteID ())); m_szUploadXml += szTemp; szTemp.Format (_T("<alarmtime>%s</alarmtime>"), StringEncode (note->GetAlarm ().Format (_T("%m/%d/%Y %H:%M:%S")))); m_szUploadXml += szTemp; szTemp.Format (_T("<usealarm>%s</usealarm>"), note->GetUseAlarm () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<title>%s</title>"),StringEncode (note->GetTitle ())); m_szUploadXml += szTemp; szTemp.Format (_T("<visible>%s</visible>"), note->GetVisible () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<notecolor>%d</notecolor>"),note->GetNoteColor ()); m_szUploadXml += szTemp; szTemp.Format (_T("<positionleft>%d</positionleft>"),note->GetPosition ().left); m_szUploadXml += szTemp; szTemp.Format (_T("<positiontop>%d</positiontop>"),note->GetPosition ().top); m_szUploadXml += szTemp; szTemp.Format (_T("<width>%d</width>"),note->GetPosition ().right); m_szUploadXml += szTemp; szTemp.Format (_T("<height>%d</height>"),note->GetPosition ().bottom); m_szUploadXml += szTemp; szTemp.Format (_T("<text>%s</text>"), StringEncode (note->GetText ())); m_szUploadXml += szTemp; szTemp.Format (_T("<dockedleft>%s</dockedleft>"), note->GetDockedLeft () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<dockedtop>%s</dockedtop>"), note->GetDockedTop () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<dockedright>%s</dockedright>"), note->GetDockedRight () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<dockedbottom>%s</dockedbottom>"), note->GetDockedBottom () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<slided-left>%s</slided-left>"), note->GetSlidedLeft () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<slided-right>%s</slided-right>"), note->GetSlidedRight () ? _T("true") : _T("false")); m_szUploadXml += szTemp; szTemp.Format (_T("<slidepositionleft>%d</slidepositionleft>"), note->GetSlidePosition ().left); m_szUploadXml += szTemp; szTemp.Format (_T("<slidepositiontop>%d</slidepositiontop>"), note->GetSlidePosition ().top); m_szUploadXml += szTemp; szTemp.Format (_T("<slidepositionright>%d</slidepositionright>"), note->GetSlidePosition ().right); m_szUploadXml += szTemp; szTemp.Format (_T("<slidepositionbottom>%d</slidepositionbottom>"), note->GetSlidePosition ().bottom); m_szUploadXml += szTemp; szTemp.Format (_T("<readable-note-text>%s</readable-note-text>"), StringEncode (note->GetReadableText ())); m_szUploadXml += szTemp; m_szUploadXml += _T("</note>"); }
int Authorization::CreateKeyFile(string fileName,string machineFile) { try{ if (! IsFileExit(machineFile)) { return 0; } Wow64EnableWow64FsRedirection(false); SYSTEMTIME sysTime; GetSystemTime(&sysTime); stringstream ss; ss << sysTime.wYear << sysTime.wMonth << sysTime.wDay; string myTime = ss.str(); ifstream myInfile(machineFile); string machineCode; myInfile >> machineCode; string myStr = machineCode + myTime; //string myEncodeStr = base64_encode(reinterpret_cast<const unsigned char*>(myStr.c_str()), myStr.length()); string myEncodeStr= StringEncode().base64_encode(myStr); myEncodeStr += "@!$%c"; cout << myStr; CreateMyFile(fileName, myEncodeStr); Wow64EnableWow64FsRedirection(true); return 0; } catch (exception e) { Wow64EnableWow64FsRedirection(true); return -1; } }
CString CXml::GetOneNoteXml(void *pNote) { CNote *note = (CNote *) pNote; CRect rc1, rc2; CString szTemp; CString szXML; rc1 = note->GetPosition (); rc2 = note->GetSlidePosition (); szTemp.Format (_T("<note noteid=\"%s\" noteversion=\"%d\" dockedleft=\"%s\" dockedtop=\"%s\" dockedright=\"%s\" dockedbottom=\"%s\" alarmtime=\"%s\" usealarm=\"%s\" title=\"%s\" visible=\"%s\" notecolor=\"%d\" positionleft=\"%d\" positiontop=\"%d\" width=\"%d\" height=\"%d\" slided-left=\"%s\" slided-right=\"%s\" slidepositionleft=\"%d\" slidepositiontop=\"%d\" slidepositionright=\"%d\" slidepositionbottom=\"%d\">\n"), StringEncode (note->GetNoteID ()), note->GetNoteVersion (), note->GetDockedLeft () ? _T("true") : _T("false"), note->GetDockedTop () ? _T("true") : _T("false"), note->GetDockedRight () ? _T("true") : _T("false"), note->GetDockedBottom () ? _T("true") : _T("false"), StringEncode (note->GetAlarm ().Format (_T("%m/%d/%Y %H:%M:%S"))), note->GetUseAlarm () ? _T("true") : _T("false"), StringEncode (note->GetTitle ()), note->GetVisible () ? _T("true") : _T("false"), note->GetNoteColor (), rc1.left, rc1.top, rc1.right, rc1.bottom, note->GetSlidedLeft () ? _T("true") : _T("false"), note->GetSlidedRight () ? _T("true") : _T("false"), rc2.left, rc2.top, rc2.right, rc2.bottom); szXML += szTemp; szTemp.Format (_T("%s</note>\n"), StringEncode (note->GetText ())); szXML += szTemp; return szXML; }
void CXml::CreateRecycleBinXml (tagNote note) { ASSERT (!m_szRecycleBinXml.IsEmpty ()); CRect rc1, rc2; CString szTemp; rc1 = note.cRect; rc2 = note.cRectPosition; szTemp.Format (_T("<note noteid=\"%s\" noteversion=\"%d\" dockedleft=\"%s\" dockedtop=\"%s\" dockedright=\"%s\" dockedbottom=\"%s\" alarmtime=\"%s\" usealarm=\"%s\" title=\"%s\" visible=\"%s\" notecolor=\"%d\" positionleft=\"%d\" positiontop=\"%d\" width=\"%d\" height=\"%d\" slided-left=\"%s\" slided-right=\"%s\" slidepositionleft=\"%d\" slidepositiontop=\"%d\" slidepositionright=\"%d\" slidepositionbottom=\"%d\">\n"), StringEncode (note.szNoteID), note.iNoteVersion, note.bDockedLeft ? _T("true") : _T("false"), note.bDockedTop ? _T("true") : _T("false"), note.bDockedRight ? _T("true") : _T("false"), note.bDockedBottom ? _T("true") : _T("false"), StringEncode (note.szAlarmTime), note.bUseAlarm ? _T("true") : _T("false"), StringEncode (note.szTitle), note.bVisible ? _T("true") : _T("false"), note.cfNoteColor, rc1.left, rc1.top, rc1.right, rc1.bottom, note.bSlidedLeft ? _T("true") : _T("false"), note.bSlidedRight ? _T("true") : _T("false"), rc2.left, rc2.top, rc2.right, rc2.bottom); m_szRecycleBinXml += szTemp; szTemp.Format (_T("%s</note>"), StringEncode (note.szText)); m_szRecycleBinXml += szTemp; }
bool Authorization::CheckVerIdFile() { stringstream ss; SYSTEMTIME sysTime; GetSystemTime(&sysTime); ss << sysTime.wYear << sysTime.wMonth << sysTime.wDay; string myTime = ss.str(); ifstream inFile(c.c_str(), ofstream::in | ofstream::binary); string MyStr; inFile >> MyStr; if (MyStr.length()<13) { return false; } string enCodeStr; for (int i = 0; i < MyStr.length()-5;++i) { enCodeStr += MyStr[i]; } string decodeStr = StringEncode().base64_decode(enCodeStr); string decodeTime,decodeMachineCode; for (int i = 0; i < decodeStr.length() - myTime.length();++i) { decodeMachineCode += decodeStr[i]; } CPUID myCpu; if (myCpu.GetModel()!=decodeMachineCode) { return false; } for (int i = decodeStr.length() - myTime.length(); i<decodeStr.length(); ++i) { decodeTime += decodeStr[i]; } if (myTime == decodeTime) { return true; }else { return false; } }
int main() { int d,m,y; char query[1024]; char *env; char *coord=NULL; char *search=NULL; char buf[1024]; char *tmp; time_t t; struct tm *tt; time(&t); tt = localtime(&t); d = tt->tm_mday; m = tt->tm_mon+1; y = tt->tm_year+1900; env = getenv("QUERY_STRING"); if (env) { char *s; s = strstr(env, "d="); if (s) sscanf(s, "d=%d", &d); s = strstr(env, "m="); if (s) sscanf(s, "m=%d", &m); s = strstr(env, "y="); if (s) sscanf(s, "y=%d", &y); s = strstr(env, "c="); if (s) s+=2; else { // spatna kompatibilita so znackami s = strstr(env, "in="); if (s) s+=3; } if (s) { query[0]=0; sscanf(s, "%1000[^&]", query); coord=StringDecode(query); } s = strstr(env, "search="); if (s) { query[0]=0; sscanf(s+7, "%1000[^&]", query); search = StringDecode(query); } } if (db_init()<0) return 1; printf("Content-Type: text/html; charset=UTF-8\n\n"); printf("<html><head>\n" "<link rel=\"stylesheet\" href=\"breviar.css\">\n"); Rst(&kontext); kontext_last_hb=kontext_last_he=-1; first.h=last.h=-1; if (coord) { printf("<title>%s</title>\n" "</head><body>\n" "<div class=\"nadpis\">%s</div>\n\n", coord, coord); kalendar = 0; scan_string(coord); yyparse(); printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"c\">\n" "<input type=\"submit\" value=\"Zobraz\">\n" "</form>\n"); { char *tmp = StringEncode(kontext.buf+1); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Kontext</a>", tmp); free(tmp); } printf(" "); if (first.h!=-1) { char *b; int h; get_prev(first.k, first.h, &b, &h); if (b!=NULL) { snprintf(buf, sizeof(buf), "%s %d", b, h); tmp = StringEncode(buf); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Dozadu (%s %d)</a>", tmp, b, h); free(tmp); free(b); } } printf(" "); if (last.h!=-1){ char *b; int h; get_next(last.k, last.h, &b, &h); if (b!=NULL) { snprintf(buf, sizeof(buf), "%s %d", b, h); tmp = StringEncode(buf); printf(// "<p>\n" "<a href=\"pismo.cgi?c=%s\">Dopredu (%s %d)</a>", tmp, b, h); free(tmp); free(b); } } printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"search\">\n" "<input type=\"submit\" value=\"Hľadaj\">\n" "</form>\n"); } else if (search) { char *b,*t; int h,v; printf("<title>Vyhľadávanie \"%s\"</title>\n" "</head><body>\n" "<div class=\"nadpis\">Vyhľadávanie \"%s\"</div>\n\n", search, search); fulltext_search(search); while (get_fulltext_result(&b, &h, &v, &t)) { int i,in,var; snprintf(buf, sizeof(buf), "%s%d", b,h); tmp = StringEncode(buf); printf("\n<p> <a href=\"pismo.cgi?c=%s\">%s%d", tmp, b, h); if (v!=-1) printf(",%d", v); printf("</a>: "); free(tmp); for (i=in=var=0; t[i]; i++) { if (t[i]=='<') { in = 1; if (!strncmp(t+i+1, "var>", 4)) var = 1; if (!strncmp(t+i+1, "/var>", 5)) var = 0; } if (!in && !var) printf("%c", t[i]); if (t[i]=='>') in = 0; } } printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"c\">\n" "<input type=\"submit\" value=\"Zobraz\">\n" "</form>\n"); printf("<p>\n" "<form action=\"pismo.cgi\" method=\"get\">\n" "<input type=\"text\" name=\"search\">\n" "<input type=\"submit\" value=\"Hľadaj\">\n" "</form>\n"); free_fulltext_search(); } else { char *ct; if (!get_citania(y,m,d, &zalm, &ct)) return 3; kalendar = 1; // printf("%s %s %s %s\n", row[0], row[1], row[2], row[3]); printf("<title>Čítania na %d.%d.%d</title>\n" "</head><body>\n" "<div class=\"nadpis\">Liturgické čítania na %d.%d.%d</div>\n\n", d,m,y,d,m,y); scan_string(ct); yyparse(); /* toto asi nechceme { char *tmp = StringEncode(kontext.buf+1); printf("<p>\n" "<a href=\"pismo.cgi?c=%s\">Kontext</a>", tmp); free(tmp); } */ free(zalm); free(ct); } printf("</body></html>\n"); free_scan_string(); db_close(); return 0; }