webForumDet fria alternativet

räknare

ASPur ASP

1 svar · 181 visningar · startad av tronez

tronezMedlem sedan juli 2001728 inlägg
#1

hur gör man lättast en grafisk besöksräknare? om det går, å det borde det väl..

------------------
aka Lexmarc

Jesper TMedlem sedan nov. 20017 144 inlägg
#2

Detta sätter du i global.asa:

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'The code in this section is for when the server starts or the first user uses your site
'any variables in the Application_OnStart will remain till the server is stopped or the server is rebooted
Sub Application_OnStart
	
	'Craete an ActiveUsersNumber variable with Application scope and set it to 0
	Application("intActiveUserNumber") = 0

End Sub

'The code in this section is for when a user connects to any page in your web site
Sub Session_OnStart

	'The session timeout is how long a session (user connection) to your web site will last. The defualt is 20 minutes
	'When you call a web page a connection is made when the page is finshed downloading the connection is dropped 
	'if the session time out is set two low you wont register active users while they are reading a page
	'if you set it two high you will still register users as active after they have left your site
	'It is pobally best to leave at the defualt 20 minutes so that it dosent effect any other session variables used in your web site
	Session.Timeout = 20

	'The appilcation must be locked so that only one user can increment the Application ActiveUserNumber variable at a time
	Application.Lock
	
		'The Application ActiveUserNumber variable is incremented by 1
		Application("intActiveUserNumber") = Application("intActiveUserNumber") + 1
	
	'The application is now unlocked
	Application.UnLock

End Sub

'The code in this section is for when a user leaves yoursite or the session times out which ever comes first.
'Usally with HTTP access the server can not tell when a user has left the site so will wait for the session to time out
Sub Session_OnEnd

	'The appilcation must be locked so that only one user can decrement the Application ActiveUserNumber variable at a time
	Application.Lock
	
		'The Application ActiveUserNumber variable is decremented by 1
		Application("intActiveUserNumber") = Application("intActiveUserNumber") - 1
	
	'The application is now unlocked
	Application.UnLock

End Sub

</SCRIPT>
[/kod}

Och detta i default.asp

[kod]

<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Active User's Hit Counter</title>

<!-- The Surf-Net active user counter is written by Bruce Corkhill ©2001
     	If you want your own hit counter then goto [url="http://www.surf-net.co.uk"]http://www.surf-net.co.uk[/url]  --> 

</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center"> 
  <h1>Active User Counter</h1>
  <br>
  <table width="102" border="1" cellspacing="0" cellpadding="0" bordercolor="#000000" height="43">
    <tr>
      <td align="center"> 
        <%
'Dimension variables
Dim intDisplayDigitsLoopCount 	'Loop counter to diplay the graphical hit count

'Error handler
On Error Resume Next

'HTML output to display the visitor number
Response.Write "		<font size=2>Active User's</font><br>"

'Loop to display grapical digits
For intDisplayDigitsLoopCount = 1 to Len(Application("intActiveUserNumber"))
	
	'Display the graphical active user hit count by getting the path to the image using the mid function
	Response.Write "<img src=""counter_images/" & Mid(Application("intActiveUserNumber"), intDisplayDigitsLoopCount, 1) & ".gif"">"
Next

'Alternative to display text output instead
'Response.Write Application("intActiveUserNumber") 

%>
      </td>
    </tr>
  </table>
  <p>This active user counter will only increment when a new user comes to the site (not 
    by hitting refresh)<br>
    The active user counter will decrement when a user leaves the site or the 
    session times out (defualt 20 minutes)<br>
    <br>
    <a href="http://www.surf-net.co.uk" target="_top"><img src="surf-net_logo.gif" width="88" height="31" border="0" alt="Surf-Net"></a> 
  </p>
</div>
</body>
</html>

Sedan döper du bilderna till 1.gif 2.gif osv.. och lägger dem i en mapp kallad counter_images

/lycka till!!!

Lycka till

145 ms totalt · 3 externa anrop · v20260731065814-full.a2ca460b
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
142 ms — hämta tråd, inlägg och bilagor (db)