#include <sstream>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <signal.h>
#include <stdio.h>
#include <ctime>
#include "main.h"
#include "buildpage.h"
#include "Client.h"
#include "Advertisement.h"
#include "Listing.h"
#include "Group.h"
using namespace std;
void buildpage (ostringstream &oss, int port, Listing::iterator start,
Listing::iterator finish) {
in_addr ip;
ip = getIP();
displayPageHeader(oss);
oss << "<TABLE width=100% cellpadding=3 cellspacing=3>" << endl;
oss << "<TR>" << endl;
oss << "<td width=50% class=advertisement>" << endl;
displaySortFind(oss, ip, port);
displayCategoryFilter(oss, ip, port);
oss << "<table width=100%>" << endl;
if (start == finish) {
oss << "<tr><td><b>No items</b></td></tr>" << endl;
}
else {
for (Listing::iterator it = start; it != finish; it++) {
oss << "<tr><td class=advertisement>" << endl;
displayAdvertisement (oss, *it, ip, port);
oss << "</td></tr>" << endl;
}
}
oss << "</table>";
oss << "<td class=controlpanel>" << endl;
displayControlPanel(oss, ip, port);
oss << "</td></tr>" << endl;
// Page Footer
oss << "</TABLE>" << endl;
oss << "</BODY>" << endl;
oss << "</HTML>" << endl;
}
void displayPageHeader(ostringstream &oss) {
// HTTP Content-type header
oss << "Content-type: text/html" << "\r\n\r\n";
// Start generating the page
oss << "<HTML>" << endl;
oss << "<HEAD>" << endl;
oss << "<TITLE>" << endl;
oss << "iCarnegie Auctions" << endl;
oss << "</TITLE>" << endl;
oss << "<link rel=\"stylesheet\" type=\"text/css\" href=\"/auction.css\" />" << endl;
oss << "</HEAD>" << endl;
oss << endl;
oss << "<BODY>" << endl;
oss << "<CENTER><H2>iCarnegie Auctions</H2></CENTER>" << endl;
}
void displayPostItem (ostringstream &oss, struct in_addr ip, int port) {
oss << "<B><CENTER>" << "Post an Ad" << "</CENTER></B><BR>" << endl;
oss << "<FORM ACTION=" << CLASSIFIED_CGI << " METHOD=POST>" << endl;
oss << "<table border=0 width=100%>" << endl;
oss << "<INPUT NAME=PORT TYPE=hidden VALUE=" << port << ">" << endl;
oss << "<INPUT NAME=IP TYPE=hidden VALUE=" << inet_ntoa(ip) << ">" << endl;
oss << "<INPUT NAME=email TYPE=hidden VALUE=" << active_user << ">" << endl;
oss << "<tr><td align=right>Title:<td>" << endl;
oss << "<INPUT NAME=title TYPE=text WIDTH=20 MAXWIDTH=20></tr>" << endl;
oss << "<tr><td align=right>Category:<td>" << endl;
oss << "<SELECT NAME=category>" << endl;
for (Categories::iterator it = categories.begin();
it != categories.end();
it++) {
oss << "<OPTION value=\"" << (*it)->getNumber() << "\">"
<< (*it)->getName() << "</OPTION>" << endl;
}
oss << "</SELECT></tr>" << endl;
oss << "<tr><td align=right>Length:<td><SELECT NAME=days>" << endl;
oss << "<OPTION value=3>3 days" << endl;
oss << "<OPTION SELECTED value=5>5 days" << endl;
oss << "<OPTION value=7>7 days" << endl;
oss << "</SELECT></tr>" << endl;
oss << "<tr><td align=right>Quantity:<td>" << endl;
oss << "<INPUT NAME=quantity VALUE=1 TYPE=text SIZE=5 MAXLENGTH=4></tr>" << endl;
oss << "<tr><td valign=top align=right>Description:<td>" << endl;
oss << "<TEXTAREA NAME=body COLS=20 ROWS=4>" << endl;
oss << "</TEXTAREA></tr>" << endl;
oss << "<tr><td align=center colspan=2><INPUT NAME=COMMAND VALUE=Add TYPE=submit></tr>" << endl;
oss << "</FORM></table>" << endl;
}
void displaySortFind (ostringstream &oss, struct in_addr ip, int port) {
oss << "<FORM ACTION=" << CLASSIFIED_CGI << " METHOD=POST>" << endl;
oss << "<INPUT NAME=PORT TYPE=hidden VALUE=" << port << ">" << endl;
oss << "<INPUT NAME=IP TYPE=hidden VALUE=" << inet_ntoa(ip) << ">" << endl;
oss << "<INPUT NAME=COMMAND VALUE=\"Sort\" TYPE=submit>" << endl;
oss << " " << endl;
oss << "<SELECT NAME=field>" << endl;
oss << "<OPTION value=\"close\">By close date" << endl;
oss << "<OPTION value=\"start\">By start date" << endl;
oss << "<OPTION value=\"email\">By seller email" << endl;
oss << "<OPTION value=\"quantity\">By quantity" << endl;
oss << "<OPTION value=\"highest\">By highest Bid" << endl;
oss << "<OPTION value=\"lowest\">By lowest Bid" << endl;
oss << "</SELECT>" << endl;
oss << " " << endl;
oss << "<INPUT NAME=COMMAND VALUE=\"Find\" TYPE=submit>" << endl;
oss << " " << endl;
oss << "<INPUT NAME=keyword TYPE=text SIZE=15 MAXLENGTH=20>" << endl;
oss << "</FORM>" << endl;
}
void displayCategoryAdd(ostringstream &oss, struct in_addr ip, int port) {
oss << "<B><CENTER>" << "Add Sub-Category" << "</CENTER></B><BR>" << endl;
oss << "<FORM ACTION=" << CLASSIFIED_CGI << " METHOD=POST>" << endl;
oss << "<INPUT NAME=PORT TYPE=hidden VALUE=" << port << ">" << endl;
oss << "<INPUT NAME=IP TYPE=hidden VALUE=" << inet_ntoa(ip) << ">" << endl;
oss << "<table width=100%><tr><td align=right>Parent category:<td>" << endl;
oss << "<SELECT NAME=parent>" << endl;
for (Categories::iterator it = categories.begin();
it != categories.end();
it++) {
oss << "<OPTION value=\"" << (*it)->getNumber() << "\">"
<< (*it)->getName() << "</OPTION>" << endl;
}
oss << "</SELECT></tr>" << endl;
oss << "<tr><td align=right>New category:<td>" << endl;
oss << "<INPUT NAME=newcategory TYPE=text></tr>" << endl;
oss << "<tr><td colspan=2 align=center>" << endl;
oss << "<INPUT NAME=COMMAND TYPE=submit VALUE=\"Add subcategory\">" << endl;
oss << "</tr></table></FORM>" << endl;
}
void displayCategoryFilter(ostringstream &oss, struct in_addr ip, int port) {
oss << "<FORM ACTION=" << CLASSIFIED_CGI << " METHOD=POST>" << endl;
oss << "<INPUT NAME=PORT TYPE=hidden VALUE=" << port << ">" << endl;
oss << "<INPUT NAME=IP TYPE=hidden VALUE=" << inet_ntoa(ip) << ">" << endl;
oss << "Category: " << endl;
oss << "<SELECT NAME=category>" << endl;
for (Categories::iterator it = categories.begin();
it != categories.end();
it++) {
oss << "<OPTION value=\"" << (*it)->getNumber() << "\">"
<< (*it)->getName() << "</OPTION>" << endl;
}
oss << "</SELECT>" << endl;
oss << "<INPUT NAME=COMMAND VALUE=\"Top Only\" TYPE=submit>" << endl;
oss << "<INPUT NAME=COMMAND VALUE=\"Recursive\" TYPE=submit>" << endl;
oss << "</FORM>" << endl;
}
void displayRegister (ostringstream &oss, struct in_addr ip, int port) {
oss << "<B><CENTER>Create Account</CENTER></B><BR>" << endl;
if (!create_verified) {
oss << "<FONT COLOR=red>Passwords didn't match.</FONT>" << endl;
create_verified = true;
}
oss << "<table width=100%>" << endl;
oss << "<FORM ACTION=" << CLASSIFIED_CGI << " METHOD=POST>" << endl;
oss << "<INPUT NAME=PORT TYPE=hidden VALUE=" << port << ">" << endl;
oss << "<INPUT NAME=IP TYPE=hidden VALUE=" << inet_ntoa(ip) << ">" << endl;
oss << "<tr><td align=right>Email:<td><INPUT NAME=email TYPE=text SIZE=20 MAXLENGTH=30></tr>"
<< endl;
oss << "<tr><td align=right>Last name:<td><INPUT NAME=lname TYPE=text SIZE=20 MAXLENGTH=20></tr>"
<< endl;
oss << "<tr><td align=right>First name:<td><INPUT NAME=fname TYPE=text SIZE=20 MAXLENGTH=20></tr>"
<< endl;
oss << "<tr><td align=right>Password:<td><INPUT NAME=passwd TYPE=password SIZE=20 MAXLENGTH=60></tr>" << endl;
oss << "<tr><td align=right>Password (again):<td><INPUT NAME=passwd2 TYPE=password SIZE=20 MAXLENGTH=60></tr>" << endl;
oss << "<tr><td align=center colspan=2><INPUT NAME=COMMAND VALUE=\"Create\" TYPE=submit></tr>" << endl;
oss << "</FORM>" << endl;
}
void displayControlPanel (ostringstream &oss, struct in_addr ip, int port) {
// If someone is logged in
if ("" != active_user) {
displayLogout(oss, ip, port);
oss << "<hr>" << endl;
displayPostItem(oss, ip, port);
o
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ssd5-exercise5.zip (57个子文件)
ssd5-exercise5
CopyByKeyword.cpp 391B
Advertisement.h 1KB
Listing.h 741B
main.opt 55KB
main.dsw 531B
Listing.cpp 4KB
bidhistory.cpp 2KB
SortBy.cpp 580B
Categories.h 561B
SortBy.h 276B
Client.h 1KB
Client.cpp 2KB
main.ncb 153KB
main.dsp 5KB
Date.h 963B
main.plg 1KB
Category.cpp 2KB
buildpage.cpp 11KB
processrequest.cpp 5KB
Group.cpp 451B
Group.h 523B
Date.cpp 3KB
Categories.cpp 511B
buildbidpage.h 295B
Bid.cpp 1KB
CopyByKeyword.h 351B
Category.h 1KB
main.cpp 3KB
main.h 397B
Makefile 835B
processrequest.h 227B
buildbidpage.cpp 2KB
Debug
Category.obj 237KB
buildbidpage.obj 174KB
Bid.obj 208KB
Client.obj 135KB
main.ilk 1.22MB
Listing.obj 191KB
Advertisement.obj 254KB
Categories.obj 29KB
CopyByKeyword.obj 45KB
processrequest.obj 265KB
vc60.idb 281KB
main.obj 281KB
main.exe 812KB
Group.obj 39KB
buildpage.obj 226KB
vc60.pdb 196KB
main.pdb 1.37MB
SortBy.obj 44KB
main.pch 3.45MB
bidhistory.obj 195KB
Date.obj 255KB
bidhistory.h 194B
Advertisement.cpp 4KB
buildpage.h 1KB
Bid.h 828B
共 57 条
- 1
资源评论
wofbhfbvd
- 粉丝: 10
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功