Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Dimming a variable from a url.....
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobby131313
Senior Member

USA
1163 Posts

Posted - 24 February 2008 :  17:43:35  Show Profile  Visit bobby131313's Homepage
Is it possible?

I'm working on a site to display auctions. I have some variables that I set for example the seller ID...

SELLER="JoeBlow"

Now the directory name that the files reside in is /JoeBlow/.

Can I grab that on the fly somehow so I can eliminate this manual step of assigning this variable to the prep for a new gallery?

Thanks in advance!

Switch the order of your title tags

phy1729
Average Member

USA
589 Posts

Posted - 24 February 2008 :  17:56:50  Show Profile
Like
SELLER = Request.QueryString("SELLER")
? If this is going to the file system make sure to strip out slashes.
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 24 February 2008 :  20:58:18  Show Profile  Visit bobby131313's Homepage
Well, if the url is...

http://forum.snitz.com/forum/topic.asp

I want the variable to be set as forum. The deepest directory in the url, so ....

http://forum.snitz.com/forum/board/topic.asp

would be set to board

Possible?

Switch the order of your title tags
Go to Top of Page

phy1729
Average Member

USA
589 Posts

Posted - 24 February 2008 :  21:20:05  Show Profile
Maybe with Regex. [.]*/([^/]+)/[^/]+ I think. There is probably a better way.

Edited by - phy1729 on 24 February 2008 21:20:54
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 24 February 2008 :  21:28:26  Show Profile  Visit bobby131313's Homepage
This code, that shaggy helped me with a while ago...

dim SELLER :SELLER = replace(mid(request.servervariables("script_name"),instrrev(request.servervariables("script_name"),"/")+1),".asp","")

returns the file name only, without the extension.

I have a page set up that shows the variable on it, I keep playing with it, uploading, and looking to see what I get. But I'll be dammed if I can get it right.

Switch the order of your title tags
Go to Top of Page

cgcarter1
Starting Member

14 Posts

Posted - 01 April 2008 :  13:02:57  Show Profile
If you break the code out... you are (I think) going the wrong way with the mid()....
The instrrev gives you the first occurance of a string within another (by position) and starts at the end of the string.

So for instance you have filepath = C:\Downloads\forums\topic.asp
your instrrev variable is set to instrrev(filepath,"\", ".asp")
Well going backwards the first occurance of \ is right before the t in topic.asp...
Then your mid() is set to find the middle of \ right before the t in topic to .asp...
Which will give you the filename...

Very Very basic.. you need something like...
pathposition = instrrev(request.servervariables("script_name"),"/") - 1
path = left(request.servervariables("script_name"),pathposition)
directoryposition = instrrev(path,"/")
directory = right(path,directoryposition)

directory would then be your lowest directory on the tree.

OR - I could be completely wrong...
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 01 April 2008 :  13:16:29  Show Profile
Here you go:
strScript=request.servervariables("script_name")
strScript=lcase(mid(strScript,instrrev(strScript,"/")+1))
strDirectory=request.servervariables("script_name")
strDirectory=left(strDirectory,len(strDirectory)-len(strScript)-1)
strDirectory=lcase(mid(strDirectory,instrrev(strDirectory,"/")+1))

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

cgcarter1
Starting Member

14 Posts

Posted - 01 April 2008 :  14:37:58  Show Profile
I just reread what I wrote... and I meant very very basic as in a very very rough draft of code...
Not that the code was easy...
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 10 April 2008 :  04:43:20  Show Profile
Another way to do it would be to create an array from the Script_Name variable, like so:

arrDirectories=split(request.servervariables("script_name"),"/")

That would give you the following array:

"","Directory","SubDirectory1", ... ,"SubDirectoryN","file.ext"

So, from a URI like http://domain.tld/seller/joeblow/gallery.asp, your array would be:

"","seller","joeblow","gallery.asp"


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

bobby131313
Senior Member

USA
1163 Posts

Posted - 10 April 2008 :  13:14:50  Show Profile  Visit bobby131313's Homepage
Thanks everyone, I won't get to play with this again for a little bit. One of my affiliate partners just changed thier link structure and I have until the end of the month to change and test probably close to 100K links or a good paycheck stops.

I am grateful, and I'll try this as soon as I can. Thanks!

Switch the order of your title tags
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 11 April 2008 :  04:27:35  Show Profile
You're welcome Forgot to mention that if you'd prefer your first directory to be given the 0th position in the array, just remove the first character from the script_name variable using the "right" function.

By the way,I'd recommend creating that link dynamically from now on so you can easily make any changes to it in the future without having to find and modify +/-100000 individual links


Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07