void serverPage::Dump(FILE* fOut) { wxString sHTML = HTML(); fprintf(fOut,"---------------------------------------------------------\n"); fprintf(fOut, "Page name : %s\n", m_sPageName.c_str()); fprintf(fOut, "Page title : %s\n", m_sPageTitle.c_str()); fprintf(fOut, "MIME type : %s\n", m_sMimeType.c_str()); fprintf(fOut, "Content Length : %ld\n", m_size); if (!m_sRedirect.IsEmpty()) { fprintf(fOut, "Redirect URL : %s\n", m_sRedirect.c_str()); fprintf(fOut, "Redirect Time : %d Seconds\n", m_nRedirectTime); } else if (m_nRedirectTime > 0) { fprintf(fOut, "Refresh Time : %d Seconds\n", m_nRedirectTime); } if (m_bEnableCaching) { fprintf(fOut, "Caching : Enabled expires @ %s\n", m_sCacheExpires.c_str()); } else { fprintf(fOut, "Caching : Disabled\n"); } fprintf(fOut, "\n"); fprintf(fOut, "%s\n", sHTML.c_str()); fprintf(fOut,"---------------------------------------------------------\n"); return; }
void ReportStudentByCourse::go() { string code = getCodeFromInput(); ofstream HTML((code + ".html").c_str()); Course course = db.doQueryCourse(code); db.Write2HTML_StudentByCourse(HTML, course); cout << "Output successful" << endl << endl; }
void ReportCourseByStudent::go() { string ID = getStuIDFromInput(); ofstream HTML((ID + ".html").c_str()); Student student = db.doQueryStudent(ID); db.Write2HTML_CourseByStudent(HTML, student); cout << "Output successful" << endl << endl; }
bool serverPage::SaveToFile(wxString sFilename) { bool bRes = false; wxFileName fname(sFilename); wxString sFullPath; wxFile textFile; wxString sFileText; D(debug("serverPage::SaveToFile(%s)\n", sFilename.c_str())); if (m_type == PAGE_HTML) { sFileText = HTML(); } else if (m_type == PAGE_TEXT) { sFileText = TEXT(); } else { fprintf(stderr, "ERROR: Unsupported page type %d.\n", (int)m_type); return false; } if (sFilename != wxT("-")) { if (fname.IsDir()) { fname.Assign( sFilename, m_sPageName ); } else { fname.Assign( sFilename ); } sFullPath = fname.GetFullPath(); D(debug("-- saving to file %s\n", sFullPath.c_str())); if (!textFile.Create( sFullPath.c_str(), true )) { fprintf(stderr, "ERROR: Unable to open output file %s!\n", sFullPath.c_str()); return false; } } else { D(debug("-- sending output to standard out!\n")); textFile.Attach(wxFile::fd_stdout); } bRes = textFile.Write( sFileText ); if (sFilename == wxT("-")) { textFile.Detach(); } return bRes; }
mHpWebClient::mHpWebClient( std::string const& html_or_url, HINSTANCE instance, bool is_url, int x, int y, int cx, int cy, HWND hParent) : instance_ (instance), browserObject_ (0), bUserTrigURL_ (false) { Create(x, y, cx, cy, hParent); if (is_url) URL (html_or_url); else HTML(html_or_url); }
ExtensionsDialog::ExtensionsDialog(wxWindow* parent) : wxDialog(parent, wxID_ANY, wxT("Extensions"), wxDefaultPosition, wxSize(600, 500), wxRESIZE_BORDER | wxCAPTION) { wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); wxHtmlWindow* htmlWindow = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(550, 400)); htmlWindow->SetPage(HTML()); topSizer->Add(htmlWindow, wxSizerFlags(1).DoubleBorder().Expand()); wxSizer* buttonSizer = newd wxBoxSizer(wxHORIZONTAL); buttonSizer->Add(newd wxButton(this, wxID_OK, wxT("OK")), wxSizerFlags(1).Center()); buttonSizer->Add(newd wxButton(this, EXTENSIONS_OPEN_FOLDER_BUTTON, wxT("Open Extensions Folder")), wxSizerFlags(1).Center()); topSizer->Add(buttonSizer, 0, wxCENTER | wxLEFT | wxRIGHT | wxBOTTOM, 20); SetSizerAndFit(topSizer); }
int WiiSave::InternalDownload(std::string url, std::string filepath) { if (url.empty()) return -1; StartManageProgress(tr("Downloading file..."), "www.wiisave.com"); HTML_Stream HTML(url.c_str()); HTML.FindStringEnd("location='"); char * location = HTML.CopyString("'"); if(location) { url = url.erase(23); url += location; free(location); } else { ManageProgressStop(); return -2; } struct block file = downloadfile(url.c_str()); if (!file.data || !file.size) { ManageProgressStop(); return -3; } FILE * File = fopen(filepath.c_str(), "wb"); if(!File) { ManageProgressStop(); return -4; } fwrite(file.data, 1, file.size, File); fclose(File); ManageProgressStop(); return 1; }
void ChatBase::saveHTML() { QString fname = KFileDialog::getSaveFileName( 0, "*.html", this, "Enter filename to save capture file." ); if ( fname.isEmpty() ) { qWarning("ChatSession::saveHTML filename is NULL"); return; } QFile* outfile = new QFile( fname ); outfile->open( IO_WriteOnly ); QTextStream outstream ( outfile ); outstream << "Chat Log taken on " << QDate::currentDate().toString() << endl; outstream << "=============================================================" << endl; outstream << HTML(); outfile->close(); }
void VybranyDenHodina(int den, int hodina, string path, bool nameB) { ofstream HTML(path.c_str()); if (!HTML.is_open()) { ClrScrn(); cout << "Nepodarilo se vytvorit soubor." << endl; system("pause"); return; } HTML << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl << "<html>" << endl << "<head>" << endl << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" << endl << "<title>Rozvrh</title>" << endl << "</head>" << endl << "<body bgcolor=\"#FFaa00\">" << endl << "<h1 align=\"center\"><b>Rozvrh pro vybrany den</b></h1>" << endl << "<p>Vybrali jste si " << hodina << ". hodinu "; switch (den) { case 1: HTML << "v pondeli"; break; case 2: HTML << "v utery"; break; case 3: HTML << "ve stredu"; break; case 4: HTML << "ve ctvrtek"; break; case 5: HTML << "v patek"; break; default: break; } den--; hodina--; HTML << ".</p><br />" << endl << "<center>" << endl << "<p>" << endl; for (int clovek = 0; clovek < pocet; clovek++) { if (TT[clovek].Table[den][hodina] != "") { if (nameB) HTML << "<b>" << jmena[clovek] << ":</b> "; HTML << TT[clovek].Table[den][hodina]; } HTML << "<br />"; } HTML << "</p>" << endl << "</body>" << endl << "</html>"; HTML.close(); ClrScrn(); cout << "Vytvoreni souboru probehlo uspesne." << endl; system("pause"); return; }
void VybranyDen(int den, string path, bool nameB) { ofstream HTML(path.c_str()); if (!HTML.is_open()) { ClrScrn(); cout << "Nepodarilo se vytvorit soubor." << endl; system("pause"); return; } HTML << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl << "<html>" << endl << "<head>" << endl << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" << endl << "<title>Rozvrh</title>" << endl << "</head>" << endl << "<body bgcolor=\"#FFaa00\">" << endl << "<center>" << endl << "<h1><b>Slouceny rozvrh pro vsechny spoluzaky</b></h1>" << endl << "</center>" << endl << "<table border=\"1\" align=\"left\">" << endl << "<tr>" << endl << "<th><font size=\"4\">Hodiny</font></th>" << endl << "<th>7:15 - 8:00</th>" << endl << "<th>8:00 - 8:45</th>" << endl << "<th>9:00 - 9:45</th>" << endl << "<th>9:45 - 10:30</th>" << endl << "<th>10:45 - 11:30</th>" << endl << "<th>11:30 - 12:15</th>" << endl << "<th>12:30 - 13:15</th>" << endl << "<th>13:15 - 14:00</th>" << endl << "<th>14:15 - 15:00</th>" << endl << "<th>15:00 - 15:45</th>" << endl << "<th>16:00 - 16:45</th>" << endl << "<th>16:45 - 17:30</th>" << endl << "<th>17:45 - 18:30</th>" << endl << "<th>18:30 - 19:15</th>" << endl << "</tr>" << endl << "<tr>" << endl; switch (den) { case 1: HTML << "<td><font size=\"4\">Pondeli</font></td>" << endl; break; case 2: HTML << "<td><font size=\"4\">Utery</font></td>" << endl; break; case 3: HTML << "<td><font size=\"4\">Streda</font></td>" << endl; break; case 4: HTML << "<td><font size=\"4\">Ctvrtek</font></td>" << endl; break; case 5: HTML << "<td><font size=\"4\">Patek</font></td>" << endl; break; default: break; } den--; for (int hodina = 0; hodina < 14; hodina++) { HTML << "<td>" << endl; for (int clovek = 0; clovek < pocet; clovek++) { if (TT[clovek].Table[den][hodina] != "") { if (nameB) HTML << "<b>" << jmena[clovek] << ":</b> "; HTML << TT[clovek].Table[den][hodina]; } HTML << "<br />"; } HTML << "</td>" << endl; } HTML << "</tr>" << endl; HTML << "</table>" << endl << "</body>" << endl << "</html>"; HTML.close(); ClrScrn(); cout << "Vytvoreni souboru probehlo uspesne." << endl; system("pause"); return; }
static int CgiStatusRow( FILE * stream, int row_no ) { time_t secs = time(NULL); switch( row_no ) { case -1: //HTML("<TR><TH> Type </TH><TH> Value </TH><TH> Comment </TH></TR>\r\n"); break; //HTML("<TR><TH align=left> </TH><TH align=left> </TH></TR>\r\n"); break; //HTML("<th colspan=\"2\" align=left>Time</th>"); break; subhdr( stream, "Time" ); break; case 0: { HTML("<TR><TD> GMT Time </TD><TD> "); printTime( stream, gmtime(&secs) ); HTML(" </TD></TR>\r\n"); //ShowTableRow3( stream, char *c1, char *c2, char *c3 ); } break; case 1: { HTML("<TR><TD> Local Time </TD><TD> "); printTime( stream, localtime(&secs) ); HTML(" </TD></TR>\r\n"); } break; case 2: { char minus = _timezone < 0; int32_t seconds = labs(_timezone); int32_t minutes = seconds / 60UL; int32_t hours = minutes / 60UL; minutes %= 60UL; seconds %= 60UL; HTML("<TR><TD> TimeZone </TD><TD> "); fprintf(stream, "%s%ld:%ld:%ld (%ld)", (minus ? "-" : ""), hours, minutes, seconds, _timezone ); HTML(" </TD></TR>\r\n"); } break; case 3: { uint32_t seconds = NutGetSeconds(); uint32_t minutes = seconds / 60UL; uint32_t hours = minutes / 60UL; uint32_t days = hours / 24UL; minutes %= 60UL; seconds %= 60UL; hours %= 24UL; HTML("<TR><TD> UpTime </TD><TD> "); fprintf(stream, "%lu days %lu:%lu:%lu", days, hours, minutes, seconds); HTML(" </TD></TR>\r\n"); } break; //case 4: ShowTableRow2b( stream, "DST", _daylight ); break; case 4: ShowTableRow2b( stream, "Used SNTP", sntp_available ); break; //case 6: HTML("<th colspan=\"2\">FirmWare</th>"); break; case 5: subhdr( stream, "FirmWare" ); break; case 6: ShowTableRow2( stream, "Build", makeDate ); break; case 7: ShowTableRow2( stream, "Name", DEVICE_NAME ); break; case 8: ShowTableRow2( stream, "ModBus Id", modbus_device_id ); break; //case 9: HTML("<th colspan=\"2\">ModBus</th>"); break; case 9: subhdr( stream, "ModBus" ); break; case 10: ShowTableRow2i( stream, "IO count", modbus_event_cnt ); break; case 11: ShowTableRow2i( stream, "CRC count", modbus_crc_cnt ); break; case 12: ShowTableRow2i( stream, "exceptions count", modbus_exceptions_cnt );break; case 13: ShowTableRow2i( stream, "err flags", modbus_error_flags ); break; case 14: subhdr( stream, "1-Wire" ); break; case 15: ShowTableRow2b( stream, "Devices detected", onewire_available ); break; case 16: ShowTableRow2i( stream, "Temp sensors count", nTempSensors ); break; case 17: #if SERVANT_1WMAC { HTML("<TR><TD> 2401 Id </TD><TD> "); fprintf(stream, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", serialNumber [7], serialNumber [6], serialNumber [5], serialNumber [4], serialNumber [3], serialNumber [2], serialNumber [1], serialNumber [0] ); HTML(" </TD></TR>\r\n"); } #endif break; case 18: subhdr( stream, "OS" ); break; case 19: ShowTableRow2i( stream, "Free mem, K", NutHeapAvailable()/1024 ); break; case 20: ShowTableRow2i( stream, "Size of EEPROM cfg", sizeof(struct eeprom_cfg) ); break; case 21: { uint32_t tx_total, rx_total; uint8_t active; #if SERVANT_TUN0 || SERVANT_TUN1 subhdr( stream, "Tunnels" ); #if SERVANT_TUN0 get_tunnel_stats( 0, &tx_total, &rx_total, &active ); ShowTableRow2b( stream, "Tun0 active", active ); ShowTableRow2i( stream, "Tun0 RX, K", rx_total/1024 ); ShowTableRow2i( stream, "Tun0 TX, K", tx_total/1024 ); #endif #if SERVANT_TUN1 get_tunnel_stats( 1, &tx_total, &rx_total, &active ); ShowTableRow2b( stream, "Tun1 active", active ); ShowTableRow2i( stream, "Tun1 RX, K", rx_total/1024 ); ShowTableRow2i( stream, "Tun1 TX, K", tx_total/1024 ); #endif #endif break; } case 22: subhdr( stream, "DHT11" ); break; case 23: ShowTableRow2i( stream, "Errors count", dht11_errorCnt ); break; default: return 0; } return 1; }
void ReportCourse::go() { ofstream HTML("Courses.html"); db.Write2HTML_Course(HTML); cout << "Output successful" << endl << endl; }
void ReportStudent::go() { ofstream HTML("Students.html"); db.Write2HTML_Student(HTML); cout << "Output successful" << endl << endl; }
bool serverPage::Send(wxSocketBase* pSocket) { bool bRes = false; wxString sHTTP; wxString sPageText; D(debug("serverPage::Send(%p)\n", pSocket)); #ifdef ENABLE_DEBUG_SEND FILE* fOut = fopen("/tmp/http.txt", "w"); #endif pSocket->SaveState(); pSocket->SetFlags(wxSOCKET_WAITALL); if (m_type == PAGE_HTML) { sPageText = HTML(); } else if (m_type == PAGE_TEXT) { sPageText = TEXT(); m_size = sPageText.Length(); } else if (m_type == PAGE_CSS) { sPageText = CSS(); m_size = sPageText.Length(); } else if (m_type == PAGE_JSCRIPT) { sPageText = JSCRIPT(); m_size = sPageText.Length(); } sHTTP = wxT("HTTP/1.1 200 OK") + sHTMLEol; sHTTP += wxT("Server: ") + sServerID + sHTMLEol; sHTTP += wxT("Content-Type: ") + m_sMimeType + sHTMLEol; if (m_bEnableCaching) { sHTTP += wxT("Expires: ") + m_sCacheExpires + sHTMLEol; } else { sHTTP += wxT("Cache-Control: no-store, no-cache, must-revalidate, max-age=0") + sHTMLEol; } sHTTP += wxT("Content-Length: ") + wxString::Format(wxT("%ld"), m_size) + sHTMLEol; // sHTTP += wxT("Expires: ") + // wxDateTime::Now().Format( wxT("%a, %d %b %Y %T GMT") , wxDateTime::UTC ) + // sHTMLEol; #if 1 sHTTP += wxT("Connection: Close") + sHTMLEol; #else sHTTP += wxT("Connection: Keep-Alive") + sHTMLEol; #endif /* Add cookies to header */ if (!m_cookies.IsEmpty()) { D(debug("-- adding cookies to header!\n")); for (size_t x = 0 ; x < m_cookies.Count() ; x++) { sHTTP += m_cookies[x].header() + sHTMLEol; } } sHTTP += sHTMLEol; /* Write the HTTP header... */ pSocket->Write( sHTTP.c_str(), sHTTP.Length() ); #ifdef ENABLE_DEBUG_SEND fwrite(sHTTP.c_str(), sHTTP.Length(), 1, fOut); #endif if ((m_type == PAGE_HTML) || (m_type == PAGE_CSS) || (m_type == PAGE_TEXT) || (m_type == PAGE_JSCRIPT)) { pSocket->Write( sPageText.c_str(), m_size); } else { pSocket->Write( m_pBinaryData, m_size ); } bRes = true; pSocket->RestoreState(); #ifdef ENABLE_DEBUG_SEND fclose(fOut); #endif return bRes; }