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)
 users own page
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 4

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 10 October 2005 :  06:26:56  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I'm trying to figure out what's the best way to present a users own page on my site. I did it this way: http://www.yoursite.com/user?=%username% (http://www.yoursite.com/user?=gretchen) but I'd like to just have http://www.yoursite.com/username. How can I do this without creating a new subfolder for each user?

/Tribaliztic
- www.gotlandrace.se -

AnonJr
Moderator

United States
5768 Posts

Posted - 10 October 2005 :  11:32:41  Show Profile  Visit AnonJr's Homepage
If I remeber right, somebody had a "My Snitz" MOD out there. I think its still up at SnitzBitz, though I don't remeber the name it is listed under. I'll try to find the details for you.
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  03:10:58  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Hm... Ain't that just a page where the user can make some settings and check his/hers PM and such? I only need some way to use the url http://www.sitename.com/username and have it redirected to some page I choose.

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 11 October 2005 :  04:24:30  Show Profile  Send pdrg a Yahoo! Message
it's gonna be a server setting.

You could drop a custom 404.asp page in to your server, and handle it in code (404 as default.htm, default.asp, default.aspx, index.htm, index.html... (the usual defaults) is missing), that might work.

Simpler still if you know the username, just add the appropriate folder and create a default.asp page with a simple response.redirect in it

couplke of thoughts for ya :)
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  05:02:48  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
We're talking about 600+ users at the moment and growing, I don't want to add all those folders.
Got a suggestion to use ISAPI-filters for this, but then I need a list of all users in a ini-file (in this filter anyway) and then I have to update it manually also..

The best way so far is this (if it could work..)

- the visitor type in www.mysite.com/tribaliztic
- the code take everything after the last / and do a check into the user database to see if tribaliztic is a registered user
- if tribaliztic is found then another check to see if the user tribaliztic is a paying member
- if everything ok then goto www.mysite.com/user?=tribaliztic
- else goto errorpage or something suitable

What do you think about that?

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 11 October 2005 :  05:30:14  Show Profile  Send pdrg a Yahoo! Message
Yep - except where does that code run? I guess you could use session_OnStart, but I'm a bit unsure about the order of events, and the ISAPI solution is certainly the more elegant (hence the 'gonna be a server setting...' thing)

I have zero experience writing ISAPI filters, they tend to have to be pretty flipping fast, so typically heavily optimised C++ (/me shudders)
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  05:39:43  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
What do you mean with where the code is run?
I make a custom 404 error page and have the code there, should work?

I found this to help me with the string:
http://www.webmasterworld.com/forum48/128.htm

We're on our own server so installing things are no problem.

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  06:24:03  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
I got this code working with the help from the link above:

<%
dim textlength, nonslashtext
textlength = Len(Request.ServerVariables("SCRIPT_NAME"))
nonslashtext = textlength - 1
Response.write(Right(Request.ServerVariables("SCRIPT_NAME"),nonslashtext))
string = (Right(Request.ServerVariables("SCRIPT_NAME"),nonslashtext))
Response.Redirect "http://www.site.com/user.asp?=" & string & ""
%>

Would there be a problem with putting this code in the 404 error page?
=)
I can't test it on my 404 page until I get home tonight..

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 October 2005 :  07:17:43  Show Profile  Visit MarcelG's Homepage
tribaliztic, I'd make sure that prior to response.redirecting the 404 to the user.asp page, that the string is a valid username.
So, you need to do a SQL statement into the Snitz db, and check if the user exists.
If so ; redirect.
If not ; redirect to a real 'Page not found' page.
Have done something similar with my linkshrinker.
Here's some code to use as a base ;
<%@ LANGUAGE="VBSCRIPT"%>
<%Response.Buffer = True%>
<%
Response.CacheControl="private, max-age=0"
	Response.Expires=0
	dim strQString
	strQString = Request.ServerVariables("QUERY_STRING")
	strQString = replace(strQString,"404;http://www.oxle.com:80/","")
	strQString = replace(strQString,"404;http://www.oxle.nl:80/","")
	strQString = replace(strQString,"404;http://oxle.com:80/","")
	strQString = replace(strQString,"404;http://oxle.nl:80/","")
	strQString = replace(strQString,"404;http://test.oxle.com:80/","")
	strQString = replace(strQString,"404;http://test.oxle.nl:80/","")
'Spider check
	' Well, normally the browser isn't a spider...
	dim isSpider
	isSpider = 0
	' No other meaning than forcing the isSpider behaviour
	' for testing pourpose
	if request("spider") = 1 then isSpider = 1
	' Takes the name of the UserAgent currently used and put it
	' into lower case for compairson
	agent = lcase(Request.ServerVariables("HTTP_USER_AGENT"))
	' Now, most of the Bots refers to themself as libwww,
	' java, perl, crawl, bot. let's start with some conditions
	' If the agent contains "bot" then it is a Spider
	if instr(agent, "bot")  > 0 then isSpider = 1
	' If the agent contains "perl" then it is a Spider
	if instr(agent, "perl") > 0 then isSpider = 1
	' If the agent contains "java" then it is a Spider
	if instr(agent, "java") > 0 then isSpider = 1
	' If the agent contains "libw" then it is a Spider
	if instr(agent, "libw") > 0 then isSpider = 1
	' If the agent contains "crawl" then it is a Spider
	if instr(agent, "crawl") > 0 then isSpider = 1
	if instr(agent, "DA 7") > 0 then isSpider = 1
	if instr(agent, "DA 6") > 0 then isSpider = 1
	if instr(agent, "DA 5") > 0 then isSpider = 1
	if instr(agent, "DA 4") > 0 then isSpider = 1
	if instr(agent, "DA 3") > 0 then isSpider = 1
	if instr(agent, "DA 2") > 0 then isSpider = 1
	if instr(agent, "DA 1") > 0 then isSpider = 1
	if instr(agent, "download") > 0 then isSpider = 1
	
'end spider check
	
    If (Len(strQString)<5) and isSpider <> 1 and strQString <> "pda" and strQString <> "wap" Then
			'start the redirect script
			%>
			<!-- #INCLUDE FILE="ls/connection.asp" -->
			<!--#INCLUDE FILE="inc_base62.asp"-->
			<%
				Dim linkRec
				Dim link
				Dim hits
				Dim newUrl
				Set objConn = Server.CreateObject ("ADODB.Connection")
				Set linkRec = Server.CreateObject ("ADODB.Recordset")	
				'get current link
				link = FromBase62(strQString)
				'here comes the conversion from Base62 to Dec

				'Open database	
				objConn.Open strConnect

				Set linkRec = objConn.Execute ("SELECT * FROM links WHERE linkid = " & link & ";")
				if linkRec.BOF or linkRec.EOF then
						Set linkRec = Nothing
						objConn.Close
						Set objConn = Nothing
				   	Response.Buffer = True
			   		Response.Clear
			   		Response.Redirect("pagenotfound.asp?page=" & strQString)
				else
					'link found, redirecting
						newUrl = linkRec("url")
						objConn.Execute "UPDATE links SET links.hits = links.hits + 1 WHERE linkid = " & link
						Set linkRec = Nothing
						objConn.Close
						Set objConn = Nothing
					   Response.Buffer = True
					   Response.Clear
					   Response.Redirect chkUrl(newUrl)
			   end if	ELSEIF isSpider <> 1 then
	Select Case strQString
		Case "scoting"
		    Response.Redirect("/scouting/")
	    Case "scoting/"
		    Response.Redirect("/scouting/")
	  	Case "scauting"
		    Response.Redirect("/scouting/")
	    Case "scauting/"
		    Response.Redirect("/scouting/")
	    Case "frontpage"
		    Response.Redirect("default.asp")
	    Case "linkdump"
		    Response.Redirect("linkdump.asp")
		Case "linkshrinker"
		    Response.Redirect("ls.asp")
		Case "shrinker"
		    Response.Redirect("ls.asp")
		Case "tinyurl"
		    Response.Redirect("ls.asp")
	   	Case "forum"
		    Response.Redirect("forums.asp")
	   	Case "default"
		    Response.Redirect("default.asp")
	   	Case "defualt"
		    Response.Redirect("default.asp")
	    Case "defualt"
		    Response.Redirect("default.asp")
	    Case "defalt"
		    Response.Redirect("default.asp")
	    Case "index"
		    Response.Redirect("default.asp")
		Case "index.htm"
	    	server.transfer("default.asp")
		Case "index.html"
	    	server.transfer("default.asp")
		Case "default.htm"
	    	server.transfer("default.asp")
		Case "pda"
	    	server.transfer("mobile.asp")
		Case "wap"
	    	server.transfer("mobile.asp")
		Case "mobile"
	    	server.transfer("mobile.asp")
	    Case "default.html"
		    server.transfer("default.asp")
	    Case "members"
		    Response.Redirect("members.asp")
		Case "weblogs"
		    Response.Redirect("weblogs.asp")
		Case "weblog"
		    Response.Redirect("weblogs.asp")
		Case "calendar"
		    Response.Redirect("cal.asp")
		Case "events"
		    Response.Redirect("cal.asp")
		Case "active"
		    Response.Redirect("active.asp")
	    Case "chatbox"
			Response.Redirect("chat.asp")
	    Case "search"
		    Response.Redirect("search.asp")
	    Case "admin"
		    Response.Redirect("default.asp")
	  	Case Else
			Response.Redirect("/pagenotfound.asp?page=" & strQString)
		End Select
	else 
	server.transfer("empty.asp")
	end if
%>
The red part is the part that does the db-check, and redirects to a shrunken url.

portfolio - linkshrinker - oxle - twitter

Edited by - MarcelG on 11 October 2005 07:20:03
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  08:12:32  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Yes, ofcourse =) Oterwise I'd just create an endless loop =)
Thanks for the code, now I realized that a counter of how many times a users page has been visited would be neat also.
I'll have a look at this tonight if I get the time (I have a 3 months old baby at home so my priorities are alittle askew at the moment hehe).

But would the code I posted work for the 404-page? It won't mess something up? =)

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 11 October 2005 :  09:17:31  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Couldn't keep my fingers away from this, did a total rip-off and came up with this:

If (Len(strQString)> 0) Then
'start the redirect script

Dim linkRec
Dim link
Dim hits
Dim newUrl
Set objConn = Server.CreateObject ("ADODB.Connection")
Set linkRec = Server.CreateObject ("ADODB.Recordset")
'get current link
link = strQString

'Open database
objConn.Open strConnString

Set linkRec = objConn.Execute ("SELECT * FROM FORUM_MEMBERS WHERE M_NAME = "" & link & "";")
if linkRec.BOF or linkRec.EOF then
Set linkRec = Nothing
objConn.Close
Set objConn = Nothing
Response.Buffer = True
Response.Clear
Response.Redirect("pagenotfound.asp?page=" & strQString)
else
'link found, redirecting
newUrl = linkRec("url")
objConn.Execute "UPDATE FORUM_MEMBERS SET PAGE_HITS = PAGE_HITS + 1 WHERE M_NAME = " & link
Set linkRec = Nothing
objConn.Close
Set objConn = Nothing
Response.Buffer = True
Response.Clear
Response.Redirect "http://www.site.com/user_show.asp?=" & strQString & ""
end if
end if

Can't test this now, so please check if you see anything that look totally screwed =)

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 11 October 2005 :  11:26:51  Show Profile  Send pdrg a Yahoo! Message
I see no reason it oughtn't work in a 404.asp - maybe just rename your old 404 as 404.asp.retired and try it. You can't break anything permenantly, just name the files back (and maybe restart IIS)

hth
Go to Top of Page

MarcelG
Retired Support Moderator

Netherlands
2625 Posts

Posted - 11 October 2005 :  14:15:35  Show Profile  Visit MarcelG's Homepage
Tribaliztic ; this line should be removed however ;
newUrl = linkRec("url")


portfolio - linkshrinker - oxle - twitter
Go to Top of Page

sr_erick
Senior Member

USA
1318 Posts

Posted - 12 October 2005 :  00:18:17  Show Profile  Visit sr_erick's Homepage  Send sr_erick a Yahoo! Message
Marcel's way is the way I do it as well (similar to that) with the custom 404.

All of the members sites on this list use it. I also use it to get me the page number to pull up the correct page for each site. http://www.snowmobilefanatics.com/webpages/listsites.asp




Erick
Snowmobile Fanatics

Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 12 October 2005 :  03:15:59  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
quote:
Originally posted by MarcelG

Tribaliztic ; this line should be removed however ;
newUrl = linkRec("url")





Already done that =)

But when I tried to link my .asp-page in IIS yesterday it gave me an error. Seems like it has to be a htm/html-page?

Edit: ah, in IIS you should select "url" (which I did) but you shouldn't put the web url there, but the local path..
And I can't test this until I get home tonight =(

/Tribaliztic
- www.gotlandrace.se -

Edited by - tribaliztic on 12 October 2005 03:38:14
Go to Top of Page

tribaliztic
Senior Member

Sweden
1532 Posts

Posted - 13 October 2005 :  03:00:13  Show Profile  Visit tribaliztic's Homepage  Send tribaliztic an ICQ Message
Well, everything work as it should.. almost.. =)

I put a file named testuser.asp as my 404-page in IIS, the file is processed and everything's fine. BUT, the code (as can be seen above) is using the url to the 404-page instead of the url that the visitor have typed in. So, if a visitor type in www.site.com/snitz.php (that don't exist), the code still think that the url it should process is www.site.com/testuser.asp.
How can I make the code understand what url it should look for =)


EDIT:
I got it =)
I changed the top of the code to this instead and now it's working:

<!--#INCLUDE FILE="config.asp"-->
<%
dim textlength, nonslashtext
textlength = Len(Request.ServerVariables("QUERY_STRING"))
nonslashtext = textlength - 36
strQString = (Right(Request.ServerVariables("QUERY_STRING"),nonslashtext))

/Tribaliztic
- www.gotlandrace.se -
Go to Top of Page
Page: of 4 Previous Topic Topic Next Topic  
Next Page
 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.31 seconds. Powered By: Snitz Forums 2000 Version 3.4.07