red orange yellow green blue pink

Session Timeout in IIS, ASP.NET

April 10th, 2013


Boss had me look into how we can keep sessions alive (IIS server/client)
without having to “stay-alive-ping” the server (in our website asp.net code)
from client browsers. The main consideration is that a user must reenter
their CAC pin when the ping occurs and if the user is away from his/her
machine during the ping request the ping will not complete and return a 403
status because the client certificate will become invalid. If a user was in
the middle of a long form or taking a training course, all data would be
lost. This is bad.

I have done some research and have found out the following:

We can extend the session out by extended the session timeout on the server.
This requires the following 3 settings:

Set Session Timeout for website:

IIS --> [website] --> Properties --> Directory Tab --> Configuration Button -->
Options Tab --> Session timout (currently 120 minutes for most sites, default
IIS value: 20)

Set ASP.NET Authentication Cookie Timout:

IIS --> [website] --> Properties --> ASP.NET Tab --> Edit Configuration Button -->
Authentication Tab --> Cookie timeout (currently 120 minutes for most sites,
default asp.net value: 30)

Set Idle timeout in App Pool:

IIS --> [app pool] --> Properties --> Performance Tab --> Idle Timeout (currently 20
for most sites, default IIS value: 20)

The botton line is that the session will timeout at the lowest of these
three settings… Which is 20 minutes in the App Pool objects. Currently we
are doing asp.net “stay-alive-ping” at some interval less than 20 minutes
from our pages to extend this limit indefinitely. If we were to change
our app pool to 120 minutes (matching the other two settings), we could then
extend the “stay alive pinging” to say… 115 minutes. Thus the CAC Pins
would only be requested when a user post/get occurs (and the cac software
requires a revalidation) or at the 115 minutes since the last user post/get,
which ever comes first.

Hope all this makes sense.

DATE DIMENTION TABLE FOR ORACLE

April 10th, 2013


--CREATE DATE DIMENTION TABLE
CREATE TABLE DATES AS
SELECT
n AS Date_ID,
CurrDate AS FULL_DATE,
(TO_NUMBER(TO_CHAR(CurrDate,'MM')) || '/' || TO_NUMBER(TO_CHAR(CurrDate,'DD')) || '/' || TO_CHAR(CurrDate,'YYYY')) AS DOT_NET_DATE, --3/23/2012
TO_NUMBER(TO_CHAR(CurrDate,'DD')) AS DAY_OF_MONTH,
TO_NUMBER(TO_CHAR(CurrDate, 'DDD')) AS DAY_OF_YEAR,
TO_NUMBER(TO_CHAR(CurrDate, 'D')) as DAY_OF_WEEK,
TO_CHAR(CurrDate,'Day') as DAY_LONG,
TO_CHAR(CurrDate, 'DY') as DAY_SHORT,
TO_NUMBER(TO_CHAR(CurrDate, 'W')) as WEEK_OF_MONTH,
TO_NUMBER(TO_CHAR(CurrDate, 'IW')) as WEEK_OF_YEAR,
TO_NUMBER(TO_CHAR(CurrDate,'Q')) AS QUARTER,
TO_NUMBER(TO_CHAR(CurrDate,'MM')) AS MONTH_OF_YEAR,
TO_CHAR(CurrDate,'Mon') AS MONTH_SHORT,
TO_CHAR(CurrDate,'Month') AS MONTH_LONG,
TO_NUMBER(TO_CHAR(CurrDate,'YYYY')) AS YEAR,
CASE
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (10,11,12) THEN 'FY' || TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YY')) || ' Q1'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (1,2,3) THEN 'FY' || TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YY')) || ' Q2'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (4,5,6) THEN 'FY' || TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YY')) || ' Q3'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (7,8,9) THEN 'FY' || TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YY')) || ' Q4'
END AS FISCAL_FY_Q,
'FY' || TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YY')) AS FISCAL_FY,
TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'YYYY')) AS FISCAL_YEAR,
CASE
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (10,11,12) THEN 'Q1'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (1,2,3) THEN 'Q2'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (4,5,6) THEN 'Q3'
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (7,8,9) THEN 'Q4'
END AS FISCAL_Q,
CASE
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (10,11,12) THEN 1
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (1,2,3) THEN 2
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (4,5,6) THEN 3
WHEN TO_NUMBER(TO_CHAR(CurrDate, 'MM')) IN (7,8,9) THEN 4
END AS FISCAL_QUARTER,
-1 AS FISCAL_DAY_NUMBER,
-1 AS FISCAL_WEEK_NUMBER,
TO_NUMBER(TO_CHAR(ADD_MONTHS(CurrDate, 3), 'MM')) AS FISCAL_MONTH_NUMBER,
TO_NUMBER(TO_CHAR(CurrDate, 'J')) AS JULIAN_DAY,
CASE
WHEN TO_CHAR(CurrDate, 'D') = '1' THEN CurrDate
WHEN TO_CHAR(CurrDate, 'D') = '2' THEN CurrDate-1
WHEN TO_CHAR(CurrDate, 'D') = '3' THEN CurrDate-2
WHEN TO_CHAR(CurrDate, 'D') = '4' THEN CurrDate-3
WHEN TO_CHAR(CurrDate, 'D') = '5' THEN CurrDate-4
WHEN TO_CHAR(CurrDate, 'D') = '6' THEN CurrDate-5
WHEN TO_CHAR(CurrDate, 'D') = '7' THEN CurrDate-6
END AS CAL_BEGIN_WEEK_DT,
CASE
WHEN TO_CHAR(CurrDate, 'D') = '7' THEN CurrDate
WHEN TO_CHAR(CurrDate, 'D') = '6' THEN CurrDate+1
WHEN TO_CHAR(CurrDate, 'D') = '5' THEN CurrDate+2
WHEN TO_CHAR(CurrDate, 'D') = '4' THEN CurrDate+3
WHEN TO_CHAR(CurrDate, 'D') = '3' THEN CurrDate+4
WHEN TO_CHAR(CurrDate, 'D') = '2' THEN CurrDate+5
WHEN TO_CHAR(CurrDate, 'D') = '1' THEN CurrDate+6
END AS CAL_END_WEEK_DT,
CASE
WHEN TO_CHAR(CurrDate, 'D') = '2' THEN CurrDate
WHEN TO_CHAR(CurrDate, 'D') = '3' THEN CurrDate-1
WHEN TO_CHAR(CurrDate, 'D') = '4' THEN CurrDate-2
WHEN TO_CHAR(CurrDate, 'D') = '5' THEN CurrDate-3
WHEN TO_CHAR(CurrDate, 'D') = '6' THEN CurrDate-4
END AS WORKING_WK_BEGIN_DT,
CASE
WHEN TO_CHAR(CurrDate, 'D') = '6' THEN CurrDate
WHEN TO_CHAR(CurrDate, 'D') = '5' THEN CurrDate+1
WHEN TO_CHAR(CurrDate, 'D') = '4' THEN CurrDate+2
WHEN TO_CHAR(CurrDate, 'D') = '3' THEN CurrDate+3
WHEN TO_CHAR(CurrDate, 'D') = '2' THEN CurrDate+4
END AS WORKING_WK_END_DT,
DECODE(TO_CHAR(CurrDate, 'D'), '7', 0, '1', 0, 1) AS IS_WORKDAY,
DECODE(TO_CHAR(CurrDate, 'D'), '7', 1, '1', 1, 0) AS IS_WEEKEND,
-1 AS IS_HOLIDAY
FROM (
select level n, TO_DATE('31/12/1989','DD/MM/YYYY') + NUMTODSINTERVAL(level,'day') CurrDate
from dual
connect by level <= 18250)

ASP.NET Add Sub Header Row (Group) To GridView Control

December 2nd, 2010

    ''' <summary>
    ''' Insert a sub header in a grid view.
    ''' </summary>
    ''' <param name="gv">The GridView to insert the sub header row into.</param>
    ''' <param name="gvrBeforeRow">The GridViewRow to insert the sub header before.</param>
    ''' <param name="sSubHeaderText">The text to render in the sub header.</param>
    ''' <remarks></remarks>
    Protected Sub insertGroupHeaderToGridView(ByRef gv As GridView, ByVal gvrBeforeRow As GridViewRow, ByVal sSubHeaderText As String)
 
        Dim visibleColumns As Integer = gv.Columns.Count
 
        Dim tbl As Table = gv.Controls(0)
        Dim newRowIndex As Integer = tbl.Rows.GetRowIndex(gvrBeforeRow)
        Dim newRow As GridViewRow = New GridViewRow(newRowIndex, newRowIndex, DataControlRowType.DataRow, DataControlRowState.Normal)
 
        newRow.Cells.Add(New TableCell())
 
        If (visibleColumns > 1) Then
            newRow.Cells(0).ColumnSpan = visibleColumns
            newRow.Cells(0).Text = sSubHeaderText
        End If
 
        tbl.Controls.AddAt(newRowIndex, newRow)
 
    End Sub

Hands Across The Sand – Stop Oil Drilling In Florida

January 12th, 2010

Hands Across The Sand is an organization committed to protecting our coastlines and waterways from near and off shore oil drilling. Join us February 13, 2010!

An organization devoted to protecting our coastlines and waterways from the devastating environmental effects of oil exploration and support industries.

Mission:

1. To raise awareness about pending Florida legislation to drill for oil within 3 to 10 miles of our coast

2. To organize a statewide, coastal movement to protest this legislation. This protest will bring thousands of Florida citizens to our beaches and will draw metaphorical and physical lines in the sand; human lines in the sand against near shore oil drilling in our waters. This event will be held on Saturday February 13, 2010

3. To convince our Legislators and Governor to drop any and all Legislation that would allow this folly.

Hands Across The Sand On Facebook

Droid On A Boat (high speed footage)

November 28th, 2009

The following is the Motorola Droid running the Android OS version 2.0 uploaded directly from the phone to youtube. I know the footage is kinda bumpy but it show how well the camera/video records when conditions are “rough”.

Halo Domains For Sale (HaloStrategy.com, HaloStrategies.com, HaloTactic.com, HaloTactics.com)

July 31st, 2009

Halo Domains For Sale (HloStrategy.com, HaloStrategies.com, HaloTactic.com, HaloTactics.com)

See this link.

Pandora Has On Air Ads

June 30th, 2009

NOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!

Top 10 Free G1 Android Apps

April 20th, 2009

Nearly every night before I go to sleep I check the Market store for new apps. I have viewed every app (several thousand now) and installed (and uninstalled) maybe 150 that seemed worthy. This list is good for the person who just purchased a new G1 and doesn’t know which good apps to get. Here is my top 10 list:

1) Star Map. This is the definitive application for showing off your G1. No other phone has the necessary hardware. It uses the accelerometers and compass to know which orientation the phone is in and prints the star map on the screen. http://www.starreservoir.com/

2) All application written by Google. By default, not all Google apps come preinstalled. Here are the current list of Google apps: My Maps Editor, Scoreboard, Finance, Picasa Uploader, My Tracks.

3) AK Notepad. A full featured notepad app. Until google (or third party) integrates Google “Tasks” or “Notes”. AK Notepad is the shit. http://www.kurniadi.org/aknotepad/

4) Ringdroid. Nicely polished ringtone app. Take any music file and chop it into a ringtone. Simple, full featured and intuitive. http://code.google.com/p/ringdroid/

5) Weatherbug. It’s a tiny bit bloated but I love it. Runs in the notification bar and always gives you local data as you travel. Gets better with every release. http://weather.weatherbug.com/mobile/android.html

6) WikiMobile. Fast as poop wiki search engine. Nice.

7) Free Dictionary. Fast as eff dictionary search engine.

8) ShopSavvy. Scan barcode and get the best prices online and locally.

9) PF Voicemail. Voicemails are downloaded to phone and organized with relevant data (time, duration caller id). You can listen to only the voice mails you want and in the order you want. Way faster than T-Mobile dial in!! This should be built into the phone.

10) Flashlight (by Devesh Parekh). There are a bazillion flashlights. This is the best. Max brightness and anti sleep. What more do you need?

Others that are good but didn’t make the top 10:

OI Countdown. A simple countdown timer.
Stopwatch. Stopwatch.
Voice Recorder. doi.
PicSay. Edit and caption photos.
SMS Backup. Backs up all your SMS/MMS messages to Google email then archives and tags them.
Convert That. Convert anything into anything (for nerds).
Bartender. Gets better with every release. Online database and custom drinks.

Astro File Manager Has Application backup feature!! backs up your .akp files to the SD card. Sweet.

Windows Media Player 11: How to share media files that are located on other computers on your home network (to share to your xbox 360 or other pc’s).

April 2nd, 2009

To enable remote content sharing

Perform the following steps on the computer that contains the library you are sharing.
1. Click Start, click Run, type regedit, and then click OK.
2. In the registry tree (on the left), expand HKEY_LOCAL_MACHINE, SOFTWARE, Microsoft, MediaPlayer, and Preferences.
3. Right-click HME, point to New, and then click DWORD Value.
4. Type EnableRemoteContentSharing, and then press ENTER.
5. Right-click EnableRemoteContentSharing, and then click Modify.
6. In the Value data text box, type 1, and then click OK. If you later decide to disable remote content sharing, you can repeat this procedure and change the value to 0.
Caution: Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on your computer.

To grant one user account permission to access folders on other computers

1. Click Start, click Control Panel, click Performance and Maintenance or System and Maintenance, click Administrative Tools, and then double-click Services.
2. Scroll down the list of services, right-click Windows Media Player Network Sharing Service, and then click Properties.
3. On the Log On tab, click This account, and specify a user account that has Read permission for the remote folders containing media that you want to share. This account should have a password that never expires.
4. On the General tab, click Stop, click Start, and then click OK.
5. On the computer containing the library you are sharing, click Start, click Run, type regedit, and then click OK.
6. In the registry tree (on the left), expand HKEY_LOCAL_MACHINE, SOFTWARE, Microsoft, and Windows Media Player NSS.
7. Right-click 3.0, and then click Permissions.
8. Click Add.
9. In the Enter the object names to select box, type the name of the account you specified in step 3 of the preceding procedure.
10. Click OK.
11. In the Group or user names box, click the name of the account you specified in step 3 of the preceding procedure.
12. In the Permissions box, on the Full Control row, select the Allow check box.
13. Click OK, and then close Registry Editor.
Caution: Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on your computer.

To enable sharing in Windows Media Player

1. Click the arrow below the Library tab, and then click Media Sharing.
2. In the Media Sharing dialog box, select the Share my media to check box.
3. In the list of devices below the Share my media to check box, select a device.
4. Do one of the following:
–If you want to share your media with the computer or device you have selected, click Allow.
–If you don’t want to share your media with the computer or device you have selected, click Deny.

More info here…

http://www.microsoft.com/windows/windowsmedia/player/faq/sharing.mspx

.NET DataGrid (or GridView) To Excel Utility

March 13th, 2009
    protected void Button3_Click(object sender, EventArgs e)
    {
 
 
        DataSet dsExport = dataSet;
        DataGrid dgExport = new DataGrid();
        dgExport.DataSource = dsExport;
 
        //ExportToExcel();
 
        DataGridToExcel(dgExport, Response);
    }
 
    protected void DataGridToExcel(DataGrid dGridExport, HttpResponse httpResp)
    {
        httpResp.Clear();
        httpResp.Charset = "";
        httpResp.ContentType = "application/vnd.ms-excel";
        StringWriter stringWrite = new StringWriter();
        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        DataGrid dGrid = new DataGrid();
        dGrid = dGridExport;
        dGrid.HeaderStyle.Font.Bold = true;
        dGrid.DataBind();
        dGrid.RenderControl(htmlWrite);
        httpResp.Write(stringWrite.ToString());
        httpResp.End();
    }

Or to export a DataGrid to Excel use:

    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        exportToExcel();
    }
 
    protected void exportToExcel()
    {
        VerifyRenderingInServerForm(GridView1);
 
        /* This is a limit in Excel prior to Office 2007 */
        if (GridView1.Rows.Count > 65536)
        {
            Page.Response.Clear();
            Page.Response.Write("Too many lines to export.");
            Page.Response.End();
        }
        GridView1.AllowPaging = false;
        GridView1.AllowSorting = false;
        GridView1.DataBind();
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
        Response.Charset = "";
        // If you want the option to open the Excel file without saving than
        // comment out the line below
        // Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        GridView1.RenderControl(htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();
    }
 
    public override void VerifyRenderingInServerForm(Control control)
    {
        /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
           server control at run time. */
    }

.NET: Convert A String Into A Compressed String

October 16th, 2008

Written with .NET 2.0. Should work with 3.x as well.

using System.IO.Compression;
using System.Text;
 
protected string Compress(string text)
{
    byte[] buffer = Encoding.UTF8.GetBytes(text);
    MemoryStream ms = new MemoryStream();
    using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))
    {
        zip.Write(buffer, 0, buffer.Length);
    }
 
    ms.Position = 0;
    MemoryStream outStream = new MemoryStream();
 
    byte[] compressed = new byte[ms.Length];
    ms.Read(compressed, 0, compressed.Length);
 
    byte[] gzBuffer = new byte[compressed.Length + 4];
    System.Buffer.BlockCopy(compressed, 0, gzBuffer, 4, compressed.Length);
    System.Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gzBuffer, 0, 4);
    return Convert.ToBase64String(gzBuffer);
}
 
 
protected string Decompress(string compressedText)
{
    byte[] gzBuffer = Convert.FromBase64String(compressedText);
    using (MemoryStream ms = new MemoryStream())
    {
        int msgLength = BitConverter.ToInt32(gzBuffer, 0);
        ms.Write(gzBuffer, 4, gzBuffer.Length - 4);
 
        byte[] buffer = new byte[msgLength];
 
        ms.Position = 0;
        using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
        {
            zip.Read(buffer, 0, buffer.Length);
        }
 
        return Encoding.UTF8.GetString(buffer);
    }
}

Break into Debugger when Exception is thrown

March 31st, 2008

Break into Debugger when Exception is thrown even if you are using try catch statements.

From Visual Studio, hit CTRL + ALT + E. Then check the “Thrown attribute of the Common Language Runtime Exceptions.

untitled.GIF

Maxmind and Google Maps Mashup [php]

March 8th, 2008

I was bored today so I created a very simple and fast php script to plot the location for a given IP and display other IP information (such as lattitude, longitude, Country, State, Area code, ISP, etc.) on a Google Map using the Maxmind web service and the Google Maps API.

maxmind_google_maps_mashup.GIF

The link in the balloon points domaintools.com and does a whois lookup on the IP for detailed information on the ISP (internet service provider).

Here is a working demo (hard coded IP).


In order for this script to work on your site, you will need a MaxMind GeoIP City/ISP/Organization Web Service Key (50,000 lookups for $20.00) and a Google Maps Key (free). There are other IP to Lat/Long Web services out there but Maxmind is by far the most accurate (none are 100% accurate).

To render the location of an IP on the map, send the IP via the query string such as…


http://www.yourDomain.com/MaxmindGoogleMap/index.php?ip=98.195.83.50


Here is the script. Copy the contents to a .php file and edit the 2 keys. That’s it!

<?php
        //////////////////////////////////////////////////////////////////////////////////////
        ///////////////  Maxmind/Google Maps Mashup by Kevin Cornwell ///////////////
        ///////////////                       Version 1.0                             ///////////////
        ///////////////          http://www.kevincornwell.com                ///////////////
        /////////////////////////////////////////////////////////////////////////////////////
 
 
 
	// EDIT THE NEXT 2 KEYS
 
	$maxmind_license_key  = "foo";    // Replace [foo] with your key.
	$google_maps_key      = "bar";    // Replace [bar] with your key.
 
 
	$zoom                 = 4;          // Default zoom level.
	$lat                  = 39.232;     // Center on this location by default when no IP is passed.
	$long                 = -95.800;    // Center on this location by default when no IP is passed.
	$ip                   = "";
	$message              = "Hello World";   // Default message when no IP is passed.
 
 
	if (isset($_REQUEST['ip']))
	{
		$ip = $_REQUEST['ip'];
 
		$r = maxmind_lookup($ip);
 
		$message = "<table cellspacing=0><tr><td align='right'><b>IP:</b> &nbsp;</td><td><a href='http://whois.domaintools.com/{$ip}'>{$ip}</a></td></tr><tr><td align='right'><b>Country:</b> &nbsp;</td><td>{$r['country']}</td></tr><tr><td align='right'><b>Region:</b> &nbsp;</td><td>{$r['region']}</td></tr><tr><td align='right'><b>City:</b> &nbsp;</td><td>{$r['city']}</td></tr><tr><td align='right'><b>Zip:</b> &nbsp;</td><td>{$r['zip']}</td></tr><tr><td align='right'><b>Lat:</b> &nbsp;</td><td>{$r['lat']}</td></tr><tr><td align='right'><b>Long:</b> &nbsp;</td><td>{$r['long']}</td></tr><tr><td align='right'><b>Metro:</b> &nbsp;</td><td>{$r['metro_code']}</td></tr><tr><td align='right'><b>Area Code:</b> &nbsp;</td><td>{$r['area_code']}</td></tr><tr><td align='right'><b>ISP:</b> &nbsp;</td><td>{$r['isp']}</td></tr><tr><td align='right'><b>Org:</b> &nbsp;</td><td>{$r['org']}</td></tr></table>";
 
		$lat = $r['lat'];
		$long = $r['long'];
	}
 
 
	function maxmind_lookup($ipaddress){
 
		global $maxmind_license_key;
 
		// Returns:ISO 3166 Two-letter Country Code, Region Code, City, Postal Code, 
		// Latitude, Longitude, Metropolitan Code, Area Code, ISP, Organization.
 
 
		$query = "http://maxmind.com:8010/f?l=" . $maxmind_license_key . "&i=" . $ipaddress;
		$url = parse_url($query);
		$host = $url["host"];
		$path = $url["path"] . "?" . $url["query"];
		$timeout = 1;
		$fp = fsockopen ($host, 8010, $errno, $errstr, $timeout)
		or die('Can not open connection to maxmind server.');
		$buf = "";
 
 
		if ($fp) {
			fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n");
			while (!feof($fp)) {
				$buf .= fgets($fp, 128);
			}
			$lines = split("\n", $buf);
			$data = $lines[count($lines)-1];
			fclose($fp);
 
			$arrMaxmind = split(",", $data);
			$arrMaxmind = str_replace("\"", "", $arrMaxmind);
			$arrMaxmind = str_replace(",", " ", $arrMaxmind);
 
			$r['country'] 		= $arrMaxmind[0];
			$r['region'] 		= $arrMaxmind[1];
			$r['city'] 		= $arrMaxmind[2];
			$r['zip'] 		= $arrMaxmind[3];
			$r['lat'] 		= $arrMaxmind[4];
			$r['long'] 		= $arrMaxmind[5];
			$r['metro_code'] 	= $arrMaxmind[6];
			$r['area_code'] 	= $arrMaxmind[7];
			$r['isp'] 		= $arrMaxmind[8];
			$r['org'] 		= $arrMaxmind[9];
 
		} else {
			return false;
		}
		return $r;
	}		
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title><?php echo $ip ?></title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo $google_maps_key ?>"
      type="text/javascript"></script>
    <script type="text/javascript">
 
    //<![CDATA[
 
	function load() 
	{
		if (GBrowserIsCompatible()) 
		{
			var map = new GMap2(document.getElementById("map"));
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			map.setCenter(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>), <?php echo $zoom ?>);
			var marker = new GMarker(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>));
			marker.html = "<?php echo $message ?>";
			GEvent.addListener(marker, 'click', function() {marker.openInfoWindowHtml(marker.html); });
			map.addOverlay(marker);
			marker.openInfoWindowHtml(marker.html);
		}
	}
 
    //]]>
    </script>
  </head>
  <body onload="load()" onunload="GUnload()">
    <div id="map" style="width:800px;height:600px"></div>
  </body>
</html>

If you liked my script, post a thanks below.
:)

.net versions rant

November 21st, 2007

I am fairly certain the .NET versioning (numbering release) scheme is the dumbest ever created. Seriously who in their right mind does a point release that is a extension of the previous point but not the one before that (2.0 -> 3.0)? Then 3.0 -> to 3.5? wtf? Remember 1.0 and 1.1? Hmmm. How does that fit in? Oh yea, it doesn’t.

It went like this…

1.0 to 1.1. Perfect. Basically the 1.0 framework fixed with a couple new things. That’s actually how it took place.

Then 2.0. A whole new framework. Yay! We are good at this point.

Then 3.0. Huh? Another new framework? Yay!? Wait, no, huh? It’s not a framework? It’s a extension but only for 2.0 and not related at all to 1.0 or 1.1? Oh good heavens MS.

Then 3.5 Another extension to 2.0 or actually 3.0? Ok, now I’m getting mad. What happened to 3.1, 3.2, etc.?

What’s next? 8.0 with 10.0 extentions?

Might as well number it 38.5. What’s the difference at this point? There is NO consistency anyway and the higher the number the better right?

Anyway here is the 2.0 -> 3.5 relationships…
dotnetframework35.png

Seriously, if you know what the hell MS was thinking, post a comment.

Cannot get the list schema column property from the SharePoint List

October 25th, 2007

This entry has been moved to mySharePointBlog.com. Go here.

Workaround For SharePoint Group Email Limits

October 23rd, 2007

This entry has been moved to mySharePointBlog.com. Go Here.

ASP.NET – Test NTFS Directory Access

October 5th, 2007
    protected void Page_Load(object sender, EventArgs e)
    {
 
        // Show admin link if they have access to the admin directory. //
 
        hyperLinkAdmin.Visible = hasAccessToDir("admin");
    }
 
    protected bool hasAccessToDir(string dir)
    {
        return System.IO.Directory.Exists(MapPath(dir));
    }

SharePoint Elevated Security

September 27th, 2007

This post has been moved to mySharePointBlog. Go Here.

Create Active Directory User In .NET

September 26th, 2007

C#

    public string CreateADUser(string szUsername, string szDisplayName, string szFirstName, string szLastName, string szMiddleInitial, string szPhone, string szEmail, string szOrgUnit)
    {
        string szPassword = "fooBar_123";  //temp only.
        string szCNName = "CN=" + szUsername;
 
        try
        {
            DirectoryEntry objContainer = new DirectoryEntry("LDAP://OU=mySubOU,OU=myMainOU,DC=KEVINCORNWELL,DC=com");
            DirectoryEntry objUser = objContainer.Children.Add(szCNName.ToLower(), "user");
            objUser.Properties["sAMAccountName"].Value = szUsername;
            objUser.Properties["userPrincipalName"].Value = szUsername + "@KEVINCORNWELL.COM";
            objUser.Properties["displayName"].Value = szDisplayName;
            objUser.Properties["GivenName"].Value = szFirstName;
            objUser.Properties["sn"].Value = szLastName;
            objUser.Properties["Initials"].Value = szMiddleInitial;
            objUser.Properties["mail"].Value = szEmail;
            objUser.Properties["TelephoneNumber"].Value = szPhone;
            objUser.Properties["Description"].Value = szOrgUnit;
            objUser.CommitChanges();
            objUser.Invoke("SetPassword", szPassword);
            objUser.CommitChanges();
            int flags = (int)objUser.Properties["userAccountControl"].Value;
            objUser.Properties["userAccountControl"].Value = flags & ~0x2;  //Enable User Account
            objUser.Properties["pwdLastSet"].Value = 0;
            objUser.CommitChanges();
            return "";
        }
        catch (Exception ex)
        {
            return ex.InnerException + ex.Message + ex.Source + ex.StackTrace + ex.Data;
        }
    }

SharePoint WebPart Dev Tip

August 14th, 2007

This post has been moved to mySharePointBlog. Go Here.

SQL Server – How to combine 2 date and time columns into 1 column.

August 9th, 2007

Sample columns

date_col:

2007-05-06 00:00:00.000	

time_col:

1971-01-01 01:06:23.000

Use this…

DATEADD(hh ,DATEPART(hh, [time_col]]), DATEADD(n ,DATEPART(n, [time_col]) , DATEADD(ss ,DATEPART(ss, [time_col]) , [date_col])))

To get this…

2007-05-06 01:06:23.000

How to use the PeoplePicker in SharePoint

July 20th, 2007

This post has been moved to mySharePointBlog. Go Here.

Taskbar Shuffle

July 20th, 2007

Here is a sweet little app that allows you to shuffle your taskbar items. Go HERE

How to enable debugging in WSS 3.0

July 12th, 2007

This post has been moved to mySharePointBlog. Go Here.

SharePoint – Establishing Site Context

July 12th, 2007

Using SPContext and making a application globally availible