Author |
Topic |
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 24 February 2008 : 17:43:35
|
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
|
LikeSELLER = Request.QueryString("SELLER") ? If this is going to the file system make sure to strip out slashes. |
|
|
bobby131313
Senior Member
USA
1163 Posts |
|
phy1729
Average Member
USA
589 Posts |
Posted - 24 February 2008 : 21:20:05
|
Maybe with Regex. [.]*/([^/]+)/[^/]+ I think. There is probably a better way. |
Edited by - phy1729 on 24 February 2008 21:20:54 |
|
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 24 February 2008 : 21:28:26
|
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 |
|
|
cgcarter1
Starting Member
14 Posts |
Posted - 01 April 2008 : 13:02:57
|
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...
|
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 01 April 2008 : 13:16:29
|
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.” |
|
|
cgcarter1
Starting Member
14 Posts |
Posted - 01 April 2008 : 14:37:58
|
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... |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 10 April 2008 : 04:43:20
|
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.” |
|
|
bobby131313
Senior Member
USA
1163 Posts |
Posted - 10 April 2008 : 13:14:50
|
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 |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 11 April 2008 : 04:27:35
|
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.” |
|
|
|
Topic |
|