<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Catch-44</title>
    <link>http://blog.focas.net.au/</link>
    <description>Divide by zero</description>
    <language>en-AU</language>
    <copyright>Mark Focas</copyright>
    <lastBuildDate>Tue, 12 Aug 2008 13:18:03 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mark@focas.net.au</managingEditor>
    <webMaster>mark@focas.net.au</webMaster>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=829b7581-94c5-479e-ac17-7e66d34fac8b</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,829b7581-94c5-479e-ac17-7e66d34fac8b.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,829b7581-94c5-479e-ac17-7e66d34fac8b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=829b7581-94c5-479e-ac17-7e66d34fac8b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
        </p>
        <p>
          <a title="Media RSS" href="http://search.yahoo.com/mrss" target="_blank">Media RSS</a> (MRSS)
is an XML format which extends the <a title="Really Simple Syndication" href="http://www.powerset.com/explore/go/rss" target="_blank">RSS</a> format.
By using this format, a website can be enabled to provide rich media functionality.
This can be used for images, audio and video. This entry discusses enabling Media
RSS for images. Video is very easy to implement, but will not be discussed here. By
using <a title="PicLens media RSS browser extension" href="http://www.piclens.com/" target="_blank">PicLens</a> in
Firefox, the result looks like below. It is very fast, full screen, and has nice facilities
to scroll around the images, zoom in and out and other such things. Here I will discuss
a simple implementation, and you can scroll below to download a small .NET application
to automate this process. If you already have a Media RSS viewing application, then <a href="http://blog.focas.net.au/imagegallery/" target="_blank">check
out an example of the output</a> (Note, copyright links were added after the page
was generated).
</p>
        <img src="http://blog.focas.net.au/content/binary/PicLens.png" style="float: left;" border="0" />
        <p>
          <br />
        </p>
        <h4>How to implement Media RSS
</h4>
        <p>
The Media RSS format is very simple, it only requires the addition of two namespaces
to an RSS feed, and two elements within that namespace. The namespaces are:<br /><br /><span class="attribute-value"><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">xmlns:atom=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"http://www.w3.org/2005/Atom"</span><br />
xmlns:media=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"><a href="http://search.yahoo.com/mrss/">http://search.yahoo.com/mrss/</a></span></span><br /></span><br />
The elements that need to be added are: 
<br /><span class="attribute-value"><br /></span><span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;">&lt;media:thumbnail
url=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"path_to_image_thumbnail"</span> /&gt;<br />
&lt;media:content url=<span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);">"path_to_image"</span> /&gt;<br /></span></p>
        <p>
The URL's can should be absolute URL's to validate in feed validation systems, although
it will still work if you use relative URL's. The <strong>thumbnail</strong> element
should be used, but if you don't have a separate thumbnail image you can
just point it at the same as the full size image. It would be worthwhile to use a
thumbnail as you will save bandwidth and probably please your viewers with a more
responsive experience.
</p>
        <img src="http://blog.focas.net.au/content/binary/raspberries.png" style="float: left;" width="425" border="0" height="397" />
        <p>
The last thing to do is to include a link to the feed on the page where you want to
display it. This points to the Media RSS feed you created earlier. The Media R
</p>
        <p>
SS feed can exist anywhere in your site, just make sure you point to it in the page
where you want the feed discovered.
</p>
        <p>
&lt;<font color="#a52a2a">link</font><font color="#a52a2a">rel</font>="<font color="#0000ff">alternate</font>" <font color="#a52a2a">href</font>="<font color="#0000ff">imagegallery\media.xml</font>" <font color="#a52a2a">type</font>="<font color="#0000ff">application/rss+xml</font>"
/&gt; 
</p>
        <h4>Automatic generation of Media RSS
</h4>
I have included a download of an application to generate all the files necessary to
implement Media RSS on a site. This is an update to an <a title="Focas.net.ImageGallery" href="http://blog.focas.net.au/2008/05/17/ImageGalleryUsingMetadata.aspx" target="_blank">earlier
application</a> called Focas.net.ImageGallery. This application creates a <a href="http://mootools.net/" target="_blank">MooTools</a>/<a href="http://www.prototypejs.org/" target="_blank">Prototype</a> image
gallery. This update adds a Media RSS file and appropriate link to it. The download
link is below. The information describing the images is extracted from the image itself.
There is an earlier blog entry describing how this is done, or you can also refer
to the metadata section below. 
<h4><br />
Using the application
</h4><p>
To use the application, you need to start the application and do the following:
</p><p><img src="http://blog.focas.net.au/content/binary/ImageGalleryMediaRss.png" border="0" /></p><ul><li>
Choose the image directory<br /><strong>Note: </strong>Only images of type <strong>jpg</strong>,<strong>jpeg</strong>,<strong>gif</strong> and <strong>png</strong> will
be used, and only images in the root of this folder. 
</li><li>
Output directory<br />
Any existing files in this folder will be overwritten. The folder will not be cleared
out first if any files exist. 
</li><li>
Title 
<br />
This will be the title of the page, the heading above the images of the Image Gallery,
and title of the Media RSS feed. 
</li><li>
URL 
<br />
This is optional. If you want to put the files up on a web server then this would
be the path up to where you put the gallery. If you omit it, then the paths to images
will be relative. This may result in feed validators claiming the feed is invalid,
but it will work anyway. It is worth leaving this blank For the first attempt, so
that you can see what the gallery looks like from the local file system. 
</li><li>
Folder for images 
<br />
This is the name of the folder where the actual pictures will be stored. The default
if empty will be <em>pictures</em>. 
</li></ul><p>
Once you click <strong>Make the gallery!</strong> all the necessary files will be
created, and automatically displayed in internet Explorer. Note that the images will
not work properly in PicLens if an URL was specified as the paths are absolute
URL's. The files are now ready to upload to your web server.
</p><h4>A note about metadata and troubleshooting
</h4><p>
Metadata is data describing something. In this case, describing the images. This metadata
is extracted from the images themselves. If using Windows Vosta then this information
is easily entered via Windows Explorer or the standard picture viewer application.
On previous versions of Windows, you can download the <a href="http://www.microsoft.com/prophoto/downloads/tools.aspx" target="_blank">Microsoft
Pro Photo tools</a>, a free download from the Microsoft site. If you have no metadata
for your images, then the application will still generate a Media RSS file, but it
is better to use some metadata.
</p><h4>Additional resources
</h4><p><a href="http://www.piclens.com/lite/webmasterguide.php" target="_blank">PicLens WebMasters
guide</a><br /><a href="http://www.microsoft.com/prophoto/downloads/tools.aspx" target="_blank">Microsoft
Pro Photo Tools</a><br /><a href="http://www.powerset.com/explore/go/Media-RSS" target="_blank">PowerSet Media
RSS links</a></p><h4>Downloads
</h4><p><a href="http://blog.focas.net.au/content/binary/Focas.NET.ImageGalleryWithMRSSSource.zip"><img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0" />Source
code (.NET) (89.9 KB)</a></p><p><a href="http://blog.focas.net.au/content/binary/Focas.NET.ImageGallery.exe"><img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0" />Executable(140.5
KB)</a></p><img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=829b7581-94c5-479e-ac17-7e66d34fac8b" /><br /><hr /><script type="text/javascript"><!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></body>
      <title>Media RSS (MRSS) and PicLens support in a web page</title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,829b7581-94c5-479e-ac17-7e66d34fac8b.aspx</guid>
      <link>http://blog.focas.net.au/2008/08/12/MediaRSSMRSSAndPicLensSupportInAWebPage.aspx</link>
      <pubDate>Tue, 12 Aug 2008 13:18:03 GMT</pubDate>
      <description>&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a title="Media RSS" href="http://search.yahoo.com/mrss" target="_blank"&gt;Media RSS&lt;/a&gt; (MRSS)
is an XML format which extends the &lt;a title="Really Simple Syndication" href="http://www.powerset.com/explore/go/rss" target="_blank"&gt;RSS&lt;/a&gt; format.
By using this format, a website can be enabled to provide rich media functionality.
This can be used for images, audio and video. This entry discusses enabling Media
RSS for images. Video is very easy to implement, but will not be discussed here. By
using &lt;a title="PicLens media RSS browser extension" href="http://www.piclens.com/" target="_blank"&gt;PicLens&lt;/a&gt; in
Firefox, the result looks like below. It is very fast, full screen, and has nice facilities
to scroll around the images, zoom in and out and other such things. Here I will discuss
a simple implementation, and you can scroll below to download a small .NET application
to automate this process. If you already have a Media RSS viewing application, then &lt;a href="http://blog.focas.net.au/imagegallery/" target="_blank"&gt;check
out an example of the output&lt;/a&gt; (Note, copyright links were added after the page
was generated).
&lt;/p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/PicLens.png" style="float: left;" border="0"&gt; 
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;h4&gt;How to implement Media RSS
&lt;/h4&gt;
&lt;p&gt;
The Media RSS format is very simple, it only requires the addition of two namespaces
to an RSS feed, and two elements within that namespace. The namespaces are:&lt;br&gt;
&lt;br&gt;
&lt;span class="attribute-value"&gt;&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;xmlns:atom=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"http://www.w3.org/2005/Atom"&lt;/span&gt;
&lt;br&gt;
xmlns:media=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;&lt;a href="http://search.yahoo.com/mrss/"&gt;http://search.yahoo.com/mrss/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;br&gt;
The elements&amp;nbsp;that need to be added are: 
&lt;br&gt;
&lt;span class="attribute-value"&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="font-size: 11px; color: black; font-family: Courier New; background-color: transparent;"&gt;&amp;lt;media:thumbnail
url=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"path_to_image_thumbnail"&lt;/span&gt; /&amp;gt;&lt;br&gt;
&amp;lt;media:content url=&lt;span style="font-size: 11px; color: rgb(102, 102, 102); font-family: Courier New; background-color: rgb(228, 228, 228);"&gt;"path_to_image"&lt;/span&gt; /&amp;gt;&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
The URL's can should be absolute URL's to validate in feed validation systems, although
it will still work if you use relative URL's. The &lt;strong&gt;thumbnail&lt;/strong&gt; element
should be used, but&amp;nbsp;if you don't have a separate thumbnail&amp;nbsp;image you can
just point it at the same as the full size image. It would be worthwhile to use a
thumbnail as you will save bandwidth and probably please your viewers with a more
responsive experience.
&lt;/p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/raspberries.png" style="float: left;" width="425" border="0" height="397"&gt; 
&lt;p&gt;
The last thing to do is to include a link to the feed on the page where you want to
display it. This points to the Media RSS feed you created earlier. The Media R
&lt;/p&gt;
&lt;p&gt;
SS feed can exist anywhere in your site, just make sure you point to it in the page
where you want the feed discovered.
&lt;/p&gt;
&lt;p&gt;
&amp;lt;&lt;font color="#a52a2a"&gt;link&lt;/font&gt; &lt;font color="#a52a2a"&gt;rel&lt;/font&gt;="&lt;font color="#0000ff"&gt;alternate&lt;/font&gt;" &lt;font color="#a52a2a"&gt;href&lt;/font&gt;="&lt;font color="#0000ff"&gt;imagegallery\media.xml&lt;/font&gt;" &lt;font color="#a52a2a"&gt;type&lt;/font&gt;="&lt;font color="#0000ff"&gt;application/rss+xml&lt;/font&gt;"
/&amp;gt; 
&lt;/p&gt;
&lt;h4&gt;Automatic generation of Media RSS
&lt;/h4&gt;
I have included a download of an application to generate all the files necessary to
implement Media RSS on a site. This is an update to an &lt;a title="Focas.net.ImageGallery" href="http://blog.focas.net.au/2008/05/17/ImageGalleryUsingMetadata.aspx" target="_blank"&gt;earlier
application&lt;/a&gt; called Focas.net.ImageGallery. This application creates a &lt;a href="http://mootools.net/" target="_blank"&gt;MooTools&lt;/a&gt;/&lt;a href="http://www.prototypejs.org/" target="_blank"&gt;Prototype&lt;/a&gt; image
gallery. This update adds a Media RSS file and appropriate link to it. The download
link is below. The information describing the images is extracted from the image itself.
There is an earlier blog entry describing how this is done, or you can also refer
to the metadata section below. 
&lt;h4&gt;
&lt;br&gt;
Using the application
&lt;/h4&gt;
&lt;p&gt;
To use the application, you need to start the application and do the following:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/ImageGalleryMediaRss.png" border="0"&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Choose the image directory&lt;br&gt;
&lt;strong&gt;Note: &lt;/strong&gt;Only images of type &lt;strong&gt;jpg&lt;/strong&gt;,&lt;strong&gt;jpeg&lt;/strong&gt;,&lt;strong&gt;gif&lt;/strong&gt; and &lt;strong&gt;png&lt;/strong&gt; will
be used, and only images in the root of this folder. 
&lt;/li&gt;
&lt;li&gt;
Output directory&lt;br&gt;
Any existing files in this folder will be overwritten. The folder will not be cleared
out first if any files exist. 
&lt;/li&gt;
&lt;li&gt;
Title 
&lt;br&gt;
This will be the title of the page, the heading above the images of the Image Gallery,
and title of the Media RSS feed. 
&lt;/li&gt;
&lt;li&gt;
URL 
&lt;br&gt;
This is optional. If you want to put the files up on a web server then this would
be the path up to where you put the gallery. If you omit it, then the paths to images
will be relative. This may result in feed validators claiming the feed is invalid,
but it will work anyway. It is worth leaving this blank For the first attempt, so
that you can see what the gallery looks like from the local file system. 
&lt;/li&gt;
&lt;li&gt;
Folder for images 
&lt;br&gt;
This is the name of the folder where the actual pictures will be stored. The default
if empty will be &lt;em&gt;pictures&lt;/em&gt;. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Once you click &lt;strong&gt;Make the gallery!&lt;/strong&gt; all the necessary files will be
created, and automatically displayed in internet Explorer. Note that the images will
not work properly in PicLens&amp;nbsp;if an URL was specified as the paths are absolute
URL's. The files are now ready to upload to your web server.
&lt;/p&gt;
&lt;h4&gt;A note about metadata and troubleshooting
&lt;/h4&gt;
&lt;p&gt;
Metadata is data describing something. In this case, describing the images. This metadata
is extracted from the images themselves. If using Windows Vosta then this information
is easily entered via Windows Explorer or the standard picture viewer application.
On previous versions of Windows, you can download the &lt;a href="http://www.microsoft.com/prophoto/downloads/tools.aspx" target="_blank"&gt;Microsoft
Pro Photo tools&lt;/a&gt;, a free download from the Microsoft site. If you have no metadata
for your images, then the application will still generate a Media RSS file, but it
is better to use some metadata.
&lt;/p&gt;
&lt;h4&gt;Additional resources
&lt;/h4&gt;
&lt;p&gt;
&lt;a href="http://www.piclens.com/lite/webmasterguide.php" target="_blank"&gt;PicLens WebMasters
guide&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://www.microsoft.com/prophoto/downloads/tools.aspx" target="_blank"&gt;Microsoft
Pro Photo Tools&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://www.powerset.com/explore/go/Media-RSS" target="_blank"&gt;PowerSet Media
RSS links&lt;/a&gt;
&lt;/p&gt;
&lt;h4&gt;Downloads
&lt;/h4&gt;
&lt;p&gt;
&lt;a href="http://blog.focas.net.au/content/binary/Focas.NET.ImageGalleryWithMRSSSource.zip"&gt;&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0"&gt;Source
code (.NET) (89.9 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.focas.net.au/content/binary/Focas.NET.ImageGallery.exe"&gt;&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0"&gt;Executable(140.5
KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=829b7581-94c5-479e-ac17-7e66d34fac8b" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,829b7581-94c5-479e-ac17-7e66d34fac8b.aspx</comments>
      <category>Downloads</category>
      <category>JavaScript</category>
      <category>Metadata</category>
      <category>Programming</category>
      <category>Webmaster</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=e5f86a91-8dab-4162-9289-87a1e378202e</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,e5f86a91-8dab-4162-9289-87a1e378202e.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,e5f86a91-8dab-4162-9289-87a1e378202e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=e5f86a91-8dab-4162-9289-87a1e378202e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I have been doing some work with the excellent <a href="http://moodle.org/" target="_blank">Moodle</a>,
an open source <a href="http://www.powerset.com/explore/go/learning-management-system" target="_blank">Learning
Management System</a>, and after doing an upgrade, started experiencing problems uploading <a href="http://www.adlnet.gov/scorm/index.aspx" target="_blank">SCORM </a>objects.
The specific errors I was getting <i>were <b>PCLZIP_ERR_BAD_FORMAT (-10) : Unable
to find End of Central Dir Record signature</b></i>, and <b><i>An error occurs during
package unzip</i></b> (sic). After a lot of searching, it seemed a few people were
having similar issues, and mostly it seems Internet Explorer was being blamed. Perhaps
there is also a problem with Internet Explorer, however in my case, I ended up working
out where Moodle stores the files on the server and inspected the folder. The file
was corrupt, I couldn't download the zip file.<br /><br />
After trying to manually upload the files I discovered that the disk quota had been
exceeded. After doing a cleanup of the disk, everything worked well.<br /><br />
Sometimes when searching for the cause of a problem some facts eclipse our abilities
to be a little objective about the true nature of the problem. In my case it seemed
clear that the problem occurred as soon as I upgraded, when in reality the cause was
my making a backup on a full server. This could have been avoided in a few ways. Firstly
I should keep an eye on the server quotas, that should have been a give away. However,
I think the Moodle developers should have caught an IO exception when the disk was
full, and reported back to the browser. This would have saved a lot of time. Having
said that, I am very impressed with Moodle, this is just one of those habits that
happen a lot in programming where such potential errors as stack overflow, out of
memory, or IO errors are ignored with an optimistic hope that they should never occur.
With this error, I assume something worse is happening. Because the page didn't crash
with an error, I can only assume the error was swallowed, and thus vital helpful information
was never presented on the web page.<br /><br />
As soon as I have caught up with this work I will look at the code and see if I can
offer a bug fix.<br /><br /><b>Update:</b> I have also experienced problems doing a course backup, with the same
root cause, not enough disk space. When doing the course backup, the messages received
are <b>An error occurred while backing up course start </b>and <b>An error occurred
while copying the zip file to the course directory</b>. After looking at the code,
it appears the Moodle error handling only looks for 4 types of IO errors. PHP 5 has
7 types, I believe it is the type 7 error that would cause this. Unfortunately the
error trapping routine has a default handler for unknown error types.<br /><p></p><img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=e5f86a91-8dab-4162-9289-87a1e378202e" /><br /><hr /><script type="text/javascript"><!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></body>
      <title>Moodle file upload and SCORM problems</title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,e5f86a91-8dab-4162-9289-87a1e378202e.aspx</guid>
      <link>http://blog.focas.net.au/2008/07/30/MoodleFileUploadAndSCORMProblems.aspx</link>
      <pubDate>Wed, 30 Jul 2008 06:24:06 GMT</pubDate>
      <description>I have been doing some work with the excellent &lt;a href="http://moodle.org/" target="_blank"&gt;Moodle&lt;/a&gt;,
an open source &lt;a href="http://www.powerset.com/explore/go/learning-management-system" target="_blank"&gt;Learning
Management System&lt;/a&gt;, and after doing an upgrade, started experiencing problems uploading &lt;a href="http://www.adlnet.gov/scorm/index.aspx" target="_blank"&gt;SCORM &lt;/a&gt;objects.
The specific errors I was getting &lt;i&gt;were &lt;b&gt;PCLZIP_ERR_BAD_FORMAT (-10) : Unable
to find End of Central Dir Record signature&lt;/b&gt;&lt;/i&gt;, and &lt;b&gt;&lt;i&gt;An error occurs during
package unzip&lt;/i&gt;&lt;/b&gt; (sic). After a lot of searching, it seemed a few people were
having similar issues, and mostly it seems Internet Explorer was being blamed. Perhaps
there is also a problem with Internet Explorer, however in my case, I ended up working
out where Moodle stores the files on the server and inspected the folder. The file
was corrupt, I couldn't download the zip file.&lt;br&gt;
&lt;br&gt;
After trying to manually upload the files I discovered that the disk quota had been
exceeded. After doing a cleanup of the disk, everything worked well.&lt;br&gt;
&lt;br&gt;
Sometimes when searching for the cause of a problem some facts eclipse our abilities
to be a little objective about the true nature of the problem. In my case it seemed
clear that the problem occurred as soon as I upgraded, when in reality the cause was
my making a backup on a full server. This could have been avoided in a few ways. Firstly
I should keep an eye on the server quotas, that should have been a give away. However,
I think the Moodle developers should have caught an IO exception when the disk was
full, and reported back to the browser. This would have saved a lot of time. Having
said that, I am very impressed with Moodle, this is just one of those habits that
happen a lot in programming where such potential errors as stack overflow, out of
memory, or IO errors are ignored with an optimistic hope that they should never occur.
With this error, I assume something worse is happening. Because the page didn't crash
with an error, I can only assume the error was swallowed, and thus vital helpful information
was never presented on the web page.&lt;br&gt;
&lt;br&gt;
As soon as I have caught up with this work I will look at the code and see if I can
offer a bug fix.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Update:&lt;/b&gt; I have also experienced problems doing a course backup, with the same
root cause, not enough disk space. When doing the course backup, the messages received
are &lt;b&gt;An error occurred while backing up course start &lt;/b&gt;and &lt;b&gt;An error occurred
while copying the zip file to the course directory&lt;/b&gt;. After looking at the code,
it appears the Moodle error handling only looks for 4 types of IO errors. PHP 5 has
7 types, I believe it is the type 7 error that would cause this. Unfortunately the
error trapping routine has a default handler for unknown error types.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=e5f86a91-8dab-4162-9289-87a1e378202e" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,e5f86a91-8dab-4162-9289-87a1e378202e.aspx</comments>
      <category>Moodle</category>
      <category>Programming</category>
      <category>Webmaster</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=e6b1e987-2119-4505-935d-90f9ac2ab015</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,e6b1e987-2119-4505-935d-90f9ac2ab015.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,e6b1e987-2119-4505-935d-90f9ac2ab015.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=e6b1e987-2119-4505-935d-90f9ac2ab015</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Continuing from a <a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx">previous
post</a> in which I added a Google Map of the visitors to my blog, this post will
discuss how to take the same information and present it in a <a title="Visifire Silverlight component" href="http://www.visifire.com/" target="_blank">Visifire</a> chart.
Visifire is an open source Silverlight charting component which is very easy
to use and well documented.
</p>
        <p>
          <img src="http://blog.focas.net.au/content/binary/chart.png" />
          <br />
          <font color="#008000" size="1">Figure 1 - An example of the Visifire Silverlight chart
tracking visitors</font>
        </p>
        <p>
This post will use the same component from the previous post, the <strong>VisitorsBox.ascx</strong>,
and modify the code that retrieves the location of the visitor, and add some javascript
to render the chart.
</p>
        <p>
First, a JavaScript array is declared which will hold the location information received
by the IPHost web site:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> cities=new <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Array</span>(); 
<br /></p>
        <p>
This array will have items pushed into it once they are retrireved:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">cities.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">push</span>(new <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Array</span>(location,
addresses[x][1]));</span>
        </pre>
        <p>
Once again, the code that actually calls the HTML page with the location information
is covered in the <a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx">earlier
post</a>.
</p>
        <p>
After the Google Map is populated, the Visifire chart is prepared. To create the Visifire
chart we need to do the following:
</p>
        <ul>
          <li>
Add some HTML code into <strong>VisitorsBox.ascx</strong></li>
          <li>
Add the <strong>Visifire.js</strong> and <strong>Visifire.xap</strong> (SilverLight
binary) files to the web server 
</li>
          <li>
Dynamically create an XML file to feed to the <strong>Visifire.xap</strong> component 
</li>
          <li>
in the JavaScript, create a new <strong>Visifre</strong> object 
</li>
          <li>
Call the <strong>Visifire</strong> object's <strong>setDataXml </strong>method, passing
the XML data in 
</li>
          <li>
Call the <strong>Visifire</strong> objects <strong>render</strong> method, passing
in the id of the HTML layer that the chart is to be rendered to. 
</li>
        </ul>
        <p>
The HTML code is straightforward, just a layer with an <strong>id </strong>attribute:
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;div
id=</span>
          <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"VisifireChart"</span>&gt;&lt;/div&gt;</pre>
        <p>
The <strong>Visifire.js</strong> can be copied wherever you want, altho the <strong>scripts </strong>folder
seems an obvious candidate. The <strong>Visifre.xap</strong> file can go in the bin
folder. 
</p>
        <p>
To create the XML, I have just concatenated a large string. Where it requires the
data, I loop thru the <strong>cities</strong> array and populate the relevant information.
Note this is C# code writing out a JavaScript block. Here is the header part of the
XML string: 
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function
chart() { var chartXmlString <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> '' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;vc:Chart
xmlns:vc=\'clr-<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">namespace</span>:Visifire.Charts;assembly=Visifire.Charts\'' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'
Width=\'500\' Height=\'300\' BorderThickness=\'0\' Theme=\'Theme3\' '; <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'LightingEnabled=\'False\'
ColorSet=\'Picasso\' AnimationType=\'Type5\'&gt;' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;vc:Title
Text=\'Visitors by location\'/&gt;' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;vc:AxisX
Title=\'blog.focas.net.au\'&gt;' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;/vc:AxisX&gt;' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;vc:AxisY
Title=\'Visitors\'&gt;' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;/vc:AxisY&gt;&lt;vc:DataSeries
Name <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> \'Series1\'
RenderAs=\'Column\'&gt;';</span>
        </pre>
        <p>
Now, to create the data points:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> (var
x=0;x&lt;cities.length;x++) {<br />
    chartXmlString+= '&lt;vc:DataPoint AxisLabel=\'' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> cities[x][0] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> '\'
YValue=\'' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> cities[x][1] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> '\'/&gt;';<br />
} 
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana">And
close the XML string off:</font>
            <font face="Verdana">
              <br />
            </font>
            <br />
chartXmlString+='&lt;/vc:DataSeries&gt;'<br />
    <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span>'&lt;/vc:Chart&gt;';</span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana">The
following JavaScript code creates the chart, loads the data and renders the chart:</font>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var
vChart <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Visifire('Visifire.xap',500,300);<br />
vChart.setDataXml(chartXmlString);<br />
vChart.render('VisifireChart');</span>
        </p>
        <p>
And thats all there is to it. As in the previous example, if you take the client side
approach, then you have cross site scripting issues. So the site will need to be added
to a trusted zone. If this is not suitable then you will need to run the code on the
server that retrieves the locations. 
</p>
        <h5>Download instructions
</h5>
        <p>
The instructions for installing this page are in the <a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx">earlier
post</a> Please remember that <font color="#ff0000">In order to view the example
for this, you would have to add </font><a title="focas.net blog" href="http://blog.focas.net.au/ct.ashx?id=027f9829-074e-40bd-bf9a-b2d4b6188c63&amp;url=http%3a%2f%2fblog.focas.net.au"><font color="#ff0000" size="1"><strong>http://blog.focas.net.au</strong></font></a><font color="#ff0000"> to
your trusted zones in Internet Explorer.</font></p>
        <p>
          <img src="http://blog.focas.net.au/content/binary/Download_32.png" />
          <a href="http://blog.focas.net.au/content/binary/visifire.zip">visifire.zip
(11.06 KB)</a>
        </p>
        <img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=e6b1e987-2119-4505-935d-90f9ac2ab015" />
        <br />
        <hr />
        <script type="text/javascript">
          <!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </body>
      <title>Using VisiFire to create a Silverlight chart of your visitors in dasBlog </title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,e6b1e987-2119-4505-935d-90f9ac2ab015.aspx</guid>
      <link>http://blog.focas.net.au/2008/06/26/UsingVisiFireToCreateASilverlightChartOfYourVisitorsInDasBlog.aspx</link>
      <pubDate>Thu, 26 Jun 2008 13:15:30 GMT</pubDate>
      <description>&lt;p&gt;
Continuing from a &lt;a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx"&gt;previous
post&lt;/a&gt; in which I added a Google Map of the visitors to my blog, this post will
discuss how to take the same information and present it in a &lt;a title="Visifire Silverlight component" href="http://www.visifire.com/" target=_blank&gt;Visifire&lt;/a&gt; chart.
Visifire is an open source Silverlight charting component&amp;nbsp;which is very easy
to use and well documented.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/chart.png"&gt;
&lt;br&gt;
&lt;font color=#008000 size=1&gt;Figure 1 - An example of the Visifire Silverlight chart
tracking visitors&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This post will use the same component from the previous post, the &lt;strong&gt;VisitorsBox.ascx&lt;/strong&gt;,
and modify the code that retrieves the location of the visitor, and add some javascript
to render the chart.
&lt;/p&gt;
&lt;p&gt;
First, a JavaScript array is declared which will hold the location information received
by the IPHost web site:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; cities=new &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Array&lt;/span&gt;(); 
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
This array will have items pushed into it once they are retrireved:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;cities.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;push&lt;/span&gt;(new &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Array&lt;/span&gt;(location,
addresses[x][1]));&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Once again, the code that actually calls the HTML page with the location information
is covered in the &lt;a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx"&gt;earlier
post&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
After the Google Map is populated, the Visifire chart is prepared. To create the Visifire
chart we need to do the following:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Add some HTML code into &lt;strong&gt;VisitorsBox.ascx&lt;/strong&gt; 
&lt;li&gt;
Add the &lt;strong&gt;Visifire.js&lt;/strong&gt; and &lt;strong&gt;Visifire.xap&lt;/strong&gt; (SilverLight
binary) files to the web server 
&lt;li&gt;
Dynamically create an XML file to feed to the &lt;strong&gt;Visifire.xap&lt;/strong&gt; component 
&lt;li&gt;
in the JavaScript, create a new &lt;strong&gt;Visifre&lt;/strong&gt; object 
&lt;li&gt;
Call the &lt;strong&gt;Visifire&lt;/strong&gt; object's &lt;strong&gt;setDataXml &lt;/strong&gt;method, passing
the XML data in 
&lt;li&gt;
Call the &lt;strong&gt;Visifire&lt;/strong&gt; objects &lt;strong&gt;render&lt;/strong&gt; method, passing
in the id of the HTML layer that the chart is to be rendered to. 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The HTML code is straightforward, just a layer with an &lt;strong&gt;id &lt;/strong&gt;attribute:
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;div
id=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"VisifireChart"&lt;/span&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/pre&gt;
&lt;p&gt;
The &lt;strong&gt;Visifire.js&lt;/strong&gt; can be copied wherever you want, altho the &lt;strong&gt;scripts &lt;/strong&gt;folder
seems an obvious candidate. The &lt;strong&gt;Visifre.xap&lt;/strong&gt; file can go in the bin
folder. 
&lt;/p&gt;
&lt;p&gt;
To create the XML, I have just concatenated a large string. Where it requires the
data, I loop thru the &lt;strong&gt;cities&lt;/strong&gt; array and populate the relevant information.
Note this is C# code writing out a JavaScript block. Here is the header part of the
XML string: 
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function
chart() { var chartXmlString &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; '' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;vc:Chart
xmlns:vc=\'clr-&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt;:Visifire.Charts;assembly=Visifire.Charts\'' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'
Width=\'500\' Height=\'300\' BorderThickness=\'0\' Theme=\'Theme3\' '; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'LightingEnabled=\'False\'
ColorSet=\'Picasso\' AnimationType=\'Type5\'&amp;gt;' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;vc:Title
Text=\'Visitors by location\'/&amp;gt;' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;vc:AxisX
Title=\'blog.focas.net.au\'&amp;gt;' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;/vc:AxisX&amp;gt;' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;vc:AxisY
Title=\'Visitors\'&amp;gt;' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;/vc:AxisY&amp;gt;&amp;lt;vc:DataSeries
Name &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; \'Series1\'
RenderAs=\'Column\'&amp;gt;';&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Now, to create the data points:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; (var
x=0;x&amp;lt;cities.length;x++) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; chartXmlString+= '&amp;lt;vc:DataPoint AxisLabel=\'' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; cities[x][0] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; '\'
YValue=\'' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; cities[x][1] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; '\'/&amp;gt;';&lt;br&gt;
} 
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana&gt;And
close the XML string off:&lt;/font&gt;&lt;font face=Verdana&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
chartXmlString+='&amp;lt;/vc:DataSeries&amp;gt;'&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;'&amp;lt;/vc:Chart&amp;gt;';&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana&gt;The
following JavaScript code creates the chart, loads the data and renders the chart:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var
vChart &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Visifire('Visifire.xap',500,300);&lt;br&gt;
vChart.setDataXml(chartXmlString);&lt;br&gt;
vChart.render('VisifireChart');&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
And thats all there is to it. As in the previous example, if you take the client side
approach, then you have cross site scripting issues. So the site will need to be added
to a trusted zone. If this is not suitable then you will need to run the code on the
server that retrieves the locations. 
&lt;/p&gt;
&lt;h5&gt;Download instructions
&lt;/h5&gt;
&lt;p&gt;
The instructions for installing this page are in the &lt;a title="Where are your blog visitors coming from in DasBlog?" href="http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx"&gt;earlier
post&lt;/a&gt;&amp;nbsp;Please remember that &lt;font color=#ff0000&gt;In order to view the example
for this, you would have to add &lt;/font&gt;&lt;a title="focas.net blog" href="http://blog.focas.net.au/ct.ashx?id=027f9829-074e-40bd-bf9a-b2d4b6188c63&amp;amp;url=http%3a%2f%2fblog.focas.net.au"&gt;&lt;font color=#ff0000 size=1&gt;&lt;strong&gt;http://blog.focas.net.au&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;&lt;font color=#ff0000&gt; to
your trusted zones in Internet Explorer.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png"&gt;&lt;a href="http://blog.focas.net.au/content/binary/visifire.zip"&gt;visifire.zip
(11.06 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=e6b1e987-2119-4505-935d-90f9ac2ab015" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,e6b1e987-2119-4505-935d-90f9ac2ab015.aspx</comments>
      <category>dasBlog</category>
      <category>Downloads</category>
      <category>JavaScript</category>
      <category>Webmaster</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=6033c5f7-5ff4-4d17-84a6-7bee6c597238</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,6033c5f7-5ff4-4d17-84a6-7bee6c597238.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,6033c5f7-5ff4-4d17-84a6-7bee6c597238.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=6033c5f7-5ff4-4d17-84a6-7bee6c597238</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A project I developed called for context sensitive dynamic help inside of Microsoft
Word, based on the current cursor location. The idea was that if the cursor is on
an image, then help information would be presented regarding the business rules pertaining
to images. I.E. what size can the image be, policies regarding alternative text for
web publishing etc. To achieve this there were two components. One was a Quality Assurance
component to check for conformance to business rules. The other was the dynamic help
system. I present a whittled down version of the help system here. The Quality
Assurance component will be discussed in a future entry. There is everything necessary
to implement this as a full fledged context sensitive dynamic help system. The help
information is presented in a custom task pane, and uses HTML.
</p>
        <p>
          <img src="http://blog.focas.net.au/content/binary/helpPanel.png" border="0" />
          <br />
          <font color="#9acd32" size="1">Figure 1 -Word 2007 showing the Context sensitive dynamic
help system</font>
        </p>
        <h5>Architecture
</h5>
        <p>
This solution uses three main components:
</p>
        <ul>
          <li>
The VSTO addin 
</li>
          <li>
A <strong>MessageBroker</strong> which receives events from the VSTO addin 
</li>
          <li>
The <strong>Help UserControl </strong>which consumes events from the <strong>MesageBroker</strong></li>
        </ul>
        <p>
This centralised messaging architecture is beneficial when other components are introduced
such as the <strong>QualityAssurance </strong>component referred to earlier.
The VSTO Addin wouldn't need to be changed, the <strong>MessageBroker</strong>, the <strong>QualityAssurance</strong> component
would subscribe as listeners for the events raised by the <strong>MessageBroker</strong>.
Another advantage of this approach is that security and logging would be easily implemented
in the one location.
</p>
        <p>
So, when the Addin loads, the <strong>WindowSelectionChanged</strong> event is subscribed
to by the addin.<br /></p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>
          <font face="Courier New">
            <font color="#000000">.Application.WindowSelectionChange+= </font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>
          </font>
          <font face="Courier New" color="#000000"> Microsoft.Office.Interop.Word.ApplicationEvents4_WindowSelectionChangeEventHandler(<br />
   Application_WindowSelectionChange);<br /></font>
          <font color="#000000">
            <br />
It would be possible for the <strong>Help UserControl</strong> to subscribe directly,
but by doing it this way we can define a few rules around what events get triggered,
and also cache the current style so that the event is not consumed by every registered
listener every time the cursor moves even though the style hasn't changed.</font>
          <br />
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Application_WindowSelectionChange(Microsoft.Office.Interop.Word.Selection
Sel) {<br />
     Word.Style style <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> (Word.Style)Sel.get_Style();<br />
     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (!
style.NameLocal.Equals(_currentStyle)) {<br />
        _currentStyle <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> style.NameLocal;<br />
        _messageBroker.Publish(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">typeof</span>(MessageEventArgs),
Sel.Paragraphs[1], style);<br />
     }<br />
}</span>
        </p>
        <p>
          <font color="#000000">Note in this code how it is important to retrieve an instance
of the style object and cast it to type <em>Word.Style</em>. This is COM Interop in
Word. It would be possible to write an extension method to get around this, but I
don't think its necessary for this example.</font>
        </p>
        <p>
The constructor for the <strong>Help UserControl</strong> accepts an instance of the <strong>MessageBroker.
Note</strong>: I should probably make this class a Singleton.
</p>
        <p>
The <strong>Help UserControl</strong> receives event notifications when the current
style has changed. It loads a web browser control and loads an HTML page named after
the style. if no page exists for that style, it will display a default help page.
There is a tabbed interface, with an <strong>Info</strong><em></em>and a<em></em><strong>Help </strong>tab.
The <strong>Help</strong> tab has not been implemented, the idea was to provide links
to examples.
</p>
        <p>
I have only included stripped down versions of HTML pages for three styles:
</p>
        <ul>
          <li>
Heading 1 
</li>
          <li>
Heading 2 
</li>
          <li>
Heading 3 
</li>
        </ul>
        <p>
It is simply a matter of creating a page witht the style name, and an extension of <strong>.html</strong> and
dropping it in the help folder. The code that loads the page looks like this:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private </span>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span>
          <font face="Courier New">
            <font color="#000000"> LoadHelpIntoBrowser(</font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> currentStyle)
{<br />
    String helpFilePath </font>
            <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> CreateHelpFilePath(currentStyle);<br />
    </font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> (File.Exists(helpFilePath))
{<br />
       webInfo.Navigate(helpFilePath);<br />
    } </font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> {<br />
       LoadHelpHomePage();<br />
    }<br />
}<br /><br /></font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private </span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> LoadHelpHomePage()
{<br /></font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   string</span>
            <font color="#000000"> p </font>
            <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> Path.Combine(Path.GetDirectoryName(<br />
   System.Reflection.Assembly.GetExecutingAssembly().CodeBase), </font>
            <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"..\\..\\help"</span>
          </font>
          <font face="Courier New">
            <font color="#000000">);<br />
   String helpFilePath </font>
            <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span>
            <font color="#000000"> CreateHelpFilePath(</font>
            <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"WordJester"</span>
          </font>
          <font face="Courier New">
            <font color="#000000">);<br />
   webInfo.Navigate(helpFilePath);<br />
}<br /><br /></font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
          </font>
          <font face="Courier New">
            <font color="#000000"> String
CreateHelpFilePath(String style) {<br />
   Uri baseUri </font>
            <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span>
            <font color="#000000"> Uri(<br />
      Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase));<br />
   </font>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span>
            <font color="#000000"> String.Format(</font>
            <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"{0}{1}..{1}..{1}help{1}{2}.html"</span>
          </font>
          <font face="Courier New" color="#000000">,
baseUri.LocalPath,<br />
         Path.DirectorySeparatorChar,
style);<br />
}</font>
        </p>
        <p>
The beauty of this approach is that you can add in as many styles as required, even
non standard styles, and as long as a help file exists, it will be displayed. The
file names will look like this:<br /></p>
        <p>
          <img src="http://blog.focas.net.au/content/binary/filenames.png" border="0" />
          <br />
          <font color="#9acd32" size="1">Figure 2 - file names for the HYML pages based upon
the word style name</font>
        </p>
        <p>
          <font color="#000000">Run the solution, and try creating some heading levels 1, 2
and 3, and move the cursor between them and check out the help in the custom task
pane change.</font> Let me know what you think of this application.
</p>
        <p>
          <a href="http://blog.focas.net.au/content/binary/WordJester.zip">
            <img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0" />WordJester.zip
(224.21 KB)</a>
        </p>
        <img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=6033c5f7-5ff4-4d17-84a6-7bee6c597238" />
        <br />
        <hr />
        <script type="text/javascript">
          <!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </body>
      <title>VSTO solution for context sensitive dynamic help in Word 2007 </title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,6033c5f7-5ff4-4d17-84a6-7bee6c597238.aspx</guid>
      <link>http://blog.focas.net.au/2008/06/19/VSTOSolutionForContextSensitiveDynamicHelpInWord2007.aspx</link>
      <pubDate>Thu, 19 Jun 2008 12:37:37 GMT</pubDate>
      <description>&lt;p&gt;
A project I developed called for context sensitive dynamic help inside of Microsoft
Word, based on the current cursor location. The idea was that if the cursor is on
an image, then help information would be presented regarding the business rules pertaining
to images. I.E. what size can the image be, policies regarding alternative text for
web publishing etc. To achieve this there were two components. One was a Quality Assurance
component to check for conformance to business rules. The other was the dynamic help
system.&amp;nbsp;I present a whittled down version of the help system here. The Quality
Assurance component will be discussed in a future entry. There is everything necessary
to implement this as a full fledged context sensitive dynamic help system. The help
information is presented in a custom task pane, and uses HTML.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/helpPanel.png" border=0&gt;
&lt;br&gt;
&lt;font color=#9acd32 size=1&gt;Figure 1 -Word 2007 showing the Context sensitive dynamic
help system&lt;/font&gt;
&lt;/p&gt;
&lt;h5&gt;Architecture
&lt;/h5&gt;
&lt;p&gt;
This solution uses three main components:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The VSTO addin 
&lt;li&gt;
A &lt;strong&gt;MessageBroker&lt;/strong&gt; which receives events from the VSTO addin 
&lt;li&gt;
The &lt;strong&gt;Help UserControl &lt;/strong&gt;which consumes events from the &lt;strong&gt;MesageBroker&lt;/strong&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This centralised messaging architecture is beneficial when other components are introduced
such as the&amp;nbsp;&lt;strong&gt;QualityAssurance &lt;/strong&gt;component referred to earlier.
The VSTO Addin wouldn't need to be changed, the &lt;strong&gt;MessageBroker&lt;/strong&gt;, the &lt;strong&gt;QualityAssurance&lt;/strong&gt; component
would subscribe as&amp;nbsp;listeners for the events raised by the &lt;strong&gt;MessageBroker&lt;/strong&gt;.
Another advantage of this approach is that security and logging would be easily implemented
in the one location.
&lt;/p&gt;
&lt;p&gt;
So, when the Addin loads, the &lt;strong&gt;WindowSelectionChanged&lt;/strong&gt; event is subscribed
to by the addin.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;.Application.WindowSelectionChange+= &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New" color=#000000&gt; Microsoft.Office.Interop.Word.ApplicationEvents4_WindowSelectionChangeEventHandler(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Application_WindowSelectionChange);&lt;br&gt;
&lt;/font&gt;&lt;font color=#000000&gt;
&lt;br&gt;
It would be possible for the &lt;strong&gt;Help UserControl&lt;/strong&gt; to subscribe directly,
but by doing it this way we can define a few rules around what events get triggered,
and also cache the current style so that the event is not consumed by every registered
listener every time the cursor moves even though the style hasn't changed.&lt;/font&gt; 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Application_WindowSelectionChange(Microsoft.Office.Interop.Word.Selection
Sel) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Word.Style style &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; (Word.Style)Sel.get_Style();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (!
style.NameLocal.Equals(_currentStyle)) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;_currentStyle &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; style.NameLocal;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _messageBroker.Publish(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/span&gt;(MessageEventArgs),
Sel.Paragraphs[1], style);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Note in this code how it is important to retrieve an instance
of the style object and cast it to type &lt;em&gt;Word.Style&lt;/em&gt;. This is COM Interop in
Word. It would be possible to write an extension method to get around this, but I
don't think its necessary for this example.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The constructor for the &lt;strong&gt;Help UserControl&lt;/strong&gt; accepts an instance of the &lt;strong&gt;MessageBroker.
Note&lt;/strong&gt;: I should probably make this class a Singleton.
&lt;/p&gt;
&lt;p&gt;
The &lt;strong&gt;Help UserControl&lt;/strong&gt; receives event notifications when the current
style has changed. It loads a web browser control and loads an HTML page named after
the style. if no page exists for that style, it will display a default help page.
There is a tabbed interface, with an &lt;strong&gt;Info&lt;/strong&gt;&lt;em&gt;&lt;/em&gt;and a&lt;em&gt;&lt;/em&gt;&lt;strong&gt;Help &lt;/strong&gt;tab.
The &lt;strong&gt;Help&lt;/strong&gt; tab has not been implemented, the idea was to provide links
to examples.
&lt;/p&gt;
&lt;p&gt;
I have only included stripped down versions of HTML pages for three styles:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Heading 1 
&lt;li&gt;
Heading 2 
&lt;li&gt;
Heading 3 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
It is simply a matter of creating a page witht the style name, and an extension of &lt;strong&gt;.html&lt;/strong&gt; and
dropping it in the help folder. The code that loads the page looks like this:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private &lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; LoadHelpIntoBrowser(&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; currentStyle)
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;String helpFilePath &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; CreateHelpFilePath(currentStyle);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; (File.Exists(helpFilePath))
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;webInfo.Navigate(helpFilePath);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;} &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LoadHelpHomePage();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private &lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; LoadHelpHomePage()
{&lt;br&gt;
&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/span&gt;&lt;font color=#000000&gt; p &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; Path.Combine(Path.GetDirectoryName(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Reflection.Assembly.GetExecutingAssembly().CodeBase), &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"..\\..\\help"&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;String helpFilePath &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;font color=#000000&gt; CreateHelpFilePath(&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"WordJester"&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;webInfo.Navigate(helpFilePath);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; String
CreateHelpFilePath(String style) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Uri baseUri &lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; Uri(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; String.Format(&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"{0}{1}..{1}..{1}help{1}{2}.html"&lt;/span&gt;&lt;/font&gt;&lt;font face="Courier New" color=#000000&gt;,
baseUri.LocalPath,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Path.DirectorySeparatorChar,
style);&lt;br&gt;
}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
The beauty of this approach is that you can add in as many styles as required, even
non standard styles, and as long as a help file exists, it will be displayed. The
file names will look like this:&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/filenames.png" border=0&gt;
&lt;br&gt;
&lt;font color=#9acd32 size=1&gt;Figure 2 - file names for the HYML pages based upon the
word style name&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000&gt;Run the solution, and try creating some heading levels 1, 2 and
3, and move the cursor between them and check out the help in the custom task pane
change.&lt;/font&gt; Let me know what you think of this application.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.focas.net.au/content/binary/WordJester.zip"&gt;&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png" border=0&gt;WordJester.zip
(224.21 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=6033c5f7-5ff4-4d17-84a6-7bee6c597238" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,6033c5f7-5ff4-4d17-84a6-7bee6c597238.aspx</comments>
      <category>Downloads</category>
      <category>VSTO</category>
      <category>Word 2007</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been having the following error occuring a lot in the dasBlog eventlog.<br /></p>
        <blockquote>
          <i>System.Web.HttpException: Validation of viewstate MAC failed. If this
application is hosted by a Web Farm or cluster, ensure that &lt;machineKey&gt; configuration
specifies the same validationKey and validation algorithm. AutoGenerate cannot be
used in a cluster. ---&gt; System.Web.UI.ViewStateException: Invalid viewstate. 
<br /><br /></i>
        </blockquote>
        <p>
As this blog is not hosted on a web farm, I searched high and low, but hadn't found
anyone else reporting the same problem. After some further investigation, I think
I have found the cause. It is always on the <b>CommentView.aspx</b> page. I tried
adding comments in various browsers, and that worked without a hitch. So in frustration
I did what I should have done in the first place, i.e. completely read the error message.
In most instances there was an interesting user agent string such as <b>MRSPUTNIK
1, 5, 0, 19 SW</b>. This is mentioned in a lot of forum entries as a harvester or
scraper. I suspect it is trying to post a spam message on the comments page, but because
it hasn't followed the normal process, it doesn't contain the view state that the
page was accepting. This is almost certainly a bot, and this is why there is no viewstate
to decrypt from a previous page. I also checked the IP address, and port number. The
ip addresses had many forum entries. One example was <b>89.149.205.199</b>. I found
an interesting site called <a title="IPIllion IP address tracing" href="http://www.ipillion.com/" target="_blank">IPillion </a>which
traces IP addresses. So adding that IP address to the url gives <a title="http://www.ipillion.com/?ip=89.149.205.199" href="http://www.ipillion.com/?ip=89.149.205.199" target="_blank">http://www.ipillion.com/?ip=89.149.205.199</a> which
reports this IP address as sending lots of spam comments.<br /><br />
So it seems that dasBlog is sort of preventing the spam comments, altho accidentally.
I hope this entry helps others having the same issue, as I couldn't find anyone using
dasBlog who had the same problem, or had traced it to spammers using bots.<br />
 
</p>
        <p>
        </p>
        <img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e" />
        <br />
        <hr />
        <script type="text/javascript">
          <!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </body>
      <title>dasBlog and the Validation of viewstate MAC failed error</title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e.aspx</guid>
      <link>http://blog.focas.net.au/2008/06/17/dasBlogAndTheValidationOfViewstateMACFailedError.aspx</link>
      <pubDate>Tue, 17 Jun 2008 13:07:26 GMT</pubDate>
      <description>&lt;p&gt;
I have been having the following error occuring a lot in the dasBlog eventlog.&lt;br&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;i&gt;System.Web.HttpException: Validation of viewstate MAC failed. If this
application is hosted by a Web Farm or cluster, ensure that &amp;lt;machineKey&amp;gt; configuration
specifies the same validationKey and validation algorithm. AutoGenerate cannot be
used in a cluster. ---&amp;gt; System.Web.UI.ViewStateException: Invalid viewstate. 
&lt;br&gt;
&lt;br&gt;
&lt;/i&gt;&lt;/blockquote&gt; 
&lt;p&gt;
As this blog is not hosted on a web farm, I searched high and low, but hadn't found
anyone else reporting the same problem. After some further investigation, I think
I have found the cause. It is always on the &lt;b&gt;CommentView.aspx&lt;/b&gt; page. I tried
adding comments in various browsers, and that worked without a hitch. So in frustration
I did what I should have done in the first place, i.e. completely read the error message.
In most instances there was an interesting user agent string such as &lt;b&gt;MRSPUTNIK
1, 5, 0, 19 SW&lt;/b&gt;. This is mentioned in a lot of forum entries as a harvester or
scraper. I suspect it is trying to post a spam message on the comments page, but because
it hasn't followed the normal process, it doesn't contain the view state that the
page was accepting. This is almost certainly a bot, and this is why there is no viewstate
to decrypt from a previous page. I also checked the IP address, and port number. The
ip addresses had many forum entries. One example was &lt;b&gt;89.149.205.199&lt;/b&gt;. I found
an interesting site called &lt;a title="IPIllion IP address tracing" href="http://www.ipillion.com/" target=_blank&gt;IPillion &lt;/a&gt;which
traces IP addresses. So adding that IP address to the url gives &lt;a title=http://www.ipillion.com/?ip=89.149.205.199 href="http://www.ipillion.com/?ip=89.149.205.199" target=_blank&gt;http://www.ipillion.com/?ip=89.149.205.199&lt;/a&gt; which
reports this IP address as sending lots of spam comments.&lt;br&gt;
&lt;br&gt;
So it seems that dasBlog is sort of preventing the spam comments, altho accidentally.
I hope this entry helps others having the same issue, as I couldn't find anyone using
dasBlog who had the same problem, or had traced it to spammers using bots.&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,2ec5b5f5-f1af-45f1-8457-2b5b2f3daf2e.aspx</comments>
      <category>Webmaster</category>
      <category>dasBlog</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=027f9829-074e-40bd-bf9a-b2d4b6188c63</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,027f9829-074e-40bd-bf9a-b2d4b6188c63.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,027f9829-074e-40bd-bf9a-b2d4b6188c63.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=027f9829-074e-40bd-bf9a-b2d4b6188c63</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
See part II of this post <a href="http://blog.focas.net.au/2008/06/26/UsingVisiFireToCreateASilverlightChartOfYourVisitorsInDasBlog.aspx">here</a>.
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
By combining the <a title="Google Maps API" href="http://code.google.com/apis/maps/signup.html" target="_blank">Google
Maps API</a> with an IP address host service such as <a title="HostIP.info home page" href="http://www.hostip.info/" target="_blank">HostIP.info</a>,
it is possible to present a map showing the current visitors to your blog, and to
display them on a map. This implementation shows how to do this for <a href="http://www.dasblog.info/">dasBlog</a>.
The result will look something like this:
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
          <img src="http://blog.focas.net.au/content/binary/blogvisitors.png" border="0" />
        </p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
Notice that the shadow on the marker for the united States is darker, indicating more
hits for that area. Each of the marker icons can be clicked to give location details
and how many hits for that location.
</p>
        <p dir="ltr" style="MARGIN-RIGHT: 0px">
          <img src="http://blog.focas.net.au/content/binary/blogvisitorinfowindow.png" border="0" />
        </p>
        <h5>Client side or server side location determination
</h5>
        <p>
The location of an IP Address can be determined at the server side, or at the client
side. Each has its advantages and disadvantages. A brief but not complete list of
pros and cons is:
</p>
        <ul>
          <li>
Client side 
<ul><li>
Pros 
<ul><li>
No delay in serving the page as the processing is done after the page has been serves
to the client. 
</li><li>
Easy to implement 
</li></ul></li><li>
Cons 
<ul><li>
Requires a call to a web service on a different domain which will cause security concerns 
</li><li>
Does not allow for users to be able to modify what is their perceived location 
</li></ul></li></ul></li>
          <li>
Server side 
<ul><li>
Pros 
<ul><li>
More control as you are not dependent on an external web service 
</li><li>
It is easier to cache results if required 
</li></ul></li><li>
Cons 
<ul><li>
More difficult to implement, especially if you want to keep to the architecture of
the software you are developing for 
</li><li>
You must maintain and update your own databse of IP address ranges and locations 
</li></ul></li></ul></li>
        </ul>
        <h6>The client side solution
</h6>
        <p>
This solution relies on a client side solution, taking advantage of the excellent <a title="Prototype JavaScript Framework home page" href="http://www.prototypejs.org/" target="_blank">Prototype
JavaScript Framework</a>. Further down the track I might possibly change this to a
server side solution, but as it is only for an administrative page it is not so important.
Note that there are security concerns with doing this client side. It is necessary
top make an AJAX call to an external webservice, and this could be malicious, especially
if a site were hacked. <font color="#ff0000">In order to view the example for this,
you would have to add </font><a title="focas.net blog" href="http://blog.focas.net.au"><font color="#ff0000">http://blog.focas.net.au</font></a><font color="#ff0000"> to
your trusted zones in Internet Explorer.</font> If you do this, please make sure you
remove it immediately afterwards. Usually I would only add a trusted site if I were
using it frequently. The example page can be viewed at <a title="focas.net Visitors page" href="http://blog.focas.net.au/Visitors.aspx">Visitors.aspx</a> (Please
scroll down to the bottom of the page as there are styling issues. The page may need
refreshing)
</p>
        <p>
I created a server page called <strong>Visitors.aspx</strong>, and a user control
called <strong>VisitorsBox.ascx</strong>. These are directly based upon <strong>Referrers.aspx</strong> and <strong>ReferrersBox.ascx</strong> in
the standard DasBlog source code.
</p>
        <h6>How it works
</h6>
        <p>
C# code in the page creates JavaScript which is then registered with the <font size="2"><em>RegisterClientScriptBlock</em> method
of the <em>ClientScript</em> object. The javascript requires some dynamic variables
to be created and this is why it is in the page. Also the way dasBlog is set-up seems
to make it difficult to add JavaScript to just one page without using this method.
Atwo dimensional array is created which contains unique IP addresses and a count of
hits for those addresses. THis is then processed on the client side The JavaScript
code to create the map follows, it is well documented in the Google Maps API documentation,
so i won't say too much about it.<br /></font><font size="2">      <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (GBrowserIsCompatible())
{<br />
     map <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GMap2(document.getElementById('map_canvas'));<br />
     map.setCenter(new GLatLng(37.4419, -122.1419), 1);<br />
     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> mapTypeControl <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GMapTypeControl();<br />
     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> topRight <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));<br />
     <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> bottomRight <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));<br />
     map.addControl(mapTypeControl, topRight);<br />
     map.addControl(new GSmallMapControl());</span><br /></font></p>
        <p>
Now we need to loop thru the IP address array and call the <a title="hostip.info html results page" href="http://api.hostip.info/get_html.php" target="_blank">hostip.info
page</a> to get the city/state/country information. There are different calls that
can be made to return HTML or XML. I used the HTML version as it is a smaller response,
and easy to parse with regular expressions. If there is no information for an IP address
it will return <em>(Unknown)</em>. Thed regular expression trims them out. This database
seems to be maintained by one person, so consider <a title="hostip.info contributions page" href="http://www.hostip.info/contrib/index.html" target="_blank">donating</a> to
them.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> myAjax; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> x=0;x&lt;addresses.<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">length</span>;x++)
{ myAjax <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
Ajax.Request('http:<span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//api.hostip.info/get_html.php?ip='
+ addresses[x][0] , </span> { method: 'get', onSuccess: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function</span>(originalRequest)
{ <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> result=originalRequest.responseText; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> tokens=result.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">split</span>('\n'); <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> count=addresses[x][1]; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> country=/\:[^\(]+/i.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">exec</span>(tokens[0])[0].<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">substring</span>(1).strip(); <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> city=/\:[^\(]+/i.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">exec</span>(tokens[1])[0].<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">substring</span>(1).strip(); <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> location=(city.<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">length</span>&gt;0)?
city <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> ',':'';
location+=country; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">message</span>=location <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> ':
' <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> addresses[x][1] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span> '
visitor'; <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (addresses[x][1]
&gt; 1) <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">message</span>+='s'; </pre>
        <p>
 Now we can call the <em>GClientGeocoder </em>object to turn the city/state/country
information into a latitude/longtitude combination. The <em>GClientGeocoder's getLatLng</em> object
expects a method to be passed in to handle a callback. In this code, it is used to
create the marker on the map which can be clicked to view more information.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   var</span> geocoder <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GClientGeocoder();    geocoder.getLatLng(location, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function</span>(point)
{    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (point)
{       <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">var</span> marker <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> new
GMarker(point);        map.addOverlay(marker);
   GEvent.addListener(marker, 'click', <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">function</span>()
{    marker.openInfoWindow(<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">message</span>);
    });  }  }); </pre>
        <p>
This javascript is created in the C# code using a <em>StringBuilder</em> object, and
is then added to the page using the <em>RegisterClientScriptBlock</em> method of the <em>ClientScript</em> object.<br /><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><br />
Page.ClientScript.RegisterClientScriptBlock(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.GetType(), <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"ipaddressdata"</span>,
sb.ToString(), <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>);</span><br /></p>
        <h5>Download
</h5>
        <p>
The download code contains the <strong>Visitors.aspx</strong> and <strong>Visitors.ascx</strong> page
and component. These should be dropped into the <em>newtelligence.DasBlog.Web</em> folder
of your dasBlog source code. Before going any further you will need to change the
Google Maps key in <em>VisitorsBox.ascx.</em>cs file.
</p>
        <pre>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Page.ClientScript.RegisterClientScriptBlock(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.GetType(), <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"googlemaps"</span>, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">@"&lt;script
src='http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=<strong><font color="#ff0000">YOUR
KEY GOES HERE</font></strong>'"</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">+</span><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"
type='text/javascript'&gt;&lt;/script&gt;"</span>);</span>
        </pre>
        <p>
When you have compiled the code, drop those two files into the root of your website,
and the <em>newtelligence.DasBlog.Web.dll</em> into the <em>bin</em> folder of your
website. Remember to change the trust settings for your blog, and enjoy seeing who
is visiting your site. Note that the Google Maps JavaScript and Prototype JavaScripts
are served up from the Google servers so you don't need to download them.
</p>
        <p>
          <a href="http://blog.focas.net.au/content/binary/Visitors.zip">
            <img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0" float="left" />Visitors.zip
(10.57 KB)</a>
        </p>
        <img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=027f9829-074e-40bd-bf9a-b2d4b6188c63" />
        <br />
        <hr />
        <script type="text/javascript">
          <!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </body>
      <title>Where are your blog visitors coming from in DasBlog?</title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,027f9829-074e-40bd-bf9a-b2d4b6188c63.aspx</guid>
      <link>http://blog.focas.net.au/2008/06/11/WhereAreYourBlogVisitorsComingFromInDasBlog.aspx</link>
      <pubDate>Wed, 11 Jun 2008 13:53:11 GMT</pubDate>
      <description>&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
See part II of this post &lt;a href="http://blog.focas.net.au/2008/06/26/UsingVisiFireToCreateASilverlightChartOfYourVisitorsInDasBlog.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
By combining the &lt;a title="Google Maps API" href="http://code.google.com/apis/maps/signup.html" target=_blank&gt;Google
Maps API&lt;/a&gt; with an IP address host service such as &lt;a title="HostIP.info home page" href="http://www.hostip.info/" target=_blank&gt;HostIP.info&lt;/a&gt;,
it is possible to present a map showing the current visitors to your blog, and to
display them on a map. This implementation shows how to do this for &lt;a href="http://www.dasblog.info/"&gt;dasBlog&lt;/a&gt;.
The result will look something like this:
&lt;/p&gt;
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;img src="http://blog.focas.net.au/content/binary/blogvisitors.png" border=0&gt;
&lt;/p&gt;
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
Notice that the shadow on the marker for the united States is darker, indicating more
hits for that area. Each of the marker icons can be clicked to give location details
and how many hits for that location.
&lt;/p&gt;
&lt;p dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;img src="http://blog.focas.net.au/content/binary/blogvisitorinfowindow.png" border=0&gt;
&lt;/p&gt;
&lt;h5&gt;Client side or server side location determination
&lt;/h5&gt;
&lt;p&gt;
The location of an IP Address can be determined at the server side, or at the client
side. Each has its advantages and disadvantages. A brief but not complete list of
pros and cons is:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Client side 
&lt;ul&gt;
&lt;li&gt;
Pros 
&lt;ul&gt;
&lt;li&gt;
No delay in serving the page as the processing is done after the page has been serves
to the client. 
&lt;li&gt;
Easy to implement 
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Cons 
&lt;ul&gt;
&lt;li&gt;
Requires a call to a web service on a different domain which will cause security concerns 
&lt;li&gt;
Does not allow for users to be able to modify what is their perceived location 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Server side 
&lt;ul&gt;
&lt;li&gt;
Pros 
&lt;ul&gt;
&lt;li&gt;
More control as you are not dependent on an external web service 
&lt;li&gt;
It is easier to cache results if required 
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Cons 
&lt;ul&gt;
&lt;li&gt;
More difficult to implement, especially if you want to keep to the architecture of
the software you are developing for 
&lt;li&gt;
You must maintain and update your own databse of IP address ranges and locations 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h6&gt;The client side solution
&lt;/h6&gt;
&lt;p&gt;
This solution relies on a client side solution, taking advantage of the excellent &lt;a title="Prototype JavaScript Framework home page" href="http://www.prototypejs.org/" target=_blank&gt;Prototype
JavaScript Framework&lt;/a&gt;. Further down the track I might possibly change this to a
server side solution, but as it is only for an administrative page it is not so important.
Note that there are security concerns with doing this client side. It is necessary
top make an AJAX call to an external webservice, and this could be malicious, especially
if a site were hacked. &lt;font color=#ff0000&gt;In order to view the example for this,
you would have to add &lt;/font&gt;&lt;a title="focas.net blog" href="http://blog.focas.net.au"&gt;&lt;font color=#ff0000&gt;http://blog.focas.net.au&lt;/font&gt;&lt;/a&gt;&lt;font color=#ff0000&gt; to
your trusted zones in Internet Explorer.&lt;/font&gt; If you do this, please make sure you
remove it immediately afterwards. Usually I would only add a trusted site if I were
using it frequently. The example page can be viewed at &lt;a title="focas.net Visitors page" href="http://blog.focas.net.au/Visitors.aspx"&gt;Visitors.aspx&lt;/a&gt; (Please
scroll down to the bottom of the page as there are styling issues. The page may need
refreshing)
&lt;/p&gt;
&lt;p&gt;
I created a server page called &lt;strong&gt;Visitors.aspx&lt;/strong&gt;, and a user control
called &lt;strong&gt;VisitorsBox.ascx&lt;/strong&gt;. These are directly based upon &lt;strong&gt;Referrers.aspx&lt;/strong&gt; and &lt;strong&gt;ReferrersBox.ascx&lt;/strong&gt; in
the standard DasBlog source code.
&lt;/p&gt;
&lt;h6&gt;How it works
&lt;/h6&gt;
&lt;p&gt;
C# code in the page creates JavaScript which is then registered with the&amp;nbsp;&lt;font size=2&gt;&lt;em&gt;RegisterClientScriptBlock&lt;/em&gt; method
of the &lt;em&gt;ClientScript&lt;/em&gt; object. The javascript requires some dynamic variables
to be created and this is why it is in the page. Also the way dasBlog is set-up seems
to make it difficult to add JavaScript to just one page without using this method.
Atwo dimensional array is created which contains unique IP addresses and a count of
hits for those addresses. THis is then processed on the client side The JavaScript
code to create the map follows, it is well documented in the Google Maps API documentation,
so i won't say too much about it.&lt;br&gt;
&lt;/font&gt;&lt;font size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (GBrowserIsCompatible())
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GMap2(document.getElementById('map_canvas'));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setCenter(new GLatLng(37.4419, -122.1419), 1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; mapTypeControl &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GMapTypeControl();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; topRight &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; bottomRight &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addControl(mapTypeControl, topRight);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addControl(new GSmallMapControl());&lt;/span&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Now we need to loop thru the IP address array and call the &lt;a title="hostip.info html results page" href="http://api.hostip.info/get_html.php" target=_blank&gt;hostip.info
page&lt;/a&gt; to get the city/state/country information. There are different calls that
can be made to return HTML or XML. I used the HTML version as it is a smaller response,
and easy to parse with regular expressions. If there is no information for an IP address
it will return &lt;em&gt;(Unknown)&lt;/em&gt;. Thed regular expression trims them out. This database
seems to be maintained by one person, so consider &lt;a title="hostip.info contributions page" href="http://www.hostip.info/contrib/index.html" target=_blank&gt;donating&lt;/a&gt; to
them.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; myAjax; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; x=0;x&amp;lt;addresses.&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;length&lt;/span&gt;;x++)
{ myAjax &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
Ajax.Request('http:&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//api.hostip.info/get_html.php?ip='
+ addresses[x][0] , &lt;/span&gt; { method: 'get', onSuccess: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function&lt;/span&gt;(originalRequest)
{ &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; result=originalRequest.responseText; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; tokens=result.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;split&lt;/span&gt;('\n'); &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; count=addresses[x][1]; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; country=/\:[^\(]+/i.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;exec&lt;/span&gt;(tokens[0])[0].&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;substring&lt;/span&gt;(1).strip(); &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; city=/\:[^\(]+/i.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;exec&lt;/span&gt;(tokens[1])[0].&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;substring&lt;/span&gt;(1).strip(); &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; location=(city.&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;length&lt;/span&gt;&amp;gt;0)?
city &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; ',':'';
location+=country; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;message&lt;/span&gt;=location &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; ':
' &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; addresses[x][1] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt; '
visitor'; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (addresses[x][1]
&amp;gt; 1) &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;message&lt;/span&gt;+='s';&gt; &lt;/pre&gt;
&lt;p&gt;
&amp;nbsp;Now we can call the &lt;em&gt;GClientGeocoder &lt;/em&gt;object to turn the city/state/country
information into a latitude/longtitude combination. The &lt;em&gt;GClientGeocoder's getLatLng&lt;/em&gt; object
expects a method to be passed in to handle a callback. In this code, it is used to
create the marker on the map which can be clicked to view more information.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&lt;/span&gt; geocoder &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GClientGeocoder(); &amp;nbsp;&amp;nbsp;&amp;nbsp;geocoder.getLatLng(location, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function&lt;/span&gt;(point)
{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (point)
{ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;var&lt;/span&gt; marker &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; new
GMarker(point); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;map.addOverlay(marker);
&amp;nbsp;&amp;nbsp;&amp;nbsp;GEvent.addListener(marker, 'click', &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;function&lt;/span&gt;()
{ &amp;nbsp;&amp;nbsp;&amp;nbsp;marker.openInfoWindow(&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;message&lt;/span&gt;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}); &amp;nbsp;} &amp;nbsp;});&gt; &lt;/pre&gt;
&lt;p&gt;
This javascript is created in the C# code using a &lt;em&gt;StringBuilder&lt;/em&gt; object, and
is then added to the page using the &lt;em&gt;RegisterClientScriptBlock&lt;/em&gt; method of the &lt;em&gt;ClientScript&lt;/em&gt; object.&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
Page.ClientScript.RegisterClientScriptBlock(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.GetType(), &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"ipaddressdata"&lt;/span&gt;,
sb.ToString(), &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;);&lt;/span&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;h5&gt;Download
&lt;/h5&gt;
&lt;p&gt;
The download code contains the &lt;strong&gt;Visitors.aspx&lt;/strong&gt; and &lt;strong&gt;Visitors.ascx&lt;/strong&gt; page
and component. These should be dropped into the &lt;em&gt;newtelligence.DasBlog.Web&lt;/em&gt; folder
of your dasBlog source code. Before going any further you will need to change the
Google Maps key in &lt;em&gt;VisitorsBox.ascx.&lt;/em&gt;cs file.
&lt;/p&gt;
&lt;pre&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Page.ClientScript.RegisterClientScriptBlock(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.GetType(), &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"googlemaps"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;@"&amp;lt;script
src='http://maps.google.com/maps?file=api&amp;amp;amp;v=2&amp;amp;amp;key=&lt;strong&gt;&lt;font color=#ff0000&gt;YOUR
KEY GOES HERE&lt;/font&gt;&lt;/strong&gt;'"&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;+&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"
type='text/javascript'&amp;gt;&amp;lt;/script&amp;gt;"&lt;/span&gt;);&lt;/span&gt; &lt;/pre&gt;
&lt;p&gt;
When you have compiled the code, drop those two files into the root of your website,
and the &lt;em&gt;newtelligence.DasBlog.Web.dll&lt;/em&gt; into the &lt;em&gt;bin&lt;/em&gt; folder of your
website. Remember to change the trust settings for your blog, and enjoy seeing who
is visiting your site. Note that the Google Maps JavaScript and Prototype JavaScripts
are served up from the Google servers so you don't need to download them.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.focas.net.au/content/binary/Visitors.zip"&gt;&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png" border=0 float="left"&gt;Visitors.zip
(10.57 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=027f9829-074e-40bd-bf9a-b2d4b6188c63" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,027f9829-074e-40bd-bf9a-b2d4b6188c63.aspx</comments>
      <category>Downloads</category>
      <category>JavaScript</category>
      <category>Webmaster</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=c1ba9270-dcad-452a-9e3b-6b7f006be888</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,c1ba9270-dcad-452a-9e3b-6b7f006be888.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,c1ba9270-dcad-452a-9e3b-6b7f006be888.aspx</wfw:comment>
      <wfw:commentRss>http://blog.focas.net.au/SyndicationService.asmx/GetEntryCommentsRss?guid=c1ba9270-dcad-452a-9e3b-6b7f006be888</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the past week I have been doing a lot of analysis on the web analytics reports
that are being generated by <a title="AWStats open source web reportig tools" href="http://awstats.sourceforge.net/" target="_blank"><strong><font color="#4c80ad" size="1">AWStats</font></strong></a> (A
good Open Source product, don't be put off by the arrogant download Firefox message)
and another commercial product that we have an Enterprise license for. I won't name
this product, as I am very disillusioned with it, its accuracy is very questionable.
</p>
        <p>
In order to determine how accurate the statistics were, i chose one days log file
for a reasonably busy website. This site is mainly a Monday to Friday website with
peaks around 10 AM to 4 PM, and another small peak 6 PM to 8PM. Weekends see a lower
usage, so I used a sunday as this would be the smallest log I could reasonably analyse.
Thee log contained just over 100,000 entries. In order to analyse it, I used Visual
Studion 2008, filtering using regular expressions. After a while I realised I would
like to review these stats on an ongoing basis, so i wrote a small log parser. There
is an excellent free parser available from Microsoft called <a title="Microsoft Log Parser 2.2" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;displaylang=en" target="_blank"><strong><font color="#4c80ad" size="1">Log
Parser 2.2</font></strong></a> however I wanted direct control, because I also
want to create some graphs. My first version creates a beautiful graph using the excellent
Open Source Silverlight data visualisation component called <a title="Visifire data visulaisation component" href="http://www.visifire.com/" target="_blank"><strong><font color="#4c80ad" size="1">Visifire</font></strong></a>.
I haven't included that code in this download as i wanted to clean it up and make
it more re-usable and extensible. 
</p>
        <p>
This tool is not particularly robust as it is just a throwaway utility, but I tried
to make it a bit extensible for future requirments. The log files I am parsing are
Apache log files. So I designed a simple <strong>ILogFormatReader </strong>interface,
and created an <strong>ApacheLogParser</strong> implementation. This doesn't populate
all the fields, but it's easy to see how it works to finish off the implementation
if more information is necessary.
</p>
        <p>
The main issue with parsing log files is how they are separated. in this case the
log file is space separated. Any fields that have spaces in them are surrounded by
double quotes or square brackets. Another consideration is what to do if a log entry
comes in with an invalid format. I didn't worry about this too much, as the web logs
should work well if the first line is correct. if this code was to go into production
then of course that would have to be refactored.
</p>
        <h5>Not all log file are created equal
</h5>
        <p>
          <img height="457" alt="Log parser example output" hspace="0" src="http://blog.focas.net.au/content/binary/log_parser_cmd.png" width="300" align="left" border="0" />Each
web server can be customised to record different informatin in the log files. Additionally
proxy servers can modify what is sent thru to the web server, so it is important to
check the format of any logfile before parsing. The log files I am parsing are using
an Apache log file format. More information can be found on the <a title="Apache log files page" href="http://httpd.apache.org/docs/1.3/logs.html" target="_blank"><strong><font color="#4c80ad" size="1">Apache
log files page</font></strong></a> and the <a title="Microsoft Log file formats in IIS (6.0) page" href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/bea506fd-38bc-4850-a4fb-e3a0379d321f.mspx?mfr=true"><strong><font color="#4c80ad" size="1">Microsoft
Log file formats in IIS (6.0) page</font></strong></a>.
</p>
        <p>
For those interested, I found the statistics in AWStats very close to what I believe
they should be. There were inaccuracies that I couldn't explain. To be fair, we are
running an old version of AWStats so I assume that this might have been addressed
in a newer version. The very expensive commercial application we use reports approximately
twice the bandwidth that it should, and does not understand how to handle the <strong>JSESSIONID</strong> tacked
on to the end of some JSP applications. It confuses the real resource with the session
ID, and we get very iaccurate statistics as a result. 
</p>
        <p>
There is some minimalistic reporting to give an idea of how to use the parser. The
output looks like thie image here.
</p>
        <p>
There is a download included below. I would be interested to hear if anyone finds
this useful. I hope to update this application at some stage to include some graphing
output. I might use Visifire as mentioned earlier, or possibly Microsoft Excel. I
think that is a better option as it would allow for richer maniupulation of the reporting
after the log files have been parsed. Excel has such powerful features it would require
good justification not to use it as a reporting mechanism. I think that AWStats doesn't
do their reports justice by presenting them as they do, Everyones reporting requirements
are different.
</p>
        <h6>Download
</h6>
        <p>
The applicaition can be downloaded here:
</p>
        <p>
          <img src="http://blog.focas.net.au/content/binary/Download_32.png" border="0" />
          <a href="http://blog.focas.net.au/content/binary/LogParsing.zip" align="left">LogParsing.zip
(7 KB)</a>
        </p>
        <img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=c1ba9270-dcad-452a-9e3b-6b7f006be888" />
        <br />
        <hr />
        <script type="text/javascript">
          <!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//-->
        </script>
        <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
        </script>
      </body>
      <title>Web log file parsing with c#</title>
      <guid isPermaLink="false">http://blog.focas.net.au/PermaLink,guid,c1ba9270-dcad-452a-9e3b-6b7f006be888.aspx</guid>
      <link>http://blog.focas.net.au/2008/06/03/WebLogFileParsingWithC.aspx</link>
      <pubDate>Tue, 03 Jun 2008 13:33:35 GMT</pubDate>
      <description>&lt;p&gt;
In the past week I have been doing a lot of analysis on the web analytics reports
that are being generated by &lt;a title="AWStats open source web reportig tools" href="http://awstats.sourceforge.net/" target=_blank&gt;&lt;strong&gt;&lt;font color=#4c80ad size=1&gt;AWStats&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&amp;nbsp;(A
good Open Source product, don't be put off by the arrogant download Firefox message)
and another commercial product that we have an Enterprise license for. I won't name
this product, as I am very disillusioned with it, its accuracy is very questionable.
&lt;/p&gt;
&lt;p&gt;
In order to determine how accurate the statistics were, i chose one days log file
for a reasonably busy website. This site is mainly a Monday to Friday website with
peaks around 10 AM to 4 PM, and another small peak 6 PM to 8PM. Weekends see a lower
usage, so I used a sunday as this would be the smallest log I could reasonably analyse.
Thee log contained just over 100,000 entries. In order to analyse it, I used Visual
Studion 2008, filtering using regular expressions. After a while I realised I would
like to review these stats on an ongoing basis, so i wrote a small log parser. There
is an excellent free parser available from Microsoft called &lt;a title="Microsoft Log Parser 2.2" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&amp;amp;displaylang=en" target=_blank&gt;&lt;strong&gt;&lt;font color=#4c80ad size=1&gt;Log
Parser 2.2&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&amp;nbsp;however I wanted direct control, because I also
want to create some graphs. My first version creates a beautiful graph using the excellent
Open Source Silverlight data visualisation component called &lt;a title="Visifire data visulaisation component" href="http://www.visifire.com/" target=_blank&gt;&lt;strong&gt;&lt;font color=#4c80ad size=1&gt;Visifire&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.
I haven't included that code in this download as i wanted to clean it up and make
it more re-usable and extensible. 
&lt;/p&gt;
&lt;p&gt;
This tool is not particularly robust as it is just a throwaway utility, but I tried
to make it a bit extensible for future requirments. The log files I am parsing are
Apache log files. So I&amp;nbsp;designed a simple &lt;strong&gt;ILogFormatReader &lt;/strong&gt;interface,
and created an &lt;strong&gt;ApacheLogParser&lt;/strong&gt; implementation. This doesn't populate
all the fields, but it's easy to see how it works to finish off the implementation
if more information is necessary.
&lt;/p&gt;
&lt;p&gt;
The main issue with parsing log files is how they are separated. in this case the
log file is space separated. Any fields that have spaces in them are surrounded by
double quotes or square brackets. Another consideration is what to do if a log entry
comes in with an invalid format. I didn't worry about this too much, as the web logs
should work well if the first line is correct. if this code was to go into production
then of course that would have to be refactored.
&lt;/p&gt;
&lt;h5&gt;Not all log file are created equal
&lt;/h5&gt;
&lt;p&gt;
&lt;img height=457 alt="Log parser example output" hspace=0 src="http://blog.focas.net.au/content/binary/log_parser_cmd.png" width=300 align=left border=0&gt;Each
web server can be customised to record different informatin in the log files. Additionally
proxy servers can modify what is sent thru to the web server, so it is important to
check the format of any logfile before parsing. The log files I am parsing are using
an Apache log file format. More information can be found on the &lt;a title="Apache log files page" href="http://httpd.apache.org/docs/1.3/logs.html" target=_blank&gt;&lt;strong&gt;&lt;font color=#4c80ad size=1&gt;Apache
log files page&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;&amp;nbsp;and the &lt;a title="Microsoft Log file formats in IIS (6.0) page" href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/bea506fd-38bc-4850-a4fb-e3a0379d321f.mspx?mfr=true"&gt;&lt;strong&gt;&lt;font color=#4c80ad size=1&gt;Microsoft
Log file formats in IIS (6.0) page&lt;/font&gt;&lt;/strong&gt;&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
For those interested, I found the statistics in AWStats very close to what I believe
they should be. There were inaccuracies that I couldn't explain. To be fair, we are
running an old version of AWStats so I assume that this might have been addressed
in a newer version. The very expensive commercial application we use reports approximately
twice the bandwidth that it should, and does not understand how to handle the &lt;strong&gt;JSESSIONID&lt;/strong&gt; tacked
on to the end of some JSP applications. It confuses the real resource with the session
ID, and we get very iaccurate statistics as a result. 
&lt;/p&gt;
&lt;p&gt;
There is some minimalistic reporting to give an idea of how to use the parser. The
output looks like thie image here.
&lt;/p&gt;
&lt;p&gt;
There is a download included below. I would be interested to hear if anyone finds
this useful. I hope to update this application at some stage to include some graphing
output. I might use Visifire as mentioned earlier, or possibly Microsoft Excel. I
think that is a better option as it would allow for richer maniupulation of the reporting
after the log files have been parsed. Excel has such powerful features it would require
good justification not to use it as a reporting mechanism. I think that AWStats doesn't
do their reports justice by presenting them as they do, Everyones reporting requirements
are different.
&lt;/p&gt;
&lt;h6&gt;Download
&lt;/h6&gt;
&lt;p&gt;
The applicaition can be downloaded here:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://blog.focas.net.au/content/binary/Download_32.png" border=0&gt;&lt;a href="http://blog.focas.net.au/content/binary/LogParsing.zip" align="left"&gt;LogParsing.zip
(7 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.focas.net.au/aggbug.ashx?id=c1ba9270-dcad-452a-9e3b-6b7f006be888" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-2990102312997184";
/* image add for header and rss */
google_ad_slot = "7433217455";
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;</description>
      <comments>http://blog.focas.net.au/CommentView,guid,c1ba9270-dcad-452a-9e3b-6b7f006be888.aspx</comments>
      <category>Downloads</category>
      <category>Webmaster</category>
    </item>
    <item>
      <trackback:ping>http://blog.focas.net.au/Trackback.aspx?guid=3493c25d-b3fd-4773-9bb1-e2678d69570b</trackback:ping>
      <pingback:server>http://blog.focas.net.au/pingback.aspx</pingback:server>
      <pingback:target>http://blog.focas.net.au/PermaLink,guid,3493c25d-b3fd-4773-9bb1-e2678d69570b.aspx</pingback:target>
      <dc:creator>Mark Focas</dc:creator>
      <wfw:comment>http://blog.focas.net.au/CommentView,guid,3493c25d-b3fd-4773-9bb1-e2678d69570b.aspx</wfw:comment>
      <wfw:com