<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>» DoYourself.org &#187; MAC</title>
	<atom:link href="http://www.doyourself.org/category/mac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doyourself.org</link>
	<description>Did you know ?</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:00:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Compiling / building XviD with asm optimisations for Mac OS X Intel</title>
		<link>http://www.doyourself.org/uncategorized/623-compiling-building-xvid-with-asm-optimisations-for-mac-os-x-intel/</link>
		<comments>http://www.doyourself.org/uncategorized/623-compiling-building-xvid-with-asm-optimisations-for-mac-os-x-intel/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 17:58:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=623</guid>
		<description><![CDATA[Using Apple’s nasm one can compile a working XviD binary using the x86 asm that will run on Core Duo systems. Thanks to Christoph Naegeli and Andrea Gianarro for the following information. Enter the build/generic directory in the xvid source directory, run bootstrap.sh and (for bash) run: ./configure --enable-macosx_module Then edit build/generic/platform.inc and ADD the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Using Apple’s nasm one can compile a working XviD binary using the  x86 asm that will run on Core Duo systems. Thanks to Christoph Naegeli  and Andrea Gianarro for the following information.</p>
<p><strong>Enter the build/generic directory in the xvid source directory, run bootstrap.sh and (for bash) run:</strong></p>
<p><code>./configure --enable-macosx_module</code></p>
<p><strong>Then edit build/generic/platform.inc and ADD the flags shown below:</strong><br />
<code>"-undefined suppress" to SPECIFIC_CFLAGS<br />
"-f macho -DPREFIX" to AFLAGS (so it reads AFLAGS="AFLAGS=-I$(&lt;D)/ -f macho -DPREFIX")<br />
"-read_only_relocs suppress" to SPECIFIC_LDFLAGS</code></p>
<p>Here’s my <a href="http://doyourself.org/wp-content/files/platform.inc">platform.inc</a> if you would like to have a look to check you’ve edited it correctly.</p>
<p>Then make and make install as usual.</p>
<p>I also change -O2 to -O3 and add “-march=prescott” to the CFLAGS and  configure with –prefix=/usr/local . The CFLAGS enable some GCC  optimisations. There is debate as to whether the use of -march with  “pentium-m” or “prescott” is better for the Core processors. I haven’t  particularly researched it all that much but the Core is supposedly a  heavily reworked Pentium 3 that is a bit like a Pentium M, has the same  instruction set as the Prescott and behaves more like the NetBurst  architecture. As such -march=prescott is supposed to be the most  appropriate choice. When I get bored someday I’ll run some benchmarks  and test to see which is faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/uncategorized/623-compiling-building-xvid-with-asm-optimisations-for-mac-os-x-intel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create XML from an Access (mdb) database with ASP</title>
		<link>http://www.doyourself.org/mac/418-how-to-create-xml-from-an-access-mdb-database-with-asp/</link>
		<comments>http://www.doyourself.org/mac/418-how-to-create-xml-from-an-access-mdb-database-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[(mdb)]]></category>
		<category><![CDATA[Access]]></category>
		<category><![CDATA[an]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[from]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[with]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=418</guid>
		<description><![CDATA[OK, so I recently created this code with VBS, but it would work with ASP as well. Basically, you need to place the script in a folder where it can get write permissions to create the XML file. Then you&#039;ll connect to the Access database like you would normally. Although to be perfectly honest, you [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>OK, so I recently created this code with VBS, but it would work with ASP as well. Basically, you need to place the script in a folder where it can get write permissions to create the XML file. Then you&#039;ll connect to the Access database like you would normally. Although to be perfectly honest, you could use this script to create an XML from data in just about any type of database that you can connect to!</p>
<p><span class="co1">&#039;=== declare variables</span><br />
<span class="kw1">Dim</span> objConn, strConnect, strSQL, rs, tb, mdbFile, objFSO, xmlFile, objWrite</p>
<p><span class="co1">&#039;=== filename variables</span><br />
xmlFile = <span class="kw1">Server</span>.<span class="kw3">MapPath</span><span class="br0">&#040;</span><span class="st0">&#034;&#034;</span>inventory.<span class="me1">xml</span><span class="st0">&#034;)<br />
mdbFile&nbsp;= Server.MapPath(&#034;</span>database.<span class="me1">mdb</span><span class="st0">&#034;)</p>
<p>&#039;=== tab character for xml file<br />
tb = chr(9)</p>
<p>&#039;=== instantiate objects<br />
set objFSO&nbsp; = Server.CreateObject( &#034;</span>Scripting.<span class="me1">FileSystemObject</span><span class="st0">&#034; )<br />
Set objConn = Server.CreateObject( &#034;</span><span class="kw1">ADODB</span>.<span class="kw3">Connection</span><span class="st0">&#034; )</p>
<p>&#039;=== connect to database<br />
objConn.Open &#034;</span>Provider=Microsoft.<span class="me1">Jet</span>.<span class="me1">OLEDB</span>.<span class="nu0">4</span>.<span class="nu0">0</span>;Data Source=<span class="st0">&#034; &amp; mdbFile</p>
<p>&#039;=== open/create xml file<br />
If Not objFSO.FileExists( xmlFile ) Then objFSO.CreateTextFile( xmlFile )<br />
set objWrite = objFSO.OpenTextFile( xmlFile, 2 )</p>
<p>&#039;=== open the xml file<br />
objWrite.WriteLine(&#034;</span>&lt;?xml version=<span class="st0">&#034;&#034;</span><span class="nu0">1</span>.0<span class="st0">&#034;&#034;</span> encoding=<span class="st0">&#034;&#034;</span>ISO-<span class="nu0">8859</span>-1<span class="st0">&#034;&#034;</span>?&gt;<span class="st0">&#034;)<br />
objWrite.WriteLine(&#034;</span>&lt;data&gt;<span class="st0">&#034;)</p>
<p>strSQL = &#034;</span><span class="kw1">SELECT</span> * FROM table WHERE <span class="nu0">1</span>=1<span class="st0">&#034;<br />
Set rs = objConn.Execute(StrSQL)</p>
<p>&#039;=== loop through results<br />
Do While not rs.EOF<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; &#034;</span>&lt;item&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; tb &amp; &#034;</span>&lt;id&gt;<span class="st0">&#034; &amp; rs(&#034;</span>id<span class="st0">&#034;) &amp; &#034;</span>&lt;/id&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; tb &amp; &#034;</span>&lt;product&gt;<span class="st0">&#034; &amp; replace(rs(&#034;</span>product<span class="st0">&#034;),&#034;</span>&amp;<span class="st0">&#034;,&#034;</span>&amp;amp;<span class="st0">&#034;) &amp; &#034;</span>&lt;/product&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; tb &amp; &#034;</span>&lt;color&gt;<span class="st0">&#034; &amp; rs(&#034;</span>color<span class="st0">&#034;) &amp; &#034;</span>&lt;/color&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; tb &amp; &#034;</span>&lt;size&gt;<span class="st0">&#034; &amp; rs(&#034;</span>size<span class="st0">&#034;) &amp; &#034;</span>&lt;/size&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; objWrite.WriteLine(tb &amp; &#034;</span>&lt;/item&gt;<span class="st0">&#034;)<br />
&nbsp; &nbsp; rs.MoveNext<br />
Loop</p>
<p>&#039;=== finish xml file<br />
objWrite.WriteLine(&#034;</span>&lt;/data&gt;<span class="st0">&#034;)<br />
objWrite.Close() </span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/418-how-to-create-xml-from-an-access-mdb-database-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Determine a visitor&#8217;s location by their IP address!</title>
		<link>http://www.doyourself.org/mac/419-determine-a-visitors-location-by-their-ip-address-4/</link>
		<comments>http://www.doyourself.org/mac/419-determine-a-visitors-location-by-their-ip-address-4/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[address!]]></category>
		<category><![CDATA[by]]></category>
		<category><![CDATA[Determine]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[their]]></category>
		<category><![CDATA[visitor's]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=419</guid>
		<description><![CDATA[Tracking a visitor&#039;s geographical location (ie. country, region, city, latitude, longitude, ZIP code, ISP and domain name) used to be a cool trick. Now it is an integral part of many websites, enabling them to identify the locations from where they&#039;re getting the maximum traffic; and tune your webpages accordingly. It also enables you to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Tracking a visitor&#039;s geographical location (ie. country, region, city, latitude, longitude, ZIP code, ISP and domain name) used to be a cool trick. Now it is an integral part of many websites, enabling them to identify the locations from where they&#039;re getting the maximum traffic; and tune your webpages accordingly. It also enables you to modify the site according to location, or send users to specific sections (ie. show prices in CAD for Canadian visitors).</p>
<p>It is relatively easy to use this technology on your website with IP2Location&#039;s proprietary IP address lookup database. This database is free for the IP-Country version. Of you need more details like region, city, latitude, longitude, ZIP code, ISP and domain name for the IP address, you need to purchase the full database.<span></span></p>
<p>To determine the user&#039;s location by their IP address, you need to perform these three steps:</p>
<p>1. Retrieve the visitors&#039; IP address <br />
Here are the <a target="_blank" href="http://www.justin-cook.com/wp/2006/11/28/how-to-retrieve-a-visitors-ip-address/">functions to get the IP address using ASP, PHP, an .Net (C# &#038; VB.Net)</a>.</p>
<p>2. Convert the visitor&#039;s IP address to an IP Number<br />
Here are the <a target="_blank" href="http://www.justin-cook.com/wp/2006/11/28/convert-an-ip-address-to-ip-number-with-php-asp-c-and-vbnet/">functions to convert an IP address to an IP number using ASP, PHP, an .Net (C# &#038; VB.Net)</a>.</p>
<p>3. Locate the IP Number in the IP-Country database<br />
Example: the IP Address 202.186.13.4 converts to IP Number 3401190660. It is between the beginning and the ending of the following IP numbers:<br />
&#034;3401056256&#034;,&#034;3401400319&#034;,&#034;MY&#034;,&#034;MALAYSIA&#034;</p>
<p>From the IP-Country recordset, the Country_Name with this IP number range is Malaysia, the Country_Code is MY.</p>
<p>So once you have the IP Number, here&#039;s the SQL Query to locate the matching recordset:</p>
<p><span class="kw1">SELECT</span> country_name <span class="kw1">FROM</span> ip_to_country <span class="kw1">WHERE</span> <br />
<span class="br0">&#091;</span>your IP number<span class="br0">&#093;</span> <span class="kw1">BETWEEN</span> ip_start <span class="kw1">AND</span> ip_end</p>
<p>Of course, you need to download the <a rel="external nofollow" href="http://ip-to-country.webhosting.info/downloads/ip-to-country.csv.zip">IP2Country database</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/419-determine-a-visitors-location-by-their-ip-address-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to retrieve a visitor&#8217;s IP address</title>
		<link>http://www.doyourself.org/mac/420-how-to-retrieve-a-visitors-ip-address-3/</link>
		<comments>http://www.doyourself.org/mac/420-how-to-retrieve-a-visitors-ip-address-3/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[a]]></category>
		<category><![CDATA[address!]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[Retrieve]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[visitor's]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=420</guid>
		<description><![CDATA[Every visitor to your site or web application has an IP address. It is quite handy to be able to get that address. It can be used for security logging, or perhaps tracing. It can also be used to determine where they are in the world, or at least where their ISP is. The difficulty [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Every visitor to your site or web application has an IP address. It is quite handy to be able to get that address. It can be used for security logging, or perhaps tracing. It can also be used to determine where they are in the world, or at least where their ISP is. </p>
<p>The difficulty is when they&#039;re behind a proxy of some sort, you only see the IP address of the proxy server. So, here are the code snippets in PHP, ASP and .Net that first check for an IP addresses that&#039;s forwarded from behind a proxy, and if there&#039;s none then just get the IP address.<br />
<span></span><br />
Here it is in PHP</p>
<p><span class="kw2">&lt;?</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#040;</span><a href="http://www.php.net/getenv"><span class="kw3">getenv</span></a><span class="br0">&#040;</span>HTTP_X_FORWARDED_FOR<span class="br0">&#041;</span><span class="br0">&#041;</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$ip_address</span> = <a href="http://www.php.net/getenv"><span class="kw3">getenv</span></a><span class="br0">&#040;</span>HTTP_X_FORWARDED_FOR<span class="br0">&#041;</span>; <br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$ip_address</span> = <a href="http://www.php.net/getenv"><span class="kw3">getenv</span></a><span class="br0">&#040;</span>REMOTE_ADDR<span class="br0">&#041;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></p></blockquote>
<p>And here&#039;s how to get the IP address in ASP</p>
<p><span class="kw2">&lt;%</span><br />
&nbsp; &nbsp; ip_address = <span class="kw1">Request</span>.<span class="kw3">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;HTTP_X_FORWARDED_FOR&#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> ip_address = <span class="st0">&#034;&#034;</span> <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ip_address = <span class="kw1">Request</span>.<span class="kw3">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;REMOTE_ADDR&#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
<span class="kw2">%&gt;</span></p>
<p>And here&#039;s the IP retriever with proxy detection in .Net (C#)</p>
<p>public <span class="kw4">string</span> IpAddress<span class="br0">&#040;</span><span class="br0">&#041;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw4">string</span> strIpAddress;<br />
&nbsp; &nbsp; strIpAddress = Request.<span class="me1">ServerVariables</span><span class="br0">&#091;</span><span class="st0">&#034;HTTP_X_FORWARDED_FOR&#034;</span><span class="br0">&#093;</span>;<br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#040;</span>strIpAddress == <span class="kw2">null</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;strIpAddress = Request.<span class="me1">ServerVariables</span><span class="br0">&#091;</span><span class="st0">&#034;REMOTE_ADDR&#034;</span><span class="br0">&#093;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> strIpAddress;<br />
<span class="br0">&#125;</span></p>
<p>And here&#039;s the same IP retriever with proxy detection in .Net, but in VB.Net</p>
<p><span class="kw2">Public</span> <span class="kw6">Function</span> IpAddress<span class="br0">&#040;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="kw6">Dim</span> strIpAddress <span class="kw2">As</span> <span class="kw2">String</span><br />
&nbsp; &nbsp; strIpAddress = Request.<span class="me1">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;HTTP_X_FORWARDED_FOR&#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="kw6">If</span> strIpAddress = <span class="st0">&#034;&#034;</span> <span class="kw2">Then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;strIpAddress = Request.<span class="me1">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;REMOTE_ADDR&#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; <span class="kw6">End</span> <span class="kw6">If</span><br />
&nbsp; &nbsp; IpAddress = strIpAddress<br />
<span class="kw6">End</span> <span class="kw6">Function</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/420-how-to-retrieve-a-visitors-ip-address-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Excel .xls files with ASP</title>
		<link>http://www.doyourself.org/mac/421-create-excel-xls-files-with-asp/</link>
		<comments>http://www.doyourself.org/mac/421-create-excel-xls-files-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[.xls]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=421</guid>
		<description><![CDATA[I used to work on a web application that tracked hardware inventory. I was requested to build a feature into the report page to be able to export to Excel (.xls) format. Initially I looked into the code to instantiate a new spreadsheet object, and build the rows and cells one by one programatically. But [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I used to work on a web application that tracked hardware inventory. I was requested to build a feature into the report page to be able to export to Excel (.xls) format. </p>
<p>Initially I looked into the code to instantiate a new spreadsheet object, and build the rows and cells one by one programatically. But I found a much simpler solution. </p>
<p>1. Create your report in HTML table format the same as you would your report page.<br />
2. Strip out any header/footer info from the page, everything except the table.<br />
3. Insert this line of code in the ASP header:</p>
<p><span class="kw2">&lt;%</span> <span class="kw1">response</span>.<span class="kw3">ContentType</span> =<span class="st0">&#034;application/x-excel&#034;</span> <span class="kw2">%&gt;</span></p>
<p>The table will be produced in HTML by the ASP server the same as it would on the report page. However, the returned content type is marked as .xls, so it will open in Excel as a spreadsheet!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/421-create-excel-xls-files-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create &#8216;add to calendar&#8217; functionality with ASP</title>
		<link>http://www.doyourself.org/mac/422-create-add-to-calendar-functionality-with-asp/</link>
		<comments>http://www.doyourself.org/mac/422-create-add-to-calendar-functionality-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[calendar']]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[functionality]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=422</guid>
		<description><![CDATA[When running events and event registrations on a website, it&#039;s very beneficial for users to be able to add the even details to their calendars without having to manually enter them. To do this, you need to generate a .vcs file or output to send to the user. You can either generate this and return [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>When running events and event registrations on a website, it&#039;s very beneficial for users to be able to add the even details to their calendars without having to manually enter them. To do this, you need to generate a .vcs file or output to send to the user. You can either generate this and return it in .vcs encoding, but in this code example I&#039;ll show you how to actually create a .vcs file, and store it on the server.</p>
<p>This code assume that you&#039;ve already got the event details, and loaded them into the descriptive variables in the code below:</p>
<p><span class="kw2">sub</span> generateCalendarFile<span class="br0">&#040;</span> intEvent <span class="br0">&#041;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> strDtStart, strTmStart, strDtEnd, strTmEnd, strTitle, strDesc, strAddress, strCity<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> strProvince, strRegURL, strCECid, strCal, strLinktoReg<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; strAddress = strAddress &amp; <span class="st0">&#034;=0D=0A&#034;</span> &amp; strCity &amp; <span class="st0">&#034;, &#034;</span> &amp; strProvince<br />
&nbsp; &nbsp; &nbsp; &nbsp; strDesc = strDesc &amp; <span class="st0">&#034;=0D=0A=0D=0A&#034;</span> &amp; strAddress<br />
&nbsp; &nbsp; &nbsp; &nbsp; strDesc = cleanString<span class="br0">&#040;</span> strDesc <span class="br0">&#041;</span> <span class="co1">&#039;function further down</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> isEmpty<span class="br0">&#040;</span> strRegURL <span class="br0">&#041;</span> <span class="kw2">or</span> <span class="kw3">trim</span><span class="br0">&#040;</span> strRegURL <span class="br0">&#041;</span> = <span class="st0">&#034;&#034;</span> <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strLinktoReg = <span class="st0">&#034;default registration URL&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strLinktoReg = strRegURL<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strDesc = strDesc &amp; <span class="st0">&#034;=0D=0A=0D=0ADon&#039;t forget to register!=0D=0A&#034;</span> &amp; <span class="kw3">replace</span><span class="br0">&#040;</span> strLinkToReg, <span class="st0">&#034;=&#034;</span>, <span class="st0">&#034;=3D&#034;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; strCal = <span class="st0">&#034;BEGIN:VCALENDAR&#034;</span> &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;BEGIN:VEVENT&#034;</span> &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;SUMMARY;CHARSET=ISO-8859-1;ENCODING=quoted-printable:&#034;</span> &amp; strTitle &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;DESCRIPTION;CHARSET=ISO-8859-1;ENCODING=quoted-printable:&#034;</span> &amp; strDesc &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;DTSTART:&#034;</span> &amp; vCalDate<span class="br0">&#040;</span> strDtStart, strTmStart <span class="br0">&#041;</span> &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;DTEND:&#034;</span> &amp; vCalDate<span class="br0">&#040;</span> strDtEnd, strTmEnd <span class="br0">&#041;</span> &amp; vbCrLf &amp; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;END:VEVENT&#034;</span> &amp; vbCrLf &amp; _ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class="st0">&#034;END:VCALENDAR&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> vCalPath, vCalFile, strFTPcmd, objFSP, objWrite<br />
&nbsp; &nbsp; &nbsp; &nbsp; vCalPath = <span class="kw1">Request</span>.<span class="kw3">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;APPL_PHYSICAL_PATH&#034;</span><span class="br0">&#041;</span> &amp; <span class="st0">&#034;downloadsevents&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objFSO = <span class="kw1">Server</span>.<span class="kw3">CreateObject</span><span class="br0">&#040;</span><span class="st0">&#034;Scripting.FileSystemObject&#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw1">Not</span> objFSO.<span class="me1">FolderExists</span><span class="br0">&#040;</span> vCalPath <span class="br0">&#041;</span> <span class="kw1">then</span> <span class="kw1">call</span> errorMessage<span class="br0">&#040;</span> vCalPath &amp; <span class="st0">&#034; is an invalid path!&#034;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; vCalFile = intEvent &amp; <span class="st0">&#034;_&#034;</span> &amp; intLanguage &amp; <span class="st0">&#034;.vcs&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objWrite = objFSO.<span class="kw3">OpenTextFile</span><span class="br0">&#040;</span> vCalPath &amp; <span class="st0">&#034;&#034;</span> &amp; vCalFile, <span class="nu0">2</span>, <span class="kw2">true</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objWrite.<span class="kw3">Write</span><span class="br0">&#040;</span>strCal<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objWrite.<span class="kw3">Close</span><span class="br0">&#040;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objWrite = <span class="kw2">nothing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objFSO = <span class="kw2">nothing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">end</span> <span class="kw2">sub</span></p>
<p>For the .vcs file format, the date and time need to be converted to a rather strange format. So here&#039;s the function to take the date and time, convert them to and return them in .vcs format:</p>
<p><span class="kw2">function</span> vCalDate<span class="br0">&#040;</span> strDate, strTime <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> arDate<br />
&nbsp; &nbsp; &nbsp; &nbsp; arDate = split<span class="br0">&#040;</span> strDate, <span class="st0">&#034;-&#034;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strDate = <span class="st0">&#034;&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> j = <span class="nu0">0</span> <span class="kw1">to</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">len</span><span class="br0">&#040;</span> arDate<span class="br0">&#040;</span> j <span class="br0">&#041;</span> <span class="br0">&#041;</span> = <span class="nu0">1</span> <span class="kw1">then</span> arDate<span class="br0">&#040;</span> j <span class="br0">&#041;</span> = <span class="st0">&#034;0&#034;</span> &amp; arDate<span class="br0">&#040;</span> j <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strDate = strDate &amp; arDate<span class="br0">&#040;</span> j <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; strTime = <span class="kw3">replace</span><span class="br0">&#040;</span> strTime, <span class="st0">&#034;:&#034;</span>, <span class="st0">&#034;&#034;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strTime = <span class="kw1">cLng</span><span class="br0">&#040;</span> strTime <span class="br0">&#041;</span> + <span class="nu0">40000</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> strTime &gt; <span class="nu0">240000</span> <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strDate = <span class="kw1">cStr</span><span class="br0">&#040;</span> <span class="kw1">cLng</span><span class="br0">&#040;</span> strDate <span class="br0">&#041;</span> + <span class="nu0">1</span>&nbsp; &nbsp; &nbsp;<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTime = strTime &#8211; <span class="nu0">240000</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strTime = <span class="kw1">cStr</span><span class="br0">&#040;</span> strTime <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">len</span><span class="br0">&#040;</span> strTime <span class="br0">&#041;</span> &lt; <span class="nu0">6</span> <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> until <span class="kw3">len</span><span class="br0">&#040;</span> strTime <span class="br0">&#041;</span> = <span class="nu0">6</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTime = <span class="st0">&#034;0&#034;</span> &amp; strTime<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; vCalDate = strDate &amp; <span class="st0">&#034;T&#034;</span> &amp; strTime &amp; <span class="st0">&#034;Z&#034;</span><br />
<span class="kw1">end</span> <span class="kw2">function</span></p>
<p>One other thing: if you have any URLs or HTML enchoded characters (like &amp;reg;, etc), they don&#039;t play well in the .vcs files. So you need to remove the URLs, and re-encode the symbols in UNICDE format. Here&#039;s the function to do that </p>
<p><span class="kw2">function</span> cleanString<span class="br0">&#040;</span> strToConvert <span class="br0">&#041;</span><br />
<span class="co1">&#039;=== remove URLS</span><br />
<span class="co1">&#039;=== takes out HTML friendly chars, and converts to UNICODE equivalent</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> objRegExp, matches, strChar<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objRegExp&nbsp; &nbsp;&nbsp; = <span class="kw2">New</span> RegExp<br />
&nbsp; &nbsp; &nbsp; &nbsp; objRegExp.<span class="me1">Pattern</span> &nbsp; &nbsp; &nbsp;&nbsp; = <span class="st0">&#034;&lt;a.*?&lt;/a&gt;&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; objRegExp.<span class="kw1">Global</span> &nbsp; &nbsp; &nbsp; &nbsp; = <span class="kw2">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strToConvert&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; = objRegExp.<span class="kw3">Replace</span><span class="br0">&#040;</span> strToConvert, <span class="st0">&#034;&#034;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objRegExp &nbsp; &nbsp;&nbsp; = <span class="kw2">nothing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objRegExp&nbsp; &nbsp;&nbsp; = <span class="kw2">New</span> RegExp<br />
&nbsp; &nbsp; &nbsp; &nbsp; objRegExp.<span class="me1">Pattern</span> &nbsp; &nbsp; &nbsp;&nbsp; = <span class="st0">&#034;&amp;#.*?;&#034;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; objRegExp.<span class="kw1">Global</span> &nbsp; &nbsp; &nbsp; &nbsp; = <span class="kw2">true</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> matches &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; = objRegExp.<span class="kw3">Execute</span><span class="br0">&#040;</span> strToConvert <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="kw1">each</span> j <span class="kw1">in</span> matches<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strChar = j.<span class="me1">value</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strChar = <span class="kw1">cInt</span><span class="br0">&#040;</span> <span class="kw3">replace</span><span class="br0">&#040;</span> <span class="kw3">replace</span><span class="br0">&#040;</span> strChar, <span class="st0">&#034;&amp;#&#034;</span>, <span class="st0">&#034;&#034;</span> <span class="br0">&#041;</span>, <span class="st0">&#034;;&#034;</span>, <span class="st0">&#034;&#034;</span> <span class="br0">&#041;</span> <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strChar = chr<span class="br0">&#040;</span> strChar <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strToConvert = <span class="kw3">replace</span><span class="br0">&#040;</span> strToConvert, j.<span class="me1">value</span>, strChar <span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">next</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> objRegExp &nbsp; &nbsp;&nbsp; = <span class="kw2">nothing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">set</span> matches &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; = <span class="kw2">nothing</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cleanString&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; = strToConvert</p>
<p><span class="kw1">end</span> <span class="kw2">function</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/422-create-add-to-calendar-functionality-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Block visitors based on IP address with ASP</title>
		<link>http://www.doyourself.org/mac/423-block-visitors-based-on-ip-address-with-asp/</link>
		<comments>http://www.doyourself.org/mac/423-block-visitors-based-on-ip-address-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[address!]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[based]]></category>
		<category><![CDATA[block!]]></category>
		<category><![CDATA[IP]]></category>
		<category><![CDATA[on]]></category>
		<category><![CDATA[visitor's]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=423</guid>
		<description><![CDATA[I previously posted this code in PHP, and I thought it would be handy to have the ASP alternative, in case you need to block visitors or known spammers based on their IP address. Function IsBlockedIP&#040;&#041; &#160; &#160; &#160; &#160; Dim UserIP &#160; &#160; &#160; &#160; Dim BlockedIParray&#040;2&#041;&#160; &#039; you can create the array larger [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I previously posted this code in PHP, and I thought it would be handy to have the ASP alternative, in case you need to block visitors or known spammers based on their IP address.</p>
<p><span class="kw2">Function</span> IsBlockedIP<span class="br0">&#040;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> UserIP <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Dim</span> BlockedIParray<span class="br0">&#040;</span><span class="nu0">2</span><span class="br0">&#041;</span>&nbsp; <span class="co1">&#039; you can create the array larger of course</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#039;put each blocked IP address in the array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; BlockedIParray<span class="br0">&#040;</span><span class="nu0">0</span><span class="br0">&#041;</span> = <span class="st0">&#034;60.0.201.209&#034;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; BlockedIParray<span class="br0">&#040;</span><span class="nu0">1</span><span class="br0">&#041;</span> = <span class="st0">&#034;218.11.15.212&#034;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#039;retrieve the visitors IP address from the server variables</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; UserIP = <span class="kw1">Request</span>.<span class="kw3">ServerVariables</span><span class="br0">&#040;</span><span class="st0">&#034;REMOTE_ADDR&#034;</span><span class="br0">&#041;</span> <br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">&#039;loop through the Blocked IPs </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">For</span> i = <span class="nu0">0</span> <span class="kw1">to</span> <span class="kw3">UBound</span><span class="br0">&#040;</span>BlockedIParray<span class="br0">&#041;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">If</span> UserIP = BlockedIParray<span class="br0">&#040;</span>i<span class="br0">&#041;</span> <span class="kw1">Then</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Response</span>.<span class="kw3">Redirect</span> <span class="st0">&#034;blocked.asp&#034;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">End</span> <span class="kw1">If</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">Next</span> <br />
<span class="kw1">End</span> <span class="kw2">Function</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/423-block-visitors-based-on-ip-address-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Track and display visitor count in globa.asa with ASP</title>
		<link>http://www.doyourself.org/mac/424-track-and-display-visitor-count-in-globa-asa-with-asp/</link>
		<comments>http://www.doyourself.org/mac/424-track-and-display-visitor-count-in-globa-asa-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[and]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[globa.asa]]></category>
		<category><![CDATA[in]]></category>
		<category><![CDATA[track]]></category>
		<category><![CDATA[Visitor]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=424</guid>
		<description><![CDATA[It is very easy within ASP to track and display the total number of visitors to your web application. Using the global.asa file, which is automatically included and processed in each webapp, we can create some simple session variables to track visitors. &#60;script language=&#034;vbscript&#034; runat=&#034;server&#034;&#62; &#160; Sub Application_OnStart &#160; &#160; &#160; &#160;&#039;Set the active users [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>It is very easy within ASP to track and display the total number of visitors to your web application. Using the global.asa file, which is automatically included and processed in each webapp, we can create some simple session variables to track visitors.</p>
<p><span class="kw2">&lt;script language=</span><span class="st0">&#034;vbscript&#034;</span> runat=<span class="st0">&#034;server&#034;</span>&gt;<br />
&nbsp;<br />
<span class="kw2">Sub</span> Application_OnStart<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#039;Set the active users to zero at the time of starting or resetting the application</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> = <span class="nu0">0</span><br />
<span class="kw1">End</span> <span class="kw2">Sub</span><br />
&nbsp;<br />
<span class="kw2">Sub</span> Session_OnStart<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#039; a new person is visiting, so start a new session</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Session</span>.<span class="me1">Timeout</span> = <span class="nu0">20</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Session</span><span class="br0">&#040;</span><span class="st0">&#034;Start&#034;</span><span class="br0">&#041;</span> = <span class="kw3">Now</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span>.<span class="kw3">Lock</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#039;Add one to the active users when the person first visits</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> = <span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> + <span class="nu0">1</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span>.<span class="kw3">unlock</span><br />
<span class="kw1">End</span> <span class="kw2">Sub</span><br />
&nbsp;<br />
<span class="kw2">Sub</span> Session_OnEnd<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#039; the user&#039;s session has timed out, so they most likely left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span>.<span class="kw3">Lock</span><br />
&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">&#039;Subtract one from the number os users</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> = <span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">Application</span>.<span class="kw3">unlock</span><br />
<span class="kw1">End</span> <span class="kw2">Sub</span><br />
&nbsp;<br />
<span class="kw2">&lt;/SCRIPT&gt;</span></p>
<p>To display the current total of users on the site, include the following code any where on your ASP pages.</p>
<p>There are currently <span class="kw2">&lt;%</span> = <span class="kw1">Application</span><span class="br0">&#040;</span><span class="st0">&#034;ActiveUsers&#034;</span><span class="br0">&#041;</span> <span class="kw2">%&gt;</span> users online!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/424-track-and-display-visitor-count-in-globa-asa-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display directory contents with ASP</title>
		<link>http://www.doyourself.org/mac/425-display-directory-contents-with-asp/</link>
		<comments>http://www.doyourself.org/mac/425-display-directory-contents-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[contents]]></category>
		<category><![CDATA[Directory]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=425</guid>
		<description><![CDATA[Here&#039;s a really quick way to list the files &#038; folders in a directory with ASP. This code uses the FileSystemObject to list the files. Obviously, you need to replace &#034;directoryname&#034; with your directory name. Or better yet, if you know the physical path you can replace the virtual reference via Server.MapPath(&#034;/directoryname&#034;) with the actual [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#039;s a really quick way to list the files &#038; folders in a directory with ASP. This code uses the FileSystemObject to list the files. </p>
<p>Obviously, you need to replace &#034;directoryname&#034; with your directory name. Or better yet, if you know the physical path you can replace the virtual reference via Server.MapPath(&#034;/directoryname&#034;) with the actual path like this: &#034;C:Inetpubwwwroothomesitedirectoryname&#034;</p>
<p>Just make sure the directory has &#034;read&#034; permissions from the anonymous account or the IUSER_machinename account, or you will get a permission denied error.</p>
<p><span class="kw2">&lt;%</span><br />
<span class="kw1">Set</span> MyDirectory=<span class="kw1">Server</span>.<span class="kw3">CreateObject</span><span class="br0">&#040;</span><span class="st0">&#034;Scripting.FileSystemObject&#034;</span><span class="br0">&#041;</span><br />
<span class="kw1">Set</span> MyFiles=MyDirectory.<span class="me1">GetFolder</span><span class="br0">&#040;</span><span class="kw1">Server</span>.<span class="kw3">MapPath</span><span class="br0">&#040;</span><span class="st0">&#034;/directoryname&#034;</span><span class="br0">&#041;</span><span class="br0">&#041;</span><br />
<span class="kw1">For</span> <span class="kw1">each</span> filefound <span class="kw1">in</span> MyFiles.<span class="me1">files</span><br />
<span class="kw2">%&gt;</span></p>
<p><span class="kw2">&lt;%</span> =filefound.<span class="me1">Name</span> &amp; <span class="st0">&#034;&lt;br&gt;&#034;</span> <span class="kw2">%&gt;</span></p>
<p><span class="kw2">&lt;%</span> <span class="kw1">Next</span> <span class="kw2">%&gt;</span></p>
<p>A good idea would be to make this your default.asp page for each directory, then you could create custom links to files, instead of the default directory indexing page in IIS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/425-display-directory-contents-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Easily Parse Text With ASP</title>
		<link>http://www.doyourself.org/mac/426-how-to-easily-parse-text-with-asp/</link>
		<comments>http://www.doyourself.org/mac/426-how-to-easily-parse-text-with-asp/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:51:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MAC]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[Easily]]></category>
		<category><![CDATA[How]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[to]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://www.doyourself.org/?p=426</guid>
		<description><![CDATA[Parsing text in ASP is not the easiest task. If you only want to extract text from the right or left side of a string, it&#039;s no problem. But if you need to extract from the middle of the string &#8211; or parse HTML or XML tags or attributes &#8211; it can be quite difficult [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Parsing text in ASP is not the easiest task. If you only want to extract text from the right or left side of a string, it&#039;s no problem. But if you need to extract from the middle of the string &#8211; or parse HTML or XML tags or attributes &#8211; it can be quite difficult if you don&#039;t know the exact location. So I built this function to take a string, and two other strings as the left and right markers to parse between.<span></span></p>
<p>The function has two additional capabilities besides just parsing between two strings.<br />
1. If you specify &#034;1&#034; as the strLft parameter, all text from the beginning of the string to the instance of the right string will be parsed. Basically this means &#034;give me everything before ___ text&#034;<br />
2. If you use empty quotes for the left parameter (&#034;&#8221;), then everything after the right marker will be parsed. This is handy if you have repeating tags, and you want to parse them one at a time. You parse the first one, then remove it by parsing everything to the right of it, parse the next, and so on.</p>
<p><span class="co1">&#039;=== extractor function</span><br />
<span class="co1">&#039;=== strSrc: the text to pull from</span><br />
<span class="co1">&#039;=== strLft: left marker to start at</span><br />
<span class="co1">&#039;=== strRgt: right marker to end at</span><br />
<span class="kw2">function</span> parser<span class="br0">&#040;</span>strSrc, strLft, strRgt<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">dim</span> strParsed<br />
&nbsp; &nbsp; &nbsp; &nbsp; strLft = <span class="kw1">cStr</span><span class="br0">&#040;</span>strLft<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> strLft = <span class="st0">&#034;1&#034;</span> <span class="kw1">then</span> <span class="co1">&#039;=== start from beginning</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strRgt<span class="br0">&#041;</span> &gt; <span class="nu0">0</span> <span class="kw1">then</span> strParsed = left<span class="br0">&#040;</span> strSrc, <span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strRgt<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">elseif</span> strLft = <span class="st0">&#034;&#034;</span> <span class="kw1">then</span> <span class="co1">&#039;=== start from right marker (trim out last result)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strRgt<span class="br0">&#041;</span> &gt; <span class="nu0">0</span> <span class="kw1">then</span> strParsed = right<span class="br0">&#040;</span> strSrc, <span class="kw3">len</span><span class="br0">&#040;</span>strSrc<span class="br0">&#041;</span> &#8211; <span class="br0">&#040;</span><span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strRgt<span class="br0">&#041;</span> + <span class="kw3">len</span><span class="br0">&#040;</span>strRgt<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strLft<span class="br0">&#041;</span> &gt; <span class="nu0">0</span> <span class="kw1">then</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strParsed = right<span class="br0">&#040;</span> strSrc, <span class="kw3">len</span><span class="br0">&#040;</span>strSrc<span class="br0">&#041;</span> &#8211; <span class="br0">&#040;</span><span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strLft<span class="br0">&#041;</span> + <span class="kw3">len</span><span class="br0">&#040;</span>strLft<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="kw3">inStr</span><span class="br0">&#040;</span>strSrc, strRgt<span class="br0">&#041;</span> &gt; <span class="nu0">0</span> <span class="kw1">then</span> strParsed = left<span class="br0">&#040;</span> strParsed, <span class="kw3">inStr</span><span class="br0">&#040;</span>strParsed, strRgt<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">end</span> <span class="kw1">if</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; strParsed = <span class="kw3">trim</span><span class="br0">&#040;</span>strParsed<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span> until left<span class="br0">&#040;</span>strParsed, <span class="nu0">1</span><span class="br0">&#041;</span> &lt;&gt; chr<span class="br0">&#040;</span><span class="nu0">10</span><span class="br0">&#041;</span> <span class="kw2">and</span> right<span class="br0">&#040;</span>strParsed, <span class="nu0">1</span><span class="br0">&#041;</span> &lt;&gt; chr<span class="br0">&#040;</span><span class="nu0">10</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> left<span class="br0">&#040;</span>strParsed, <span class="nu0">1</span><span class="br0">&#041;</span> = chr<span class="br0">&#040;</span><span class="nu0">10</span><span class="br0">&#041;</span> <span class="kw1">then</span> strParsed = right<span class="br0">&#040;</span>strParsed, <span class="kw3">len</span><span class="br0">&#040;</span>strParsed<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> right<span class="br0">&#040;</span>strParsed, <span class="nu0">1</span><span class="br0">&#041;</span> = chr<span class="br0">&#040;</span><span class="nu0">10</span><span class="br0">&#041;</span> <span class="kw1">then</span> strParsed = left<span class="br0">&#040;</span>strParsed, <span class="kw3">len</span><span class="br0">&#040;</span>strParsed<span class="br0">&#041;</span> &#8211; <span class="nu0">1</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">loop</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; strParsed = <span class="kw3">replace</span><span class="br0">&#040;</span> strParsed, <span class="st0">&#034;%20&#034;</span>, <span class="st0">&#034; &#034;</span><span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; strParsed = <span class="kw3">trim</span><span class="br0">&#040;</span>strParsed<span class="br0">&#041;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; parser = strParsed<br />
<span class="kw1">end</span> <span class="kw2">function</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.doyourself.org/mac/426-how-to-easily-parse-text-with-asp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

