|
|
|
date: Wed, 24 Oct 2007 13:00:01 -0700,
group: microsoft.public.platformsdk.internet.server.isapi-dev
back
ISAPI for Keyword Replacement
Hi.
I am trying to write an ISAPI filter which would replace keywords with an
anchor.
So, my keywords are in a file called data.txt, and it has the following.
IIS http://www.intel.com
XP http://oracle.com
I have a test.htm file which contains the keywords. I have written the
following code, but the browser hangs, but gives me the following log.
***************************************************
HttpFilterProc(...)
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Cache-Control: no-cache
Date: Wed, 24 Oct 2007 19:45:12 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
ETag: "bcca5567cc15c81:c45"
Content-Length: 18460
Data: HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Cache-Control: no-cache
Date: Wed, 24 Oct 2007 19:45:12 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
ETag: "bcca5567cc15c81:c45"
Content-Length: 18460
IIS http://www.intel.com
***************************************************
Can anyone shine some light here and tell me what I am doing wrong or missing?
Here is my code.
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <httpfilt.h>
#include <string>
#include <map>
#include <fstream>
#include <iostream>
using namespace std;
typedef std::map<string, string> KeywordURL;
// global variables
KeywordURL Keywords;
BOOL LoadData()
{
ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
string sKeyword;
string sURL;
if (fData)
{
while (fData >> sKeyword >> sURL)
Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
}
fData.close();
return TRUE;
}
BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
{
// Specify the types and order of notification
// pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
| SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
SF_NOTIFY_SEND_RAW_DATA);
pVer->dwFilterVersion = HTTP_FILTER_REVISION;
strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
// Load keywords
LoadData();
return TRUE;
}
DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
NotificationType, VOID *pvData)
{
BYTE * pchIn = NULL;
BYTE * pchInTemp = NULL;
DWORD cbBuffer, cbtemp;
PHTTP_FILTER_RAW_DATA pRawData = NULL;
ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
fDebug << "HttpFilterProc(...)" << endl;
switch (NotificationType)
{
case SF_NOTIFY_SEND_RAW_DATA:
{
if (pfc->pFilterContext == (VOID *) 1)
{
// nothing happens with the code here
pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
pchIn = (BYTE *) pRawData->pvInData;
string sHeader((CHAR *) pchIn);
fDebug << "Header: " << sHeader << endl;
}
else
{
pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
pchIn = (BYTE *) pRawData->pvInData;
pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
string sInTemp((CHAR *) pchInTemp);
fDebug << sInTemp << endl;
fDebug << "Data: " << sInTemp << endl;
int iInData = pRawData->cbInData;
int iFound = 0;
basic_string <CHAR>::size_type Found = string::npos;
for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
Keywords.end(); iterator++)
{
fDebug << iterator->first << ' ' << iterator->second << endl;
//int iIndex = 0;
Found = sInTemp.find(iterator->first);
while (Found != string::npos)
{
if (iFound == 0)
iFound = 1;
string sAnchor("<a href=""" + iterator->second + """>" +
iterator->first + "</a>");
sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
iInData = iInData + iterator->second.length() + 15;
Found = sInTemp.find(iterator->first, Found);
}
}
if (iFound == 1)
{
pRawData->pvInData = (VOID *) sInTemp.c_str();
pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
pRawData->cbInData = (DWORD) iInData;
pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
pRawData->cbInBuffer, 0);
}
}
break;
}
default:
break;
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
date: Wed, 24 Oct 2007 13:00:01 -0700
author: thejackofall
Re: ISAPI for Keyword Replacement
On Oct 24, 1:00 pm, thejackofall
wrote:
> Hi.
>
> I am trying to write an ISAPI filter which would replace keywords with an
> anchor.
> So, my keywords are in a file called data.txt, and it has the following.
>
> IIShttp://www.intel.com
> XPhttp://oracle.com
>
> I have a test.htm file which contains the keywords. I have written the
> following code, but the browser hangs, but gives me the following log.
>
> ***************************************************
> HttpFilterProc(...)
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Cache-Control: no-cache
> Date: Wed, 24 Oct 2007 19:45:12 GMT
> Content-Type: text/html
> Accept-Ranges: bytes
> Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> ETag: "bcca5567cc15c81:c45"
> Content-Length: 18460
>
> Data: HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Cache-Control: no-cache
> Date: Wed, 24 Oct 2007 19:45:12 GMT
> Content-Type: text/html
> Accept-Ranges: bytes
> Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> ETag: "bcca5567cc15c81:c45"
> Content-Length: 18460
>
> IIShttp://www.intel.com
>
> ***************************************************
>
> Can anyone shine some light here and tell me what I am doing wrong or missing?
> Here is my code.
>
> #include <windows.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <httpfilt.h>
>
> #include <string>
> #include <map>
> #include <fstream>
> #include <iostream>
>
> using namespace std;
>
> typedef std::map<string, string> KeywordURL;
>
> // global variables
> KeywordURL Keywords;
>
> BOOL LoadData()
> {
> ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> string sKeyword;
> string sURL;
>
> if (fData)
> {
> while (fData >> sKeyword >> sURL)
> Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> }
>
> fData.close();
>
> return TRUE;
>
> }
>
> BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> {
> // Specify the types and order of notification
> // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> SF_NOTIFY_SEND_RAW_DATA);
> pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
>
> // Load keywords
> LoadData();
>
> return TRUE;
>
> }
>
> DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> NotificationType, VOID *pvData)
> {
> BYTE * pchIn = NULL;
> BYTE * pchInTemp = NULL;
> DWORD cbBuffer, cbtemp;
> PHTTP_FILTER_RAW_DATA pRawData = NULL;
>
> ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> fDebug << "HttpFilterProc(...)" << endl;
>
> switch (NotificationType)
> {
> case SF_NOTIFY_SEND_RAW_DATA:
> {
> if (pfc->pFilterContext == (VOID *) 1)
> {
> // nothing happens with the code here
> pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> pchIn = (BYTE *) pRawData->pvInData;
> string sHeader((CHAR *) pchIn);
> fDebug << "Header: " << sHeader << endl;
> }
> else
> {
> pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> pchIn = (BYTE *) pRawData->pvInData;
>
> pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
>
> string sInTemp((CHAR *) pchInTemp);
> fDebug << sInTemp << endl;
> fDebug << "Data: " << sInTemp << endl;
> int iInData = pRawData->cbInData;
> int iFound = 0;
> basic_string <CHAR>::size_type Found = string::npos;
>
> for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> Keywords.end(); iterator++)
> {
> fDebug << iterator->first << ' ' << iterator->second << endl;
> //int iIndex = 0;
> Found = sInTemp.find(iterator->first);
>
> while (Found != string::npos)
> {
> if (iFound == 0)
> iFound = 1;
>
> string sAnchor("<a href=""" + iterator->second + """>" +
> iterator->first + "</a>");
>
> sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
> iInData = iInData + iterator->second.length() + 15;
>
> Found = sInTemp.find(iterator->first, Found);
> }
> }
>
> if (iFound == 1)
> {
> pRawData->pvInData = (VOID *) sInTemp.c_str();
> pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
> pRawData->cbInData = (DWORD) iInData;
>
> pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
> pRawData->cbInBuffer, 0);
> }
> }
>
> break;
> }
>
> default:
> break;
> }
>
> return SF_STATUS_REQ_NEXT_NOTIFICATION;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -
This is fallout from a prior discussion at:
http://groups.google.com/group/microsoft.public.platformsdk.internet.server.isapi-dev/browse_thread/thread/91578c41c65fbd45#
I recommend anyone to abstain from answering at this time -- please
read the thread for why and judge for yourself whether to answer or
not.
Thank you.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
date: Wed, 24 Oct 2007 22:19:00 -0700
author: David Wang
Re: ISAPI for Keyword Replacement
Mr. Wang,
It's pretty pathetic that you spent your time, asking others not to answer
this post even after I advised you not to answer the posts because you are
not worthy technically or in character, unless you can provide concreate
details. I posted the code before, but you have only complained that I
didn't include the code in prior post. Your postings may sound decent
because some of us are in the dark, but any smart person would know that you
only talk high level without being specific.
It clearly demonstrates your unqualified ego. Why would you spend your own
time to do that? What others do is their business, and not yours.
And, if anyone is interested, I encourage him or her to take a look at the
prior discussion as Mr. Wang mentioned. You will notice that Mr.Wang really
only advises to "search the newsgroup", but does not provide a link regarding
the subject matter. He, also, says that he "gave step-by-step instructions
short of actual source code, but lots of examples". If you look at the link
he provided, where is a step-by-step instruction, or lots of examples?
I think Mr. Wang is trying to make a name for himself in this public
newsgroup to feel good at other people's time and annoyance.
Mr. Wang, I would appreciate it if you can abstain from trying to answer my
postings. Your answers aren't that helpful, although it may make you feel
good.
It's like a guy asking how to build a car. And, you say, "build the engine
and connect it to a transmission which would turn the wheels". Basically,
very high level, not where the rubber meets the road.
Thanks.
--
Be Cool!
"David Wang" wrote:
> On Oct 24, 1:00 pm, thejackofall
> wrote:
> > Hi.
> >
> > I am trying to write an ISAPI filter which would replace keywords with an
> > anchor.
> > So, my keywords are in a file called data.txt, and it has the following.
> >
> > IIShttp://www.intel.com
> > XPhttp://oracle.com
> >
> > I have a test.htm file which contains the keywords. I have written the
> > following code, but the browser hangs, but gives me the following log.
> >
> > ***************************************************
> > HttpFilterProc(...)
> > HTTP/1.1 200 OK
> > Server: Microsoft-IIS/5.1
> > Cache-Control: no-cache
> > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > Content-Type: text/html
> > Accept-Ranges: bytes
> > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > ETag: "bcca5567cc15c81:c45"
> > Content-Length: 18460
> >
> > Data: HTTP/1.1 200 OK
> > Server: Microsoft-IIS/5.1
> > Cache-Control: no-cache
> > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > Content-Type: text/html
> > Accept-Ranges: bytes
> > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > ETag: "bcca5567cc15c81:c45"
> > Content-Length: 18460
> >
> > IIShttp://www.intel.com
> >
> > ***************************************************
> >
> > Can anyone shine some light here and tell me what I am doing wrong or missing?
> > Here is my code.
> >
> > #include <windows.h>
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <httpfilt.h>
> >
> > #include <string>
> > #include <map>
> > #include <fstream>
> > #include <iostream>
> >
> > using namespace std;
> >
> > typedef std::map<string, string> KeywordURL;
> >
> > // global variables
> > KeywordURL Keywords;
> >
> > BOOL LoadData()
> > {
> > ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> > string sKeyword;
> > string sURL;
> >
> > if (fData)
> > {
> > while (fData >> sKeyword >> sURL)
> > Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> > }
> >
> > fData.close();
> >
> > return TRUE;
> >
> > }
> >
> > BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> > {
> > // Specify the types and order of notification
> > // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> > | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> > SF_NOTIFY_SEND_RAW_DATA);
> > pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> > strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
> >
> > // Load keywords
> > LoadData();
> >
> > return TRUE;
> >
> > }
> >
> > DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> > NotificationType, VOID *pvData)
> > {
> > BYTE * pchIn = NULL;
> > BYTE * pchInTemp = NULL;
> > DWORD cbBuffer, cbtemp;
> > PHTTP_FILTER_RAW_DATA pRawData = NULL;
> >
> > ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> > fDebug << "HttpFilterProc(...)" << endl;
> >
> > switch (NotificationType)
> > {
> > case SF_NOTIFY_SEND_RAW_DATA:
> > {
> > if (pfc->pFilterContext == (VOID *) 1)
> > {
> > // nothing happens with the code here
> > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > pchIn = (BYTE *) pRawData->pvInData;
> > string sHeader((CHAR *) pchIn);
> > fDebug << "Header: " << sHeader << endl;
> > }
> > else
> > {
> > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > pchIn = (BYTE *) pRawData->pvInData;
> >
> > pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> > memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> > memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
> >
> > string sInTemp((CHAR *) pchInTemp);
> > fDebug << sInTemp << endl;
> > fDebug << "Data: " << sInTemp << endl;
> > int iInData = pRawData->cbInData;
> > int iFound = 0;
> > basic_string <CHAR>::size_type Found = string::npos;
> >
> > for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> > Keywords.end(); iterator++)
> > {
> > fDebug << iterator->first << ' ' << iterator->second << endl;
> > //int iIndex = 0;
> > Found = sInTemp.find(iterator->first);
> >
> > while (Found != string::npos)
> > {
> > if (iFound == 0)
> > iFound = 1;
> >
> > string sAnchor("<a href=""" + iterator->second + """>" +
> > iterator->first + "</a>");
> >
> > sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
> > iInData = iInData + iterator->second.length() + 15;
> >
> > Found = sInTemp.find(iterator->first, Found);
> > }
> > }
> >
> > if (iFound == 1)
> > {
> > pRawData->pvInData = (VOID *) sInTemp.c_str();
> > pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
> > pRawData->cbInData = (DWORD) iInData;
> >
> > pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
> > pRawData->cbInBuffer, 0);
> > }
> > }
> >
> > break;
> > }
> >
> > default:
> > break;
> > }
> >
> > return SF_STATUS_REQ_NEXT_NOTIFICATION;
> >
> >
> >
> > }- Hide quoted text -
> >
> > - Show quoted text -
>
>
> This is fallout from a prior discussion at:
> http://groups.google.com/group/microsoft.public.platformsdk.internet.server.isapi-dev/browse_thread/thread/91578c41c65fbd45#
>
> I recommend anyone to abstain from answering at this time -- please
> read the thread for why and judge for yourself whether to answer or
> not.
>
> Thank you.
>
>
> //David
> http://w3-4u.blogspot.com
> http://blogs.msdn.com/David.Wang
> //
>
>
date: Thu, 25 Oct 2007 11:32:37 -0700
author: thejackofall
Re: ISAPI for Keyword Replacement
Hehe, you are the one making this personal, not me.
In the end, you are making it clear that you are the one slinging
stones for no good reason and ignoring olive branches, and trying very
hard to get people to do your work for you while you insult them.
You, on the other hand, have shown very little credentials and
information to back up your ego and attacks, and your continuing
antics simply expose yourself.
Good luck with your problem, and I hope you do find someone to answer
your question because clearly you are the one with all the problems,
not me.
I will even let you have the last word because your bruised ego needs
it.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
On Oct 25, 11:32 am, thejackofall
wrote:
> Mr. Wang,
>
> It's pretty pathetic that you spent your time, asking others not to answer
> this post even after I advised you not to answer the posts because you are
> not worthy technically or in character, unless you can provide concreate
> details. I posted the code before, but you have only complained that I
> didn't include the code in prior post. Your postings may sound decent
> because some of us are in the dark, but any smart person would know that you
> only talk high level without being specific.
>
> It clearly demonstrates your unqualified ego. Why would you spend your own
> time to do that? What others do is their business, and not yours.
>
> And, if anyone is interested, I encourage him or her to take a look at the
> prior discussion as Mr. Wang mentioned. You will notice that Mr.Wang really
> only advises to "search the newsgroup", but does not provide a link regarding
> the subject matter. He, also, says that he "gave step-by-step instructions
> short of actual source code, but lots of examples". If you look at the link
> he provided, where is a step-by-step instruction, or lots of examples?
>
> I think Mr. Wang is trying to make a name for himself in this public
> newsgroup to feel good at other people's time and annoyance.
>
> Mr. Wang, I would appreciate it if you can abstain from trying to answer my
> postings. Your answers aren't that helpful, although it may make you feel
> good.
> It's like a guy asking how to build a car. And, you say, "build the engine
> and connect it to a transmission which would turn the wheels". Basically,
> very high level, not where the rubber meets the road.
>
> Thanks.
>
> --
> Be Cool!
>
>
>
> "David Wang" wrote:
> > On Oct 24, 1:00 pm, thejackofall
> > wrote:
> > > Hi.
>
> > > I am trying to write an ISAPI filter which would replace keywords with an
> > > anchor.
> > > So, my keywords are in a file called data.txt, and it has the following.
>
> > > IIShttp://www.intel.com
> > > XPhttp://oracle.com
>
> > > I have a test.htm file which contains the keywords. I have written the
> > > following code, but the browser hangs, but gives me the following log.
>
> > > ***************************************************
> > > HttpFilterProc(...)
> > > HTTP/1.1 200 OK
> > > Server: Microsoft-IIS/5.1
> > > Cache-Control: no-cache
> > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > Content-Type: text/html
> > > Accept-Ranges: bytes
> > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > ETag: "bcca5567cc15c81:c45"
> > > Content-Length: 18460
>
> > > Data: HTTP/1.1 200 OK
> > > Server: Microsoft-IIS/5.1
> > > Cache-Control: no-cache
> > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > Content-Type: text/html
> > > Accept-Ranges: bytes
> > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > ETag: "bcca5567cc15c81:c45"
> > > Content-Length: 18460
>
> > > IIShttp://www.intel.com
>
> > > ***************************************************
>
> > > Can anyone shine some light here and tell me what I am doing wrong or missing?
> > > Here is my code.
>
> > > #include <windows.h>
> > > #include <stdio.h>
> > > #include <stdlib.h>
> > > #include <httpfilt.h>
>
> > > #include <string>
> > > #include <map>
> > > #include <fstream>
> > > #include <iostream>
>
> > > using namespace std;
>
> > > typedef std::map<string, string> KeywordURL;
>
> > > // global variables
> > > KeywordURL Keywords;
>
> > > BOOL LoadData()
> > > {
> > > ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> > > string sKeyword;
> > > string sURL;
>
> > > if (fData)
> > > {
> > > while (fData >> sKeyword >> sURL)
> > > Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> > > }
>
> > > fData.close();
>
> > > return TRUE;
>
> > > }
>
> > > BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> > > {
> > > // Specify the types and order of notification
> > > // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> > > | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> > > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> > > SF_NOTIFY_SEND_RAW_DATA);
> > > pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> > > strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
>
> > > // Load keywords
> > > LoadData();
>
> > > return TRUE;
>
> > > }
>
> > > DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> > > NotificationType, VOID *pvData)
> > > {
> > > BYTE * pchIn = NULL;
> > > BYTE * pchInTemp = NULL;
> > > DWORD cbBuffer, cbtemp;
> > > PHTTP_FILTER_RAW_DATA pRawData = NULL;
>
> > > ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> > > fDebug << "HttpFilterProc(...)" << endl;
>
> > > switch (NotificationType)
> > > {
> > > case SF_NOTIFY_SEND_RAW_DATA:
> > > {
> > > if (pfc->pFilterContext == (VOID *) 1)
> > > {
> > > // nothing happens with the code here
> > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > pchIn = (BYTE *) pRawData->pvInData;
> > > string sHeader((CHAR *) pchIn);
> > > fDebug << "Header: " << sHeader << endl;
> > > }
> > > else
> > > {
> > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > pchIn = (BYTE *) pRawData->pvInData;
>
> > > pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> > > memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> > > memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
>
> > > string sInTemp((CHAR *) pchInTemp);
> > > fDebug << sInTemp << endl;
> > > fDebug << "Data: " << sInTemp << endl;
> > > int iInData = pRawData->cbInData;
> > > int iFound = 0;
> > > basic_string <CHAR>::size_type Found = string::npos;
>
> > > for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> > > Keywords.end(); iterator++)
> > > {
> > > fDebug << iterator->first << ' ' << iterator->second << endl;
> > > //int iIndex = 0;
> > > Found = sInTemp.find(iterator->first);
>
> > > while (Found != string::npos)
> > > {
> > > if (iFound == 0)
> > > iFound = 1;
>
> > > string sAnchor("<a href=""" + iterator->second + """>" +
> > > iterator->first + "</a>");
>
> > > sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
> > > iInData = iInData + iterator->second.length() + 15;
>
> > > Found = sInTemp.find(iterator->first, Found);
> > > }
> > > }
>
> > > if (iFound == 1)
> > > {
> > > pRawData->pvInData = (VOID *) sInTemp.c_str();
> > > pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
> > > pRawData->cbInData = (DWORD) iInData;
>
> > > pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
> > > pRawData->cbInBuffer, 0);
> > > }
> > > }
>
> > > break;
> > > }
>
> > > default:
> > > break;
> > > }
>
> > > return SF_STATUS_REQ_NEXT_NOTIFICATION;
>
> > > }- Hide quoted text -
>
> > > - Show quoted text -
>
> > This is fallout from a prior discussion at:
> >http://groups.google.com/group/microsoft.public.platformsdk.internet....
>
> > I recommend anyone to abstain from answering at this time -- please
> > read the thread for why and judge for yourself whether to answer or
> > not.
>
> > Thank you.
>
> > //David
> >http://w3-4u.blogspot.com
> >http://blogs.msdn.com/David.Wang
> > //- Hide quoted text -
>
> - Show quoted text -
date: Fri, 26 Oct 2007 08:55:32 -0000
author: David Wang
Re: ISAPI for Keyword Replacement
Inline.
On Oct 24, 1:00 pm, thejackofall
wrote:
> Hi.
>
> I am trying to write an ISAPI filter which would replace keywords with an
> anchor.
> So, my keywords are in a file called data.txt, and it has the following.
>
> IIShttp://www.intel.com
> XPhttp://oracle.com
>
> I have a test.htm file which contains the keywords. I have written the
> following code, but the browser hangs, but gives me the following log.
>
> ***************************************************
> HttpFilterProc(...)
> HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Cache-Control: no-cache
> Date: Wed, 24 Oct 2007 19:45:12 GMT
> Content-Type: text/html
> Accept-Ranges: bytes
> Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> ETag: "bcca5567cc15c81:c45"
> Content-Length: 18460
>
> Data: HTTP/1.1 200 OK
> Server: Microsoft-IIS/5.1
> Cache-Control: no-cache
> Date: Wed, 24 Oct 2007 19:45:12 GMT
> Content-Type: text/html
> Accept-Ranges: bytes
> Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> ETag: "bcca5567cc15c81:c45"
> Content-Length: 18460
>
> IIShttp://www.intel.com
>
> ***************************************************
>
> Can anyone shine some light here and tell me what I am doing wrong or missing?
> Here is my code.
>
> #include <windows.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <httpfilt.h>
>
> #include <string>
> #include <map>
> #include <fstream>
> #include <iostream>
>
> using namespace std;
>
> typedef std::map<string, string> KeywordURL;
>
> // global variables
> KeywordURL Keywords;
>
> BOOL LoadData()
> {
> ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> string sKeyword;
> string sURL;
>
> if (fData)
> {
> while (fData >> sKeyword >> sURL)
> Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> }
>
> fData.close();
>
> return TRUE;
>
> }
>
> BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> {
> // Specify the types and order of notification
> // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> SF_NOTIFY_SEND_RAW_DATA);
> pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
This feature, AutoLink, looks to be implemented by Google already.
>
> // Load keywords
> LoadData();
>
> return TRUE;
>
> }
>
> DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> NotificationType, VOID *pvData)
> {
> BYTE * pchIn = NULL;
> BYTE * pchInTemp = NULL;
> DWORD cbBuffer, cbtemp;
> PHTTP_FILTER_RAW_DATA pRawData = NULL;
>
> ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> fDebug << "HttpFilterProc(...)" << endl;
>
> switch (NotificationType)
> {
> case SF_NOTIFY_SEND_RAW_DATA:
> {
I highly recommend using a debugger because no one writes perfect
code.
http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx
Do you know why nothing happens with this block of code? Because who
is setting pfc->pFilterContext to 1??? Not any code you show, that's
for sure. Besides, it only reads from HTTP_FILTER_RAW_DATA* , so no
client observable change results.
Hint: pfc->pFilterContext = NULL in your situation
Special Astute Reader Award: This code block makes an (incorrect)
assumption that the first SF_NOTIFY_SEND_RAW_DATA event contains all
HTTP response header data. While it is *frequently* the case for
IIS4/5/5.1, alas it is not guaranteed. Hey, we never documented the
behavior as such! It also won't work on IIS6 because if the response
is small enough, IIS6 sends the response headers and entity body at
once. So, this code block is basically not 100% correct, but good
enough for casual illustrative purposes.
> if (pfc->pFilterContext == (VOID *) 1)
> {
> // nothing happens with the code here
> pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> pchIn = (BYTE *) pRawData->pvInData;
> string sHeader((CHAR *) pchIn);
> fDebug << "Header: " << sHeader << endl;
> }
> else
> {
So many things wrong with the following code block. SOME(intentionally
not all) of the problems:
- Buffer overrun potential where the total difference of substituted
lengths is more than pRawData->cbInBuffer.
- Add/Subtract raw response data's length without correcting for HTTP
semantics. Read RFC2616 sections 4.3 and 4.4. Here's the link for the
lazy -- http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
- Be weary that your memory allocations (implicit or explicit) do not
fragment the heap. Common mistake
- what happens if the response data comes in >1 event and the search
string is split between two or more events
> pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> pchIn = (BYTE *) pRawData->pvInData;
>
> pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
>
> string sInTemp((CHAR *) pchInTemp);
> fDebug << sInTemp << endl;
> fDebug << "Data: " << sInTemp << endl;
> int iInData = pRawData->cbInData;
> int iFound = 0;
> basic_string <CHAR>::size_type Found = string::npos;
>
> for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> Keywords.end(); iterator++)
> {
> fDebug << iterator->first << ' ' << iterator->second << endl;
> //int iIndex = 0;
> Found = sInTemp.find(iterator->first);
>
> while (Found != string::npos)
> {
> if (iFound == 0)
> iFound = 1;
>
> string sAnchor("<a href=""" + iterator->second + """>" +
> iterator->first + "</a>");
>
> sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
> iInData = iInData + iterator->second.length() + 15;
>
> Found = sInTemp.find(iterator->first, Found);
> }
> }
>
Either WriteClient, or modify pRawData. Not both. And no, they are not
equivalent -- you will see the bug in this code with one of the
choices when you run it on IIS6. Exercise to the reader to determine
how to make either choice work.
> if (iFound == 1)
> {
> pRawData->pvInData = (VOID *) sInTemp.c_str();
> pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
> pRawData->cbInData = (DWORD) iInData;
>
> pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
> pRawData->cbInBuffer, 0);
> }
> }
>
> break;
> }
>
> default:
> break;
> }
>
> return SF_STATUS_REQ_NEXT_NOTIFICATION;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -
For those keeping score -- I rate this source code:
You have shown some command of the language, but your algorithms are
inefficient and use excessive classes. At least the code is indented
nicely. But this is not server-worthy code.
Through sheer luck or skillful copying, you have some details right.
Keep going.
I'm sure you'll complain that my details don't include answers, but
hey, that's your problem. In your case, I also have to leave something
as an exercise to the reader so that they can prove they actually
learned.
Good luck.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
date: Fri, 26 Oct 2007 09:59:19 -0000
author: David Wang
Re: ISAPI for Keyword Replacement
David Wang,
You are fired!
When you took your time to tell other people not to answer my post when I
indicated you are absolutely no help along with other peoples' negative
comment about your replies, you've made a personal attack. I've crushed your
ego to the ground.
You can defend yourself all you want, but by dealing with you, I learned
that you are only a hypocrite who is more interested in impressing yourself
than assisting people with technical questions. Deep inside, you know who
you are.
David Wang,
It's not how many posts you reply. It's the quality of the content of your
replies, with concrete details where the rubber meets the road because some
of us don't have the "credentials" you think you have. If anyone reads your
posts, he or she can tell the "credentials".
This is what you said. "Good luck with your problem, and I hope you do find
someone to answer your question because clearly you are the one with all the
problems, not me." It only demonstrates your bruised ego and your poor
character.
By the way, with a key piece of information from other people, I was able to
achieve my goal easily in a few hours. It wasn't your "50,000 feet high"
reply.
And, they had a far less ego than you, and they weren't arrogant as you.
They didn't have their nose up in the clouds with the little ISAPI stuff.
I am sorry I hurt your ego and feelings. It would take more than a "little
man" to bruise my ego. I know one when I see one.
You are a little man. You are fired!
--
Be Cool!
"David Wang" wrote:
> Hehe, you are the one making this personal, not me.
>
> In the end, you are making it clear that you are the one slinging
> stones for no good reason and ignoring olive branches, and trying very
> hard to get people to do your work for you while you insult them.
>
> You, on the other hand, have shown very little credentials and
> information to back up your ego and attacks, and your continuing
> antics simply expose yourself.
>
> Good luck with your problem, and I hope you do find someone to answer
> your question because clearly you are the one with all the problems,
> not me.
>
> I will even let you have the last word because your bruised ego needs
> it.
>
>
> //David
> http://w3-4u.blogspot.com
> http://blogs.msdn.com/David.Wang
> //
>
>
>
> On Oct 25, 11:32 am, thejackofall
> wrote:
> > Mr. Wang,
> >
> > It's pretty pathetic that you spent your time, asking others not to answer
> > this post even after I advised you not to answer the posts because you are
> > not worthy technically or in character, unless you can provide concreate
> > details. I posted the code before, but you have only complained that I
> > didn't include the code in prior post. Your postings may sound decent
> > because some of us are in the dark, but any smart person would know that you
> > only talk high level without being specific.
> >
> > It clearly demonstrates your unqualified ego. Why would you spend your own
> > time to do that? What others do is their business, and not yours.
> >
> > And, if anyone is interested, I encourage him or her to take a look at the
> > prior discussion as Mr. Wang mentioned. You will notice that Mr.Wang really
> > only advises to "search the newsgroup", but does not provide a link regarding
> > the subject matter. He, also, says that he "gave step-by-step instructions
> > short of actual source code, but lots of examples". If you look at the link
> > he provided, where is a step-by-step instruction, or lots of examples?
> >
> > I think Mr. Wang is trying to make a name for himself in this public
> > newsgroup to feel good at other people's time and annoyance.
> >
> > Mr. Wang, I would appreciate it if you can abstain from trying to answer my
> > postings. Your answers aren't that helpful, although it may make you feel
> > good.
> > It's like a guy asking how to build a car. And, you say, "build the engine
> > and connect it to a transmission which would turn the wheels". Basically,
> > very high level, not where the rubber meets the road.
> >
> > Thanks.
> >
> > --
> > Be Cool!
> >
> >
> >
> > "David Wang" wrote:
> > > On Oct 24, 1:00 pm, thejackofall
> > > wrote:
> > > > Hi.
> >
> > > > I am trying to write an ISAPI filter which would replace keywords with an
> > > > anchor.
> > > > So, my keywords are in a file called data.txt, and it has the following.
> >
> > > > IIShttp://www.intel.com
> > > > XPhttp://oracle.com
> >
> > > > I have a test.htm file which contains the keywords. I have written the
> > > > following code, but the browser hangs, but gives me the following log.
> >
> > > > ***************************************************
> > > > HttpFilterProc(...)
> > > > HTTP/1.1 200 OK
> > > > Server: Microsoft-IIS/5.1
> > > > Cache-Control: no-cache
> > > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > > Content-Type: text/html
> > > > Accept-Ranges: bytes
> > > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > > ETag: "bcca5567cc15c81:c45"
> > > > Content-Length: 18460
> >
> > > > Data: HTTP/1.1 200 OK
> > > > Server: Microsoft-IIS/5.1
> > > > Cache-Control: no-cache
> > > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > > Content-Type: text/html
> > > > Accept-Ranges: bytes
> > > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > > ETag: "bcca5567cc15c81:c45"
> > > > Content-Length: 18460
> >
> > > > IIShttp://www.intel.com
> >
> > > > ***************************************************
> >
> > > > Can anyone shine some light here and tell me what I am doing wrong or missing?
> > > > Here is my code.
> >
> > > > #include <windows.h>
> > > > #include <stdio.h>
> > > > #include <stdlib.h>
> > > > #include <httpfilt.h>
> >
> > > > #include <string>
> > > > #include <map>
> > > > #include <fstream>
> > > > #include <iostream>
> >
> > > > using namespace std;
> >
> > > > typedef std::map<string, string> KeywordURL;
> >
> > > > // global variables
> > > > KeywordURL Keywords;
> >
> > > > BOOL LoadData()
> > > > {
> > > > ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> > > > string sKeyword;
> > > > string sURL;
> >
> > > > if (fData)
> > > > {
> > > > while (fData >> sKeyword >> sURL)
> > > > Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> > > > }
> >
> > > > fData.close();
> >
> > > > return TRUE;
> >
> > > > }
> >
> > > > BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> > > > {
> > > > // Specify the types and order of notification
> > > > // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> > > > | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> > > > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> > > > SF_NOTIFY_SEND_RAW_DATA);
> > > > pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> > > > strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
> >
> > > > // Load keywords
> > > > LoadData();
> >
> > > > return TRUE;
> >
> > > > }
> >
> > > > DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> > > > NotificationType, VOID *pvData)
> > > > {
> > > > BYTE * pchIn = NULL;
> > > > BYTE * pchInTemp = NULL;
> > > > DWORD cbBuffer, cbtemp;
> > > > PHTTP_FILTER_RAW_DATA pRawData = NULL;
> >
> > > > ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> > > > fDebug << "HttpFilterProc(...)" << endl;
> >
> > > > switch (NotificationType)
> > > > {
> > > > case SF_NOTIFY_SEND_RAW_DATA:
> > > > {
> > > > if (pfc->pFilterContext == (VOID *) 1)
> > > > {
> > > > // nothing happens with the code here
> > > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > > pchIn = (BYTE *) pRawData->pvInData;
> > > > string sHeader((CHAR *) pchIn);
> > > > fDebug << "Header: " << sHeader << endl;
> > > > }
> > > > else
> > > > {
> > > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > > pchIn = (BYTE *) pRawData->pvInData;
> >
> > > > pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> > > > memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> > > > memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
> >
> > > > string sInTemp((CHAR *) pchInTemp);
> > > > fDebug << sInTemp << endl;
> > > > fDebug << "Data: " << sInTemp << endl;
> > > > int iInData = pRawData->cbInData;
> > > > int iFound = 0;
> > > > basic_string <CHAR>::size_type Found = string::npos;
> >
> > > > for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> > > > Keywords.end(); iterator++)
> > > > {
> > > > fDebug << iterator->first << ' ' << iterator->second << endl;
> > > > //int iIndex = 0;
> > > > Found = sInTemp.find(iterator->first);
> >
> > > > while (Found != string::npos)
> > > > {
> > > > if (iFound == 0)
> > > > iFound = 1;
> >
> > > > string sAnchor("<a href=""" + iterator->second + """>" +
> > > > iterator->first + "</a>");
> >
> > > > sInTemp = sInTemp.replace(Found, Found + sAnchor.length(), sAnchor);
> > > > iInData = iInData + iterator->second.length() + 15;
> >
> > > > Found = sInTemp.find(iterator->first, Found);
> > > > }
> > > > }
> >
> > > > if (iFound == 1)
> > > > {
> > > > pRawData->pvInData = (VOID *) sInTemp.c_str();
> > > > pRawData->cbInBuffer = (DWORD) strlen(sInTemp.c_str());
> > > > pRawData->cbInData = (DWORD) iInData;
> >
> > > > pfc->WriteClient(pfc, pRawData->pvInData, (LPDWORD)
> > > > pRawData->cbInBuffer, 0);
> > > > }
> > > > }
> >
> > > > break;
> > > > }
> >
> > > > default:
> > > > break;
> > > > }
> >
> > > > return SF_STATUS_REQ_NEXT_NOTIFICATION;
> >
> > > > }- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > This is fallout from a prior discussion at:
> > >http://groups.google.com/group/microsoft.public.platformsdk.internet....
> >
> > > I recommend anyone to abstain from answering at this time -- please
> > > read the thread for why and judge for yourself whether to answer or
> > > not.
> >
> > > Thank you.
> >
> > > //David
> > >http://w3-4u.blogspot.com
> > >http://blogs.msdn.com/David.Wang
> > > //- Hide quoted text -
> >
> > - Show quoted text -
>
>
>
date: Fri, 26 Oct 2007 17:39:01 -0700
author: thejackofall
Re: ISAPI for Keyword Replacement
Sorry, I wasn't aware of any hiring here.
I'm glad you got your issue resolved and we can all move forward.
I don't need to take your word for it; you don't need to take my word
for it. But please take a look at many other people's reactions
towards your posts and profiles.
I think it is clear that people conclude that you are the little man
with the bruised ego. I feel no malice towards you, only pity, that
you cannot seem to see beyond your own anger, and I failed to help you
forward. But, such is life -- you go your way, I go mine.
Good luck.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
On Oct 26, 5:39 pm, thejackofall
wrote:
> David Wang,
>
> You are fired!
>
> When you took your time to tell other people not to answer my post when I
> indicated you are absolutely no help along with other peoples' negative
> comment about your replies, you've made a personal attack. I've crushed your
> ego to the ground.
>
> You can defend yourself all you want, but by dealing with you, I learned
> that you are only a hypocrite who is more interested in impressing yourself
> than assisting people with technical questions. Deep inside, you know who
> you are.
>
> David Wang,
>
> It's not how many posts you reply. It's the quality of the content of your
> replies, with concrete details where the rubber meets the road because some
> of us don't have the "credentials" you think you have. If anyone reads your
> posts, he or she can tell the "credentials".
>
> This is what you said. "Good luck with your problem, and I hope you do find
> someone to answer your question because clearly you are the one with all the
> problems, not me." It only demonstrates your bruised ego and your poor
> character.
>
> By the way, with a key piece of information from other people, I was able to
> achieve my goal easily in a few hours. It wasn't your "50,000 feet high"
> reply.
> And, they had a far less ego than you, and they weren't arrogant as you.
> They didn't have their nose up in the clouds with the little ISAPI stuff.
>
> I am sorry I hurt your ego and feelings. It would take more than a "little
> man" to bruise my ego. I know one when I see one.
>
> You are a little man. You are fired!
>
> --
> Be Cool!
>
>
>
> "David Wang" wrote:
> > Hehe, you are the one making this personal, not me.
>
> > In the end, you are making it clear that you are the one slinging
> > stones for no good reason and ignoring olive branches, and trying very
> > hard to get people to do your work for you while you insult them.
>
> > You, on the other hand, have shown very little credentials and
> > information to back up your ego and attacks, and your continuing
> > antics simply expose yourself.
>
> > Good luck with your problem, and I hope you do find someone to answer
> > your question because clearly you are the one with all the problems,
> > not me.
>
> > I will even let you have the last word because your bruised ego needs
> > it.
>
> > //David
> >http://w3-4u.blogspot.com
> >http://blogs.msdn.com/David.Wang
> > //
>
> > On Oct 25, 11:32 am, thejackofall
> > wrote:
> > > Mr. Wang,
>
> > > It's pretty pathetic that you spent your time, asking others not to answer
> > > this post even after I advised you not to answer the posts because you are
> > > not worthy technically or in character, unless you can provide concreate
> > > details. I posted the code before, but you have only complained that I
> > > didn't include the code in prior post. Your postings may sound decent
> > > because some of us are in the dark, but any smart person would know that you
> > > only talk high level without being specific.
>
> > > It clearly demonstrates your unqualified ego. Why would you spend your own
> > > time to do that? What others do is their business, and not yours.
>
> > > And, if anyone is interested, I encourage him or her to take a look at the
> > > prior discussion as Mr. Wang mentioned. You will notice that Mr.Wang really
> > > only advises to "search the newsgroup", but does not provide a link regarding
> > > the subject matter. He, also, says that he "gave step-by-step instructions
> > > short of actual source code, but lots of examples". If you look at the link
> > > he provided, where is a step-by-step instruction, or lots of examples?
>
> > > I think Mr. Wang is trying to make a name for himself in this public
> > > newsgroup to feel good at other people's time and annoyance.
>
> > > Mr. Wang, I would appreciate it if you can abstain from trying to answer my
> > > postings. Your answers aren't that helpful, although it may make you feel
> > > good.
> > > It's like a guy asking how to build a car. And, you say, "build the engine
> > > and connect it to a transmission which would turn the wheels". Basically,
> > > very high level, not where the rubber meets the road.
>
> > > Thanks.
>
> > > --
> > > Be Cool!
>
> > > "David Wang" wrote:
> > > > On Oct 24, 1:00 pm, thejackofall
> > > > wrote:
> > > > > Hi.
>
> > > > > I am trying to write an ISAPI filter which would replace keywords with an
> > > > > anchor.
> > > > > So, my keywords are in a file called data.txt, and it has the following.
>
> > > > > IIShttp://www.intel.com
> > > > > XPhttp://oracle.com
>
> > > > > I have a test.htm file which contains the keywords. I have written the
> > > > > following code, but the browser hangs, but gives me the following log.
>
> > > > > ***************************************************
> > > > > HttpFilterProc(...)
> > > > > HTTP/1.1 200 OK
> > > > > Server: Microsoft-IIS/5.1
> > > > > Cache-Control: no-cache
> > > > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > > > Content-Type: text/html
> > > > > Accept-Ranges: bytes
> > > > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > > > ETag: "bcca5567cc15c81:c45"
> > > > > Content-Length: 18460
>
> > > > > Data: HTTP/1.1 200 OK
> > > > > Server: Microsoft-IIS/5.1
> > > > > Cache-Control: no-cache
> > > > > Date: Wed, 24 Oct 2007 19:45:12 GMT
> > > > > Content-Type: text/html
> > > > > Accept-Ranges: bytes
> > > > > Last-Modified: Tue, 23 Oct 2007 23:28:23 GMT
> > > > > ETag: "bcca5567cc15c81:c45"
> > > > > Content-Length: 18460
>
> > > > > IIShttp://www.intel.com
>
> > > > > ***************************************************
>
> > > > > Can anyone shine some light here and tell me what I am doing wrong or missing?
> > > > > Here is my code.
>
> > > > > #include <windows.h>
> > > > > #include <stdio.h>
> > > > > #include <stdlib.h>
> > > > > #include <httpfilt.h>
>
> > > > > #include <string>
> > > > > #include <map>
> > > > > #include <fstream>
> > > > > #include <iostream>
>
> > > > > using namespace std;
>
> > > > > typedef std::map<string, string> KeywordURL;
>
> > > > > // global variables
> > > > > KeywordURL Keywords;
>
> > > > > BOOL LoadData()
> > > > > {
> > > > > ifstream fData("c:\\inetpub\\scripts\\data.txt", ios::in);
> > > > > string sKeyword;
> > > > > string sURL;
>
> > > > > if (fData)
> > > > > {
> > > > > while (fData >> sKeyword >> sURL)
> > > > > Keywords.insert(KeywordURL::value_type(sKeyword, sURL));
> > > > > }
>
> > > > > fData.close();
>
> > > > > return TRUE;
>
> > > > > }
>
> > > > > BOOL WINAPI __stdcall GetFilterVersion(HTTP_FILTER_VERSION *pVer)
> > > > > {
> > > > > // Specify the types and order of notification
> > > > > // pVer->dwFlags = (SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_URL_MAP
> > > > > | SF_NOTIFY_SEND_RAW_DATA | SF_NOTIFY_ORDER_DEFAULT);
> > > > > pVer->dwFlags = (SF_NOTIFY_ORDER_MEDIUM | SF_NOTIFY_NONSECURE_PORT |
> > > > > SF_NOTIFY_SEND_RAW_DATA);
> > > > > pVer->dwFilterVersion = HTTP_FILTER_REVISION;
> > > > > strcpy(pVer->lpszFilterDesc, "AutoLink, Version 1.0");
>
> > > > > // Load keywords
> > > > > LoadData();
>
> > > > > return TRUE;
>
> > > > > }
>
> > > > > DWORD WINAPI __stdcall HttpFilterProc(HTTP_FILTER_CONTEXT *pfc, DWORD
> > > > > NotificationType, VOID *pvData)
> > > > > {
> > > > > BYTE * pchIn = NULL;
> > > > > BYTE * pchInTemp = NULL;
> > > > > DWORD cbBuffer, cbtemp;
> > > > > PHTTP_FILTER_RAW_DATA pRawData = NULL;
>
> > > > > ofstream fDebug("c:\\inetpub\\scripts\\debug.txt", ios::out | ios::app);
> > > > > fDebug << "HttpFilterProc(...)" << endl;
>
> > > > > switch (NotificationType)
> > > > > {
> > > > > case SF_NOTIFY_SEND_RAW_DATA:
> > > > > {
> > > > > if (pfc->pFilterContext == (VOID *) 1)
> > > > > {
> > > > > // nothing happens with the code here
> > > > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > > > pchIn = (BYTE *) pRawData->pvInData;
> > > > > string sHeader((CHAR *) pchIn);
> > > > > fDebug << "Header: " << sHeader << endl;
> > > > > }
> > > > > else
> > > > > {
> > > > > pRawData = (PHTTP_FILTER_RAW_DATA) pvData;
> > > > > pchIn = (BYTE *) pRawData->pvInData;
>
> > > > > pchInTemp = (BYTE *) pfc->AllocMem(pfc, pRawData->cbInBuffer * 2, NULL);
> > > > > memset(pchInTemp, '\0', pRawData->cbInBuffer * 2);
> > > > > memcpy(pchInTemp, (BYTE *) pchIn, pRawData->cbInData);
>
> > > > > string sInTemp((CHAR *) pchInTemp> > > > > fDebug << sInTemp << endl;
> > > > > fDebug << "Data: " << sInTemp << endl;
> > > > > int iInData = pRawData->cbInData;
> > > > > int iFound = 0;
> > > > > basic_string <CHAR>::size_type Found = string::npos;
>
> > > > > for (KeywordURL::const_iterator iterator = Keywords.begin(); iterator !=
> > > > > Keywords.end(); iterator)
> > > > > {
> > > > > fDebug << iterator->first << ' ' << iterator->second << endl;
> > > > > //int iIndex = 0;
> > > > > Found = sInTemp.find(iterator->first);
>
> > > > > while (Found != string::npos)
> > > > > {
> > > > > if (iFound == 0)
>
> ...
>
> read more ยป- Hide quoted text -
>
> - Show quoted text -
date: Sat, 27 Oct 2007 17:46:13 -0700
author: David Wang
|
|