Am I missing something here ...? Instr Function 
Author Message
 Am I missing something here ...? Instr Function

I'm trying to verify that a particular script was called from a valid
location and not anywhere else (to add a level of protection from kids
running their own calls against the script).

Here's my site structure (with names changed appropriately):

ROOT
Root/Folder1/Processor.asp
Root/Folder2/Folder3/game.asp
Root/Folder2/Folder3/Folder4/game.swf

Game.swf is embedded in game.asp
Game.swf calls Processor.asp to set and retrieve high scores.

I *thought* that the http_referer would therefore be
http://www.*-*-*.com/

If it's not that, then it would be
http://www.*-*-*.com/

The problem is that this chunk of code fails everytime ... and it's
confusing me. The whole .swf has thrown me into a loop.
------------------------------
 strReferer = Request.ServerVariables("HTTP_REFERER")

 If Instr(1, strReferer, http://www.*-*-*.com/ , 1) <>
1 Then
  intScore = -1
 End If
------------------------------

Is the logic behind this wrong? I figured that the strReferer will have the
entire URL and all I'm doing is checking to see if the first part of it
matches the correct site/folder structure.

I have validated the path by placing a test.asp in folder 4 which called
processor.asp and had it response.write the referer ... everything looked
normal.

I've also taken the same code and put it in another page (no .swf) and it
seems to work okay.

So, what am I overlooking here? Probably something very straight forward. At
the moment, the above code NEVER equals one and is there rejecting all
scores.



Mon, 13 Sep 2004 20:48:49 GMT  
 Am I missing something here ...? Instr Function
If you write out the HTTP_REFERER I guess you get nothing and that means you
dont have any HTTP_REFERER. To get one you need to submit a form or have
your user click a link on the refering page. As far as I know the
response.redirect doesnt qualfy as a referer.

Anyone please respond if I am wrong!

//Micke

Quote:
> I'm trying to verify that a particular script was called from a valid
> location and not anywhere else (to add a level of protection from kids
> running their own calls against the script).

> Here's my site structure (with names changed appropriately):

> ROOT
> Root/Folder1/Processor.asp
> Root/Folder2/Folder3/game.asp
> Root/Folder2/Folder3/Folder4/game.swf

> Game.swf is embedded in game.asp
> Game.swf calls Processor.asp to set and retrieve high scores.

> I *thought* that the http_referer would therefore be
> http://www.sitename/folder1/folder2/folder3/game.swf

> If it's not that, then it would be
> http://www.sitename/folder1/folder2/folder3/game.asp - right?

> The problem is that this chunk of code fails everytime ... and it's
> confusing me. The whole .swf has thrown me into a loop.
> ------------------------------
>  strReferer = Request.ServerVariables("HTTP_REFERER")

>  If Instr(1, strReferer, http://www.sitename/folder1/folder2/folder3/, 1)
<>
> 1 Then
>   intScore = -1
>  End If
> ------------------------------

> Is the logic behind this wrong? I figured that the strReferer will have
the
> entire URL and all I'm doing is checking to see if the first part of it
> matches the correct site/folder structure.

> I have validated the path by placing a test.asp in folder 4 which called
> processor.asp and had it response.write the referer ... everything looked
> normal.

> I've also taken the same code and put it in another page (no .swf) and it
> seems to work okay.

> So, what am I overlooking here? Probably something very straight forward.
At
> the moment, the above code NEVER equals one and is there rejecting all
> scores.



Tue, 14 Sep 2004 01:16:06 GMT  
 Am I missing something here ...? Instr Function
Well, you know ... you're probably right for all the wrong reasons. It's
coming from a flash file, so - yes - that's not a link or form submission.

BUM FLUFF!

Now that's going to prove interesting trying to figure out a way around
that. Any suggestions?


Quote:
> If you write out the HTTP_REFERER I guess you get nothing and that means
you
> dont have any HTTP_REFERER. To get one you need to submit a form or have
> your user click a link on the refering page. As far as I know the
> response.redirect doesnt qualfy as a referer.

> Anyone please respond if I am wrong!

> //Micke

> > I'm trying to verify that a particular script was called from a valid
> > location and not anywhere else (to add a level of protection from kids
> > running their own calls against the script).

> > Here's my site structure (with names changed appropriately):

> > ROOT
> > Root/Folder1/Processor.asp
> > Root/Folder2/Folder3/game.asp
> > Root/Folder2/Folder3/Folder4/game.swf

> > Game.swf is embedded in game.asp
> > Game.swf calls Processor.asp to set and retrieve high scores.

> > I *thought* that the http_referer would therefore be
> > http://www.sitename/folder1/folder2/folder3/game.swf

> > If it's not that, then it would be
> > http://www.sitename/folder1/folder2/folder3/game.asp - right?

> > The problem is that this chunk of code fails everytime ... and it's
> > confusing me. The whole .swf has thrown me into a loop.
> > ------------------------------
> >  strReferer = Request.ServerVariables("HTTP_REFERER")

> >  If Instr(1, strReferer, http://www.sitename/folder1/folder2/folder3/,
1)
> <>
> > 1 Then
> >   intScore = -1
> >  End If
> > ------------------------------

> > Is the logic behind this wrong? I figured that the strReferer will have
> the
> > entire URL and all I'm doing is checking to see if the first part of it
> > matches the correct site/folder structure.

> > I have validated the path by placing a test.asp in folder 4 which called
> > processor.asp and had it response.write the referer ... everything
looked
> > normal.

> > I've also taken the same code and put it in another page (no .swf) and
it
> > seems to work okay.

> > So, what am I overlooking here? Probably something very straight
forward.
> At
> > the moment, the above code NEVER equals one and is there rejecting all
> > scores.



Tue, 14 Sep 2004 02:58:34 GMT  
 Am I missing something here ...? Instr Function
Cant you put a link/form-submission in the end of the game?
//Micke



Quote:
> Well, you know ... you're probably right for all the wrong reasons. It's
> coming from a flash file, so - yes - that's not a link or form submission.

> BUM FLUFF!

> Now that's going to prove interesting trying to figure out a way around
> that. Any suggestions?



> > If you write out the HTTP_REFERER I guess you get nothing and that means
> you
> > dont have any HTTP_REFERER. To get one you need to submit a form or
have
> > your user click a link on the refering page. As far as I know the
> > response.redirect doesnt qualfy as a referer.

> > Anyone please respond if I am wrong!

> > //Micke

> > > I'm trying to verify that a particular script was called from a valid
> > > location and not anywhere else (to add a level of protection from kids
> > > running their own calls against the script).

> > > Here's my site structure (with names changed appropriately):

> > > ROOT
> > > Root/Folder1/Processor.asp
> > > Root/Folder2/Folder3/game.asp
> > > Root/Folder2/Folder3/Folder4/game.swf

> > > Game.swf is embedded in game.asp
> > > Game.swf calls Processor.asp to set and retrieve high scores.

> > > I *thought* that the http_referer would therefore be
> > > http://www.sitename/folder1/folder2/folder3/game.swf

> > > If it's not that, then it would be
> > > http://www.sitename/folder1/folder2/folder3/game.asp - right?

> > > The problem is that this chunk of code fails everytime ... and it's
> > > confusing me. The whole .swf has thrown me into a loop.
> > > ------------------------------
> > >  strReferer = Request.ServerVariables("HTTP_REFERER")

> > >  If Instr(1, strReferer, http://www.sitename/folder1/folder2/folder3/,
> 1)
> > <>
> > > 1 Then
> > >   intScore = -1
> > >  End If
> > > ------------------------------

> > > Is the logic behind this wrong? I figured that the strReferer will
have
> > the
> > > entire URL and all I'm doing is checking to see if the first part of
it
> > > matches the correct site/folder structure.

> > > I have validated the path by placing a test.asp in folder 4 which
called
> > > processor.asp and had it response.write the referer ... everything
> looked
> > > normal.

> > > I've also taken the same code and put it in another page (no .swf) and
> it
> > > seems to work okay.

> > > So, what am I overlooking here? Probably something very straight
> forward.
> > At
> > > the moment, the above code NEVER equals one and is there rejecting all
> > > scores.



Tue, 14 Sep 2004 19:25:34 GMT  
 Am I missing something here ...? Instr Function
I'm not sure how Flash works ... but it uses a built in function to make the
processing .asp call ... there's no human interaction and it doesn't worth
through a form. I guess I'll have to try and figure out something clever
with the parameter string that it passes, an encrypted password or
something.

~ Jen


Quote:
> Cant you put a link/form-submission in the end of the game?
> //Micke



> > Well, you know ... you're probably right for all the wrong reasons. It's
> > coming from a flash file, so - yes - that's not a link or form
submission.

> > BUM FLUFF!

> > Now that's going to prove interesting trying to figure out a way around
> > that. Any suggestions?



> > > If you write out the HTTP_REFERER I guess you get nothing and that
means
> > you
> > > dont have any HTTP_REFERER. To get one you need to submit a form or
> have
> > > your user click a link on the refering page. As far as I know the
> > > response.redirect doesnt qualfy as a referer.

> > > Anyone please respond if I am wrong!

> > > //Micke

> > > > I'm trying to verify that a particular script was called from a
valid
> > > > location and not anywhere else (to add a level of protection from
kids
> > > > running their own calls against the script).

> > > > Here's my site structure (with names changed appropriately):

> > > > ROOT
> > > > Root/Folder1/Processor.asp
> > > > Root/Folder2/Folder3/game.asp
> > > > Root/Folder2/Folder3/Folder4/game.swf

> > > > Game.swf is embedded in game.asp
> > > > Game.swf calls Processor.asp to set and retrieve high scores.

> > > > I *thought* that the http_referer would therefore be
> > > > http://www.sitename/folder1/folder2/folder3/game.swf

> > > > If it's not that, then it would be
> > > > http://www.sitename/folder1/folder2/folder3/game.asp - right?

> > > > The problem is that this chunk of code fails everytime ... and it's
> > > > confusing me. The whole .swf has thrown me into a loop.
> > > > ------------------------------
> > > >  strReferer = Request.ServerVariables("HTTP_REFERER")

> > > >  If Instr(1, strReferer,

http://www.sitename/folder1/folder2/folder3/,

- Show quoted text -

Quote:
> > 1)
> > > <>
> > > > 1 Then
> > > >   intScore = -1
> > > >  End If
> > > > ------------------------------

> > > > Is the logic behind this wrong? I figured that the strReferer will
> have
> > > the
> > > > entire URL and all I'm doing is checking to see if the first part of
> it
> > > > matches the correct site/folder structure.

> > > > I have validated the path by placing a test.asp in folder 4 which
> called
> > > > processor.asp and had it response.write the referer ... everything
> > looked
> > > > normal.

> > > > I've also taken the same code and put it in another page (no .swf)
and
> > it
> > > > seems to work okay.

> > > > So, what am I overlooking here? Probably something very straight
> > forward.
> > > At
> > > > the moment, the above code NEVER equals one and is there rejecting
all
> > > > scores.



Tue, 14 Sep 2004 19:58:15 GMT  
 Am I missing something here ...? Instr Function
I believe the problem is that your parameter needs to be enclosed in quotes!

In the future, you can narrow down the source of error by inserting a test
line like:
strReferer = "http://www.sitename/folder1/folder2/folder3/"

before the instr function. Then you will quickly realize that it has nothing
to do with HTTP_REFERER and rather something with your instr syntax.

Quote:
> The problem is that this chunk of code fails everytime ... and it's
> confusing me. The whole .swf has thrown me into a loop.
> ------------------------------
>  strReferer = Request.ServerVariables("HTTP_REFERER")

>  If Instr(1, strReferer, http://www.sitename/folder1/folder2/folder3/, 1)
<>
> 1 Then
>   intScore = -1
>  End If
> ------------------------------



Sat, 18 Sep 2004 05:52:38 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. RegEx: Am I missing something?

2. am I missing something ?

3. WSH 5.6 argument definitions - am I missing something?

4. Pop-up windows - Am I missing something?

5. Access Runtime - Am I Missing Something?

6. AM I missing something - Sum and Cumulative Sum

7. VBA For Dummies --- Am I missing something here?

8. Am I missing something?

9. Am I missing something?

10. Am I missing something incredibly easy?

11. Am I missing something in the DHTML Editor?

12. Undraggable controls: Am I Missing something???

 

 
Powered by phpBB® Forum Software